mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
* Added comments to map.h * Refactoring(renamed attributes, some steps towards coding guidelines, ..)
This commit is contained in:
@ -2737,7 +2737,7 @@ TSubgoal CGoal::whatToDoToAchieve()
|
|||||||
{
|
{
|
||||||
case WIN:
|
case WIN:
|
||||||
{
|
{
|
||||||
const CVictoryCondition &vc = cb->getMapHeader()->victoryCondition;
|
const VictoryCondition &vc = cb->getMapHeader()->victoryCondition;
|
||||||
EVictoryConditionType::EVictoryConditionType cond = vc.condition;
|
EVictoryConditionType::EVictoryConditionType cond = vc.condition;
|
||||||
|
|
||||||
if(!vc.appliesToAI)
|
if(!vc.appliesToAI)
|
||||||
|
@ -1385,7 +1385,7 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
|
|||||||
{
|
{
|
||||||
if(pnode->land)
|
if(pnode->land)
|
||||||
{
|
{
|
||||||
if(LOCPLINT->cb->getTile(h->getPosition(false))->tertype != TerrainTile::water)
|
if(LOCPLINT->cb->getTile(h->getPosition(false))->tertype != ETerrainType::WATER)
|
||||||
CCS->curh->changeGraphic(0, 4 + turns*6);
|
CCS->curh->changeGraphic(0, 4 + turns*6);
|
||||||
else
|
else
|
||||||
CCS->curh->changeGraphic(0, 7 + turns*6); //anchor
|
CCS->curh->changeGraphic(0, 7 + turns*6); //anchor
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
};
|
};
|
||||||
extern CClientState * CCS;
|
extern CClientState * CCS;
|
||||||
|
|
||||||
struct Mapa;
|
struct CMap;
|
||||||
|
|
||||||
/// CGameInfo class
|
/// CGameInfo class
|
||||||
/// for allowing different functions for accessing game informations
|
/// for allowing different functions for accessing game informations
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
void setFromLib();
|
void setFromLib();
|
||||||
|
|
||||||
friend class CClient;
|
friend class CClient;
|
||||||
friend void initVillagesCapitols(Mapa * map);
|
friend void initVillagesCapitols(CMap * map);
|
||||||
|
|
||||||
CGameInfo();
|
CGameInfo();
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ CSoundHandler::CSoundHandler():
|
|||||||
pickupSounds += soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
|
pickupSounds += soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
|
||||||
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07;
|
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07;
|
||||||
|
|
||||||
horseSounds += // must be the same order as terrains (see EterrainType);
|
horseSounds += // must be the same order as terrains (see ETerrainType);
|
||||||
soundBase::horseDirt, soundBase::horseSand, soundBase::horseGrass,
|
soundBase::horseDirt, soundBase::horseSand, soundBase::horseGrass,
|
||||||
soundBase::horseSnow, soundBase::horseSwamp, soundBase::horseRough,
|
soundBase::horseSnow, soundBase::horseSwamp, soundBase::horseRough,
|
||||||
soundBase::horseSubterranean, soundBase::horseLava,
|
soundBase::horseSubterranean, soundBase::horseLava,
|
||||||
|
@ -1223,8 +1223,8 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
|
|||||||
boost::unique_lock<boost::mutex> un(stillMoveHero.mx);
|
boost::unique_lock<boost::mutex> un(stillMoveHero.mx);
|
||||||
stillMoveHero.data = CONTINUE_MOVE;
|
stillMoveHero.data = CONTINUE_MOVE;
|
||||||
|
|
||||||
enum TerrainTile::EterrainType currentTerrain = TerrainTile::border; // not init yet
|
enum ETerrainType::ETerrainType currentTerrain = ETerrainType::BORDER; // not init yet
|
||||||
enum TerrainTile::EterrainType newTerrain;
|
enum ETerrainType::ETerrainType newTerrain;
|
||||||
int sh = -1;
|
int sh = -1;
|
||||||
|
|
||||||
const TerrainTile * curTile = cb->getTile(CGHeroInstance::convertPosition(h->pos, false));
|
const TerrainTile * curTile = cb->getTile(CGHeroInstance::convertPosition(h->pos, false));
|
||||||
|
@ -1048,7 +1048,7 @@ void SelectionTab::parseMaps(const std::vector<ResourceID> &files, int start, in
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TInputStreamPtr stream(Mapa::getMapStream(files[start].getName()));
|
TInputStreamPtr stream(CMap::getMapStream(files[start].getName()));
|
||||||
int read = stream->read(mapBuffer, 1500);
|
int read = stream->read(mapBuffer, 1500);
|
||||||
|
|
||||||
if(read < 50 || !mapBuffer[4])
|
if(read < 50 || !mapBuffer[4])
|
||||||
@ -1360,16 +1360,16 @@ void SelectionTab::printMaps(SDL_Surface *to)
|
|||||||
int temp=-1;
|
int temp=-1;
|
||||||
switch (currentItem->mapHeader->version)
|
switch (currentItem->mapHeader->version)
|
||||||
{
|
{
|
||||||
case CMapHeader::RoE:
|
case EMapFormat::ROE:
|
||||||
temp=0;
|
temp=0;
|
||||||
break;
|
break;
|
||||||
case CMapHeader::AB:
|
case EMapFormat::AB:
|
||||||
temp=1;
|
temp=1;
|
||||||
break;
|
break;
|
||||||
case CMapHeader::SoD:
|
case EMapFormat::SOD:
|
||||||
temp=2;
|
temp=2;
|
||||||
break;
|
break;
|
||||||
case CMapHeader::WoG:
|
case EMapFormat::WOG:
|
||||||
temp=3;
|
temp=3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -34,39 +34,39 @@ extern SDL_Surface * screen;
|
|||||||
|
|
||||||
std::string nameFromType (int typ)
|
std::string nameFromType (int typ)
|
||||||
{
|
{
|
||||||
switch(static_cast<TerrainTile::EterrainType>(typ))
|
switch(static_cast<ETerrainType::ETerrainType>(typ))
|
||||||
{
|
{
|
||||||
case TerrainTile::dirt:
|
case ETerrainType::DIRT:
|
||||||
return std::string("DIRTTL.DEF");
|
return std::string("DIRTTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::sand:
|
case ETerrainType::SAND:
|
||||||
return std::string("SANDTL.DEF");
|
return std::string("SANDTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::grass:
|
case ETerrainType::GRASS:
|
||||||
return std::string("GRASTL.DEF");
|
return std::string("GRASTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::snow:
|
case ETerrainType::SNOW:
|
||||||
return std::string("SNOWTL.DEF");
|
return std::string("SNOWTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::swamp:
|
case ETerrainType::SWAMP:
|
||||||
return std::string("SWMPTL.DEF");
|
return std::string("SWMPTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::rough:
|
case ETerrainType::ROUGH:
|
||||||
return std::string("ROUGTL.DEF");
|
return std::string("ROUGTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::subterranean:
|
case ETerrainType::SUBTERRANEAN:
|
||||||
return std::string("SUBBTL.DEF");
|
return std::string("SUBBTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::lava:
|
case ETerrainType::LAVA:
|
||||||
return std::string("LAVATL.DEF");
|
return std::string("LAVATL.DEF");
|
||||||
|
|
||||||
case TerrainTile::water:
|
case ETerrainType::WATER:
|
||||||
return std::string("WATRTL.DEF");
|
return std::string("WATRTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::rock:
|
case ETerrainType::ROCK:
|
||||||
return std::string("ROCKTL.DEF");
|
return std::string("ROCKTL.DEF");
|
||||||
|
|
||||||
case TerrainTile::border:
|
case ETerrainType::BORDER:
|
||||||
//TODO use me
|
//TODO use me
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -378,7 +378,7 @@ void CMapHandler::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::for_each(map->defy.begin(),map->defy.end(),processDef); //load h3m defs
|
std::for_each(map->customDefs.begin(),map->customDefs.end(),processDef); //load h3m defs
|
||||||
tlog0<<"\tUnpacking and handling defs: "<<th.getDiff()<<std::endl;
|
tlog0<<"\tUnpacking and handling defs: "<<th.getDiff()<<std::endl;
|
||||||
|
|
||||||
//it seems to be completely unnecessary and useless
|
//it seems to be completely unnecessary and useless
|
||||||
@ -504,27 +504,27 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
|
|||||||
}
|
}
|
||||||
else //use default terrain graphic
|
else //use default terrain graphic
|
||||||
{
|
{
|
||||||
blitterWithRotation(terrainGraphics[tinfo.tertype][tinfo.terview],rtile, extSurf, sr, tinfo.siodmyTajemniczyBajt%4);
|
blitterWithRotation(terrainGraphics[tinfo.tertype][tinfo.terview],rtile, extSurf, sr, tinfo.extTileFlags%4);
|
||||||
}
|
}
|
||||||
if(tinfo.nuine) //print river if present
|
if(tinfo.riverType) //print river if present
|
||||||
{
|
{
|
||||||
blitterWithRotationAndAlpha(staticRiverDefs[tinfo.nuine-1]->ourImages[tinfo.rivDir].bitmap,rtile, extSurf, sr, (tinfo.siodmyTajemniczyBajt>>2)%4);
|
blitterWithRotationAndAlpha(staticRiverDefs[tinfo.riverType-1]->ourImages[tinfo.riverDir].bitmap,rtile, extSurf, sr, (tinfo.extTileFlags>>2)%4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Roads are shifted by 16 pixels to bottom. We have to draw both parts separately
|
//Roads are shifted by 16 pixels to bottom. We have to draw both parts separately
|
||||||
if (pos.y > 0 && map->terrain[pos.x][pos.y-1][pos.z].malle)
|
if (pos.y > 0 && map->terrain[pos.x][pos.y-1][pos.z].roadType)
|
||||||
{ //part from top tile
|
{ //part from top tile
|
||||||
const TerrainTile &topTile = map->terrain[pos.x][pos.y-1][pos.z];
|
const TerrainTile &topTile = map->terrain[pos.x][pos.y-1][pos.z];
|
||||||
Rect source(0, 16, 32, 16);
|
Rect source(0, 16, 32, 16);
|
||||||
Rect dest(sr.x, sr.y, sr.w, sr.h/2);
|
Rect dest(sr.x, sr.y, sr.w, sr.h/2);
|
||||||
blitterWithRotationAndAlpha(roadDefs[topTile.malle-1]->ourImages[topTile.roadDir].bitmap, source, extSurf, dest, (topTile.siodmyTajemniczyBajt>>4)%4);
|
blitterWithRotationAndAlpha(roadDefs[topTile.roadType-1]->ourImages[topTile.roadDir].bitmap, source, extSurf, dest, (topTile.extTileFlags>>4)%4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tinfo.malle) //print road from this tile
|
if(tinfo.roadType) //print road from this tile
|
||||||
{
|
{
|
||||||
Rect source(0, 0, 32, 32);
|
Rect source(0, 0, 32, 32);
|
||||||
Rect dest(sr.x, sr.y+16, sr.w, sr.h/2);
|
Rect dest(sr.x, sr.y+16, sr.w, sr.h/2);
|
||||||
blitterWithRotationAndAlpha(roadDefs[tinfo.malle-1]->ourImages[tinfo.roadDir].bitmap, source, extSurf, dest, (tinfo.siodmyTajemniczyBajt>>4)%4);
|
blitterWithRotationAndAlpha(roadDefs[tinfo.roadType-1]->ourImages[tinfo.roadDir].bitmap, source, extSurf, dest, (tinfo.extTileFlags>>4)%4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//blit objects
|
//blit objects
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
struct Mapa;
|
struct CMap;
|
||||||
class CGDefInfo;
|
class CGDefInfo;
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
class CDefHandler;
|
class CDefHandler;
|
||||||
@ -73,7 +73,7 @@ class CMapHandler
|
|||||||
public:
|
public:
|
||||||
PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles; //informations about map tiles
|
PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles; //informations about map tiles
|
||||||
int3 sizes; //map size (x = width, y = height, z = number of levels)
|
int3 sizes; //map size (x = width, y = height, z = number of levels)
|
||||||
const Mapa * map;
|
const CMap * map;
|
||||||
|
|
||||||
// Max number of tiles that will fit in the map screen. Tiles
|
// Max number of tiles that will fit in the map screen. Tiles
|
||||||
// can be partial on each edges.
|
// can be partial on each edges.
|
||||||
|
@ -465,7 +465,7 @@ int CGameState::pickHero(int owner)
|
|||||||
{
|
{
|
||||||
int h=-1;
|
int h=-1;
|
||||||
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
const PlayerSettings &ps = scenarioOps->getIthPlayersSettings(owner);
|
||||||
if(!map->getHero(h = ps.hero,0) && h>=0) //we haven't used selected hero
|
if(!map->getHero(h = ps.hero) && h>=0) //we haven't used selected hero
|
||||||
return h;
|
return h;
|
||||||
|
|
||||||
if(scenarioOps->mode == StartInfo::CAMPAIGN)
|
if(scenarioOps->mode == StartInfo::CAMPAIGN)
|
||||||
@ -699,7 +699,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
|
|||||||
cur->ID = ran.first;
|
cur->ID = ran.first;
|
||||||
cur->subID = ran.second;
|
cur->subID = ran.second;
|
||||||
map->removeBlockVisTiles(cur); //recalculate blockvis tiles - picked object might have different than random placeholder
|
map->removeBlockVisTiles(cur); //recalculate blockvis tiles - picked object might have different than random placeholder
|
||||||
map->defy.push_back(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]);
|
map->customDefs.push_back(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]);
|
||||||
if(!cur->defInfo)
|
if(!cur->defInfo)
|
||||||
{
|
{
|
||||||
tlog1<<"*BIG* WARNING: Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;
|
tlog1<<"*BIG* WARNING: Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;
|
||||||
@ -771,7 +771,7 @@ BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2],
|
|||||||
const TerrainTile &t = map->getTile(tile);
|
const TerrainTile &t = map->getTile(tile);
|
||||||
int terrain = t.tertype;
|
int terrain = t.tertype;
|
||||||
if(t.isCoastal() && !t.isWater())
|
if(t.isCoastal() && !t.isWater())
|
||||||
terrain = TerrainTile::sand;
|
terrain = ETerrainType::SAND;
|
||||||
|
|
||||||
int terType = battleGetBattlefieldType(tile);
|
int terType = battleGetBattlefieldType(tile);
|
||||||
return BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
|
return BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
|
||||||
@ -865,7 +865,7 @@ void CGameState::init(StartInfo * si)
|
|||||||
switch(scenarioOps->mode)
|
switch(scenarioOps->mode)
|
||||||
{
|
{
|
||||||
case StartInfo::NEW_GAME:
|
case StartInfo::NEW_GAME:
|
||||||
map = new Mapa(scenarioOps->mapname);
|
map = new CMap(scenarioOps->mapname);
|
||||||
break;
|
break;
|
||||||
case StartInfo::CAMPAIGN:
|
case StartInfo::CAMPAIGN:
|
||||||
{
|
{
|
||||||
@ -873,7 +873,7 @@ void CGameState::init(StartInfo * si)
|
|||||||
assert(vstd::contains(campaign->camp->mapPieces, scenarioOps->campState->currentMap));
|
assert(vstd::contains(campaign->camp->mapPieces, scenarioOps->campState->currentMap));
|
||||||
|
|
||||||
std::string &mapContent = campaign->camp->mapPieces[scenarioOps->campState->currentMap];
|
std::string &mapContent = campaign->camp->mapPieces[scenarioOps->campState->currentMap];
|
||||||
map = new Mapa();
|
map = new CMap();
|
||||||
map->initFromBytes((const ui8*)mapContent.c_str(), mapContent.size());
|
map->initFromBytes((const ui8*)mapContent.c_str(), mapContent.size());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -926,8 +926,8 @@ void CGameState::init(StartInfo * si)
|
|||||||
const TerrainTile &t = map->terrain[i][j][k];
|
const TerrainTile &t = map->terrain[i][j][k];
|
||||||
if(!t.blocked
|
if(!t.blocked
|
||||||
&& !t.visitable
|
&& !t.visitable
|
||||||
&& t.tertype != TerrainTile::water
|
&& t.tertype != ETerrainType::WATER
|
||||||
&& t.tertype != TerrainTile::rock
|
&& t.tertype != ETerrainType::ROCK
|
||||||
&& map->grailPos.dist2d(int3(i,j,k)) <= map->grailRadious)
|
&& map->grailPos.dist2d(int3(i,j,k)) <= map->grailRadious)
|
||||||
allowedPos.push_back(int3(i,j,k));
|
allowedPos.push_back(int3(i,j,k));
|
||||||
}
|
}
|
||||||
@ -974,7 +974,7 @@ void CGameState::init(StartInfo * si)
|
|||||||
{
|
{
|
||||||
int3 pos = obj->pos - int3(i,j,0);
|
int3 pos = obj->pos - int3(i,j,0);
|
||||||
if(map->isInTheMap(pos))
|
if(map->isInTheMap(pos))
|
||||||
map->getTile(pos).siodmyTajemniczyBajt |= 128;
|
map->getTile(pos).extTileFlags |= 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
|
//std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
|
||||||
@ -1669,25 +1669,25 @@ int CGameState::battleGetBattlefieldType(int3 tile) const
|
|||||||
|
|
||||||
switch(t.tertype)
|
switch(t.tertype)
|
||||||
{
|
{
|
||||||
case TerrainTile::dirt:
|
case ETerrainType::DIRT:
|
||||||
return rand()%3+3;
|
return rand()%3+3;
|
||||||
case TerrainTile::sand:
|
case ETerrainType::SAND:
|
||||||
return 2; //TODO: coast support
|
return 2; //TODO: coast support
|
||||||
case TerrainTile::grass:
|
case ETerrainType::GRASS:
|
||||||
return rand()%2+6;
|
return rand()%2+6;
|
||||||
case TerrainTile::snow:
|
case ETerrainType::SNOW:
|
||||||
return rand()%2+10;
|
return rand()%2+10;
|
||||||
case TerrainTile::swamp:
|
case ETerrainType::SWAMP:
|
||||||
return 13;
|
return 13;
|
||||||
case TerrainTile::rough:
|
case ETerrainType::ROUGH:
|
||||||
return 23;
|
return 23;
|
||||||
case TerrainTile::subterranean:
|
case ETerrainType::SUBTERRANEAN:
|
||||||
return 12;
|
return 12;
|
||||||
case TerrainTile::lava:
|
case ETerrainType::LAVA:
|
||||||
return 8;
|
return 8;
|
||||||
case TerrainTile::water:
|
case ETerrainType::WATER:
|
||||||
return 25;
|
return 25;
|
||||||
case TerrainTile::rock:
|
case ETerrainType::ROCK:
|
||||||
return 15;
|
return 15;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
@ -1794,9 +1794,9 @@ void CGameState::loadTownDInfos()
|
|||||||
capitols[town.first] = new CGDefInfo(*townInfos[town.first]);
|
capitols[town.first] = new CGDefInfo(*townInfos[town.first]);
|
||||||
capitols[town.first]->name = town.second.clientInfo.advMapCapitol;
|
capitols[town.first]->name = town.second.clientInfo.advMapCapitol;
|
||||||
|
|
||||||
map->defy.push_back(villages[town.first]);
|
map->customDefs.push_back(villages[town.first]);
|
||||||
map->defy.push_back(forts[town.first]);
|
map->customDefs.push_back(forts[town.first]);
|
||||||
map->defy.push_back(capitols[town.first]);
|
map->customDefs.push_back(capitols[town.first]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1819,19 +1819,19 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<i
|
|||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(srct.tertype == TerrainTile::water && limitCoastSailing && hlpt.tertype == TerrainTile::water && dirs[i].x && dirs[i].y) //diagonal move through water
|
if(srct.tertype == ETerrainType::WATER && limitCoastSailing && hlpt.tertype == ETerrainType::WATER && dirs[i].x && dirs[i].y) //diagonal move through water
|
||||||
{
|
{
|
||||||
int3 hlp1 = tile,
|
int3 hlp1 = tile,
|
||||||
hlp2 = tile;
|
hlp2 = tile;
|
||||||
hlp1.x += dirs[i].x;
|
hlp1.x += dirs[i].x;
|
||||||
hlp2.y += dirs[i].y;
|
hlp2.y += dirs[i].y;
|
||||||
|
|
||||||
if(map->getTile(hlp1).tertype != TerrainTile::water || map->getTile(hlp2).tertype != TerrainTile::water)
|
if(map->getTile(hlp1).tertype != ETerrainType::WATER || map->getTile(hlp2).tertype != ETerrainType::WATER)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((indeterminate(onLand) || onLand == (hlpt.tertype!=TerrainTile::water) )
|
if((indeterminate(onLand) || onLand == (hlpt.tertype!=ETerrainType::WATER) )
|
||||||
&& hlpt.tertype != TerrainTile::rock)
|
&& hlpt.tertype != ETerrainType::ROCK)
|
||||||
{
|
{
|
||||||
vec.push_back(hlp);
|
vec.push_back(hlp);
|
||||||
}
|
}
|
||||||
@ -1858,7 +1858,7 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const
|
|||||||
ret *= 1.4; //40% penalty for movement over blocked tile
|
ret *= 1.4; //40% penalty for movement over blocked tile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (d.tertype == TerrainTile::water)
|
else if (d.tertype == ETerrainType::WATER)
|
||||||
{
|
{
|
||||||
if(h->boat && s.hasFavourableWinds() && d.hasFavourableWinds()) //Favourable Winds
|
if(h->boat && s.hasFavourableWinds() && d.hasFavourableWinds()) //Favourable Winds
|
||||||
ret *= 0.666;
|
ret *= 0.666;
|
||||||
@ -1882,7 +1882,7 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const
|
|||||||
if(checkLast && left > 0 && remainingMovePoints-ret < 250) //it might be the last tile - if no further move possible we take all move points
|
if(checkLast && left > 0 && remainingMovePoints-ret < 250) //it might be the last tile - if no further move possible we take all move points
|
||||||
{
|
{
|
||||||
std::vector<int3> vec;
|
std::vector<int3> vec;
|
||||||
getNeighbours(d, dest, vec, s.tertype != TerrainTile::water, true);
|
getNeighbours(d, dest, vec, s.tertype != ETerrainType::WATER, true);
|
||||||
for(size_t i=0; i < vec.size(); i++)
|
for(size_t i=0; i < vec.size(); i++)
|
||||||
{
|
{
|
||||||
int fcost = getMovementCost(h,dest,vec[i],left,false);
|
int fcost = getMovementCost(h,dest,vec[i],left,false);
|
||||||
@ -1952,7 +1952,7 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
|
|||||||
if (map->isInTheMap(pos))
|
if (map->isInTheMap(pos))
|
||||||
{
|
{
|
||||||
TerrainTile &tile = map->terrain[pos.x][pos.y][pos.z];
|
TerrainTile &tile = map->terrain[pos.x][pos.y][pos.z];
|
||||||
if (tile.visitable && (tile.tertype == TerrainTile::water) == (posTile.tertype == TerrainTile::water))
|
if (tile.visitable && (tile.tertype == ETerrainType::WATER) == (posTile.tertype == ETerrainType::WATER))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
|
BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
|
||||||
{
|
{
|
||||||
@ -2809,7 +2809,7 @@ DuelParameters::SideSettings::SideSettings()
|
|||||||
|
|
||||||
DuelParameters::DuelParameters()
|
DuelParameters::DuelParameters()
|
||||||
{
|
{
|
||||||
terType = TerrainTile::dirt;
|
terType = ETerrainType::DIRT;
|
||||||
bfieldType = 15;
|
bfieldType = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2928,7 +2928,7 @@ void CPathfinder::initializeGraph()
|
|||||||
node.coord.x = i;
|
node.coord.x = i;
|
||||||
node.coord.y = j;
|
node.coord.y = j;
|
||||||
node.coord.z = k;
|
node.coord.z = k;
|
||||||
node.land = tinfo->tertype != TerrainTile::water;
|
node.land = tinfo->tertype != ETerrainType::WATER;
|
||||||
node.theNodeBefore = NULL;
|
node.theNodeBefore = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3101,7 +3101,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
|
|||||||
CGPathNode::EAccessibility ret = (tinfo->blocked ? CGPathNode::BLOCKED : CGPathNode::ACCESSIBLE);
|
CGPathNode::EAccessibility ret = (tinfo->blocked ? CGPathNode::BLOCKED : CGPathNode::ACCESSIBLE);
|
||||||
|
|
||||||
|
|
||||||
if(tinfo->tertype == TerrainTile::rock || !FoW[curPos.x][curPos.y][curPos.z])
|
if(tinfo->tertype == ETerrainType::ROCK || !FoW[curPos.x][curPos.y][curPos.z])
|
||||||
return CGPathNode::BLOCKED;
|
return CGPathNode::BLOCKED;
|
||||||
|
|
||||||
if(tinfo->visitable)
|
if(tinfo->visitable)
|
||||||
|
@ -44,7 +44,7 @@ class CGDefInfo;
|
|||||||
class CObjectScript;
|
class CObjectScript;
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
class CCreature;
|
class CCreature;
|
||||||
struct Mapa;
|
struct CMap;
|
||||||
struct StartInfo;
|
struct StartInfo;
|
||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
class CMapHandler;
|
class CMapHandler;
|
||||||
@ -386,7 +386,7 @@ public:
|
|||||||
ui8 currentPlayer; //ID of player currently having turn
|
ui8 currentPlayer; //ID of player currently having turn
|
||||||
ConstTransitivePtr<BattleInfo> curB; //current battle
|
ConstTransitivePtr<BattleInfo> curB; //current battle
|
||||||
ui32 day; //total number of days in game
|
ui32 day; //total number of days in game
|
||||||
ConstTransitivePtr<Mapa> map;
|
ConstTransitivePtr<CMap> map;
|
||||||
bmap<TPlayerColor, PlayerState> players;
|
bmap<TPlayerColor, PlayerState> players;
|
||||||
bmap<TPlayerColor, TeamState> teams;
|
bmap<TPlayerColor, TeamState> teams;
|
||||||
bmap<TPlayerColor, ConstTransitivePtr<CGDefInfo> > villages, forts, capitols; //def-info for town graphics
|
bmap<TPlayerColor, ConstTransitivePtr<CGDefInfo> > villages, forts, capitols; //def-info for town graphics
|
||||||
@ -461,7 +461,7 @@ public:
|
|||||||
friend class CCallback;
|
friend class CCallback;
|
||||||
friend class CLuaCallback;
|
friend class CLuaCallback;
|
||||||
friend class CClient;
|
friend class CClient;
|
||||||
friend void initGameState(Mapa * map, CGameInfo * cgi);
|
friend void initGameState(CMap * map, CGameInfo * cgi);
|
||||||
friend class IGameCallback;
|
friend class IGameCallback;
|
||||||
friend class CMapHandler;
|
friend class CMapHandler;
|
||||||
friend class CGameHandler;
|
friend class CGameHandler;
|
||||||
|
@ -38,7 +38,7 @@ void CMapInfo::mapInit(const std::string &fname, const ui8 *map )
|
|||||||
fileURI = fname;
|
fileURI = fname;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
mapHeader = new CMapHeader();
|
mapHeader = new CMapHeader();
|
||||||
mapHeader->version = CMapHeader::invalid;
|
mapHeader->version = EMapFormat::INVALID;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -530,18 +530,18 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
|
|||||||
unsigned ret = 100;
|
unsigned ret = 100;
|
||||||
|
|
||||||
//if there is road both on dest and src tiles - use road movement cost
|
//if there is road both on dest and src tiles - use road movement cost
|
||||||
if(dest.malle && from.malle)
|
if(dest.roadType && from.roadType)
|
||||||
{
|
{
|
||||||
int road = std::min(dest.malle,from.malle); //used road ID
|
int road = std::min(dest.roadType,from.roadType); //used road ID
|
||||||
switch(road)
|
switch(road)
|
||||||
{
|
{
|
||||||
case TerrainTile::dirtRoad:
|
case ERoadType::DIRT_ROAD:
|
||||||
ret = 75;
|
ret = 75;
|
||||||
break;
|
break;
|
||||||
case TerrainTile::grazvelRoad:
|
case ERoadType::GRAVEL_ROAD:
|
||||||
ret = 65;
|
ret = 65;
|
||||||
break;
|
break;
|
||||||
case TerrainTile::cobblestoneRoad:
|
case ERoadType::COBBLESTONE_ROAD:
|
||||||
ret = 50;
|
ret = 50;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1502,7 +1502,7 @@ CGHeroInstance::ECanDig CGHeroInstance::diggingStatus() const
|
|||||||
{
|
{
|
||||||
if(movement < maxMovePoints(true))
|
if(movement < maxMovePoints(true))
|
||||||
return LACK_OF_MOVEMENT;
|
return LACK_OF_MOVEMENT;
|
||||||
else if(cb->getTile(getPosition(false))->tertype == TerrainTile::water)
|
else if(cb->getTile(getPosition(false))->tertype == ETerrainType::WATER)
|
||||||
return WRONG_TERRAIN;
|
return WRONG_TERRAIN;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -6530,7 +6530,7 @@ int3 IBoatGenerator::bestLocation() const
|
|||||||
{
|
{
|
||||||
if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offsets[i], false)) //tile is in the map
|
if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offsets[i], false)) //tile is in the map
|
||||||
{
|
{
|
||||||
if (tile->tertype == TerrainTile::water && (!tile->blocked || tile->blockingObjects.front()->ID == 8)) //and is water and is not blocked or is blocked by boat
|
if (tile->tertype == ETerrainType::WATER && (!tile->blocked || tile->blockingObjects.front()->ID == 8)) //and is water and is not blocked or is blocked by boat
|
||||||
return o->pos + offsets[i];
|
return o->pos + offsets[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,9 +430,9 @@ bool CGameInfoCallback::verifyPath(CPath * path, bool blockSea) const
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
const TerrainTile *prev = getTile(path->nodes[i-1].coord); //tile of previous node on the path
|
const TerrainTile *prev = getTile(path->nodes[i-1].coord); //tile of previous node on the path
|
||||||
if (( t->tertype == TerrainTile::water && prev->tertype != TerrainTile::water)
|
if (( t->tertype == ETerrainType::WATER && prev->tertype != ETerrainType::WATER)
|
||||||
|| (t->tertype != TerrainTile::water && prev->tertype == TerrainTile::water)
|
|| (t->tertype != ETerrainType::WATER && prev->tertype == ETerrainType::WATER)
|
||||||
|| prev->tertype == TerrainTile::rock
|
|| prev->tertype == ETerrainType::ROCK
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -594,7 +594,7 @@ int CGameInfoCallback::canBuildStructure( const CGTownInstance *t, int ID )
|
|||||||
{
|
{
|
||||||
const TerrainTile *tile = getTile(t->bestLocation(), false);
|
const TerrainTile *tile = getTile(t->bestLocation(), false);
|
||||||
|
|
||||||
if(!tile || tile->tertype != TerrainTile::water )
|
if(!tile || tile->tertype != ETerrainType::WATER)
|
||||||
return EBuildingState::NO_WATER; //lack of water
|
return EBuildingState::NO_WATER; //lack of water
|
||||||
}
|
}
|
||||||
|
|
||||||
|
962
lib/map.cpp
962
lib/map.cpp
File diff suppressed because it is too large
Load Diff
@ -1229,7 +1229,7 @@ void CGameHandler::newTurn()
|
|||||||
|
|
||||||
NewTurn::Hero hth;
|
NewTurn::Hero hth;
|
||||||
hth.id = h->id;
|
hth.id = h->id;
|
||||||
hth.move = h->maxMovePoints(gs->map->getTile(h->getPosition(false)).tertype != TerrainTile::water);
|
hth.move = h->maxMovePoints(gs->map->getTile(h->getPosition(false)).tertype != ETerrainType::WATER);
|
||||||
|
|
||||||
if(h->visitedTown && h->visitedTown->hasBuilt(EBuilding::MAGES_GUILD_1)) //if hero starts turn in town with mage guild
|
if(h->visitedTown && h->visitedTown->hasBuilt(EBuilding::MAGES_GUILD_1)) //if hero starts turn in town with mage guild
|
||||||
hth.mana = std::max(h->mana, h->manaLimit()); //restore all mana
|
hth.mana = std::max(h->mana, h->manaLimit()); //restore all mana
|
||||||
@ -1671,11 +1671,11 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
|||||||
|
|
||||||
//it's a rock or blocked and not visitable tile
|
//it's a rock or blocked and not visitable tile
|
||||||
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
//OR hero is on land and dest is water and (there is not present only one object - boat)
|
||||||
if(((t.tertype == TerrainTile::rock || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) ))
|
if(((t.tertype == ETerrainType::ROCK || (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) ))
|
||||||
&& complain("Cannot move hero, destination tile is blocked!"))
|
&& complain("Cannot move hero, destination tile is blocked!"))
|
||||||
|| ((!h->boat && !h->canWalkOnSea() && t.tertype == TerrainTile::water && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
|| ((!h->boat && !h->canWalkOnSea() && t.tertype == ETerrainType::WATER && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
|
||||||
&& complain("Cannot move hero, destination tile is on water!"))
|
&& complain("Cannot move hero, destination tile is on water!"))
|
||||||
|| ((h->boat && t.tertype != TerrainTile::water && t.blocked)
|
|| ((h->boat && t.tertype != ETerrainType::WATER && t.blocked)
|
||||||
&& complain("Cannot disembark hero, tile is blocked!"))
|
&& complain("Cannot disembark hero, tile is blocked!"))
|
||||||
|| ((h->movement < cost && dst != h->pos && !instant)
|
|| ((h->movement < cost && dst != h->pos && !instant)
|
||||||
&& complain("Hero doesn't have any movement points left!"))
|
&& complain("Hero doesn't have any movement points left!"))
|
||||||
@ -1697,7 +1697,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//hero leaves the boat
|
//hero leaves the boat
|
||||||
else if(h->boat && t.tertype != TerrainTile::water && !t.blocked)
|
else if(h->boat && t.tertype != ETerrainType::WATER && !t.blocked)
|
||||||
{
|
{
|
||||||
//TODO? code similarity with the block above
|
//TODO? code similarity with the block above
|
||||||
tmh.result = TryMoveHero::DISEMBARK;
|
tmh.result = TryMoveHero::DISEMBARK;
|
||||||
|
Reference in New Issue
Block a user