mirror of https://github.com/OpenTTD/OpenTTD
(svn r25229) -Feature: [NewGRF] Variable 0x82 for canals and rivers (dike map)
parent
26dd535c6b
commit
a8ba748434
|
@ -13,6 +13,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "newgrf_spritegroup.h"
|
#include "newgrf_spritegroup.h"
|
||||||
#include "newgrf_canal.h"
|
#include "newgrf_canal.h"
|
||||||
|
#include "water.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
|
|
||||||
/** Table of canal 'feature' sprite groups */
|
/** Table of canal 'feature' sprite groups */
|
||||||
|
@ -66,6 +67,29 @@ struct CanalResolverObject : public ResolverObject {
|
||||||
/* Terrain type */
|
/* Terrain type */
|
||||||
case 0x81: return GetTerrainType(this->tile);
|
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 */
|
/* Random data for river or canal tiles, otherwise zero */
|
||||||
case 0x83: return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0;
|
case 0x83: return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o);
|
||||||
|
|
||||||
bool RiverModifyDesertZone(TileIndex tile, void *data);
|
bool RiverModifyDesertZone(TileIndex tile, void *data);
|
||||||
|
|
||||||
|
bool IsWateredTile(TileIndex tile, Direction from);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the maintenance cost of a number of canal tiles.
|
* Calculates the maintenance cost of a number of canal tiles.
|
||||||
* @param num Number of canal tiles.
|
* @param num Number of canal tiles.
|
||||||
|
|
|
@ -548,7 +548,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
|
||||||
* @return true iff the tile is water in the view of 'from'.
|
* @return true iff the tile is water in the view of 'from'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static bool IsWateredTile(TileIndex tile, Direction from)
|
bool IsWateredTile(TileIndex tile, Direction from)
|
||||||
{
|
{
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_WATER:
|
case MP_WATER:
|
||||||
|
|
Loading…
Reference in New Issue