1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-10 00:43:59 +02:00

Remove deleted objects from timed events data

This commit is contained in:
Dydzio 2024-09-28 21:24:13 +02:00 committed by GitHub
parent 6a7f58c3d1
commit 0589403ea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,6 +40,8 @@ NewTurnProcessor::NewTurnProcessor(CGameHandler * gameHandler)
void NewTurnProcessor::handleTimeEvents(PlayerColor color)
{
std::vector<const CGObjectInstance*> removedObjects;
for (auto const & event : gameHandler->gameState()->map->events)
{
if (!event.occursToday(gameHandler->gameState()->day))
@ -64,10 +66,18 @@ void NewTurnProcessor::handleTimeEvents(PlayerColor color)
//remove objects specified by event
for(const CGObjectInstance * objectToRemove : event.deletedObjectsInstances)
{
removedObjects.push_back(objectToRemove);
gameHandler->removeObject(objectToRemove, PlayerColor::NEUTRAL);
}
gameHandler->sendAndApply(&iw); //show dialog
}
for (auto & event : gameHandler->gameState()->map->events)
vstd::erase_if(event.deletedObjectsInstances,
[removedObjects](const CGObjectInstance * o)
{
return vstd::contains(removedObjects, o);
});
}
void NewTurnProcessor::handleTownEvents(const CGTownInstance * town)