1 /** @file triphistory.h */
7 #include "window_gui.h"
8 #include "strings_type.h"
9 #include "economy_type.h"
10 #include "date_type.h"
13 #define TRIP_LENGTH 10
15 static inline int TripHistoryRound( float x
)
17 return int( x
> 0.0 ? x
+ 0.5 : x
- 0.5 );
20 struct TripHistoryEntry
{
21 Money profit
; // Saved
23 int32 profit_change
; // Calculated
24 Date TBT
; // Calculated
25 int32 TBT_change
; // Calculated
27 TripHistoryEntry( ) : profit( 0 ), date( 0 ), profit_change( 0 ), TBT( 0 ), TBT_change( 0 ) { };
30 /** Structure to hold data for each vehicle */
32 // a lot of saveload stuff for std::deque. So...
33 TripHistoryEntry t
[ TRIP_LENGTH
];
44 profit_per_day( 0 ) { }
48 void AddValue( Money mvalue
, Date dvalue
);
54 * @return size_t number of valid rows
56 size_t UpdateCalculated( );
58 int32
FindPercentChange( Money v1
, Money v2
) {
63 return TripHistoryRound( ( float ) temp
* 100 / ( float ) v1
);
68 return TripHistoryRound( ( float ) temp
* 100 / ( float ) v2
);
75 #endif /* TRIPHISTORY_H */