summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-01 08:31:36 +0000
committerrubidium <rubidium@openttd.org>2007-09-01 08:31:36 +0000
commit56ab253307c128cd99342ab1b6809e02b3fe9dcc (patch)
tree6358623fdcb900c9c4bcb968c9388b48c33f1cb5 /src/vehicle_gui.cpp
parent0df355bbda0e97edb0c642188db663620dd2e4f6 (diff)
downloadopenttd-56ab253307c128cd99342ab1b6809e02b3fe9dcc.tar.xz
(svn r11031) -Codechange: reduce the amount of duplication of bit counting functions. Based on patches by skidd13, SmatZ and Belugas.
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e2cd1d05c..da36d99f9 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -475,14 +475,6 @@ uint ShowAdditionalText(int x, int y, uint w, EngineID engine)
return DrawStringMultiLine(x, y, STR_02BD, w);
}
-/** Count the number of bits that are set in a mask */
-static uint CountBits(uint32 mask)
-{
- uint c = 0;
- for (; mask != 0; mask >>= 1) if (HASBIT(mask, 0)) c++;
- return c;
-}
-
/** Display list of cargo types of the engine, for the purchase information window */
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine)
{
@@ -493,7 +485,7 @@ uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine)
char *b = _userstring;
/* Draw nothing if the engine is not refittable */
- if (CountBits(cmask) <= 1) return 0;
+ if (COUNTBITS(cmask) <= 1) return 0;
b = InlineString(b, STR_PURCHASE_INFO_REFITTABLE_TO);
@@ -503,7 +495,7 @@ uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine)
} else {
/* Check if we are able to refit to more cargo types and unable to. If
* so, invert the cargo types to list those that we can't refit to. */
- if (CountBits(cmask ^ lmask) < CountBits(cmask)) {
+ if (COUNTBITS(cmask ^ lmask) < COUNTBITS(cmask)) {
cmask ^= lmask;
b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT);
}