From 8e83aee47e24bb0dd1c7c2b3a1ac53be25890506 Mon Sep 17 00:00:00 2001 From: haonoq Date: Thu, 9 Aug 2012 13:15:04 +0400 Subject: [PATCH] Old map conversion fix 1: water fix, water no longer climbs cliffs. --- src/bridge.cpp | 4 ++-- src/map.cpp | 8 ++------ src/map.h | 2 -- src/terrain.cpp | 8 ++++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/bridge.cpp b/src/bridge.cpp index 3f126f877..9143c2fa9 100644 --- a/src/bridge.cpp +++ b/src/bridge.cpp @@ -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; @@ -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; diff --git a/src/map.cpp b/src/map.cpp index 4a4048af5..a1a592b71 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -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; @@ -356,7 +355,6 @@ fallback: psGroundTypes[getTextureType(textureType)].textureSize = textureSize ; } - waterGroundType = getTextureType("a_water"); cliffGroundType = getTextureType("a_cliff"); SetGroundForTile("tileset/arizonaground.txt", "arizona_ground"); @@ -398,7 +396,6 @@ fallback: psGroundTypes[getTextureType(textureType)].textureSize = textureSize; } - waterGroundType = getTextureType("u_water"); cliffGroundType = getTextureType("u_cliff"); SetGroundForTile("tileset/urbanground.txt", "urban_ground"); @@ -440,7 +437,6 @@ fallback: psGroundTypes[getTextureType(textureType)].textureSize = textureSize; } - waterGroundType = getTextureType("r_water"); cliffGroundType = getTextureType("r_cliff"); SetGroundForTile("tileset/rockieground.txt", "rockie_ground"); @@ -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); } @@ -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; } diff --git a/src/map.h b/src/map.h index 43f800c29..4369540f5 100644 --- a/src/map.h +++ b/src/map.h @@ -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; @@ -346,7 +345,6 @@ extern MAPTILE *psMapTiles; extern GROUND_TYPE *psGroundTypes; extern int numGroundTypes; -extern int waterGroundType; extern int cliffGroundType; extern char *tileset; diff --git a/src/terrain.cpp b/src/terrain.cpp index 03ab57b39..0385c9a7a 100644 --- a/src/terrain.cpp +++ b/src/terrain.cpp @@ -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; }