diff --git a/CGameState.h b/CGameState.h index 46f4d4c0a..6566f92d0 100644 --- a/CGameState.h +++ b/CGameState.h @@ -22,6 +22,7 @@ class CGameState public: friend CCallback; friend int _tmain(int argc, _TCHAR* argv[]); + friend void CAmbarCendamo::deh3m(); CCallback * cb; //for communication between PlayerInterface/AI and GameState }; diff --git a/CMT.cpp b/CMT.cpp index c939bc185..4ab023846 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -63,9 +63,9 @@ const char * NAME = "VCMI 0.3"; SDL_Surface * ekran, * screen, * screen2; TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM; -// #include "lua.h" -// #include "lualib.h" -// #include "lauxlib.h" +//#include "lua.h" +//#include "lualib.h" +//#include "lauxlib.h" //#include //#include //#include @@ -99,7 +99,7 @@ int _tmain(int argc, _TCHAR* argv[]) // { luabind::open(lua); // luabind::module(lua) // [ -// luabind::def("powitanie",&piszpowitanie2,NULL) +// luabind::def("powitanie",&piszpowitanie2) // // ]; // diff --git a/hch/CAmbarCendamo.cpp b/hch/CAmbarCendamo.cpp index ccf10da5d..d67930ac9 100644 --- a/hch/CAmbarCendamo.cpp +++ b/hch/CAmbarCendamo.cpp @@ -4,9 +4,11 @@ #include "../CGameInfo.h" #include "CObjectHandler.h" #include "CCastleHandler.h" +#include "CTownHandler.h" #include "CDefObjInfoHandler.h" #include "../SDL_Extensions.h" #include "boost\filesystem.hpp" +#include "CGameState.h" #include "CLodHandler.h" #include #include @@ -1477,6 +1479,18 @@ void CAmbarCendamo::deh3m() spec->alignment = 0xff; i+=3; nobj->info = spec; + //////////// rewriting info to CTownInstance class ///////////////////// + CTownInstance * nt = new CTownInstance; + nt->type = CTownHandler::getTypeByDefName(map.defy[nobj->defNumber].name); + nt->builded = 0; + nt->destroyed = 0; + nt->name = spec->name; + nt->garrison = spec->garrison; + nt->garrisonHero = spec->garnisonHero; + nt->pos = int3(spec->x, spec->y, spec->z); + nt->possibleSpells = spec->possibleSpells; + nt->obligatorySpells = spec->obligatorySpells; + CGI->state->players[spec->player].towns.push_back(nt); break; } case EDefType::PLAYERONLY_DEF: diff --git a/hch/CTownHandler.cpp b/hch/CTownHandler.cpp index fb2b198b0..d6478f8bf 100644 --- a/hch/CTownHandler.cpp +++ b/hch/CTownHandler.cpp @@ -46,4 +46,10 @@ SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded) pom--; return smallIcons->ourImages[pom].bitmap; } -} \ No newline at end of file +} + +int CTownHandler::getTypeByDefName(std::string name) +{ + //TODO + return 0; +} diff --git a/hch/CTownHandler.h b/hch/CTownHandler.h index cdbeaf286..dd494ddf5 100644 --- a/hch/CTownHandler.h +++ b/hch/CTownHandler.h @@ -1,17 +1,24 @@ #ifndef CTOWNHANDLER_H #define CTOWNHANDLER_H + #include "CDefHandler.h" #include "CCreatureHandler.h" #include "SDL.h" #include "../int3.h" #include #include + +class CBuilding; +class CSpell; +class CHero; + class CTown { public: std::string name; int bonus; //pic number }; + class CTownHandler { CDefHandler * smallIcons; @@ -21,9 +28,12 @@ public: std::vector towns; void loadNames(); SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random + static int getTypeByDefName(std::string name); }; + class CTownInstance { +public: int type; //type of town int owner; //ID of owner int3 pos; //position @@ -34,9 +44,13 @@ class CTownInstance int destroyed; //how many buildings has been destroyed this turn //TODO: - //buildings - //creatures to be recruited - //hero in garrison - //spells in mage guild + std::vector allBuildings, possibleBuildings, builtBuildings; + std::vector creatureIncome; //vector by level + std::vector creaturesLeft; //that can be recruited + + CHero * garrisonHero; + + std::vector possibleSpells, obligatorySpells, availableSpells; }; + #endif //CTOWNHANDLER_H \ No newline at end of file