|
@@ -38,14 +38,14 @@ enum {
|
|
|
/* 9 is convenient as that means the distance between them is the height of the graph / 8,
|
|
|
* which is the same
|
|
|
* as height >> 3. */
|
|
|
};
|
|
|
|
|
|
/* Apparently these don't play well with enums. */
|
|
|
static const int64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn.
|
|
|
static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn.
|
|
|
static const OverflowSafeInt64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn.
|
|
|
static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn.
|
|
|
|
|
|
struct GraphDrawer {
|
|
|
uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
|
|
|
byte num_dataset;
|
|
|
byte num_on_x_axis;
|
|
|
bool has_negative_values;
|
|
@@ -67,15 +67,15 @@ struct GraphDrawer {
|
|
|
byte colors[GRAPH_MAX_DATASETS];
|
|
|
Money cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
|
|
|
};
|
|
|
|
|
|
static void DrawGraph(const GraphDrawer *gw)
|
|
|
{
|
|
|
uint x, y; ///< Reused whenever x and y coordinates are needed.
|
|
|
int64 highest_value; ///< Highest value to be drawn.
|
|
|
int x_axis_offset; ///< Distance from the top of the graph to the x axis.
|
|
|
uint x, y; ///< Reused whenever x and y coordinates are needed.
|
|
|
OverflowSafeInt64 highest_value; ///< Highest value to be drawn.
|
|
|
int x_axis_offset; ///< Distance from the top of the graph to the x axis.
|
|
|
|
|
|
/* the colors and cost array of GraphDrawer must accomodate
|
|
|
* both values for cargo and players. So if any are higher, quit */
|
|
|
assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_PLAYERS);
|
|
|
assert(gw->num_vert_lines > 0);
|
|
|
|
|
@@ -512,13 +512,13 @@ static void DeliveredCargoGraphWndProc(W
|
|
|
|
|
|
int numd = 0;
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
if (p->is_active) {
|
|
|
gd.colors[numd] = _colour_gradient[p->player_color][6];
|
|
|
for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
|
|
|
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].delivered_cargo;
|
|
|
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (OverflowSafeInt64)p->old_economy[j].delivered_cargo;
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
numd++;
|
|
|
}
|
|
|
|
|
@@ -579,13 +579,13 @@ static void PerformanceHistoryWndProc(Wi
|
|
|
|
|
|
int numd = 0;
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
if (p->is_active) {
|
|
|
gd.colors[numd] = _colour_gradient[p->player_color][6];
|
|
|
for (int j = gd.num_on_x_axis, i = 0; --j >= 0;) {
|
|
|
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : p->old_economy[j].performance_history;
|
|
|
gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_DATAPOINT : (OverflowSafeInt64)p->old_economy[j].performance_history;
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
numd++;
|
|
|
}
|
|
|
|