mirror of https://github.com/OpenTTD/OpenTTD
(svn r3714) Add functions to turn tiles into water and shore tiles
parent
e7e8466fb6
commit
819d210acc
|
@ -15,6 +15,7 @@
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "void.h"
|
#include "void.h"
|
||||||
|
#include "water_map.h"
|
||||||
|
|
||||||
extern const TileTypeProcs
|
extern const TileTypeProcs
|
||||||
_tile_type_clear_procs,
|
_tile_type_clear_procs,
|
||||||
|
@ -450,9 +451,7 @@ void ConvertGroundTilesIntoWaterTiles(void)
|
||||||
|
|
||||||
for (tile = 0; tile < MapSize(); ++tile) {
|
for (tile = 0; tile < MapSize(); ++tile) {
|
||||||
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
|
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h == 0) {
|
||||||
SetTileType(tile, MP_WATER);
|
MakeWater(tile);
|
||||||
SetTileOwner(tile, OWNER_WATER);
|
|
||||||
_m[tile].m5 = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
|
#include "water_map.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* Max stations: 64000 (64 * 1000) */
|
/* Max stations: 64000 (64 * 1000) */
|
||||||
|
@ -1777,12 +1778,8 @@ static int32 RemoveBuoy(Station *st, uint32 flags)
|
||||||
st->facilities &= ~FACIL_DOCK;
|
st->facilities &= ~FACIL_DOCK;
|
||||||
st->had_vehicle_of_type &= ~HVOT_BUOY;
|
st->had_vehicle_of_type &= ~HVOT_BUOY;
|
||||||
|
|
||||||
ModifyTile(tile,
|
MakeWater(tile);
|
||||||
MP_SETTYPE(MP_WATER) |
|
MarkTileDirtyByTile(tile);
|
||||||
MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR,
|
|
||||||
OWNER_WATER, /* map_owner */
|
|
||||||
0 /* map5 */
|
|
||||||
);
|
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
DeleteStationIfEmpty(st);
|
DeleteStationIfEmpty(st);
|
||||||
|
@ -1926,8 +1923,8 @@ static int32 RemoveDock(Station *st, uint32 flags)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
DoClearSquare(tile1);
|
DoClearSquare(tile1);
|
||||||
|
|
||||||
// convert the water tile to water.
|
MakeWater(tile2);
|
||||||
ModifyTile(tile2, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0);
|
MarkTileDirtyByTile(tile2);
|
||||||
|
|
||||||
st->dock_tile = 0;
|
st->dock_tile = 0;
|
||||||
st->facilities &= ~FACIL_DOCK;
|
st->facilities &= ~FACIL_DOCK;
|
||||||
|
|
28
water_cmd.c
28
water_cmd.c
|
@ -16,6 +16,7 @@
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
|
#include "water_map.h"
|
||||||
|
|
||||||
const SpriteID _water_shore_sprites[15] = {
|
const SpriteID _water_shore_sprites[15] = {
|
||||||
0,
|
0,
|
||||||
|
@ -116,9 +117,10 @@ static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
|
||||||
/* Kill the depot */
|
/* Kill the depot */
|
||||||
DoDeleteDepot(tile);
|
DoDeleteDepot(tile);
|
||||||
|
|
||||||
/* Make the tiles water */
|
MakeWater(tile);
|
||||||
ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0);
|
MakeWater(tile2);
|
||||||
ModifyTile(tile2, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0);
|
MarkTileDirtyByTile(tile);
|
||||||
|
MarkTileDirtyByTile(tile2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _price.remove_ship_depot;
|
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
|
// 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);
|
ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _m[tile].m5 | 0x08);
|
||||||
} else {
|
} 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
|
// mark the tiles around dirty too
|
||||||
MarkTilesAroundDirty(tile);
|
MarkTilesAroundDirty(tile);
|
||||||
|
@ -532,12 +535,8 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
|
||||||
case MP_TREES:
|
case MP_TREES:
|
||||||
_current_player = OWNER_WATER;
|
_current_player = OWNER_WATER;
|
||||||
if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
|
if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
|
||||||
ModifyTile(
|
MakeShore(target);
|
||||||
target,
|
MarkTileDirtyByTile(target);
|
||||||
MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR |
|
|
||||||
MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
|
|
||||||
OWNER_WATER, 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -570,13 +569,8 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
|
if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
|
||||||
ModifyTile(
|
MakeWater(target);
|
||||||
target,
|
MarkTileDirtyByTile(target);
|
||||||
MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR |
|
|
||||||
MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,
|
|
||||||
OWNER_WATER,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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