Mercurial > hg > openttd
changeset 8368:b42c4785f6e8 draft
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 20 Jan 2008 18:30:53 +0000 |
parents | b82d9e8a0a21 |
children | cd8726a0f767 |
files | docs/landscape.html src/newgrf_canal.cpp src/openttd.cpp src/water_cmd.cpp src/water_map.h |
diffstat | 5 files changed, 27 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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>
--- 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 @@ * three functions are stubs. */ static uint32 CanalGetRandomBits(const ResolverObject *object) { - return 0; + return GetWaterTileRandomBits(object->u.canal.tile); } @@ -47,6 +48,9 @@ case 0x81: return GetTerrainType(tile); + + case 0x83: + return GetWaterTileRandomBits(tile); } DEBUG(grf, 1, "Unhandled canal property 0x%02X", variable);
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1710,7 +1710,7 @@ 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);
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -56,7 +56,7 @@ /* Non-sealevel -> canal */ if (TileHeight(t) != 0) { - MakeCanal(t, o); + MakeCanal(t, o, Random()); return; } @@ -71,7 +71,7 @@ } } if (has_canal || !has_water) { - MakeCanal(t, o); + MakeCanal(t, o, Random()); } else { MakeWater(t); } @@ -128,7 +128,7 @@ if (o == OWNER_WATER) { MakeWater(tile); } else { - MakeCanal(tile, o); + MakeCanal(tile, o, Random()); } } @@ -305,9 +305,9 @@ 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);
--- a/src/water_map.h +++ b/src/water_map.h @@ -108,6 +108,11 @@ 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 @@ _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; }