1
0
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:
Ivan Savenko 2024-09-09 23:39:20 +03:00 committed by GitHub
commit a58e209cbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 2 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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());

View File

@ -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
{