Fix previous commits.

This commit is contained in:
joris 2013-04-24 14:17:40 +02:00
parent 8610491675
commit c89449df41
4 changed files with 48 additions and 52 deletions

View file

@ -958,7 +958,7 @@ static void DrawEditorInfo()
// Tile info
const CTileset &tileset = *Map.Tileset;
const int index = tileset.findTileIndexByTile(mf.TilesetTile);
const int index = tileset.findTileIndexByTile(mf.Tile);
Assert(index != -1);
const int baseTerrainIdx = tileset.tiles[index].tileinfo.BaseTerrain;
const char *baseTerrainStr = tileset.getTerrainName(baseTerrainIdx).c_str();

View file

@ -84,6 +84,9 @@ struct SolidTerrainInfo {
class CTile
{
public:
CTile() : tile(0), flag(0) {}
public:
unsigned short tile; /// graphical pos
unsigned short flag; /// Flag
@ -112,12 +115,12 @@ public:
unsigned getBottomOneTreeTile() const { return botOneTreeTile; }
unsigned getTopOneTreeTile() const { return topOneTreeTile; }
unsigned getHumanWallTile(int dirFlag) const;
unsigned getOrcWallTile(int dirFlag) const;
unsigned getHumanWallTile_broken(int dirFlag) const;
unsigned getOrcWallTile_broken(int dirFlag) const;
unsigned getHumanWallTile_destroyed(int dirFlag) const;
unsigned getOrcWallTile_destroyed(int dirFlag) const;
unsigned getHumanWallTileIndex(int dirFlag) const;
unsigned getOrcWallTileIndex(int dirFlag) const;
unsigned getHumanWallTileIndex_broken(int dirFlag) const;
unsigned getOrcWallTileIndex_broken(int dirFlag) const;
unsigned getHumanWallTileIndex_destroyed(int dirFlag) const;
unsigned getOrcWallTileIndex_destroyed(int dirFlag) const;
unsigned int getSolidTerrainCount() const;

View file

@ -62,23 +62,25 @@
static unsigned int getWallTile(const CTileset &tileset, bool humanWall, int dirFlag, int value)
{
unsigned int tileIndex;
if (humanWall) {
if (value == 0) {
return tileset.getHumanWallTile_destroyed(dirFlag);
tileIndex = tileset.getHumanWallTileIndex_destroyed(dirFlag);
} else if (UnitTypeHumanWall && value <= UnitTypeHumanWall->DefaultStat.Variables[HP_INDEX].Max / 2) {
return tileset.getHumanWallTile_broken(dirFlag);
tileIndex = tileset.getHumanWallTileIndex_broken(dirFlag);
} else {
return tileset.getHumanWallTile(dirFlag);
tileIndex = tileset.getHumanWallTileIndex(dirFlag);
}
} else { // orcWall
if (value == 0) {
return tileset.getOrcWallTile_destroyed(dirFlag);
tileIndex = tileset.getOrcWallTileIndex_destroyed(dirFlag);
} else if (UnitTypeOrcWall && value <= UnitTypeOrcWall->DefaultStat.Variables[HP_INDEX].Max / 2) {
return tileset.getOrcWallTile_broken(dirFlag);
tileIndex = tileset.getOrcWallTileIndex_broken(dirFlag);
} else {
return tileset.getOrcWallTile(dirFlag);
tileIndex = tileset.getOrcWallTileIndex(dirFlag);
}
}
return tileset.tiles[tileIndex].tile;
}
@ -235,10 +237,10 @@ void CMap::SetWall(const Vec2i &pos, bool humanwall)
if (humanwall) {
const int value = UnitTypeHumanWall->DefaultStat.Variables[HP_INDEX].Max;
mf.setTileIndex(*Tileset, Tileset->getHumanWallTile(0), value);
mf.setTileIndex(*Tileset, Tileset->getHumanWallTileIndex(0), value);
} else {
const int value = UnitTypeOrcWall->DefaultStat.Variables[HP_INDEX].Max;
mf.setTileIndex(*Tileset, Tileset->getOrcWallTile(0), value);
mf.setTileIndex(*Tileset, Tileset->getOrcWallTileIndex(0), value);
}
UI.Minimap.UpdateXY(pos);

View file

@ -647,59 +647,50 @@ void CTileset::fillSolidTiles(std::vector<unsigned int> *solidTiles) const
}
}
unsigned CTileset::getHumanWallTile(int dirFlag) const
unsigned CTileset::getHumanWallTileIndex(int dirFlag) const
{
unsigned tile = humanWallTable[dirFlag];
tile = tiles[tile].tile;
return tile;
return humanWallTable[dirFlag];
}
unsigned CTileset::getOrcWallTile(int dirFlag) const
unsigned CTileset::getOrcWallTileIndex(int dirFlag) const
{
unsigned tile = orcWallTable[dirFlag];
tile = tiles[tile].tile;
return tile;
return orcWallTable[dirFlag];
}
static unsigned int NextSection(const CTileset &tileset, unsigned int tile)
static unsigned int NextSection(const CTileset &tileset, unsigned int tileIndex)
{
while (tileset.tiles[tile].tile) { // Skip good tiles
++tile;
while (tileset.tiles[tileIndex].tile) { // Skip good tiles
++tileIndex;
}
while (!tileset.tiles[tile].tile) { // Skip separator
++tile;
while (!tileset.tiles[tileIndex].tile) { // Skip separator
++tileIndex;
}
return tile;
return tileIndex;
}
unsigned CTileset::getHumanWallTile_broken(int dirFlag) const
unsigned CTileset::getHumanWallTileIndex_broken(int dirFlag) const
{
unsigned tile = humanWallTable[dirFlag];
tile = NextSection(*this, tile);
tile = tiles[tile].tile;
return tile;
unsigned tileIndex = humanWallTable[dirFlag];
tileIndex = NextSection(*this, tileIndex);
return tileIndex;
}
unsigned CTileset::getOrcWallTile_broken(int dirFlag) const
unsigned CTileset::getOrcWallTileIndex_broken(int dirFlag) const
{
unsigned tile = orcWallTable[dirFlag];
tile = NextSection(*this, tile);
tile = tiles[tile].tile;
return tile;
unsigned tileIndex = orcWallTable[dirFlag];
tileIndex = NextSection(*this, tileIndex);
return tileIndex;
}
unsigned CTileset::getHumanWallTile_destroyed(int dirFlag) const
unsigned CTileset::getHumanWallTileIndex_destroyed(int dirFlag) const
{
unsigned tile = humanWallTable[dirFlag];
tile = NextSection(*this, tile);
tile = NextSection(*this, tile);
tile = tiles[tile].tile;
return tile;
unsigned tileIndex = humanWallTable[dirFlag];
tileIndex = NextSection(*this, tileIndex);
tileIndex = NextSection(*this, tileIndex);
return tileIndex;
}
unsigned CTileset::getOrcWallTile_destroyed(int dirFlag) const
unsigned CTileset::getOrcWallTileIndex_destroyed(int dirFlag) const
{
unsigned tile = orcWallTable[dirFlag];
tile = NextSection(*this, tile);
tile = NextSection(*this, tile);
tile = tiles[tile].tile;
return tile;
unsigned tileIndex = orcWallTable[dirFlag];
tileIndex = NextSection(*this, tileIndex);
tileIndex = NextSection(*this, tileIndex);
return tileIndex;
}
//@}