From eb577a03b51439f6cd7ce35e88a7f83eaff548c7 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Mon, 1 May 2023 15:29:56 +0400 Subject: [PATCH] Deprecating enum constants --- AI/Nullkiller/Engine/PriorityEvaluator.cpp | 8 ++++++-- AI/VCAI/Goals/CollectRes.cpp | 13 ++++++++----- config/objects/generic.json | 12 ++++++------ lib/GameConstants.h | 12 ++++++------ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index fcc7d291d..352281429 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -297,6 +297,12 @@ int RewardEvaluator::getGoldCost(const CGObjectInstance * target, const CGHeroIn { if(!target) return 0; + + if(auto * m = dynamic_cast(target)) + { + if(m->allowsTrade(EMarketMode::RESOURCE_SKILL)) + return 2000; + } switch(target->ID) { @@ -305,8 +311,6 @@ int RewardEvaluator::getGoldCost(const CGObjectInstance * target, const CGHeroIn case Obj::SCHOOL_OF_MAGIC: case Obj::SCHOOL_OF_WAR: return 1000; - case Obj::UNIVERSITY: - return 2000; case Obj::CREATURE_GENERATOR1: case Obj::CREATURE_GENERATOR2: case Obj::CREATURE_GENERATOR3: diff --git a/AI/VCAI/Goals/CollectRes.cpp b/AI/VCAI/Goals/CollectRes.cpp index 2e7c21fa7..2fed89549 100644 --- a/AI/VCAI/Goals/CollectRes.cpp +++ b/AI/VCAI/Goals/CollectRes.cpp @@ -131,13 +131,16 @@ TSubgoal CollectRes::whatToDoToTrade() std::vector visObjs; ai->retrieveVisitableObjs(visObjs, true); - for (const CGObjectInstance * obj : visObjs) + for(const CGObjectInstance * obj : visObjs) { - if (const IMarket * m = IMarket::castFrom(obj, false)) + if(const IMarket * m = IMarket::castFrom(obj, false); m->allowsTrade(EMarketMode::RESOURCE_RESOURCE)) { - if (obj->ID == Obj::TOWN && obj->tempOwner == ai->playerID && m->allowsTrade(EMarketMode::RESOURCE_RESOURCE)) - markets.push_back(m); - else if (obj->ID == Obj::TRADING_POST) + if(obj->ID == Obj::TOWN) + { + if(obj->tempOwner == ai->playerID) + markets.push_back(m); + } + else markets.push_back(m); } } diff --git a/config/objects/generic.json b/config/objects/generic.json index c20e0b137..e147427da 100644 --- a/config/objects/generic.json +++ b/config/objects/generic.json @@ -15,7 +15,7 @@ }, "altarOfSacrifice" : { - "index" :2, + "index" :2, //deprecated "handler" : "market", "base" : { "sounds" : { @@ -36,7 +36,7 @@ } }, "tradingPost" : { - "index" :221, + "index" :221, //deprecated "handler" : "market", "base" : { "sounds" : { @@ -60,7 +60,7 @@ } }, "tradingPostDUPLICATE" : { - "index" :99, + "index" :99, //deprecated "handler" : "market", "base" : { "sounds" : { @@ -84,7 +84,7 @@ } }, "freelancersGuild" : { - "index" :213, + "index" :213, //deprecated "handler" : "market", "types" : { "object" : { @@ -101,7 +101,7 @@ }, "blackMarket" : { - "index" :7, + "index" :7, //deprecated "handler" : "market", "base" : { "sounds" : { @@ -545,7 +545,7 @@ } }, "university" : { - "index" :104, + "index" :104, //deprecated "handler" : "market", "base" : { "sounds" : { diff --git a/lib/GameConstants.h b/lib/GameConstants.h index 5f22f9475..2b909a031 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -763,12 +763,12 @@ public: enum EObj { NO_OBJ = -1, - ALTAR_OF_SACRIFICE = 2, + ALTAR_OF_SACRIFICE [[deprecated]] = 2, ANCHOR_POINT = 3, ARENA = 4, ARTIFACT = 5, PANDORAS_BOX = 6, - BLACK_MARKET = 7, + BLACK_MARKET [[deprecated]] = 7, BOAT = 8, BORDERGUARD = 9, KEYMASTER = 10, @@ -860,12 +860,12 @@ public: TEMPLE = 96, DEN_OF_THIEVES = 97, TOWN = 98, - TRADING_POST = 99, + TRADING_POST [[deprecated]] = 99, LEARNING_STONE = 100, TREASURE_CHEST = 101, TREE_OF_KNOWLEDGE = 102, SUBTERRANEAN_GATE = 103, - UNIVERSITY = 104, + UNIVERSITY [[deprecated]] = 104, WAGON = 105, WAR_MACHINE_FACTORY = 106, SCHOOL_OF_WAR = 107, @@ -880,7 +880,7 @@ public: RANDOM_MONSTER_L6 = 163, RANDOM_MONSTER_L7 = 164, BORDER_GATE = 212, - FREELANCERS_GUILD = 213, + FREELANCERS_GUILD [[deprecated]] = 213, HERO_PLACEHOLDER = 214, QUEST_GUARD = 215, RANDOM_DWELLING = 216, @@ -888,7 +888,7 @@ public: RANDOM_DWELLING_FACTION = 218, //subtype = faction GARRISON2 = 219, ABANDONED_MINE = 220, - TRADING_POST_SNOW = 221, + TRADING_POST_SNOW [[deprecated]] = 221, CLOVER_FIELD = 222, CURSED_GROUND2 = 223, EVIL_FOG = 224,