summaryrefslogtreecommitdiff
path: root/gfx.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-11-13 14:54:09 +0000
committertron <tron@openttd.org>2005-11-13 14:54:09 +0000
commit4a14a586e2f457d38e9fede1a494478105a8acfd (patch)
tree0bcf189f35802c7769cd23e20ed58a18b59d9b2e /gfx.c
parentee15e3de13643b2d09abcc5424bf8e2d916cff75 (diff)
downloadopenttd-4a14a586e2f457d38e9fede1a494478105a8acfd.tar.xz
(svn r3173) Use the trinary operator and switch to improve readability
Also align short cases nicely
Diffstat (limited to 'gfx.c')
-rw-r--r--gfx.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/gfx.c b/gfx.c
index c26e4b536..670e62c9f 100644
--- a/gfx.c
+++ b/gfx.c
@@ -434,7 +434,7 @@ void DrawStringMultiCenter(int x, int y, uint16 str, int maxw)
{
char buffer[512];
uint32 tmp;
- int num, w, mt, t;
+ int num, w, mt;
const char *src;
byte c;
@@ -442,12 +442,11 @@ void DrawStringMultiCenter(int x, int y, uint16 str, int maxw)
tmp = FormatStringLinebreaks(buffer, maxw);
num = (uint16)tmp;
- t = tmp >> 16;
- mt = 10;
- if (t != 0) {
- mt = 6;
- if (t != 244) mt = 18;
+ switch (GB(tmp, 16, 16)) {
+ case 0: mt = 10; break;
+ case 244: mt = 6; break;
+ default: mt = 18; break;
}
y -= (mt >> 1) * num;
@@ -481,7 +480,7 @@ void DrawStringMultiLine(int x, int y, uint16 str, int maxw)
{
char buffer[512];
uint32 tmp;
- int num, w, mt, t;
+ int num, w, mt;
const char *src;
byte c;
@@ -489,11 +488,11 @@ void DrawStringMultiLine(int x, int y, uint16 str, int maxw)
tmp = FormatStringLinebreaks(buffer, maxw);
num = (uint16)tmp;
- t = tmp >> 16;
- mt = 10;
- if (t != 0) {
- mt = 6;
- if (t != 244) mt = 18;
+
+ switch (GB(tmp, 16, 16)) {
+ case 0: mt = 10; break;
+ case 244: mt = 6; break;
+ default: mt = 18; break;
}
src = buffer;