1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +02:00

Implemented serialization of MapObjectSubID, refactoring of related code

This commit is contained in:
Ivan Savenko
2023-11-17 21:18:34 +02:00
parent 9f906ff1d2
commit c872f8418f
15 changed files with 103 additions and 68 deletions

View File

@ -1061,6 +1061,12 @@ void ChangeObjectVisitors::applyGs(CGameState * gs) const
}
break;
case VISITOR_GLOBAL:
{
CGObjectInstance * objectPtr = gs->getObjInstance(object);
gs->getPlayerState(gs->getHero(hero)->tempOwner)->visitedObjectsGlobal.insert({objectPtr->ID, objectPtr->subID});
break;
}
case VISITOR_REMOVE:
gs->getHero(hero)->visitedObjects.erase(object);
break;
@ -1488,7 +1494,7 @@ void NewObject::applyGs(CGameState *gs)
const TerrainTile & t = gs->map->getTile(targetPos);
terrainType = t.terType->getId();
auto handler = VLC->objtypeh->getHandlerFor(ID, subID.getNum());
auto handler = VLC->objtypeh->getHandlerFor(ID, subID);
CGObjectInstance * o = handler->create();
handler->configureObject(o, gs->getRandomGenerator());
@ -1504,7 +1510,7 @@ void NewObject::applyGs(CGameState *gs)
cre->character = 2;
cre->gainedArtifact = ArtifactID::NONE;
cre->identifier = -1;
cre->addToSlot(SlotID(0), new CStackInstance(subID.as<CreatureID>(), -1)); //add placeholder stack
cre->addToSlot(SlotID(0), new CStackInstance(subID.getNum(), -1)); //add placeholder stack
}
assert(!handler->getTemplates(terrainType).empty());