1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Fix discovered bugs from develop branch

This commit is contained in:
Ivan Savenko
2025-04-27 15:53:03 +03:00
parent a8a74888f7
commit 04c9e27ccd
3 changed files with 8 additions and 5 deletions

View File

@@ -1039,7 +1039,7 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
auto equipBest = [](const CGHeroInstance * h, const CGHeroInstance * otherh, bool giveStuffToFirstHero) -> void
{
bool changeMade = false;
std::set<std::pair<CArtifactInstance *, CArtifactInstance *> > swappedSet;
std::set<std::pair<ArtifactInstanceID, ArtifactInstanceID> > swappedSet;
do
{
changeMade = false;
@@ -1120,13 +1120,13 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
//combined artifacts are not always allowed to move
if(artifactScore > otherArtifactScore && artifact->canBePutAt(target, slot, true))
{
auto swapPair = std::minmax(artifact, otherSlot->artifact);
std::pair swapPair = std::minmax<ArtifactInstanceID>({artifact->getId(), otherSlot->artifactID});
if (swappedSet.find(swapPair) != swappedSet.end())
{
logAi->warn(
"Artifacts % s < -> % s have already swapped before, ignored.",
artifact->getType()->getJsonKey(),
otherSlot->artifact->getType()->getJsonKey());
otherSlot->getArt()->getType()->getJsonKey());
continue;
}
logAi->trace(

View File

@@ -171,6 +171,9 @@ JsonNode TimesStackLevelUpdater::toJsonNode() const
std::shared_ptr<Bonus> DivideStackLevelUpdater::apply(const std::shared_ptr<Bonus> & b, int level) const
{
if (level == 0)
return b; // e.g. war machines & other special units
auto newBonus = std::make_shared<Bonus>(*b);
newBonus->val /= level;
newBonus->updater = nullptr; // prevent double-apply

View File

@@ -1492,8 +1492,8 @@ void CGameHandler::throwNotAllowedAction(const std::shared_ptr<CConnection> & co
void CGameHandler::wrongPlayerMessage(const std::shared_ptr<CConnection> & connection, const CPackForServer * pack, PlayerColor expectedplayer)
{
auto str = MetaString::createFromTextID("vcmi.server.errors.wrongIdentified");
str.appendName(pack->player);
str.appendName(expectedplayer);
str.replaceName(pack->player);
str.replaceName(expectedplayer);
logNetwork->error(str.toString());
playerMessages->sendSystemMessage(connection, str);