summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-13 19:24:40 +0000
committersmatz <smatz@openttd.org>2008-02-13 19:24:40 +0000
commitfe48d0be219f2035b146c6444c92c305d9c3bedf (patch)
treeaf07b8c3ed3437ba91111379ab438956940c60bb /src/vehicle_gui.cpp
parent833a00def99ecf91bce955e35b82b33e4b7d5517 (diff)
downloadopenttd-fe48d0be219f2035b146c6444c92c305d9c3bedf.tar.xz
(svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
-Fix [FS#1739]: vehicle profit is now counted with 8bit fract, so it is now shown properly in the vehicle details window
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 3a5d1f4ec..38a864a22 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -173,7 +173,7 @@ void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
pal = PALETTE_TO_GREY;
} else if (v->profit_last_year < 0) {
pal = PALETTE_TO_RED;
- } else if (v->profit_last_year < 10000) {
+ } else if (v->profit_last_year >> 8 < 10000) {
pal = PALETTE_TO_YELLOW;
} else {
pal = PALETTE_TO_GREEN;
@@ -598,7 +598,7 @@ static int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
{
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
- int r = ClampToI32(va->profit_last_year - vb->profit_last_year);
+ int r = ClampToI32((va->profit_last_year - vb->profit_last_year) >> 8);
VEHICLEUNITNUMBERSORTER(r, va, vb);
@@ -983,8 +983,8 @@ static void DrawVehicleListWindow(Window *w)
const Vehicle *v = vl->sort_list[i];
StringID str;
- SetDParam(0, v->profit_this_year);
- SetDParam(1, v->profit_last_year);
+ SetDParam(0, v->profit_this_year >> 8);
+ SetDParam(1, v->profit_last_year >> 8);
DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
@@ -1500,8 +1500,8 @@ static void DrawVehicleDetailsWindow(Window *w)
}
/* Draw profit */
- SetDParam(0, v->profit_this_year);
- SetDParam(1, v->profit_last_year);
+ SetDParam(0, v->profit_this_year >> 8);
+ SetDParam(1, v->profit_last_year >> 8);
DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
/* Draw breakdown & reliability */