Changeset - r5761:ad9b5d64995e
[Not reviewed]
master
0 1 0
maedhros - 17 years ago 2007-01-21 15:03:37
maedhros@openttd.org
(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++.
1 file changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/graph_gui.cpp
Show inline comments
 
@@ -37,26 +37,26 @@ typedef struct GraphDrawer {
 
	uint16 unk61C;
 
	int left, top;
 
	uint height;
 
	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)
 
{
 

	
 
	int i,j,k;
 
	uint x,y,old_x,old_y;
 
	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;
 
	int64 value;
 
	int64 cur_val;
 
	uint sel;
 
@@ -113,13 +113,13 @@ static void DrawGraph(const GraphDrawer 
 
		if (!(sel&1)) {
 
			num_x = gw->num_on_x_axis;
 
			assert(num_x > 0);
 
			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);
 
		}
 
	} while (sel>>=1, row_ptr+=24, --num_dataset);
 

	
 
	/* setup scaling */
 
@@ -349,13 +349,13 @@ static void OperatingProfitWndProc(Windo
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			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++;
 
				}
 
			}
 
			numd++;
 
		}
 

	
 
@@ -422,13 +422,13 @@ static void IncomeGraphWndProc(Window *w
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			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++;
 
				}
 
			}
 
			numd++;
 
		}
 

	
 
@@ -495,13 +495,13 @@ static void DeliveredCargoGraphWndProc(W
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			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++;
 
				}
 
			}
 
			numd++;
 
		}
 

	
 
@@ -568,13 +568,13 @@ static void PerformanceHistoryWndProc(Wi
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			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++;
 
				}
 
			}
 
			numd++;
 
		}
 

	
 
@@ -644,13 +644,13 @@ static void CompanyValueGraphWndProc(Win
 

	
 
		numd = 0;
 
		FOR_ALL_PLAYERS(p) {
 
			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++;
 
				}
 
			}
 
			numd++;
 
		}
 

	
 
@@ -742,13 +742,13 @@ static void CargoPaymentRatesWndProc(Win
 
			GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, _cargo_colours[i]);
 
			SetDParam(0, _cargoc.names_s[i]);
 
			DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0);
 
			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);
 
			}
 
		}
 

	
 
		DrawGraph(&gd);
 

	
 
		DrawString(2 + 46, 24 + gd.height + 7, STR_7062_DAYS_IN_TRANSIT, 0);
0 comments (0 inline, 0 general)