mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Remove int <=> Identifier comparisons
This commit is contained in:
parent
885dce0c27
commit
3634fb2158
@ -96,7 +96,7 @@ FactionID CGDwelling::randomizeFaction(CRandomGenerator & rand)
|
||||
|
||||
std::vector<FactionID> potentialPicks;
|
||||
|
||||
for (FactionID faction(0); faction < VLC->townh->size(); ++faction)
|
||||
for (FactionID faction(0); faction < FactionID(VLC->townh->size()); ++faction)
|
||||
if (VLC->factions()->getById(faction)->hasTown())
|
||||
potentialPicks.push_back(faction);
|
||||
|
||||
|
@ -372,7 +372,7 @@ bool CGTownInstance::isBonusingBuildingAdded(BuildingID bid) const
|
||||
{
|
||||
auto present = std::find_if(bonusingBuildings.begin(), bonusingBuildings.end(), [&](CGTownBuilding* building)
|
||||
{
|
||||
return building->getBuildingType().num == bid;
|
||||
return building->getBuildingType() == bid;
|
||||
});
|
||||
|
||||
return present != bonusingBuildings.end();
|
||||
@ -470,7 +470,7 @@ FactionID CGTownInstance::randomizeFaction(CRandomGenerator & rand)
|
||||
|
||||
std::vector<FactionID> potentialPicks;
|
||||
|
||||
for (FactionID faction(0); faction < VLC->townh->size(); ++faction)
|
||||
for (FactionID faction(0); faction < FactionID(VLC->townh->size()); ++faction)
|
||||
if (VLC->factions()->getById(faction)->hasTown())
|
||||
potentialPicks.push_back(faction);
|
||||
|
||||
@ -996,9 +996,9 @@ bool CGTownInstance::hasBuilt(const BuildingID & buildingID) const
|
||||
return vstd::contains(builtBuildings, buildingID);
|
||||
}
|
||||
|
||||
bool CGTownInstance::hasBuilt(const BuildingID & buildingID, int townID) const
|
||||
bool CGTownInstance::hasBuilt(const BuildingID & buildingID, FactionID townID) const
|
||||
{
|
||||
if (townID == town->faction->getIndex() || townID == ETownType::ANY)
|
||||
if (townID == town->faction->getId() || townID == FactionID::ANY)
|
||||
return hasBuilt(buildingID);
|
||||
return false;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
bool hasBuilt(BuildingSubID::EBuildingSubID buildingID) const;
|
||||
//checks if building is constructed and town has same subID
|
||||
bool hasBuilt(const BuildingID & buildingID) const;
|
||||
bool hasBuilt(const BuildingID & buildingID, int townID) const;
|
||||
bool hasBuilt(const BuildingID & buildingID, FactionID townID) const;
|
||||
|
||||
TResources getBuildingCost(const BuildingID & buildingID) const;
|
||||
TResources dailyIncome() const; //calculates daily income of this town
|
||||
|
@ -34,7 +34,7 @@
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
std::map <PlayerColor, std::set <ui8> > CGKeys::playerKeyMap;
|
||||
std::map <PlayerColor, std::set <MapObjectSubID> > CGKeys::playerKeyMap;
|
||||
|
||||
//TODO: Remove constructor
|
||||
CQuest::CQuest():
|
||||
@ -724,7 +724,7 @@ void CGQuestGuard::init(CRandomGenerator & rand)
|
||||
|
||||
configuration.info.push_back({});
|
||||
configuration.info.back().visitType = Rewardable::EEventType::EVENT_FIRST_VISIT;
|
||||
configuration.info.back().reward.removeObject = subID == 0 ? true : false;
|
||||
configuration.info.back().reward.removeObject = subID.getNum() == 0 ? true : false;
|
||||
configuration.canRefuse = true;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ protected:
|
||||
class DLL_LINKAGE CGKeys : public CGObjectInstance //Base class for Keymaster and guards
|
||||
{
|
||||
public:
|
||||
static std::map <PlayerColor, std::set <ui8> > playerKeyMap; //[players][keysowned]
|
||||
static std::map <PlayerColor, std::set <MapObjectSubID> > playerKeyMap; //[players][keysowned]
|
||||
//SubID 0 - lightblue, 1 - green, 2 - red, 3 - darkblue, 4 - brown, 5 - purple, 6 - white, 7 - black
|
||||
|
||||
static void reset();
|
||||
|
@ -126,7 +126,7 @@ void CGMine::initObj(CRandomGenerator & rand)
|
||||
|
||||
bool CGMine::isAbandoned() const
|
||||
{
|
||||
return (getObjTypeIndex() >= 7);
|
||||
return subID.getNum() >= 7;
|
||||
}
|
||||
|
||||
ResourceSet CGMine::dailyIncome() const
|
||||
@ -467,7 +467,7 @@ void CGTeleport::addToChannel(std::map<TeleportChannelID, std::shared_ptr<Telepo
|
||||
}
|
||||
}
|
||||
|
||||
TeleportChannelID CGMonolith::findMeChannel(const std::vector<Obj> & IDs, int SubID) const
|
||||
TeleportChannelID CGMonolith::findMeChannel(const std::vector<Obj> & IDs, MapObjectSubID SubID) const
|
||||
{
|
||||
for(auto obj : cb->gameState()->map->objects)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ public:
|
||||
|
||||
class DLL_LINKAGE CGMonolith : public CGTeleport
|
||||
{
|
||||
TeleportChannelID findMeChannel(const std::vector<Obj> & IDs, int SubID) const;
|
||||
TeleportChannelID findMeChannel(const std::vector<Obj> & IDs, MapObjectSubID SubID) const;
|
||||
|
||||
protected:
|
||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||
|
@ -245,7 +245,7 @@ void CMap::calculateGuardingGreaturePositions()
|
||||
CGHeroInstance * CMap::getHero(HeroTypeID heroID)
|
||||
{
|
||||
for(auto & elem : heroesOnMap)
|
||||
if(elem->getObjTypeIndex() == heroID.getNum())
|
||||
if(elem->getHeroType() == heroID)
|
||||
return elem;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ CGObjectInstance * CMapLoaderH3M::readResource(const int3 & mapPosition, std::sh
|
||||
readMessageAndGuards(object->message, object, mapPosition);
|
||||
|
||||
object->amount = reader->readUInt32();
|
||||
if(objectTemplate->subid == GameResID(EGameResID::GOLD))
|
||||
if(GameResID(objectTemplate->subid) == GameResID(EGameResID::GOLD))
|
||||
{
|
||||
// Gold is multiplied by 100.
|
||||
object->amount *= 100;
|
||||
@ -1740,7 +1740,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
||||
|
||||
for(auto & elem : map->disposedHeroes)
|
||||
{
|
||||
if(elem.heroId.getNum() == object->subID)
|
||||
if(elem.heroId == object->getHeroType())
|
||||
{
|
||||
object->nameCustomTextId = elem.name;
|
||||
object->customPortraitSource = elem.portrait;
|
||||
@ -1750,7 +1750,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
||||
|
||||
bool hasName = reader->readBool();
|
||||
if(hasName)
|
||||
object->nameCustomTextId = readLocalizedString(TextIdentifier("heroes", object->subID, "name"));
|
||||
object->nameCustomTextId = readLocalizedString(TextIdentifier("heroes", object->getHeroType().getNum(), "name"));
|
||||
|
||||
if(features.levelSOD)
|
||||
{
|
||||
@ -1861,8 +1861,8 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
||||
}
|
||||
}
|
||||
|
||||
if (object->subID != -1)
|
||||
logGlobal->debug("Map '%s': Hero on map: %s at %s, owned by %s", mapName, VLC->heroh->getByIndex(object->subID)->getJsonKey(), mapPosition.toString(), object->getOwner().toString());
|
||||
if (object->subID != MapObjectSubID())
|
||||
logGlobal->debug("Map '%s': Hero on map: %s at %s, owned by %s", mapName, VLC->heroh->getById(object->getHeroType())->getJsonKey(), mapPosition.toString(), object->getOwner().toString());
|
||||
else
|
||||
logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString());
|
||||
|
||||
|
@ -144,7 +144,7 @@ void CMapGenOptions::resetPlayersMap()
|
||||
for(const auto & p : players)
|
||||
{
|
||||
auto town = p.second.getStartingTown();
|
||||
if (town != RANDOM_SIZE)
|
||||
if (town != FactionID::RANDOM)
|
||||
rememberTownTypes[p.first] = FactionID(town);
|
||||
rememberTeam[p.first] = p.second.getTeam();
|
||||
}
|
||||
@ -522,17 +522,17 @@ void CMapGenOptions::CPlayerSettings::setColor(const PlayerColor & value)
|
||||
color = value;
|
||||
}
|
||||
|
||||
si32 CMapGenOptions::CPlayerSettings::getStartingTown() const
|
||||
FactionID CMapGenOptions::CPlayerSettings::getStartingTown() const
|
||||
{
|
||||
return startingTown;
|
||||
}
|
||||
|
||||
void CMapGenOptions::CPlayerSettings::setStartingTown(si32 value)
|
||||
void CMapGenOptions::CPlayerSettings::setStartingTown(FactionID value)
|
||||
{
|
||||
assert(value >= -1);
|
||||
if(value >= 0)
|
||||
assert(value >= FactionID::RANDOM);
|
||||
if(value != FactionID::RANDOM)
|
||||
{
|
||||
assert(value < static_cast<int>(VLC->townh->size()));
|
||||
assert(value < FactionID(VLC->townh->size()));
|
||||
assert((*VLC->townh)[value]->town != nullptr);
|
||||
}
|
||||
startingTown = value;
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
|
||||
/// The starting town of the player ranging from 0 to town max count or RANDOM_TOWN.
|
||||
/// The default value is RANDOM_TOWN.
|
||||
si32 getStartingTown() const;
|
||||
void setStartingTown(si32 value);
|
||||
FactionID getStartingTown() const;
|
||||
void setStartingTown(FactionID value);
|
||||
|
||||
/// The default value is EPlayerType::AI.
|
||||
EPlayerType getPlayerType() const;
|
||||
@ -55,7 +55,7 @@ public:
|
||||
|
||||
private:
|
||||
PlayerColor color;
|
||||
si32 startingTown;
|
||||
FactionID startingTown;
|
||||
EPlayerType playerType;
|
||||
TeamID team;
|
||||
|
||||
|
@ -442,7 +442,7 @@ void CZonePlacer::prepareZones(TZoneMap &zones, TZoneVector &zonesVector, const
|
||||
{
|
||||
auto player = PlayerColor(*owner - 1);
|
||||
auto playerSettings = map.getMapGenOptions().getPlayersSettings();
|
||||
si32 faction = FactionID::RANDOM;
|
||||
FactionID faction = FactionID::RANDOM;
|
||||
if (vstd::contains(playerSettings, player))
|
||||
faction = playerSettings[player].getStartingTown();
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user