Browse Source

Bugfixes for AI, Callback Interface, logging macrodefs.

Michał W. Urbańczyk 18 years ago
parent
commit
c8c0d0eaaf
11 changed files with 123 additions and 21 deletions
  1. 1 1
      AI/EmptyAI/CEmptyAI.cpp
  2. 2 2
      AI/EmptyAI/CEmptyAI.h
  3. 79 5
      AI/EmptyAI/Z_EmptyAI.vcproj
  4. 2 1
      CAdvmapInterface.cpp
  5. 24 1
      CCallback.h
  6. 1 1
      CGameInterface.h
  7. 3 2
      CPlayerInterface.cpp
  8. 1 1
      CPlayerInterface.h
  9. 1 0
      StartInfo.h
  10. 9 0
      global.h
  11. 0 7
      nodrze.h

+ 1 - 1
AI/EmptyAI/CEmptyAI.cpp

@@ -1,6 +1,6 @@
 #include "CEmptyAI.h"
 #include <iostream>
-void CEmptyAI::init(CCallback * CB)
+void CEmptyAI::init(ICallback * CB)
 {
 	cb = CB;
 	human=false;

+ 2 - 2
AI/EmptyAI/CEmptyAI.h

@@ -2,9 +2,9 @@
 
 class CEmptyAI : public CGlobalAI
 {
-	CCallback * cb;
+	ICallback * cb;
 public:
-	void init(CCallback * CB);
+	void init(ICallback * CB);
 	void yourTurn();
 	void heroKilled(const CHeroInstance *);
 	void heroCreated(const CHeroInstance *);

+ 79 - 5
AI/EmptyAI/Z_EmptyAI.vcproj

@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="windows-1250"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9,00"
 	Name="Z_EmptyAI"
 	ProjectGUID="{954A9AEC-B3D0-46FA-9969-D44F069EAA23}"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -37,6 +38,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
+				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
 				DebugInformationFormat="3"
 			/>
 			<Tool
@@ -56,6 +58,9 @@
 				GenerateMapFile="true"
 				MapFileName="mapfile.map"
 				MapExports="true"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				Profile="true"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -75,9 +80,6 @@
 			<Tool
 				Name="VCAppVerifierTool"
 			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
 			<Tool
 				Name="VCPostBuildEventTool"
 			/>
@@ -112,6 +114,8 @@
 				OmitFramePointers="true"
 				EnableFiberSafeOptimizations="true"
 				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
+				StringPooling="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -126,6 +130,8 @@
 				Name="VCLinkerTool"
 				OutputFile="../EmptyAI.dll"
 				LinkTimeCodeGeneration="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -146,7 +152,75 @@
 				Name="VCAppVerifierTool"
 			/>
 			<Tool
-				Name="VCWebDeploymentTool"
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="RD|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				EnableFiberSafeOptimizations="true"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
+				StringPooling="true"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="../EmptyAI.dll"
+				LinkTimeCodeGeneration="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
 			/>
 			<Tool
 				Name="VCPostBuildEventTool"

+ 2 - 1
CAdvmapInterface.cpp

@@ -800,6 +800,7 @@ void CTerrainRect::deactivate()
 }; 
 void CTerrainRect::clickLeft(tribool down)
 {
+	LOGE("Left mouse button down2");
 	if ((down==false) || indeterminate(down))
 		return;
 	if (LOCPLINT->adventureInt->selection.type != HEROI_TYPE)
@@ -814,7 +815,7 @@ void CTerrainRect::clickLeft(tribool down)
 	int3 mp = whichTileIsIt();
 	if ((mp.x<0) || (mp.y<0))
 		return;
-	bool mres;
+	bool mres =true;
 	if (currentPath)
 	{
 		if ( (currentPath->endPos()) == mp)

+ 24 - 1
CCallback.h

@@ -10,6 +10,29 @@ class CPath;
 class CGObjectInstance;
 struct SComponent;
 typedef struct lua_State lua_State;
+
+class ICallback
+{	
+public:
+	virtual bool moveHero(int ID, CPath * path, int idtype, int pathType=0)=0;//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero 
+															//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
+
+//get info
+	virtual bool verifyPath(CPath * path, bool blockSea)=0;
+	virtual int getDate(int mode=0)=0; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
+	virtual PseudoV< PseudoV< PseudoV<unsigned char> > > & getVisibilityMap()=0; //returns visibility map (TODO: make it const)
+	virtual const CGHeroInstance * getHeroInfo(int player, int val, bool mode)=0; //mode = 0 -> val = serial; mode = 1 -> val = ID
+	virtual int getResourceAmount(int type)=0;
+	virtual int howManyHeroes()=0;
+	virtual const CGTownInstance * getTownInfo(int val, bool mode)=0; //mode = 0 -> val = serial; mode = 1 -> val = ID
+	virtual int howManyTowns()=0;
+	virtual std::vector < std::string > getObjDescriptions(int3 pos)=0; //returns descriptions of objects at pos in order from the lowest to the highest
+	virtual std::vector < const CGHeroInstance *> * getHeroesInfo(bool onlyOur=true)=0;
+	virtual bool isVisible(int3 pos)=0;
+	virtual int getMyColor()=0;
+	virtual int getMySerial()=0;
+};
+
 struct HeroMoveDetails
 {
 	int3 src, dst; //source and destination points
@@ -18,7 +41,7 @@ struct HeroMoveDetails
 	bool successful;
 };
 
-class CCallback 
+class CCallback : public ICallback
 {
 private:
 	void newTurn();

+ 1 - 1
CGameInterface.h

@@ -15,7 +15,7 @@ public:
 	bool human;
 	int playerID, serialID;
 
-	virtual void init(CCallback * CB)=0{};
+	virtual void init(ICallback * CB)=0{};
 	virtual void yourTurn()=0{};
 	virtual void heroKilled(const CGHeroInstance*)=0{};
 	virtual void heroCreated(const CGHeroInstance*)=0{};

+ 3 - 2
CPlayerInterface.cpp

@@ -286,9 +286,9 @@ CPlayerInterface::CPlayerInterface(int Player, int serial)
 	morale82 = CGI->spriteh->giveDefEss("IMRL82.DEF");
 
 }
-void CPlayerInterface::init(CCallback * CB)
+void CPlayerInterface::init(ICallback * CB)
 {
-	cb = CB;
+	cb = dynamic_cast<CCallback*>(CB);
 	CGI->localPlayer = serialID;
 	adventureInt = new CAdvMapInt(playerID);
 }
@@ -1190,6 +1190,7 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
 
 	else if ((sEvent->type==SDL_MOUSEBUTTONDOWN) && (sEvent->button.button == SDL_BUTTON_LEFT))
 	{
+		LOGE("Left mouse button down1");
 		for(int i=0; i<lclickable.size();i++)
 		{
 			if (isItIn(&lclickable[i]->pos,sEvent->motion.x,sEvent->motion.y))

+ 1 - 1
CPlayerInterface.h

@@ -178,7 +178,7 @@ public:
 	
 	SDL_Surface * infoWin(const void * specific); //specific=0 => draws info about selected town/hero //TODO - gdy sie dorobi sensowna hierarchie klas ins. to wywalic tego brzydkiego void*
 	void handleEvent(SDL_Event * sEvent);
-	void init(CCallback * CB);
+	void init(ICallback * CB);
 	int3 repairScreenPos(int3 pos);
 	void showInfoDialog(std::string text, std::vector<SComponent*> & components);
 	void removeObjToBlit(IShowable* obj);

+ 1 - 0
StartInfo.h

@@ -26,6 +26,7 @@ struct StartInfo
 		for(int i=0; i<playerInfos.size(); ++i)
 			if(playerInfos[i].color == no)
 				return playerInfos[i];
+		throw new std::exception("Cannot find info about player");
 	}
 };
 

+ 9 - 0
global.h

@@ -31,6 +31,15 @@ enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHE
 #define HEROI_TYPE (0)
 #define TOWNI_TYPE (1)
 
+//#define LOGUJ
+
+#ifdef LOGUJ
+#define LOG(x) std::cout<<x;
+#define LOGE(x) std::cout<<x<<std::endl;
+#else
+#define LOG(x) ;
+#define LOGE(x) ;
+#endif
 
 const int F_NUMBER = 9; //factions (town types) quantity
 const int PLAYER_LIMIT = 8; //player limit per map

+ 0 - 7
nodrze.h

@@ -9,13 +9,6 @@
 #include <string>
 #include <vector>
 
-#define LOGUJ ;
-#define CLOG ;
-
-#ifndef LOGUJ
-#define LOGUJ(a) (std::cout<<a)
-#define CLOG(a) (std::cout<<a)
-#endif
 const bool CZERWONY=true, CZARNY=false;
 template <typename T>  class wezel
 {