Michał W. Urbańczyk 16 年之前
父节点
当前提交
e9ebc7de5b

+ 3 - 0
AI/GeniusAI/genius.vcproj

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

+ 10 - 19
CBattleInterface.cpp

@@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
 		}
 	}
 	//initializing
-	std::map<int, int> animLengths;
-	std::map<int, int> increments;
 	int maxLen = 0;
 	for(size_t g=0; g<attackedInfos.size(); ++g)
 	{
-		int animLen;
 		if(attackedInfos[g].killed)
 		{
 			creAnims[attackedInfos[g].ID]->setType(5); //death
-			animLen = creAnims[attackedInfos[g].ID]->framesInGroup(5);
 		}
 		else
 		{
 			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
@@ -1201,18 +1190,17 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
 		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 		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();
-				++(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);
 		}
 		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)
 		{
-			if(increments[attackedInfos[g].ID] < animLengths[attackedInfos[g].ID]-1)
+			if(!creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
 			{
 				isAnotherOne = true;
 				break;
@@ -2245,9 +2233,12 @@ void CBattleHero::show(SDL_Surface *to)
 		{
 			SDL_Rect posb = pos;
 			CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[i].bitmap, NULL, to, &posb);
-			if(phase != 4 || image != 4)
+			if(phase != 4 || nextPhase != -1 || image < 4)
 			{
-				++image;
+				if(flagAnimCount%2==0)
+				{
+					++image;
+				}
 				if(dh->ourImages[(i+1)%dh->ourImages.size()].groupNumber!=phase) //back to appropriate frame
 				{
 					image = 0;
@@ -2256,6 +2247,7 @@ void CBattleHero::show(SDL_Surface *to)
 			if(phase == 4 && nextPhase != -1 && image == 7)
 			{
 				phase = nextPhase;
+				nextPhase = -1;
 				image = 0;
 			}
 			break;
@@ -2281,14 +2273,13 @@ void CBattleHero::setPhase(int newPhase)
 	}
 	else
 	{
-		++image;
 		nextPhase = newPhase;
 	}
 }
 
 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
 		{

+ 0 - 1
CGameInfo.h

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

+ 40 - 0
CGameState.cpp

@@ -14,12 +14,15 @@
 #include "hch/CObjectHandler.h"
 #include "hch/CCreatureHandler.h"
 #include "lib/VCMI_Lib.h"
+#include "lib/Connection.h"
 #include "map.h"
 #include "StartInfo.h"
 #include "lib/NetPacks.h"
 #include <boost/foreach.hpp>
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
+
+#include "lib/RegisterTypes.h"
 boost::rand48 ran;
 
 
@@ -30,6 +33,38 @@ boost::rand48 ran;
 #undef max
 #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 ret;
@@ -1434,6 +1469,11 @@ int CGameState::canBuildStructure( const CGTownInstance *t, int ID )
 	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 attackerAttackBonus = attacker->creature->attack + (attackerHero ? attackerHero->getPrimSkillLevel(0) : 0);

+ 2 - 0
CGameState.h

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

+ 0 - 5
CMT.cpp

@@ -27,7 +27,6 @@
 #include "CAdvmapInterface.h"
 #include "hch/CBuildingHandler.h"
 #include "hch/CVideoHandler.h"
-#include "hch/CAbilityHandler.h"
 #include "hch/CHeroHandler.h"
 #include "hch/CCreatureHandler.h"
 #include "hch/CSpellHandler.h"
@@ -123,10 +122,6 @@ int main(int argc, char** argv)
 		cgi->curh->initCursor();
 		cgi->curh->show();
 		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();
 		tlog0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
 		tlog0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;

+ 9 - 2
client/CCreatureAnimation.cpp

@@ -137,6 +137,13 @@ int CCreatureAnimation::getFrame() const
 	return curFrame;
 }
 
+bool CCreatureAnimation::onLastFrameInGroup()
+{
+	if(internalFrame == frameGroups[type].size() - 1)
+		return true;
+	return false;
+}
+
 void CCreatureAnimation::playOnce(int type)
 {
 	setType(type);
@@ -265,8 +272,8 @@ inline void CCreatureAnimation::putPixel(
         const int & ftcp,
         const BMPPalette & color,
         const unsigned char & palc,
-        const bool & yellowBorder,
-		const bool & blueBorder,
+        const bool & yellowBorder,
+		const bool & blueBorder,
 		const unsigned char & animCount
 ) const
 {	

+ 2 - 1
client/CCreatureAnimation.h

@@ -36,8 +36,8 @@ private:
 	unsigned char * FDef; //animation raw data
 	int curFrame, internalFrame; //number of currently displayed frame
 	unsigned int frames; //number of frames
-	std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
 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 fullWidth, fullHeight; //read-only, please!
 	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 
 	void incrementFrame();
 	int getFrame() const;
+	bool onLastFrameInGroup();
 
 	bool once;
 	void playOnce(int type); //plays once given stage of animation, then resets to 2

+ 52 - 38
client/Client.cpp

@@ -25,9 +25,51 @@
 #include <boost/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
 #include <sstream>
+
+#undef DLL_EXPORT
+#define DLL_EXPORT
+#include "../lib/RegisterTypes.h"
 extern std::string NAME;
 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()
 {
 	IObjectInterface::cb = this;
@@ -53,38 +95,6 @@ CClient::~CClient(void)
 {
 	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)
 {
 	try
@@ -97,14 +107,18 @@ void CClient::waitForMoveAndSend(int color)
 }
 void CClient::run()
 {
+	CPack *pack;
 	try
 	{
-		ui16 typ;
-		while(1)
-		{
-			*serv >> typ;
-			process(typ);
-		}
+		*serv >> pack;
+		CBaseForCLApply *apply = applier.apps[typeList.getTypeID(pack)];
+
+		apply->applyOnClBefore(this,pack);
+		gs->apply(pack);
+		apply->applyOnClAfter(this,pack);
+
+		delete pack;
+		pack = NULL;
 	} HANDLE_EXCEPTION
 }
 

+ 0 - 1
client/Client.h

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

+ 0 - 8
client/VCMI_client.vcproj

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

+ 10 - 9
hch/CObjectHandler.cpp

@@ -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
 {
-	return 6 + getSecSkillLevel(3); //default + scouting
+	return 5 + getSecSkillLevel(3); //default + scouting
 }
 
 si32 CGHeroInstance::manaLimit() const
@@ -302,7 +302,7 @@ si32 CGHeroInstance::manaLimit() const
 	case 2:		modifier+=0.5;		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
 //{
@@ -334,19 +334,20 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
 	if (ret>2000) 
 		ret=2000;
 
+	double bonus = 0;
 	if(onLand)
 	{
 		//logistics:
 		switch(getSecSkillLevel(2))
 		{
 		case 1:
-			ret *= 1.1f;
+			bonus = 0.1;
 			break;
 		case 2:
-			ret *= 1.2f;
+			bonus = 0.2;
 			break;
 		case 3:
-			ret *= 1.3f;
+			bonus = 0.3;
 			break;
 		}
 	}
@@ -356,17 +357,17 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
 		switch(getSecSkillLevel(2))
 		{
 		case 1:
-			ret *= 1.5f;
+			bonus = 0.5;
 			break;
 		case 2:
-			ret *= 2.0f;
+			bonus = 1.0;
 			break;
 		case 3:
-			ret *= 2.5f;
+			bonus = 1.5;
 			break;
 		}
 	}
-	return ret;
+	return int(ret + ret*bonus);
 }
 ui32 CGHeroInstance::getArtAtPos(ui16 pos) const
 {

+ 1 - 0
lib/Connection.cpp

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

+ 0 - 2
lib/Connection.h

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

+ 1 - 1
lib/IGameCallback.h

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

+ 69 - 37
lib/NetPacks.h

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

+ 8 - 0
lib/VCMI_lib.vcproj

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