summaryrefslogtreecommitdiff
path: root/water_cmd.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-09-03 17:57:27 +0000
committerdarkvater <darkvater@openttd.org>2004-09-03 17:57:27 +0000
commit7b02cd3248650d0ece425b7640a9631f2d26c067 (patch)
treea7cb9d6999e2ad750ce6c0217f7e84aa1920584e /water_cmd.c
parentb5a0840621d291ed384f2abac305a850bf1eeea3 (diff)
downloadopenttd-7b02cd3248650d0ece425b7640a9631f2d26c067.tar.xz
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
-Fix: [993493] Buildings on water -Feature: Water floods everything, including vehicles.
Diffstat (limited to 'water_cmd.c')
-rw-r--r--water_cmd.c52
1 files changed, 52 insertions, 0 deletions
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)
{