mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
Refactoring: replace macro with variadic templates on client-side
Big thanks to @mwu-tow for helping me with this.
This commit is contained in:
parent
7c77249d37
commit
fc3b8b2c87
@ -485,8 +485,8 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
// for(FileInfo &m : scriptModules)
|
||||
// {
|
||||
// CScriptingModule * nm = CDynLibHandler::getNewScriptingModule(m.name);
|
||||
// privilagedGameEventReceivers.push_back(nm);
|
||||
// privilagedBattleEventReceivers.push_back(nm);
|
||||
// privilegedGameEventReceivers.push_back(nm);
|
||||
// privilegedBattleEventReceivers.push_back(nm);
|
||||
// nm->giveActionCB(this);
|
||||
// nm->giveInfoCB(this);
|
||||
// nm->init();
|
||||
@ -925,7 +925,7 @@ void CClient::installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInte
|
||||
PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);
|
||||
|
||||
if(!color)
|
||||
privilagedGameEventReceivers.push_back(gameInterface);
|
||||
privilegedGameEventReceivers.push_back(gameInterface);
|
||||
|
||||
playerint[colorUsed] = gameInterface;
|
||||
|
||||
@ -944,7 +944,7 @@ void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> ba
|
||||
PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);
|
||||
|
||||
if(!color)
|
||||
privilagedBattleEventReceivers.push_back(battleInterface);
|
||||
privilegedBattleEventReceivers.push_back(battleInterface);
|
||||
|
||||
battleints[colorUsed] = battleInterface;
|
||||
|
||||
|
@ -128,8 +128,8 @@ class CClient : public IGameCallback
|
||||
public:
|
||||
std::map<PlayerColor,std::shared_ptr<CCallback> > callbacks; //callbacks given to player interfaces
|
||||
std::map<PlayerColor,std::shared_ptr<CBattleCallback> > battleCallbacks; //callbacks given to player interfaces
|
||||
std::vector<std::shared_ptr<IGameEventsReceiver>> privilagedGameEventReceivers; //scripting modules, spectator interfaces
|
||||
std::vector<std::shared_ptr<IBattleEventsReceiver>> privilagedBattleEventReceivers; //scripting modules, spectator interfaces
|
||||
std::vector<std::shared_ptr<IGameEventsReceiver>> privilegedGameEventReceivers; //scripting modules, spectator interfaces
|
||||
std::vector<std::shared_ptr<IBattleEventsReceiver>> privilegedBattleEventReceivers; //scripting modules, spectator interfaces
|
||||
std::map<PlayerColor, std::shared_ptr<CGameInterface>> playerint;
|
||||
std::map<PlayerColor, std::shared_ptr<CBattleGameInterface>> battleints;
|
||||
|
||||
|
@ -42,79 +42,87 @@
|
||||
#include "widgets/AdventureMapClasses.h"
|
||||
#include "CMT.h"
|
||||
|
||||
//macros to avoid code duplication - calls given method with given arguments if interface for specific player is present
|
||||
//awaiting variadic templates...
|
||||
#define CALL_IN_PRIVILAGED_INTS(function, ...) \
|
||||
do \
|
||||
{ \
|
||||
for(auto &ger : cl->privilagedGameEventReceivers) \
|
||||
ger->function(__VA_ARGS__); \
|
||||
} while(0)
|
||||
// TODO: as Tow suggested these template should all be part of CClient
|
||||
// This will require rework spectator interface properly though
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callPrivilegedInterfaces(CClient * cl, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
for(auto &ger : cl->privilegedGameEventReceivers)
|
||||
((*ger).*ptr)(std::forward<Args2>(args)...);
|
||||
}
|
||||
|
||||
#define CALL_ONLY_THAT_INTERFACE(player, function, ...) \
|
||||
do \
|
||||
{ \
|
||||
if(vstd::contains(cl->playerint,player)) \
|
||||
cl->playerint[player]->function(__VA_ARGS__); \
|
||||
}while(0)
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
bool callOnlyThatInterface(CClient * cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
if(vstd::contains(cl->playerint, player))
|
||||
{
|
||||
((*cl->playerint[player]).*ptr)(std::forward<Args2>(args)...);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#define INTERFACE_CALL_IF_PRESENT(player,function,...) \
|
||||
do \
|
||||
{ \
|
||||
CALL_ONLY_THAT_INTERFACE(player, function, __VA_ARGS__);\
|
||||
CALL_IN_PRIVILAGED_INTS(function, __VA_ARGS__); \
|
||||
} while(0)
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
bool callInterfaceIfPresent(CClient * cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
bool called = callOnlyThatInterface(cl, player, ptr, std::forward<Args2>(args)...);
|
||||
callPrivilegedInterfaces(cl, ptr, std::forward<Args2>(args)...);
|
||||
return called;
|
||||
}
|
||||
|
||||
#define CALL_ONLY_THAT_BATTLE_INTERFACE(player,function, ...) \
|
||||
do \
|
||||
{ \
|
||||
if(vstd::contains(cl->battleints,player)) \
|
||||
cl->battleints[player]->function(__VA_ARGS__); \
|
||||
\
|
||||
if(cl->additionalBattleInts.count(player)) \
|
||||
{ \
|
||||
for(auto bInt : cl->additionalBattleInts[player])\
|
||||
bInt->function(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0);
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callOnlyThatBattleInterface(CClient * cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
if(vstd::contains(cl->battleints,player))
|
||||
((*cl->battleints[player]).*ptr)(std::forward<Args2>(args)...);
|
||||
|
||||
#define BATTLE_INTERFACE_CALL_RECEIVERS(function,...) \
|
||||
do \
|
||||
{ \
|
||||
for(auto & ber : cl->privilagedBattleEventReceivers)\
|
||||
ber->function(__VA_ARGS__); \
|
||||
} while(0)
|
||||
if(cl->additionalBattleInts.count(player))
|
||||
{
|
||||
for(auto bInt : cl->additionalBattleInts[player])
|
||||
((*bInt).*ptr)(std::forward<Args2>(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
#define BATTLE_INTERFACE_CALL_IF_PRESENT(player,function,...) \
|
||||
do \
|
||||
{ \
|
||||
CALL_ONLY_THAT_INTERFACE(player, function, __VA_ARGS__);\
|
||||
BATTLE_INTERFACE_CALL_RECEIVERS(function, __VA_ARGS__); \
|
||||
} while(0)
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callPrivilegedBattleInterfaces(CClient * cl, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
for(auto & ber : cl->privilegedBattleEventReceivers)
|
||||
((*ber).*ptr)(std::forward<Args2>(args)...);
|
||||
}
|
||||
|
||||
//calls all normal interfaces and privilaged ones, playerints may be updated when iterating over it, so we need a copy
|
||||
#define CALL_IN_ALL_INTERFACES(function, ...) \
|
||||
do \
|
||||
{ \
|
||||
auto ints = cl->playerint; \
|
||||
for(auto i = ints.begin(); i != ints.end(); i++)\
|
||||
CALL_ONLY_THAT_INTERFACE(i->first, function, __VA_ARGS__); \
|
||||
} while(0)
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callBattleInterfaceIfPresent(CClient * cl, PlayerColor player, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
callOnlyThatInterface(cl, player, ptr, std::forward<Args2>(args)...);
|
||||
callPrivilegedBattleInterfaces(cl, ptr, std::forward<Args2>(args)...);
|
||||
}
|
||||
|
||||
//calls all normal interfaces and privileged ones, playerints may be updated when iterating over it, so we need a copy
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callAllInterfaces(CClient * cl, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
for(auto pInt : cl->playerint)
|
||||
((*pInt.second).*ptr)(std::forward<Args2>(args)...);
|
||||
}
|
||||
|
||||
//calls all normal interfaces and privileged ones, playerints may be updated when iterating over it, so we need a copy
|
||||
template<typename T, typename ... Args, typename ... Args2>
|
||||
void callBattleInterfaceIfPresentForBothSides(CClient * cl, void (T::*ptr)(Args...), Args2 && ...args)
|
||||
{
|
||||
callOnlyThatBattleInterface(cl, cl->gameState()->curB->sides[0].color, ptr, std::forward<Args2>(args)...);
|
||||
callOnlyThatBattleInterface(cl, cl->gameState()->curB->sides[1].color, ptr, std::forward<Args2>(args)...);
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool() && LOCPLINT->battleInt)
|
||||
{
|
||||
callOnlyThatBattleInterface(cl, PlayerColor::SPECTATOR, ptr, std::forward<Args2>(args)...);
|
||||
}
|
||||
callPrivilegedBattleInterfaces(cl, ptr, std::forward<Args2>(args)...);
|
||||
}
|
||||
|
||||
#define BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(function,...) \
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[0].color, function, __VA_ARGS__) \
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[1].color, function, __VA_ARGS__) \
|
||||
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool() && LOCPLINT->battleInt) \
|
||||
{ \
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(PlayerColor::SPECTATOR, function, __VA_ARGS__) \
|
||||
} \
|
||||
BATTLE_INTERFACE_CALL_RECEIVERS(function, __VA_ARGS__)
|
||||
|
||||
void SetResources::applyCl(CClient *cl)
|
||||
{
|
||||
//todo: inform on actual resource set transfered
|
||||
INTERFACE_CALL_IF_PRESENT(player,receivedResource);
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::receivedResource);
|
||||
}
|
||||
|
||||
void SetPrimSkill::applyCl(CClient *cl)
|
||||
@ -125,7 +133,7 @@ void SetPrimSkill::applyCl(CClient *cl)
|
||||
logNetwork->error("Cannot find hero with ID %d", id.getNum());
|
||||
return;
|
||||
}
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroPrimarySkillChanged,h,which,val);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroPrimarySkillChanged, h, which, val);
|
||||
}
|
||||
|
||||
void SetSecSkill::applyCl(CClient *cl)
|
||||
@ -136,7 +144,7 @@ void SetSecSkill::applyCl(CClient *cl)
|
||||
logNetwork->error("Cannot find hero with ID %d", id.getNum());
|
||||
return;
|
||||
}
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroSecondarySkillChanged,h,which,val);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroSecondarySkillChanged, h, which, val);
|
||||
}
|
||||
|
||||
void HeroVisitCastle::applyCl(CClient *cl)
|
||||
@ -145,7 +153,7 @@ void HeroVisitCastle::applyCl(CClient *cl)
|
||||
|
||||
if(start())
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroVisitsTown, h, GS(cl)->getTown(tid));
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroVisitsTown, h, GS(cl)->getTown(tid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,14 +165,14 @@ void ChangeSpells::applyCl(CClient *cl)
|
||||
void SetMana::applyCl(CClient *cl)
|
||||
{
|
||||
const CGHeroInstance *h = cl->getHero(hid);
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroManaPointsChanged, h);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroManaPointsChanged, h);
|
||||
}
|
||||
|
||||
void SetMovePoints::applyCl(CClient *cl)
|
||||
{
|
||||
const CGHeroInstance *h = cl->getHero(hid);
|
||||
cl->invalidatePaths();
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroMovePointsChanged, h);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroMovePointsChanged, h);
|
||||
}
|
||||
|
||||
void FoWChange::applyCl(CClient *cl)
|
||||
@ -193,69 +201,69 @@ void SetAvailableHeroes::applyCl(CClient *cl)
|
||||
|
||||
void ChangeStackCount::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChagedCount, sl, count, absoluteValue);
|
||||
callInterfaceIfPresent(cl, sl.army->tempOwner, &IGameEventsReceiver::stackChagedCount, sl, count, absoluteValue);
|
||||
}
|
||||
|
||||
void SetStackType::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChangedType, sl, *type);
|
||||
callInterfaceIfPresent(cl, sl.army->tempOwner, &IGameEventsReceiver::stackChangedType, sl, *type);
|
||||
}
|
||||
|
||||
void EraseStack::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stacksErased, sl);
|
||||
callInterfaceIfPresent(cl, sl.army->tempOwner, &IGameEventsReceiver::stacksErased, sl);
|
||||
}
|
||||
|
||||
void SwapStacks::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(sl1.army->tempOwner, stacksSwapped, sl1, sl2);
|
||||
callInterfaceIfPresent(cl, sl1.army->tempOwner, &IGameEventsReceiver::stacksSwapped, sl1, sl2);
|
||||
if(sl1.army->tempOwner != sl2.army->tempOwner)
|
||||
INTERFACE_CALL_IF_PRESENT(sl2.army->tempOwner, stacksSwapped, sl1, sl2);
|
||||
callInterfaceIfPresent(cl, sl2.army->tempOwner, &IGameEventsReceiver::stacksSwapped, sl1, sl2);
|
||||
}
|
||||
|
||||
void InsertNewStack::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner,newStackInserted,sl, *sl.getStack());
|
||||
callInterfaceIfPresent(cl, sl.army->tempOwner, &IGameEventsReceiver::newStackInserted, sl, *sl.getStack());
|
||||
}
|
||||
|
||||
void RebalanceStacks::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(src.army->tempOwner, stacksRebalanced, src, dst, count);
|
||||
callInterfaceIfPresent(cl, src.army->tempOwner, &IGameEventsReceiver::stacksRebalanced, src, dst, count);
|
||||
if(src.army->tempOwner != dst.army->tempOwner)
|
||||
INTERFACE_CALL_IF_PRESENT(dst.army->tempOwner,stacksRebalanced, src, dst, count);
|
||||
callInterfaceIfPresent(cl, dst.army->tempOwner, &IGameEventsReceiver::stacksRebalanced, src, dst, count);
|
||||
}
|
||||
|
||||
void PutArtifact::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactPut, al);
|
||||
callInterfaceIfPresent(cl, al.owningPlayer(), &IGameEventsReceiver::artifactPut, al);
|
||||
}
|
||||
|
||||
void EraseArtifact::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactRemoved, al);
|
||||
callInterfaceIfPresent(cl, al.owningPlayer(), &IGameEventsReceiver::artifactRemoved, al);
|
||||
}
|
||||
|
||||
void MoveArtifact::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(src.owningPlayer(), artifactMoved, src, dst);
|
||||
callInterfaceIfPresent(cl, src.owningPlayer(), &IGameEventsReceiver::artifactMoved, src, dst);
|
||||
if(src.owningPlayer() != dst.owningPlayer())
|
||||
INTERFACE_CALL_IF_PRESENT(dst.owningPlayer(), artifactMoved, src, dst);
|
||||
callInterfaceIfPresent(cl, dst.owningPlayer(), &IGameEventsReceiver::artifactMoved, src, dst);
|
||||
}
|
||||
|
||||
void AssembledArtifact::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactAssembled, al);
|
||||
callInterfaceIfPresent(cl, al.owningPlayer(), &IGameEventsReceiver::artifactAssembled, al);
|
||||
}
|
||||
|
||||
void DisassembledArtifact::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactDisassembled, al);
|
||||
callInterfaceIfPresent(cl, al.owningPlayer(), &IGameEventsReceiver::artifactDisassembled, al);
|
||||
}
|
||||
|
||||
void HeroVisit::applyCl(CClient *cl)
|
||||
{
|
||||
assert(hero);
|
||||
INTERFACE_CALL_IF_PRESENT(player, heroVisit, hero, obj, starting);
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::heroVisit, hero, obj, starting);
|
||||
}
|
||||
|
||||
void NewTurn::applyCl(CClient *cl)
|
||||
@ -272,13 +280,13 @@ void GiveBonus::applyCl(CClient *cl)
|
||||
case HERO:
|
||||
{
|
||||
const CGHeroInstance *h = GS(cl)->getHero(ObjectInstanceID(id));
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroBonusChanged, h, *h->getBonusList().back(),true);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, *h->getBonusList().back(), true);
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
{
|
||||
const PlayerState *p = GS(cl)->getPlayer(PlayerColor(id));
|
||||
INTERFACE_CALL_IF_PRESENT(PlayerColor(id), playerBonusChanged, *p->getBonusList().back(), true);
|
||||
callInterfaceIfPresent(cl, PlayerColor(id), &IGameEventsReceiver::playerBonusChanged, *p->getBonusList().back(), true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -301,7 +309,7 @@ void ChangeObjPos::applyCl(CClient *cl)
|
||||
|
||||
void PlayerEndsGame::applyCl(CClient *cl)
|
||||
{
|
||||
CALL_IN_ALL_INTERFACES(gameOver, player, victoryLossCheckResult);
|
||||
callAllInterfaces(cl, &IGameEventsReceiver::gameOver, player, victoryLossCheckResult);
|
||||
|
||||
// In auto testing mode we always close client if red player won or lose
|
||||
if(!settings["session"]["testmap"].isNull() && player == PlayerColor(0))
|
||||
@ -316,13 +324,13 @@ void RemoveBonus::applyCl(CClient *cl)
|
||||
case HERO:
|
||||
{
|
||||
const CGHeroInstance *h = GS(cl)->getHero(ObjectInstanceID(id));
|
||||
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroBonusChanged, h, bonus,false);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroBonusChanged, h, bonus, false);
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
{
|
||||
//const PlayerState *p = GS(cl)->getPlayer(id);
|
||||
INTERFACE_CALL_IF_PRESENT(PlayerColor(id), playerBonusChanged, bonus, false);
|
||||
callInterfaceIfPresent(cl, PlayerColor(id), &IGameEventsReceiver::playerBonusChanged, bonus, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -430,8 +438,7 @@ void NewStructures::applyCl(CClient *cl)
|
||||
CGTownInstance *town = GS(cl)->getTown(tid);
|
||||
for(const auto & id : bid)
|
||||
{
|
||||
if(vstd::contains(cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged(town,id,1);
|
||||
callInterfaceIfPresent(cl, town->tempOwner, &IGameEventsReceiver::buildChanged, town, id, 1);
|
||||
}
|
||||
}
|
||||
void RazeStructures::applyCl (CClient *cl)
|
||||
@ -439,8 +446,7 @@ void RazeStructures::applyCl (CClient *cl)
|
||||
CGTownInstance *town = GS(cl)->getTown(tid);
|
||||
for(const auto & id : bid)
|
||||
{
|
||||
if(vstd::contains (cl->playerint,town->tempOwner))
|
||||
cl->playerint[town->tempOwner]->buildChanged (town,id,2);
|
||||
callInterfaceIfPresent(cl, town->tempOwner, &IGameEventsReceiver::buildChanged, town, id, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,7 +462,7 @@ void SetAvailableCreatures::applyCl(CClient *cl)
|
||||
else
|
||||
p = dw->tempOwner;
|
||||
|
||||
INTERFACE_CALL_IF_PRESENT(p, availableCreaturesChanged, dw);
|
||||
callInterfaceIfPresent(cl, p, &IGameEventsReceiver::availableCreaturesChanged, dw);
|
||||
}
|
||||
|
||||
void SetHeroesInTown::applyCl(CClient *cl)
|
||||
@ -489,12 +495,11 @@ void HeroRecruited::applyCl(CClient *cl)
|
||||
}
|
||||
|
||||
bool needsPrinting = true;
|
||||
if(vstd::contains(cl->playerint, h->tempOwner))
|
||||
if(callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroCreated, h))
|
||||
{
|
||||
cl->playerint[h->tempOwner]->heroCreated(h);
|
||||
if(const CGTownInstance *t = GS(cl)->getTown(tid))
|
||||
{
|
||||
cl->playerint[h->tempOwner]->heroInGarrisonChange(t);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroInGarrisonChange, t);
|
||||
needsPrinting = false;
|
||||
}
|
||||
}
|
||||
@ -507,7 +512,7 @@ void GiveHero::applyCl(CClient *cl)
|
||||
CGHeroInstance *h = GS(cl)->getHero(id);
|
||||
if(CGI->mh)
|
||||
CGI->mh->printObject(h);
|
||||
cl->playerint[h->tempOwner]->heroCreated(h);
|
||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroCreated, h);
|
||||
}
|
||||
|
||||
void GiveHero::applyFirstCl(CClient *cl)
|
||||
@ -526,9 +531,7 @@ void InfoWindow::applyCl(CClient *cl)
|
||||
std::string str;
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
||||
else
|
||||
if(!callInterfaceIfPresent(cl, player, &CGameInterface::showInfoDialog, str,comps,(soundBase::soundID)soundID))
|
||||
logNetwork->warn("We received InfoWindow for not our player...");
|
||||
}
|
||||
|
||||
@ -538,30 +541,21 @@ void SetObjectProperty::applyCl(CClient *cl)
|
||||
for(auto it = cl->playerint.cbegin(); it != cl->playerint.cend(); ++it)
|
||||
{
|
||||
if(GS(cl)->isVisible(GS(cl)->getObjInstance(id), it->first))
|
||||
INTERFACE_CALL_IF_PRESENT(it->first, objectPropertyChanged, this);
|
||||
callInterfaceIfPresent(cl, it->first, &IGameEventsReceiver::objectPropertyChanged, this);
|
||||
}
|
||||
}
|
||||
|
||||
void HeroLevelUp::applyCl(CClient *cl)
|
||||
{
|
||||
//INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroGotLevel, h, primskill, skills, id);
|
||||
if(vstd::contains(cl->playerint,hero->tempOwner))
|
||||
{
|
||||
cl->playerint[hero->tempOwner]->heroGotLevel(hero, primskill, skills, queryID);
|
||||
}
|
||||
//else
|
||||
// cb->selectionMade(0, queryID);
|
||||
callOnlyThatInterface(cl, hero->tempOwner, &CGameInterface::heroGotLevel, hero, primskill, skills, queryID);
|
||||
}
|
||||
|
||||
void CommanderLevelUp::applyCl(CClient *cl)
|
||||
{
|
||||
const CCommanderInstance * commander = hero->commander;
|
||||
assert (commander);
|
||||
PlayerColor player = hero->tempOwner;
|
||||
if (commander->armyObj && vstd::contains(cl->playerint, player)) //is it possible for Commander to exist beyond armed instance?
|
||||
{
|
||||
cl->playerint[player]->commanderGotLevel(commander, skills, queryID);
|
||||
}
|
||||
assert(commander);
|
||||
assert(commander->armyObj); //is it possible for Commander to exist beyond armed instance?
|
||||
callOnlyThatInterface(cl, hero->tempOwner, &CGameInterface::commanderGotLevel, commander, skills, queryID);
|
||||
}
|
||||
|
||||
void BlockingDialog::applyCl(CClient *cl)
|
||||
@ -569,9 +563,7 @@ void BlockingDialog::applyCl(CClient *cl)
|
||||
std::string str;
|
||||
text.toString(str);
|
||||
|
||||
if(vstd::contains(cl->playerint,player))
|
||||
cl->playerint.at(player)->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
||||
else
|
||||
if(!callOnlyThatInterface(cl, player, &CGameInterface::showBlockingDialog, str, components, queryID, (soundBase::soundID)soundID, selection(), cancel()))
|
||||
logNetwork->warn("We received YesNoDialog for not our player...");
|
||||
}
|
||||
|
||||
@ -580,38 +572,35 @@ void GarrisonDialog::applyCl(CClient *cl)
|
||||
const CGHeroInstance *h = cl->getHero(hid);
|
||||
const CArmedInstance *obj = static_cast<const CArmedInstance*>(cl->getObj(objid));
|
||||
|
||||
if(!vstd::contains(cl->playerint,h->getOwner()))
|
||||
return;
|
||||
|
||||
cl->playerint.at(h->getOwner())->showGarrisonDialog(obj,h,removableUnits,queryID);
|
||||
callOnlyThatInterface(cl, h->getOwner(), &CGameInterface::showGarrisonDialog, obj, h, removableUnits, queryID);
|
||||
}
|
||||
|
||||
void ExchangeDialog::applyCl(CClient *cl)
|
||||
{
|
||||
assert(heroes[0] && heroes[1]);
|
||||
INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
|
||||
callInterfaceIfPresent(cl, heroes[0]->tempOwner, &IGameEventsReceiver::heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
|
||||
}
|
||||
|
||||
void TeleportDialog::applyCl(CClient *cl)
|
||||
{
|
||||
CALL_ONLY_THAT_INTERFACE(hero->tempOwner,showTeleportDialog,channel,exits,impassable,queryID);
|
||||
callOnlyThatInterface(cl, hero->tempOwner, &CGameInterface::showTeleportDialog, channel, exits, impassable, queryID);
|
||||
}
|
||||
|
||||
void MapObjectSelectDialog::applyCl(CClient * cl)
|
||||
{
|
||||
CALL_ONLY_THAT_INTERFACE(player, showMapObjectSelectDialog, queryID, icon, title, description, objects);
|
||||
callOnlyThatInterface(cl, player, &CGameInterface::showMapObjectSelectDialog, queryID, icon, title, description, objects);
|
||||
}
|
||||
|
||||
void BattleStart::applyFirstCl(CClient *cl)
|
||||
{
|
||||
//Cannot use the usual macro because curB is not set yet
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(info->sides[0].color, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
// Cannot use the usual code because curB is not set yet
|
||||
callOnlyThatBattleInterface(cl, info->sides[0].color, &IBattleEventsReceiver::battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
info->tile, info->sides[0].hero, info->sides[1].hero);
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(info->sides[1].color, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
callOnlyThatBattleInterface(cl, info->sides[1].color, &IBattleEventsReceiver::battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
info->tile, info->sides[0].hero, info->sides[1].hero);
|
||||
CALL_ONLY_THAT_BATTLE_INTERFACE(PlayerColor::SPECTATOR, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
callOnlyThatBattleInterface(cl, PlayerColor::SPECTATOR, &IBattleEventsReceiver::battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
info->tile, info->sides[0].hero, info->sides[1].hero);
|
||||
BATTLE_INTERFACE_CALL_RECEIVERS(battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
callPrivilegedBattleInterfaces(cl, &IBattleEventsReceiver::battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject,
|
||||
info->tile, info->sides[0].hero, info->sides[1].hero);
|
||||
}
|
||||
|
||||
@ -622,12 +611,12 @@ void BattleStart::applyCl(CClient *cl)
|
||||
|
||||
void BattleNextRound::applyFirstCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRoundFirst,round);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleNewRoundFirst, round);
|
||||
}
|
||||
|
||||
void BattleNextRound::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRound,round);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleNewRound, round);
|
||||
}
|
||||
|
||||
void BattleSetActiveStack::applyCl(CClient *cl)
|
||||
@ -653,29 +642,29 @@ void BattleSetActiveStack::applyCl(CClient *cl)
|
||||
|
||||
void BattleTriggerEffect::applyCl(CClient * cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleTriggerEffect, *this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleTriggerEffect, *this);
|
||||
}
|
||||
|
||||
void BattleObstaclePlaced::applyCl(CClient * cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleObstaclePlaced, *obstacle);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleObstaclePlaced, *obstacle);
|
||||
}
|
||||
|
||||
void BattleUpdateGateState::applyFirstCl(CClient * cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleGateStateChanged, state);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleGateStateChanged, state);
|
||||
}
|
||||
|
||||
void BattleResult::applyFirstCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleEnd,this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleEnd, this);
|
||||
cl->battleFinished();
|
||||
}
|
||||
|
||||
void BattleStackMoved::applyFirstCl(CClient *cl)
|
||||
{
|
||||
const CStack * movedStack = GS(cl)->curB->battleGetStackByID(stack);
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStackMoved,movedStack,tilesToMove,distance);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStackMoved, movedStack, tilesToMove, distance);
|
||||
}
|
||||
|
||||
//void BattleStackAttacked::(CClient *cl)
|
||||
@ -684,12 +673,12 @@ void BattleStackAttacked::applyFirstCl(CClient *cl)
|
||||
std::vector<BattleStackAttacked> bsa;
|
||||
bsa.push_back(*this);
|
||||
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksAttacked, bsa);
|
||||
}
|
||||
|
||||
void BattleAttack::applyFirstCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleAttack,this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleAttack, this);
|
||||
for (auto & elem : bsa)
|
||||
{
|
||||
for (int z=0; z<elem.healedStacks.size(); ++z)
|
||||
@ -701,36 +690,36 @@ void BattleAttack::applyFirstCl(CClient *cl)
|
||||
|
||||
void BattleAttack::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksAttacked, bsa);
|
||||
}
|
||||
|
||||
void StartAction::applyFirstCl(CClient *cl)
|
||||
{
|
||||
cl->curbaction = boost::make_optional(ba);
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionStarted, ba);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::actionStarted, ba);
|
||||
}
|
||||
|
||||
void BattleSpellCast::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleSpellCast,this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleSpellCast, this);
|
||||
}
|
||||
|
||||
void SetStackEffect::applyCl(CClient *cl)
|
||||
{
|
||||
//informing about effects
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksEffectsSet,*this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksEffectsSet, *this);
|
||||
}
|
||||
|
||||
void StacksInjured::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,stacks);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksAttacked, stacks);
|
||||
}
|
||||
|
||||
void BattleResultsApplied::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(player1, battleResultsApplied);
|
||||
INTERFACE_CALL_IF_PRESENT(player2, battleResultsApplied);
|
||||
INTERFACE_CALL_IF_PRESENT(PlayerColor::SPECTATOR, battleResultsApplied);
|
||||
callInterfaceIfPresent(cl, player1, &IGameEventsReceiver::battleResultsApplied);
|
||||
callInterfaceIfPresent(cl, player2, &IGameEventsReceiver::battleResultsApplied);
|
||||
callInterfaceIfPresent(cl, PlayerColor::SPECTATOR, &IGameEventsReceiver::battleResultsApplied);
|
||||
}
|
||||
|
||||
void StacksHealedOrResurrected::applyCl(CClient * cl)
|
||||
@ -740,30 +729,30 @@ void StacksHealedOrResurrected::applyCl(CClient * cl)
|
||||
{
|
||||
shiftedHealed.push_back(std::make_pair(elem.stackId, (ui32)elem.delta));
|
||||
}
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
|
||||
}
|
||||
|
||||
void ObstaclesRemoved::applyCl(CClient *cl)
|
||||
{
|
||||
//inform interfaces about removed obstacles
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleObstaclesRemoved, obstacles);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleObstaclesRemoved, obstacles);
|
||||
}
|
||||
|
||||
void CatapultAttack::applyCl(CClient *cl)
|
||||
{
|
||||
//inform interfaces about catapult attack
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleCatapultAttacked, *this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleCatapultAttacked, *this);
|
||||
}
|
||||
|
||||
void BattleStacksRemoved::applyFirstCl(CClient * cl)
|
||||
{
|
||||
//inform interfaces about removed stacks
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksRemoved, *this);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleStacksRemoved, *this);
|
||||
}
|
||||
|
||||
void BattleStackAdded::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewStackAppeared, GS(cl)->curB->stacks.back());
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::battleNewStackAppeared, GS(cl)->curB->stacks.back());
|
||||
}
|
||||
|
||||
CGameState* CPackForClient::GS(CClient *cl)
|
||||
@ -773,13 +762,13 @@ CGameState* CPackForClient::GS(CClient *cl)
|
||||
|
||||
void EndAction::applyCl(CClient *cl)
|
||||
{
|
||||
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionFinished, *cl->curbaction);
|
||||
callBattleInterfaceIfPresentForBothSides(cl, &IBattleEventsReceiver::actionFinished, *cl->curbaction);
|
||||
cl->curbaction.reset();
|
||||
}
|
||||
|
||||
void PackageApplied::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::requestRealized, this);
|
||||
if(!CClient::waitingRequest.tryRemovingElement(requestID))
|
||||
logNetwork->warn("Surprising server message!");
|
||||
}
|
||||
@ -796,13 +785,13 @@ void SystemMessage::applyCl(CClient *cl)
|
||||
|
||||
void PlayerBlocked::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(player,playerBlocked,reason, startOrEnd==BLOCKADE_STARTED);
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::playerBlocked, reason, startOrEnd == BLOCKADE_STARTED);
|
||||
}
|
||||
|
||||
void YourTurn::applyCl(CClient *cl)
|
||||
{
|
||||
CALL_IN_ALL_INTERFACES(playerStartsTurn, player);
|
||||
CALL_ONLY_THAT_INTERFACE(player,yourTurn);
|
||||
callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, player);
|
||||
callOnlyThatInterface(cl, player, &CGameInterface::yourTurn);
|
||||
}
|
||||
|
||||
void SaveGame::applyCl(CClient *cl)
|
||||
@ -837,19 +826,19 @@ void PlayerMessage::applyCl(CClient *cl)
|
||||
|
||||
void ShowInInfobox::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(player,showComp, c, text.toString());
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::showComp, c, text.toString());
|
||||
}
|
||||
|
||||
void AdvmapSpellCast::applyCl(CClient *cl)
|
||||
{
|
||||
cl->invalidatePaths();
|
||||
//consider notifying other interfaces that see hero?
|
||||
INTERFACE_CALL_IF_PRESENT(caster->getOwner(),advmapSpellCast, caster, spellID);
|
||||
callInterfaceIfPresent(cl, caster->getOwner(), &IGameEventsReceiver::advmapSpellCast, caster, spellID);
|
||||
}
|
||||
|
||||
void ShowWorldViewEx::applyCl(CClient * cl)
|
||||
{
|
||||
CALL_ONLY_THAT_INTERFACE(player, showWorldViewEx, objectPositions);
|
||||
callOnlyThatInterface(cl, player, &CGameInterface::showWorldViewEx, objectPositions);
|
||||
}
|
||||
|
||||
void OpenWindow::applyCl(CClient *cl)
|
||||
@ -861,20 +850,20 @@ void OpenWindow::applyCl(CClient *cl)
|
||||
{
|
||||
const CGDwelling *dw = dynamic_cast<const CGDwelling*>(cl->getObj(ObjectInstanceID(id1)));
|
||||
const CArmedInstance *dst = dynamic_cast<const CArmedInstance*>(cl->getObj(ObjectInstanceID(id2)));
|
||||
INTERFACE_CALL_IF_PRESENT(dst->tempOwner,showRecruitmentDialog, dw, dst, window == RECRUITMENT_FIRST ? 0 : -1);
|
||||
callInterfaceIfPresent(cl, dst->tempOwner, &IGameEventsReceiver::showRecruitmentDialog, dw, dst, window == RECRUITMENT_FIRST ? 0 : -1);
|
||||
}
|
||||
break;
|
||||
case SHIPYARD_WINDOW:
|
||||
{
|
||||
const IShipyard *sy = IShipyard::castFrom(cl->getObj(ObjectInstanceID(id1)));
|
||||
INTERFACE_CALL_IF_PRESENT(sy->o->tempOwner, showShipyardDialog, sy);
|
||||
callInterfaceIfPresent(cl, sy->o->tempOwner, &IGameEventsReceiver::showShipyardDialog, sy);
|
||||
}
|
||||
break;
|
||||
case THIEVES_GUILD:
|
||||
{
|
||||
//displays Thieves' Guild window (when hero enters Den of Thieves)
|
||||
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id2));
|
||||
INTERFACE_CALL_IF_PRESENT(PlayerColor(id1), showThievesGuildWindow, obj);
|
||||
callInterfaceIfPresent(cl, PlayerColor(id1), &IGameEventsReceiver::showThievesGuildWindow, obj);
|
||||
}
|
||||
break;
|
||||
case UNIVERSITY_WINDOW:
|
||||
@ -882,7 +871,7 @@ void OpenWindow::applyCl(CClient *cl)
|
||||
//displays University window (when hero enters University on adventure map)
|
||||
const IMarket *market = IMarket::castFrom(cl->getObj(ObjectInstanceID(id1)));
|
||||
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
||||
INTERFACE_CALL_IF_PRESENT(hero->tempOwner,showUniversityWindow, market, hero);
|
||||
callInterfaceIfPresent(cl, hero->tempOwner, &IGameEventsReceiver::showUniversityWindow, market, hero);
|
||||
}
|
||||
break;
|
||||
case MARKET_WINDOW:
|
||||
@ -891,7 +880,7 @@ void OpenWindow::applyCl(CClient *cl)
|
||||
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id1));
|
||||
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
||||
const IMarket *market = IMarket::castFrom(obj);
|
||||
INTERFACE_CALL_IF_PRESENT(cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, showMarketWindow, market, hero);
|
||||
callInterfaceIfPresent(cl, cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::showMarketWindow, market, hero);
|
||||
}
|
||||
break;
|
||||
case HILL_FORT_WINDOW:
|
||||
@ -899,18 +888,18 @@ void OpenWindow::applyCl(CClient *cl)
|
||||
//displays Hill fort window
|
||||
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id1));
|
||||
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
||||
INTERFACE_CALL_IF_PRESENT(cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, showHillFortWindow, obj, hero);
|
||||
callInterfaceIfPresent(cl, cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::showHillFortWindow, obj, hero);
|
||||
}
|
||||
break;
|
||||
case PUZZLE_MAP:
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT(PlayerColor(id1), showPuzzleMap);
|
||||
callInterfaceIfPresent(cl, PlayerColor(id1), &IGameEventsReceiver::showPuzzleMap);
|
||||
}
|
||||
break;
|
||||
case TAVERN_WINDOW:
|
||||
const CGObjectInstance *obj1 = cl->getObj(ObjectInstanceID(id1)),
|
||||
*obj2 = cl->getObj(ObjectInstanceID(id2));
|
||||
INTERFACE_CALL_IF_PRESENT(obj1->tempOwner, showTavernWindow, obj2);
|
||||
callInterfaceIfPresent(cl, obj1->tempOwner, &IGameEventsReceiver::showTavernWindow, obj2);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -918,7 +907,7 @@ void OpenWindow::applyCl(CClient *cl)
|
||||
|
||||
void CenterView::applyCl(CClient *cl)
|
||||
{
|
||||
INTERFACE_CALL_IF_PRESENT (player, centerView, pos, focusTime);
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::centerView, pos, focusTime);
|
||||
}
|
||||
|
||||
void NewObject::applyCl(CClient *cl)
|
||||
@ -940,13 +929,12 @@ void SetAvailableArtifacts::applyCl(CClient *cl)
|
||||
{
|
||||
if(id < 0) //artifact merchants globally
|
||||
{
|
||||
for(auto & elem : cl->playerint)
|
||||
elem.second->availableArtifactsChanged(nullptr);
|
||||
callAllInterfaces(cl, &IGameEventsReceiver::availableArtifactsChanged, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CGBlackMarket *bm = dynamic_cast<const CGBlackMarket *>(cl->getObj(ObjectInstanceID(id)));
|
||||
assert(bm);
|
||||
INTERFACE_CALL_IF_PRESENT(cl->getTile(bm->visitablePos())->visitableObjects.back()->tempOwner, availableArtifactsChanged, bm);
|
||||
callInterfaceIfPresent(cl, cl->getTile(bm->visitablePos())->visitableObjects.back()->tempOwner, &IGameEventsReceiver::availableArtifactsChanged, bm);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user