1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

initializing town instances in game state

This commit is contained in:
mateuszb 2007-09-05 15:56:35 +00:00
parent 4edc6176dc
commit 88a1809229
5 changed files with 44 additions and 9 deletions

View File

@ -22,6 +22,7 @@ class CGameState
public: public:
friend CCallback; friend CCallback;
friend int _tmain(int argc, _TCHAR* argv[]); friend int _tmain(int argc, _TCHAR* argv[]);
friend void CAmbarCendamo::deh3m();
CCallback * cb; //for communication between PlayerInterface/AI and GameState CCallback * cb; //for communication between PlayerInterface/AI and GameState
}; };

View File

@ -63,9 +63,9 @@ const char * NAME = "VCMI 0.3";
SDL_Surface * ekran, * screen, * screen2; SDL_Surface * ekran, * screen, * screen2;
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM; TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
// #include "lua.h" //#include "lua.h"
// #include "lualib.h" //#include "lualib.h"
// #include "lauxlib.h" //#include "lauxlib.h"
//#include <luabind/luabind.hpp> //#include <luabind/luabind.hpp>
//#include <luabind/function.hpp> //#include <luabind/function.hpp>
//#include <luabind/class.hpp> //#include <luabind/class.hpp>
@ -99,7 +99,7 @@ int _tmain(int argc, _TCHAR* argv[])
// { luabind::open(lua); // { luabind::open(lua);
// luabind::module(lua) // luabind::module(lua)
// [ // [
// luabind::def("powitanie",&piszpowitanie2,NULL) // luabind::def("powitanie",&piszpowitanie2)
// //
// ]; // ];
// //

View File

@ -4,9 +4,11 @@
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "CObjectHandler.h" #include "CObjectHandler.h"
#include "CCastleHandler.h" #include "CCastleHandler.h"
#include "CTownHandler.h"
#include "CDefObjInfoHandler.h" #include "CDefObjInfoHandler.h"
#include "../SDL_Extensions.h" #include "../SDL_Extensions.h"
#include "boost\filesystem.hpp" #include "boost\filesystem.hpp"
#include "CGameState.h"
#include "CLodHandler.h" #include "CLodHandler.h"
#include <set> #include <set>
#include <iomanip> #include <iomanip>
@ -1477,6 +1479,18 @@ void CAmbarCendamo::deh3m()
spec->alignment = 0xff; spec->alignment = 0xff;
i+=3; i+=3;
nobj->info = spec; 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; break;
} }
case EDefType::PLAYERONLY_DEF: case EDefType::PLAYERONLY_DEF:

View File

@ -47,3 +47,9 @@ SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded)
return smallIcons->ourImages[pom].bitmap; return smallIcons->ourImages[pom].bitmap;
} }
} }
int CTownHandler::getTypeByDefName(std::string name)
{
//TODO
return 0;
}

View File

@ -1,17 +1,24 @@
#ifndef CTOWNHANDLER_H #ifndef CTOWNHANDLER_H
#define CTOWNHANDLER_H #define CTOWNHANDLER_H
#include "CDefHandler.h" #include "CDefHandler.h"
#include "CCreatureHandler.h" #include "CCreatureHandler.h"
#include "SDL.h" #include "SDL.h"
#include "../int3.h" #include "../int3.h"
#include <string> #include <string>
#include <vector> #include <vector>
class CBuilding;
class CSpell;
class CHero;
class CTown class CTown
{ {
public: public:
std::string name; std::string name;
int bonus; //pic number int bonus; //pic number
}; };
class CTownHandler class CTownHandler
{ {
CDefHandler * smallIcons; CDefHandler * smallIcons;
@ -21,9 +28,12 @@ public:
std::vector<CTown> towns; std::vector<CTown> towns;
void loadNames(); void loadNames();
SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random 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 class CTownInstance
{ {
public:
int type; //type of town int type; //type of town
int owner; //ID of owner int owner; //ID of owner
int3 pos; //position int3 pos; //position
@ -34,9 +44,13 @@ class CTownInstance
int destroyed; //how many buildings has been destroyed this turn int destroyed; //how many buildings has been destroyed this turn
//TODO: //TODO:
//buildings std::vector<CBuilding *> allBuildings, possibleBuildings, builtBuildings;
//creatures to be recruited std::vector<int> creatureIncome; //vector by level
//hero in garrison std::vector<int> creaturesLeft; //that can be recruited
//spells in mage guild
CHero * garrisonHero;
std::vector<CSpell *> possibleSpells, obligatorySpells, availableSpells;
}; };
#endif //CTOWNHANDLER_H #endif //CTOWNHANDLER_H