1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00
This commit is contained in:
Michał W. Urbańczyk 2009-03-06 22:25:19 +00:00
parent b1c0d10ece
commit e9ebc7de5b
17 changed files with 207 additions and 124 deletions

View File

@ -49,6 +49,7 @@
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="4" WarningLevel="4"
DebugInformationFormat="4" DebugInformationFormat="4"
DisableSpecificWarnings="4512"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
@ -127,6 +128,7 @@
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3" DebugInformationFormat="3"
DisableSpecificWarnings="4512"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
@ -210,6 +212,7 @@
ProgramDataBaseFileName="$(SolutionDir)$(ConfigurationName)\GeniusAI.pdb" ProgramDataBaseFileName="$(SolutionDir)$(ConfigurationName)\GeniusAI.pdb"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3" DebugInformationFormat="3"
DisableSpecificWarnings="4512"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"

View File

@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
} }
} }
//initializing //initializing
std::map<int, int> animLengths;
std::map<int, int> increments;
int maxLen = 0; int maxLen = 0;
for(size_t g=0; g<attackedInfos.size(); ++g) for(size_t g=0; g<attackedInfos.size(); ++g)
{ {
int animLen;
if(attackedInfos[g].killed) if(attackedInfos[g].killed)
{ {
creAnims[attackedInfos[g].ID]->setType(5); //death creAnims[attackedInfos[g].ID]->setType(5); //death
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(5);
} }
else else
{ {
creAnims[attackedInfos[g].ID]->setType(3); //getting hit creAnims[attackedInfos[g].ID]->setType(3); //getting hit
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(3);
}
animLengths.insert(std::make_pair(attackedInfos[g].ID, animLen));
increments.insert(std::make_pair(attackedInfos[g].ID, 0));
if(animLen > maxLen)
{
maxLen = animLen;
} }
} }
//main showing loop //main showing loop
@ -1201,18 +1190,17 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
SDL_framerateDelay(LOCPLINT->mainFPSmng); SDL_framerateDelay(LOCPLINT->mainFPSmng);
for(size_t g=0; g<attackedInfos.size(); ++g) for(size_t g=0; g<attackedInfos.size(); ++g)
{ {
if((animCount+1)%(4/animSpeed)==0 && increments[attackedInfos[g].ID]<animLengths[attackedInfos[g].ID]) if((animCount+1)%(4/animSpeed)==0 && !creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
{ {
creAnims[attackedInfos[g].ID]->incrementFrame(); creAnims[attackedInfos[g].ID]->incrementFrame();
++(increments[attackedInfos[g].ID]);
} }
if(increments[attackedInfos[g].ID]>=animLengths[attackedInfos[g].ID] && creAnims[attackedInfos[g].ID]->getType() == 3) if(creAnims[attackedInfos[g].ID]->onLastFrameInGroup() && creAnims[attackedInfos[g].ID]->getType() == 3)
creAnims[attackedInfos[g].ID]->setType(2); creAnims[attackedInfos[g].ID]->setType(2);
} }
bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued
for(size_t g=0; g<attackedInfos.size(); ++g) for(size_t g=0; g<attackedInfos.size(); ++g)
{ {
if(increments[attackedInfos[g].ID] < animLengths[attackedInfos[g].ID]-1) if(!creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
{ {
isAnotherOne = true; isAnotherOne = true;
break; break;
@ -2245,9 +2233,12 @@ void CBattleHero::show(SDL_Surface *to)
{ {
SDL_Rect posb = pos; SDL_Rect posb = pos;
CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb); CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb);
if(phase != 4 || image != 4) if(phase != 4 || nextPhase != -1 || image < 4)
{
if(flagAnimCount%2==0)
{ {
++image; ++image;
}
if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame
{ {
image = 0; image = 0;
@ -2256,6 +2247,7 @@ void CBattleHero::show(SDL_Surface *to)
if(phase == 4 && nextPhase != -1 && image == 7) if(phase == 4 && nextPhase != -1 && image == 7)
{ {
phase = nextPhase; phase = nextPhase;
nextPhase = -1;
image = 0; image = 0;
} }
break; break;
@ -2281,14 +2273,13 @@ void CBattleHero::setPhase(int newPhase)
} }
else else
{ {
++image;
nextPhase = newPhase; nextPhase = newPhase;
} }
} }
void CBattleHero::clickLeft(boost::logic::tribool down) void CBattleHero::clickLeft(boost::logic::tribool down)
{ {
if(!down && myHero && myHero->getArt(17)) if(!down && myHero) if(myHero->getArt(17)) //if both conditions are satisfied; for certain reason myHero->getArt(17) has been checked once even though myHero was NULL
{ {
for(int it=0; it<BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield for(int it=0; it<BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
{ {

View File

@ -45,7 +45,6 @@ public:
CArtHandler * arth; CArtHandler * arth;
CHeroHandler * heroh; CHeroHandler * heroh;
CCreatureHandler * creh; CCreatureHandler * creh;
CAbilityHandler * abilh;
CSpellHandler * spellh; CSpellHandler * spellh;
CMapHandler * mh; CMapHandler * mh;
CBuildingHandler * buildh; CBuildingHandler * buildh;

View File

@ -14,12 +14,15 @@
#include "hch/CObjectHandler.h" #include "hch/CObjectHandler.h"
#include "hch/CCreatureHandler.h" #include "hch/CCreatureHandler.h"
#include "lib/VCMI_Lib.h" #include "lib/VCMI_Lib.h"
#include "lib/Connection.h"
#include "map.h" #include "map.h"
#include "StartInfo.h" #include "StartInfo.h"
#include "lib/NetPacks.h" #include "lib/NetPacks.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/shared_mutex.hpp>
#include "lib/RegisterTypes.h"
boost::rand48 ran; boost::rand48 ran;
@ -30,6 +33,38 @@ boost::rand48 ran;
#undef max #undef max
#endif #endif
class CBaseForGSApply
{
public:
virtual void applyOnGS(CGameState *gs, void *pack) const =0;
};
template <typename T> class CApplyOnGS : public CBaseForGSApply
{
public:
void applyOnGS(CGameState *gs, void *pack) const
{
T *ptr = static_cast<T*>(pack);
ptr->applyGs(gs);
}
};
class CGSApplier
{
public:
std::map<ui16,CBaseForGSApply*> apps;
CGSApplier()
{
registerTypes2(*this);
}
template<typename T> void registerType(const T * t=NULL)
{
ui16 ID = typeList.registerType(&typeid(T));
apps[ID] = new CApplyOnGS<T>;
}
} applier;
std::string DLL_EXPORT toString(MetaString &ms) std::string DLL_EXPORT toString(MetaString &ms)
{ {
std::string ret; std::string ret;
@ -1434,6 +1469,11 @@ int CGameState::canBuildStructure( const CGTownInstance *t, int ID )
return ret; return ret;
} }
void CGameState::apply(CPack *pack)
{
applier.apps[typeList.getTypeID(pack)]->applyOnGS(this,pack);
}
int BattleInfo::calculateDmg(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting) int BattleInfo::calculateDmg(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting)
{ {
int attackerAttackBonus = attacker->creature->attack + (attackerHero ? attackerHero->getPrimSkillLevel(0) : 0); int attackerAttackBonus = attacker->creature->attack + (attackerHero ? attackerHero->getPrimSkillLevel(0) : 0);

View File

@ -35,6 +35,7 @@ class CMapHandler;
class CPathfinder; class CPathfinder;
struct SetObjectProperty; struct SetObjectProperty;
struct MetaString; struct MetaString;
struct CPack;
std::string DLL_EXPORT toString(MetaString &ms); std::string DLL_EXPORT toString(MetaString &ms);
@ -228,6 +229,7 @@ public:
void randomizeObject(CGObjectInstance *cur); void randomizeObject(CGObjectInstance *cur);
std::pair<int,int> pickObject(CGObjectInstance *obj); std::pair<int,int> pickObject(CGObjectInstance *obj);
int pickHero(int owner); int pickHero(int owner);
void apply(CPack *pack);
CGHeroInstance *getHero(int objid); CGHeroInstance *getHero(int objid);
CGTownInstance *getTown(int objid); CGTownInstance *getTown(int objid);
bool battleMoveCreatureStack(int ID, int dest); bool battleMoveCreatureStack(int ID, int dest);

View File

@ -27,7 +27,6 @@
#include "CAdvmapInterface.h" #include "CAdvmapInterface.h"
#include "hch/CBuildingHandler.h" #include "hch/CBuildingHandler.h"
#include "hch/CVideoHandler.h" #include "hch/CVideoHandler.h"
#include "hch/CAbilityHandler.h"
#include "hch/CHeroHandler.h" #include "hch/CHeroHandler.h"
#include "hch/CCreatureHandler.h" #include "hch/CCreatureHandler.h"
#include "hch/CSpellHandler.h" #include "hch/CSpellHandler.h"
@ -123,10 +122,6 @@ int main(int argc, char** argv)
cgi->curh->initCursor(); cgi->curh->initCursor();
cgi->curh->show(); cgi->curh->show();
tlog0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl; tlog0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
CAbilityHandler * abilh = new CAbilityHandler;
abilh->loadAbilities();
cgi->abilh = abilh;
tlog0<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
cgi->pathf = new CPathfinder(); cgi->pathf = new CPathfinder();
tlog0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl; tlog0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
tlog0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl; tlog0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;

View File

@ -137,6 +137,13 @@ int CCreatureAnimation::getFrame() const
return curFrame; return curFrame;
} }
bool CCreatureAnimation::onLastFrameInGroup()
{
if(internalFrame == frameGroups[type].size() - 1)
return true;
return false;
}
void CCreatureAnimation::playOnce(int type) void CCreatureAnimation::playOnce(int type)
{ {
setType(type); setType(type);

View File

@ -36,8 +36,8 @@ private:
unsigned char * FDef; //animation raw data unsigned char * FDef; //animation raw data
int curFrame, internalFrame; //number of currently displayed frame int curFrame, internalFrame; //number of currently displayed frame
unsigned int frames; //number of frames unsigned int frames; //number of frames
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
public: public:
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1]) int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
int fullWidth, fullHeight; //read-only, please! int fullWidth, fullHeight; //read-only, please!
CCreatureAnimation(std::string name); //c-tor CCreatureAnimation(std::string name); //c-tor
@ -50,6 +50,7 @@ public:
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
void incrementFrame(); void incrementFrame();
int getFrame() const; int getFrame() const;
bool onLastFrameInGroup();
bool once; bool once;
void playOnce(int type); //plays once given stage of animation, then resets to 2 void playOnce(int type); //plays once given stage of animation, then resets to 2

View File

@ -25,9 +25,51 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/shared_mutex.hpp>
#include <sstream> #include <sstream>
#undef DLL_EXPORT
#define DLL_EXPORT
#include "../lib/RegisterTypes.h"
extern std::string NAME; extern std::string NAME;
namespace intpr = boost::interprocess; namespace intpr = boost::interprocess;
class CBaseForCLApply
{
public:
virtual void applyOnClAfter(CClient *cl, void *pack) const =0;
virtual void applyOnClBefore(CClient *cl, void *pack) const =0;
};
template <typename T> class CApplyOnCL : public CBaseForCLApply
{
public:
void applyOnClAfter(CClient *cl, void *pack) const
{
T *ptr = static_cast<T*>(pack);
ptr->applyCl(cl);
}
void applyOnClBefore(CClient *cl, void *pack) const
{
T *ptr = static_cast<T*>(pack);
ptr->applyFirstCl(cl);
}
};
class CCLApplier
{
public:
std::map<ui16,CBaseForCLApply*> apps;
CCLApplier()
{
registerTypes2(*this);
}
template<typename T> void registerType(const T * t=NULL)
{
ui16 ID = typeList.registerType(&typeid(T));
apps[ID] = new CApplyOnCL<T>;
}
} applier;
void CClient::init() void CClient::init()
{ {
IObjectInterface::cb = this; IObjectInterface::cb = this;
@ -53,38 +95,6 @@ CClient::~CClient(void)
{ {
delete shared; delete shared;
} }
void CClient::process(int what)
{
switch (what)
{
case 107:
{
ShowInInfobox sii;
*serv >> sii;
SComponent sc(sii.c);
sc.description = toString(sii.text);
if(playerint[sii.player]->human)
static_cast<CPlayerInterface*>(playerint[sii.player])->showComp(sc);
break;
}
case 513:
{
ui8 color;
std::string message;
*serv >> color >> message;
tlog4 << "Player "<<(int)color<<" sends a message: " << message << std::endl;
break;
}
case 9999:
break;
default:
{
std::ostringstream ex;
ex << "Not supported server message (type=" << what <<")";
throw ex.str();
}
}
}
void CClient::waitForMoveAndSend(int color) void CClient::waitForMoveAndSend(int color)
{ {
try try
@ -97,14 +107,18 @@ void CClient::waitForMoveAndSend(int color)
} }
void CClient::run() void CClient::run()
{ {
CPack *pack;
try try
{ {
ui16 typ; *serv >> pack;
while(1) CBaseForCLApply *apply = applier.apps[typeList.getTypeID(pack)];
{
*serv >> typ; apply->applyOnClBefore(this,pack);
process(typ); gs->apply(pack);
} apply->applyOnClAfter(this,pack);
delete pack;
pack = NULL;
} HANDLE_EXCEPTION } HANDLE_EXCEPTION
} }

View File

@ -59,7 +59,6 @@ public:
void newGame(CConnection *con, StartInfo *si); //con - connection to server void newGame(CConnection *con, StartInfo *si); //con - connection to server
void save(const std::string & fname); void save(const std::string & fname);
void load(const std::string & fname); void load(const std::string & fname);
void process(int what);
void run(); void run();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//from IGameCallback //from IGameCallback

View File

@ -274,10 +274,6 @@
RelativePath="..\AdventureMapButton.cpp" RelativePath="..\AdventureMapButton.cpp"
> >
</File> </File>
<File
RelativePath="..\hch\CAbilityHandler.cpp"
>
</File>
<File <File
RelativePath="..\CAdvmapInterface.cpp" RelativePath="..\CAdvmapInterface.cpp"
> >
@ -400,10 +396,6 @@
RelativePath="..\AI_Base.h" RelativePath="..\AI_Base.h"
> >
</File> </File>
<File
RelativePath="..\hch\CAbilityHandler.h"
>
</File>
<File <File
RelativePath="..\CAdvmapInterface.h" RelativePath="..\CAdvmapInterface.h"
> >

View File

@ -290,7 +290,7 @@ int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position o
} }
int CGHeroInstance::getSightDistance() const //returns sight distance of this hero int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
{ {
return 6 + getSecSkillLevel(3); //default + scouting return 5 + getSecSkillLevel(3); //default + scouting
} }
si32 CGHeroInstance::manaLimit() const si32 CGHeroInstance::manaLimit() const
@ -302,7 +302,7 @@ si32 CGHeroInstance::manaLimit() const
case 2: modifier+=0.5; break; case 2: modifier+=0.5; break;
case 3: modifier+=1.0; break; case 3: modifier+=1.0; break;
} }
return 10*getPrimSkillLevel(3)*modifier; return si32(10*getPrimSkillLevel(3)*modifier);
} }
//void CGHeroInstance::setPosition(int3 Pos, bool h3m) //as above, but sets position //void CGHeroInstance::setPosition(int3 Pos, bool h3m) //as above, but sets position
//{ //{
@ -334,19 +334,20 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
if (ret>2000) if (ret>2000)
ret=2000; ret=2000;
double bonus = 0;
if(onLand) if(onLand)
{ {
//logistics: //logistics:
switch(getSecSkillLevel(2)) switch(getSecSkillLevel(2))
{ {
case 1: case 1:
ret *= 1.1f; bonus = 0.1;
break; break;
case 2: case 2:
ret *= 1.2f; bonus = 0.2;
break; break;
case 3: case 3:
ret *= 1.3f; bonus = 0.3;
break; break;
} }
} }
@ -356,17 +357,17 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
switch(getSecSkillLevel(2)) switch(getSecSkillLevel(2))
{ {
case 1: case 1:
ret *= 1.5f; bonus = 0.5;
break; break;
case 2: case 2:
ret *= 2.0f; bonus = 1.0;
break; break;
case 3: case 3:
ret *= 2.5f; bonus = 1.5;
break; break;
} }
} }
return ret; return int(ret + ret*bonus);
} }
ui32 CGHeroInstance::getArtAtPos(ui16 pos) const ui32 CGHeroInstance::getArtAtPos(ui16 pos) const
{ {

View File

@ -7,6 +7,7 @@
using namespace boost; using namespace boost;
using namespace boost::asio::ip; using namespace boost::asio::ip;
template<typename Serializer> DLL_EXPORT void registerTypes(Serializer &s); //defined elsewhere and explicitly instantiated for used serializers
CTypeList typeList; CTypeList typeList;

View File

@ -53,8 +53,6 @@ enum SerializationLvl
Serializable Serializable
}; };
template<typename Serializer> DLL_EXPORT void registerTypes(Serializer &s); //defined in .cpp and explicitly instantiated for used serializers
class DLL_EXPORT CTypeList class DLL_EXPORT CTypeList
{ {
std::map<const type_info *,ui16> types; std::map<const type_info *,ui16> types;

View File

@ -66,6 +66,6 @@ public:
virtual void giveHero(int id, int player)=0; virtual void giveHero(int id, int player)=0;
virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0; virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0;
friend class CPackForClient; friend struct CPackForClient;
}; };
#endif // __IGAMECALLBACK_H__ #endif // __IGAMECALLBACK_H__

View File

@ -16,15 +16,27 @@ struct CPack
CPack(){}; CPack(){};
~CPack(){}; ~CPack(){};
ui16 getType() const{return type;} ui16 getType() const{return type;}
template <typename Handler> void serialize(Handler &h, const int version)
{
}
}; };
struct CPackForClient : public CPack struct CPackForClient : public CPack
{ {
CGameState* GS(CClient *cl); CGameState* GS(CClient *cl);
//virtual void applyFirstCl(CClient *cl){}; //called before applying to gs void applyFirstCl(CClient *cl)//called before applying to gs
//virtual void applyGs(CGameState *gs){}; {
//virtual void applyCl(CClient *cl){}; //called after applying to gs tlog1 << "CPackForClient::applyFirstCl - We should not be here!\n";
};
DLL_EXPORT void applyGs(CGameState *gs)
{
tlog1 << "CPackForClient::applyGs - We should not be here!\n";
};
void applyCl(CClient *cl)//called after applying to gs
{
tlog1 << "CPackForClient::applyCl - We should not be here!\n";
};
}; };
struct Query : public CPackForClient struct Query : public CPackForClient
@ -72,8 +84,10 @@ struct SystemMessage : public CPackForClient //95
void applyCl(CClient *cl); void applyCl(CClient *cl);
std::string text; std::string text;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & text;
} }
}; };
@ -81,11 +95,13 @@ struct YourTurn : public CPackForClient //100
{ {
YourTurn(){type = 100;}; YourTurn(){type = 100;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 player; ui8 player;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & player;
} }
}; };
@ -93,7 +109,7 @@ struct SetResource : public CPackForClient //102
{ {
SetResource(){type = 102;}; SetResource(){type = 102;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 player, resid; ui8 player, resid;
si32 val; si32 val;
@ -107,7 +123,7 @@ struct SetResources : public CPackForClient //104
{ {
SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;}; SetResources(){res.resize(RESOURCE_QUANTITY);type = 104;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 player; ui8 player;
std::vector<si32> res; //res[resid] => res amount std::vector<si32> res; //res[resid] => res amount
@ -122,7 +138,7 @@ struct SetPrimSkill : public CPackForClient //105
{ {
SetPrimSkill(){type = 105;}; SetPrimSkill(){type = 105;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 abs; //0 - changes by value; 1 - sets to value ui8 abs; //0 - changes by value; 1 - sets to value
si32 id; si32 id;
@ -137,7 +153,7 @@ struct SetSecSkill : public CPackForClient //106
{ {
SetSecSkill(){type = 106;}; SetSecSkill(){type = 106;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 abs; //0 - changes by value; 1 - sets to value ui8 abs; //0 - changes by value; 1 - sets to value
si32 id; si32 id;
@ -152,7 +168,7 @@ struct HeroVisitCastle : public CPackForClient //108
{ {
HeroVisitCastle(){flags=0;type = 108;}; HeroVisitCastle(){flags=0;type = 108;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 flags; //1 - start, 2 - garrison ui8 flags; //1 - start, 2 - garrison
ui32 tid, hid; ui32 tid, hid;
@ -174,7 +190,7 @@ struct ChangeSpells : public CPackForClient //109
{ {
ChangeSpells(){type = 109;}; ChangeSpells(){type = 109;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 learn; //1 - gives spell, 0 - takes ui8 learn; //1 - gives spell, 0 - takes
ui32 hid; ui32 hid;
@ -190,7 +206,7 @@ struct SetMana : public CPackForClient //110
{ {
SetMana(){type = 110;}; SetMana(){type = 110;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 hid, val; ui32 hid, val;
@ -204,7 +220,7 @@ struct SetMovePoints : public CPackForClient //111
{ {
SetMovePoints(){type = 111;}; SetMovePoints(){type = 111;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 hid, val; ui32 hid, val;
@ -217,7 +233,7 @@ struct FoWChange : public CPackForClient //112
{ {
FoWChange(){type = 112;}; FoWChange(){type = 112;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
std::set<int3> tiles; std::set<int3> tiles;
ui8 player, mode; //mode==0 - hide, mode==1 - reveal ui8 player, mode; //mode==0 - hide, mode==1 - reveal
@ -231,7 +247,7 @@ struct SetAvailableHeroes : public CPackForClient //113
{ {
SetAvailableHeroes(){type = 113;flags=0;}; SetAvailableHeroes(){type = 113;flags=0;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 player; ui8 player;
si32 hid1, hid2; si32 hid1, hid2;
@ -246,7 +262,7 @@ struct GiveBonus : public CPackForClient //115
{ {
GiveBonus(){type = 115;}; GiveBonus(){type = 115;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 hid; ui32 hid;
HeroBonus bonus; HeroBonus bonus;
@ -263,7 +279,7 @@ struct ChangeObjPos : public CPackForClient //116
ChangeObjPos(){type = 116;}; ChangeObjPos(){type = 116;};
void applyFirstCl(CClient *cl); void applyFirstCl(CClient *cl);
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 objid; ui32 objid;
int3 nPos; int3 nPos;
@ -281,7 +297,7 @@ struct RemoveObject : public CPackForClient //500
RemoveObject(si32 ID){id = ID;type = 500;}; RemoveObject(si32 ID){id = ID;type = 500;};
void applyFirstCl(CClient *cl); void applyFirstCl(CClient *cl);
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 id; si32 id;
@ -311,7 +327,7 @@ struct SetGarrisons : public CPackForClient //502
{ {
SetGarrisons(){type = 502;}; SetGarrisons(){type = 502;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
std::map<ui32,CCreatureSet> garrs; std::map<ui32,CCreatureSet> garrs;
@ -324,7 +340,7 @@ struct NewStructures : public CPackForClient //504
{ {
NewStructures(){type = 504;}; NewStructures(){type = 504;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 tid; si32 tid;
std::set<si32> bid; std::set<si32> bid;
@ -339,7 +355,7 @@ struct SetAvailableCreatures : public CPackForClient //506
{ {
SetAvailableCreatures(){type = 506;}; SetAvailableCreatures(){type = 506;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 tid; si32 tid;
std::map<si32,ui32> creatures; std::map<si32,ui32> creatures;
@ -353,7 +369,7 @@ struct SetHeroesInTown : public CPackForClient //508
{ {
SetHeroesInTown(){type = 508;}; SetHeroesInTown(){type = 508;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison si32 tid, visiting, garrison; //id of town, visiting hero, hero in garrison
@ -366,7 +382,7 @@ struct SetHeroArtifacts : public CPackForClient //509
{ {
SetHeroArtifacts(){type = 509;}; SetHeroArtifacts(){type = 509;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 hid; si32 hid;
std::vector<ui32> artifacts; //hero's artifacts from bag std::vector<ui32> artifacts; //hero's artifacts from bag
@ -378,10 +394,24 @@ struct SetHeroArtifacts : public CPackForClient //509
} }
}; };
struct PlayerMessage : public CPackForClient //513
{
PlayerMessage(){type = 513;};
void applyCl(CClient *cl);
ui8 player;
std::string text;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & text & player;
}
};
struct SetSelection : public CPackForClient //514 struct SetSelection : public CPackForClient //514
{ {
SetSelection(){type = 514;}; SetSelection(){type = 514;};
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui8 player; ui8 player;
ui32 id; ui32 id;
@ -396,7 +426,7 @@ struct HeroRecruited : public CPackForClient //515
{ {
HeroRecruited(){type = 515;}; HeroRecruited(){type = 515;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 hid, tid; //subID of hero si32 hid, tid; //subID of hero
int3 tile; int3 tile;
@ -413,7 +443,7 @@ struct GiveHero : public CPackForClient //516
GiveHero(){type = 516;}; GiveHero(){type = 516;};
void applyFirstCl(CClient *cl); void applyFirstCl(CClient *cl);
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 id; //object id ui32 id; //object id
ui8 player; ui8 player;
@ -426,7 +456,7 @@ struct GiveHero : public CPackForClient //516
struct NewTurn : public CPackForClient //101 struct NewTurn : public CPackForClient //101
{ {
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
struct Hero struct Hero
{ {
@ -483,7 +513,7 @@ struct InfoWindow : public CPackForClient //103 - displays simple info window
struct SetObjectProperty : public CPackForClient//1001 struct SetObjectProperty : public CPackForClient//1001
{ {
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 id; ui32 id;
ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced) ui8 what; //1 - owner; 2 - blockvis; 3 - first stack count; 4 - visitors; 5 - visited; 6 - ID (if 34 then also def is replaced)
@ -499,7 +529,7 @@ struct SetObjectProperty : public CPackForClient//1001
struct SetHoverName : public CPackForClient//1002 struct SetHoverName : public CPackForClient//1002
{ {
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 id; ui32 id;
MetaString name; MetaString name;
@ -514,7 +544,7 @@ struct SetHoverName : public CPackForClient//1002
struct HeroLevelUp : public Query//2000 struct HeroLevelUp : public Query//2000
{ {
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 heroid; si32 heroid;
ui8 primskill, level; ui8 primskill, level;
@ -565,7 +595,7 @@ struct BattleStart : public CPackForClient//3000
{ {
BattleStart(){type = 3000;}; BattleStart(){type = 3000;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
BattleInfo * info; BattleInfo * info;
@ -579,7 +609,7 @@ struct BattleNextRound : public CPackForClient//3001
{ {
BattleNextRound(){type = 3001;}; BattleNextRound(){type = 3001;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
si32 round; si32 round;
@ -592,7 +622,7 @@ struct BattleSetActiveStack : public CPackForClient//3002
{ {
BattleSetActiveStack(){type = 3002;}; BattleSetActiveStack(){type = 3002;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 stack; ui32 stack;
@ -638,7 +668,7 @@ struct BattleStackAttacked : public CPackForClient//3005
{ {
BattleStackAttacked(){flags = 0; type = 3005;}; BattleStackAttacked(){flags = 0; type = 3005;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
ui32 stackAttacked; ui32 stackAttacked;
ui32 newAmount, newHP, killedAmount, damageAmount; ui32 newAmount, newHP, killedAmount, damageAmount;
@ -667,7 +697,7 @@ struct BattleAttack : public CPackForClient//3006
{ {
BattleAttack(){flags = 0; type = 3006;}; BattleAttack(){flags = 0; type = 3006;};
void applyFirstCl(CClient *cl); void applyFirstCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
void applyCl(CClient *cl); void applyCl(CClient *cl);
BattleStackAttacked bsa; BattleStackAttacked bsa;
@ -697,7 +727,7 @@ struct StartAction : public CPackForClient//3007
StartAction(){type = 3007;}; StartAction(){type = 3007;};
StartAction(const BattleAction &act){ba = act; type = 3007;}; StartAction(const BattleAction &act){ba = act; type = 3007;};
void applyFirstCl(CClient *cl); void applyFirstCl(CClient *cl);
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
BattleAction ba; BattleAction ba;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
@ -710,6 +740,7 @@ struct EndAction : public CPackForClient//3008
{ {
EndAction(){type = 3008;}; EndAction(){type = 3008;};
void applyCl(CClient *cl); void applyCl(CClient *cl);
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
} }
@ -718,7 +749,7 @@ struct EndAction : public CPackForClient//3008
struct SpellCasted : public CPackForClient//3009 struct SpellCasted : public CPackForClient//3009
{ {
SpellCasted(){type = 3009;}; SpellCasted(){type = 3009;};
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
void applyCl(CClient *cl); void applyCl(CClient *cl);
ui8 side; //which hero casted spell: 0 - attacker, 1 - defender ui8 side; //which hero casted spell: 0 - attacker, 1 - defender
@ -734,7 +765,7 @@ struct SpellCasted : public CPackForClient//3009
struct SetStackEffect : public CPackForClient //3010 struct SetStackEffect : public CPackForClient //3010
{ {
SetStackEffect(){type = 3010;}; SetStackEffect(){type = 3010;};
void applyGs(CGameState *gs); DLL_EXPORT void applyGs(CGameState *gs);
void applyCl(CClient *cl); void applyCl(CClient *cl);
ui32 stack; ui32 stack;
@ -752,6 +783,7 @@ struct ShowInInfobox : public CPackForClient //107
Component c; Component c;
MetaString text; MetaString text;
void applyCl(CClient *cl);
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & player & c & text; h & player & c & text;

View File

@ -322,6 +322,10 @@
RelativePath="..\map.cpp" RelativePath="..\map.cpp"
> >
</File> </File>
<File
RelativePath=".\NetPacksLib.cpp"
>
</File>
<File <File
RelativePath=".\RegisterTypes.cpp" RelativePath=".\RegisterTypes.cpp"
> >
@ -420,6 +424,10 @@
RelativePath=".\NetPacks.h" RelativePath=".\NetPacks.h"
> >
</File> </File>
<File
RelativePath=".\RegisterTypes.h"
>
</File>
<File <File
RelativePath=".\VCMI_Lib.h" RelativePath=".\VCMI_Lib.h"
> >