mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r3714) Add functions to turn tiles into water and shore tiles
This commit is contained in:
parent
e7e8466fb6
commit
819d210acc
@ -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 @@ void ConvertGroundTilesIntoWaterTiles(void)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ static int32 RemoveBuoy(Station *st, uint32 flags)
|
||||
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 @@ static int32 RemoveDock(Station *st, uint32 flags)
|
||||
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;
|
||||
|
28
water_cmd.c
28
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 @@ static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
|
||||
/* 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 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
// 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 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
|
||||
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 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
27
water_map.h
Normal file
27
water_map.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user