diff options
author | planetmaker <planetmaker@openttd.org> | 2013-05-06 20:48:18 +0000 |
---|---|---|
committer | planetmaker <planetmaker@openttd.org> | 2013-05-06 20:48:18 +0000 |
commit | a8ba74843439e1ad1157db7621cbd1a5ae10e428 (patch) | |
tree | 5d3f98a9d2544cb8d344f3c45f9126a64586e4f3 /src/newgrf_canal.cpp | |
parent | 26dd535c6b33c54b4d4218f1c90ddb527239bca4 (diff) | |
download | openttd-a8ba74843439e1ad1157db7621cbd1a5ae10e428.tar.xz |
(svn r25229) -Feature: [NewGRF] Variable 0x82 for canals and rivers (dike map)
Diffstat (limited to 'src/newgrf_canal.cpp')
-rw-r--r-- | src/newgrf_canal.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index 13b7e15d6..ef678a0cc 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -13,6 +13,7 @@ #include "debug.h" #include "newgrf_spritegroup.h" #include "newgrf_canal.h" +#include "water.h" #include "water_map.h" /** Table of canal 'feature' sprite groups */ @@ -66,6 +67,29 @@ struct CanalResolverObject : public ResolverObject { /* Terrain type */ case 0x81: return GetTerrainType(this->tile); + /* Dike map: Connectivity info for river and canal tiles + * + * Assignment of bits to directions defined in agreement with + * http://projects.tt-forums.net/projects/ttdpatch/repository/revisions/2367/entry/trunk/patches/water.asm#L879 + * 7 + * 3 0 + * 6 * 4 + * 2 1 + * 5 + */ + case 0x82: { + uint32 connectivity = + (!IsWateredTile(TILE_ADDXY(tile, -1, 0), DIR_SW) << 0) // NE + + (!IsWateredTile(TILE_ADDXY(tile, 0, 1), DIR_NW) << 1) // SE + + (!IsWateredTile(TILE_ADDXY(tile, 1, 0), DIR_NE) << 2) // SW + + (!IsWateredTile(TILE_ADDXY(tile, 0, -1), DIR_SE) << 3) // NW + + (!IsWateredTile(TILE_ADDXY(tile, -1, 1), DIR_W) << 4) // E + + (!IsWateredTile(TILE_ADDXY(tile, 1, 1), DIR_N) << 5) // S + + (!IsWateredTile(TILE_ADDXY(tile, 1, -1), DIR_E) << 6) // W + + (!IsWateredTile(TILE_ADDXY(tile, -1, -1), DIR_S) << 7); // N + return connectivity; + } + /* Random data for river or canal tiles, otherwise zero */ case 0x83: return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0; } |