mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* refactoring of map handler and minor changes
This commit is contained in:
parent
9445e5b184
commit
9aa6d0a7b9
@ -283,8 +283,8 @@ bool CCallback::verifyPath(CPath * path, bool blockSea) const
|
||||
{
|
||||
for (size_t i=0; i < path->nodes.size(); ++i)
|
||||
{
|
||||
if ( CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->blocked
|
||||
&& (! (CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->visitable)))
|
||||
if ( CGI->mh->map->terrain[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].blocked
|
||||
&& (! (CGI->mh->map->terrain[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].visitable)))
|
||||
return false; //path is wrong - one of the tiles is blocked
|
||||
|
||||
if (blockSea)
|
||||
@ -293,15 +293,15 @@ bool CCallback::verifyPath(CPath * path, bool blockSea) const
|
||||
continue;
|
||||
|
||||
if (
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype==TerrainTile::water)
|
||||
((CGI->mh->map->terrain[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tertype==TerrainTile::water)
|
||||
&&
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype!=TerrainTile::water))
|
||||
(CGI->mh->map->terrain[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tertype!=TerrainTile::water))
|
||||
||
|
||||
((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tileInfo->tertype!=TerrainTile::water)
|
||||
((CGI->mh->map->terrain[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].tertype!=TerrainTile::water)
|
||||
&&
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==TerrainTile::water))
|
||||
(CGI->mh->map->terrain[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tertype==TerrainTile::water))
|
||||
||
|
||||
(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tileInfo->tertype==TerrainTile::rock)
|
||||
(CGI->mh->map->terrain[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].tertype==TerrainTile::rock)
|
||||
|
||||
)
|
||||
return false;
|
||||
|
@ -17,29 +17,21 @@ class CMapHandler;
|
||||
class CArtHandler;
|
||||
class CHeroHandler;
|
||||
class CCreatureHandler;
|
||||
class CAbilityHandler;
|
||||
class CSpellHandler;
|
||||
class CAmbarCendamo;
|
||||
class CPreGameTextHandler;
|
||||
class CBuildingHandler;
|
||||
class CObjectHandler;
|
||||
class CSoundHandler;
|
||||
class CMusicHandler;
|
||||
class CDefObjInfoHandler;
|
||||
class CTownHandler;
|
||||
class CLodHandler;
|
||||
class CGeneralTextHandler;
|
||||
class CConsoleHandler;
|
||||
class CPathfinder;
|
||||
class CCursorHandler;
|
||||
class CScreenHandler;
|
||||
class CGameState;
|
||||
class CMapHandler;
|
||||
class CGameInterface;
|
||||
class CPreGame;
|
||||
class CDefHandler;
|
||||
class CVideoPlayer;
|
||||
|
||||
class Mapa;
|
||||
|
||||
/*
|
||||
CGameInfo class
|
||||
for allowing different functions for accessing game informations
|
||||
@ -62,13 +54,12 @@ public:
|
||||
/*const*/ CGeneralTextHandler * generaltexth;
|
||||
CConsoleHandler * consoleh;
|
||||
CCursorHandler * curh;
|
||||
/*const*/ CScreenHandler * screenh;
|
||||
CVideoPlayer * videoh;
|
||||
|
||||
void setFromLib();
|
||||
|
||||
friend class CClient;
|
||||
friend class CMapHandler; //TODO: remove it
|
||||
friend void initVillagesCapitols(Mapa * map);
|
||||
|
||||
CGameInfo();
|
||||
};
|
||||
|
@ -206,7 +206,7 @@ void CPlayerInterface::yourTurn()
|
||||
acceptTurn();
|
||||
}
|
||||
|
||||
inline void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const int & hid)
|
||||
STRONG_INLINE void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const int & hid)
|
||||
{
|
||||
TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
|
||||
for(int h=0; h<hlp.objects.size(); ++h)
|
||||
@ -217,7 +217,7 @@ inline void subRect(const int & x, const int & y, const int & z, const SDL_Rect
|
||||
}
|
||||
}
|
||||
|
||||
inline void delObjRect(const int & x, const int & y, const int & z, const int & hid)
|
||||
STRONG_INLINE void delObjRect(const int & x, const int & y, const int & z, const int & hid)
|
||||
{
|
||||
TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
|
||||
for(int h=0; h<hlp.objects.size(); ++h)
|
||||
@ -392,10 +392,10 @@ int3 CPlayerInterface::repairScreenPos(int3 pos)
|
||||
pos.x = -CGI->mh->frameW;
|
||||
if(pos.y<-CGI->mh->frameH)
|
||||
pos.y = -CGI->mh->frameH;
|
||||
if(pos.x>CGI->mh->map->width - adventureInt->terrain.tilesw + CGI->mh->frameW)
|
||||
pos.x = CGI->mh->map->width - adventureInt->terrain.tilesw + CGI->mh->frameW;
|
||||
if(pos.y>CGI->mh->map->height - adventureInt->terrain.tilesh + CGI->mh->frameH)
|
||||
pos.y = CGI->mh->map->height - adventureInt->terrain.tilesh + CGI->mh->frameH;
|
||||
if(pos.x>CGI->mh->sizes.x - adventureInt->terrain.tilesw + CGI->mh->frameW)
|
||||
pos.x = CGI->mh->sizes.x - adventureInt->terrain.tilesw + CGI->mh->frameW;
|
||||
if(pos.y>CGI->mh->sizes.y - adventureInt->terrain.tilesh + CGI->mh->frameH)
|
||||
pos.y = CGI->mh->sizes.y - adventureInt->terrain.tilesh + CGI->mh->frameH;
|
||||
return pos;
|
||||
}
|
||||
void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val)
|
||||
|
@ -191,6 +191,31 @@ void CClient::save(const std::string & fname)
|
||||
*serv << &SaveGame(fname);
|
||||
}
|
||||
|
||||
#include <fstream>
|
||||
void initVillagesCapitols(Mapa * map)
|
||||
{
|
||||
std::ifstream ifs(DATA_DIR "/config/townsDefs.txt");
|
||||
int ccc;
|
||||
ifs>>ccc;
|
||||
for(int i=0;i<ccc*2;i++)
|
||||
{
|
||||
CGDefInfo *n;
|
||||
if(i<ccc)
|
||||
{
|
||||
n = CGI->state->villages[i];
|
||||
map->defy.push_back(CGI->state->forts[i]);
|
||||
}
|
||||
else
|
||||
n = CGI->state->capitols[i%ccc];
|
||||
|
||||
ifs >> n->name;
|
||||
if(!n)
|
||||
tlog1 << "*HUGE* Warning - missing town def for " << i << std::endl;
|
||||
else
|
||||
map->defy.push_back(n);
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::endGame()
|
||||
{
|
||||
tlog0 << "\n\nEnding current game!" << std::endl;
|
||||
@ -274,6 +299,8 @@ void CClient::loadGame( const std::string & fname )
|
||||
CGI->mh->map = gs->map;
|
||||
pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1));
|
||||
CGI->mh->init();
|
||||
initVillagesCapitols(gs->map);
|
||||
|
||||
tlog0 <<"Initing maphandler: "<<tmh.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
@ -391,6 +418,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
CGI->mh->map = gs->map;
|
||||
tlog0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
|
||||
CGI->mh->init();
|
||||
initVillagesCapitols(gs->map);
|
||||
pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1));
|
||||
tlog0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
|
||||
|
||||
|
@ -59,6 +59,9 @@ public:
|
||||
CDefEssential * flags;
|
||||
std::vector<CDefEssential *> heroAnims; // [class id: 0 - 17] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
||||
std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
|
||||
std::map<std::string, CDefEssential*> mapObjectDefs; //pointers to loaded defs (key is filename, uppercase)
|
||||
CDefHandler * FoWfullHide; //for Fog of War
|
||||
CDefHandler * FoWpartialHide; //for For of War
|
||||
//creatures
|
||||
std::map<int,SDL_Surface*> smallImgs; //creature ID -> small 32x32 img of creature; //ID=-2 is for blank (black) img; -1 for the border
|
||||
std::map<int,SDL_Surface*> bigImgs; //creature ID -> big 58x64 img of creature; //ID=-2 is for blank (black) img; -1 for the border
|
||||
|
@ -84,51 +84,51 @@ struct OCM_HLP
|
||||
}
|
||||
} ocmptwo ;
|
||||
|
||||
void alphaTransformDef(CGDefInfo * defInfo)
|
||||
{
|
||||
for(int yy=0; yy<defInfo->handler->ourImages.size(); ++yy)
|
||||
{
|
||||
CSDL_Ext::alphaTransform(defInfo->handler->ourImages[yy].bitmap);
|
||||
}
|
||||
}
|
||||
// void alphaTransformDef(CGDefInfo * defInfo)
|
||||
// {
|
||||
// for(int yy=0; yy<defInfo->handler->ourImages.size(); ++yy)
|
||||
// {
|
||||
// CSDL_Ext::alphaTransform(defInfo->handler->ourImages[yy].bitmap);
|
||||
// }
|
||||
// }
|
||||
|
||||
void CMapHandler::prepareFOWDefs()
|
||||
{
|
||||
fullHide = CDefHandler::giveDef("TSHRC.DEF");
|
||||
partialHide = CDefHandler::giveDef("TSHRE.DEF");
|
||||
graphics->FoWfullHide = CDefHandler::giveDef("TSHRC.DEF");
|
||||
graphics->FoWpartialHide = CDefHandler::giveDef("TSHRE.DEF");
|
||||
|
||||
//adding necessary rotations
|
||||
int missRot [] = {22, 15, 2, 13, 12, 16, 18, 17, 20, 19, 7, 24, 26, 25, 30, 32, 27, 28};
|
||||
static const int missRot [] = {22, 15, 2, 13, 12, 16, 18, 17, 20, 19, 7, 24, 26, 25, 30, 32, 27, 28};
|
||||
|
||||
Cimage nw;
|
||||
for(int g=0; g<ARRAY_COUNT(missRot); ++g)
|
||||
{
|
||||
nw = partialHide->ourImages[missRot[g]];
|
||||
nw = graphics->FoWpartialHide->ourImages[missRot[g]];
|
||||
nw.bitmap = CSDL_Ext::rotate01(nw.bitmap);
|
||||
partialHide->ourImages.push_back(nw);
|
||||
graphics->FoWpartialHide->ourImages.push_back(nw);
|
||||
}
|
||||
//necessaary rotations added
|
||||
|
||||
//alpha - transformation
|
||||
for(size_t i=0; i<partialHide->ourImages.size(); ++i)
|
||||
for(size_t i=0; i<graphics->FoWpartialHide->ourImages.size(); ++i)
|
||||
{
|
||||
CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap);
|
||||
CSDL_Ext::alphaTransform(graphics->FoWpartialHide->ourImages[i].bitmap);
|
||||
}
|
||||
|
||||
//initialization of type of full-hide image
|
||||
hideBitmap.resize(CGI->mh->map->width);
|
||||
hideBitmap.resize(sizes.x);
|
||||
for (size_t i=0;i<hideBitmap.size();i++)
|
||||
{
|
||||
hideBitmap[i].resize(CGI->mh->map->height);
|
||||
hideBitmap[i].resize(sizes.y);
|
||||
}
|
||||
for (size_t i=0; i<hideBitmap.size(); ++i)
|
||||
{
|
||||
for (int j=0; j < CGI->mh->map->height; ++j)
|
||||
for (int j=0; j < sizes.y; ++j)
|
||||
{
|
||||
hideBitmap[i][j].resize(CGI->mh->map->twoLevel+1);
|
||||
for(int k=0; k<CGI->mh->map->twoLevel+1; ++k)
|
||||
hideBitmap[i][j].resize(sizes.z);
|
||||
for(int k=0; k<sizes.z; ++k)
|
||||
{
|
||||
hideBitmap[i][j][k] = rand()%fullHide->ourImages.size();
|
||||
hideBitmap[i][j][k] = rand()%graphics->FoWfullHide->ourImages.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,32 +160,26 @@ void CMapHandler::roadsRiverTerrainInit()
|
||||
}
|
||||
}
|
||||
|
||||
sizes.x = CGI->mh->map->width;
|
||||
sizes.y = CGI->mh->map->height;
|
||||
sizes.z = CGI->mh->map->twoLevel+1;
|
||||
|
||||
// Create enough room for the whole map and its frame
|
||||
ttiles.resize(CGI->mh->map->width, frameW, frameW);
|
||||
ttiles.resize(sizes.x, frameW, frameW);
|
||||
for (int i=0-frameW;i<ttiles.size()-frameW;i++)
|
||||
{
|
||||
ttiles[i].resize(CGI->mh->map->height, frameH, frameH);
|
||||
ttiles[i].resize(sizes.y, frameH, frameH);
|
||||
}
|
||||
for (int i=0-frameW;i<ttiles.size()-frameW;i++)
|
||||
{
|
||||
for (int j=0-frameH;j<(int)CGI->mh->map->height+frameH;j++)
|
||||
ttiles[i][j].resize(CGI->mh->map->twoLevel+1, 0, 0);
|
||||
for (int j=0-frameH;j<(int)sizes.y+frameH;j++)
|
||||
ttiles[i][j].resize(sizes.z, 0, 0);
|
||||
}
|
||||
|
||||
// prepare the map
|
||||
for (int i=0; i<map->width; i++) //by width
|
||||
for (int i=0; i<sizes.x; i++) //by width
|
||||
{
|
||||
for (int j=0; j<map->height;j++) //by height
|
||||
for (int j=0; j<sizes.y;j++) //by height
|
||||
{
|
||||
for (int k=0; k<=map->twoLevel; ++k) //by levels
|
||||
for (int k=0; k<sizes.z; ++k) //by levels
|
||||
{
|
||||
TerrainTile2 &pom(ttiles[i][j][k]);
|
||||
pom.pos = int3(i, j, k);
|
||||
pom.tileInfo = &(map->terrain[i][j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,31 +199,31 @@ void CMapHandler::borderAndTerrainBitmapInit()
|
||||
delete hlp;
|
||||
}
|
||||
|
||||
for (int i=0-frameW; i<map->width+frameW; i++) //by width
|
||||
for (int i=0-frameW; i<sizes.x+frameW; i++) //by width
|
||||
{
|
||||
for (int j=0-frameH; j<map->height+frameH;j++) //by height
|
||||
for (int j=0-frameH; j<sizes.y+frameH;j++) //by height
|
||||
{
|
||||
for(int k=0; k<=map->twoLevel; ++k) //by levles
|
||||
for(int k=0; k<sizes.z; ++k) //by levles
|
||||
{
|
||||
if(i < 0 || i > (map->width-1) || j < 0 || j > (map->height-1))
|
||||
if(i < 0 || i > (sizes.x-1) || j < 0 || j > (sizes.y-1))
|
||||
{
|
||||
int terBitmapNum = -1;
|
||||
|
||||
if(i==-1 && j==-1)
|
||||
terBitmapNum = 16;
|
||||
else if(i==-1 && j==(map->height))
|
||||
else if(i==-1 && j==(sizes.y))
|
||||
terBitmapNum = 19;
|
||||
else if(i==(map->width) && j==-1)
|
||||
else if(i==(sizes.x) && j==-1)
|
||||
terBitmapNum = 17;
|
||||
else if(i==(map->width) && j==(map->height))
|
||||
else if(i==(sizes.x) && j==(sizes.y))
|
||||
terBitmapNum = 18;
|
||||
else if(j == -1 && i > -1 && i < map->height)
|
||||
else if(j == -1 && i > -1 && i < sizes.y)
|
||||
terBitmapNum = 22+rand()%2;
|
||||
else if(i == -1 && j > -1 && j < map->height)
|
||||
else if(i == -1 && j > -1 && j < sizes.y)
|
||||
terBitmapNum = 33+rand()%2;
|
||||
else if(j == map->height && i >-1 && i < map->width)
|
||||
else if(j == sizes.y && i >-1 && i < sizes.x)
|
||||
terBitmapNum = 29+rand()%2;
|
||||
else if(i == map->width && j > -1 && j < map->height)
|
||||
else if(i == sizes.x && j > -1 && j < sizes.y)
|
||||
terBitmapNum = 25+rand()%2;
|
||||
else
|
||||
terBitmapNum = rand()%16;
|
||||
@ -309,13 +303,13 @@ static void processDef (CGDefInfo* def)
|
||||
{
|
||||
if(def->name.size())
|
||||
{
|
||||
if(vstd::contains(CGI->mh->loadedDefs, def->name))
|
||||
if(vstd::contains(graphics->mapObjectDefs, def->name))
|
||||
{
|
||||
def->handler = CGI->mh->loadedDefs[def->name];
|
||||
def->handler = graphics->mapObjectDefs[def->name];
|
||||
}
|
||||
else
|
||||
{
|
||||
CGI->mh->loadedDefs[def->name] = def->handler = CDefHandler::giveDefEss(def->name);
|
||||
graphics->mapObjectDefs[def->name] = def->handler = CDefHandler::giveDefEss(def->name);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -361,8 +355,13 @@ void CMapHandler::init()
|
||||
CGI->dobjinfo->gobjs[8][2]->handler = graphics->boatAnims[2];
|
||||
|
||||
// Size of visible terrain.
|
||||
mapW = conf.go()->ac.advmapW;
|
||||
mapH = conf.go()->ac.advmapH;
|
||||
int mapW = conf.go()->ac.advmapW;
|
||||
int mapH = conf.go()->ac.advmapH;
|
||||
|
||||
//sizes of terrain
|
||||
sizes.x = map->width;
|
||||
sizes.y = map->height;
|
||||
sizes.z = map->twoLevel+1;
|
||||
|
||||
// Total number of visible tiles. Substract the center tile, then
|
||||
// compute the number of tiles on each side, and reassemble.
|
||||
@ -384,28 +383,6 @@ void CMapHandler::init()
|
||||
offsetX = (mapW - (2*frameW+1)*32)/2;
|
||||
offsetY = (mapH - (2*frameH+1)*32)/2;
|
||||
|
||||
std::ifstream ifs(DATA_DIR "/config/townsDefs.txt");
|
||||
int ccc;
|
||||
ifs>>ccc;
|
||||
for(int i=0;i<ccc*2;i++)
|
||||
{
|
||||
CGDefInfo *n;
|
||||
if(i<ccc)
|
||||
{
|
||||
n = CGI->state->villages[i];
|
||||
map->defy.push_back(CGI->state->forts[i]);
|
||||
}
|
||||
else
|
||||
n = CGI->state->capitols[i%ccc];
|
||||
|
||||
ifs >> n->name;
|
||||
if(!n)
|
||||
tlog1 << "*HUGE* Warning - missing town def for " << i << std::endl;
|
||||
else
|
||||
map->defy.push_back(n);
|
||||
}
|
||||
tlog0<<"\tLoading town def info: "<<th.getDif()<<std::endl;
|
||||
|
||||
for(int i=0;i<map->heroes.size();i++)
|
||||
{
|
||||
if(!map->heroes[i]->defInfo->handler)
|
||||
@ -417,14 +394,15 @@ void CMapHandler::init()
|
||||
std::for_each(map->defy.begin(),map->defy.end(),processDef); //load h3m defs
|
||||
tlog0<<"\tUnpacking and handling defs: "<<th.getDif()<<std::endl;
|
||||
|
||||
for(int i=0;i<PLAYER_LIMIT;i++)
|
||||
{
|
||||
for(size_t j=0; j < map->players[i].heroesNames.size(); ++j)
|
||||
{
|
||||
usedHeroes.insert(map->players[i].heroesNames[j].heroID);
|
||||
}
|
||||
}
|
||||
tlog0<<"\tChecking used heroes: "<<th.getDif()<<std::endl;
|
||||
//it seems to be completely unnecessary and useless
|
||||
// for(int i=0;i<PLAYER_LIMIT;i++)
|
||||
// {
|
||||
// for(size_t j=0; j < map->players[i].heroesNames.size(); ++j)
|
||||
// {
|
||||
// usedHeroes.insert(map->players[i].heroesNames[j].heroID);
|
||||
// }
|
||||
// }
|
||||
// tlog0<<"\tChecking used heroes: "<<th.getDif()<<std::endl;
|
||||
|
||||
|
||||
|
||||
@ -488,10 +466,10 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
top_tile.x = -frameW;
|
||||
if (top_tile.y < -frameH)
|
||||
top_tile.y = -frameH;
|
||||
if (top_tile.x + dx > map->width + frameW)
|
||||
dx = map->width + frameW - top_tile.x;
|
||||
if (top_tile.y + dy > map->height + frameH)
|
||||
dy = map->height + frameH - top_tile.y;
|
||||
if (top_tile.x + dx > sizes.x + frameW)
|
||||
dx = sizes.x + frameW - top_tile.x;
|
||||
if (top_tile.y + dy > sizes.y + frameH)
|
||||
dy = sizes.y + frameH - top_tile.y;
|
||||
|
||||
if(!otherHeroAnim)
|
||||
heroAnim = anim; //the same, as it should be
|
||||
@ -510,7 +488,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
for (int bx = 0; bx < dx; bx++, srx+=32)
|
||||
{
|
||||
// Skip column if not in map
|
||||
if (top_tile.x+bx < 0 || top_tile.x+bx >= map->width)
|
||||
if (top_tile.x+bx < 0 || top_tile.x+bx >= sizes.x)
|
||||
continue;
|
||||
|
||||
sry = sry_init;
|
||||
@ -520,11 +498,11 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
int3 pos(top_tile.x+bx, top_tile.y+by, top_tile.z); //blitted tile position
|
||||
|
||||
// Skip tile if not in map
|
||||
if (pos.y < 0 || pos.y >= map->height)
|
||||
if (pos.y < 0 || pos.y >= sizes.y)
|
||||
continue;
|
||||
|
||||
const TerrainTile2 & tile = ttiles[pos.x][pos.y][pos.z];
|
||||
const TerrainTile &tinfo = *tile.tileInfo;
|
||||
const TerrainTile &tinfo = map->terrain[pos.x][pos.y][pos.z];
|
||||
|
||||
SDL_Rect sr;
|
||||
sr.x=srx;
|
||||
@ -691,8 +669,8 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
sr.y=sry;
|
||||
sr.h=sr.w=32;
|
||||
|
||||
if (pos.x < 0 || pos.x >= map->width ||
|
||||
pos.y < 0 || pos.y >= map->height)
|
||||
if (pos.x < 0 || pos.x >= sizes.x ||
|
||||
pos.y < 0 || pos.y >= sizes.y)
|
||||
{
|
||||
|
||||
|
||||
@ -706,11 +684,11 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
{
|
||||
if (pos.x >= 0 &&
|
||||
pos.y >= 0 &&
|
||||
pos.x < CGI->mh->map->width &&
|
||||
pos.y < CGI->mh->map->height &&
|
||||
pos.x < sizes.x &&
|
||||
pos.y < sizes.y &&
|
||||
!(*visibilityMap)[pos.x][pos.y][top_tile.z])
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(pos.x, pos.y, *visibilityMap, top_tile.z);
|
||||
SDL_Surface * hide = getVisBitmap(pos, *visibilityMap);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(hide, &rtile, extSurf, &sr);
|
||||
}
|
||||
}
|
||||
@ -719,7 +697,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
|
||||
// TODO: these should be activable by the console
|
||||
#ifdef MARK_BLOCKED_POSITIONS
|
||||
if(ttiles[pos.x][pos.y][top_tile.z].tileInfo->blocked) //temporary hiding blocked positions
|
||||
if(map->terrain[pos.x][pos.y][top_tile.z].blocked) //temporary hiding blocked positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
|
||||
@ -732,7 +710,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
}
|
||||
#endif
|
||||
#ifdef MARK_VISITABLE_POSITIONS
|
||||
if(ttiles[pos.x][pos.y][top_tile.z].tileInfo->visitable) //temporary hiding visitable positions
|
||||
if(map->terrain[pos.x][pos.y][top_tile.z].visitable) //temporary hiding visitable positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
|
||||
@ -851,232 +829,45 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, const std::vect
|
||||
SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect
|
||||
}
|
||||
|
||||
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl)
|
||||
SDL_Surface * CMapHandler::getVisBitmap( const int3 & pos, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap )
|
||||
{
|
||||
int size = visibilityMap.size()-1; //is tile visible. arrangement: (like num keyboard)
|
||||
bool d7 = (x>0 && y>0) ? visibilityMap[x-1][y-1][lvl] : 0, //789
|
||||
d8 = (y>0) ? visibilityMap[x][y-1][lvl] : 0, //456
|
||||
d9 = (y>0 && x<size) ? visibilityMap[x+1][y-1][lvl] : 0,//123
|
||||
d4 = (x>0) ? visibilityMap[x-1][y][lvl] : 0,
|
||||
d5 = visibilityMap[x][y][lvl], //TODO use me - OMFG
|
||||
d6 = (x<size) ? visibilityMap[x+1][y][lvl] : 0,
|
||||
d1 = (x>0 && y<size) ? visibilityMap[x-1][y+1][lvl] : 0,
|
||||
d2 = (y<size) ? visibilityMap[x][y+1][lvl] : 0,
|
||||
d3 = (x<size && y<size) ? visibilityMap[x+1][y+1][lvl] : 0;
|
||||
static const int visBitmaps[256] = {-1, 34, -1, 4, 22, 22, 4, 4, 36, 36, 38, 38, 47, 47, 38, 38, 3, 25, 12, 12, 3, 25, 12, 12,
|
||||
9, 9, 6, 6, 9, 9, 6, 6, 35, 34, 4, 4, 22, 22, 4, 4, 36, 36, 38, 38, 47, 47, 38, 38, 26, 49, 28, 28, 26, 49, 28,
|
||||
28, 9, 9, 6, 6, 9, 9, 6, 6, -3, 0, -3, 4, 0, 0, 4, 4, 37, 37, 7, 7, 50, 50, 7, 7, 13, 27, 44, 44, 13, 27, 44,
|
||||
44, 8,8, 10, 10, 8, 8, 10, 10, 0, 0, 4, 4, 0, 0, 4, 4, 37, 37, 7, 7, 50, 50, 7, 7, 13, 27, 44, 44, 13, 27, 44,
|
||||
44, 8, 8, 10, 10, 8, 8, 10, 10, 15, 15, 4, 4, 22, 22, 4, 4, 46, 46, 51, 51, 32, 32, 51, 51, 2, 25, 12, 12, 2,
|
||||
25, 12, 12, 9, 9, 6, 6, 9, 9, 6, 6, 15, 15, 4, 4, 22, 22, 4, 4, 46, 46, 51, 51, 32, 32, 51, 51, 26, 49, 28, 28,
|
||||
26, 49, 28, 28, 9, 9, 6, 6, 9, 9, 6, 6, 0, 0, 4, 4, 0, 0, 4, 4, 37, 37, 7, 7, 50, 50, 7, 7, 13, 27, 44, 44, 13,
|
||||
27, 44, 44, 8, 8, 10, 10, 8, 8, 10, 10, 0, 0, 4, 4, 0, 0, 4, 4, 37, 37, 7, 7, 50, 50, 7, 7, 13, 27, 44, 44, 13,
|
||||
27, 44, 44, 8, 8, 10, 10, 8, 8, 10, 10};
|
||||
|
||||
if (!d6 && !d4)
|
||||
|
||||
//is tile visible. arrangement: (like num keyboard)
|
||||
bool d7 = (pos.x>0 && pos.y>0) ? visibilityMap[pos.x-1][pos.y-1][pos.z] : 0, //789
|
||||
d8 = (pos.y>0) ? visibilityMap[pos.x][pos.y-1][pos.z] : 0, //456
|
||||
d9 = (pos.y>0 && pos.x<sizes.x) ? visibilityMap[pos.x+1][pos.y-1][pos.z] : 0, //123
|
||||
d4 = (pos.x>0) ? visibilityMap[pos.x-1][pos.y][pos.z] : 0,
|
||||
//d5 = visibilityMap[pos.x][y][pos.z], //TODO use me - OMFG
|
||||
d6 = (pos.x<sizes.x) ? visibilityMap[pos.x+1][pos.y][pos.z] : 0,
|
||||
d1 = (pos.x>0 && pos.y<sizes.y) ? visibilityMap[pos.x-1][pos.y+1][pos.z] : 0,
|
||||
d2 = (pos.y<sizes.y) ? visibilityMap[pos.x][pos.y+1][pos.z] : 0,
|
||||
d3 = (pos.x<sizes.x && pos.y<sizes.y) ? visibilityMap[pos.x+1][pos.y+1][pos.z] : 0;
|
||||
|
||||
int retBitmapID = visBitmaps[d1 + d2 * 2 + d3 * 4 + d4 * 8 + d6 * 16 + d7 * 32 + d8 * 64 + d9 * 128]; // >=0 -> partial hide, <0 - full hide
|
||||
if (retBitmapID < 0)
|
||||
{
|
||||
if (!d3 && !d9 && !d1 && !d7)
|
||||
return fullHide->ourImages[hideBitmap[x][y][lvl]].bitmap; //fully hidden
|
||||
if(d2)
|
||||
return partialHide->ourImages[4].bitmap; //visble bottom
|
||||
else if (d8)
|
||||
return partialHide->ourImages[0].bitmap; //visible top
|
||||
else if (d3)
|
||||
return partialHide->ourImages[22].bitmap; //visible right bottom corner
|
||||
else if (d9)
|
||||
return partialHide->ourImages[15].bitmap; //visible right top corner
|
||||
else if (d1)
|
||||
return partialHide->ourImages[34].bitmap; //visible left bottom corner
|
||||
else if (d7)
|
||||
return partialHide->ourImages[35].bitmap; //visible left top corner
|
||||
if (!d2 && !d8)
|
||||
{
|
||||
if (d1)
|
||||
{
|
||||
if (d3)
|
||||
{
|
||||
if (d7)
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[21].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[43].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[19].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[40].bitmap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d7)
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[42].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[39].bitmap;
|
||||
}
|
||||
else
|
||||
return partialHide->ourImages[17].bitmap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!d3)
|
||||
return partialHide->ourImages[18].bitmap;
|
||||
else if(!d7)
|
||||
return partialHide->ourImages[16].bitmap; //visible right corner
|
||||
else if(!d9)
|
||||
return partialHide->ourImages[41].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[20].bitmap;
|
||||
}
|
||||
}
|
||||
if (d2)
|
||||
{
|
||||
if(d8)
|
||||
return partialHide->ourImages[29].bitmap;
|
||||
else if(d3)
|
||||
return partialHide->ourImages[1].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[5].bitmap;
|
||||
}
|
||||
else if (d7)
|
||||
return partialHide->ourImages[4].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[9].bitmap;
|
||||
retBitmapID = - hideBitmap[pos.x][pos.y][pos.z] - 1; //fully hidden
|
||||
}
|
||||
else //(d4 && d6 != 0)
|
||||
|
||||
|
||||
if (retBitmapID >= 0)
|
||||
{
|
||||
if (d2)
|
||||
{
|
||||
if (d4)
|
||||
{
|
||||
if (d6)
|
||||
{
|
||||
if (d8)
|
||||
return partialHide->ourImages[10].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[6].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d8)
|
||||
return partialHide->ourImages[7].bitmap;
|
||||
else if (d9)
|
||||
return partialHide->ourImages[51].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[38].bitmap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d6)
|
||||
{
|
||||
if (d8)
|
||||
return partialHide->ourImages[44].bitmap;
|
||||
else if (d7)
|
||||
return partialHide->ourImages[28].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[12].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d7)
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[31].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[48].bitmap;
|
||||
}
|
||||
else
|
||||
return partialHide->ourImages[30].bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d4)
|
||||
{
|
||||
if (d6)
|
||||
{
|
||||
if (d8)
|
||||
return partialHide->ourImages[8].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[9].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d8)
|
||||
{
|
||||
if (d3)
|
||||
return partialHide->ourImages[50].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[37].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d3)
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[32].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[47].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[46].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[36].bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d6)
|
||||
{
|
||||
if (d8)
|
||||
{
|
||||
if (d1)
|
||||
return partialHide->ourImages[27].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[13].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d7)
|
||||
{
|
||||
if (d1)
|
||||
return partialHide->ourImages[49].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[26].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d1)
|
||||
return partialHide->ourImages[25].bitmap;
|
||||
else
|
||||
{
|
||||
if (d9)
|
||||
return partialHide->ourImages[2].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[3].bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d1)
|
||||
{
|
||||
if (d3)
|
||||
return partialHide->ourImages[33].bitmap;
|
||||
else
|
||||
return partialHide->ourImages[45].bitmap;
|
||||
}
|
||||
else
|
||||
return partialHide->ourImages[24].bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
return graphics->FoWpartialHide->ourImages[retBitmapID].bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
return graphics->FoWfullHide->ourImages[-retBitmapID - 1].bitmap;
|
||||
}
|
||||
return fullHide->ourImages[0].bitmap; //this case should never happen, but it is better to hide too much than reveal it....
|
||||
}
|
||||
|
||||
bool CMapHandler::printObject(const CGObjectInstance *obj)
|
||||
@ -1321,8 +1112,8 @@ void CMapHandler::updateWater() //shift colors in palettes of water tiles
|
||||
|
||||
CMapHandler::~CMapHandler()
|
||||
{
|
||||
delete fullHide;
|
||||
delete partialHide;
|
||||
delete graphics->FoWfullHide;
|
||||
delete graphics->FoWpartialHide;
|
||||
|
||||
for(int i=0; i < roadDefs.size(); i++)
|
||||
delete roadDefs[i];
|
||||
@ -1341,17 +1132,17 @@ CMapHandler::~CMapHandler()
|
||||
|
||||
CMapHandler::CMapHandler()
|
||||
{
|
||||
mapW = mapH = 0;
|
||||
frameW = frameH = 0;
|
||||
fullHide = NULL;
|
||||
partialHide = NULL;
|
||||
graphics->FoWfullHide = NULL;
|
||||
graphics->FoWpartialHide = NULL;
|
||||
}
|
||||
|
||||
void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terName )
|
||||
{
|
||||
out.clear();
|
||||
TerrainTile2 &t = ttiles[pos.x][pos.y][pos.z];
|
||||
for(std::vector < std::pair<const CGObjectInstance*,SDL_Rect> >::const_iterator i = t.objects.begin(); i != t.objects.end(); i++)
|
||||
TerrainTile2 & tt = ttiles[pos.x][pos.y][pos.z];
|
||||
const TerrainTile &t = map->terrain[pos.x][pos.y][pos.z];
|
||||
for(std::vector < std::pair<const CGObjectInstance*,SDL_Rect> >::const_iterator i = tt.objects.begin(); i != tt.objects.end(); i++)
|
||||
{
|
||||
if(i->first->ID == 124) //Hole
|
||||
{
|
||||
@ -1360,12 +1151,12 @@ void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terN
|
||||
}
|
||||
}
|
||||
|
||||
if(t.tileInfo->siodmyTajemniczyBajt & 128)
|
||||
if(t.siodmyTajemniczyBajt & 128)
|
||||
out = CGI->generaltexth->names[225]; //Favourable Winds
|
||||
else if(terName)
|
||||
out = CGI->generaltexth->terrainNames[t.tileInfo->tertype];
|
||||
out = CGI->generaltexth->terrainNames[t.tertype];
|
||||
}
|
||||
|
||||
TerrainTile2::TerrainTile2()
|
||||
:tileInfo(0),terbitmap(0)
|
||||
:terbitmap(0)
|
||||
{}
|
||||
|
@ -27,17 +27,12 @@ class CDefEssential;
|
||||
|
||||
struct TerrainTile2
|
||||
{
|
||||
int3 pos;
|
||||
const TerrainTile *tileInfo;
|
||||
SDL_Surface * terbitmap; //bitmap of terrain
|
||||
|
||||
std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > objects; //pointers to objects being on this tile with rects to be easier to blit this tile on screen
|
||||
TerrainTile2();
|
||||
};
|
||||
|
||||
//pathfinder
|
||||
// map<int,int> iDTerenu=>koszt_pola
|
||||
// map<int,int> IDdrogi=>koszt_drogi
|
||||
template <typename T> class PseudoV
|
||||
{
|
||||
public:
|
||||
@ -73,16 +68,13 @@ public:
|
||||
return inver.size();
|
||||
}
|
||||
};
|
||||
|
||||
class CMapHandler
|
||||
{
|
||||
public:
|
||||
PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles; //informations about map tiles
|
||||
int3 sizes; //map size (x = width, y = height, z = number of levels)
|
||||
Mapa * map;
|
||||
|
||||
// Size of the map window in pixels. This doesn't have to be a multiple of tiles.
|
||||
int mapW;
|
||||
int mapH;
|
||||
const Mapa * map;
|
||||
|
||||
// Max number of tiles that will fit in the map screen. Tiles
|
||||
// can be partial on each edges.
|
||||
@ -99,22 +91,18 @@ public:
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
|
||||
std::set<int> usedHeroes;
|
||||
CDefHandler * fullHide; //for Fog of War
|
||||
CDefHandler * partialHide; //for For of War
|
||||
//std::set<int> usedHeroes;
|
||||
|
||||
std::vector<std::vector<SDL_Surface *> > terrainGraphics; // [terrain id] [view type] [rotation type]
|
||||
std::vector<CDefEssential *> roadDefs;
|
||||
std::vector<CDefEssential *> staticRiverDefs;
|
||||
|
||||
std::map<std::string, CDefEssential*> loadedDefs; //pointers to loaded defs (key is filename, uppercase)
|
||||
|
||||
std::vector<std::vector<std::vector<unsigned char> > > hideBitmap; //specifies number of graphic that should be used to fully hide a tile
|
||||
|
||||
CMapHandler(); //c-tor
|
||||
~CMapHandler(); //d-tor
|
||||
|
||||
SDL_Surface * getVisBitmap(int x, int y, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl);
|
||||
SDL_Surface * getVisBitmap(const int3 & pos, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap);
|
||||
|
||||
std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position
|
||||
void getTerrainDescr(const int3 &pos, std::string & out, bool terName); //if tername == false => empty string when tile is clear
|
||||
|
@ -394,6 +394,36 @@ public:
|
||||
void onHeroVisit(const CGHeroInstance * h) const;
|
||||
};
|
||||
|
||||
class DLL_EXPORT CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
virtual ~CSpecObjInfo(){};
|
||||
};
|
||||
|
||||
class DLL_EXPORT CCreGenObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
bool asCastle;
|
||||
ui32 identifier;
|
||||
unsigned char castles[2]; //allowed castles
|
||||
};
|
||||
class DLL_EXPORT CCreGen2ObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
bool asCastle;
|
||||
ui32 identifier;
|
||||
unsigned char castles[2]; //allowed castles
|
||||
unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
|
||||
};
|
||||
class DLL_EXPORT CCreGen3ObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
|
||||
};
|
||||
|
||||
class DLL_EXPORT CGDwelling : public CArmedInstance
|
||||
{
|
||||
public:
|
||||
|
62
lib/map.cpp
62
lib/map.cpp
@ -81,64 +81,6 @@ static unsigned char reverse(unsigned char arg)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static EDefType getDefType(CGDefInfo * a)
|
||||
{
|
||||
switch(a->id)
|
||||
{
|
||||
case 5: case 65: case 66: case 67: case 68: case 69:
|
||||
return ARTIFACT_DEF; //handled
|
||||
case 6:
|
||||
return PANDORA_DEF; //hanled
|
||||
case 10:
|
||||
return EVENTOBJ_DEF; //???
|
||||
case 26:
|
||||
return EVENTOBJ_DEF; //handled
|
||||
case 33:
|
||||
return GARRISON_DEF; //handled
|
||||
case 34: case 70: case 62: //70 - random hero //62 - prison
|
||||
return HERO_DEF; //handled
|
||||
case 36:
|
||||
return GRAIL_DEF; //hanled
|
||||
case 53: case 17: case 18: case 19: case 20: case 42: case 87: case 220://cases 17 - 20 and 42 - tests
|
||||
return PLAYERONLY_DEF; //handled
|
||||
case 54: case 71: case 72: case 73: case 74: case 75: case 162: case 163: case 164:
|
||||
return CREATURES_DEF; //handled
|
||||
case 59:
|
||||
return SIGN_DEF; //handled
|
||||
case 77:
|
||||
return TOWN_DEF; //can be problematic, but handled
|
||||
case 79: case 76:
|
||||
return RESOURCE_DEF; //handled
|
||||
case 81:
|
||||
return SCHOLAR_DEF; //handled
|
||||
case 83:
|
||||
return SEERHUT_DEF; //handled
|
||||
case 91:
|
||||
return SIGN_DEF; //handled
|
||||
case 88: case 89: case 90:
|
||||
return SHRINE_DEF; //handled
|
||||
case 93:
|
||||
return SPELLSCROLL_DEF; //handled
|
||||
case 98:
|
||||
return TOWN_DEF; //handled
|
||||
case 113:
|
||||
return WITCHHUT_DEF; //handled
|
||||
case 214:
|
||||
return HEROPLACEHOLDER_DEF; //partially handled
|
||||
case 215: case 9: //???
|
||||
return BORDERGUARD_DEF; //handled by analogy to seer huts ;]
|
||||
case 216:
|
||||
return CREGEN2_DEF; //handled
|
||||
case 217:
|
||||
return CREGEN_DEF; //handled
|
||||
case 218:
|
||||
return CREGEN3_DEF; //handled
|
||||
case 219:
|
||||
return GARRISON_DEF; //handled
|
||||
default:
|
||||
return TERRAINOBJ_DEF; // nothing to be handled
|
||||
}
|
||||
}
|
||||
|
||||
static CCreatureSet readCreatureSet(const unsigned char * bufor, int &i, int number, bool version) //version==true for >RoE maps
|
||||
{
|
||||
@ -2106,12 +2048,12 @@ void Mapa::loadQuest(CQuest * guard, const unsigned char * bufor, int & i)
|
||||
guard->isCustom = false; //randomize all if any text is missing
|
||||
}
|
||||
|
||||
TerrainTile & Mapa::getTile( int3 tile )
|
||||
TerrainTile & Mapa::getTile( const int3 & tile )
|
||||
{
|
||||
return terrain[tile.x][tile.y][tile.z];
|
||||
}
|
||||
|
||||
const TerrainTile & Mapa::getTile( int3 tile ) const
|
||||
const TerrainTile & Mapa::getTile( const int3 & tile ) const
|
||||
{
|
||||
return terrain[tile.x][tile.y][tile.z];
|
||||
}
|
||||
|
38
lib/map.h
38
lib/map.h
@ -31,40 +31,8 @@ class CGCreature;
|
||||
class CQuest;
|
||||
class CGTownInstance;
|
||||
|
||||
enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF,
|
||||
EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, PLAYERONLY_DEF,
|
||||
SHRINE_DEF, SPELLSCROLL_DEF, PANDORA_DEF, GRAIL_DEF, CREGEN_DEF, CREGEN2_DEF, CREGEN3_DEF,
|
||||
BORDERGUARD_DEF, HEROPLACEHOLDER_DEF};
|
||||
|
||||
class DLL_EXPORT CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
virtual ~CSpecObjInfo(){};
|
||||
};
|
||||
|
||||
class DLL_EXPORT CCreGenObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
bool asCastle;
|
||||
ui32 identifier;
|
||||
unsigned char castles[2]; //allowed castles
|
||||
};
|
||||
class DLL_EXPORT CCreGen2ObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
bool asCastle;
|
||||
ui32 identifier;
|
||||
unsigned char castles[2]; //allowed castles
|
||||
unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
|
||||
};
|
||||
class DLL_EXPORT CCreGen3ObjInfo : public CSpecObjInfo
|
||||
{
|
||||
public:
|
||||
unsigned char player; //owner
|
||||
unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
|
||||
};
|
||||
struct DLL_EXPORT TerrainTile
|
||||
{
|
||||
enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
|
||||
@ -294,11 +262,13 @@ struct DLL_EXPORT Mapa : public CMapHeader
|
||||
Mapa(std::string filename); //creates map structure from .h3m file
|
||||
Mapa();
|
||||
~Mapa();
|
||||
TerrainTile &getTile(int3 tile);
|
||||
const TerrainTile &getTile(int3 tile) const;
|
||||
TerrainTile &getTile(const int3 & tile);
|
||||
const TerrainTile &getTile(const int3 & tile) const;
|
||||
CGHeroInstance * getHero(int ID, int mode=0);
|
||||
bool isInTheMap(const int3 &pos) const;
|
||||
bool isWaterTile(const int3 &pos) const; //out-of-pos safe
|
||||
|
||||
void loadingHelper();
|
||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||
{
|
||||
h & static_cast<CMapHeader&>(*this);
|
||||
|
Loading…
Reference in New Issue
Block a user