diff --git a/AI/Nullkiller/Goals/CompleteQuest.cpp b/AI/Nullkiller/Goals/CompleteQuest.cpp index 4a80dffc9..f774a2295 100644 --- a/AI/Nullkiller/Goals/CompleteQuest.cpp +++ b/AI/Nullkiller/Goals/CompleteQuest.cpp @@ -94,7 +94,7 @@ std::string CompleteQuest::questToString() const return "find " + VLC->generaltexth->tentColors[q.obj->subID] + " keymaster tent"; } - if(q.quest->questName == CQuest::missionName(0)) + if(q.quest->questName == CQuest::missionName(EQuestMission::NONE)) return "inactive quest"; MetaString ms; diff --git a/AI/VCAI/Goals/CompleteQuest.cpp b/AI/VCAI/Goals/CompleteQuest.cpp index f92560114..39fa64245 100644 --- a/AI/VCAI/Goals/CompleteQuest.cpp +++ b/AI/VCAI/Goals/CompleteQuest.cpp @@ -99,7 +99,7 @@ std::string CompleteQuest::completeMessage() const std::string CompleteQuest::questToString() const { - if(q.quest->questName == CQuest::missionName(0)) + if(q.quest->questName == CQuest::missionName(EQuestMission::NONE)) return "inactive quest"; MetaString ms; diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index 543d8c374..d2af457cf 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -569,7 +569,9 @@ CGeneralTextHandler::CGeneralTextHandler(): for (size_t i = 0; i < 9; ++i) //9 types of quests { - std::string questName = CQuest::missionName(1+i); + EQuestMission missionID = static_cast(i+1); + + std::string questName = CQuest::missionName(missionID); for (size_t j = 0; j < 5; ++j) { diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index 0188d1fc6..98084443c 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -49,7 +49,7 @@ CQuest::CQuest(): isCustomNext(false), isCustomComplete(false), repeatedQuest(false), - questName(CQuest::missionName(0)) + questName(CQuest::missionName(EQuestMission::NONE)) { } @@ -59,9 +59,9 @@ static std::string visitedTxt(const bool visited) return VLC->generaltexth->allTexts[id]; } -const std::string & CQuest::missionName(int mission) +const std::string & CQuest::missionName(EQuestMission mission) { - static const std::array names = { + static const std::array names = { "empty", "heroLevel", "primarySkill", @@ -72,9 +72,10 @@ const std::string & CQuest::missionName(int mission) "bringResources", "bringHero", "bringPlayer", + "hotaINVALID", // only used for h3m parsing "keymaster", - "hota", - "other" + "heroClass", + "reachDate" }; if(static_cast(mission) < names.size()) @@ -307,20 +308,18 @@ void CQuest::getCompletionText(IGameCallback * cb, MetaString &iwText) const void CQuest::defineQuestName() { //standard quests - questName = CQuest::missionName(0); - if(mission != Rewardable::Limiter{}) questName = CQuest::missionName(12); - if(mission.heroLevel > 0) questName = CQuest::missionName(1); - for(auto & s : mission.primary) if(s) questName = CQuest::missionName(2); - if(!mission.spells.empty()) questName = CQuest::missionName(2); - if(!mission.secondary.empty()) questName = CQuest::missionName(2); - if(killTarget != ObjectInstanceID::NONE && !heroName.empty()) questName = CQuest::missionName(3); - if(killTarget != ObjectInstanceID::NONE && stackToKill != CreatureID::NONE) questName = CQuest::missionName(4); - if(!mission.artifacts.empty()) questName = CQuest::missionName(5); - if(!mission.creatures.empty()) questName = CQuest::missionName(6); - if(mission.resources.nonZero()) questName = CQuest::missionName(7); - if(!mission.heroes.empty()) questName = CQuest::missionName(8); - if(!mission.players.empty()) questName = CQuest::missionName(9); - if(mission.daysPassed > 0 || !mission.heroClasses.empty()) questName = CQuest::missionName(11); + questName = CQuest::missionName(EQuestMission::NONE); + if(mission.heroLevel > 0) questName = CQuest::missionName(EQuestMission::LEVEL); + for(auto & s : mission.primary) if(s) questName = CQuest::missionName(EQuestMission::PRIMARY_SKILL); + if(killTarget != ObjectInstanceID::NONE && !heroName.empty()) questName = CQuest::missionName(EQuestMission::KILL_HERO); + if(killTarget != ObjectInstanceID::NONE && stackToKill != CreatureID::NONE) questName = CQuest::missionName(EQuestMission::KILL_CREATURE); + if(!mission.artifacts.empty()) questName = CQuest::missionName(EQuestMission::ARTIFACT); + if(!mission.creatures.empty()) questName = CQuest::missionName(EQuestMission::ARMY); + if(mission.resources.nonZero()) questName = CQuest::missionName(EQuestMission::RESOURCES); + if(!mission.heroes.empty()) questName = CQuest::missionName(EQuestMission::HERO); + if(!mission.players.empty()) questName = CQuest::missionName(EQuestMission::PLAYER); + if(mission.daysPassed > 0) questName = CQuest::missionName(EQuestMission::HOTA_REACH_DATE); + if(!mission.heroClasses.empty()) questName = CQuest::missionName(EQuestMission::HOTA_HERO_CLASS); } void CQuest::addKillTargetReplacements(MetaString &out) const @@ -466,7 +465,7 @@ void CGSeerHut::initObj(CRandomGenerator & rand) if(quest->mission == Rewardable::Limiter{} && quest->killTarget == ObjectInstanceID::NONE) quest->isCompleted = true; - if(quest->questName == quest->missionName(0)) + if(quest->questName == quest->missionName(EQuestMission::NONE)) { quest->firstVisitText.appendTextID(TextIdentifier("core", "seehut", "empty", quest->completedOption).get()); } diff --git a/lib/mapObjects/CQuest.h b/lib/mapObjects/CQuest.h index 5b9fb2220..69676584f 100644 --- a/lib/mapObjects/CQuest.h +++ b/lib/mapObjects/CQuest.h @@ -17,11 +17,30 @@ VCMI_LIB_NAMESPACE_BEGIN class CGCreature; +enum class EQuestMission { + NONE = 0, + LEVEL = 1, + PRIMARY_SKILL = 2, + KILL_HERO = 3, + KILL_CREATURE = 4, + ARTIFACT = 5, + ARMY = 6, + RESOURCES = 7, + HERO = 8, + PLAYER = 9, + HOTA_MULTI = 10, + // end of H3 missions + + KEYMASTER = 11, + HOTA_HERO_CLASS = 12, + HOTA_REACH_DATE = 13, +}; + class DLL_LINKAGE CQuest final { public: - static const std::string & missionName(int index); + static const std::string & missionName(EQuestMission index); static const std::string & missionState(int index); std::string questName; diff --git a/lib/mapping/MapFormatH3M.h b/lib/mapping/MapFormatH3M.h index 84100c45a..3cc3e93da 100644 --- a/lib/mapping/MapFormatH3M.h +++ b/lib/mapping/MapFormatH3M.h @@ -35,23 +35,7 @@ class SpellID; class PlayerColor; class int3; -enum class EQuestMission { - NONE = 0, - LEVEL = 1, - PRIMARY_SKILL = 2, - KILL_HERO = 3, - KILL_CREATURE = 4, - ARTIFACT = 5, - ARMY = 6, - RESOURCES = 7, - HERO = 8, - PLAYER = 9, - HOTA_MULTI = 10, - // end of H3 missions - KEYMASTER = 100, - HOTA_HERO_CLASS = 101, - HOTA_REACH_DATE = 102 -}; +enum class EQuestMission; enum class EVictoryConditionType : int8_t {