diff options
author | rubidium <rubidium@openttd.org> | 2009-10-20 12:31:11 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-10-20 12:31:11 +0000 |
commit | 06c55863ca6b5bff147c2b11f08f7193fc2a9f81 (patch) | |
tree | e0fb63960f5f733fb24b066f452a67f4551f8f67 | |
parent | 9696e3e39bcfa5092221e1db9d75769700f0482b (diff) | |
download | openttd-06c55863ca6b5bff147c2b11f08f7193fc2a9f81.tar.xz |
(svn r17817) -Codechange: MakeWater actually made sea tiles, so rename it to MakeSea and unduplicate the code to make sea, rivers and canals.
-rw-r--r-- | src/saveload/afterload.cpp | 4 | ||||
-rw-r--r-- | src/water_cmd.cpp | 8 | ||||
-rw-r--r-- | src/water_map.h | 59 |
3 files changed, 42 insertions, 29 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 0e663ee1c..de87e71b5 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -926,7 +926,7 @@ bool AfterLoadGame() MakeShore(t); } else { if (GetTileOwner(t) == OWNER_WATER) { - MakeWater(t); + MakeSea(t); } else { MakeCanal(t, GetTileOwner(t), Random()); } @@ -1484,7 +1484,7 @@ bool AfterLoadGame() if (IsWater(t)) { Owner o = GetTileOwner(t); if (o == OWNER_WATER) { - MakeWater(t); + MakeSea(t); } else { MakeCanal(t, o, Random()); } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 7d626c5e1..2c9a3a9af 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -165,7 +165,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o) if (wc == WATER_CLASS_SEA && z > 0) wc = WATER_CLASS_CANAL; switch (wc) { - case WATER_CLASS_SEA: MakeWater(tile); break; + case WATER_CLASS_SEA: MakeSea(tile); break; case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break; case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; default: DoClearSquare(tile); break; @@ -337,7 +337,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (flags & DC_EXEC) { if (TileHeight(tile) == 0 && p2 == 1) { - MakeWater(tile); + MakeSea(tile); } else if (p2 == 2) { MakeRiver(tile, Random()); } else { @@ -947,7 +947,7 @@ void DoFloodTile(TileIndex target) /* flood flat tile */ if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { - MakeWater(target); + MakeSea(target); MarkTileDirtyByTile(target); flooded = true; } @@ -1067,7 +1067,7 @@ void ConvertGroundTilesIntoWaterTiles() * during the generation. */ switch (slope) { case SLOPE_FLAT: - MakeWater(tile); + MakeSea(tile); break; case SLOPE_N: diff --git a/src/water_map.h b/src/water_map.h index 7210c90ca..b266aecc1 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -148,18 +148,6 @@ static inline byte GetWaterTileRandomBits(TileIndex t) } -static inline void MakeWater(TileIndex t) -{ - SetTileType(t, MP_WATER); - SetTileOwner(t, OWNER_WATER); - _m[t].m2 = 0; - _m[t].m3 = WATER_CLASS_SEA; - _m[t].m4 = 0; - _m[t].m5 = 0; - SB(_m[t].m6, 2, 4, 0); - _me[t].m7 = 0; -} - static inline void MakeShore(TileIndex t) { SetTileType(t, MP_WATER); @@ -172,29 +160,54 @@ static inline void MakeShore(TileIndex t) _me[t].m7 = 0; } -static inline void MakeRiver(TileIndex t, uint8 random_bits) +/** + * Helper function for making a watery tile. + * @param t The tile to change into water + * @param o The owner of the water + * @param wc The class of water the tile has to be + * @param random_bits Eventual random bits to be set for this tile + */ +static inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8 random_bits) { SetTileType(t, MP_WATER); - SetTileOwner(t, OWNER_WATER); + SetTileOwner(t, o); _m[t].m2 = 0; - _m[t].m3 = WATER_CLASS_RIVER; + _m[t].m3 = wc; _m[t].m4 = random_bits; _m[t].m5 = 0; SB(_m[t].m6, 2, 4, 0); _me[t].m7 = 0; } +/** + * Make a sea tile. + * @param t The tile to change into sea + */ +static inline void MakeSea(TileIndex t) +{ + MakeWater(t, OWNER_WATER, WATER_CLASS_SEA, 0); +} + +/** + * Make a river tile + * @param t The tile to change into river + * @param random_bits Random bits to be set for this tile + */ +static inline void MakeRiver(TileIndex t, uint8 random_bits) +{ + MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits); +} + +/** + * Make a canal tile + * @param t The tile to change into canal + * @param o The owner of the canal + * @param random_bits Random bits to be set for this tile + */ static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits) { assert(o != OWNER_WATER); - SetTileType(t, MP_WATER); - SetTileOwner(t, o); - _m[t].m2 = 0; - _m[t].m3 = WATER_CLASS_CANAL; - _m[t].m4 = random_bits; - _m[t].m5 = 0; - SB(_m[t].m6, 2, 4, 0); - _me[t].m7 = 0; + MakeWater(t, o, WATER_CLASS_CANAL, random_bits); } static inline void MakeShipDepot(TileIndex t, Owner o, DepotID did, DepotPart base, Axis a, WaterClass original_water_class) |