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:
friend CCallback;
friend int _tmain(int argc, _TCHAR* argv[]);
friend void CAmbarCendamo::deh3m();
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;
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 <luabind/luabind.hpp>
//#include <luabind/function.hpp>
//#include <luabind/class.hpp>
@ -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)
//
// ];
//

View File

@ -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 <set>
#include <iomanip>
@ -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:

View File

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

View File

@ -1,17 +1,24 @@
#ifndef CTOWNHANDLER_H
#define CTOWNHANDLER_H
#include "CDefHandler.h"
#include "CCreatureHandler.h"
#include "SDL.h"
#include "../int3.h"
#include <string>
#include <vector>
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<CTown> 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<CBuilding *> allBuildings, possibleBuildings, builtBuildings;
std::vector<int> creatureIncome; //vector by level
std::vector<int> creaturesLeft; //that can be recruited
CHero * garrisonHero;
std::vector<CSpell *> possibleSpells, obligatorySpells, availableSpells;
};
#endif //CTOWNHANDLER_H