1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Merge pull request #5335 from IvanSavenko/bugfixing_164

Fixes for bugs for 1.6.4
This commit is contained in:
Ivan Savenko 2025-01-26 19:08:25 +02:00 committed by GitHub
commit 64bb3099f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 41 additions and 19 deletions

View File

@ -164,10 +164,10 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
cb = CB; cb = CB;
env = ENV; env = ENV;
pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get()));
CCS->musich->loadTerrainMusicThemes(); CCS->musich->loadTerrainMusicThemes();
initializeHeroTownList(); initializeHeroTownList();
pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get()));
adventureInt.reset(new AdventureMapInterface()); adventureInt.reset(new AdventureMapInterface());
} }
@ -628,7 +628,6 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build
switch(what) switch(what)
{ {
case 1: case 1:
CCS->soundh->playSound(soundBase::newBuilding);
castleInt->addBuilding(buildingID); castleInt->addBuilding(buildingID);
break; break;
case 2: case 2:
@ -1415,7 +1414,6 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
&& LOCPLINT->castleInt && LOCPLINT->castleInt
&& obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation()) && obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation())
{ {
CCS->soundh->playSound(soundBase::newBuilding);
LOCPLINT->castleInt->addBuilding(BuildingID::SHIP); LOCPLINT->castleInt->addBuilding(BuildingID::SHIP);
} }
} }

View File

@ -171,7 +171,7 @@ void GlobalLobbyClient::receiveChatMessage(const JsonNode & json)
lobbyWindowPtr->onGameChatMessage(message.displayName, message.messageText, message.timeFormatted, channelType, channelName); lobbyWindowPtr->onGameChatMessage(message.displayName, message.messageText, message.timeFormatted, channelType, channelName);
lobbyWindowPtr->refreshChatText(); lobbyWindowPtr->refreshChatText();
if(channelType == "player" || lobbyWindowPtr->isChannelOpen(channelType, channelName)) if(channelType == "player" || (lobbyWindowPtr->isChannelOpen(channelType, channelName) && lobbyWindowPtr->isActive()))
CCS->soundh->playSound(AudioPath::builtin("CHAT")); CCS->soundh->playSound(AudioPath::builtin("CHAT"));
} }
} }

View File

@ -252,7 +252,7 @@ SDLImageShared::SDLImageShared(const SDLImageShared * from, int integerScaleFact
upscalingInProgress = true; upscalingInProgress = true;
auto scaler = std::make_shared<SDLImageScaler>(from->surf, Rect(from->margins, from->fullSize)); auto scaler = std::make_shared<SDLImageScaler>(from->surf, Rect(from->margins, from->fullSize), true);
const auto & scalingTask = [this, algorithm, scaler]() const auto & scalingTask = [this, algorithm, scaler]()
{ {
@ -278,7 +278,7 @@ std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size,
if (palette && surf->format->palette) if (palette && surf->format->palette)
SDL_SetSurfacePalette(surf, palette); SDL_SetSurfacePalette(surf, palette);
SDLImageScaler scaler(surf, Rect(margins, fullSize)); SDLImageScaler scaler(surf, Rect(margins, fullSize), true);
scaler.scaleSurface(size, EScalingAlgorithm::XBRZ_ALPHA); scaler.scaleSurface(size, EScalingAlgorithm::XBRZ_ALPHA);

View File

@ -196,16 +196,25 @@ void SDLImageScaler::scaleSurfaceIntegerFactor(int factor, EScalingAlgorithm alg
} }
SDLImageScaler::SDLImageScaler(SDL_Surface * surf) SDLImageScaler::SDLImageScaler(SDL_Surface * surf)
:SDLImageScaler(surf, Rect(0,0,surf->w, surf->h)) :SDLImageScaler(surf, Rect(0,0,surf->w, surf->h), false)
{ {
} }
SDLImageScaler::SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions) SDLImageScaler::SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions, bool optimizeImage)
{ {
if (optimizeImage)
{
SDLImageOptimizer optimizer(surf, virtualDimensions); SDLImageOptimizer optimizer(surf, virtualDimensions);
optimizer.optimizeSurface(screen); optimizer.optimizeSurface(screen);
intermediate = optimizer.acquireResultSurface(); intermediate = optimizer.acquireResultSurface();
virtualDimensionsInput = optimizer.getResultDimensions(); virtualDimensionsInput = optimizer.getResultDimensions();
}
else
{
intermediate = surf;
intermediate->refcount += 1;
virtualDimensionsInput = virtualDimensions;
}
if (intermediate == surf) if (intermediate == surf)
{ {

View File

@ -43,7 +43,7 @@ class SDLImageScaler : boost::noncopyable
public: public:
SDLImageScaler(SDL_Surface * surf); SDLImageScaler(SDL_Surface * surf);
SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions); SDLImageScaler(SDL_Surface * surf, const Rect & virtualDimensions, bool optimizeImage);
~SDLImageScaler(); ~SDLImageScaler();
/// Performs upscaling or downscaling to a requested dimensions /// Performs upscaling or downscaling to a requested dimensions

View File

@ -24,6 +24,7 @@
#include "../gui/Shortcut.h" #include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h" #include "../gui/WindowHandler.h"
#include "../media/IMusicPlayer.h" #include "../media/IMusicPlayer.h"
#include "../media/ISoundPlayer.h"
#include "../widgets/MiscWidgets.h" #include "../widgets/MiscWidgets.h"
#include "../widgets/CComponent.h" #include "../widgets/CComponent.h"
#include "../widgets/CGarrisonInt.h" #include "../widgets/CGarrisonInt.h"
@ -1435,6 +1436,9 @@ void CCastleInterface::townChange()
void CCastleInterface::addBuilding(BuildingID bid) void CCastleInterface::addBuilding(BuildingID bid)
{ {
if (town->getTown()->buildings.at(bid)->mode != CBuilding::BUILD_AUTO)
CCS->soundh->playSound(soundBase::newBuilding);
deactivate(); deactivate();
builds->addBuilding(bid); builds->addBuilding(bid);
recreateIcons(); recreateIcons();

View File

@ -48,6 +48,10 @@
{ {
"type" : "SHOOTER" "type" : "SHOOTER"
}, },
"noDistancePenalty" :
{
"type" : "NO_DISTANCE_PENALTY" // hide shooting range visualization
},
"siegeMachine" : "siegeMachine" :
{ {
"type" : "CATAPULT", "type" : "CATAPULT",

View File

@ -267,6 +267,12 @@ public:
return hex < other.hex; return hex < other.hex;
} }
[[nodiscard]] bool operator <=(const BattleHex & other) const noexcept
{
return hex <= other.hex;
}
template <typename Handler> template <typename Handler>
void serialize(Handler & h) void serialize(Handler & h)
{ {

View File

@ -51,7 +51,7 @@ static bool sameSideOfWall(const BattleHex & pos1, const BattleHex & pos2)
static bool isInsideWalls(const BattleHex & pos) static bool isInsideWalls(const BattleHex & pos)
{ {
return lineToWallHex(pos.getY()) < pos; return lineToWallHex(pos.getY()) <= pos;
} }
// parts of wall // parts of wall

View File

@ -605,17 +605,18 @@ uint8_t CUnitState::getRangedFullDamageDistance() const
if(!isShooter()) if(!isShooter())
return 0; return 0;
uint8_t rangedFullDamageDistance = GameConstants::BATTLE_SHOOTING_PENALTY_DISTANCE;
// overwrite full ranged damage distance with the value set in Additional info field of LIMITED_SHOOTING_RANGE bonus // overwrite full ranged damage distance with the value set in Additional info field of LIMITED_SHOOTING_RANGE bonus
if(hasBonusOfType(BonusType::LIMITED_SHOOTING_RANGE)) if(hasBonusOfType(BonusType::LIMITED_SHOOTING_RANGE))
{ {
auto bonus = this->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE)); auto bonus = this->getBonus(Selector::type()(BonusType::LIMITED_SHOOTING_RANGE));
if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE) if(bonus != nullptr && bonus->additionalInfo != CAddInfo::NONE)
rangedFullDamageDistance = bonus->additionalInfo[0]; return bonus->additionalInfo[0];
} }
return rangedFullDamageDistance; if (hasBonusOfType(BonusType::NO_DISTANCE_PENALTY))
return GameConstants::BATTLE_SHOOTING_RANGE_DISTANCE;
return GameConstants::BATTLE_SHOOTING_PENALTY_DISTANCE;
} }
uint8_t CUnitState::getShootingRangeDistance() const uint8_t CUnitState::getShootingRangeDistance() const

View File

@ -325,7 +325,7 @@ void LobbyServer::onDisconnected(const NetworkConnectionPtr & connection, const
if(activeProxies.count(connection)) if(activeProxies.count(connection))
{ {
const auto & otherConnection = activeProxies.at(connection); const auto otherConnection = activeProxies.at(connection);
if (otherConnection) if (otherConnection)
otherConnection->close(); otherConnection->close();