mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +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 <iostream>
|
||||
void CEmptyAI::init(CCallback * CB)
|
||||
void CEmptyAI::init(ICallback * CB)
|
||||
{
|
||||
cb = CB;
|
||||
human=false;
|
||||
|
@ -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 *);
|
||||
|
@ -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;"E:\Program Files\Microsoft Visual Studio 8\VC\include""
|
||||
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;"E:\Program Files\Microsoft Visual Studio 8\VC\include""
|
||||
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;"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
|
||||
Name="VCPostBuildEventTool"
|
||||
|
@ -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)
|
||||
|
25
CCallback.h
25
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();
|
||||
|
@ -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{};
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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
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 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
|
||||
|
Loading…
Reference in New Issue
Block a user