From 7b02cd3248650d0ece425b7640a9631f2d26c067 Mon Sep 17 00:00:00 2001 From: darkvater Date: Fri, 3 Sep 2004 17:57:27 +0000 Subject: (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs -Fix: [993493] Buildings on water -Feature: Water floods everything, including vehicles. --- clear_cmd.c | 2 +- industry_cmd.c | 9 ++++++++- lang/english.txt | 1 + rail_cmd.c | 2 +- road_cmd.c | 2 +- station_cmd.c | 11 +++++++---- unmovable_cmd.c | 23 ++++------------------- water_cmd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 75 insertions(+), 27 deletions(-) diff --git a/clear_cmd.c b/clear_cmd.c index 0308485e8..6b6445916 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -431,7 +431,7 @@ int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) tile = TILE_FROM_XY(x,y); - if (!CheckTileOwnership(tile)) + if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; if (!EnsureNoVehicle(tile)) diff --git a/industry_cmd.c b/industry_cmd.c index 067a91458..bd955dbab 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -378,7 +378,14 @@ static int32 ClearTile_Industry(uint tile, byte flags) { Industry *i = DEREF_INDUSTRY(_map2[tile]); - if ((_current_player == OWNER_WATER || _game_mode != GM_EDITOR) && !_cheats.magic_bulldozer.value) { + /* * water can destroy industries + * in editor you can bulldoze industries + * with magic_bulldozer cheat you can destroy industries + * (area around OILRIG is water, so water shouldn't flood it + */ + if ((_current_player != OWNER_WATER && _game_mode != GM_EDITOR && + !_cheats.magic_bulldozer.value) || + (_current_player == OWNER_WATER && i->type == IT_OIL_RIG) ) { SET_DPARAM16(0, STR_4802_COAL_MINE + i->type); return_cmd_error(STR_4800_IN_THE_WAY); } diff --git a/lang/english.txt b/lang/english.txt index b22586cb2..cb716832c 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -2520,6 +2520,7 @@ STR_B002_OIL_REFINERY_EXPLOSION :{BLACK}{BIGFONT}Oil refinery explosion near { STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS:{BLACK}{BIGFONT}Factory destroyed in suspicious circumstances near {TOWN}! STR_B004_UFO_LANDS_NEAR :{BLACK}{BIGFONT}'UFO' lands near {TOWN}! STR_B005_COAL_MINE_SUBSIDENCE_LEAVES :{BLACK}{BIGFONT}Coal mine subsidence leaves trail of destruction near {TOWN}! +STR_B006_FLOOD_VEHICLE_DESTROYED :{BLACK}{BIGFONT}Floods!{}At least {COMMA16} presumed missing or dead after deadly floods! STR_BRIBE_FAILED :{WHITE}Your attempted bribery has been STR_BRIBE_FAILED_2 :{WHITE}discovered by a regional investigator diff --git a/rail_cmd.c b/rail_cmd.c index 567e0c973..cff3cea8e 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1151,7 +1151,7 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) static int32 RemoveTrainDepot(uint tile, uint32 flags) { - if (!CheckTileOwnership(tile) && !(_current_player==17)) + if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; if (!EnsureNoVehicle(tile)) diff --git a/road_cmd.c b/road_cmd.c index e782430e0..fa3ea30f1 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -630,7 +630,7 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) static int32 RemoveRoadDepot(uint tile, uint32 flags) { - if (!CheckTileOwnership(tile)) + if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; if (!EnsureNoVehicle(tile)) diff --git a/station_cmd.c b/station_cmd.c index bab692386..b2bd2f54a 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -905,7 +905,7 @@ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 // make sure the specified tile belongs to the current player, and that it is a railroad station. if (!IS_TILETYPE(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR; st = DEREF_STATION(_map2[tile]); - if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR; + if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR; // if we reached here, it means we can actually delete it. do that. if (flags & DC_EXEC) { @@ -948,12 +948,15 @@ uint GetStationPlatforms(Station *st, uint tile) } -static int32 RemoveRailroadStation(Station *st, uint32 flags) +static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) { - uint tile; int w,h; int32 cost; + /* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */ + if (_current_player == OWNER_WATER && _patches.nonuniform_stations) + return DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION); + /* Current player owns the station? */ if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; @@ -2434,7 +2437,7 @@ static int32 ClearTile_Station(uint tile, byte flags) { st = DEREF_STATION(_map2[tile]); if (m5 < 8) - return RemoveRailroadStation(st, flags); + return RemoveRailroadStation(st, tile, flags); // original airports < 67, new airports between 83 - 114 if (m5 < 0x43 || ( m5 >= 83 && m5 <= 114) ) diff --git a/unmovable_cmd.c b/unmovable_cmd.c index 1c6d26f5b..0cdc67a5e 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -114,39 +114,24 @@ static uint GetSlopeTileh_Unmovable(TileInfo *ti) static int32 ClearTile_Unmovable(uint tile, byte flags) { byte m5 = _map5[tile]; - //Town *t; if (m5 & 0x80) { if (_current_player == OWNER_WATER) - return DoCommandByTile(tile, OWNER_WATER, 0, flags, CMD_DESTROY_COMPANY_HQ); + return DoCommandByTile(tile, OWNER_WATER, 0, DC_EXEC, CMD_DESTROY_COMPANY_HQ); return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN); } if (m5 == 3) // company owned land return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA); - //t = ClosestTownFromTile(tile, _patches.dist_local_authority + 20); // needed for town penalty - - // checks if you're allowed to remove unmovable things. no remove under rating "%difficulty setting" - if (_game_mode != GM_EDITOR) { - if (flags & DC_AUTO || !_cheats.magic_bulldozer.value) - return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); - - /*if (!CheckforTownRating(tile, flags, t, UNMOVEABLE_REMOVE)) - return CMD_ERROR; - */ - - } + // checks if you're allowed to remove unmovable things + if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) ) + return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); if (flags & DC_EXEC) { DoClearSquare(tile); - // decreases the town rating by 250; - /*if (_game_mode != GM_EDITOR) - ChangeTownRating(t, -250, -100); - */ } - // return _price.build_industry*0.34; return 0; } diff --git a/water_cmd.c b/water_cmd.c index ef98a0a44..a7740f3e1 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -4,6 +4,9 @@ #include "viewport.h" #include "command.h" #include "town.h" +#include "news.h" + +static void FloodVehicle(Vehicle *v); bool IsShipDepotTile(TileIndex tile) { @@ -506,11 +509,60 @@ static void TileLoopWaterHelper(uint tile, const int16 *offs) } _current_player = OWNER_WATER; + { + Vehicle *v = FindVehicleBetween(tile, tile, 0); + if (v != NULL) {FloodVehicle(v);} + } if (DoCommandByTile(tile,0,0,DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,0); } } +static void FloodVehicle(Vehicle *v) +{ + Vehicle *u; + uint16 pass; + if (!(v->vehstatus & VS_CRASHED)) { + + if (v->type == VEH_Road) { // flood bus/truck + pass = 1; // driver + if (v->cargo_type == CT_PASSENGERS) + pass += v->cargo_count; + + v->vehstatus |= VS_CRASHED; + v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast + InvalidateWindow(WC_ROADVEH_LIST, v->owner); + } + + else if (v->type == VEH_Train) { + v = GetFirstVehicleInChain(v); + u = v; + pass = 4; // driver + + // crash all wagons, and count passangers + BEGIN_ENUM_WAGONS(v) + if (v->cargo_type == CT_PASSENGERS) pass += v->cargo_count; + v->vehstatus |= VS_CRASHED; + END_ENUM_WAGONS(v) + + v = u; + v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast + InvalidateWindow(WC_TRAINS_LIST, v->owner); + } + + InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4); + InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); + + SET_DPARAM16(0, pass); + AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED, + NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), + v->index, + 0); + } + CreateEffectVehicleRel(v,4,4,8,EV_CRASHED_SMOKE); // show cool destruction effects + SndPlayVehicleFx(16, v); // create sound +} + // called from tunnelbridge_cmd void TileLoop_Water(uint tile) { -- cgit v1.2.3-54-g00ecf