(svn r11934) -Codechange: add persistent random data for river and canal tiles.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
peter1138 17 years ago
parent ffb9ca164e
commit 9ca929c812

@ -864,6 +864,11 @@
<td align=left>coast or riverbank</td>
</tr>
<tr>
<td noswap valign=top><tt>02</tt>&nbsp; </td>
<td align=left>river</td>
</tr>
<tr>
<td nowrap valign=top><tt>10</tt>..<tt>1B</tt>&nbsp; </td>
<td align=left>canal locks
@ -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>

@ -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);

@ -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);

@ -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);

@ -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;
}

Loading…
Cancel
Save