Mercurial > hg > openttd
changeset 3111:ba229b675f02 draft
(svn r3714) Add functions to turn tiles into water and shore tiles
author | tron <tron@openttd.org> |
---|---|
date | Wed, 01 Mar 2006 21:00:44 +0000 |
parents | 9a42b59dcae8 |
children | 3a5e0c62fb5e |
files | landscape.c station_cmd.c water_cmd.c water_map.h |
diffstat | 4 files changed, 45 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/landscape.c +++ b/landscape.c @@ -15,6 +15,7 @@ #include "vehicle.h" #include "variables.h" #include "void.h" +#include "water_map.h" extern const TileTypeProcs _tile_type_clear_procs, @@ -450,9 +451,7 @@ for (tile = 0; tile < MapSize(); ++tile) { if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) { - SetTileType(tile, MP_WATER); - SetTileOwner(tile, OWNER_WATER); - _m[tile].m5 = 0; + MakeWater(tile); } } }
--- a/station_cmd.c +++ b/station_cmd.c @@ -26,6 +26,7 @@ #include "sprite.h" #include "depot.h" #include "train.h" +#include "water_map.h" enum { /* Max stations: 64000 (64 * 1000) */ @@ -1777,12 +1778,8 @@ st->facilities &= ~FACIL_DOCK; st->had_vehicle_of_type &= ~HVOT_BUOY; - ModifyTile(tile, - MP_SETTYPE(MP_WATER) | - MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR, - OWNER_WATER, /* map_owner */ - 0 /* map5 */ - ); + MakeWater(tile); + MarkTileDirtyByTile(tile); UpdateStationVirtCoordDirty(st); DeleteStationIfEmpty(st); @@ -1926,8 +1923,8 @@ if (flags & DC_EXEC) { DoClearSquare(tile1); - // convert the water tile to water. - ModifyTile(tile2, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); + MakeWater(tile2); + MarkTileDirtyByTile(tile2); st->dock_tile = 0; st->facilities &= ~FACIL_DOCK;
--- a/water_cmd.c +++ b/water_cmd.c @@ -16,6 +16,7 @@ #include "depot.h" #include "vehicle_gui.h" #include "train.h" +#include "water_map.h" const SpriteID _water_shore_sprites[15] = { 0, @@ -116,9 +117,10 @@ /* Kill the depot */ DoDeleteDepot(tile); - /* Make the tiles water */ - ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); - ModifyTile(tile2, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); + MakeWater(tile); + MakeWater(tile2); + MarkTileDirtyByTile(tile); + MarkTileDirtyByTile(tile2); } return _price.remove_ship_depot; @@ -258,7 +260,8 @@ // change owner to OWNER_WATER and set land under bridge bit to water ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _m[tile].m5 | 0x08); } else { - ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); + MakeWater(tile); + MarkTileDirtyByTile(tile); } // mark the tiles around dirty too MarkTilesAroundDirty(tile); @@ -532,12 +535,8 @@ case MP_TREES: _current_player = OWNER_WATER; if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { - ModifyTile( - target, - MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | - MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, - OWNER_WATER, 1 - ); + MakeShore(target); + MarkTileDirtyByTile(target); } break; @@ -570,13 +569,8 @@ } if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { - ModifyTile( - target, - MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | - MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, - OWNER_WATER, - 0 - ); + MakeWater(target); + MarkTileDirtyByTile(target); } } }
new file mode 100644 --- /dev/null +++ b/water_map.h @@ -0,0 +1,27 @@ +/* $Id$ */ + +#ifndef WATER_MAP_H +#define WATER_MAP_H + +static inline void MakeWater(TileIndex t) +{ + SetTileType(t, MP_WATER); + SetTileOwner(t, OWNER_WATER); + _m[t].m2 = 0; + _m[t].m3 = 0; + _m[t].m4 = 0; + _m[t].m5 = 0; +} + + +static inline void MakeShore(TileIndex t) +{ + SetTileType(t, MP_WATER); + SetTileOwner(t, OWNER_WATER); + _m[t].m2 = 0; + _m[t].m3 = 0; + _m[t].m4 = 0; + _m[t].m5 = 1; +} + +#endif