From c6e80cdb010364250ec9e904dedaf4acb03ffb86 Mon Sep 17 00:00:00 2001 From: keldorkatarn Date: Tue, 24 Apr 2018 00:54:27 +0200 Subject: [PATCH] Fix some file layouts. --- src/saveload/vehicle_sl.cpp | 45 +++++++++++++++++++++++---------------------- src/triphistory.h | 36 ++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index c1daccca4..d9d2d20e6 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -718,28 +718,29 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDNULL(10, 2, 143), // old reserved space - // Trip History Arrays - SLE_CONDVAR(Vehicle, trip_history.t[0].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[1].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[2].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[3].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[4].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[5].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[6].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[7].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[8].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[9].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[0].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[1].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[2].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[3].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[4].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[5].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[6].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[7].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[8].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, trip_history.t[9].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), - SLE_END() + // Trip History Arrays + SLE_CONDVAR(Vehicle, trip_history.t[0].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[1].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[2].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[3].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[4].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[5].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[6].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[7].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[8].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[9].profit, SLE_INT64, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[0].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[1].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[2].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[3].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[4].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[5].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[6].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[7].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[8].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, trip_history.t[9].date, SLE_FILE_I64 | SLE_VAR_I32, SL_PATCH_PACK, SL_MAX_VERSION), + + SLE_END() }; diff --git a/src/triphistory.h b/src/triphistory.h index bbc6c306a..78282974b 100644 --- a/src/triphistory.h +++ b/src/triphistory.h @@ -12,9 +12,9 @@ // entries to save #define TRIP_LENGTH 10 -static inline int TripHistoryRound( float x ) +static inline int TripHistoryRound(float x) { - return int( x > 0.0 ? x + 0.5 : x - 0.5 ); + return int(x > 0.0 ? x + 0.5 : x - 0.5); } struct TripHistoryEntry { @@ -24,28 +24,28 @@ struct TripHistoryEntry { Date TBT; // Calculated int32 TBT_change; // Calculated - TripHistoryEntry( ) : profit( 0 ), date( 0 ), profit_change( 0 ), TBT( 0 ), TBT_change( 0 ) { }; + TripHistoryEntry() : profit(0), date(0), profit_change(0), TBT(0), TBT_change(0) { }; }; /** Structure to hold data for each vehicle */ struct TripHistory { // a lot of saveload stuff for std::deque. So... - TripHistoryEntry t[ TRIP_LENGTH ]; + TripHistoryEntry t[TRIP_LENGTH]; - Money total_profit; - int32 avg_daylength; + Money total_profit; + int32 avg_daylength; int32 total_change; Money profit_per_day; - TripHistory( ) : - total_profit( 0 ), - avg_daylength( 0 ), - total_change( 0 ), - profit_per_day( 0 ) { } + TripHistory() : + total_profit(0), + avg_daylength(0), + total_change(0), + profit_per_day(0) { } void NewRound(); - void AddValue( Money mvalue, Date dvalue ); + void AddValue(Money mvalue, Date dvalue); /** @@ -53,19 +53,19 @@ struct TripHistory { * * @return size_t number of valid rows */ - size_t UpdateCalculated( ); + size_t UpdateCalculated(); - int32 FindPercentChange( Money v1, Money v2 ) { + int32 FindPercentChange(Money v1, Money v2) { float temp; - if ( v1 > v2 ) { + if (v1 > v2) { temp = v1 - v2; - return TripHistoryRound( ( float ) temp * 100 / ( float ) v1 ); + return TripHistoryRound((float)temp * 100 / (float)v1); } - if ( v2 > v1 ) { + if (v2 > v1) { temp = v1 - v2; - return TripHistoryRound( ( float ) temp * 100 / ( float ) v2 ); + return TripHistoryRound((float)temp * 100 / (float)v2); } return 0; -- 2.11.4.GIT