diff options
author | peter1138 <peter1138@openttd.org> | 2008-01-20 18:30:53 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-01-20 18:30:53 +0000 |
commit | 9ca929c812fe06cab248feb00fc830e00363ea95 (patch) | |
tree | 87986eebd3e482588635177f36db036e4a2f4124 | |
parent | ffb9ca164ea4661b2d854e00aa81e43b2dc5d852 (diff) | |
download | openttd-9ca929c812fe06cab248feb00fc830e00363ea95.tar.xz |
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
-rw-r--r-- | docs/landscape.html | 8 | ||||
-rw-r--r-- | src/newgrf_canal.cpp | 6 | ||||
-rw-r--r-- | src/openttd.cpp | 2 | ||||
-rw-r--r-- | src/water_cmd.cpp | 10 | ||||
-rw-r--r-- | src/water_map.h | 13 |
5 files changed, 27 insertions, 12 deletions
diff --git a/docs/landscape.html b/docs/landscape.html index cd6a0cf12..ec208b944 100644 --- a/docs/landscape.html +++ b/docs/landscape.html @@ -865,6 +865,11 @@ </tr> <tr> + <td noswap valign=top><tt>02</tt> </td> + <td align=left>river</td> + </tr> + + <tr> <td nowrap valign=top><tt>10</tt>..<tt>1B</tt> </td> <td align=left>canal locks <table> @@ -945,7 +950,8 @@ </tr> </table> </li> - <li>m4: Owner of the water</li> + <li>m4: Owner of the water when ship depot</li> + <li>m4: Random data for canal or river tiles</li> <li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li> <li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li> </ul> diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index f7cc633d7..a2a89d13b 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -11,6 +11,7 @@ #include "newgrf_spritegroup.h" #include "newgrf_canal.h" #include "tile_map.h" +#include "water_map.h" /** Table of canal 'feature' sprite groups */ @@ -21,7 +22,7 @@ const SpriteGroup *_canal_sg[CF_END]; * three functions are stubs. */ static uint32 CanalGetRandomBits(const ResolverObject *object) { - return 0; + return GetWaterTileRandomBits(object->u.canal.tile); } @@ -47,6 +48,9 @@ static uint32 CanalGetVariable(const ResolverObject *object, byte variable, byte case 0x81: return GetTerrainType(tile); + + case 0x83: + return GetWaterTileRandomBits(tile); } DEBUG(grf, 1, "Unhandled canal property 0x%02X", variable); diff --git a/src/openttd.cpp b/src/openttd.cpp index cff06481b..19436ea1e 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1710,7 +1710,7 @@ bool AfterLoadGame() if (GB(_m[t].m5, 3, 2) == 0) { MakeClear(t, CLEAR_GRASS, 3); } else { - MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t)); + MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t), Random()); } } SetBridgeMiddle(t, axis); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index ac90ef20d..eeed4a696 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -56,7 +56,7 @@ void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o) /* Non-sealevel -> canal */ if (TileHeight(t) != 0) { - MakeCanal(t, o); + MakeCanal(t, o, Random()); return; } @@ -71,7 +71,7 @@ void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o) } } if (has_canal || !has_water) { - MakeCanal(t, o); + MakeCanal(t, o, Random()); } else { MakeWater(t); } @@ -128,7 +128,7 @@ void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o) if (o == OWNER_WATER) { MakeWater(tile); } else { - MakeCanal(tile, o); + MakeCanal(tile, o, Random()); } } @@ -305,9 +305,9 @@ CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (TileHeight(tile) == 0 && p2 == 1) { MakeWater(tile); } else if (p2 == 2) { - MakeRiver(tile); + MakeRiver(tile, Random()); } else { - MakeCanal(tile, _current_player); + MakeCanal(tile, _current_player, Random()); } MarkTileDirtyByTile(tile); MarkTilesAroundDirty(tile); diff --git a/src/water_map.h b/src/water_map.h index 98177631b..93ec67a9d 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -108,6 +108,11 @@ static inline byte GetSection(TileIndex t) return GB(_m[t].m5, 0, 4); } +static inline byte GetWaterTileRandomBits(TileIndex t) +{ + return _m[t].m4; +} + static inline void MakeWater(TileIndex t) { @@ -129,24 +134,24 @@ static inline void MakeShore(TileIndex t) _m[t].m5 = 1; } -static inline void MakeRiver(TileIndex t) +static inline void MakeRiver(TileIndex t, uint8 random_bits) { SetTileType(t, MP_WATER); SetTileOwner(t, OWNER_WATER); _m[t].m2 = 0; _m[t].m3 = 0; - _m[t].m4 = 0; + _m[t].m4 = random_bits; _m[t].m5 = 2; } -static inline void MakeCanal(TileIndex t, Owner o) +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 = 0; - _m[t].m4 = 0; + _m[t].m4 = random_bits; _m[t].m5 = 0; } |