# HG changeset patch # User maedhros # Date 2007-01-21 15:03:37 # Node ID ad9b5d64995ef52bf8e29d00b62481fda0fc4c43 # Parent 339db98780e9528d1ab77af52be445dbaaa8f5f3 (svn r8312) -Fix (r8038, sort of): Operating profit and the company value can be negative, so don't put them in an unsigned variable before drawing them in the various graphs. Although the code didn't change, this only seems to have broken since we started compiling it as C++. diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -40,10 +40,10 @@ typedef struct GraphDrawer { StringID format_str_y_axis; byte color_3, color_2, bg_line_color; byte colors[GRAPH_NUM]; - uint64 cost[GRAPH_NUM][24]; // last 2 years + int64 cost[GRAPH_NUM][24]; // last 2 years } GraphDrawer; -#define INVALID_VALUE 0x80000000 +static const int64 INVALID_VALUE = 0x80000000; static void DrawGraph(const GraphDrawer *gw) { @@ -53,7 +53,7 @@ static void DrawGraph(const GraphDrawer int color; int right, bottom; int num_x, num_dataset; - const uint64 *row_ptr, *col_ptr; + const int64 *row_ptr, *col_ptr; int64 mx; int adj_height; uint64 y_scaling, tmp; @@ -116,7 +116,7 @@ static void DrawGraph(const GraphDrawer col_ptr = row_ptr; do { if (*col_ptr != INVALID_VALUE) { - mx = max((uint64)mx, *col_ptr); + mx = max(mx, *col_ptr); } } while (col_ptr++, --num_x); } @@ -352,7 +352,7 @@ static void OperatingProfitWndProc(Windo if (p->is_active) { gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { - gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)(p->old_economy[j].income + p->old_economy[j].expenses); + gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (p->old_economy[j].income + p->old_economy[j].expenses); i++; } } @@ -425,7 +425,7 @@ static void IncomeGraphWndProc(Window *w if (p->is_active) { gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { - gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].income; + gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : p->old_economy[j].income; i++; } } @@ -498,7 +498,7 @@ static void DeliveredCargoGraphWndProc(W if (p->is_active) { gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { - gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].delivered_cargo; + gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : p->old_economy[j].delivered_cargo; i++; } } @@ -571,7 +571,7 @@ static void PerformanceHistoryWndProc(Wi if (p->is_active) { gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { - gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].performance_history; + gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : p->old_economy[j].performance_history; i++; } } @@ -647,7 +647,7 @@ static void CompanyValueGraphWndProc(Win if (p->is_active) { gd.colors[numd] = _colour_gradient[p->player_color][6]; for (j = gd.num_on_x_axis, i = 0; --j >= 0;) { - gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : (uint64)p->old_economy[j].company_value; + gd.cost[numd][i] = (j >= p->num_valid_stat_ent) ? INVALID_VALUE : p->old_economy[j].company_value; i++; } } @@ -745,7 +745,7 @@ static void CargoPaymentRatesWndProc(Win y += 8; gd.colors[i] = _cargo_colours[i]; for (j = 0; j != 20; j++) { - gd.cost[i][j] = (uint64)GetTransportedGoodsIncome(10, 20, j * 6 + 6, i); + gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, i); } }