1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

Explicitly convert identifier to underlying enumeration

This commit is contained in:
Ivan Savenko 2023-11-02 16:29:59 +02:00
parent 87f6c7354b
commit 2b9c362d5b
17 changed files with 30 additions and 30 deletions

View File

@ -167,7 +167,7 @@ bool CArtifact::isBig() const
bool CArtifact::isTradable() const
{
switch(id)
switch(id.getNum())
{
case ArtifactID::SPELLBOOK:
case ArtifactID::GRAIL:

View File

@ -686,7 +686,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
//MODS COMPATIBILITY FOR 0.96
if(!ret->produce.nonZero())
{
switch (ret->bid) {
switch (ret->bid.getNum()) {
break; case BuildingID::VILLAGE_HALL: ret->produce[EGameResID::GOLD] = 500;
break; case BuildingID::TOWN_HALL : ret->produce[EGameResID::GOLD] = 1000;
break; case BuildingID::CITY_HALL : ret->produce[EGameResID::GOLD] = 2000;

View File

@ -1663,7 +1663,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
|| !(spellID.toSpell()->canBeCast(this, spells::Mode::CREATURE_ACTIVE, subject)))
continue;
switch (spellID)
switch (spellID.toEnum())
{
case SpellID::SHIELD:
case SpellID::FIRE_SHIELD: // not if all enemy units are shooters

View File

@ -18,7 +18,7 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army
hero = Hero;
armyObject = Army;
switch(armyObject->ID)
switch(armyObject->ID.toEnum())
{
case Obj::CREATURE_GENERATOR1:
case Obj::CREATURE_GENERATOR2:

View File

@ -931,7 +931,7 @@ void CGameState::initMapObjects()
if(!obj)
continue;
switch (obj->ID)
switch (obj->ID.getNum())
{
case Obj::QUEST_GUARD:
case Obj::SEER_HUT:

View File

@ -137,7 +137,7 @@ void CBank::onHeroVisit(const CGHeroInstance * h) const
cb->sendAndApply(&cov);
int banktext = 0;
switch (ID)
switch (ID.toEnum())
{
case Obj::DERELICT_SHIP:
banktext = 41;
@ -180,7 +180,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
if (bc)
{
switch (ID)
switch (ID.toEnum())
{
case Obj::DERELICT_SHIP:
textID = 43;
@ -203,7 +203,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
}
else
{
switch (ID)
switch (ID.toEnum())
{
case Obj::SHIPWRECK:
case Obj::DERELICT_SHIP:
@ -216,7 +216,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
gbonus.bonus.sid = BonusSourceID(ID);
gbonus.bonus.type = BonusType::MORALE;
gbonus.bonus.val = -1;
switch (ID)
switch (ID.toEnum())
{
case Obj::SHIPWRECK:
textID = 123;

View File

@ -161,7 +161,7 @@ CreatureID CGCreature::getCreature() const
void CGCreature::pickRandomObject(CRandomGenerator & rand)
{
switch(ID)
switch(ID.toEnum())
{
case MapObjectID::RANDOM_MONSTER:
subID = VLC->creh->pickRandomMonster(rand);

View File

@ -170,7 +170,7 @@ void CGDwelling::pickRandomObject(CRandomGenerator & rand)
void CGDwelling::initObj(CRandomGenerator & rand)
{
switch(ID)
switch(ID.toEnum())
{
case Obj::CREATURE_GENERATOR1:
case Obj::CREATURE_GENERATOR4:
@ -488,7 +488,7 @@ void CGDwelling::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer)
void CGDwelling::serializeJsonOptions(JsonSerializeFormat & handler)
{
switch (ID)
switch (ID.toEnum())
{
case Obj::WAR_MACHINE_FACTORY:
case Obj::REFUGEE_CAMP:

View File

@ -173,7 +173,7 @@ void CGObjectInstance::pickRandomObject(CRandomGenerator & rand)
void CGObjectInstance::initObj(CRandomGenerator & rand)
{
switch(ID)
switch(ID.toEnum())
{
case Obj::TAVERN:
blockVisit = true;
@ -302,7 +302,7 @@ std::vector<Component> CGObjectInstance::getPopupComponents(const CGHeroInstance
void CGObjectInstance::onHeroVisit( const CGHeroInstance * h ) const
{
switch(ID)
switch(ID.toEnum())
{
case Obj::SANCTUARY:
{

View File

@ -273,7 +273,7 @@ void CGResource::initObj(CRandomGenerator & rand)
if(amount == CGResource::RANDOM_AMOUNT)
{
switch(resourceID())
switch(resourceID().toEnum())
{
case EGameResID::GOLD:
amount = rand.nextInt(5, 10) * 100;
@ -532,7 +532,7 @@ void CGMonolith::initObj(CRandomGenerator & rand)
{
std::vector<Obj> IDs;
IDs.push_back(ID);
switch(ID)
switch(ID.toEnum())
{
case Obj::MONOLITH_ONE_WAY_ENTRANCE:
type = ENTRANCE;
@ -723,7 +723,7 @@ ArtifactID CGArtifact::getArtifact() const
void CGArtifact::pickRandomObject(CRandomGenerator & rand)
{
switch(ID)
switch(ID.toEnum())
{
case MapObjectID::RANDOM_ART:
subID = VLC->arth->pickRandomArtifact(rand, CArtifact::ART_TREASURE | CArtifact::ART_MINOR | CArtifact::ART_MAJOR | CArtifact::ART_RELIC);
@ -786,7 +786,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
if(storedArtifact->artType->canBePutAt(h))
{
switch (ID)
switch (ID.toEnum())
{
case Obj::ARTIFACT:
{
@ -821,7 +821,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
}
else
{
switch(ID)
switch(ID.toEnum())
{
case Obj::ARTIFACT:
{

View File

@ -1488,7 +1488,7 @@ CGObjectInstance * CMapLoaderH3M::readBank(const int3 & mapPosition, std::shared
CGObjectInstance * CMapLoaderH3M::readObject(std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & mapPosition, const ObjectInstanceID & objectInstanceID)
{
switch(objectTemplate->id)
switch(objectTemplate->id.toEnum())
{
case Obj::EVENT:
return readEvent(mapPosition, objectInstanceID);

View File

@ -944,7 +944,7 @@ void FoWChange::applyGs(CGameState *gs)
const CGObjectInstance *o = elem;
if (o)
{
switch(o->ID)
switch(o->ID.toEnum())
{
case Obj::HERO:
case Obj::MINE:

View File

@ -302,7 +302,7 @@ bool CPathfinder::isLayerTransitionPossible() const
if(source.node->action == EPathNodeAction::BATTLE)
return false;
switch(source.node->layer)
switch(source.node->layer.toEnum())
{
case ELayer::LAND:
if(destLayer == ELayer::AIR)
@ -505,7 +505,7 @@ void CPathfinderHelper::updateTurnInfo(const int Turn)
bool CPathfinderHelper::isLayerAvailable(const EPathfindingLayer & layer) const
{
switch(layer)
switch(layer.getNum())
{
case EPathfindingLayer::AIR:
if(!options.useFlying)

View File

@ -123,7 +123,7 @@ void DestinationActionRule::process(
EPathNodeAction action = EPathNodeAction::NORMAL;
const auto * hero = pathfinderHelper->hero;
switch(destination.node->layer)
switch(destination.node->layer.toEnum())
{
case EPathfindingLayer::LAND:
if(source.node->layer == EPathfindingLayer::SAIL)
@ -290,7 +290,7 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea
if(destination.node->accessible == EPathAccessibility::BLOCKED)
return BlockingReason::DESTINATION_BLOCKED;
switch(destination.node->layer)
switch(destination.node->layer.toEnum())
{
case EPathfindingLayer::LAND:
if(!pathfinderHelper->canMoveBetween(source.coord, destination.coord))
@ -359,7 +359,7 @@ void LayerTransitionRule::process(
if(source.node->layer == destination.node->layer)
return;
switch(source.node->layer)
switch(source.node->layer.toEnum())
{
case EPathfindingLayer::LAND:
if(destination.node->layer == EPathfindingLayer::SAIL)

View File

@ -47,7 +47,7 @@ TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn):
bool TurnInfo::isLayerAvailable(const EPathfindingLayer & layer) const
{
switch(layer)
switch(layer.toEnum())
{
case EPathfindingLayer::AIR:
if(hero && hero->boat && hero->boat->layer == EPathfindingLayer::AIR)

View File

@ -556,7 +556,7 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD
}
}
switch (instance->object().ID)
switch (instance->object().ID.getNum())
{
case Obj::RANDOM_TREASURE_ART:
case Obj::RANDOM_MINOR_ART: //In OH3 quest artifacts have higher value than normal arts
@ -586,7 +586,7 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD
case Obj::MONOLITH_ONE_WAY_EXIT:
*/
switch (object.instances().front()->object().ID)
switch (object.instances().front()->object().ID.getNum())
{
case Obj::WATER_WHEEL:
if (auto* m = zone.getModificator<RiverPlacer>())

View File

@ -717,7 +717,7 @@ IAdventureSpellMechanics::IAdventureSpellMechanics(const CSpell * s)
std::unique_ptr<IAdventureSpellMechanics> IAdventureSpellMechanics::createMechanics(const CSpell * s)
{
switch (s->id)
switch (s->id.getNum())
{
case SpellID::SUMMON_BOAT:
return std::make_unique<SummonBoatMechanics>(s);