mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Likely fixed duplicated random heroes
This commit is contained in:
@ -1383,7 +1383,8 @@ void CGameState::placeStartingHeroes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int heroTypeId = pickNextHeroType(playerColor);
|
int heroTypeId = pickNextHeroType(playerColor);
|
||||||
if(playerSettingPair.second.hero == -1) playerSettingPair.second.hero = heroTypeId;
|
if(playerSettingPair.second.hero == -1)
|
||||||
|
playerSettingPair.second.hero = heroTypeId;
|
||||||
|
|
||||||
placeStartingHero(playerColor, HeroTypeID(heroTypeId), playerInfo.posOfMainTown);
|
placeStartingHero(playerColor, HeroTypeID(heroTypeId), playerInfo.posOfMainTown);
|
||||||
}
|
}
|
||||||
@ -2770,7 +2771,7 @@ CGHeroInstance * CGameState::getUsedHero(HeroTypeID hid) const
|
|||||||
{
|
{
|
||||||
for(auto hero : map->heroesOnMap) //heroes instances initialization
|
for(auto hero : map->heroesOnMap) //heroes instances initialization
|
||||||
{
|
{
|
||||||
if(hero->subID == hid.getNum())
|
if(hero->type && hero->type->ID == hid)
|
||||||
{
|
{
|
||||||
return hero;
|
return hero;
|
||||||
}
|
}
|
||||||
@ -2778,9 +2779,12 @@ CGHeroInstance * CGameState::getUsedHero(HeroTypeID hid) const
|
|||||||
|
|
||||||
for(auto obj : map->objects) //prisons
|
for(auto obj : map->objects) //prisons
|
||||||
{
|
{
|
||||||
if(obj && obj->ID == Obj::PRISON && obj->subID == hid.getNum())
|
if(obj && obj->ID == Obj::PRISON )
|
||||||
{
|
{
|
||||||
return dynamic_cast<CGHeroInstance *>(obj.get());
|
auto hero = dynamic_cast<CGHeroInstance *>(obj.get());
|
||||||
|
assert(hero);
|
||||||
|
if ( hero->type && hero->type->ID == hid )
|
||||||
|
return hero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ struct PlayerSettings
|
|||||||
Ebonus bonus;
|
Ebonus bonus;
|
||||||
si16 castle;
|
si16 castle;
|
||||||
si32 hero,
|
si32 hero,
|
||||||
heroPortrait; //-1 if default, else ID
|
heroPortrait; //-1 if default, else ID
|
||||||
|
|
||||||
std::string heroName;
|
std::string heroName;
|
||||||
PlayerColor color; //from 0 -
|
PlayerColor color; //from 0 -
|
||||||
@ -70,13 +70,13 @@ struct StartInfo
|
|||||||
{
|
{
|
||||||
enum EMode {NEW_GAME, LOAD_GAME, CAMPAIGN, DUEL, INVALID = 255};
|
enum EMode {NEW_GAME, LOAD_GAME, CAMPAIGN, DUEL, INVALID = 255};
|
||||||
|
|
||||||
EMode mode;
|
EMode mode;
|
||||||
ui8 difficulty; //0=easy; 4=impossible
|
ui8 difficulty; //0=easy; 4=impossible
|
||||||
|
|
||||||
typedef std::map<PlayerColor, PlayerSettings> TPlayerInfos;
|
typedef std::map<PlayerColor, PlayerSettings> TPlayerInfos;
|
||||||
TPlayerInfos playerInfos; //color indexed
|
TPlayerInfos playerInfos; //color indexed
|
||||||
|
|
||||||
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
|
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
|
||||||
ui32 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet
|
ui32 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet
|
||||||
ui32 mapfileChecksum; //0 if not relevant
|
ui32 mapfileChecksum; //0 if not relevant
|
||||||
ui8 turnTime; //in minutes, 0=unlimited
|
ui8 turnTime; //in minutes, 0=unlimited
|
||||||
|
Reference in New Issue
Block a user