mirror of https://github.com/OpenTTD/OpenTTD
(svn r5403) - Feature: Allow building canals at sea-level, using ctrl to toggle canal or plain water tile. This allows building of non-raisable sea-level water ways (useful in multiplayer) and dikes for low-level areas.
parent
b310c78aaa
commit
a12c748f5b
|
@ -151,7 +151,7 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
|
||||||
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
||||||
GUIPlaceProcDragXY(e);
|
GUIPlaceProcDragXY(e);
|
||||||
} else if (e->place.userdata == VPM_X_OR_Y) {
|
} else if (e->place.userdata == VPM_X_OR_Y) {
|
||||||
DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
DoCommandP(e->place.tile, e->place.starttile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ STR_TREES_RANDOM_TYPE :{BLACK}Trees of
|
||||||
STR_TREES_RANDOM_TYPE_TIP :{BLACK}Place trees of random type
|
STR_TREES_RANDOM_TYPE_TIP :{BLACK}Place trees of random type
|
||||||
|
|
||||||
STR_CANT_BUILD_CANALS :{WHITE}Can't build canals here...
|
STR_CANT_BUILD_CANALS :{WHITE}Can't build canals here...
|
||||||
STR_BUILD_CANALS_TIP :{BLACK}Build canals
|
STR_BUILD_CANALS_TIP :{BLACK}Build canals. Press CTRL to place sea tiles (at sea-level only.)
|
||||||
STR_LANDINFO_CANAL :Canal
|
STR_LANDINFO_CANAL :Canal
|
||||||
|
|
||||||
STR_CANT_BUILD_LOCKS :{WHITE}Can't build locks here...
|
STR_CANT_BUILD_LOCKS :{WHITE}Can't build locks here...
|
||||||
|
|
|
@ -110,7 +110,7 @@ bool GUIPlaceProcDragXY(const WindowEvent *we)
|
||||||
GenerateDesertArea(end_tile, start_tile);
|
GenerateDesertArea(end_tile, start_tile);
|
||||||
break;
|
break;
|
||||||
case GUI_PlaceProc_WaterArea >> 4:
|
case GUI_PlaceProc_WaterArea >> 4:
|
||||||
DoCommandP(end_tile, start_tile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
|
||||||
break;
|
break;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -637,7 +637,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
} else if (IsWaterUnderBridge(tile) && TilePixelHeight(tile) != 0) {
|
} else if (IsWaterUnderBridge(tile) && !IsTileOwner(tile, OWNER_WATER)) {
|
||||||
/* delete canal under bridge */
|
/* delete canal under bridge */
|
||||||
|
|
||||||
// check for vehicles under bridge
|
// check for vehicles under bridge
|
||||||
|
@ -710,7 +710,11 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
DoClearSquare(c);
|
DoClearSquare(c);
|
||||||
} else {
|
} else {
|
||||||
if (GetTileSlope(c, NULL) == SLOPE_FLAT) {
|
if (GetTileSlope(c, NULL) == SLOPE_FLAT) {
|
||||||
MakeWater(c);
|
if (IsTileOwner(c, OWNER_WATER)) {
|
||||||
|
MakeWater(c);
|
||||||
|
} else {
|
||||||
|
MakeCanal(c, GetTileOwner(c));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MakeShore(c);
|
MakeShore(c);
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1034,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
} else {
|
} else {
|
||||||
if (ti->tileh == SLOPE_FLAT) {
|
if (ti->tileh == SLOPE_FLAT) {
|
||||||
DrawGroundSprite(SPR_FLAT_WATER_TILE);
|
DrawGroundSprite(SPR_FLAT_WATER_TILE);
|
||||||
if (ti->z != 0) DrawCanalWater(ti->tile);
|
if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile);
|
||||||
} else {
|
} else {
|
||||||
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
DrawGroundSprite(_water_shore_sprites[ti->tileh]);
|
||||||
}
|
}
|
||||||
|
|
30
water_cmd.c
30
water_cmd.c
|
@ -200,7 +200,7 @@ int32 CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
/** Build a piece of canal.
|
/** Build a piece of canal.
|
||||||
* @param tile end tile of stretch-dragging
|
* @param tile end tile of stretch-dragging
|
||||||
* @param p1 start tile of stretch-dragging
|
* @param p1 start tile of stretch-dragging
|
||||||
* @param p2 unused
|
* @param p2 ctrl pressed - toggles ocean / canals at sealevel
|
||||||
*/
|
*/
|
||||||
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't make water of water!
|
// can't make water of water!
|
||||||
if (IsTileType(tile, MP_WATER)) continue;
|
if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) continue;
|
||||||
|
|
||||||
/* is middle piece of a bridge? */
|
/* is middle piece of a bridge? */
|
||||||
if (IsBridgeTile(tile) && IsBridgeMiddle(tile)) {
|
if (IsBridgeTile(tile) && IsBridgeMiddle(tile)) {
|
||||||
|
@ -242,10 +242,10 @@ int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
|
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWaterUnderBridge(tile)) return_cmd_error(STR_1007_ALREADY_BUILT);
|
if (IsWaterUnderBridge(tile) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) return_cmd_error(STR_1007_ALREADY_BUILT);
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (TileHeight(tile) == 0) {
|
if (TileHeight(tile) == 0 && HASBIT(p2, 0)) {
|
||||||
SetWaterUnderBridge(tile);
|
SetWaterUnderBridge(tile);
|
||||||
} else {
|
} else {
|
||||||
SetCanalUnderBridge(tile, _current_player);
|
SetCanalUnderBridge(tile, _current_player);
|
||||||
|
@ -259,7 +259,7 @@ int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
cost += ret;
|
cost += ret;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (TileHeight(tile) == 0) {
|
if (TileHeight(tile) == 0 && HASBIT(p2, 0)) {
|
||||||
MakeWater(tile);
|
MakeWater(tile);
|
||||||
} else {
|
} else {
|
||||||
MakeCanal(tile, _current_player);
|
MakeCanal(tile, _current_player);
|
||||||
|
@ -352,7 +352,18 @@ static bool IsWateredTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_WATER:
|
case MP_WATER:
|
||||||
return !IsCoast(tile);
|
if (!IsCoast(tile)) return true;
|
||||||
|
|
||||||
|
switch (GetTileSlope(tile, NULL)) {
|
||||||
|
case SLOPE_W:
|
||||||
|
case SLOPE_S:
|
||||||
|
case SLOPE_E:
|
||||||
|
case SLOPE_N:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
return IsOilRig(tile) || IsDock(tile) || IsBuoy_(tile);
|
return IsOilRig(tile) || IsDock(tile) || IsBuoy_(tile);
|
||||||
|
@ -436,7 +447,7 @@ static void DrawTile_Water(TileInfo *ti)
|
||||||
switch (GetWaterTileType(ti->tile)) {
|
switch (GetWaterTileType(ti->tile)) {
|
||||||
case WATER_CLEAR:
|
case WATER_CLEAR:
|
||||||
DrawGroundSprite(SPR_FLAT_WATER_TILE);
|
DrawGroundSprite(SPR_FLAT_WATER_TILE);
|
||||||
if (ti->z != 0) DrawCanalWater(ti->tile);
|
if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WATER_COAST:
|
case WATER_COAST:
|
||||||
|
@ -487,7 +498,7 @@ static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
|
||||||
{
|
{
|
||||||
switch (GetWaterTileType(tile)) {
|
switch (GetWaterTileType(tile)) {
|
||||||
case WATER_CLEAR:
|
case WATER_CLEAR:
|
||||||
if (TilePixelHeight(tile) == 0) {
|
if (TilePixelHeight(tile) == 0 || IsTileOwner(tile, OWNER_WATER)) {
|
||||||
td->str = STR_3804_WATER;
|
td->str = STR_3804_WATER;
|
||||||
} else {
|
} else {
|
||||||
td->str = STR_LANDINFO_CANAL;
|
td->str = STR_LANDINFO_CANAL;
|
||||||
|
@ -642,6 +653,9 @@ void TileLoop_Water(TileIndex tile)
|
||||||
{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}}
|
{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Ensure sea-level canals do not flood */
|
||||||
|
if (!IsTileOwner(tile, OWNER_WATER)) return;
|
||||||
|
|
||||||
if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) &&
|
if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) &&
|
||||||
IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) {
|
IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) {
|
||||||
uint i;
|
uint i;
|
||||||
|
|
Loading…
Reference in New Issue