mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Remove few more implicit conversions
This commit is contained in:
parent
abad4b01ce
commit
34338f4eaa
@ -77,7 +77,7 @@ void CSkill::registerIcons(const IconRegistar & cb) const
|
|||||||
{
|
{
|
||||||
for(int level = 1; level <= 3; level++)
|
for(int level = 1; level <= 3; level++)
|
||||||
{
|
{
|
||||||
int frame = 2 + level + 3 * id;
|
int frame = 2 + level + 3 * id.getNum();
|
||||||
const LevelInfo & skillAtLevel = at(level);
|
const LevelInfo & skillAtLevel = at(level);
|
||||||
cb(frame, 0, "SECSK32", skillAtLevel.iconSmall);
|
cb(frame, 0, "SECSK32", skillAtLevel.iconSmall);
|
||||||
cb(frame, 0, "SECSKILL", skillAtLevel.iconMedium);
|
cb(frame, 0, "SECSKILL", skillAtLevel.iconMedium);
|
||||||
|
@ -144,12 +144,12 @@ CFaction::~CFaction()
|
|||||||
|
|
||||||
int32_t CFaction::getIndex() const
|
int32_t CFaction::getIndex() const
|
||||||
{
|
{
|
||||||
return index;
|
return index.getNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CFaction::getIconIndex() const
|
int32_t CFaction::getIconIndex() const
|
||||||
{
|
{
|
||||||
return index; //???
|
return index.getNum(); //???
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CFaction::getJsonKey() const
|
std::string CFaction::getJsonKey() const
|
||||||
@ -172,8 +172,8 @@ void CFaction::registerIcons(const IconRegistar & cb) const
|
|||||||
cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
|
cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
|
||||||
cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
|
cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
|
||||||
|
|
||||||
cb(index, 1, "CPRSMALL", info.towerIconSmall);
|
cb(index.getNum(), 1, "CPRSMALL", info.towerIconSmall);
|
||||||
cb(index, 1, "TWCRPORT", info.towerIconLarge);
|
cb(index.getNum(), 1, "TWCRPORT", info.towerIconLarge);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,7 +734,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|||||||
|
|
||||||
ret->town->buildings[ret->bid] = ret;
|
ret->town->buildings[ret->bid] = ret;
|
||||||
|
|
||||||
registerObject(source.meta, ret->town->getBuildingScope(), ret->identifier, ret->bid);
|
registerObject(source.meta, ret->town->getBuildingScope(), ret->identifier, ret->bid.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
|
void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
|
||||||
@ -1115,10 +1115,10 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
if (object->town)
|
if (object->town)
|
||||||
{
|
{
|
||||||
auto & info = object->town->clientInfo;
|
auto & info = object->town->clientInfo;
|
||||||
info.icons[0][0] = 8 + object->index * 4 + 0;
|
info.icons[0][0] = 8 + object->index.getNum() * 4 + 0;
|
||||||
info.icons[0][1] = 8 + object->index * 4 + 1;
|
info.icons[0][1] = 8 + object->index.getNum() * 4 + 1;
|
||||||
info.icons[1][0] = 8 + object->index * 4 + 2;
|
info.icons[1][0] = 8 + object->index.getNum() * 4 + 2;
|
||||||
info.icons[1][1] = 8 + object->index * 4 + 3;
|
info.icons[1][1] = 8 + object->index.getNum() * 4 + 3;
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(scope, "object", "town", [=](si32 index)
|
VLC->identifiers()->requestIdentifier(scope, "object", "town", [=](si32 index)
|
||||||
{
|
{
|
||||||
@ -1142,7 +1142,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerObject(scope, "faction", name, object->index);
|
registerObject(scope, "faction", name, object->index.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||||
@ -1158,10 +1158,10 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
if (object->town)
|
if (object->town)
|
||||||
{
|
{
|
||||||
auto & info = object->town->clientInfo;
|
auto & info = object->town->clientInfo;
|
||||||
info.icons[0][0] = (GameConstants::F_NUMBER + object->index) * 2 + 0;
|
info.icons[0][0] = (GameConstants::F_NUMBER + object->index.getNum()) * 2 + 0;
|
||||||
info.icons[0][1] = (GameConstants::F_NUMBER + object->index) * 2 + 1;
|
info.icons[0][1] = (GameConstants::F_NUMBER + object->index.getNum()) * 2 + 1;
|
||||||
info.icons[1][0] = object->index * 2 + 0;
|
info.icons[1][0] = object->index.getNum() * 2 + 0;
|
||||||
info.icons[1][1] = object->index * 2 + 1;
|
info.icons[1][1] = object->index.getNum() * 2 + 1;
|
||||||
|
|
||||||
VLC->identifiers()->requestIdentifier(scope, "object", "town", [=](si32 index)
|
VLC->identifiers()->requestIdentifier(scope, "object", "town", [=](si32 index)
|
||||||
{
|
{
|
||||||
@ -1173,7 +1173,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerObject(scope, "faction", name, object->index);
|
registerObject(scope, "faction", name, object->index.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTownHandler::loadRandomFaction()
|
void CTownHandler::loadRandomFaction()
|
||||||
|
@ -571,6 +571,12 @@ public:
|
|||||||
|
|
||||||
static std::string encode(int32_t index);
|
static std::string encode(int32_t index);
|
||||||
static si32 decode(const std::string & identifier);
|
static si32 decode(const std::string & identifier);
|
||||||
|
|
||||||
|
// TODO: Remove
|
||||||
|
constexpr operator int32_t () const
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapObjectSubID : public Identifier<MapObjectSubID>
|
class MapObjectSubID : public Identifier<MapObjectSubID>
|
||||||
@ -594,6 +600,12 @@ public:
|
|||||||
this->num = value.getNum();
|
this->num = value.getNum();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove
|
||||||
|
constexpr operator int32_t () const
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE RoadId : public Identifier<RoadId>
|
class DLL_LINKAGE RoadId : public Identifier<RoadId>
|
||||||
|
@ -52,10 +52,10 @@ public:
|
|||||||
num += change;
|
num += change;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr operator int32_t () const
|
// constexpr operator int32_t () const
|
||||||
{
|
// {
|
||||||
return num;
|
// return num;
|
||||||
}
|
// }
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
|
friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ std::vector<JsonNode> CObjectClassesHandler::loadLegacyData()
|
|||||||
tmpl->readTxt(parser);
|
tmpl->readTxt(parser);
|
||||||
parser.endLine();
|
parser.endLine();
|
||||||
|
|
||||||
std::pair<si32, si32> key(tmpl->id.num, tmpl->subid);
|
std::pair key(tmpl->id, tmpl->subid);
|
||||||
legacyTemplates.insert(std::make_pair(key, std::shared_ptr<const ObjectTemplate>(tmpl)));
|
legacyTemplates.insert(std::make_pair(key, std::shared_ptr<const ObjectTemplate>(tmpl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
|
|||||||
std::map<std::string, std::function<TObjectTypeHandler()> > handlerConstructors;
|
std::map<std::string, std::function<TObjectTypeHandler()> > handlerConstructors;
|
||||||
|
|
||||||
/// container with H3 templates, used only during loading, no need to serialize it
|
/// container with H3 templates, used only during loading, no need to serialize it
|
||||||
using TTemplatesContainer = std::multimap<std::pair<si32, si32>, std::shared_ptr<const ObjectTemplate>>;
|
using TTemplatesContainer = std::multimap<std::pair<MapObjectID, MapObjectSubID>, std::shared_ptr<const ObjectTemplate>>;
|
||||||
TTemplatesContainer legacyTemplates;
|
TTemplatesContainer legacyTemplates;
|
||||||
|
|
||||||
TObjectTypeHandler loadSubObjectFromJson(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * obj, size_t index);
|
TObjectTypeHandler loadSubObjectFromJson(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * obj, size_t index);
|
||||||
|
@ -49,7 +49,7 @@ CGDwelling::~CGDwelling() = default;
|
|||||||
FactionID CGDwelling::randomizeFaction(CRandomGenerator & rand)
|
FactionID CGDwelling::randomizeFaction(CRandomGenerator & rand)
|
||||||
{
|
{
|
||||||
if (ID == Obj::RANDOM_DWELLING_FACTION)
|
if (ID == Obj::RANDOM_DWELLING_FACTION)
|
||||||
return FactionID(subID);
|
return FactionID(subID.getNum());
|
||||||
|
|
||||||
assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL);
|
assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL);
|
||||||
assert(randomizationInfo.has_value());
|
assert(randomizationInfo.has_value());
|
||||||
@ -138,7 +138,7 @@ void CGDwelling::pickRandomObject(CRandomGenerator & rand)
|
|||||||
auto testID = [&](const Obj & primaryID) -> MapObjectSubID
|
auto testID = [&](const Obj & primaryID) -> MapObjectSubID
|
||||||
{
|
{
|
||||||
auto dwellingIDs = VLC->objtypeh->knownSubObjects(primaryID);
|
auto dwellingIDs = VLC->objtypeh->knownSubObjects(primaryID);
|
||||||
for (si32 entry : dwellingIDs)
|
for (MapObjectSubID entry : dwellingIDs)
|
||||||
{
|
{
|
||||||
const auto * handler = dynamic_cast<const DwellingInstanceConstructor *>(VLC->objtypeh->getHandlerFor(primaryID, entry).get());
|
const auto * handler = dynamic_cast<const DwellingInstanceConstructor *>(VLC->objtypeh->getHandlerFor(primaryID, entry).get());
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class DLL_LINKAGE ObjectTemplate
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// H3 ID/subID of this object
|
/// H3 ID/subID of this object
|
||||||
Obj id;
|
MapObjectID id;
|
||||||
si32 subid;
|
MapObjectSubID subid;
|
||||||
/// print priority, objects with higher priority will be print first, below everything else
|
/// print priority, objects with higher priority will be print first, below everything else
|
||||||
si32 printPriority;
|
si32 printPriority;
|
||||||
/// animation file that should be used to display object
|
/// animation file that should be used to display object
|
||||||
|
@ -707,7 +707,7 @@ void CMapLoaderH3M::readDisposedHeroes()
|
|||||||
for(int g = 0; g < disp; ++g)
|
for(int g = 0; g < disp; ++g)
|
||||||
{
|
{
|
||||||
map->disposedHeroes[g].heroId = reader->readHero();
|
map->disposedHeroes[g].heroId = reader->readHero();
|
||||||
map->disposedHeroes[g].portrait.setNum(reader->readHeroPortrait());
|
map->disposedHeroes[g].portrait = reader->readHeroPortrait();
|
||||||
map->disposedHeroes[g].name = readLocalizedString(TextIdentifier("header", "heroes", map->disposedHeroes[g].heroId));
|
map->disposedHeroes[g].name = readLocalizedString(TextIdentifier("header", "heroes", map->disposedHeroes[g].heroId));
|
||||||
reader->readBitmaskPlayers(map->disposedHeroes[g].players, false);
|
reader->readBitmaskPlayers(map->disposedHeroes[g].players, false);
|
||||||
}
|
}
|
||||||
|
@ -127,10 +127,10 @@ rmg::Area & Zone::freePaths()
|
|||||||
|
|
||||||
FactionID Zone::getTownType() const
|
FactionID Zone::getTownType() const
|
||||||
{
|
{
|
||||||
return FactionID(townType);
|
return townType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::setTownType(si32 town)
|
void Zone::setTownType(FactionID town)
|
||||||
{
|
{
|
||||||
townType = town;
|
townType = town;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
void fractalize();
|
void fractalize();
|
||||||
|
|
||||||
FactionID getTownType() const;
|
FactionID getTownType() const;
|
||||||
void setTownType(si32 town);
|
void setTownType(FactionID town);
|
||||||
TerrainId getTerrainType() const;
|
TerrainId getTerrainType() const;
|
||||||
void setTerrainType(TerrainId terrain);
|
void setTerrainType(TerrainId terrain);
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ protected:
|
|||||||
std::vector<int3> possibleQuestArtifactPos;
|
std::vector<int3> possibleQuestArtifactPos;
|
||||||
|
|
||||||
//template info
|
//template info
|
||||||
si32 townType;
|
FactionID townType;
|
||||||
TerrainId terrainType;
|
TerrainId terrainType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ void TownPlacer::addNewTowns(int count, bool hasFort, const PlayerColor & player
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < count; i++)
|
for(int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
si32 subType = zone.getTownType();
|
FactionID subType = zone.getTownType();
|
||||||
|
|
||||||
if(totalTowns>0)
|
if(totalTowns>0)
|
||||||
{
|
{
|
||||||
|
@ -155,8 +155,8 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
if(dwellingType == Obj::CREATURE_GENERATOR1)
|
if(dwellingType == Obj::CREATURE_GENERATOR1)
|
||||||
{
|
{
|
||||||
//don't spawn original "neutral" dwellings that got replaced by Conflux dwellings in AB
|
//don't spawn original "neutral" dwellings that got replaced by Conflux dwellings in AB
|
||||||
static int elementalConfluxROE[] = {7, 13, 16, 47};
|
static MapObjectSubID elementalConfluxROE[] = {7, 13, 16, 47};
|
||||||
for(int & i : elementalConfluxROE)
|
for(auto const & i : elementalConfluxROE)
|
||||||
vstd::erase_if_present(subObjects, i);
|
vstd::erase_if_present(subObjects, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,7 +918,7 @@ char TreasurePlacer::dump(const int3 & t)
|
|||||||
return Modificator::dump(t);
|
return Modificator::dump(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectInfo::setTemplates(si32 type, si32 subtype, TerrainId terrainType)
|
void ObjectInfo::setTemplates(MapObjectID type, MapObjectSubID subtype, TerrainId terrainType)
|
||||||
{
|
{
|
||||||
auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
|
auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
|
||||||
if(!templHandler)
|
if(!templHandler)
|
||||||
|
@ -29,7 +29,7 @@ struct ObjectInfo
|
|||||||
//ui32 maxPerMap; //unused
|
//ui32 maxPerMap; //unused
|
||||||
std::function<CGObjectInstance *()> generateObject;
|
std::function<CGObjectInstance *()> generateObject;
|
||||||
|
|
||||||
void setTemplates(si32 type, si32 subtype, TerrainId terrain);
|
void setTemplates(MapObjectID type, MapObjectSubID subtype, TerrainId terrain);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TreasurePlacer: public Modificator
|
class TreasurePlacer: public Modificator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user