From 2fc0cb3e76ec36826056c661555b925b3ce43fe3 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 2 Jun 2009 19:12:28 +0000 Subject: [PATCH] (svn r16505) -Fix [FS#2951] (r16472): since g++ 4.4 the implicit (default) constructor will zero the whole class. This caused all vehicle indices to be 0, which causes all kinds of trouble. --- src/aircraft.h | 2 ++ src/effectvehicle_base.h | 2 ++ src/roadveh.h | 2 ++ src/ship.h | 2 ++ src/train.h | 2 ++ src/vehicle_base.h | 2 ++ 6 files changed, 12 insertions(+) diff --git a/src/aircraft.h b/src/aircraft.h index 1977b82494..b782aae502 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -100,6 +100,8 @@ struct Aircraft : public SpecializedVehicle { StationID targetairport; byte state; + /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ + Aircraft() : SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~Aircraft() { this->PreDestructor(); } diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h index 15c100b062..1f99661eb3 100644 --- a/src/effectvehicle_base.h +++ b/src/effectvehicle_base.h @@ -19,6 +19,8 @@ struct EffectVehicle : public SpecializedVehicle { uint16 animation_state; byte animation_substate; + /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ + EffectVehicle() : SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~EffectVehicle() {} diff --git a/src/roadveh.h b/src/roadveh.h index 7a248b8e76..687cbd313f 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -133,6 +133,8 @@ struct RoadVehicle : public SpecializedVehicle { RoadType roadtype; RoadTypes compatible_roadtypes; + /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ + RoadVehicle() : SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~RoadVehicle() { this->PreDestructor(); } diff --git a/src/ship.h b/src/ship.h index 7e1b2ec6d5..01e337eea4 100644 --- a/src/ship.h +++ b/src/ship.h @@ -20,6 +20,8 @@ void GetShipSpriteSize(EngineID engine, uint &width, uint &height); struct Ship: public SpecializedVehicle { TrackBitsByte state; + /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ + Ship() : SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~Ship() { this->PreDestructor(); } diff --git a/src/train.h b/src/train.h index bcf005472c..b52b52396f 100644 --- a/src/train.h +++ b/src/train.h @@ -314,6 +314,8 @@ struct Train : public SpecializedVehicle { RailTypeByte railtype; RailTypes compatible_railtypes; + /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ + Train() : SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~Train() { this->PreDestructor(); } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index b4a43e2aec..b6bcbb4b61 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -584,6 +584,8 @@ struct DisasterVehicle : public SpecializedVehicle() {} /** We want to 'destruct' the right class. */ virtual ~DisasterVehicle() {}