Change the way trip history works. It now records ticks and displays time and time...
[openttd-joker.git] / src / triphistory.h
blobe0778b7c8728ce682b02375d06782a997b84fc35
1 /** @file triphistory.h */
3 #ifndef TRIPHISTORY_H
4 #define TRIPHISTORY_H
6 #include "economy_type.h"
7 #include "date_type.h"
8 #include <cmath>
10 // entries to save
11 static const int NUM_TRIP_HISTORY_ENTRIES = 10;
13 struct TripHistoryEntry {
14 Money profit; // Saved
15 Ticks ticks; // Saved
16 int32 profit_change; // Calculated
17 Ticks time_between_trips; // Calculated
18 int32 time_between_trips_change; // Calculated
20 TripHistoryEntry() : profit(0), ticks(0), profit_change(0), time_between_trips(0), time_between_trips_change(0) { };
23 /** Structure to hold data for each vehicle */
24 struct TripHistory {
25 // a lot of saveload stuff for std::deque. So...
26 TripHistoryEntry entries[NUM_TRIP_HISTORY_ENTRIES];
28 Money total_profit;
29 Money avg_profit;
30 Ticks avg_time_between_trips;
32 TripHistory() :
33 total_profit(0),
34 avg_time_between_trips(0),
35 avg_profit(0) { }
38 void AddValue(Money profit, Ticks ticks);
39 int32 FindPercentChange(float current_value, float previous_value);
40 void NewRound();
41 int32 UpdateCalculated(bool update_entries = false);
44 #endif /* TRIPHISTORY_H */