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:
@@ -562,11 +562,11 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
|
||||
const std::string instanceName = hero.first;
|
||||
|
||||
SHeroName hname;
|
||||
hname.heroId = -1;
|
||||
hname.heroId = HeroTypeID::NONE;
|
||||
std::string rawId = data["type"].String();
|
||||
|
||||
if(!rawId.empty())
|
||||
hname.heroId = HeroTypeID::decode(rawId);
|
||||
hname.heroId = HeroTypeID(HeroTypeID::decode(rawId));
|
||||
|
||||
hname.heroName = data["name"].String();
|
||||
|
||||
@@ -574,9 +574,9 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
|
||||
{
|
||||
//this is main hero
|
||||
info.mainCustomHeroNameTextId = hname.heroName;
|
||||
info.hasRandomHero = (hname.heroId == -1);
|
||||
info.hasRandomHero = (hname.heroId == HeroTypeID::NONE);
|
||||
info.mainCustomHeroId = hname.heroId;
|
||||
info.mainCustomHeroPortrait = -1;
|
||||
info.mainCustomHeroPortrait = HeroTypeID::NONE;
|
||||
//todo:mainHeroPortrait
|
||||
}
|
||||
|
||||
@@ -744,7 +744,7 @@ void CMapFormatJson::readDisposedHeroes(JsonSerializeFormat & handler)
|
||||
{
|
||||
DisposedHero hero;
|
||||
|
||||
hero.heroId = type.getNum();
|
||||
hero.heroId = type;
|
||||
hero.players = mask;
|
||||
//name and portrait are not used
|
||||
|
||||
|
||||
Reference in New Issue
Block a user