mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
Bugfixes for AI, Callback Interface, logging macrodefs.
This commit is contained in:
parent
e1b2ae0df1
commit
c8c0d0eaaf
@ -1,6 +1,6 @@
|
|||||||
#include "CEmptyAI.h"
|
#include "CEmptyAI.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
void CEmptyAI::init(CCallback * CB)
|
void CEmptyAI::init(ICallback * CB)
|
||||||
{
|
{
|
||||||
cb = CB;
|
cb = CB;
|
||||||
human=false;
|
human=false;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
class CEmptyAI : public CGlobalAI
|
class CEmptyAI : public CGlobalAI
|
||||||
{
|
{
|
||||||
CCallback * cb;
|
ICallback * cb;
|
||||||
public:
|
public:
|
||||||
void init(CCallback * CB);
|
void init(ICallback * CB);
|
||||||
void yourTurn();
|
void yourTurn();
|
||||||
void heroKilled(const CHeroInstance *);
|
void heroKilled(const CHeroInstance *);
|
||||||
void heroCreated(const CHeroInstance *);
|
void heroCreated(const CHeroInstance *);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="windows-1250"?>
|
<?xml version="1.0" encoding="windows-1250"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8,00"
|
Version="9,00"
|
||||||
Name="Z_EmptyAI"
|
Name="Z_EmptyAI"
|
||||||
ProjectGUID="{954A9AEC-B3D0-46FA-9969-D44F069EAA23}"
|
ProjectGUID="{954A9AEC-B3D0-46FA-9969-D44F069EAA23}"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
@ -37,6 +38,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="G:\tp\SDL\include;"E:\Program Files\Microsoft Visual Studio 8\VC\include""
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
@ -56,6 +58,9 @@
|
|||||||
GenerateMapFile="true"
|
GenerateMapFile="true"
|
||||||
MapFileName="mapfile.map"
|
MapFileName="mapfile.map"
|
||||||
MapExports="true"
|
MapExports="true"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
Profile="true"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@ -75,9 +80,6 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
@ -112,6 +114,8 @@
|
|||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
EnableFiberSafeOptimizations="true"
|
EnableFiberSafeOptimizations="true"
|
||||||
WholeProgramOptimization="true"
|
WholeProgramOptimization="true"
|
||||||
|
AdditionalIncludeDirectories="G:\tp\SDL\include;"E:\Program Files\Microsoft Visual Studio 8\VC\include""
|
||||||
|
StringPooling="true"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
@ -126,6 +130,8 @@
|
|||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="../EmptyAI.dll"
|
OutputFile="../EmptyAI.dll"
|
||||||
LinkTimeCodeGeneration="1"
|
LinkTimeCodeGeneration="1"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
@ -146,7 +152,75 @@
|
|||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<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;"E:\Program Files\Microsoft Visual Studio 8\VC\include""
|
||||||
|
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
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
|
@ -800,6 +800,7 @@ void CTerrainRect::deactivate()
|
|||||||
};
|
};
|
||||||
void CTerrainRect::clickLeft(tribool down)
|
void CTerrainRect::clickLeft(tribool down)
|
||||||
{
|
{
|
||||||
|
LOGE("Left mouse button down2");
|
||||||
if ((down==false) || indeterminate(down))
|
if ((down==false) || indeterminate(down))
|
||||||
return;
|
return;
|
||||||
if (LOCPLINT->adventureInt->selection.type != HEROI_TYPE)
|
if (LOCPLINT->adventureInt->selection.type != HEROI_TYPE)
|
||||||
@ -814,7 +815,7 @@ void CTerrainRect::clickLeft(tribool down)
|
|||||||
int3 mp = whichTileIsIt();
|
int3 mp = whichTileIsIt();
|
||||||
if ((mp.x<0) || (mp.y<0))
|
if ((mp.x<0) || (mp.y<0))
|
||||||
return;
|
return;
|
||||||
bool mres;
|
bool mres =true;
|
||||||
if (currentPath)
|
if (currentPath)
|
||||||
{
|
{
|
||||||
if ( (currentPath->endPos()) == mp)
|
if ( (currentPath->endPos()) == mp)
|
||||||
|
25
CCallback.h
25
CCallback.h
@ -10,6 +10,29 @@ class CPath;
|
|||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
struct SComponent;
|
struct SComponent;
|
||||||
typedef struct lua_State lua_State;
|
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
|
struct HeroMoveDetails
|
||||||
{
|
{
|
||||||
int3 src, dst; //source and destination points
|
int3 src, dst; //source and destination points
|
||||||
@ -18,7 +41,7 @@ struct HeroMoveDetails
|
|||||||
bool successful;
|
bool successful;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCallback
|
class CCallback : public ICallback
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
void newTurn();
|
void newTurn();
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
bool human;
|
bool human;
|
||||||
int playerID, serialID;
|
int playerID, serialID;
|
||||||
|
|
||||||
virtual void init(CCallback * CB)=0{};
|
virtual void init(ICallback * CB)=0{};
|
||||||
virtual void yourTurn()=0{};
|
virtual void yourTurn()=0{};
|
||||||
virtual void heroKilled(const CGHeroInstance*)=0{};
|
virtual void heroKilled(const CGHeroInstance*)=0{};
|
||||||
virtual void heroCreated(const CGHeroInstance*)=0{};
|
virtual void heroCreated(const CGHeroInstance*)=0{};
|
||||||
|
@ -286,9 +286,9 @@ CPlayerInterface::CPlayerInterface(int Player, int serial)
|
|||||||
morale82 = CGI->spriteh->giveDefEss("IMRL82.DEF");
|
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;
|
CGI->localPlayer = serialID;
|
||||||
adventureInt = new CAdvMapInt(playerID);
|
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))
|
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++)
|
for(int i=0; i<lclickable.size();i++)
|
||||||
{
|
{
|
||||||
if (isItIn(&lclickable[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
if (isItIn(&lclickable[i]->pos,sEvent->motion.x,sEvent->motion.y))
|
||||||
|
@ -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*
|
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 handleEvent(SDL_Event * sEvent);
|
||||||
void init(CCallback * CB);
|
void init(ICallback * CB);
|
||||||
int3 repairScreenPos(int3 pos);
|
int3 repairScreenPos(int3 pos);
|
||||||
void showInfoDialog(std::string text, std::vector<SComponent*> & components);
|
void showInfoDialog(std::string text, std::vector<SComponent*> & components);
|
||||||
void removeObjToBlit(IShowable* obj);
|
void removeObjToBlit(IShowable* obj);
|
||||||
|
@ -26,6 +26,7 @@ struct StartInfo
|
|||||||
for(int i=0; i<playerInfos.size(); ++i)
|
for(int i=0; i<playerInfos.size(); ++i)
|
||||||
if(playerInfos[i].color == no)
|
if(playerInfos[i].color == no)
|
||||||
return playerInfos[i];
|
return playerInfos[i];
|
||||||
|
throw new std::exception("Cannot find info about player");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
9
global.h
9
global.h
@ -31,6 +31,15 @@ enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHE
|
|||||||
#define HEROI_TYPE (0)
|
#define HEROI_TYPE (0)
|
||||||
#define TOWNI_TYPE (1)
|
#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 F_NUMBER = 9; //factions (town types) quantity
|
||||||
const int PLAYER_LIMIT = 8; //player limit per map
|
const int PLAYER_LIMIT = 8; //player limit per map
|
||||||
|
7
nodrze.h
7
nodrze.h
@ -9,13 +9,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#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;
|
const bool CZERWONY=true, CZARNY=false;
|
||||||
template <typename T> class wezel
|
template <typename T> class wezel
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user