1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Add TeleportDialog and CTeleportDialogQuery

TeleportDialog is based off BlockingDialog and it's needed for server to ask client what teleport hero should be teleported to.
It's also contain list of possible exits, identifier of currently used channel and also impassable option.
If impassable set to true then client will remember that current teleport channel is lack of exit point.
This commit is contained in:
ArseniyShestakov 2015-03-08 16:37:33 +03:00
parent 8d7b6d119f
commit 18535db0ef
5 changed files with 50 additions and 0 deletions

View File

@ -595,6 +595,11 @@ void ExchangeDialog::applyCl(CClient *cl)
INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
}
void TeleportDialog::applyCl( CClient *cl )
{
CALL_ONLY_THAT_INTERFACE(hero->tempOwner,showTeleportDialog,channel,exits,impassable,queryID);
}
void BattleStart::applyFirstCl( CClient *cl )
{
//Cannot use the usual macro because curB is not set yet

View File

@ -1206,6 +1206,28 @@ struct ExchangeDialog : public Query//2005
}
};
struct TeleportDialog : public Query//2006
{
TeleportDialog() {type = 2006;}
TeleportDialog(const CGHeroInstance *Hero, TeleportChannelID Channel)
: hero(Hero), channel(Channel), impassable(false)
{
type = 2006;
}
void applyCl(CClient *cl);
const CGHeroInstance *hero;
TeleportChannelID channel;
std::vector<ObjectInstanceID> exits;
bool impassable;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & queryID & hero & channel & exits & impassable;
}
};
struct BattleInfo;
struct BattleStart : public CPackForClient//3000
{

View File

@ -286,6 +286,7 @@ void registerTypesClientPacks2(Serializer &s)
s.template registerType<Query, BlockingDialog>();
s.template registerType<Query, GarrisonDialog>();
s.template registerType<Query, ExchangeDialog>();
s.template registerType<Query, TeleportDialog>();
s.template registerType<CPackForClient, CGarrisonOperationPack>();
s.template registerType<CGarrisonOperationPack, ChangeStackCount>();

View File

@ -313,6 +313,18 @@ CBlockingDialogQuery::CBlockingDialogQuery(const BlockingDialog &bd)
addPlayer(bd.player);
}
void CTeleportDialogQuery::notifyObjectAboutRemoval(const CObjectVisitQuery &objectVisit) const
{
auto obj = dynamic_cast<const CGTeleport *>(objectVisit.visitedObject);
obj->teleportDialogAnswered(objectVisit.visitingHero, *answer, td.exits);
}
CTeleportDialogQuery::CTeleportDialogQuery(const TeleportDialog &td)
{
this->td = td;
addPlayer(td.hero->tempOwner);
}
CHeroLevelUpDialogQuery::CHeroLevelUpDialogQuery(const HeroLevelUp &Hlu)
{
hlu = Hlu;

View File

@ -130,6 +130,16 @@ public:
virtual void notifyObjectAboutRemoval(const CObjectVisitQuery &objectVisit) const override;
};
class CTeleportDialogQuery : public CDialogQuery
{
public:
TeleportDialog td; //copy of pack... debug purposes
CTeleportDialogQuery(const TeleportDialog &td);
virtual void notifyObjectAboutRemoval(const CObjectVisitQuery &objectVisit) const override;
};
class CHeroLevelUpDialogQuery : public CDialogQuery
{
public: