(svn r8448) -Codechange/Fix (r2993): Also update the helicopter's rotor when loading the game. This can solve crashes when a game is loaded with missing GRF's
authorDarkvater
Sun, 28 Jan 2007 21:53:13 +0000
changeset 6117 b50b5ebc1c98
parent 6116 3c464a271d89
child 6118 99a95cda1174
(svn r8448) -Codechange/Fix (r2993): Also update the helicopter's rotor when loading the game. This can solve crashes when a game is loaded with missing GRF's
src/vehicle.cpp
src/vehicle.h
--- a/src/vehicle.cpp	Sun Jan 28 20:54:30 2007 +0000
+++ b/src/vehicle.cpp	Sun Jan 28 21:53:13 2007 +0000
@@ -234,7 +234,16 @@
 			case VEH_Aircraft:
 				if (IsNormalAircraft(v)) {
 					v->cur_image = GetAircraftImage(v, v->direction);
-					if (v->next != NULL) v->next->cur_image = v->cur_image;
+
+					/* The plane's shadow will have the same image as the plane */
+					Vehicle *shadow = v->next;
+					shadow->cur_image = v->cur_image;
+
+					/* In the case of a helicopter we will update the rotor sprites */
+					if (v->subtype == AIR_HELICOPTER) {
+						Vehicle *rotor = shadow->next;
+						rotor->cur_image = GetRotorImage(v);
+					}
 				}
 				break;
 			default: break;
--- a/src/vehicle.h	Sun Jan 28 20:54:30 2007 +0000
+++ b/src/vehicle.h	Sun Jan 28 21:53:13 2007 +0000
@@ -296,6 +296,7 @@
 int GetAircraftImage(const Vehicle* v, Direction direction);
 int GetRoadVehImage(const Vehicle* v, Direction direction);
 int GetShipImage(const Vehicle* v, Direction direction);
+SpriteID GetRotorImage(const Vehicle *v);
 
 Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
 Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);