mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Change deleted objects format to use ObjectInstanceID
This commit is contained in:
		| @@ -404,6 +404,18 @@ void CPlayerInterface::heroKilled(const CGHeroInstance* hero) | ||||
| 	localState->erasePath(hero); | ||||
| } | ||||
|  | ||||
| void CPlayerInterface::townRemoved(const CGTownInstance* town) | ||||
| { | ||||
| 	EVENT_HANDLER_CALLED_BY_CLIENT; | ||||
|  | ||||
| 	if(town->tempOwner == playerID) | ||||
| 	{ | ||||
| 		localState->removeOwnedTown(town); | ||||
| 		adventureInt->onTownChanged(town); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void CPlayerInterface::heroVisit(const CGHeroInstance * visitor, const CGObjectInstance * visitedObj, bool start) | ||||
| { | ||||
| 	EVENT_HANDLER_CALLED_BY_CLIENT; | ||||
| @@ -1421,6 +1433,12 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj, const PlayerC | ||||
| 		const CGHeroInstance * h = static_cast<const CGHeroInstance *>(obj); | ||||
| 		heroKilled(h); | ||||
| 	} | ||||
|  | ||||
| 	if(obj->ID == Obj::TOWN && obj->tempOwner == playerID) | ||||
| 	{ | ||||
| 		const CGTownInstance * t = static_cast<const CGTownInstance *>(obj); | ||||
| 		townRemoved(t); | ||||
| 	} | ||||
| 	GH.fakeMouseMove(); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -220,6 +220,7 @@ private: | ||||
| 	}; | ||||
|  | ||||
| 	void heroKilled(const CGHeroInstance* hero); | ||||
| 	void townRemoved(const CGTownInstance* town); | ||||
| 	void garrisonsChanged(std::vector<const CArmedInstance *> objs); | ||||
| 	void requestReturningToMainMenu(bool won); | ||||
| 	void acceptTurn(QueryID queryID, bool hotseatWait); //used during hot seat after your turn message is close | ||||
|   | ||||
| @@ -962,7 +962,7 @@ void CGameState::initTimedEventsRemovableObjects() | ||||
| 			{ | ||||
| 				for(const CGObjectInstance * object : getBlockingObjs(coordinate)) | ||||
| 				{ | ||||
| 					timedEvent.deletedObjectsInstances.push_back(object); | ||||
| 					timedEvent.deletedObjectsInstances.push_back(object->id); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ public: | ||||
| 	ui32 nextOccurrence; /// specifies after how many days the event will occur the next time; 0 if event occurs only one time | ||||
|  | ||||
| 	std::vector<int3> deletedObjectsCoordinates; | ||||
| 	std::vector<const CGObjectInstance*> deletedObjectsInstances; | ||||
| 	std::vector<ObjectInstanceID> deletedObjectsInstances; | ||||
|  | ||||
| 	std::vector<int3> unused; | ||||
| 	std::set<const CGObjectInstance*> unused2; | ||||
|   | ||||
| @@ -769,7 +769,7 @@ bool CGameHandler::removeObject(const CGObjectInstance * obj, const PlayerColor | ||||
| 	ro.initiator = initiator; | ||||
| 	sendAndApply(&ro); | ||||
|  | ||||
| 	checkVictoryLossConditionsForAll(); //eg if monster escaped (removing objs after battle is done dircetly by endBattle, not this function) | ||||
| 	checkVictoryLossConditionsForAll(); //e.g. if monster escaped (removing objs after battle is done directly by endBattle, not this function) | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -64,20 +64,14 @@ void NewTurnProcessor::handleTimeEvents(PlayerColor color) | ||||
| 		} | ||||
|  | ||||
| 		//remove objects specified by event | ||||
| 		for(const CGObjectInstance * objectToRemove : event.deletedObjectsInstances) | ||||
| 		for(const ObjectInstanceID objectIdToRemove : event.deletedObjectsInstances) | ||||
| 		{ | ||||
| 			removedObjects.push_back(objectToRemove); | ||||
| 			gameHandler->removeObject(objectToRemove, PlayerColor::NEUTRAL); | ||||
| 			auto objectInstance = gameHandler->getObj(objectIdToRemove, false); | ||||
| 			if(objectInstance != nullptr) | ||||
| 				gameHandler->removeObject(objectInstance, 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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user