summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-07-29 16:48:00 +0000
committerfrosch <frosch@openttd.org>2012-07-29 16:48:00 +0000
commit9527bad3a7fe4098ff2ebe2173e2d7b14d1aaaa7 (patch)
treeda0bb313402db4fcc98c06b17dcca2f945f0af62 /src
parentfcbe53d204ae2f66054c2f93ada1eda46e2ef6b9 (diff)
downloadopenttd-9527bad3a7fe4098ff2ebe2173e2d7b14d1aaaa7.tar.xz
(svn r24446) -Add [FS#5199]: Store more consist properties in order backups.
Diffstat (limited to 'src')
-rw-r--r--src/base_consist.cpp11
-rw-r--r--src/base_consist.h10
-rw-r--r--src/order_backup.cpp2
-rw-r--r--src/saveload/order_sl.cpp23
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/vehicle_base.h17
6 files changed, 38 insertions, 28 deletions
diff --git a/src/base_consist.cpp b/src/base_consist.cpp
index 93b97e10e..005c88672 100644
--- a/src/base_consist.cpp
+++ b/src/base_consist.cpp
@@ -11,6 +11,7 @@
#include "stdafx.h"
#include "base_consist.h"
+#include "vehicle_base.h"
BaseConsist::~BaseConsist()
{
@@ -28,6 +29,16 @@ void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
free(this->name);
this->name = src->name != NULL ? strdup(src->name) : NULL;
+ this->current_order_time = src->current_order_time;
+ this->lateness_counter = src->lateness_counter;
+ this->timetable_start = src->timetable_start;
+
this->service_interval = src->service_interval;
+
this->cur_real_order_index = src->cur_real_order_index;
+ this->cur_implicit_order_index = src->cur_implicit_order_index;
+
+ if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
+ if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE);
+ if (HasBit(src->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME)) SetBit(this->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
}
diff --git a/src/base_consist.h b/src/base_consist.h
index 68303f4d8..5e45d354d 100644
--- a/src/base_consist.h
+++ b/src/base_consist.h
@@ -18,8 +18,18 @@
/** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */
struct BaseConsist {
char *name; ///< Name of vehicle
+
+ /* Used for timetabling. */
+ uint32 current_order_time; ///< How many ticks have passed since this order started.
+ int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
+ Date timetable_start; ///< When the vehicle is supposed to start the timetable.
+
Date service_interval; ///< The interval for (automatic) servicing; either in days or %.
+
VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order
+ VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order
+
+ byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
BaseConsist() : name(NULL) {}
virtual ~BaseConsist();
diff --git a/src/order_backup.cpp b/src/order_backup.cpp
index e6effaf0f..100348f8a 100644
--- a/src/order_backup.cpp
+++ b/src/order_backup.cpp
@@ -86,7 +86,7 @@ void OrderBackup::DoRestore(Vehicle *v)
/* Make sure orders are in range */
v->UpdateRealOrderIndex();
- v->cur_implicit_order_index = v->cur_real_order_index;
+ if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = v->cur_real_order_index;
/* Restore vehicle group */
DoCommand(0, this->group, v->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP);
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index 4637d4a80..c72d982ad 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -244,15 +244,20 @@ static void Ptrs_ORDL()
const SaveLoad *GetOrderBackupDescription()
{
static const SaveLoad _order_backup_desc[] = {
- SLE_VAR(OrderBackup, user, SLE_UINT32),
- SLE_VAR(OrderBackup, tile, SLE_UINT32),
- SLE_VAR(OrderBackup, group, SLE_UINT16),
- SLE_VAR(OrderBackup, service_interval, SLE_INT32),
- SLE_STR(OrderBackup, name, SLE_STR, 0),
- SLE_VAR(OrderBackup, clone, SLE_UINT16),
- SLE_VAR(OrderBackup, cur_real_order_index, SLE_UINT8),
- SLE_REF(OrderBackup, orders, REF_ORDER),
- SLE_END()
+ SLE_VAR(OrderBackup, user, SLE_UINT32),
+ SLE_VAR(OrderBackup, tile, SLE_UINT32),
+ SLE_VAR(OrderBackup, group, SLE_UINT16),
+ SLE_VAR(OrderBackup, service_interval, SLE_INT32),
+ SLE_STR(OrderBackup, name, SLE_STR, 0),
+ SLE_VAR(OrderBackup, clone, SLE_UINT16),
+ SLE_VAR(OrderBackup, cur_real_order_index, SLE_UINT8),
+ SLE_CONDVAR(OrderBackup, cur_implicit_order_index, SLE_UINT8, 176, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderBackup, current_order_time, SLE_UINT32, 176, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderBackup, lateness_counter, SLE_INT32, 176, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderBackup, timetable_start, SLE_INT32, 176, SL_MAX_VERSION),
+ SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT8, 176, SL_MAX_VERSION),
+ SLE_REF(OrderBackup, orders, REF_ORDER),
+ SLE_END()
};
return _order_backup_desc;
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 7cc1da4ed..d49d90a5a 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -239,8 +239,9 @@
* 173 23967 1.2.0-RC1
* 174 23973 1.2.x
* 175 24136
+ * 176 24446
*/
-extern const uint16 SAVEGAME_VERSION = 175; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 176; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 98d741948..6c9ba195e 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -151,11 +151,6 @@ public:
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
- /* Used for timetabling. */
- uint32 current_order_time; ///< How many ticks have passed since this order started.
- int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
- Date timetable_start; ///< When the vehicle is supposed to start the timetable.
-
Rect coord; ///< NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
Vehicle *hash_viewport_next; ///< NOSAVE: Next vehicle in the visual location hash.
@@ -227,15 +222,12 @@ public:
byte vehstatus; ///< Status
Order current_order; ///< The current order (+ status, like: loading)
- VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order
union {
OrderList *list; ///< Pointer to the order list for this vehicle
Order *old; ///< Only used during conversion of old save games
} orders; ///< The orders currently assigned to the vehicle.
- byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
-
uint16 load_unload_ticks; ///< Ticks to wait before starting next cycle.
GroupID group_id; ///< Index of group Pool array
byte subtype; ///< subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes)
@@ -598,20 +590,11 @@ public:
this->unitnumber = src->unitnumber;
- this->cur_implicit_order_index = src->cur_implicit_order_index;
this->current_order = src->current_order;
this->dest_tile = src->dest_tile;
this->profit_this_year = src->profit_this_year;
this->profit_last_year = src->profit_last_year;
-
- this->current_order_time = src->current_order_time;
- this->lateness_counter = src->lateness_counter;
- this->timetable_start = src->timetable_start;
-
- if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
- if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE);
- if (HasBit(src->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME)) SetBit(this->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
}