mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Improvements to type safety of Identifier class
- Constructor of Identifier from integer is now explicit - Lobby hero/town selection now uses Identifiers instead of int's - Removed serialization workaround for hero portraits - Added dummy objects for custom heroes portraits for ID resolver to use - HeroInstance now stores portrait ID only in case of custom portrait - Fixed loading of campaign heroes portraits on RoE maps
This commit is contained in:
@@ -824,7 +824,7 @@ void CGameState::placeStartingHeroes()
|
||||
if (campaign && campaign->playerHasStartingHero(playerColor))
|
||||
continue;
|
||||
|
||||
int heroTypeId = pickNextHeroType(playerColor);
|
||||
HeroTypeID heroTypeId = pickNextHeroType(playerColor);
|
||||
if(playerSettingPair.second.hero == HeroTypeID::NONE)
|
||||
playerSettingPair.second.hero = heroTypeId;
|
||||
|
||||
@@ -959,14 +959,15 @@ void CGameState::initStartingBonus()
|
||||
for(auto & elem : players)
|
||||
{
|
||||
//starting bonus
|
||||
if(scenarioOps->playerInfos[elem.first].bonus==PlayerSettings::RANDOM)
|
||||
scenarioOps->playerInfos[elem.first].bonus = static_cast<PlayerSettings::Ebonus>(getRandomGenerator().nextInt(2));
|
||||
if(scenarioOps->playerInfos[elem.first].bonus == PlayerStartingBonus::RANDOM)
|
||||
scenarioOps->playerInfos[elem.first].bonus = static_cast<PlayerStartingBonus>(getRandomGenerator().nextInt(2));
|
||||
|
||||
switch(scenarioOps->playerInfos[elem.first].bonus)
|
||||
{
|
||||
case PlayerSettings::GOLD:
|
||||
case PlayerStartingBonus::GOLD:
|
||||
elem.second.resources[EGameResID::GOLD] += getRandomGenerator().nextInt(5, 10) * 100;
|
||||
break;
|
||||
case PlayerSettings::RESOURCE:
|
||||
case PlayerStartingBonus::RESOURCE:
|
||||
{
|
||||
auto res = (*VLC->townh)[scenarioOps->playerInfos[elem.first].castle]->town->primaryRes;
|
||||
if(res == EGameResID::WOOD_AND_ORE)
|
||||
@@ -981,7 +982,7 @@ void CGameState::initStartingBonus()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PlayerSettings::ARTIFACT:
|
||||
case PlayerStartingBonus::ARTIFACT:
|
||||
{
|
||||
if(elem.second.heroes.empty())
|
||||
{
|
||||
@@ -2117,7 +2118,7 @@ std::set<HeroTypeID> CGameState::getUnusedAllowedHeroes(bool alsoIncludeNotAllow
|
||||
|
||||
for(const auto & playerSettingPair : scenarioOps->playerInfos) //remove uninitialized yet heroes picked for start by other players
|
||||
{
|
||||
if(playerSettingPair.second.hero.getNum() != PlayerSettings::RANDOM)
|
||||
if(playerSettingPair.second.hero != HeroTypeID::RANDOM)
|
||||
ret -= HeroTypeID(playerSettingPair.second.hero);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user