src/water_cmd.cpp
changeset 6857 60130753e595
parent 6683 b88ae30866ce
child 6906 80503931fe10
equal deleted inserted replaced
6856:aa95d0fd29f1 6857:60130753e595
    21 #include "news.h"
    21 #include "news.h"
    22 #include "sound.h"
    22 #include "sound.h"
    23 #include "depot.h"
    23 #include "depot.h"
    24 #include "vehicle_gui.h"
    24 #include "vehicle_gui.h"
    25 #include "train.h"
    25 #include "train.h"
       
    26 #include "roadveh.h"
    26 #include "water_map.h"
    27 #include "water_map.h"
    27 #include "newgrf.h"
    28 #include "newgrf.h"
    28 #include "newgrf_canal.h"
    29 #include "newgrf_canal.h"
    29 
    30 
    30 static const SpriteID _water_shore_sprites[] = {
    31 static const SpriteID _water_shore_sprites[] = {
   639 static void FloodVehicle(Vehicle *v)
   640 static void FloodVehicle(Vehicle *v)
   640 {
   641 {
   641 	if (!(v->vehstatus & VS_CRASHED)) {
   642 	if (!(v->vehstatus & VS_CRASHED)) {
   642 		uint16 pass = 0;
   643 		uint16 pass = 0;
   643 
   644 
   644 		if (v->type == VEH_ROAD) { // flood bus/truck
   645 		if (v->type == VEH_TRAIN || v->type == VEH_ROAD) {
   645 			pass = 1; // driver
       
   646 			if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo_count;
       
   647 
       
   648 			v->vehstatus |= VS_CRASHED;
       
   649 			v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast
       
   650 			RebuildVehicleLists();
       
   651 		} else if (v->type == VEH_TRAIN) {
       
   652 			Vehicle *u;
   646 			Vehicle *u;
   653 
   647 
   654 			v = GetFirstVehicleInChain(v);
   648 			v = GetFirstVehicleInChain(v);
   655 			u = v;
   649 			u = v;
   656 			if (IsFrontEngine(v)) pass = 4; // driver
   650 
   657 
   651 			/* crash all wagons, and count passengers */
   658 			/* crash all wagons, and count passangers */
       
   659 			BEGIN_ENUM_WAGONS(v)
   652 			BEGIN_ENUM_WAGONS(v)
   660 				if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo_count;
   653 				if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo_count;
   661 				v->vehstatus |= VS_CRASHED;
   654 				v->vehstatus |= VS_CRASHED;
   662 				MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
   655 				MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
   663 			END_ENUM_WAGONS(v)
   656 			END_ENUM_WAGONS(v)
   664 
   657 
   665 			v = u;
   658 			v = u;
   666 			v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
   659 
       
   660 			if (v->type == VEH_TRAIN) {
       
   661 				if (IsFrontEngine(v)) pass += 4; // driver
       
   662 				v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
       
   663 			} else {
       
   664 				if (IsRoadVehFront(v)) pass += 1; // driver
       
   665 				v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast
       
   666 			}
       
   667 
   667 			RebuildVehicleLists();
   668 			RebuildVehicleLists();
   668 		} else {
   669 		} else {
   669 			return;
   670 			return;
   670 		}
   671 		}
   671 
   672