Mercurial > hg > openttd
changeset 13308:e44c31238b3c draft
(svn r17817) -Codechange: MakeWater actually made sea tiles, so rename it to MakeSea and unduplicate the code to make sea, rivers and canals.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Tue, 20 Oct 2009 12:31:11 +0000 |
parents | d998ec8f4d78 |
children | f571faf401af |
files | src/saveload/afterload.cpp src/water_cmd.cpp src/water_map.h |
diffstat | 3 files changed, 42 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -926,7 +926,7 @@ MakeShore(t); } else { if (GetTileOwner(t) == OWNER_WATER) { - MakeWater(t); + MakeSea(t); } else { MakeCanal(t, GetTileOwner(t), Random()); } @@ -1484,7 +1484,7 @@ if (IsWater(t)) { Owner o = GetTileOwner(t); if (o == OWNER_WATER) { - MakeWater(t); + MakeSea(t); } else { MakeCanal(t, o, Random()); }
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -165,7 +165,7 @@ 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 @@ 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 @@ /* 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 @@ * during the generation. */ switch (slope) { case SLOPE_FLAT: - MakeWater(tile); + MakeSea(tile); break; case SLOPE_N:
--- a/src/water_map.h +++ b/src/water_map.h @@ -148,18 +148,6 @@ } -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 @@ _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)