(svn r10983) -Codechange: use vehstatus & VS_CRASHED instead of some other "methods" custom to each vehicle to determine whether the vehicle is crashed.
authorrubidium
Sun, 26 Aug 2007 20:16:02 +0000
changeset 7972 dff055fff851
parent 7971 c1b1fa49885a
child 7973 ce69b7781d4a
(svn r10983) -Codechange: use vehstatus & VS_CRASHED instead of some other "methods" custom to each vehicle to determine whether the vehicle is crashed.
src/roadveh_cmd.cpp
src/train_cmd.cpp
--- a/src/roadveh_cmd.cpp	Sun Aug 26 14:38:44 2007 +0000
+++ b/src/roadveh_cmd.cpp	Sun Aug 26 20:16:02 2007 +0000
@@ -534,7 +534,7 @@
 	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
 
 	if (v->vehstatus & VS_STOPPED ||
-			v->u.road.crashed_ctr != 0 ||
+			v->vehstatus & VS_CRASHED ||
 			v->breakdown_ctr != 0 ||
 			v->u.road.overtaking != 0 ||
 			v->u.road.state == RVSB_WORMHOLE ||
@@ -1794,7 +1794,7 @@
 	if (v->u.road.reverse_ctr != 0) v->u.road.reverse_ctr--;
 
 	/* handle crashed */
-	if (v->u.road.crashed_ctr != 0) {
+	if (v->vehstatus & VS_CRASHED) {
 		RoadVehIsCrashed(v);
 		return;
 	}
--- a/src/train_cmd.cpp	Sun Aug 26 14:38:44 2007 +0000
+++ b/src/train_cmd.cpp	Sun Aug 26 20:16:02 2007 +0000
@@ -1645,8 +1645,8 @@
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 		}
 	} else {
-		/*turn the whole train around */
-		if (v->u.rail.crash_anim_pos != 0 || v->breakdown_ctr != 0) return CMD_ERROR;
+		/* turn the whole train around */
+		if (v->vehstatus & VS_CRASHED || v->breakdown_ctr != 0) return CMD_ERROR;
 
 		if (flags & DC_EXEC) {
 			if (_patches.realistic_acceleration && v->cur_speed != 0) {
@@ -3255,7 +3255,7 @@
 static void TrainLocoHandler(Vehicle *v, bool mode)
 {
 	/* train has crashed? */
-	if (v->u.rail.crash_anim_pos != 0) {
+	if (v->vehstatus & VS_CRASHED) {
 		if (!mode) HandleCrashedTrain(v);
 		return;
 	}