浏览代码

few tweaks to make (server, client) on gcc (4.3.3 ubuntu)

Łukasz Wychrystenko 17 年之前
父节点
当前提交
0f81bf5ae0
共有 5 个文件被更改,包括 103 次插入22 次删除
  1. 72 1
      CLua.cpp
  2. 22 20
      CLua.h
  3. 4 0
      lib/Connection.h
  4. 1 1
      map.h
  5. 4 0
      server/CGameHandler.h

+ 72 - 1
CLua.cpp

@@ -23,6 +23,7 @@
 #include "lib/NetPacks.h"
 #pragma warning (disable : 4311)
 #define DEFOS const CGObjectInstance *os = cb->getObj(objid)
+
 bool getGlobalFunc(lua_State * L, std::string fname)
 {
 	//unsigned int hash = lua_calchash(fname.c_str(), fname.size());
@@ -32,6 +33,39 @@ bool getGlobalFunc(lua_State * L, std::string fname)
 	return false;
 }
 
+
+
+void CObjectScript::newObject(int objid) {
+};
+
+void CObjectScript::onHeroVisit(int objid, int heroID) {
+};
+
+void CObjectScript::onHeroLeave(int objid, int heroID) {
+};
+
+std::string CObjectScript::hoverText(int objid) {
+    return "";
+};
+
+void CObjectScript::newTurn () {
+};
+
+void CObjectScript::equipArtefact(int HID, int AID, int slot, bool putOn) {
+}; //putOn==0 means that artifact is taken off
+
+void CObjectScript::battleStart(int phase) {
+}; //phase==0 - very start, before initialization of battle; phase==1 - just before battle starts
+
+void CObjectScript::battleNewTurn (int turn) {
+}; //turn==-1 is for tactic stage
+
+void CObjectScript::heroLevelUp (int HID) {
+}; //add possibility of changing available sec. skills
+//CObjectScript
+
+
+
 CObjectScript::CObjectScript()
 {
 	language = UNDEF;
@@ -560,6 +594,9 @@ void CMines::newTurn ()
 	}
 }
 
+CPickable::CPickable(CScriptCallback * CB):CCPPObjectScript(CB) {
+
+};
 
 void CPickable::newObject(int objid)
 {
@@ -717,6 +754,9 @@ std::vector<int> CPickable::yourObjects() //returns IDs of objects which are han
 	ret.push_back(101); //treasure chest / commander stone
 	return ret;
 }
+//CPickable
+CTownScript::CTownScript(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
 
 void CTownScript::onHeroVisit(int objid, int heroID)
 {
@@ -747,6 +787,9 @@ std::vector<int> CTownScript::yourObjects() //returns IDs of objects which are h
 	ret.push_back(98); //town
 	return ret;
 }
+//CTownScript
+CHeroScript::CHeroScript(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
 
 void CHeroScript::newObject(int objid)
 {
@@ -784,6 +827,11 @@ std::vector<int> CHeroScript::yourObjects() //returns IDs of objects which are h
 	ret.push_back(34); //hero
 	return ret;
 }
+//CHeroScript
+
+CMonsterS::CMonsterS(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
+
 void CMonsterS::newObject(int objid)
 {
 	//os->blockVisit = true;
@@ -859,6 +907,11 @@ void CMonsterS::endBattleWith(const CGObjectInstance *monster, BattleResult *res
 		cb->setAmount(monster->id,((CCreatureObjInfo*)(monster->info))->number - killedAmount);
 	}
 }
+//CMonsterS
+
+
+CCreatureGen::CCreatureGen(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
 
 void CCreatureGen::newObject(int objid)
 {
@@ -868,15 +921,20 @@ void CCreatureGen::newObject(int objid)
 	ms << std::pair<ui8,ui32>(8,os->subID);
 	cb->setHoverName(objid,&ms);
 }
+
 void CCreatureGen::onHeroVisit(int objid, int heroID)
 {
 }
+
 std::vector<int> CCreatureGen::yourObjects() //returns IDs of objects which are handled by script
 {
 	std::vector<int> ret;
 	ret.push_back(17); //cregen1
 	return ret;
 }
+//CCreatureGen
+CTeleports::CTeleports(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
 
 void CTeleports::newObject(int objid)
 {
@@ -941,4 +999,17 @@ std::vector<int> CTeleports::yourObjects() //returns IDs of objects which are ha
 	ret.push_back(45); 
 	ret.push_back(103); 
 	return ret;
-}
+}
+//CTeleports
+CCPPObjectScript::CCPPObjectScript(CScriptCallback * CB) {
+    cb=CB;
+};
+
+CVisitableOPH::CVisitableOPH(CScriptCallback * CB):CCPPObjectScript(CB) {//:CCPPObjectScript(CB) {
+};
+
+CVisitableOPW::CVisitableOPW(CScriptCallback * CB):CCPPObjectScript(CB) {
+};
+
+CMines::CMines(CScriptCallback * CB):CCPPObjectScript(CB) {
+};

+ 22 - 20
CLua.h

@@ -27,10 +27,12 @@ struct Mapa;
 struct lua_State;
 struct BattleResult;
 enum ESLan{UNDEF=-1,CPP,ERM,LUA};
+
+
 class CObjectScript
 {
 public:
-	int owner, language;
+        int owner, language;
 	std::string filename;
 
 	int getOwner(){return owner;} //255 - neutral /  254 - not flaggable
@@ -40,20 +42,20 @@ public:
 
 	//functions to be called in script
 	//virtual void init(){}; //called when game is ready
-	virtual void newObject(int objid){};
-	virtual void onHeroVisit(int objid, int heroID){};
-	virtual void onHeroLeave(int objid, int heroID){};
-	virtual std::string hoverText(int objid){return "";};
-	virtual void newTurn (){};
+	virtual void newObject(int objid);
+	virtual void onHeroVisit(int objid, int heroID);
+	virtual void onHeroLeave(int objid, int heroID);
+	virtual std::string hoverText(int objid);
+	virtual void newTurn ();
 
 
 	//TODO: implement functions below:
-	virtual void equipArtefact(int HID, int AID, int slot, bool putOn){}; //putOn==0 means that artifact is taken off
-	virtual void battleStart(int phase){}; //phase==0 - very start, before initialization of battle; phase==1 - just before battle starts
-	virtual void battleNewTurn (int turn){}; //turn==-1 is for tactic stage
+	virtual void equipArtefact(int HID, int AID, int slot, bool putOn); //putOn==0 means that artifact is taken off
+	virtual void battleStart(int phase); //phase==0 - very start, before initialization of battle; phase==1 - just before battle starts
+	virtual void battleNewTurn (int turn); //turn==-1 is for tactic stage
 	//virtual void battleAction (int type,int destination, int stack, int owner, int){};
 	//virtual void mouseClick (down,left,screen?, pos??){};
-	virtual void heroLevelUp (int HID){}; //add possibility of changing available sec. skills
+	virtual void heroLevelUp (int HID); //add possibility of changing available sec. skills
 
 };
 class CScript
@@ -97,7 +99,7 @@ class CCPPObjectScript: public CObjectScript
 {
 public:
 	CScriptCallback * cb;
-	CCPPObjectScript(CScriptCallback * CB){cb=CB;};
+	CCPPObjectScript(CScriptCallback * CB);//{cb=CB;};
 	virtual std::vector<int> yourObjects()=0; //returns IDs of objects which are handled by script
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -107,7 +109,7 @@ public:
 class CVisitableOPH : public CCPPObjectScript  //once per hero
 {
 public:
-	CVisitableOPH(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CVisitableOPH(CScriptCallback * CB);//{};
 	std::map<int, int> typeOfTree; //0 - level for free; 1 - 2000 gold; 2 - 10 gems
 	std::map<int,std::set<int> > visitors;
 
@@ -121,7 +123,7 @@ public:
 class CVisitableOPW : public CCPPObjectScript  //once per week
 {
 public:
-	CVisitableOPW(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CVisitableOPW(CScriptCallback * CB);
 	std::map<int,bool> visited;
 	void onNAHeroVisit(int objid, int heroID, bool alreadyVisited);
 	void newObject(int objid);
@@ -133,7 +135,7 @@ public:
 class CMines : public CCPPObjectScript  //flaggable, and giving resource at each day
 {
 public:
-	CMines(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CMines(CScriptCallback * CB);
 
 	std::vector<int> ourObjs;
 
@@ -146,7 +148,7 @@ public:
 class CPickable : public CCPPObjectScript //pickable - resources, artifacts, etc
 {
 public:
-	CPickable(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CPickable(CScriptCallback * CB);//:CCPPObjectScript(CB);
 	void chosen(ui32 which, int heroid, int val); //val - value of treasure in gold
 	void newObject(int objid);
 	void onHeroVisit(int objid, int heroID);
@@ -156,7 +158,7 @@ public:
 class CTownScript : public CCPPObjectScript  //pickable - resources, artifacts, etc
 {
 public:
-	CTownScript(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CTownScript(CScriptCallback * CB);//:CCPPObjectScript(CB){};
 	void onHeroVisit(int objid, int heroID);
 	void onHeroLeave(int objid, int heroID);
 	void newObject(int objid);
@@ -166,7 +168,7 @@ public:
 class CHeroScript : public CCPPObjectScript
 {
 public:
-	CHeroScript(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CHeroScript(CScriptCallback * CB);//:CCPPObjectScript(CB){};
 	void newObject(int objid);
 	void onHeroVisit(int objid, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
@@ -175,7 +177,7 @@ public:
 class CMonsterS : public CCPPObjectScript
 {
 public:
-	CMonsterS(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CMonsterS(CScriptCallback * CB);//:CCPPObjectScript(CB){};
 	void newObject(int objid);
 	void onHeroVisit(int objid, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
@@ -186,7 +188,7 @@ class CCreatureGen : public CCPPObjectScript
 {
 public:
 	std::map<int, int> amount; //amount of creatures in each dwelling
-	CCreatureGen(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CCreatureGen(CScriptCallback * CB);//:CCPPObjectScript(CB){};
 	void newObject(int objid);
 	void onHeroVisit(int objid, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
@@ -200,5 +202,5 @@ public:
 	void newObject(int objid);
 	void onHeroVisit(int objid, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
-	CTeleports(CScriptCallback * CB):CCPPObjectScript(CB){};
+	CTeleports(CScriptCallback * CB);//:CCPPObjectScript(CB){};
 };

+ 4 - 0
lib/Connection.h

@@ -1,3 +1,5 @@
+#ifndef CONNECTION_H
+#define CONNECTION_H
 #pragma once
 #include "../global.h"
 #include <string>
@@ -15,6 +17,7 @@
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/identity.hpp>
 
+#include <boost/type_traits/is_array.hpp>
 const int version = 63;
 class CConnection;
 
@@ -409,3 +412,4 @@ public:
 	void close();
 	~CConnection(void);
 };
+#endif //CONNECTION_H

+ 1 - 1
map.h

@@ -1,7 +1,7 @@
 #ifndef MAPD_H
 #define MAPD_H
 #pragma warning (disable : 4482)
-#include <string>
+#include <cstring>
 #include <vector>
 #include <map>
 #include <set>

+ 4 - 0
server/CGameHandler.h

@@ -1,3 +1,6 @@
+#ifndef CGAMEHANDLER_H
+#define CGAMEHANDLER_H
+
 #pragma once
 #include "../global.h"
 #include <set>
@@ -133,3 +136,4 @@ public:
 	friend class CVCMIServer;
 	friend class CScriptCallback;
 };
+#endif //CGAMEHANDLER_H