summaryrefslogtreecommitdiff
path: root/src/depot_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-18 14:56:05 +0000
committerfrosch <frosch@openttd.org>2010-04-18 14:56:05 +0000
commit2e90f7f8b975d380c3d544995ef6db9d6c8a86d8 (patch)
tree90fb0852bd31229b016ca998a8e6c0ce44d699dd /src/depot_gui.cpp
parent2330851d1dc0650335bc73ec4cfd010f08c55742 (diff)
downloadopenttd-2e90f7f8b975d380c3d544995ef6db9d6c8a86d8.tar.xz
(svn r19670) -Codechange: Add CeilDiv() and RoundDiv() to simplify integer divisions with rounding.
Diffstat (limited to 'src/depot_gui.cpp')
-rw-r--r--src/depot_gui.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 6a5d53592..fef980725 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -259,7 +259,7 @@ struct DepotWindow : Window {
DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1, this->sel, free_wagon ? 0 : this->hscroll.GetPosition());
/* Number of wagons relative to a standard length wagon (rounded up) */
- SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
+ SetDParam(0, CeilDiv(u->tcache.cached_total_length, 8));
DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter
break;
}
@@ -692,7 +692,7 @@ struct DepotWindow : Window {
this->vscroll.SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
this->hscroll.SetCount(max_width);
} else {
- this->vscroll.SetCount((this->vehicle_list.Length() + this->hscroll.GetCapacity() - 1) / this->hscroll.GetCapacity());
+ this->vscroll.SetCount(CeilDiv(this->vehicle_list.Length(), this->hscroll.GetCapacity()));
}
/* Setup disabled buttons. */