From e5719daf1152445a43a28a575046bf45ca9dbc36 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 6 Sep 2023 22:44:41 +0300 Subject: [PATCH] Added "vcmiartifacts angelWings" form to cheat --- server/PlayerMessageProcessor.cpp | 22 +++++++++++++++++----- server/PlayerMessageProcessor.h | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/PlayerMessageProcessor.cpp b/server/PlayerMessageProcessor.cpp index 268802a9a..f044c17b6 100644 --- a/server/PlayerMessageProcessor.cpp +++ b/server/PlayerMessageProcessor.cpp @@ -211,15 +211,27 @@ void PlayerMessageProcessor::cheatGiveMachines(PlayerColor player, const CGHeroI gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::FIRST_AID_TENT], ArtifactPosition::MACH3); } -void PlayerMessageProcessor::cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero) +void PlayerMessageProcessor::cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero, std::vector words) { if (!hero) return; - for(int g = 7; g < VLC->arth->objects.size(); ++g) //including artifacts from mods + if (!words.empty()) { - if(VLC->arth->objects[g]->canBePutAt(hero)) - gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[g], ArtifactPosition::FIRST_AVAILABLE); + for (auto const & word : words) + { + auto artID = VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "artifact", word, false); + if(artID && VLC->arth->objects[*artID]) + gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[*artID], ArtifactPosition::FIRST_AVAILABLE); + } + } + else + { + for(int g = 7; g < VLC->arth->objects.size(); ++g) //including artifacts from mods + { + if(VLC->arth->objects[g]->canBePutAt(hero)) + gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[g], ArtifactPosition::FIRST_AVAILABLE); + } } } @@ -432,7 +444,7 @@ void PlayerMessageProcessor::executeCheatCode(const std::string & cheatName, Pla const auto & doCheatGiveArmyCustom = [&]() { cheatGiveArmy(player, hero, words); }; const auto & doCheatGiveArmyFixed = [&](std::vector customWords) { cheatGiveArmy(player, hero, customWords); }; const auto & doCheatGiveMachines = [&]() { cheatGiveMachines(player, hero); }; - const auto & doCheatGiveArtifacts = [&]() { cheatGiveArtifacts(player, hero); }; + const auto & doCheatGiveArtifacts = [&]() { cheatGiveArtifacts(player, hero, words); }; const auto & doCheatLevelup = [&]() { cheatLevelup(player, hero, words); }; const auto & doCheatExperience = [&]() { cheatExperience(player, hero, words); }; const auto & doCheatMovement = [&]() { cheatMovement(player, hero, words); }; diff --git a/server/PlayerMessageProcessor.h b/server/PlayerMessageProcessor.h index 2351140ca..bb9335676 100644 --- a/server/PlayerMessageProcessor.h +++ b/server/PlayerMessageProcessor.h @@ -31,7 +31,7 @@ class PlayerMessageProcessor void cheatBuildTown(PlayerColor player, const CGTownInstance * town); void cheatGiveArmy(PlayerColor player, const CGHeroInstance * hero, std::vector words); void cheatGiveMachines(PlayerColor player, const CGHeroInstance * hero); - void cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero); + void cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero, std::vector words); void cheatLevelup(PlayerColor player, const CGHeroInstance * hero, std::vector words); void cheatExperience(PlayerColor player, const CGHeroInstance * hero, std::vector words); void cheatMovement(PlayerColor player, const CGHeroInstance * hero, std::vector words);