mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Split map object visit from town building visit. Removes side effects
from building visit
This commit is contained in:
@@ -10,34 +10,26 @@
|
||||
#include "StdInc.h"
|
||||
#include "VisitQueries.h"
|
||||
|
||||
#include "QueriesProcessor.h"
|
||||
#include "../CGameHandler.h"
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
#include "../CGameHandler.h"
|
||||
#include "QueriesProcessor.h"
|
||||
|
||||
CObjectVisitQuery::CObjectVisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const CGHeroInstance * Hero):
|
||||
CQuery(owner), visitedObject(Obj), visitingHero(Hero), removeObjectAfterVisit(false)
|
||||
VisitQuery::VisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const CGHeroInstance * Hero)
|
||||
: CQuery(owner)
|
||||
, visitedObject(Obj)
|
||||
, visitingHero(Hero)
|
||||
{
|
||||
addPlayer(Hero->tempOwner);
|
||||
}
|
||||
|
||||
bool CObjectVisitQuery::blocksPack(const CPack *pack) const
|
||||
bool VisitQuery::blocksPack(const CPack * pack) const
|
||||
{
|
||||
//During the visit itself ALL actions are blocked.
|
||||
//(However, the visit may trigger a query above that'll pass some.)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CObjectVisitQuery::onRemoval(PlayerColor color)
|
||||
{
|
||||
gh->objectVisitEnded(*this);
|
||||
|
||||
//TODO or should it be destructor?
|
||||
//Can object visit affect 2 players and what would be desired behavior?
|
||||
if(removeObjectAfterVisit)
|
||||
gh->removeObject(visitedObject, color);
|
||||
}
|
||||
|
||||
void CObjectVisitQuery::onExposure(QueryPtr topQuery)
|
||||
void VisitQuery::onExposure(QueryPtr topQuery)
|
||||
{
|
||||
//Object may have been removed and deleted.
|
||||
if(gh->isValidObject(visitedObject))
|
||||
@@ -45,3 +37,30 @@ void CObjectVisitQuery::onExposure(QueryPtr topQuery)
|
||||
|
||||
owner->popIfTop(*this);
|
||||
}
|
||||
|
||||
MapObjectVisitQuery::MapObjectVisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const CGHeroInstance * Hero)
|
||||
: VisitQuery(owner, Obj, Hero)
|
||||
, removeObjectAfterVisit(false)
|
||||
{
|
||||
}
|
||||
|
||||
void MapObjectVisitQuery::onRemoval(PlayerColor color)
|
||||
{
|
||||
gh->objectVisitEnded(visitingHero, players.front());
|
||||
|
||||
//TODO or should it be destructor?
|
||||
//Can object visit affect 2 players and what would be desired behavior?
|
||||
if(removeObjectAfterVisit)
|
||||
gh->removeObject(visitedObject, color);
|
||||
}
|
||||
|
||||
TownBuildingVisitQuery::TownBuildingVisitQuery(CGameHandler * owner, const CGObjectInstance * Obj, const CGHeroInstance * Hero, BuildingID buildingToVisit)
|
||||
: VisitQuery(owner, Obj, Hero)
|
||||
, visitedBuilding(buildingToVisit)
|
||||
{
|
||||
}
|
||||
|
||||
void TownBuildingVisitQuery::onRemoval(PlayerColor color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user