diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 55a5029a3..f7b17e2f1 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -1056,7 +1056,8 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance if(location.slot == ArtifactPosition::MACH4) // don't attempt to move catapult continue; - auto s = cb->getHero(location.artHolder)->getSlot(location.slot); + auto artHolder = cb->getHero(location.artHolder); + auto s = artHolder->getSlot(location.slot); if(!s || s->locked) //we can't move locks continue; auto artifact = s->artifact; @@ -1084,10 +1085,27 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance if(otherSlot && otherSlot->artifact) //we need to exchange artifact for better one { //if that artifact is better than what we have, pick it - if(compareArtifacts(artifact, otherSlot->artifact) && artifact->canBePutAt(target, slot, true)) //combined artifacts are not always allowed to move + if(compareArtifacts(artifact, otherSlot->artifact) + && artifact->canBePutAt(target, slot, true)) //combined artifacts are not always allowed to move { - ArtifactLocation destLocation(target->id, slot); - cb->swapArtifacts(location, ArtifactLocation(target->id, target->getArtPos(otherSlot->artifact))); + logAi->trace( + "Exchange artifacts %s <-> %s", + artifact->artType->getNameTranslated(), + otherSlot->artifact->artType->getNameTranslated()); + + if(!otherSlot->artifact->canBePutAt(artHolder, location.slot, true)) + { + ArtifactLocation destLocation(target->id, slot); + ArtifactLocation backpack(artHolder->id, ArtifactPosition::BACKPACK_START); + + cb->swapArtifacts(destLocation, backpack); + cb->swapArtifacts(location, destLocation); + } + else + { + cb->swapArtifacts(location, ArtifactLocation(target->id, target->getArtPos(otherSlot->artifact))); + } + changeMade = true; break; } diff --git a/client/ClientCommandManager.cpp b/client/ClientCommandManager.cpp index 12636ed35..39a5aabdf 100644 --- a/client/ClientCommandManager.cpp +++ b/client/ClientCommandManager.cpp @@ -136,8 +136,9 @@ void ClientCommandManager::handleControlaiCommand(std::istringstream& singleWord for(auto & elem : CSH->client->gameState()->players) { - if(elem.second.human || - (colorName.length() && elem.first.getNum() != vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, colorName))) + if(!elem.first.isValidPlayer() + || elem.second.human + || (colorName.length() && elem.first.getNum() != vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, colorName))) { continue; } diff --git a/lib/modding/ActiveModsInSaveList.cpp b/lib/modding/ActiveModsInSaveList.cpp index b7b03577a..17e8927f0 100644 --- a/lib/modding/ActiveModsInSaveList.cpp +++ b/lib/modding/ActiveModsInSaveList.cpp @@ -47,7 +47,7 @@ void ActiveModsInSaveList::verifyActiveMods(const std::mapmodh->getModInfo(compared.first).getVerificationInfo().name); if (compared.second == ModVerificationStatus::EXCESSIVE) - excessiveMods.push_back(modList.at(compared.first).name); + excessiveMods.push_back(VLC->modh->getModInfo(compared.first).getVerificationInfo().name); } if(!missingMods.empty() || !excessiveMods.empty())