mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Remove few more implicit conversions
This commit is contained in:
parent
34338f4eaa
commit
13763cad8e
@ -235,38 +235,30 @@ void CBonusSelection::createBonusesIcons()
|
|||||||
break;
|
break;
|
||||||
case CampaignBonusType::RESOURCE:
|
case CampaignBonusType::RESOURCE:
|
||||||
{
|
{
|
||||||
int serialResID = 0;
|
desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
|
||||||
|
|
||||||
switch(bonDescs[i].info1)
|
switch(bonDescs[i].info1)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
serialResID = bonDescs[i].info1;
|
|
||||||
break;
|
|
||||||
case 0xFD: //wood + ore
|
case 0xFD: //wood + ore
|
||||||
serialResID = 7;
|
{
|
||||||
break;
|
desc.replaceLocalString(EMetaText::GENERAL_TXT, 721);
|
||||||
case 0xFE: //rare resources
|
picNumber = 7;
|
||||||
serialResID = 8;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
picNumber = serialResID;
|
case 0xFE: //wood + ore
|
||||||
|
{
|
||||||
|
desc.replaceLocalString(EMetaText::GENERAL_TXT, 722);
|
||||||
|
picNumber = 8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
desc.replaceName(GameResID(bonDescs[i].info1));
|
||||||
|
picNumber = bonDescs[i].info1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
|
|
||||||
desc.replaceNumber(bonDescs[i].info2);
|
desc.replaceNumber(bonDescs[i].info2);
|
||||||
|
|
||||||
if(serialResID <= 6)
|
|
||||||
{
|
|
||||||
desc.replaceLocalString(EMetaText::RES_NAMES, serialResID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
desc.replaceLocalString(EMetaText::GENERAL_TXT, 714 + serialResID);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CampaignBonusType::HEROES_FROM_PREVIOUS_SCENARIO:
|
case CampaignBonusType::HEROES_FROM_PREVIOUS_SCENARIO:
|
||||||
|
@ -122,17 +122,17 @@ TurnTimerInfo CGameInfoCallback::getPlayerTurnTime(PlayerColor color) const
|
|||||||
return TurnTimerInfo{};
|
return TurnTimerInfo{};
|
||||||
}
|
}
|
||||||
|
|
||||||
const CGObjectInstance * CGameInfoCallback::getObjByQuestIdentifier(int identifier) const
|
const CGObjectInstance * CGameInfoCallback::getObjByQuestIdentifier(ObjectInstanceID identifier) const
|
||||||
{
|
{
|
||||||
if(gs->map->questIdentifierToId.empty())
|
if(gs->map->questIdentifierToId.empty())
|
||||||
{
|
{
|
||||||
//assume that it is VCMI map and quest identifier equals instance identifier
|
//assume that it is VCMI map and quest identifier equals instance identifier
|
||||||
return getObj(ObjectInstanceID(identifier), true);
|
return getObj(identifier, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_RET_VAL_IF(!vstd::contains(gs->map->questIdentifierToId, identifier), "There is no object with such quest identifier!", nullptr);
|
ERROR_RET_VAL_IF(!vstd::contains(gs->map->questIdentifierToId, identifier.getNum()), "There is no object with such quest identifier!", nullptr);
|
||||||
return getObj(gs->map->questIdentifierToId[identifier]);
|
return getObj(gs->map->questIdentifierToId[identifier.getNum()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
// std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
|
// std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
|
||||||
// const CGObjectInstance * getTopObj (int3 pos) const;
|
// const CGObjectInstance * getTopObj (int3 pos) const;
|
||||||
// PlayerColor getOwner(ObjectInstanceID heroID) const;
|
// PlayerColor getOwner(ObjectInstanceID heroID) const;
|
||||||
// const CGObjectInstance *getObjByQuestIdentifier(int identifier) const; //nullptr if object has been removed (eg. killed)
|
// const CGObjectInstance *getObjByQuestIdentifier(ObjectInstanceID identifier) const; //nullptr if object has been removed (eg. killed)
|
||||||
|
|
||||||
//map
|
//map
|
||||||
// int3 guardingCreaturePosition (int3 pos) const;
|
// int3 guardingCreaturePosition (int3 pos) const;
|
||||||
@ -190,7 +190,7 @@ public:
|
|||||||
virtual std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
|
virtual std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
|
||||||
virtual const CGObjectInstance * getTopObj (int3 pos) const;
|
virtual const CGObjectInstance * getTopObj (int3 pos) const;
|
||||||
virtual PlayerColor getOwner(ObjectInstanceID heroID) const;
|
virtual PlayerColor getOwner(ObjectInstanceID heroID) const;
|
||||||
virtual const CGObjectInstance *getObjByQuestIdentifier(int identifier) const; //nullptr if object has been removed (eg. killed)
|
virtual const CGObjectInstance *getObjByQuestIdentifier(ObjectInstanceID identifier) const; //nullptr if object has been removed (eg. killed)
|
||||||
|
|
||||||
//map
|
//map
|
||||||
virtual int3 guardingCreaturePosition (int3 pos) const;
|
virtual int3 guardingCreaturePosition (int3 pos) const;
|
||||||
|
@ -114,8 +114,6 @@ std::string MetaString::getLocalString(const std::pair<EMetaText, ui32> & txt) c
|
|||||||
{
|
{
|
||||||
case EMetaText::GENERAL_TXT:
|
case EMetaText::GENERAL_TXT:
|
||||||
return VLC->generaltexth->translate("core.genrltxt", ser);
|
return VLC->generaltexth->translate("core.genrltxt", ser);
|
||||||
case EMetaText::RES_NAMES:
|
|
||||||
return VLC->generaltexth->translate("core.restypes", ser);
|
|
||||||
case EMetaText::ARRAY_TXT:
|
case EMetaText::ARRAY_TXT:
|
||||||
return VLC->generaltexth->translate("core.arraytxt", ser);
|
return VLC->generaltexth->translate("core.arraytxt", ser);
|
||||||
case EMetaText::ADVOB_TXT:
|
case EMetaText::ADVOB_TXT:
|
||||||
@ -374,6 +372,11 @@ void MetaString::replaceName(const SpellID & id)
|
|||||||
replaceTextID(id.toEntity(VLC)->getNameTextID());
|
replaceTextID(id.toEntity(VLC)->getNameTextID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetaString::replaceName(const GameResID& id)
|
||||||
|
{
|
||||||
|
replaceTextID(TextIdentifier("core.restypes", id.getNum()).get());
|
||||||
|
}
|
||||||
|
|
||||||
void MetaString::replaceNameSingular(const CreatureID & id)
|
void MetaString::replaceNameSingular(const CreatureID & id)
|
||||||
{
|
{
|
||||||
replaceTextID(id.toEntity(VLC)->getNameSingularTextID());
|
replaceTextID(id.toEntity(VLC)->getNameSingularTextID());
|
||||||
|
@ -21,13 +21,13 @@ class MapObjectSubID;
|
|||||||
class PlayerColor;
|
class PlayerColor;
|
||||||
class SecondarySkill;
|
class SecondarySkill;
|
||||||
class SpellID;
|
class SpellID;
|
||||||
|
class GameResID;
|
||||||
using TQuantity = si32;
|
using TQuantity = si32;
|
||||||
|
|
||||||
/// Strings classes that can be used as replacement in MetaString
|
/// Strings classes that can be used as replacement in MetaString
|
||||||
enum class EMetaText : uint8_t
|
enum class EMetaText : uint8_t
|
||||||
{
|
{
|
||||||
GENERAL_TXT = 1,
|
GENERAL_TXT = 1,
|
||||||
RES_NAMES,
|
|
||||||
ARRAY_TXT,
|
ARRAY_TXT,
|
||||||
ADVOB_TXT,
|
ADVOB_TXT,
|
||||||
JK_TXT
|
JK_TXT
|
||||||
@ -97,6 +97,7 @@ public:
|
|||||||
void replaceName(const PlayerColor& id);
|
void replaceName(const PlayerColor& id);
|
||||||
void replaceName(const SecondarySkill& id);
|
void replaceName(const SecondarySkill& id);
|
||||||
void replaceName(const SpellID& id);
|
void replaceName(const SpellID& id);
|
||||||
|
void replaceName(const GameResID& id);
|
||||||
|
|
||||||
/// Replaces first '%s' placeholder with singular or plural name depending on creatures count
|
/// Replaces first '%s' placeholder with singular or plural name depending on creatures count
|
||||||
void replaceName(const CreatureID & id, TQuantity count);
|
void replaceName(const CreatureID & id, TQuantity count);
|
||||||
|
@ -189,8 +189,8 @@ void CGameStateCampaign::placeCampaignHeroes()
|
|||||||
auto it = gameState->scenarioOps->playerInfos.find(playerColor);
|
auto it = gameState->scenarioOps->playerInfos.find(playerColor);
|
||||||
if(it != gameState->scenarioOps->playerInfos.end())
|
if(it != gameState->scenarioOps->playerInfos.end())
|
||||||
{
|
{
|
||||||
auto heroTypeId = campaignBonus->info2;
|
HeroTypeID heroTypeId = HeroTypeID(campaignBonus->info2);
|
||||||
if(heroTypeId == 0xffff) // random bonus hero
|
if(heroTypeId.getNum() == 0xffff) // random bonus hero
|
||||||
{
|
{
|
||||||
heroTypeId = gameState->pickUnusedHeroTypeRandomly(playerColor);
|
heroTypeId = gameState->pickUnusedHeroTypeRandomly(playerColor);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ struct DLL_LINKAGE SThievesGuildInfo
|
|||||||
std::map<PlayerColor, InfoAboutHero> colorToBestHero; //maps player's color to his best heros'
|
std::map<PlayerColor, InfoAboutHero> colorToBestHero; //maps player's color to his best heros'
|
||||||
|
|
||||||
std::map<PlayerColor, EAiTactic> personality; // color to personality // ai tactic
|
std::map<PlayerColor, EAiTactic> personality; // color to personality // ai tactic
|
||||||
std::map<PlayerColor, si32> bestCreature; // color to ID // id or -1 if not known
|
std::map<PlayerColor, CreatureID> bestCreature; // color to ID // id or -1 if not known
|
||||||
|
|
||||||
// template <typename Handler> void serialize(Handler &h, const int version)
|
// template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
// {
|
// {
|
||||||
|
@ -273,7 +273,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
iw.components.emplace_back(ComponentType::RESOURCE, it, bc->resources[it]);
|
iw.components.emplace_back(ComponentType::RESOURCE, it, bc->resources[it]);
|
||||||
loot.appendRawString("%d %s");
|
loot.appendRawString("%d %s");
|
||||||
loot.replaceNumber(bc->resources[it]);
|
loot.replaceNumber(bc->resources[it]);
|
||||||
loot.replaceLocalString(EMetaText::RES_NAMES, it);
|
loot.replaceName(it);
|
||||||
cb->giveResource(hero->getOwner(), it, bc->resources[it]);
|
cb->giveResource(hero->getOwner(), it, bc->resources[it]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,13 +242,13 @@ void CQuest::addTextReplacements(MetaString & text, std::vector<Component> & com
|
|||||||
if(mission.resources.nonZero())
|
if(mission.resources.nonZero())
|
||||||
{
|
{
|
||||||
MetaString loot;
|
MetaString loot;
|
||||||
for(int i = 0; i < 7; ++i)
|
for(auto i : GameResID::ALL_RESOURCES())
|
||||||
{
|
{
|
||||||
if(mission.resources[i])
|
if(mission.resources[i])
|
||||||
{
|
{
|
||||||
loot.appendRawString("%d %s");
|
loot.appendRawString("%d %s");
|
||||||
loot.replaceNumber(mission.resources[i]);
|
loot.replaceNumber(mission.resources[i]);
|
||||||
loot.replaceLocalString(EMetaText::RES_NAMES, i);
|
loot.replaceName(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text.replaceRawString(loot.buildList());
|
text.replaceRawString(loot.buildList());
|
||||||
|
@ -320,7 +320,7 @@ void CGResource::collectRes(const PlayerColor & player) const
|
|||||||
{
|
{
|
||||||
sii.type = EInfoWindowMode::INFO;
|
sii.type = EInfoWindowMode::INFO;
|
||||||
sii.text.appendLocalString(EMetaText::ADVOB_TXT,113);
|
sii.text.appendLocalString(EMetaText::ADVOB_TXT,113);
|
||||||
sii.text.replaceLocalString(EMetaText::RES_NAMES, resourceID());
|
sii.text.replaceName(resourceID());
|
||||||
}
|
}
|
||||||
sii.components.emplace_back(ComponentType::RESOURCE, resourceID(), amount);
|
sii.components.emplace_back(ComponentType::RESOURCE, resourceID(), amount);
|
||||||
sii.soundID = soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6);
|
sii.soundID = soundBase::pickup01 + CRandomGenerator::getDefault().nextInt(6);
|
||||||
|
@ -26,9 +26,9 @@ CIdentifierStorage::CIdentifierStorage()
|
|||||||
{
|
{
|
||||||
//TODO: moddable spell schools
|
//TODO: moddable spell schools
|
||||||
for (auto i = 0; i < GameConstants::DEFAULT_SCHOOLS; ++i)
|
for (auto i = 0; i < GameConstants::DEFAULT_SCHOOLS; ++i)
|
||||||
registerObject(ModScope::scopeBuiltin(), "spellSchool", SpellConfig::SCHOOL[i].jsonName, SpellConfig::SCHOOL[i].id);
|
registerObject(ModScope::scopeBuiltin(), "spellSchool", SpellConfig::SCHOOL[i].jsonName, SpellConfig::SCHOOL[i].id.getNum());
|
||||||
|
|
||||||
registerObject(ModScope::scopeBuiltin(), "spellSchool", "any", SpellSchool(SpellSchool::ANY));
|
registerObject(ModScope::scopeBuiltin(), "spellSchool", "any", SpellSchool::ANY.getNum());
|
||||||
|
|
||||||
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
for (int i = 0; i < GameConstants::RESOURCE_QUANTITY; ++i)
|
||||||
registerObject(ModScope::scopeBuiltin(), "resource", GameConstants::RESOURCE_NAMES[i], i);
|
registerObject(ModScope::scopeBuiltin(), "resource", GameConstants::RESOURCE_NAMES[i], i);
|
||||||
|
@ -1971,9 +1971,9 @@ void HeroVisit::applyGs(CGameState *gs)
|
|||||||
|
|
||||||
void SetAvailableArtifacts::applyGs(CGameState * gs) const
|
void SetAvailableArtifacts::applyGs(CGameState * gs) const
|
||||||
{
|
{
|
||||||
if(id >= 0)
|
if(id != ObjectInstanceID::NONE)
|
||||||
{
|
{
|
||||||
if(auto * bm = dynamic_cast<CGBlackMarket *>(gs->map->objects[id].get()))
|
if(auto * bm = dynamic_cast<CGBlackMarket *>(gs->getObjInstance(id)))
|
||||||
{
|
{
|
||||||
bm->artifacts = arts;
|
bm->artifacts = arts;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ void CMapGenOptions::resetPlayersMap()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->warn("Adding settings for player %s", color.encode(color));
|
logGlobal->warn("Adding settings for player %s", color);
|
||||||
// Usually, all players should be initialized in initPlayersMap()
|
// Usually, all players should be initialized in initPlayersMap()
|
||||||
CPlayerSettings settings;
|
CPlayerSettings settings;
|
||||||
players[color] = settings;
|
players[color] = settings;
|
||||||
|
@ -182,7 +182,7 @@ void CMapGenerator::addPlayerInfo()
|
|||||||
{
|
{
|
||||||
// Teams are already configured in CMapGenOptions. However, it's not the case when it comes to map editor
|
// Teams are already configured in CMapGenOptions. However, it's not the case when it comes to map editor
|
||||||
|
|
||||||
std::set<int> teamsTotal;
|
std::set<TeamID> teamsTotal;
|
||||||
|
|
||||||
if (mapGenOptions.arePlayersCustomized())
|
if (mapGenOptions.arePlayersCustomized())
|
||||||
{
|
{
|
||||||
@ -284,7 +284,7 @@ void CMapGenerator::addPlayerInfo()
|
|||||||
player.team = TeamID(*itTeam);
|
player.team = TeamID(*itTeam);
|
||||||
teamNumbers[j].erase(itTeam);
|
teamNumbers[j].erase(itTeam);
|
||||||
}
|
}
|
||||||
teamsTotal.insert(player.team.getNum());
|
teamsTotal.insert(player.team);
|
||||||
map->getMap(this).players[pSettings.getColor().getNum()] = player;
|
map->getMap(this).players[pSettings.getColor().getNum()] = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void TownPlacer::addNewTowns(int count, bool hasFort, const PlayerColor & player
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
si32 TownPlacer::getRandomTownType(bool matchUndergroundType)
|
FactionID TownPlacer::getRandomTownType(bool matchUndergroundType)
|
||||||
{
|
{
|
||||||
auto townTypesAllowed = (!zone.getTownTypes().empty() ? zone.getTownTypes() : zone.getDefaultTownTypes());
|
auto townTypesAllowed = (!zone.getTownTypes().empty() ? zone.getTownTypes() : zone.getDefaultTownTypes());
|
||||||
if(matchUndergroundType)
|
if(matchUndergroundType)
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void cleanupBoundaries(const rmg::Object & rmgObject);
|
void cleanupBoundaries(const rmg::Object & rmgObject);
|
||||||
void addNewTowns(int count, bool hasFort, const PlayerColor & player, ObjectManager & manager);
|
void addNewTowns(int count, bool hasFort, const PlayerColor & player, ObjectManager & manager);
|
||||||
si32 getRandomTownType(bool matchUndergroundType = false);
|
FactionID getRandomTownType(bool matchUndergroundType = false);
|
||||||
void placeTowns(ObjectManager & manager);
|
void placeTowns(ObjectManager & manager);
|
||||||
bool placeMines(ObjectManager & manager);
|
bool placeMines(ObjectManager & manager);
|
||||||
int3 placeMainTown(ObjectManager & manager, CGTownInstance & town);
|
int3 placeMainTown(ObjectManager & manager, CGTownInstance & town);
|
||||||
|
@ -30,8 +30,8 @@ public:
|
|||||||
EXPECT_CALL(spellMock, forEachSchool(NotNull())).Times(AtLeast(1)).WillRepeatedly([](const spells::Spell::SchoolCallback & cb)
|
EXPECT_CALL(spellMock, forEachSchool(NotNull())).Times(AtLeast(1)).WillRepeatedly([](const spells::Spell::SchoolCallback & cb)
|
||||||
{
|
{
|
||||||
bool stop = false;
|
bool stop = false;
|
||||||
cb(SpellSchool(SpellSchool::AIR), stop);
|
cb(SpellSchool::AIR, stop);
|
||||||
cb(SpellSchool(SpellSchool::FIRE), stop);
|
cb(SpellSchool::FIRE, stop);
|
||||||
});
|
});
|
||||||
|
|
||||||
EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
|
EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
|
||||||
|
Loading…
Reference in New Issue
Block a user