瀏覽代碼

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.
ArseniyShestakov 10 年之前
父節點
當前提交
18535db0ef
共有 5 個文件被更改,包括 50 次插入0 次删除
  1. 5 0
      client/NetPacksClient.cpp
  2. 22 0
      lib/NetPacks.h
  3. 1 0
      lib/registerTypes/RegisterTypes.h
  4. 12 0
      server/CQuery.cpp
  5. 10 0
      server/CQuery.h

+ 5 - 0
client/NetPacksClient.cpp

@@ -595,6 +595,11 @@ void ExchangeDialog::applyCl(CClient *cl)
 	INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID);
 	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 )
 void BattleStart::applyFirstCl( CClient *cl )
 {
 {
 	//Cannot use the usual macro because curB is not set yet
 	//Cannot use the usual macro because curB is not set yet

+ 22 - 0
lib/NetPacks.h

@@ -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 BattleInfo;
 struct BattleStart : public CPackForClient//3000
 struct BattleStart : public CPackForClient//3000
 {
 {

+ 1 - 0
lib/registerTypes/RegisterTypes.h

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

+ 12 - 0
server/CQuery.cpp

@@ -313,6 +313,18 @@ CBlockingDialogQuery::CBlockingDialogQuery(const BlockingDialog &bd)
 	addPlayer(bd.player);
 	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)
 CHeroLevelUpDialogQuery::CHeroLevelUpDialogQuery(const HeroLevelUp &Hlu)
 {
 {
 	hlu = Hlu;
 	hlu = Hlu;

+ 10 - 0
server/CQuery.h

@@ -130,6 +130,16 @@ public:
 	virtual void notifyObjectAboutRemoval(const CObjectVisitQuery &objectVisit) const override;
 	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
 class CHeroLevelUpDialogQuery : public CDialogQuery
 {
 {
 public:
 public: