changeset 5761:94b3a1048604 draft

(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++.
author maedhros <maedhros@openttd.org>
date Sun, 21 Jan 2007 15:03:37 +0000
parents 0b7188ebfc0f
children 102ded141250
files src/graph_gui.cpp
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -40,10 +40,10 @@
 	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 @@
 	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 @@
 			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 @@
 			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 @@
 			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 @@
 			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 @@
 			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 @@
 			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 @@
 			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);
 			}
 		}