(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type

This commit is contained in:
smatz
2009-05-30 20:13:12 +00:00
parent 7633362912
commit 8c11d612e4
7 changed files with 8 additions and 21 deletions

View File

@@ -182,7 +182,7 @@ public:
VehicleCache vcache; ///< Cache of often used calculated values
/** Create a new vehicle */
Vehicle();
Vehicle(VehicleType type = VEH_INVALID);
/** Destroy all stuff that (still) needs the virtual functions to work properly */
void PreDestructor();
@@ -502,6 +502,11 @@ template <class T, VehicleType Type>
struct SpecializedVehicle : public Vehicle {
static const VehicleType EXPECTED_TYPE = Type; ///< Specialized type
/**
* Set vehicle type correctly
*/
FORCEINLINE SpecializedVehicle<T, Type>() : Vehicle(Type) { }
/**
* Get the first vehicle in the chain
* @return first vehicle in the chain
@@ -559,9 +564,6 @@ struct DisasterVehicle : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER
uint16 image_override;
VehicleID big_ufo_destroyer_target;
/** Initializes the Vehicle to a disaster vehicle */
DisasterVehicle() { this->type = VEH_DISASTER; }
/** We want to 'destruct' the right class. */
virtual ~DisasterVehicle() {}