@@ -8,12 +8,13 @@
*/
/** @file base_consist.cpp Properties for front vehicles/consists. */
#include "stdafx.h"
#include "base_consist.h"
#include "vehicle_base.h"
BaseConsist::~BaseConsist()
{
free(this->name);
}
@@ -25,9 +26,19 @@ void BaseConsist::CopyConsistPropertiesF
if (this == src) return;
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);
@@ -15,14 +15,24 @@
#include "order_type.h"
#include "date_type.h"
/** 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();
void CopyConsistPropertiesFrom(const BaseConsist *src);
};
@@ -83,13 +83,13 @@ void OrderBackup::DoRestore(Vehicle *v)
v->CopyConsistPropertiesFrom(this);
/* 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);
/**
@@ -241,21 +241,26 @@ 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_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),
return _order_backup_desc;
static void Save_BKOR()
@@ -236,14 +236,15 @@
* 170 23826
* 171 23835
* 172 23947
* 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
uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -148,17 +148,12 @@ public:
Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract
Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract
Money value; ///< Value of the vehicle
CargoPayment *cargo_payment; ///< The cargo payment we're currently in
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.
Vehicle **hash_viewport_prev; ///< NOSAVE: Previous vehicle in the visual location hash.
Vehicle *hash_tile_next; ///< NOSAVE: Next vehicle in the tile location hash.
@@ -224,21 +219,18 @@ public:
byte day_counter; ///< Increased by one for each day
byte tick_counter; ///< Increased by one for each tick
byte running_ticks; ///< Number of ticks this vehicle was not stopped this day
byte vehstatus; ///< Status
Order current_order; ///< The current order (+ status, like: loading)
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.
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)
NewGRFCache grf_cache; ///< Cache of often used calculated NewGRF values
VehicleCache vcache; ///< Cache of often used vehicle values.
@@ -595,26 +587,17 @@ public:
inline void CopyVehicleConfigAndStatistics(const Vehicle *src)
this->CopyConsistPropertiesFrom(src);
this->unitnumber = src->unitnumber;
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;
bool HandleBreakdown();
bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
Status change: