mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Remove boarded boat as a separate call to player interfaces
This commit is contained in:
@@ -453,19 +453,6 @@ void VCAI::objectRemoved(const CGObjectInstance * obj, const PlayerColor & initi
|
|||||||
//clear resource manager goal cache
|
//clear resource manager goal cache
|
||||||
ah->removeOutdatedObjectives(checkRemovalValidity);
|
ah->removeOutdatedObjectives(checkRemovalValidity);
|
||||||
|
|
||||||
//TODO: Find better way to handle hero boat removal
|
|
||||||
if(auto hero = dynamic_cast<const CGHeroInstance *>(obj))
|
|
||||||
{
|
|
||||||
if(hero->inBoat())
|
|
||||||
{
|
|
||||||
vstd::erase_if_present(visitableObjs, hero->getBoat());
|
|
||||||
vstd::erase_if_present(alreadyVisited, hero->getBoat());
|
|
||||||
|
|
||||||
for(auto h : cb->getHeroesInfo())
|
|
||||||
unreserveObject(h, hero->getBoat());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//there are other places where CGObjectinstance ptrs are stored...
|
//there are other places where CGObjectinstance ptrs are stored...
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "../lib/CSoundBase.h"
|
#include "../lib/CSoundBase.h"
|
||||||
#include "../lib/StartInfo.h"
|
#include "../lib/StartInfo.h"
|
||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
|
#include "../lib/mapObjects/MiscObjects.h"
|
||||||
#include "../lib/mapObjects/CGMarket.h"
|
#include "../lib/mapObjects/CGMarket.h"
|
||||||
#include "../lib/mapObjects/CGTownInstance.h"
|
#include "../lib/mapObjects/CGTownInstance.h"
|
||||||
#include "../lib/gameState/CGameState.h"
|
#include "../lib/gameState/CGameState.h"
|
||||||
@@ -478,8 +479,11 @@ void ApplyClientNetPackVisitor::visitRemoveBonus(RemoveBonus & pack)
|
|||||||
void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
|
void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
|
||||||
{
|
{
|
||||||
const CGObjectInstance *o = cl.gameInfo().getObj(pack.objectID);
|
const CGObjectInstance *o = cl.gameInfo().getObj(pack.objectID);
|
||||||
|
const auto * h = dynamic_cast<const CGHeroInstance*>(o);
|
||||||
|
|
||||||
GAME->map().onObjectFadeOut(o, pack.initiator);
|
GAME->map().onObjectFadeOut(o, pack.initiator);
|
||||||
|
if (h && h->inBoat())
|
||||||
|
GAME->map().onObjectFadeOut(h->getBoat(), pack.initiator);
|
||||||
|
|
||||||
//notify interfaces about removal
|
//notify interfaces about removal
|
||||||
for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
|
for(auto i=cl.playerint.begin(); i!=cl.playerint.end(); i++)
|
||||||
@@ -487,7 +491,11 @@ void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
|
|||||||
//below line contains little cheat for AI so it will be aware of deletion of enemy heroes that moved or got re-covered by FoW
|
//below line contains little cheat for AI so it will be aware of deletion of enemy heroes that moved or got re-covered by FoW
|
||||||
//TODO: loose requirements as next AI related crashes appear, for example another pack.player collects object that got re-covered by FoW, unsure if AI code workarounds this
|
//TODO: loose requirements as next AI related crashes appear, for example another pack.player collects object that got re-covered by FoW, unsure if AI code workarounds this
|
||||||
if(gs.isVisibleFor(o, i->first) || (!cl.gameInfo().getPlayerState(i->first)->human && o->ID == Obj::HERO && o->tempOwner != i->first))
|
if(gs.isVisibleFor(o, i->first) || (!cl.gameInfo().getPlayerState(i->first)->human && o->ID == Obj::HERO && o->tempOwner != i->first))
|
||||||
|
{
|
||||||
i->second->objectRemoved(o, pack.initiator);
|
i->second->objectRemoved(o, pack.initiator);
|
||||||
|
if (h && h->inBoat())
|
||||||
|
i->second->objectRemoved(h->getBoat(), pack.initiator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GAME->map().waitForOngoingAnimations();
|
GAME->map().waitForOngoingAnimations();
|
||||||
|
|||||||
Reference in New Issue
Block a user