2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2009-03-07 17:55:56 +02:00
|
|
|
#include "../lib/NetPacks.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2013-04-07 13:48:07 +03:00
|
|
|
#include "../lib/filesystem/CResourceLoader.h"
|
|
|
|
#include "../lib/filesystem/CFileInfo.h"
|
2009-03-07 17:55:56 +02:00
|
|
|
#include "../CCallback.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "Client.h"
|
|
|
|
#include "CPlayerInterface.h"
|
|
|
|
#include "CGameInfo.h"
|
2009-03-28 20:46:20 +02:00
|
|
|
#include "../lib/Connection.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "../lib/CGeneralTextHandler.h"
|
|
|
|
#include "../lib/CDefObjInfoHandler.h"
|
|
|
|
#include "../lib/CHeroHandler.h"
|
|
|
|
#include "../lib/CObjectHandler.h"
|
2009-03-07 17:55:56 +02:00
|
|
|
#include "../lib/VCMI_Lib.h"
|
2013-04-07 13:48:07 +03:00
|
|
|
#include "../lib/mapping/CMap.h"
|
2009-10-10 08:47:59 +03:00
|
|
|
#include "../lib/VCMIDirs.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "../lib/CSpellHandler.h"
|
|
|
|
#include "CSoundBase.h"
|
2010-04-06 11:59:24 +03:00
|
|
|
#include "mapHandler.h"
|
2009-05-19 21:23:04 +03:00
|
|
|
#include "GUIClasses.h"
|
2012-09-29 13:59:43 +03:00
|
|
|
#include "../lib/CConfigHandler.h"
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "gui/SDL_Extensions.h"
|
|
|
|
#include "battle/CBattleInterface.h"
|
2013-04-07 13:48:07 +03:00
|
|
|
#include "../lib/mapping/CCampaignHandler.h"
|
2010-12-25 21:23:30 +02:00
|
|
|
#include "../lib/CGameState.h"
|
|
|
|
#include "../lib/BattleState.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "../lib/GameConstants.h"
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "gui/CGuiHandler.h"
|
2013-06-17 18:45:55 +03:00
|
|
|
#include "CMT.h"
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2011-05-30 02:49:25 +03:00
|
|
|
//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 \
|
|
|
|
{ \
|
2013-06-23 10:54:33 +03:00
|
|
|
BOOST_FOREACH(auto &ger, cl->privilagedGameEventReceivers) \
|
2011-05-30 02:49:25 +03:00
|
|
|
ger->function(__VA_ARGS__); \
|
|
|
|
} while(0)
|
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
#define CALL_ONLY_THAT_INTERFACE(player, function, ...) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if(vstd::contains(cl->playerint,player)) \
|
|
|
|
cl->playerint[player]->function(__VA_ARGS__); \
|
2012-02-16 20:10:58 +03:00
|
|
|
}while(0)
|
2011-05-10 01:20:47 +03:00
|
|
|
|
2011-05-30 02:49:25 +03:00
|
|
|
#define INTERFACE_CALL_IF_PRESENT(player,function,...) \
|
|
|
|
do \
|
|
|
|
{ \
|
2011-05-10 01:20:47 +03:00
|
|
|
CALL_ONLY_THAT_INTERFACE(player, function, __VA_ARGS__);\
|
2011-05-30 02:49:25 +03:00
|
|
|
CALL_IN_PRIVILAGED_INTS(function, __VA_ARGS__); \
|
2012-02-16 20:10:58 +03:00
|
|
|
} while(0)
|
2011-05-10 01:20:47 +03:00
|
|
|
|
2013-06-23 19:09:15 +03:00
|
|
|
#define CALL_ONLY_THAT_BATTLE_INTERFACE(player,function, ...) \
|
2011-05-10 01:20:47 +03:00
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if(vstd::contains(cl->battleints,player)) \
|
|
|
|
cl->battleints[player]->function(__VA_ARGS__); \
|
2013-06-22 21:22:44 +03:00
|
|
|
\
|
|
|
|
if(cl->additionalBattleInts.count(player)) \
|
|
|
|
BOOST_FOREACH(auto bInt, cl->additionalBattleInts[player])\
|
|
|
|
bInt->function(__VA_ARGS__); \
|
2011-05-10 01:20:47 +03:00
|
|
|
} while (0);
|
|
|
|
|
|
|
|
#define BATTLE_INTERFACE_CALL_RECEIVERS(function,...) \
|
|
|
|
do \
|
|
|
|
{ \
|
2013-06-23 10:54:33 +03:00
|
|
|
BOOST_FOREACH(auto & ber, cl->privilagedBattleEventReceivers)\
|
2011-05-10 01:20:47 +03:00
|
|
|
ber->function(__VA_ARGS__); \
|
|
|
|
} while(0)
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2010-12-25 03:43:40 +02:00
|
|
|
#define BATTLE_INTERFACE_CALL_IF_PRESENT(player,function,...) \
|
2011-05-10 01:20:47 +03:00
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
CALL_ONLY_THAT_INTERFACE(player, function, __VA_ARGS__);\
|
|
|
|
BATTLE_INTERFACE_CALL_RECEIVERS(function, __VA_ARGS__); \
|
|
|
|
} while(0)
|
|
|
|
|
2011-05-30 02:49:25 +03:00
|
|
|
//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 \
|
|
|
|
{ \
|
2013-06-23 10:54:33 +03:00
|
|
|
auto ints = cl->playerint; \
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i = ints.begin(); i != ints.end(); i++)\
|
2011-05-30 02:49:25 +03:00
|
|
|
CALL_ONLY_THAT_INTERFACE(i->first, function, __VA_ARGS__); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
#define BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(function,...) \
|
2013-06-23 19:09:15 +03:00
|
|
|
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[0], function, __VA_ARGS__) \
|
|
|
|
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[1], function, __VA_ARGS__) \
|
2011-05-10 01:20:47 +03:00
|
|
|
BATTLE_INTERFACE_CALL_RECEIVERS(function, __VA_ARGS__)
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* NetPacksClient.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
void SetResources::applyCl( CClient *cl )
|
|
|
|
{
|
2010-10-24 14:35:14 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(player,receivedResource,-1,-1);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetResource::applyCl( CClient *cl )
|
|
|
|
{
|
2010-10-24 14:35:14 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(player,receivedResource,resid,val);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetPrimSkill::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(id);
|
2009-03-19 16:17:19 +02:00
|
|
|
if(!h)
|
|
|
|
{
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->errorStream() << "Cannot find hero with ID " << id.getNum();
|
2009-03-19 16:17:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroPrimarySkillChanged,h,which,val);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetSecSkill::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(id);
|
2010-07-20 17:08:13 +03:00
|
|
|
if(!h)
|
|
|
|
{
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->errorStream() << "Cannot find hero with ID " << id;
|
2010-07-20 17:08:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner,heroSecondarySkillChanged,h,which,val);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeroVisitCastle::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(hid);
|
|
|
|
|
|
|
|
if(start())
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroVisitsTown, h, GS(cl)->getTown(tid));
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeSpells::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//TODO: inform interface?
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMana::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(hid);
|
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroManaPointsChanged, h);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetMovePoints::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(hid);
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths(h);
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroMovePointsChanged, h);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FoWChange::applyCl( CClient *cl )
|
|
|
|
{
|
2012-02-21 00:01:54 +03:00
|
|
|
|
|
|
|
BOOST_FOREACH(auto &i, cl->playerint)
|
2013-02-04 00:05:44 +03:00
|
|
|
if(cl->getPlayerRelations(i.first, player) != PlayerRelations::ENEMIES)
|
2012-02-21 00:01:54 +03:00
|
|
|
{
|
|
|
|
if(mode)
|
|
|
|
i.second->tileRevealed(tiles);
|
|
|
|
else
|
|
|
|
i.second->tileHidden(tiles);
|
|
|
|
}
|
2009-12-31 13:04:29 +02:00
|
|
|
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetAvailableHeroes::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//TODO: inform interface?
|
|
|
|
}
|
|
|
|
|
2010-11-27 22:17:28 +02:00
|
|
|
void ChangeStackCount::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChagedCount, sl, count, absoluteValue);
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetStackType::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stackChangedType, sl, *type);
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EraseStack::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner, stacksErased, sl);
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwapStacks::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl1.army->tempOwner, stacksSwapped, sl1, sl2);
|
2010-12-14 23:55:23 +02:00
|
|
|
if(sl1.army->tempOwner != sl2.army->tempOwner)
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl2.army->tempOwner, stacksSwapped, sl1, sl2);
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void InsertNewStack::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-14 23:55:23 +02:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sl.army->tempOwner,newStackInserted,sl, *sl.getStack());
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RebalanceStacks::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-14 23:55:23 +02:00
|
|
|
INTERFACE_CALL_IF_PRESENT(src.army->tempOwner, stacksRebalanced, src, dst, count);
|
|
|
|
if(src.army->tempOwner != dst.army->tempOwner)
|
|
|
|
INTERFACE_CALL_IF_PRESENT(dst.army->tempOwner,stacksRebalanced, src, dst, count);
|
2010-11-27 22:17:28 +02:00
|
|
|
}
|
|
|
|
|
2010-12-26 16:34:11 +02:00
|
|
|
void PutArtifact::applyCl( CClient *cl )
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactPut, al);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EraseArtifact::applyCl( CClient *cl )
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactRemoved, al);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MoveArtifact::applyCl( CClient *cl )
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(src.owningPlayer(), artifactMoved, src, dst);
|
|
|
|
if(src.owningPlayer() != dst.owningPlayer())
|
2012-12-30 21:29:15 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(dst.owningPlayer(), artifactMoved, src, dst);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2011-01-22 05:43:20 +02:00
|
|
|
void AssembledArtifact::applyCl( CClient *cl )
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactAssembled, al);
|
2011-01-22 05:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisassembledArtifact::applyCl( CClient *cl )
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(al.owningPlayer(), artifactDisassembled, al);
|
2011-01-22 05:43:20 +02:00
|
|
|
}
|
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
void HeroVisit::applyCl( CClient *cl )
|
|
|
|
{
|
2013-05-19 01:30:48 +03:00
|
|
|
assert(hero);
|
2011-05-10 01:20:47 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(hero->tempOwner, heroVisit, hero, obj, starting);
|
|
|
|
}
|
|
|
|
|
2011-08-25 18:24:37 +03:00
|
|
|
void NewTurn::applyCl( CClient *cl )
|
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2011-08-25 18:24:37 +03:00
|
|
|
}
|
|
|
|
|
2011-05-10 01:20:47 +03:00
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void GiveBonus::applyCl( CClient *cl )
|
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2010-02-10 04:56:00 +02:00
|
|
|
switch(who)
|
|
|
|
{
|
|
|
|
case HERO:
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGHeroInstance *h = GS(cl)->getHero(ObjectInstanceID(id));
|
2011-07-13 21:39:02 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroBonusChanged, h, *h->getBonusList().back(),true);
|
2010-02-10 04:56:00 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PLAYER:
|
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
const PlayerState *p = GS(cl)->getPlayer(PlayerColor(id));
|
|
|
|
INTERFACE_CALL_IF_PRESENT(PlayerColor(id), playerBonusChanged, *p->getBonusList().back(), true);
|
2010-02-10 04:56:00 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeObjPos::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
|
2009-03-07 17:55:56 +02:00
|
|
|
if(flags & 1)
|
|
|
|
CGI->mh->hideObject(obj);
|
|
|
|
}
|
|
|
|
void ChangeObjPos::applyCl( CClient *cl )
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
|
2009-03-07 17:55:56 +02:00
|
|
|
if(flags & 1)
|
|
|
|
CGI->mh->printObject(obj);
|
2010-03-11 01:16:30 +02:00
|
|
|
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2010-01-29 22:52:45 +02:00
|
|
|
void PlayerEndsGame::applyCl( CClient *cl )
|
|
|
|
{
|
2011-05-30 02:49:25 +03:00
|
|
|
CALL_IN_ALL_INTERFACES(gameOver, player, victory);
|
2010-01-29 22:52:45 +02:00
|
|
|
}
|
|
|
|
|
2010-02-10 04:56:00 +02:00
|
|
|
void RemoveBonus::applyCl( CClient *cl )
|
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2010-02-10 04:56:00 +02:00
|
|
|
switch(who)
|
|
|
|
{
|
|
|
|
case HERO:
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGHeroInstance *h = GS(cl)->getHero(ObjectInstanceID(id));
|
2010-02-10 04:56:00 +02:00
|
|
|
INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroBonusChanged, h, bonus,false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PLAYER:
|
|
|
|
{
|
2012-02-16 20:10:58 +03:00
|
|
|
//const PlayerState *p = GS(cl)->getPlayer(id);
|
2013-03-03 20:06:03 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(PlayerColor(id), playerBonusChanged, bonus, false);
|
2010-02-10 04:56:00 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:34:39 +03:00
|
|
|
void UpdateCampaignState::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
cl->stopConnection();
|
2013-02-23 22:16:14 +03:00
|
|
|
cl->campaignMapFinished(camp);
|
2010-08-20 16:34:39 +03:00
|
|
|
}
|
|
|
|
|
2013-02-09 21:18:55 +03:00
|
|
|
void PrepareForAdvancingCampaign::applyCl(CClient *cl)
|
|
|
|
{
|
|
|
|
cl->serv->prepareForSendingHeroes();
|
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void RemoveObject::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2009-08-04 02:53:18 +03:00
|
|
|
const CGObjectInstance *o = cl->getObj(id);
|
2012-07-19 12:10:55 +03:00
|
|
|
|
2009-08-04 02:53:18 +03:00
|
|
|
CGI->mh->hideObject(o);
|
|
|
|
|
2010-05-15 11:33:32 +03:00
|
|
|
int3 pos = o->visitablePos();
|
2009-08-04 02:53:18 +03:00
|
|
|
//notify interfaces about removal
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
if(GS(cl)->isVisible(o, i->first))
|
2009-08-04 02:53:18 +03:00
|
|
|
i->second->objectRemoved(o);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-07 19:08:40 +02:00
|
|
|
void RemoveObject::applyCl( CClient *cl )
|
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2009-03-07 19:08:40 +02:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void TryMoveHero::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2009-07-19 06:10:24 +03:00
|
|
|
CGHeroInstance *h = GS(cl)->getHero(id);
|
2009-12-28 06:08:24 +02:00
|
|
|
|
|
|
|
//check if playerint will have the knowledge about movement - if not, directly update maphandler
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
|
2009-12-28 06:08:24 +02:00
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
if(i->first >= PlayerColor::PLAYER_LIMIT)
|
2009-12-28 06:08:24 +02:00
|
|
|
continue;
|
2010-08-03 15:34:06 +03:00
|
|
|
TeamState *t = GS(cl)->getPlayerTeam(i->first);
|
|
|
|
if((t->fogOfWarMap[start.x-1][start.y][start.z] || t->fogOfWarMap[end.x-1][end.y][end.z])
|
|
|
|
&& GS(cl)->getPlayer(i->first)->human)
|
2009-12-28 06:08:24 +02:00
|
|
|
humanKnows = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(result == TELEPORTATION || result == EMBARK || result == DISEMBARK || !humanKnows)
|
2009-07-19 06:10:24 +03:00
|
|
|
CGI->mh->removeObject(h);
|
|
|
|
|
|
|
|
|
|
|
|
if(result == DISEMBARK)
|
|
|
|
CGI->mh->printObject(h->boat);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TryMoveHero::applyCl( CClient *cl )
|
|
|
|
{
|
2009-07-03 22:57:14 +03:00
|
|
|
const CGHeroInstance *h = cl->getHero(id);
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2009-07-19 06:10:24 +03:00
|
|
|
if(result == TELEPORTATION || result == EMBARK || result == DISEMBARK)
|
2011-06-21 19:00:19 +03:00
|
|
|
{
|
2009-07-03 22:57:14 +03:00
|
|
|
CGI->mh->printObject(h);
|
2011-06-21 19:00:19 +03:00
|
|
|
}
|
2009-07-19 06:10:24 +03:00
|
|
|
|
|
|
|
if(result == EMBARK)
|
|
|
|
CGI->mh->hideObject(h->boat);
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
PlayerColor player = h->tempOwner;
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2012-02-21 00:01:54 +03:00
|
|
|
BOOST_FOREACH(auto &i, cl->playerint)
|
2013-02-04 00:05:44 +03:00
|
|
|
if(cl->getPlayerRelations(i.first, player) != PlayerRelations::ENEMIES)
|
2012-02-21 00:01:54 +03:00
|
|
|
i.second->tileRevealed(fowRevealed);
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
//notify interfaces about move
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
if(i->first >= PlayerColor::PLAYER_LIMIT) continue;
|
2010-08-03 15:34:06 +03:00
|
|
|
TeamState *t = GS(cl)->getPlayerTeam(i->first);
|
|
|
|
if(t->fogOfWarMap[start.x-1][start.y][start.z] || t->fogOfWarMap[end.x-1][end.y][end.z])
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2009-07-03 22:57:14 +03:00
|
|
|
i->second->heroMoved(*this);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
2009-12-28 06:08:24 +02:00
|
|
|
|
|
|
|
if(!humanKnows) //maphandler didn't get update from playerint, do it now
|
|
|
|
{ //TODO: restructure nicely
|
|
|
|
CGI->mh->printObject(h);
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewStructures::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
CGTownInstance *town = GS(cl)->getTown(tid);
|
2013-02-11 22:11:34 +03:00
|
|
|
BOOST_FOREACH(const auto & id, bid)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-02-11 22:11:34 +03:00
|
|
|
if(id == BuildingID::CAPITOL) //fort or capitol
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2012-11-13 14:52:23 +03:00
|
|
|
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->capitols[town->subID].get());
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2013-02-11 02:24:57 +03:00
|
|
|
if(id == BuildingID::FORT)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2012-11-13 14:52:23 +03:00
|
|
|
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs[Obj::TOWN][town->subID].get());
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
if(vstd::contains(cl->playerint,town->tempOwner))
|
|
|
|
cl->playerint[town->tempOwner]->buildChanged(town,id,1);
|
|
|
|
}
|
|
|
|
}
|
2009-09-22 17:27:46 +03:00
|
|
|
void RazeStructures::applyCl (CClient *cl)
|
|
|
|
{
|
|
|
|
CGTownInstance *town = GS(cl)->getTown(tid);
|
2013-02-11 22:11:34 +03:00
|
|
|
BOOST_FOREACH(const auto & id, bid)
|
2009-09-22 17:27:46 +03:00
|
|
|
{
|
2013-02-11 22:11:34 +03:00
|
|
|
if (id == BuildingID::CAPITOL) //fort or capitol
|
2009-09-22 17:27:46 +03:00
|
|
|
{
|
2012-11-13 14:52:23 +03:00
|
|
|
town->defInfo = const_cast<CGDefInfo*>(CGI->dobjinfo->gobjs[Obj::TOWN][town->subID].get());
|
2009-09-22 17:27:46 +03:00
|
|
|
}
|
|
|
|
if(vstd::contains (cl->playerint,town->tempOwner))
|
|
|
|
cl->playerint[town->tempOwner]->buildChanged (town,id,2);
|
|
|
|
}
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
void SetAvailableCreatures::applyCl( CClient *cl )
|
|
|
|
{
|
2009-07-26 13:43:22 +03:00
|
|
|
const CGDwelling *dw = static_cast<const CGDwelling*>(cl->getObj(tid));
|
2010-05-15 11:33:32 +03:00
|
|
|
|
|
|
|
//inform order about the change
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
PlayerColor p;
|
2012-09-23 21:01:04 +03:00
|
|
|
if(dw->ID == Obj::WAR_MACHINE_FACTORY) //War Machines Factory is not flaggable, it's "owned" by visitor
|
2010-05-15 11:33:32 +03:00
|
|
|
p = cl->getTile(dw->visitablePos())->visitableObjects.back()->tempOwner;
|
|
|
|
else
|
|
|
|
p = dw->tempOwner;
|
|
|
|
|
|
|
|
INTERFACE_CALL_IF_PRESENT(p, availableCreaturesChanged, dw);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetHeroesInTown::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
CGTownInstance *t = GS(cl)->getTown(tid);
|
2013-02-23 15:22:23 +03:00
|
|
|
CGHeroInstance *hGarr = GS(cl)->getHero(this->garrison);
|
|
|
|
CGHeroInstance *hVisit = GS(cl)->getHero(this->visiting);
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
std::set<PlayerColor> playersToNotify;
|
2013-02-23 15:22:23 +03:00
|
|
|
|
|
|
|
if(vstd::contains(cl->playerint,t->tempOwner)) // our town
|
|
|
|
playersToNotify.insert(t->tempOwner);
|
|
|
|
|
|
|
|
if (hGarr && vstd::contains(cl->playerint, hGarr->tempOwner))
|
|
|
|
playersToNotify.insert(hGarr->tempOwner);
|
|
|
|
|
|
|
|
if (hVisit && vstd::contains(cl->playerint, hVisit->tempOwner))
|
|
|
|
playersToNotify.insert(hVisit->tempOwner);
|
|
|
|
|
|
|
|
BOOST_FOREACH(auto playerID, playersToNotify)
|
|
|
|
cl->playerint[playerID]->heroInGarrisonChange(t);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2011-01-18 20:56:14 +02:00
|
|
|
// void SetHeroArtifacts::applyCl( CClient *cl )
|
|
|
|
// {
|
|
|
|
// // CGHeroInstance *h = GS(cl)->getHero(hid);
|
|
|
|
// // CGameInterface *player = (vstd::contains(cl->playerint,h->tempOwner) ? cl->playerint[h->tempOwner] : NULL);
|
|
|
|
// // if(!player)
|
|
|
|
// // return;
|
2012-02-16 20:10:58 +03:00
|
|
|
//
|
2011-01-18 20:56:14 +02:00
|
|
|
// //h->recreateArtBonuses();
|
|
|
|
// //player->heroArtifactSetChanged(h);
|
2012-02-16 20:10:58 +03:00
|
|
|
//
|
2011-01-18 20:56:14 +02:00
|
|
|
// // BOOST_FOREACH(Bonus bonus, gained)
|
|
|
|
// // {
|
|
|
|
// // player->heroBonusChanged(h,bonus,true);
|
|
|
|
// // }
|
|
|
|
// // BOOST_FOREACH(Bonus bonus, lost)
|
|
|
|
// // {
|
|
|
|
// // player->heroBonusChanged(h,bonus,false);
|
|
|
|
// // }
|
|
|
|
// }
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
void HeroRecruited::applyCl( CClient *cl )
|
|
|
|
{
|
2013-05-19 01:30:48 +03:00
|
|
|
CGHeroInstance *h = GS(cl)->map->heroesOnMap.back();
|
2009-03-07 17:55:56 +02:00
|
|
|
if(h->subID != hid)
|
|
|
|
{
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->errorStream() << "Something wrong with hero recruited!";
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CGI->mh->initHeroDef(h);
|
2009-08-01 13:08:16 +03:00
|
|
|
CGI->mh->printObject(h);
|
2012-02-16 20:10:58 +03:00
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
if(vstd::contains(cl->playerint,h->tempOwner))
|
|
|
|
{
|
|
|
|
cl->playerint[h->tempOwner]->heroCreated(h);
|
2010-07-09 02:03:27 +03:00
|
|
|
if(const CGTownInstance *t = GS(cl)->getTown(tid))
|
|
|
|
cl->playerint[h->tempOwner]->heroInGarrisonChange(t);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GiveHero::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
CGHeroInstance *h = GS(cl)->getHero(id);
|
|
|
|
CGI->mh->initHeroDef(h);
|
|
|
|
CGI->mh->printObject(h);
|
|
|
|
cl->playerint[h->tempOwner]->heroCreated(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GiveHero::applyFirstCl( CClient *cl )
|
|
|
|
{
|
|
|
|
CGI->mh->hideObject(GS(cl)->getHero(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
void InfoWindow::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
std::vector<Component*> comps;
|
2012-02-16 20:10:58 +03:00
|
|
|
for(size_t i=0;i<components.size();i++)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
comps.push_back(&components[i]);
|
|
|
|
}
|
2009-07-09 22:15:22 +03:00
|
|
|
std::string str;
|
|
|
|
text.toString(str);
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
if(vstd::contains(cl->playerint,player))
|
2009-04-30 13:53:06 +03:00
|
|
|
cl->playerint[player]->showInfoDialog(str,comps,(soundBase::soundID)soundID);
|
2009-03-07 17:55:56 +02:00
|
|
|
else
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->warnStream() << "We received InfoWindow for not our player...";
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-07-30 15:49:45 +03:00
|
|
|
void SetObjectProperty::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//inform all players that see this object
|
2013-02-14 02:55:42 +03:00
|
|
|
for(auto it = cl->playerint.cbegin(); it != cl->playerint.cend(); ++it)
|
2009-07-30 15:49:45 +03:00
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
if(GS(cl)->isVisible(GS(cl)->getObjInstance(id), it->first))
|
2009-07-30 15:49:45 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(it->first, objectPropertyChanged, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void HeroLevelUp::applyCl( CClient *cl )
|
|
|
|
{
|
2012-07-15 18:34:00 +03:00
|
|
|
//INTERFACE_CALL_IF_PRESENT(h->tempOwner, heroGotLevel, h, primskill, skills, id);
|
2013-04-20 14:34:01 +03:00
|
|
|
if(vstd::contains(cl->playerint,hero->tempOwner))
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-04-20 14:34:01 +03:00
|
|
|
cl->playerint[hero->tempOwner]->heroGotLevel(hero, primskill, skills, queryID);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2013-02-04 15:32:53 +03:00
|
|
|
//else
|
|
|
|
// cb->selectionMade(0, queryID);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2012-07-15 18:34:00 +03:00
|
|
|
|
2012-05-16 20:29:05 +03:00
|
|
|
void CommanderLevelUp::applyCl( CClient *cl )
|
|
|
|
{
|
2013-04-20 14:34:01 +03:00
|
|
|
const CCommanderInstance * commander = hero->commander;
|
2012-05-18 17:02:27 +03:00
|
|
|
assert (commander);
|
2013-04-20 14:34:01 +03:00
|
|
|
PlayerColor player = hero->tempOwner;
|
2012-05-18 17:02:27 +03:00
|
|
|
if (commander->armyObj && vstd::contains(cl->playerint, player)) //is it possible for Commander to exist beyond armed instance?
|
2012-05-16 20:29:05 +03:00
|
|
|
{
|
2012-07-15 18:34:00 +03:00
|
|
|
cl->playerint[player]->commanderGotLevel(commander, skills, queryID);
|
2012-05-16 20:29:05 +03:00
|
|
|
}
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2009-04-11 04:32:50 +03:00
|
|
|
void BlockingDialog::applyCl( CClient *cl )
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2009-07-09 22:15:22 +03:00
|
|
|
std::string str;
|
|
|
|
text.toString(str);
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
if(vstd::contains(cl->playerint,player))
|
2012-07-15 18:34:00 +03:00
|
|
|
cl->playerint[player]->showBlockingDialog(str,components,queryID,(soundBase::soundID)soundID,selection(),cancel());
|
2009-03-07 17:55:56 +02:00
|
|
|
else
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->warnStream() << "We received YesNoDialog for not our player...";
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-04-12 03:58:41 +03:00
|
|
|
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;
|
|
|
|
|
2012-07-15 18:34:00 +03:00
|
|
|
cl->playerint[h->getOwner()]->showGarrisonDialog(obj,h,removableUnits,queryID);
|
2009-04-12 03:58:41 +03:00
|
|
|
}
|
|
|
|
|
2013-05-27 13:53:28 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void BattleStart::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-23 02:33:48 +02:00
|
|
|
cl->battleStarted(info);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2010-05-07 15:29:41 +03:00
|
|
|
void BattleNextRound::applyFirstCl(CClient *cl)
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRoundFirst,round);
|
2010-05-07 15:29:41 +03:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void BattleNextRound::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewRound,round);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleSetActiveStack::applyCl( CClient *cl )
|
|
|
|
{
|
2012-08-27 15:34:43 +03:00
|
|
|
if(!askPlayerInterface)
|
|
|
|
return;
|
|
|
|
|
2012-08-26 12:07:48 +03:00
|
|
|
const CStack * activated = GS(cl)->curB->battleGetStackByID(stack);
|
2013-03-03 20:06:03 +03:00
|
|
|
PlayerColor playerToCall; //player that will move activated stack
|
2010-05-02 21:20:26 +03:00
|
|
|
if( activated->hasBonusOfType(Bonus::HYPNOTIZED) )
|
2009-08-18 14:49:34 +03:00
|
|
|
{
|
2011-01-09 19:41:46 +02:00
|
|
|
playerToCall = ( GS(cl)->curB->sides[0] == activated->owner ? GS(cl)->curB->sides[1] : GS(cl)->curB->sides[0] );
|
2009-08-18 14:49:34 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playerToCall = activated->owner;
|
|
|
|
}
|
2010-12-25 03:43:40 +02:00
|
|
|
if( vstd::contains(cl->battleints, playerToCall) )
|
2009-08-18 14:49:34 +03:00
|
|
|
boost::thread( boost::bind(&CClient::waitForMoveAndSend, cl, playerToCall) );
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 16:02:58 +03:00
|
|
|
void BattleTriggerEffect::applyCl(CClient * cl)
|
|
|
|
{
|
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleTriggerEffect, *this);
|
|
|
|
}
|
|
|
|
|
2012-05-05 00:16:39 +03:00
|
|
|
void BattleObstaclePlaced::applyCl(CClient * cl)
|
|
|
|
{
|
2012-05-18 23:50:16 +03:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleObstaclePlaced, *obstacle);
|
2012-05-05 00:16:39 +03:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void BattleResult::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleEnd,this);
|
2012-08-26 12:07:48 +03:00
|
|
|
cl->battleFinished();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleStackMoved::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2012-08-26 12:07:48 +03:00
|
|
|
const CStack * movedStack = GS(cl)->curB->battleGetStackByID(stack);
|
2011-08-01 20:36:18 +03:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStackMoved,movedStack,tilesToMove,distance);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2012-02-18 20:39:47 +03:00
|
|
|
//void BattleStackAttacked::( CClient *cl )
|
|
|
|
void BattleStackAttacked::applyFirstCl( CClient *cl )
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2010-02-20 15:24:38 +02:00
|
|
|
std::vector<BattleStackAttacked> bsa;
|
|
|
|
bsa.push_back(*this);
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleAttack::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleAttack,this);
|
2010-05-07 15:29:41 +03:00
|
|
|
for (int g=0; g<bsa.size(); ++g)
|
|
|
|
{
|
|
|
|
for (int z=0; z<bsa[g].healedStacks.size(); ++z)
|
|
|
|
{
|
|
|
|
bsa[g].healedStacks[z].applyCl(cl);
|
|
|
|
}
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BattleAttack::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,bsa);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void StartAction::applyFirstCl( CClient *cl )
|
|
|
|
{
|
2013-05-09 14:09:23 +03:00
|
|
|
cl->curbaction = ba;
|
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionStarted, ba);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2010-05-16 16:42:19 +03:00
|
|
|
void BattleSpellCast::applyCl( CClient *cl )
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleSpellCast,this);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetStackEffect::applyCl( CClient *cl )
|
|
|
|
{
|
2009-03-21 18:03:07 +02:00
|
|
|
//informing about effects
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksEffectsSet,*this);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-04-16 03:28:54 +03:00
|
|
|
void StacksInjured::applyCl( CClient *cl )
|
|
|
|
{
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksAttacked,stacks);
|
2009-04-16 03:28:54 +03:00
|
|
|
}
|
|
|
|
|
2009-08-04 02:53:18 +03:00
|
|
|
void BattleResultsApplied::applyCl( CClient *cl )
|
|
|
|
{
|
2011-01-08 21:38:42 +02:00
|
|
|
INTERFACE_CALL_IF_PRESENT(player1, battleResultsApplied);
|
|
|
|
INTERFACE_CALL_IF_PRESENT(player2, battleResultsApplied);
|
2013-03-03 20:06:03 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(PlayerColor::UNFLAGGABLE, battleResultsApplied);
|
2011-01-08 21:38:42 +02:00
|
|
|
if(GS(cl)->initialOpts->mode == StartInfo::DUEL)
|
|
|
|
{
|
2013-06-17 18:45:55 +03:00
|
|
|
handleQuit();
|
2011-01-08 21:38:42 +02:00
|
|
|
}
|
2009-08-04 02:53:18 +03:00
|
|
|
}
|
|
|
|
|
2009-08-05 15:46:08 +03:00
|
|
|
void StacksHealedOrResurrected::applyCl( CClient *cl )
|
|
|
|
{
|
2009-08-06 08:08:17 +03:00
|
|
|
std::vector<std::pair<ui32, ui32> > shiftedHealed;
|
2009-08-05 15:46:08 +03:00
|
|
|
for(int v=0; v<healedStacks.size(); ++v)
|
|
|
|
{
|
|
|
|
shiftedHealed.push_back(std::make_pair(healedStacks[v].stackID, healedStacks[v].healedHP));
|
|
|
|
}
|
2011-06-21 15:45:57 +03:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
|
2009-08-05 15:46:08 +03:00
|
|
|
}
|
|
|
|
|
2009-08-19 13:59:42 +03:00
|
|
|
void ObstaclesRemoved::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//inform interfaces about removed obstacles
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleObstaclesRemoved, obstacles);
|
2009-08-19 13:59:42 +03:00
|
|
|
}
|
|
|
|
|
2009-09-01 16:54:13 +03:00
|
|
|
void CatapultAttack::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//inform interfaces about catapult attack
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleCatapultAttacked, *this);
|
2009-09-01 16:54:13 +03:00
|
|
|
}
|
|
|
|
|
2009-09-05 17:10:26 +03:00
|
|
|
void BattleStacksRemoved::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
//inform interfaces about removed stacks
|
2010-12-25 03:43:40 +02:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksRemoved, *this);
|
2009-09-05 17:10:26 +03:00
|
|
|
}
|
|
|
|
|
2011-10-01 22:56:54 +03:00
|
|
|
void BattleStackAdded::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleNewStackAppeared, GS(cl)->curB->stacks.back());
|
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
CGameState* CPackForClient::GS( CClient *cl )
|
|
|
|
{
|
|
|
|
return cl->gs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndAction::applyCl( CClient *cl )
|
|
|
|
{
|
2013-05-09 14:09:23 +03:00
|
|
|
BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(actionFinished, *cl->curbaction);
|
|
|
|
cl->curbaction.reset();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-04-16 03:28:54 +03:00
|
|
|
void PackageApplied::applyCl( CClient *cl )
|
|
|
|
{
|
2009-08-30 15:47:40 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(player, requestRealized, this);
|
2012-03-26 01:46:14 +03:00
|
|
|
if(!cl->waitingRequest.tryRemovingElement(requestID))
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->warnStream() << "Surprising server message!";
|
2009-04-16 03:28:54 +03:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void SystemMessage::applyCl( CClient *cl )
|
|
|
|
{
|
2009-04-04 22:26:41 +03:00
|
|
|
std::ostringstream str;
|
2009-04-11 04:32:50 +03:00
|
|
|
str << "System message: " << text;
|
2009-04-04 22:26:41 +03:00
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
logNetwork->errorStream() << str.str(); // usually used to receive error messages from server
|
2009-04-04 22:26:41 +03:00
|
|
|
if(LOCPLINT)
|
|
|
|
LOCPLINT->cingconsole->print(str.str());
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-08-04 02:53:18 +03:00
|
|
|
void PlayerBlocked::applyCl( CClient *cl )
|
|
|
|
{
|
|
|
|
INTERFACE_CALL_IF_PRESENT(player,playerBlocked,reason);
|
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void YourTurn::applyCl( CClient *cl )
|
|
|
|
{
|
2011-07-17 21:49:05 +03:00
|
|
|
CALL_IN_ALL_INTERFACES(playerStartsTurn, player);
|
2011-05-10 01:20:47 +03:00
|
|
|
CALL_ONLY_THAT_INTERFACE(player,yourTurn);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-03-28 20:46:20 +02:00
|
|
|
void SaveGame::applyCl(CClient *cl)
|
|
|
|
{
|
2012-08-07 14:28:52 +03:00
|
|
|
CFileInfo info(fname);
|
|
|
|
CResourceHandler::get()->createResource(info.getStem() + ".vcgm1");
|
|
|
|
|
2012-06-09 22:58:17 +03:00
|
|
|
try
|
|
|
|
{
|
2012-08-07 14:28:52 +03:00
|
|
|
CSaveFile save(CResourceHandler::get()->getResourceName(ResourceID(info.getStem(), EResType::CLIENT_SAVEGAME)));
|
2013-02-19 01:37:22 +03:00
|
|
|
cl->saveCommonState(save);
|
2012-06-09 22:58:17 +03:00
|
|
|
save << *cl;
|
|
|
|
}
|
|
|
|
catch(std::exception &e)
|
|
|
|
{
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->errorStream() << "Failed to save game:" << e.what();
|
2012-06-09 22:58:17 +03:00
|
|
|
}
|
2009-03-28 20:46:20 +02:00
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
|
|
|
|
void PlayerMessage::applyCl(CClient *cl)
|
|
|
|
{
|
2009-04-04 22:26:41 +03:00
|
|
|
std::ostringstream str;
|
2013-03-03 20:06:03 +03:00
|
|
|
str << "Player "<< player <<" sends a message: " << text;
|
2009-04-04 22:26:41 +03:00
|
|
|
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->debugStream() << str.str();
|
2009-04-04 22:26:41 +03:00
|
|
|
if(LOCPLINT)
|
|
|
|
LOCPLINT->cingconsole->print(str.str());
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2009-08-30 15:47:40 +03:00
|
|
|
void SetSelection::applyCl(CClient *cl)
|
|
|
|
{
|
|
|
|
const CGHeroInstance *h = cl->getHero(id);
|
|
|
|
if(!h)
|
|
|
|
return;
|
|
|
|
|
2009-09-13 01:17:23 +03:00
|
|
|
//CPackForClient::GS(cl)->calculatePaths(h, *cl->pathInfo);
|
2009-08-30 15:47:40 +03:00
|
|
|
}
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
void ShowInInfobox::applyCl(CClient *cl)
|
|
|
|
{
|
2012-06-13 16:04:06 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(player,showComp, c, text.toString());
|
2009-05-12 06:35:51 +03:00
|
|
|
}
|
2009-06-16 14:18:14 +03:00
|
|
|
|
2010-05-16 16:42:19 +03:00
|
|
|
void AdvmapSpellCast::applyCl(CClient *cl)
|
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
cl->invalidatePaths();
|
2012-02-16 20:10:58 +03:00
|
|
|
//consider notifying other interfaces that see hero?
|
2011-09-03 05:54:33 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(caster->getOwner(),advmapSpellCast, caster, spellID);
|
2010-05-16 16:42:19 +03:00
|
|
|
}
|
|
|
|
|
2009-07-06 22:41:27 +03:00
|
|
|
void OpenWindow::applyCl(CClient *cl)
|
2009-06-16 14:18:14 +03:00
|
|
|
{
|
2009-07-06 22:41:27 +03:00
|
|
|
switch(window)
|
|
|
|
{
|
|
|
|
case RECRUITMENT_FIRST:
|
2009-07-26 13:43:22 +03:00
|
|
|
case RECRUITMENT_ALL:
|
2009-07-06 22:41:27 +03:00
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGDwelling *dw = dynamic_cast<const CGDwelling*>(cl->getObj(ObjectInstanceID(id1)));
|
|
|
|
const CArmedInstance *dst = dynamic_cast<const CArmedInstance*>(cl->getObj(ObjectInstanceID(id2)));
|
2010-05-15 11:33:32 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(dst->tempOwner,showRecruitmentDialog, dw, dst, window == RECRUITMENT_FIRST ? 0 : -1);
|
2009-07-06 22:41:27 +03:00
|
|
|
}
|
2009-07-26 06:33:13 +03:00
|
|
|
break;
|
|
|
|
case SHIPYARD_WINDOW:
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
const IShipyard *sy = IShipyard::castFrom(cl->getObj(ObjectInstanceID(id1)));
|
2009-07-26 06:33:13 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(sy->o->tempOwner, showShipyardDialog, sy);
|
|
|
|
}
|
|
|
|
break;
|
2010-02-07 17:06:14 +02:00
|
|
|
case THIEVES_GUILD:
|
|
|
|
{
|
|
|
|
//displays Thieves' Guild window (when hero enters Den of Thieves)
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id2));
|
2013-03-03 20:06:03 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(PlayerColor(id1), showThievesGuildWindow, obj);
|
2010-02-07 17:06:14 +02:00
|
|
|
}
|
|
|
|
break;
|
2010-07-20 17:08:13 +03:00
|
|
|
case UNIVERSITY_WINDOW:
|
|
|
|
{
|
|
|
|
//displays University window (when hero enters University on adventure map)
|
2013-02-14 02:55:42 +03:00
|
|
|
const IMarket *market = IMarket::castFrom(cl->getObj(ObjectInstanceID(id1)));
|
|
|
|
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
2010-07-20 17:08:13 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(hero->tempOwner,showUniversityWindow, market, hero);
|
|
|
|
}
|
|
|
|
break;
|
2010-05-18 10:01:54 +03:00
|
|
|
case MARKET_WINDOW:
|
|
|
|
{
|
|
|
|
//displays Thieves' Guild window (when hero enters Den of Thieves)
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id1));
|
|
|
|
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
2010-05-18 10:01:54 +03:00
|
|
|
const IMarket *market = IMarket::castFrom(obj);
|
|
|
|
INTERFACE_CALL_IF_PRESENT(cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, showMarketWindow, market, hero);
|
|
|
|
}
|
|
|
|
break;
|
2010-07-22 03:32:45 +03:00
|
|
|
case HILL_FORT_WINDOW:
|
|
|
|
{
|
|
|
|
//displays Hill fort window
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGObjectInstance *obj = cl->getObj(ObjectInstanceID(id1));
|
|
|
|
const CGHeroInstance *hero = cl->getHero(ObjectInstanceID(id2));
|
2010-07-22 03:32:45 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(cl->getTile(obj->visitablePos())->visitableObjects.back()->tempOwner, showHillFortWindow, obj, hero);
|
|
|
|
}
|
|
|
|
break;
|
2010-02-10 04:56:00 +02:00
|
|
|
case PUZZLE_MAP:
|
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(PlayerColor(id1), showPuzzleMap);
|
2010-02-10 04:56:00 +02:00
|
|
|
}
|
2010-07-20 17:08:13 +03:00
|
|
|
break;
|
2010-07-09 02:03:27 +03:00
|
|
|
case TAVERN_WINDOW:
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGObjectInstance *obj1 = cl->getObj(ObjectInstanceID(id1)),
|
|
|
|
*obj2 = cl->getObj(ObjectInstanceID(id2));
|
2010-07-09 02:03:27 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT(obj1->tempOwner, showTavernWindow, obj2);
|
2010-02-10 04:56:00 +02:00
|
|
|
break;
|
2009-07-06 22:41:27 +03:00
|
|
|
}
|
|
|
|
|
2009-06-16 14:18:14 +03:00
|
|
|
}
|
2009-07-26 06:33:13 +03:00
|
|
|
|
2009-08-11 10:50:29 +03:00
|
|
|
void CenterView::applyCl(CClient *cl)
|
|
|
|
{
|
2009-08-13 04:03:11 +03:00
|
|
|
INTERFACE_CALL_IF_PRESENT (player, centerView, pos, focusTime);
|
2009-08-11 10:50:29 +03:00
|
|
|
}
|
|
|
|
|
2009-07-26 06:33:13 +03:00
|
|
|
void NewObject::applyCl(CClient *cl)
|
|
|
|
{
|
2010-06-24 15:10:45 +03:00
|
|
|
cl->updatePaths();
|
|
|
|
|
2009-07-26 06:33:13 +03:00
|
|
|
const CGObjectInstance *obj = cl->getObj(id);
|
2011-08-25 23:02:38 +03:00
|
|
|
CGI->mh->printObject(obj);
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
2011-09-03 05:54:33 +03:00
|
|
|
if(GS(cl)->isVisible(obj, i->first))
|
2009-07-26 06:33:13 +03:00
|
|
|
i->second->newObject(obj);
|
|
|
|
}
|
|
|
|
}
|
2009-10-03 14:16:42 +03:00
|
|
|
|
2010-06-27 19:03:01 +03:00
|
|
|
void SetAvailableArtifacts::applyCl(CClient *cl)
|
|
|
|
{
|
|
|
|
if(id < 0) //artifact merchants globally
|
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
|
2010-06-27 19:03:01 +03:00
|
|
|
i->second->availableArtifactsChanged(NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
const CGBlackMarket *bm = dynamic_cast<const CGBlackMarket *>(cl->getObj(ObjectInstanceID(id)));
|
2010-06-27 19:03:01 +03:00
|
|
|
assert(bm);
|
|
|
|
INTERFACE_CALL_IF_PRESENT(cl->getTile(bm->visitablePos())->visitableObjects.back()->tempOwner, availableArtifactsChanged, bm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 14:16:42 +03:00
|
|
|
void TradeComponents::applyCl(CClient *cl)
|
|
|
|
{///Shop handler
|
|
|
|
switch (CGI->mh->map->objects[objectid]->ID)
|
|
|
|
{
|
2012-09-23 21:01:04 +03:00
|
|
|
case Obj::BLACK_MARKET:
|
|
|
|
break;
|
|
|
|
case Obj::TAVERN:
|
|
|
|
break;
|
|
|
|
case Obj::DEN_OF_THIEVES:
|
|
|
|
break;
|
|
|
|
case Obj::TRADING_POST_SNOW:
|
|
|
|
break;
|
|
|
|
default:
|
2013-04-09 17:31:36 +03:00
|
|
|
logNetwork->warnStream() << "Shop type not supported!";
|
2009-10-03 14:16:42 +03:00
|
|
|
}
|
2009-10-04 05:02:45 +03:00
|
|
|
}
|