From a59e12ca5f5a22885c98e8d897b1104326747e6f Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Mon, 15 Feb 2021 15:03:32 +0300 Subject: [PATCH] tweaks --- AI/BattleAI/BattleAI.cpp | 8 ++++---- client/widgets/CComponent.cpp | 6 ++++-- lib/CArtHandler.cpp | 6 +++--- lib/mapObjects/CGTownInstance.cpp | 2 +- lib/mapObjects/CQuest.cpp | 3 ++- lib/mapObjects/MiscObjects.cpp | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/AI/BattleAI/BattleAI.cpp b/AI/BattleAI/BattleAI.cpp index 98e94495e..bfd8d010f 100644 --- a/AI/BattleAI/BattleAI.cpp +++ b/AI/BattleAI/BattleAI.cpp @@ -18,7 +18,7 @@ #include "../../lib/spells/CSpellHandler.h" #include "../../lib/spells/ISpellMechanics.h" #include "../../lib/CStack.h" // TODO: remove - // Eventually only IBattleInfoCallback and battle::Unit should be used, + // Eventually only IBattleInfoCallback and battle::Unit should be used, // CUnitState should be private and CStack should be removed completely #define LOGL(text) print(text) @@ -43,14 +43,14 @@ SpellTypes spellType(const CSpell * spell) std::vector CBattleAI::getBrokenWallMoatHexes() const { std::vector result; - + for(int wallPart = EWallPart::BOTTOM_WALL; wallPart < EWallPart::UPPER_WALL; wallPart++) { auto state = cb->battleGetWallState(wallPart); if(state != EWallState::DESTROYED) continue; - + auto wallHex = cb->wallPartToBattleHex((EWallPart::EWallPart)wallPart); auto moatHex = wallHex.cloneInDirection(BattleHex::LEFT); @@ -311,7 +311,7 @@ BattleAction CBattleAI::useCatapult(const CStack * stack) if(cb->battleGetGateState() == EGateState::CLOSED) { targetHex = cb->wallPartToBattleHex(EWallPart::GATE); -} + } else { EWallPart::EWallPart wallParts[] = { diff --git a/client/widgets/CComponent.cpp b/client/widgets/CComponent.cpp index b2fbb26fa..e5850d6ca 100644 --- a/client/widgets/CComponent.cpp +++ b/client/widgets/CComponent.cpp @@ -10,6 +10,9 @@ #include "StdInc.h" #include "CComponent.h" +#include +#include + #include "../gui/CGuiHandler.h" #include "../gui/CCursorHandler.h" @@ -23,7 +26,6 @@ #include "../../lib/CTownHandler.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/CSkillHandler.h" -#include "../../lib/spells/CSpellHandler.h" #include "../../lib/CGeneralTextHandler.h" #include "../../lib/NetPacksBase.h" @@ -164,7 +166,7 @@ std::string CComponent::getDescription() return art->getEffectiveDescription(); } case experience: return CGI->generaltexth->allTexts[241]; - case spell: return CGI->spellh->objects[subtype]->getLevelDescription(val); + case spell: return SpellID(subtype).toSpell(CGI->spells())->getLevelDescription(val); case morale: return CGI->generaltexth->heroscrn[ 4 - (val>0) + (val<0)]; case luck: return CGI->generaltexth->heroscrn[ 7 - (val>0) + (val<0)]; case building: return (*CGI->townh)[subtype]->town->buildings[BuildingID(val)]->Description(); diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index 3ea4364be..9aac2aebd 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -761,13 +761,13 @@ std::string CArtifactInstance::getEffectiveDescription(const CGHeroInstance * he // we expect scroll description to be like this: This scroll contains the [spell name] spell which is added into your spell book for as long as you carry the scroll. // so we want to replace text in [...] with a spell name // however other language versions don't have name placeholder at all, so we have to be careful - int32_t spellID = getGivenSpellID(); + SpellID spellID = getGivenSpellID(); size_t nameStart = text.find_first_of('['); size_t nameEnd = text.find_first_of(']', nameStart); - if(spellID >= 0) + if(spellID.getNum() >= 0) { if(nameStart != std::string::npos && nameEnd != std::string::npos) - text = text.replace(nameStart, nameEnd - nameStart + 1, VLC->spellh->objects[spellID]->name); + text = text.replace(nameStart, nameEnd - nameStart + 1, spellID.toSpell(VLC->spells())->getName()); } } else if(hero && artType->constituentOf.size()) //display info about set diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 711b36a3b..1d5891668 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -938,7 +938,7 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const { //give resources if there's a Mystic Pond if (hasBuilt(BuildingSubID::MYSTIC_POND) - && cb->getDate(Date::DAY) != 1 + && cb->getDate(Date::DAY) != 1 && (tempOwner < PlayerColor::PLAYER_LIMIT) ) { diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index 5bd5deca5..abcec6022 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -11,6 +11,8 @@ #include "StdInc.h" #include "CQuest.h" +#include + #include "../NetPacks.h" #include "../CSoundBase.h" #include "../CGeneralTextHandler.h" @@ -23,7 +25,6 @@ #include "../CModHandler.h" #include "../GameConstants.h" #include "../StringConstants.h" -#include "../spells/CSpellHandler.h" #include "../CSkillHandler.h" #include "../mapping/CMap.h" diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index ab2b90ea0..ba3dcd574 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1773,7 +1773,7 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler) handler.serializeString("rewardSkill", value); break; case SPELL: - value = VLC->spellh->objects.at(bonusID)->identifier; + value = SpellID::encode(bonusID); handler.serializeString("rewardSpell", value); break; case RANDOM: