diff options
author | maedhros <maedhros@openttd.org> | 2007-01-21 15:03:37 +0000 |
---|---|---|
committer | maedhros <maedhros@openttd.org> | 2007-01-21 15:03:37 +0000 |
commit | 667c4c0a0af13307ce39df3046040e1de9797ce7 (patch) | |
tree | dd6c20cdab1bf34bbda274c25aef0a3163daa0f9 /src | |
parent | e6f033f69294f132d65f907a976c883130f2c812 (diff) | |
download | openttd-667c4c0a0af13307ce39df3046040e1de9797ce7.tar.xz |
(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++.
Diffstat (limited to 'src')
-rw-r--r-- | src/graph_gui.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index de27117a2..244ba05e2 100644 --- 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 *gw) 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 *gw) 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(Window *w, WindowEvent *e) 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, WindowEvent *e) 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(Window *w, WindowEvent *e) 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(Window *w, WindowEvent *e) 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(Window *w, WindowEvent *e) 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(Window *w, WindowEvent *e) 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); } } |