Skip to content

Commit

Permalink
Old map conversion fix 1: water fix, water no longer climbs cliffs.
Browse files Browse the repository at this point in the history
  • Loading branch information
haoNoQ authored and perim committed Nov 25, 2012
1 parent 014cc2c commit 8e83aee
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/bridge.cpp
Expand Up @@ -83,7 +83,7 @@ bool bridgeValid(int startX, int startY, int endX, int endY)
{
for (i = minY + 1; i < maxY - 1; i++)
{
if (mapTile(startX, i)->ground != waterGroundType)
if (terrainType(mapTile(startX, i)) != TER_WATER)
{
debug(LOG_ERROR, "Bridge cannot cross !water - X");
return false;
Expand All @@ -94,7 +94,7 @@ bool bridgeValid(int startX, int startY, int endX, int endY)
{
for (i = minX + 1; i < maxX - 1; i++)
{
if (mapTile(i, startY)->ground != waterGroundType)
if (terrainType(mapTile(i, startY)) != TER_WATER)
{
debug(LOG_ERROR, "Bridge cannot cross !water - Y");
return false;
Expand Down
8 changes: 2 additions & 6 deletions src/map.cpp
Expand Up @@ -118,7 +118,6 @@ static void init_tileNames(int type);
/// The different ground types
GROUND_TYPE *psGroundTypes;
int numGroundTypes;
int waterGroundType;
int cliffGroundType;
char *tileset = NULL;
static int numTile_names;
Expand Down Expand Up @@ -356,7 +355,6 @@ static bool mapLoadGroundTypes(void)
psGroundTypes[getTextureType(textureType)].textureSize = textureSize ;
}

waterGroundType = getTextureType("a_water");
cliffGroundType = getTextureType("a_cliff");

SetGroundForTile("tileset/arizonaground.txt", "arizona_ground");
Expand Down Expand Up @@ -398,7 +396,6 @@ static bool mapLoadGroundTypes(void)
psGroundTypes[getTextureType(textureType)].textureSize = textureSize;
}

waterGroundType = getTextureType("u_water");
cliffGroundType = getTextureType("u_cliff");

SetGroundForTile("tileset/urbanground.txt", "urban_ground");
Expand Down Expand Up @@ -440,7 +437,6 @@ static bool mapLoadGroundTypes(void)
psGroundTypes[getTextureType(textureType)].textureSize = textureSize;
}

waterGroundType = getTextureType("r_water");
cliffGroundType = getTextureType("r_cliff");

SetGroundForTile("tileset/rockieground.txt", "rockie_ground");
Expand Down Expand Up @@ -881,7 +877,7 @@ bool mapLoad(char *filename, bool preview)
// FIXME: magic number
mapTile(i, j)->waterLevel = mapTile(i, j)->height - world_coord(1) / 3;
// lower riverbed
if (mapTile(i, j)->ground == waterGroundType)
if (terrainType(mapTile(i, j)) == TER_WATER && terrainType(mapTile(i-1, j)) == TER_WATER && terrainType(mapTile(i, j-1)) == TER_WATER && terrainType(mapTile(i-1, j-1)) == TER_WATER)
{
mapTile(i, j)->height -= WATER_MIN_DEPTH - mt.u32()%(WATER_MAX_DEPTH + 1 - WATER_MIN_DEPTH);
}
Expand Down Expand Up @@ -994,7 +990,7 @@ bool mapSave(char **ppFileData, UDWORD *pFileSize)
for (int i = 0; i < mapWidth*mapHeight; i++)
{
psTileData->texture = psTile->texture;
if (psTile->ground == waterGroundType)
if (terrainType(psTile) == TER_WATER)
{
psTileData->height = (psTile->waterLevel + world_coord(1) / 3) / ELEVATION_SCALE;
}
Expand Down
2 changes: 0 additions & 2 deletions src/map.h
Expand Up @@ -118,7 +118,6 @@ extern MAPTILE *psMapTiles;
extern float waterLevel;
extern GROUND_TYPE *psGroundTypes;
extern int numGroundTypes;
extern int waterGroundType;
extern int cliffGroundType;
extern char *tileset;

Expand Down Expand Up @@ -346,7 +345,6 @@ extern MAPTILE *psMapTiles;

extern GROUND_TYPE *psGroundTypes;
extern int numGroundTypes;
extern int waterGroundType;
extern int cliffGroundType;
extern char *tileset;

Expand Down
8 changes: 4 additions & 4 deletions src/terrain.cpp
Expand Up @@ -338,10 +338,10 @@ static void averagePos(Vector3i *center, Vector3i *a, Vector3i *b, Vector3i *c,
static bool isWater(int x, int y)
{
bool result = false;
result = result || (tileOnMap(x ,y ) && mapTile(x ,y )->ground == waterGroundType);
result = result || (tileOnMap(x+1,y ) && mapTile(x+1,y )->ground == waterGroundType);
result = result || (tileOnMap(x ,y+1) && mapTile(x ,y+1)->ground == waterGroundType);
result = result || (tileOnMap(x+1,y+1) && mapTile(x+1,y+1)->ground == waterGroundType);
result = result || (tileOnMap(x ,y ) && terrainType(mapTile(x ,y )) == TER_WATER);
result = result || (tileOnMap(x-1,y ) && terrainType(mapTile(x-1,y )) == TER_WATER);
result = result || (tileOnMap(x ,y-1) && terrainType(mapTile(x ,y-1)) == TER_WATER);
result = result || (tileOnMap(x-1,y-1) && terrainType(mapTile(x-1,y-1)) == TER_WATER);
return result;
}

Expand Down

0 comments on commit 8e83aee

Please sign in to comment.