Bläddra i källkod

Teleports: use TTeleportExitsList typedef for exits list

There is several ideas that teleportation code have to be shared between object/spells and this way we can avoid changing showTeleportDialog declaration every time.
ArseniyShestakov 10 år sedan
förälder
incheckning
f6de3f94ca
7 ändrade filer med 10 tillägg och 6 borttagningar
  1. 1 1
      AI/EmptyAI/CEmptyAI.cpp
  2. 1 1
      AI/EmptyAI/CEmptyAI.h
  3. 1 1
      AI/VCAI/VCAI.cpp
  4. 1 1
      AI/VCAI/VCAI.h
  5. 3 1
      lib/CGameInterface.h
  6. 1 1
      lib/NetPacks.h
  7. 2 0
      lib/mapObjects/MiscObjects.h

+ 1 - 1
AI/EmptyAI/CEmptyAI.cpp

@@ -30,7 +30,7 @@ void CEmptyAI::showBlockingDialog(const std::string &text, const std::vector<Com
 	cb->selectionMade(0, askID);
 	cb->selectionMade(0, askID);
 }
 }
 
 
-void CEmptyAI::showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID)
+void CEmptyAI::showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
 {
 {
 	cb->selectionMade(0, askID);
 	cb->selectionMade(0, askID);
 }
 }

+ 1 - 1
AI/EmptyAI/CEmptyAI.h

@@ -15,7 +15,7 @@ public:
 	void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
 	void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
 	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
 	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
 	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override;
 	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override;
-	void showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID) override;
+	void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override;
 	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override;
 	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override;
 };
 };
 
 

+ 1 - 1
AI/VCAI/VCAI.cpp

@@ -614,7 +614,7 @@ void VCAI::showBlockingDialog(const std::string &text, const std::vector<Compone
 	});
 	});
 }
 }
 
 
-void VCAI::showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID)
+void VCAI::showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID)
 {
 {
 	LOG_TRACE_PARAMS(logAi, "askID '%i', exits '%s'", askID % exits);
 	LOG_TRACE_PARAMS(logAi, "askID '%i', exits '%s'", askID % exits);
 	NET_EVENT_HANDLER;
 	NET_EVENT_HANDLER;

+ 1 - 1
AI/VCAI/VCAI.h

@@ -202,7 +202,7 @@ public:
 	virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
 	virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
 	virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
 	virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
 	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
 	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
-	virtual void showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID) override;
+	virtual void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override;
 	virtual void saveGame(COSer & h, const int version) override; //saving
 	virtual void saveGame(COSer & h, const int version) override; //saving
 	virtual void loadGame(CISer & h, const int version) override; //loading
 	virtual void loadGame(CISer & h, const int version) override; //loading
 	virtual void finish() override;
 	virtual void finish() override;

+ 3 - 1
lib/CGameInterface.h

@@ -7,6 +7,8 @@
 
 
 #include "spells/ViewSpellInt.h"
 #include "spells/ViewSpellInt.h"
 
 
+#include "mapObjects/MiscObjects.h"
+
 /*
 /*
  * CGameInterface.h, part of VCMI engine
  * CGameInterface.h, part of VCMI engine
  *
  *
@@ -94,7 +96,7 @@ public:
 
 
 	// all stacks operations between these objects become allowed, interface has to call onEnd when done
 	// all stacks operations between these objects become allowed, interface has to call onEnd when done
 	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) = 0;
 	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) = 0;
-	virtual void showTeleportDialog(TeleportChannelID channel, std::vector<ObjectInstanceID> exits, bool impassable, QueryID askID) = 0;
+	virtual void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) = 0;
 	virtual void finish(){}; //if for some reason we want to end
 	virtual void finish(){}; //if for some reason we want to end
 	
 	
 	virtual void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions){};
 	virtual void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions){};

+ 1 - 1
lib/NetPacks.h

@@ -1221,7 +1221,7 @@ struct TeleportDialog : public Query//2006
 
 
 	const CGHeroInstance *hero;
 	const CGHeroInstance *hero;
 	TeleportChannelID channel;
 	TeleportChannelID channel;
-	std::vector<ObjectInstanceID> exits;
+	TTeleportExitsList exits;
 	bool impassable;
 	bool impassable;
 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)

+ 2 - 0
lib/mapObjects/MiscObjects.h

@@ -247,6 +247,8 @@ public:
 	ui32 defaultResProduction();
 	ui32 defaultResProduction();
 };
 };
 
 
+typedef std::vector<ObjectInstanceID> TTeleportExitsList;
+
 struct DLL_LINKAGE TeleportChannel
 struct DLL_LINKAGE TeleportChannel
 {
 {
 	enum EPassability {UNKNOWN, IMPASSABLE, PASSABLE};
 	enum EPassability {UNKNOWN, IMPASSABLE, PASSABLE};