summaryrefslogtreecommitdiff
path: root/src/vehicle_base.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-22 15:13:50 +0000
committersmatz <smatz@openttd.org>2009-05-22 15:13:50 +0000
commit62a7948af0ca9eb3b190a54918201e1075edcbbc (patch)
tree27a79b7850682cd43cac2462c3410ed8b567c4b2 /src/vehicle_base.h
parent04723b240ebc7384954f73590be517ad2a47ce04 (diff)
downloadopenttd-62a7948af0ca9eb3b190a54918201e1075edcbbc.tar.xz
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r--src/vehicle_base.h29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 087833cb6..955c4f3fe 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -16,7 +16,7 @@
#include "date_type.h"
#include "company_base.h"
#include "company_type.h"
-#include "oldpool.h"
+#include "core/pool.hpp"
#include "order_base.h"
#include "cargopacket.h"
#include "texteff.hpp"
@@ -189,15 +189,18 @@ struct VehicleShip {
TrackBitsByte state;
};
-DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
+typedef Pool<Vehicle, VehicleID, 512, 64000> VehiclePool;
+extern VehiclePool _vehicle_pool;
/* Some declarations of functions, so we can make them friendly */
struct SaveLoad;
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
struct LoadgameState;
extern bool LoadOldVehicle(LoadgameState *ls, int num);
+extern bool AfterLoadGame();
+extern void FixOldVehicles();
-struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
+struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle {
private:
Vehicle *next; ///< pointer to the next vehicle in the chain
Vehicle *previous; ///< NOSAVE: pointer to the previous vehicle in the chain
@@ -207,6 +210,8 @@ private:
Vehicle *previous_shared; ///< NOSAVE: pointer to the previous vehicle in the shared order chain
public:
friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code
+ friend bool AfterLoadGame();
+ friend void FixOldVehicles();
friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the previous and first pointers while loading
friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading
@@ -624,24 +629,6 @@ struct DisasterVehicle : public Vehicle {
bool Tick();
};
-/**
- * This class 'wraps' Vehicle; you do not actually instantiate this class.
- * You create a Vehicle using AllocateVehicle, so it is added to the pool
- * and you reinitialize that to a Train using:
- * v = new (v) Train();
- *
- * As side-effect the vehicle type is set correctly.
- */
-struct InvalidVehicle : public Vehicle {
- /** Initializes the Vehicle to a invalid vehicle */
- InvalidVehicle() { this->type = VEH_INVALID; }
-
- /** We want to 'destruct' the right class. */
- virtual ~InvalidVehicle() {}
-
- const char *GetTypeString() const { return "invalid vehicle"; }
-};
-
#define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start)
#define FOR_ALL_VEHICLES(var) FOR_ALL_VEHICLES_FROM(var, 0)