mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Merge pull request #4490 from godric3/fix-campaign-hero-placeholder
Fix campaign hero placeholder
This commit is contained in:
commit
a58e209cbd
@ -346,7 +346,7 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(MapObjectID type, MapObj
|
||||
return mapObjectTypes.front()->objectTypeHandlers.front();
|
||||
|
||||
auto subID = subtype.getNum();
|
||||
if (type == Obj::PRISON)
|
||||
if (type == Obj::PRISON || type == Obj::HERO_PLACEHOLDER)
|
||||
subID = 0;
|
||||
auto result = mapObjectTypes.at(type.getNum())->objectTypeHandlers.at(subID);
|
||||
|
||||
|
@ -329,6 +329,8 @@ void CMapFormatJson::serializeHeader(JsonSerializeFormat & handler)
|
||||
|
||||
handler.serializeStruct("defeatMessage", mapHeader->defeatMessage);
|
||||
handler.serializeInt("defeatIconIndex", mapHeader->defeatIconIndex);
|
||||
|
||||
handler.serializeIdArray("reservedCampaignHeroes", mapHeader->reservedCampaignHeroes);
|
||||
}
|
||||
|
||||
void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
|
||||
|
@ -475,7 +475,7 @@ void Inspector::updateProperties()
|
||||
addProperty("TypeName", obj->typeName);
|
||||
addProperty("SubTypeName", obj->subTypeName);
|
||||
|
||||
if(!dynamic_cast<CGHeroInstance*>(obj))
|
||||
if(obj->ID != Obj::HERO_PLACEHOLDER && !dynamic_cast<CGHeroInstance*>(obj))
|
||||
{
|
||||
auto factory = VLC->objtypeh->getHandlerFor(obj->ID, obj->subID);
|
||||
addProperty("IsStatic", factory->isStaticObject());
|
||||
|
@ -452,6 +452,18 @@ void MainWindow::saveMap()
|
||||
|
||||
Translations::cleanupRemovedItems(*controller.map());
|
||||
|
||||
for(auto obj : controller.map()->objects)
|
||||
{
|
||||
if(obj->ID == Obj::HERO_PLACEHOLDER)
|
||||
{
|
||||
auto hero = dynamic_cast<CGHeroPlaceholder *>(obj.get());
|
||||
if(hero->heroType.has_value())
|
||||
{
|
||||
controller.map()->reservedCampaignHeroes.insert(hero->heroType.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CMapService mapService;
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user