diff --git a/CLua.cpp b/CLua.cpp index a93bf9f80..e4e062751 100644 --- a/CLua.cpp +++ b/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 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 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 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(8,os->subID); cb->setHoverName(objid,&ms); } + void CCreatureGen::onHeroVisit(int objid, int heroID) { } + std::vector CCreatureGen::yourObjects() //returns IDs of objects which are handled by script { std::vector 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 CTeleports::yourObjects() //returns IDs of objects which are ha ret.push_back(45); ret.push_back(103); return ret; -} \ No newline at end of file +} +//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) { +}; \ No newline at end of file diff --git a/CLua.h b/CLua.h index 35dd9e709..f0f3fc51e 100644 --- a/CLua.h +++ b/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 yourObjects()=0; //returns IDs of objects which are handled by script template 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 typeOfTree; //0 - level for free; 1 - 2000 gold; 2 - 10 gems std::map > visitors; @@ -121,7 +123,7 @@ public: class CVisitableOPW : public CCPPObjectScript //once per week { public: - CVisitableOPW(CScriptCallback * CB):CCPPObjectScript(CB){}; + CVisitableOPW(CScriptCallback * CB); std::map 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 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 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 yourObjects(); //returns IDs of objects which are handled by script @@ -186,7 +188,7 @@ class CCreatureGen : public CCPPObjectScript { public: std::map 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 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 yourObjects(); //returns IDs of objects which are handled by script - CTeleports(CScriptCallback * CB):CCPPObjectScript(CB){}; + CTeleports(CScriptCallback * CB);//:CCPPObjectScript(CB){}; }; \ No newline at end of file diff --git a/lib/Connection.h b/lib/Connection.h index 1b5274e2e..37294527f 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -1,3 +1,5 @@ +#ifndef CONNECTION_H +#define CONNECTION_H #pragma once #include "../global.h" #include @@ -15,6 +17,7 @@ #include #include +#include const int version = 63; class CConnection; @@ -409,3 +412,4 @@ public: void close(); ~CConnection(void); }; +#endif //CONNECTION_H diff --git a/map.h b/map.h index ef60d19b8..bd5741a40 100644 --- a/map.h +++ b/map.h @@ -1,7 +1,7 @@ #ifndef MAPD_H #define MAPD_H #pragma warning (disable : 4482) -#include +#include #include #include #include diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 5dd81cf0b..1461ff7e7 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -1,3 +1,6 @@ +#ifndef CGAMEHANDLER_H +#define CGAMEHANDLER_H + #pragma once #include "../global.h" #include @@ -133,3 +136,4 @@ public: friend class CVCMIServer; friend class CScriptCallback; }; +#endif //CGAMEHANDLER_H \ No newline at end of file