mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Our changes.
Restructured instances classes. Still very instable.
This commit is contained in:
parent
c18e4573f1
commit
4f316cd7e6
@ -13,6 +13,7 @@
|
||||
#include "CMessage.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include "CLua.h"
|
||||
extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
|
||||
|
||||
using namespace boost::logic;
|
||||
@ -176,7 +177,7 @@ void CHeroList::genList()
|
||||
int howMany = LOCPLINT->cb->howManyHeroes();
|
||||
for (int i=0;i<howMany;i++)
|
||||
{
|
||||
items.push_back(std::pair<const CHeroInstance *,CPath *>(LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0),NULL));
|
||||
items.push_back(std::pair<const CGHeroInstance *,CPath *>(LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0),NULL));
|
||||
}
|
||||
}
|
||||
void CHeroList::select(int which)
|
||||
@ -633,7 +634,7 @@ void CMinimap::draw()
|
||||
blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps);
|
||||
|
||||
//draw heroes
|
||||
std::vector <const CHeroInstance *> * hh = LOCPLINT->cb->getHeroesInfo(false);
|
||||
std::vector <const CGHeroInstance *> * hh = LOCPLINT->cb->getHeroesInfo(false);
|
||||
int mw = map[0]->w, mh = map[0]->h,
|
||||
wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
|
||||
for (int i=0; i<hh->size();i++)
|
||||
@ -645,7 +646,7 @@ void CMinimap::draw()
|
||||
{
|
||||
for (int jj=0; jj<ho; jj++)
|
||||
{
|
||||
SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[(*hh)[i]->owner].r,CGI->playerColors[(*hh)[i]->owner].g,CGI->playerColors[(*hh)[i]->owner].b);
|
||||
SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[(*hh)[i]->state->owner].r,CGI->playerColors[(*hh)[i]->state->owner].g,CGI->playerColors[(*hh)[i]->state->owner].b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -816,7 +817,7 @@ void CTerrainRect::clickLeft(tribool down)
|
||||
if ( (currentPath->endPos()) == mp)
|
||||
{ //move
|
||||
CPath sended(*currentPath); //temporary path - engine will operate on it
|
||||
LOCPLINT->cb->moveHero( ((const CHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
||||
LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -824,7 +825,7 @@ void CTerrainRect::clickLeft(tribool down)
|
||||
currentPath=NULL;
|
||||
}
|
||||
}
|
||||
const CHeroInstance * currentHero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first;
|
||||
const CGHeroInstance * currentHero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first;
|
||||
int3 bufpos = currentHero->getPosition(false);
|
||||
//bufpos.x-=1;
|
||||
currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->getPath(bufpos,mp,currentHero,1);
|
||||
@ -1041,7 +1042,7 @@ void CTerrainRect::show()
|
||||
}
|
||||
|
||||
}
|
||||
if ( ((currentPath->nodes[i].dist)-(*(currentPath->nodes.end()-1)).dist) > ((const CHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->movement)
|
||||
if ( ((currentPath->nodes[i].dist)-(*(currentPath->nodes.end()-1)).dist) > ((const CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->movement)
|
||||
pn+=25;
|
||||
if (pn>=0)
|
||||
{
|
||||
@ -1239,7 +1240,7 @@ void CAdvMapInt::fmoveHero()
|
||||
if (!terrain.currentPath)
|
||||
return;
|
||||
CPath sended(*(terrain.currentPath)); //temporary path - engine will operate on it
|
||||
LOCPLINT->cb->moveHero( ((const CHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
||||
LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
||||
}
|
||||
void CAdvMapInt::fshowSpellbok()
|
||||
{
|
||||
|
@ -11,7 +11,8 @@ class CDefHandler;
|
||||
class CCallback;
|
||||
class CTownInstance;
|
||||
class CPath;
|
||||
|
||||
class CGHeroInstance;
|
||||
class CGTownInstance;
|
||||
class AdventureMapButton
|
||||
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
|
||||
{
|
||||
@ -26,7 +27,7 @@ public:
|
||||
void hover (bool on);
|
||||
void keyPressed (SDL_KeyboardEvent & key);
|
||||
void activate(); // makes button active
|
||||
void deactivate(); // makes button inactive (but don't deletes)
|
||||
void deactivate(); // makes button inactive (but doesn't delete)
|
||||
|
||||
AdventureMapButton(); //c-tor
|
||||
AdventureMapButton( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ=false, std::vector<std::string> * add = NULL );//c-tor
|
||||
@ -59,7 +60,7 @@ class CHeroList
|
||||
{
|
||||
public:
|
||||
CDefHandler *mobile, *mana;
|
||||
std::vector<std::pair<const CHeroInstance*, CPath *> > items;
|
||||
std::vector<std::pair<const CGHeroInstance*, CPath *> > items;
|
||||
int posmobx, posporx, posmanx, posmoby, pospory, posmany;
|
||||
|
||||
CHeroList();
|
||||
@ -79,7 +80,7 @@ class CTownList
|
||||
: public CList
|
||||
{
|
||||
public:
|
||||
std::vector<const CTownInstance*> items;
|
||||
std::vector<const CGTownInstance*> items;
|
||||
int posporx,pospory;
|
||||
|
||||
CTownList();
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include "mapHandler.h"
|
||||
#include "CGameState.h"
|
||||
#include "CGameInterface.h"
|
||||
int CCallback::lowestSpeed(CHeroInstance * chi)
|
||||
#include "CLua.h"
|
||||
int CCallback::lowestSpeed(CGHeroInstance * chi)
|
||||
{
|
||||
int min = 150;
|
||||
for ( std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin();
|
||||
@ -19,7 +20,7 @@ int CCallback::lowestSpeed(CHeroInstance * chi)
|
||||
}
|
||||
return min;
|
||||
}
|
||||
int CCallback::valMovePoints(CHeroInstance * chi)
|
||||
int CCallback::valMovePoints(CGHeroInstance * chi)
|
||||
{
|
||||
int ret = 1270+70*lowestSpeed(chi);
|
||||
if (ret>2000)
|
||||
@ -43,7 +44,7 @@ void CCallback::newTurn()
|
||||
}
|
||||
bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
|
||||
{
|
||||
CHeroInstance * hero = NULL;
|
||||
CGHeroInstance * hero = NULL;
|
||||
|
||||
if (idtype==0)
|
||||
{
|
||||
@ -97,8 +98,8 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
|
||||
HeroMoveDetails curd;
|
||||
curd.src = stpos;
|
||||
curd.dst = endpos;
|
||||
curd.ho = hero->ourObject;
|
||||
curd.owner = hero->owner;
|
||||
//curd.ho = hero->ourObject;
|
||||
curd.owner = hero->state->owner;
|
||||
/*if(player!=-1)
|
||||
{
|
||||
hero->pos = endpos;
|
||||
@ -148,10 +149,15 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
|
||||
}
|
||||
++nn;
|
||||
}
|
||||
|
||||
std::vector< CGObjectInstance * > vis = CGI->mh->getVisitableObjs(hero->getPosition(false));
|
||||
for (int iii=0; iii<vis.size(); iii++)
|
||||
std::cout<< CGI->objh->objects[5].name<<std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
return true; //move ended - no more movement points
|
||||
hero->ourObject->pos = curd.dst;
|
||||
hero->pos = curd.dst;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -161,7 +167,7 @@ int CCallback::howManyTowns()
|
||||
{
|
||||
return gs->players[gs->currentPlayer].towns.size();
|
||||
}
|
||||
const CTownInstance * CCallback::getTownInfo(int val, bool mode) //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
const CGTownInstance * CCallback::getTownInfo(int val, bool mode) //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
{
|
||||
if (!mode)
|
||||
return gs->players[gs->currentPlayer].towns[val];
|
||||
@ -183,7 +189,7 @@ int CCallback::howManyHeroes()
|
||||
{
|
||||
return gs->players[player].heroes.size();
|
||||
}
|
||||
const CHeroInstance * CCallback::getHeroInfo(int player, int val, bool mode) //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
const CGHeroInstance * CCallback::getHeroInfo(int player, int val, bool mode) //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
{
|
||||
if (gs->currentPlayer!=player) //TODO: checking if we are allowed to give that info
|
||||
return NULL;
|
||||
@ -283,9 +289,9 @@ bool CCallback::isVisible(int3 pos, int Player)
|
||||
return gs->players[Player].fogOfWarMap[pos.x][pos.y][pos.z];
|
||||
}
|
||||
|
||||
std::vector < const CHeroInstance *> * CCallback::getHeroesInfo(bool onlyOur)
|
||||
std::vector < const CGHeroInstance *> * CCallback::getHeroesInfo(bool onlyOur)
|
||||
{
|
||||
std::vector < const CHeroInstance *> * ret = new std::vector < const CHeroInstance *>();
|
||||
std::vector < const CGHeroInstance *> * ret = new std::vector < const CGHeroInstance *>();
|
||||
for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
|
||||
{
|
||||
for (int j=0;j<(*i).second.heroes.size();j++)
|
||||
|
17
CCallback.h
17
CCallback.h
@ -7,12 +7,12 @@ class CGameState;
|
||||
class CHeroInstance;
|
||||
class CTownInstance;
|
||||
class CPath;
|
||||
class CObjectInstance;
|
||||
class CGObjectInstance;
|
||||
|
||||
struct HeroMoveDetails
|
||||
{
|
||||
int3 src, dst; //source and destination points
|
||||
CObjectInstance * ho; //object instance of this hero
|
||||
CGHeroInstance * ho; //object instance of this hero
|
||||
int owner;
|
||||
};
|
||||
|
||||
@ -22,8 +22,8 @@ private:
|
||||
void newTurn();
|
||||
CCallback(CGameState * GS, int Player):gs(GS),player(Player){};
|
||||
CGameState * gs;
|
||||
int lowestSpeed(CHeroInstance * chi); //speed of the slowest stack
|
||||
int valMovePoints(CHeroInstance * chi);
|
||||
int lowestSpeed(CGHeroInstance * chi); //speed of the slowest stack
|
||||
int valMovePoints(CGHeroInstance * chi);
|
||||
bool isVisible(int3 pos, int Player);
|
||||
|
||||
protected:
|
||||
@ -38,17 +38,20 @@ public:
|
||||
bool verifyPath(CPath * path, bool blockSea);
|
||||
int getDate(int mode=0); //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
|
||||
PseudoV< PseudoV< PseudoV<unsigned char> > > & getVisibilityMap(); //returns visibility map (TODO: make it const)
|
||||
const CHeroInstance * getHeroInfo(int player, int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
const CGHeroInstance * getHeroInfo(int player, int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
int getResourceAmount(int type);
|
||||
int howManyHeroes();
|
||||
const CTownInstance * getTownInfo(int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
const CGTownInstance * getTownInfo(int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
|
||||
int howManyTowns();
|
||||
std::vector < std::string > getObjDescriptions(int3 pos); //returns descriptions of objects at pos in order from the lowest to the highest
|
||||
std::vector < const CHeroInstance *> * getHeroesInfo(bool onlyOur=true);
|
||||
std::vector < const CGHeroInstance *> * getHeroesInfo(bool onlyOur=true);
|
||||
bool isVisible(int3 pos);
|
||||
|
||||
//friends
|
||||
friend int _tmain(int argc, _TCHAR* argv[]);
|
||||
};
|
||||
|
||||
class CLuaCallback
|
||||
{
|
||||
};
|
||||
#endif //CCALLBACK_H
|
@ -46,7 +46,7 @@ int internalFunc(void * callback)
|
||||
case 'M': //move heroa
|
||||
{
|
||||
readed>>heronum>>dest;
|
||||
const CHeroInstance * hero = cb->getHeroInfo(0,heronum,0);
|
||||
const CGHeroInstance * hero = cb->getHeroInfo(0,heronum,0);
|
||||
CPath * path = CGI->pathf->getPath(hero->getPosition(false),dest,hero);
|
||||
cb->moveHero(heronum, path, 0, 0);
|
||||
delete path;
|
||||
|
@ -22,7 +22,7 @@ using namespace CSDL_Ext;
|
||||
class OCM_HLP_CGIN
|
||||
{
|
||||
public:
|
||||
bool operator ()(const std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & a, const std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & b) const
|
||||
bool operator ()(const std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & a, const std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & b) const
|
||||
{
|
||||
return (*a.first)<(*b.first);
|
||||
}
|
||||
@ -289,7 +289,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
{
|
||||
adventureInt->minimap.draw();
|
||||
//initializing objects and performing first step of move
|
||||
CObjectInstance * ho = details.ho; //object representing this hero
|
||||
CGHeroInstance * ho = details.ho; //object representing this hero
|
||||
int3 hp = details.src;
|
||||
|
||||
if (adventureInt->terrain.currentPath) //&& hero is moving
|
||||
@ -843,10 +843,10 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
//move finished
|
||||
adventureInt->heroList.draw();
|
||||
}
|
||||
void CPlayerInterface::heroKilled(const CHeroInstance * hero)
|
||||
void CPlayerInterface::heroKilled(const CGHeroInstance*)
|
||||
{
|
||||
}
|
||||
void CPlayerInterface::heroCreated(const CHeroInstance * hero)
|
||||
void CPlayerInterface::heroCreated(const CGHeroInstance * hero)
|
||||
{
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ SDL_Surface * CPlayerInterface::infoWin(void * specific) //specific=0 => draws i
|
||||
SDL_Surface * ret = copySurface(hInfo);
|
||||
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255));
|
||||
blueToPlayersAdv(ret,playerID,1);
|
||||
const CHeroInstance * curh = (const CHeroInstance *)adventureInt->selection.selected;
|
||||
const CGHeroInstance * curh = (const CGHeroInstance *)adventureInt->selection.selected;
|
||||
printAt(curh->name,75,15,GEOR13,zwykly,ret);
|
||||
for (int i=0;i<PRIMARY_SKILLS;i++)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ class CHeroInstance;
|
||||
class CDefHandler;
|
||||
struct HeroMoveDetails;
|
||||
class CDefEssential;
|
||||
class CGHeroInstance;
|
||||
class CIntObject //interface object
|
||||
{
|
||||
public:
|
||||
@ -93,8 +94,8 @@ public:
|
||||
|
||||
virtual void init(CCallback * CB)=0{};
|
||||
virtual void yourTurn()=0{};
|
||||
virtual void heroKilled(const CHeroInstance * hero)=0{};
|
||||
virtual void heroCreated(const CHeroInstance * hero)=0{};
|
||||
virtual void heroKilled(const CGHeroInstance*)=0{};
|
||||
virtual void heroCreated(const CGHeroInstance*)=0{};
|
||||
|
||||
virtual void heroMoved(const HeroMoveDetails & details)=0;
|
||||
};
|
||||
@ -109,8 +110,8 @@ class CGlobalAI : public CGameInterface // AI class (to derivate)
|
||||
public:
|
||||
//CGlobalAI();
|
||||
virtual void yourTurn(){};
|
||||
virtual void heroKilled(const CHeroInstance * hero){};
|
||||
virtual void heroCreated(const CHeroInstance * hero){};
|
||||
virtual void heroKilled(const CGHeroInstance*){};
|
||||
virtual void heroCreated(const CGHeroInstance*){};
|
||||
};
|
||||
class CPlayerInterface : public CGameInterface
|
||||
{
|
||||
@ -138,8 +139,8 @@ public:
|
||||
//overloaded funcs from Interface
|
||||
void yourTurn();
|
||||
void heroMoved(const HeroMoveDetails & details);
|
||||
void heroKilled(const CHeroInstance * hero);
|
||||
void heroCreated(const CHeroInstance * hero);
|
||||
void heroKilled(const CGHeroInstance*);
|
||||
void heroCreated(const CGHeroInstance*);
|
||||
|
||||
SDL_Surface * infoWin(void * specific); //specific=0 => draws info about selected town/hero //TODO - gdy sie dorobi sensowna hierarchie klas ins. to wywalic tego brzydkiego void*
|
||||
void handleEvent(SDL_Event * sEvent);
|
||||
|
@ -14,8 +14,8 @@ public:
|
||||
//std::vector<std::vector<std::vector<char> > > fogOfWarMap; //true - visible, false - hidden
|
||||
PseudoV< PseudoV< PseudoV<unsigned char> > > fogOfWarMap; //true - visible, false - hidden
|
||||
std::vector<int> resources;
|
||||
std::vector<CHeroInstance *> heroes;
|
||||
std::vector<CTownInstance *> towns;
|
||||
std::vector<CGHeroInstance *> heroes;
|
||||
std::vector<CGTownInstance *> towns;
|
||||
PlayerState():color(-1){};
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include <luabind/function.hpp>
|
||||
#include <luabind/class.hpp>
|
||||
#include "CLuaHandler.h"
|
||||
|
||||
#include "boost/filesystem.hpp"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
void piszpowitanie2(std::string i) //simple global function for testing
|
||||
{
|
||||
std::cout<<"powitanie2zc++. Liczba dnia to " << i;
|
||||
@ -53,4 +54,27 @@ void CLuaHandler::test()
|
||||
}
|
||||
}
|
||||
lua_close (lua);
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> * CLuaHandler::searchForScripts(std::string fol)
|
||||
{
|
||||
std::vector<std::string> * ret = new std::vector<std::string> ();
|
||||
boost::filesystem::path folder(fol);
|
||||
if (!boost::filesystem::exists(folder))
|
||||
throw new std::exception("No such folder!");
|
||||
boost::filesystem::directory_iterator end_itr;
|
||||
for
|
||||
(
|
||||
boost::filesystem::directory_iterator it(folder);
|
||||
it!=end_itr;
|
||||
it++
|
||||
)
|
||||
{
|
||||
if(boost::algorithm::ends_with((it->path().leaf()),".lua"))
|
||||
{
|
||||
ret->push_back(fol+"/"+(it->path().leaf()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
@ -12,6 +12,9 @@ class CLuaHandler
|
||||
{
|
||||
public:
|
||||
CLuaHandler();
|
||||
|
||||
static std::vector<std::string> * searchForScripts(std::string fol);
|
||||
|
||||
~CLuaHandler();
|
||||
|
||||
void test();
|
||||
|
16
CMT.cpp
16
CMT.cpp
@ -44,6 +44,7 @@
|
||||
#include "CGameState.h"
|
||||
#include "CCallback.h"
|
||||
#include "CLuaHandler.h"
|
||||
#include "CLua.h"
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
@ -96,9 +97,9 @@ void initGameState(CGameInfo * cgi)
|
||||
/*************************HEROES************************************************/
|
||||
for (int i=0; i<cgi->heroh->heroInstances.size();i++) //heroes instances
|
||||
{
|
||||
if (!cgi->heroh->heroInstances[i]->type || cgi->heroh->heroInstances[i]->owner<0)
|
||||
if (!cgi->heroh->heroInstances[i]->type || cgi->heroh->heroInstances[i]->state->owner<0)
|
||||
continue;
|
||||
CHeroInstance * vhi = new CHeroInstance();
|
||||
CGHeroInstance * vhi = new CGHeroInstance();
|
||||
*vhi=*(cgi->heroh->heroInstances[i]);
|
||||
if (!vhi->level)
|
||||
{
|
||||
@ -138,7 +139,7 @@ void initGameState(CGameInfo * cgi)
|
||||
vhi->army.slots[2].second = (rand()%(vhi->type->high3stack-vhi->type->low3stack))+vhi->type->low3stack;
|
||||
}
|
||||
|
||||
cgi->state->players[vhi->owner].heroes.push_back(vhi);
|
||||
cgi->state->players[vhi->state->owner].heroes.push_back(vhi);
|
||||
|
||||
}
|
||||
/*************************FOG**OF**WAR******************************************/
|
||||
@ -173,12 +174,12 @@ void initGameState(CGameInfo * cgi)
|
||||
/****************************TOWNS************************************************/
|
||||
for (int i=0;i<cgi->townh->townInstances.size();i++)
|
||||
{
|
||||
CTownInstance * vti = new CTownInstance();
|
||||
CGTownInstance * vti = new CGTownInstance();
|
||||
(*vti)=*(cgi->townh->townInstances[i]);
|
||||
if (vti->name.length()==0) // if town hasn't name we draw it
|
||||
vti->name=vti->town->names[rand()%vti->town->names.size()];
|
||||
|
||||
cgi->state->players[vti->owner].towns.push_back(vti);
|
||||
cgi->state->players[vti->state->owner].towns.push_back(vti);
|
||||
}
|
||||
|
||||
for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
|
||||
@ -203,8 +204,13 @@ void initGameState(CGameInfo * cgi)
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
|
||||
CLuaHandler luatest;
|
||||
luatest.test();
|
||||
CLuaHandler::searchForScripts("scripts");
|
||||
CLua * lua = new CLua("test.lua");
|
||||
|
||||
|
||||
|
||||
//CBIKHandler cb;
|
||||
//cb.open("CSECRET.BIK");
|
||||
|
@ -13,7 +13,7 @@ int3 CPath::endPos()
|
||||
return int3(nodes[0].coord.x,nodes[0].coord.y,nodes[0].coord.z);
|
||||
}
|
||||
|
||||
CPath * CPathfinder::getPath(int3 src, int3 dest, const CHeroInstance * hero, unsigned char type) //TODO: test it (seems to be finished, but relies on unwritten functions :()
|
||||
CPath * CPathfinder::getPath(int3 src, int3 dest, const CGHeroInstance * hero, unsigned char type) //TODO: test it (seems to be finished, but relies on unwritten functions :()
|
||||
{
|
||||
//check input
|
||||
if ((src.x < 0)||(src.y < 0)||(src.z < 0)||(dest.x < 0)||(dest.y < 0)||(dest.z < 0))
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
class CHeroInstance;
|
||||
class CGHeroInstance;
|
||||
struct CPathNode
|
||||
{
|
||||
bool accesible; //true if a hero can be on this node
|
||||
@ -29,7 +30,7 @@ class CPathfinder
|
||||
private:
|
||||
std::vector< std::vector<CPathNode *> > graph;
|
||||
public:
|
||||
CPath * getPath(int3 src, int3 dest, const CHeroInstance * hero, unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero
|
||||
CPath * getPath(int3 src, int3 dest, const CGHeroInstance * hero, unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero
|
||||
CPath * getPath(const int3 & src, const int3 & dest, const CHeroInstance * hero, int (*getDist)(int3 & a, int3 & b), unsigned char type=0); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance; type - type of calculation: 0 - positions are normal positions of hero; 1 - given places are tiles blocked by hero
|
||||
|
||||
static void convertPath(CPath * path, unsigned int mode); //mode=0 -> from 'manifest' to 'object'
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@ public:
|
||||
std::vector<std::string> resDefNames;
|
||||
////
|
||||
void loadDefs();
|
||||
EDefType getDefType(DefInfo& a); //returns type of object in def
|
||||
EDefType getDefType(CGDefInfo * a); //returns type of object in def
|
||||
CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
|
||||
};
|
||||
#endif //CAMBARCENDAMO_H
|
@ -13,7 +13,7 @@ class CHeroClass;
|
||||
class CObjectInstance;
|
||||
class CDefHandler;
|
||||
class CGameInfo;
|
||||
|
||||
class CGHeroInstance;
|
||||
class CHero
|
||||
{
|
||||
public:
|
||||
@ -85,7 +85,7 @@ public:
|
||||
class CHeroHandler
|
||||
{
|
||||
public:
|
||||
std::vector<CHeroInstance *> heroInstances;
|
||||
std::vector<CGHeroInstance *> heroInstances;
|
||||
std::vector<CHero*> heroes; //by³o nodrze
|
||||
std::vector<CHeroClass *> heroClasses;
|
||||
std::vector<CDefHandler *> flags1, flags2, flags3, flags4; //flags blitted on heroes when
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "CAmbarCendamo.h"
|
||||
#include "mapHandler.h"
|
||||
#include "../mapHandler.h"
|
||||
#include "CDefObjInfoHandler.h"
|
||||
|
||||
#include "../CLua.h"
|
||||
void CObjectHandler::loadObjects()
|
||||
{
|
||||
int ID=0;
|
||||
@ -24,42 +24,241 @@ void CObjectHandler::loadObjects()
|
||||
|
||||
bool CObjectInstance::operator <(const CObjectInstance &cmp) const
|
||||
{
|
||||
if(CGI->ac->map.defy[this->defNumber].printPriority==1 && CGI->ac->map.defy[cmp.defNumber].printPriority==0)
|
||||
//if(CGI->ac->map.defy[this->defNumber].printPriority==1 && CGI->ac->map.defy[cmp.defNumber].printPriority==0)
|
||||
// return true;
|
||||
//if(CGI->ac->map.defy[cmp.defNumber].printPriority==1 && CGI->ac->map.defy[this->defNumber].printPriority==0)
|
||||
// return false;
|
||||
//if(this->pos.y<cmp.pos.y)
|
||||
// return true;
|
||||
//if(this->pos.y>cmp.pos.y)
|
||||
// return false;
|
||||
//if(CGI->ac->map.defy[this->defNumber].isOnDefList && !(CGI->ac->map.defy[cmp.defNumber].isOnDefList))
|
||||
// return true;
|
||||
//if(CGI->ac->map.defy[cmp.defNumber].isOnDefList && !(CGI->ac->map.defy[this->defNumber].isOnDefList))
|
||||
// return false;
|
||||
//if(!CGI->ac->map.defy[this->defNumber].isVisitable() && CGI->ac->map.defy[cmp.defNumber].isVisitable())
|
||||
// return true;
|
||||
//if(!CGI->ac->map.defy[cmp.defNumber].isVisitable() && CGI->ac->map.defy[this->defNumber].isVisitable())
|
||||
// return false;
|
||||
//if(this->pos.x<cmp.pos.x)
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CObjectInstance::getWidth() const
|
||||
{
|
||||
return -1;//CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->w/32;
|
||||
}
|
||||
|
||||
int CObjectInstance::getHeight() const
|
||||
{
|
||||
return -1;//CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->h/32;
|
||||
}
|
||||
|
||||
bool CObjectInstance::visitableAt(int x, int y) const
|
||||
{
|
||||
//if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defObjInfoNumber<0)
|
||||
// return false;
|
||||
//if((CGI->dobjinfo->objs[defObjInfoNumber].visitMap[y+6-getHeight()] >> (7-(8-getWidth()+x) )) & 1)
|
||||
// return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CGObjectInstance::isHero() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int CGObjectInstance::getOwner() const
|
||||
{
|
||||
return state->getOwner();
|
||||
}
|
||||
int CGObjectInstance::getWidth() const//returns width of object graphic in tiles
|
||||
{
|
||||
return defInfo->handler->ourImages[0].bitmap->w/32;
|
||||
}
|
||||
int CGObjectInstance::getHeight() const //returns height of object graphic in tiles
|
||||
{
|
||||
return defInfo->handler->ourImages[0].bitmap->h/32;
|
||||
}
|
||||
bool CGObjectInstance::visitableAt(int x, int y) const //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
|
||||
{
|
||||
if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defInfo==NULL)
|
||||
return false;
|
||||
if((defInfo->visitMap[y+6-getHeight()] >> (7-(8-getWidth()+x) )) & 1)
|
||||
return true;
|
||||
if(CGI->ac->map.defy[cmp.defNumber].printPriority==1 && CGI->ac->map.defy[this->defNumber].printPriority==0)
|
||||
return false;
|
||||
}
|
||||
bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen printing priority comparing
|
||||
{
|
||||
if(defInfo->printPriority==1 && defInfo->printPriority==0)
|
||||
return true;
|
||||
if(defInfo->printPriority==1 && defInfo->printPriority==0)
|
||||
return false;
|
||||
if(this->pos.y<cmp.pos.y)
|
||||
return true;
|
||||
if(this->pos.y>cmp.pos.y)
|
||||
return false;
|
||||
if(CGI->ac->map.defy[this->defNumber].isOnDefList && !(CGI->ac->map.defy[cmp.defNumber].isOnDefList))
|
||||
if(defInfo->isOnDefList && !(defInfo->isOnDefList))
|
||||
return true;
|
||||
if(CGI->ac->map.defy[cmp.defNumber].isOnDefList && !(CGI->ac->map.defy[this->defNumber].isOnDefList))
|
||||
if(defInfo->isOnDefList && !(defInfo->isOnDefList))
|
||||
return false;
|
||||
if(!CGI->ac->map.defy[this->defNumber].isVisitable() && CGI->ac->map.defy[cmp.defNumber].isVisitable())
|
||||
if(!defInfo->isVisitable() && defInfo->isVisitable())
|
||||
return true;
|
||||
if(!CGI->ac->map.defy[cmp.defNumber].isVisitable() && CGI->ac->map.defy[this->defNumber].isVisitable())
|
||||
if(!defInfo->isVisitable() && defInfo->isVisitable())
|
||||
return false;
|
||||
if(this->pos.x<cmp.pos.x)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CObjectInstance::getWidth() const
|
||||
{
|
||||
return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->w/32;
|
||||
}
|
||||
|
||||
int CObjectInstance::getHeight() const
|
||||
bool CGDefInfo::isVisitable()
|
||||
{
|
||||
return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->h/32;
|
||||
}
|
||||
|
||||
bool CObjectInstance::visitableAt(int x, int y) const
|
||||
{
|
||||
if(x<0 || y<0 || x>=getWidth() || y>=getHeight())
|
||||
return false;
|
||||
if((CGI->dobjinfo->objs[defObjInfoNumber].visitMap[y] >> (7-x)) & 1)
|
||||
return true;
|
||||
for (int i=6; i<12; i++)
|
||||
{
|
||||
if (bytes[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CGHeroInstance::isHero() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
unsigned int CGHeroInstance::getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype)
|
||||
{
|
||||
unsigned int ret = type->heroClass->terrCosts[ttype];
|
||||
switch(rdtype)
|
||||
{
|
||||
case Eroad::dirtRoad:
|
||||
ret*=0.75;
|
||||
break;
|
||||
case Eroad::grazvelRoad:
|
||||
ret*=0.667;
|
||||
break;
|
||||
case Eroad::cobblestoneRoad:
|
||||
ret*=0.5;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
unsigned int CGHeroInstance::getLowestCreatureSpeed()
|
||||
{
|
||||
unsigned int sl = 100;
|
||||
for(int h=0; h<army.slots.size(); ++h)
|
||||
{
|
||||
if(army.slots[h].first->speed<sl)
|
||||
sl = army.slots[h].first->speed;
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
int3 CGHeroInstance::convertPosition(int3 src, bool toh3m) //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
|
||||
{
|
||||
if (toh3m)
|
||||
{
|
||||
src.x+=1;
|
||||
return src;
|
||||
}
|
||||
else
|
||||
{
|
||||
src.x-=1;
|
||||
return src;
|
||||
}
|
||||
}
|
||||
int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
|
||||
{
|
||||
if (h3m)
|
||||
return pos;
|
||||
else return convertPosition(pos,false);
|
||||
}
|
||||
int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
void CGHeroInstance::setPosition(int3 Pos, bool h3m) //as above, but sets position
|
||||
{
|
||||
if (h3m)
|
||||
pos = Pos;
|
||||
else
|
||||
pos = convertPosition(Pos,true);
|
||||
}
|
||||
|
||||
bool CGHeroInstance::canWalkOnSea() const
|
||||
{
|
||||
//TODO: write it - it should check if hero is flying, or something similiar
|
||||
return false;
|
||||
}
|
||||
int CGHeroInstance::getCurrentLuck() const
|
||||
{
|
||||
//TODO: write it
|
||||
return 0;
|
||||
}
|
||||
int CGHeroInstance::getCurrentMorale() const
|
||||
{
|
||||
//TODO: write it
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CGTownInstance::getSightDistance() const //returns sight distance
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
CGTownInstance::CGTownInstance()
|
||||
{
|
||||
pos = int3(-1,-1,-1);
|
||||
builded=-1;
|
||||
destroyed=-1;
|
||||
garrisonHero=NULL;
|
||||
state->owner=-1;
|
||||
town=NULL;
|
||||
}
|
||||
|
||||
CGObjectInstance::CGObjectInstance()
|
||||
{
|
||||
//std::cout << "Tworze obiekt "<<this<<std::endl;
|
||||
state = new CLuaObjectScript();
|
||||
defObjInfoNumber = -1;
|
||||
}
|
||||
CGObjectInstance::~CGObjectInstance()
|
||||
{
|
||||
//std::cout << "Usuwam obiekt "<<this<<std::endl;
|
||||
if (state)
|
||||
delete state;
|
||||
state=NULL;
|
||||
}
|
||||
|
||||
CGHeroInstance::~CGHeroInstance()
|
||||
{
|
||||
}
|
||||
|
||||
CGTownInstance::~CGTownInstance()
|
||||
{}
|
||||
CGObjectInstance::CGObjectInstance(const CGObjectInstance & right)
|
||||
{
|
||||
pos = right.pos;
|
||||
ID = right.ID;
|
||||
subID = right.subID;
|
||||
id = right.id;
|
||||
defInfo = right.defInfo;
|
||||
info = right.info;
|
||||
defObjInfoNumber = right.defObjInfoNumber;
|
||||
state = new CLuaObjectScript();
|
||||
*state = *right.state;
|
||||
}
|
||||
CGObjectInstance& CGObjectInstance::operator=(const CGObjectInstance & right)
|
||||
{
|
||||
pos = right.pos;
|
||||
ID = right.ID;
|
||||
subID = right.subID;
|
||||
id = right.id;
|
||||
defInfo = right.defInfo;
|
||||
info = right.info;
|
||||
defObjInfoNumber = right.defObjInfoNumber;
|
||||
state = new CLuaObjectScript();
|
||||
*state = *right.state;
|
||||
return *this;
|
||||
}
|
@ -8,7 +8,13 @@
|
||||
#include "CAbilityHandler.h"
|
||||
#include "CSpellHandler.h"
|
||||
#include "CHeroHandler.h"
|
||||
|
||||
class CScript;
|
||||
class CObjectScript;
|
||||
class CGHeroInstance;
|
||||
class CTown;
|
||||
class CHero;
|
||||
class CBuilding;
|
||||
class CSpell;
|
||||
class CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
|
||||
{
|
||||
};
|
||||
@ -60,7 +66,7 @@ public:
|
||||
std::vector<CAbility *> abilities; //hero's abilities
|
||||
std::vector<int> abilityLevels; //hero ability levels
|
||||
bool defaultMainStats; //if true attack, defence, power and knowledge are typical
|
||||
CHeroInstance * myInstance; //pointer to appropriate hero instance
|
||||
CGHeroInstance * myInstance; //pointer to appropriate hero instance
|
||||
};
|
||||
|
||||
class CCreatureObjInfo : public CSpecObjInfo
|
||||
@ -307,11 +313,108 @@ public:
|
||||
bool operator<(const CObjectInstance & cmp) const; //screen printing priority comparing
|
||||
};
|
||||
|
||||
class CGDefInfo
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
int bytes [42];
|
||||
|
||||
unsigned char visitMap[6];
|
||||
unsigned char blockMap[6];
|
||||
//CSemiDefHandler * handler;
|
||||
CDefHandler * handler;
|
||||
int printPriority;
|
||||
bool isOnDefList;
|
||||
bool isVisitable();
|
||||
};
|
||||
|
||||
class CGObjectInstance
|
||||
{
|
||||
public:
|
||||
int3 pos; //h3m pos
|
||||
int ID, subID; //normal ID (this one from OH3 maps ;])
|
||||
int id;//number of object in CObjectHandler's vector
|
||||
CGDefInfo * defInfo;
|
||||
CObjectScript * state;
|
||||
CSpecObjInfo * info;
|
||||
int defObjInfoNumber;
|
||||
|
||||
virtual bool isHero() const;
|
||||
int getOwner() const;
|
||||
int getWidth() const; //returns width of object graphic in tiles
|
||||
int getHeight() const; //returns height of object graphic in tiles
|
||||
bool visitableAt(int x, int y) const; //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
|
||||
bool operator<(const CGObjectInstance & cmp) const; //screen printing priority comparing
|
||||
CGObjectInstance();
|
||||
virtual ~CGObjectInstance();
|
||||
CGObjectInstance(const CGObjectInstance & right);
|
||||
CGObjectInstance& operator=(const CGObjectInstance & right);
|
||||
};
|
||||
|
||||
class CGHeroInstance : public CGObjectInstance
|
||||
{
|
||||
public:
|
||||
int moveDir;
|
||||
|
||||
bool isStanding;
|
||||
bool flagPrinted;
|
||||
CHero * type;
|
||||
int exp; //experience point
|
||||
int level; //current level of hero
|
||||
std::string name; //may be custom
|
||||
std::string biography; //may be custom
|
||||
int portrait; //may be custom
|
||||
CCreatureSet army; //army
|
||||
int mana; // remaining spell points
|
||||
std::vector<int> primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge
|
||||
std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
|
||||
int movement; //remaining movement points
|
||||
bool inTownGarrison; // if hero is in town garrison
|
||||
|
||||
virtual bool isHero() const;
|
||||
unsigned int getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype);
|
||||
unsigned int getLowestCreatureSpeed();
|
||||
unsigned int getAdditiveMoveBonus();
|
||||
unsigned float getMultiplicativeMoveBonus();
|
||||
static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
|
||||
int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
|
||||
int getSightDistance() const; //returns sight distance of this hero
|
||||
void setPosition(int3 Pos, bool h3m); //as above, but sets position
|
||||
|
||||
bool canWalkOnSea() const;
|
||||
int getCurrentLuck() const;
|
||||
int getCurrentMorale() const;
|
||||
virtual ~CGHeroInstance();
|
||||
};
|
||||
|
||||
class CGTownInstance : public CGObjectInstance
|
||||
{
|
||||
public:
|
||||
CTown * town;
|
||||
std::string name; // name of town
|
||||
CCreatureSet garrison;
|
||||
int builded; //how many buildings has been built this turn
|
||||
int destroyed; //how many buildings has been destroyed this turn
|
||||
|
||||
//TODO:
|
||||
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;
|
||||
|
||||
int getSightDistance() const; //returns sight distance
|
||||
CGTownInstance();
|
||||
virtual ~CGTownInstance();
|
||||
};
|
||||
|
||||
class CObjectHandler
|
||||
{
|
||||
public:
|
||||
std::vector<CObject> objects; //vector of objects; i-th object in vector has subnumber i
|
||||
std::vector<CObjectInstance*> objInstances; //vector with objects on map
|
||||
std::vector<CGObjectInstance*> objInstances; //vector with objects on map
|
||||
void loadObjects();
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@ class CBuilding;
|
||||
class CSpell;
|
||||
class CHero;
|
||||
class CTownInstance;
|
||||
|
||||
class CGTownInstance;
|
||||
class CTown
|
||||
{
|
||||
public:
|
||||
@ -33,7 +33,7 @@ public:
|
||||
SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random
|
||||
static int getTypeByDefName(std::string name);
|
||||
|
||||
std::vector<CTownInstance *> townInstances;
|
||||
std::vector<CGTownInstance *> townInstances;
|
||||
|
||||
};
|
||||
|
||||
|
4
map.h
4
map.h
@ -6,7 +6,7 @@
|
||||
#include "global.h"
|
||||
#include "hch\CSemiDefHandler.h"
|
||||
#include "hch\CDefHandler.h"
|
||||
|
||||
class CGDefInfo;
|
||||
enum ESortBy{name,playerAm,size,format, viccon,loscon};
|
||||
struct Sresource
|
||||
{
|
||||
@ -184,7 +184,7 @@ struct Mapa
|
||||
TerrainTile** terrain;
|
||||
TerrainTile** undergroungTerrain; // used only if there is underground level
|
||||
std::vector<Rumor> rumors;
|
||||
std::vector<DefInfo> defy; // list of .def files
|
||||
std::vector<CGDefInfo *> defy; // list of .def files
|
||||
PlayerInfo players[8]; // info about players
|
||||
std::vector<int> teams; // teams[i] = team of player no i
|
||||
LossCondition lossCondition;
|
||||
|
105
mapHandler.cpp
105
mapHandler.cpp
@ -14,7 +14,7 @@ extern SDL_Surface * ekran;
|
||||
class OCM_HLP
|
||||
{
|
||||
public:
|
||||
bool operator ()(const std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & a, const std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & b)
|
||||
bool operator ()(const std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & a, const std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> & b)
|
||||
{
|
||||
return (*a.first)<(*b.first);
|
||||
}
|
||||
@ -404,7 +404,7 @@ void CMapHandler::init()
|
||||
{
|
||||
/*CGI->objh->objInstances[f]->pos.x+=1;
|
||||
CGI->objh->objInstances[f]->pos.y+=1;*/
|
||||
CDefHandler * curd = CGI->ac->map.defy[CGI->objh->objInstances[f]->defNumber].handler;
|
||||
CDefHandler * curd = CGI->objh->objInstances[f]->defInfo->handler;
|
||||
for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
|
||||
{
|
||||
for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
|
||||
@ -414,19 +414,19 @@ void CMapHandler::init()
|
||||
cr.h = 32;
|
||||
cr.x = fx*32;
|
||||
cr.y = fy*32;
|
||||
std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||
std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
||||
if(toAdd.first->defObjInfoNumber>=0 && CGI->dobjinfo->objs[toAdd.first->defObjInfoNumber].isVisitable())
|
||||
{
|
||||
toAdd.second.second.resize(CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size());
|
||||
for(int no = 0; no<CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size(); ++no)
|
||||
toAdd.second.second.resize(toAdd.first->defInfo->handler->ourImages.size());
|
||||
for(int no = 0; no<toAdd.first->defInfo->handler->ourImages.size(); ++no)
|
||||
{
|
||||
bool breakNow = true;
|
||||
for(int dx=0; dx<32; ++dx)
|
||||
{
|
||||
for(int dy=0; dy<32; ++dy)
|
||||
{
|
||||
SDL_Surface * curs = CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages[no].bitmap;
|
||||
SDL_Surface * curs = toAdd.first->defInfo->handler->ourImages[no].bitmap;
|
||||
Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx));
|
||||
Uint8 r, g, b, a;
|
||||
SDL_GetRGBA(*point, curs->format, &r, &g, &b, &a);
|
||||
@ -460,7 +460,7 @@ void CMapHandler::init()
|
||||
{
|
||||
if(CGI->objh->objInstances[f]->defObjInfoNumber == -1)
|
||||
continue;
|
||||
CDefHandler * curd = CGI->ac->map.defy[CGI->objh->objInstances[f]->defNumber].handler;
|
||||
CDefHandler * curd = CGI->objh->objInstances[f]->defInfo->handler;
|
||||
for(int fx=0; fx<8; ++fx)
|
||||
{
|
||||
for(int fy=0; fy<6; ++fy)
|
||||
@ -566,17 +566,18 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
sr.y = (by)*32;
|
||||
|
||||
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second.first;
|
||||
if(ttiles[x+bx][y+by][level].objects[h].first->isHero && ttiles[x+bx][y+by][level].objects[h].first->moveDir && !ttiles[x+bx][y+by][level].objects[h].first->isStanding)
|
||||
CGHeroInstance * themp = (dynamic_cast<CGHeroInstance*>(ttiles[x+bx][y+by][level].objects[h].first));
|
||||
if(themp && themp->moveDir && !themp->isStanding)
|
||||
{
|
||||
int imgVal = 8;
|
||||
SDL_Surface * tb;
|
||||
switch(ttiles[x+bx][y+by][level].objects[h].first->moveDir)
|
||||
switch(themp->moveDir)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if(((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type==NULL)
|
||||
if(((CHeroObjInfo*)themp->info)->myInstance->type==NULL)
|
||||
continue;
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)themp->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
int gg;
|
||||
for(gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
@ -589,7 +590,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
@ -609,7 +610,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
@ -629,7 +630,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
@ -649,7 +650,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
@ -669,7 +670,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 6: //ok
|
||||
@ -689,7 +690,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
@ -709,7 +710,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
@ -729,16 +730,16 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[gg+anim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ttiles[x+bx][y+by][level].objects[h].first->isHero && ttiles[x+bx][y+by][level].objects[h].first->moveDir && ttiles[x+bx][y+by][level].objects[h].first->isStanding)
|
||||
else if(themp && themp->moveDir && themp->isStanding)
|
||||
{
|
||||
int imgVal = 8;
|
||||
SDL_Surface * tb;
|
||||
switch(ttiles[x+bx][y+by][level].objects[h].first->moveDir)
|
||||
switch(themp->moveDir)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
@ -760,8 +761,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[13*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[13*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -785,8 +786,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -810,8 +811,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -835,8 +836,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[2*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[2*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -860,8 +861,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[3*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[3*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -885,8 +886,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[4*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[4*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -910,8 +911,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[15*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[15*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -935,8 +936,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->owner]->ourImages[14*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
ttiles[x+bx][y+by][level].objects[h].first->flagPrinted = true;
|
||||
SDL_BlitSurface(CGI->heroh->flags4[ttiles[x+bx][y+by][level].objects[h].first->getOwner()]->ourImages[14*8+anim%imgVal].bitmap, NULL, su, &bufr);
|
||||
themp->flagPrinted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -944,8 +945,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
else
|
||||
{
|
||||
int imgVal = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages.size();
|
||||
SDL_BlitSurface(CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,&pp,su,&sr);
|
||||
int imgVal = ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages.size();
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[anim%imgVal].bitmap,&pp,su,&sr);
|
||||
}
|
||||
//printing appropriate flag colour
|
||||
if(ttiles[x+bx][y+by][level].objects[h].second.second.size())
|
||||
@ -954,10 +955,10 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
for(std::list<int3>::iterator g=curl.begin(); g!=curl.end(); ++g)
|
||||
{
|
||||
SDL_Color ourC;
|
||||
int own = ttiles[x+bx][y+by][level].objects[h].first->owner;
|
||||
if(ttiles[x+bx][y+by][level].objects[h].first->owner!=255 && ttiles[x+bx][y+by][level].objects[h].first->owner!=254)
|
||||
ourC = CGI->playerColors[ttiles[x+bx][y+by][level].objects[h].first->owner];
|
||||
else if(ttiles[x+bx][y+by][level].objects[h].first->owner==255)
|
||||
int own = ttiles[x+bx][y+by][level].objects[h].first->getOwner();
|
||||
if(ttiles[x+bx][y+by][level].objects[h].first->getOwner()!=255 && ttiles[x+bx][y+by][level].objects[h].first->getOwner()!=254)
|
||||
ourC = CGI->playerColors[ttiles[x+bx][y+by][level].objects[h].first->getOwner()];
|
||||
else if(ttiles[x+bx][y+by][level].objects[h].first->getOwner()==255)
|
||||
ourC = CGI->neutralColor;
|
||||
else continue;
|
||||
CSDL_Ext::SDL_PutPixelWithoutRefresh(su, bx*32 + g->x%32 , by*32 + g->y%32, ourC.r , ourC.g, ourC.b, 0);
|
||||
@ -971,7 +972,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
|
||||
for(int qq=0; qq<CGI->heroh->heroInstances.size(); ++qq)
|
||||
{
|
||||
CGI->heroh->heroInstances[qq]->ourObject->flagPrinted = false;
|
||||
//CGI->heroh->heroInstances[qq]->ourObject->flagPrinted = false;
|
||||
}
|
||||
|
||||
///flags enabled
|
||||
@ -1341,7 +1342,7 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV<
|
||||
// return undVisibility[x+Woff][y+Hoff];
|
||||
//}
|
||||
|
||||
int CMapHandler::getCost(int3 &a, int3 &b, const CHeroInstance *hero)
|
||||
int CMapHandler::getCost(int3 &a, int3 &b, const CGHeroInstance *hero)
|
||||
{
|
||||
int ret = hero->type->heroClass->terrCosts[CGI->mh->ttiles[a.x][a.y][a.z].malle];
|
||||
if(!(a.x==b.x || a.y==b.y))
|
||||
@ -1353,7 +1354,7 @@ int CMapHandler::getCost(int3 &a, int3 &b, const CHeroInstance *hero)
|
||||
|
||||
std::vector < std::string > CMapHandler::getObjDescriptions(int3 pos)
|
||||
{
|
||||
std::vector < std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> > objs = ttiles[pos.x][pos.y][pos.z].objects;
|
||||
std::vector < std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> > objs = ttiles[pos.x][pos.y][pos.z].objects;
|
||||
std::vector<std::string> ret;
|
||||
for(int g=0; g<objs.size(); ++g)
|
||||
{
|
||||
@ -1362,19 +1363,21 @@ std::vector < std::string > CMapHandler::getObjDescriptions(int3 pos)
|
||||
) //checking position blocking
|
||||
{
|
||||
unsigned char * blm = CGI->dobjinfo->objs[objs[g].first->defObjInfoNumber].blockMap;
|
||||
ret.push_back(CGI->objh->objects[CGI->ac->map.defy[objs[g].first->defNumber].bytes[16]].name);
|
||||
ret.push_back(
|
||||
CGI->objh->objects[objs[g].first->defInfo->bytes[16]].name
|
||||
);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector < CObjectInstance * > CMapHandler::getVisitableObjs(int3 pos)
|
||||
std::vector < CGObjectInstance * > CMapHandler::getVisitableObjs(int3 pos)
|
||||
{
|
||||
std::vector < CObjectInstance * > ret;
|
||||
std::vector < CGObjectInstance * > ret;
|
||||
for(int h=0; h<ttiles[pos.x][pos.y][pos.z].objects.size(); ++h)
|
||||
{
|
||||
CObjectInstance * curi = ttiles[pos.x][pos.y][pos.z].objects[h].first;
|
||||
if(curi->visitableAt(curi->pos.x - pos.x, curi->pos.y - pos.y))
|
||||
CGObjectInstance * curi = ttiles[pos.x][pos.y][pos.z].objects[h].first;
|
||||
if(curi->visitableAt(- curi->pos.x + pos.x + curi->getWidth() - 1, -curi->pos.y + pos.y + curi->getHeight() - 1))
|
||||
ret.push_back(curi);
|
||||
}
|
||||
return ret;
|
||||
|
@ -29,8 +29,8 @@ struct TerrainTile2
|
||||
bool visitable; //false = not visitable; true = visitable
|
||||
bool blocked; //false = free; true = blocked;
|
||||
|
||||
std::vector < std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> > objects; //poiters to objects being on this tile with rects to be easier to blit this tile on screen
|
||||
std::vector <CObjectInstance*> visitableObjects; //pointers to objects hero is visiting being on this tile
|
||||
std::vector < std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> > objects; //poiters to objects being on this tile with rects to be easier to blit this tile on screen
|
||||
std::vector <CGObjectInstance*> visitableObjects; //pointers to objects hero is visiting being on this tile
|
||||
|
||||
};
|
||||
|
||||
@ -77,9 +77,9 @@ public:
|
||||
SDL_Surface mirrorImage(SDL_Surface *src); //what is this??
|
||||
SDL_Surface * getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl);
|
||||
|
||||
int getCost(int3 & a, int3 & b, const CHeroInstance * hero);
|
||||
int getCost(int3 & a, int3 & b, const CGHeroInstance * hero);
|
||||
std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position
|
||||
std::vector< CObjectInstance * > getVisitableObjs(int3 pos); //returns vector of visitable objects at certain position
|
||||
std::vector< CGObjectInstance * > getVisitableObjs(int3 pos); //returns vector of visitable objects at certain position
|
||||
void init();
|
||||
SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap = CGI->mh->visibility);
|
||||
SDL_Surface * terrBitmap(int x, int y);
|
||||
|
Loading…
Reference in New Issue
Block a user