summaryrefslogtreecommitdiff
path: root/smallmap_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-02-06 09:18:04 +0000
committertron <tron@openttd.org>2006-02-06 09:18:04 +0000
commit453b30e387f8d8ab1839d96b0d1f9a8fea841292 (patch)
tree3a4002304d8204d11c37ba706d6ffbd2e5dfac1b /smallmap_gui.c
parent0755bbead0240f519c9d78bb88ef4629d5ab8fa5 (diff)
downloadopenttd-453b30e387f8d8ab1839d96b0d1f9a8fea841292.tar.xz
(svn r3564) Several smaller changes:
- Don't treat non-booleans as booleans - Reduce variable scope - Bracing - Use DeMorgan's law to make conditionals easier to read - if cascade -> switch - Replace some magic numbers by symbolic names - Avoid assignments within other statements
Diffstat (limited to 'smallmap_gui.c')
-rw-r--r--smallmap_gui.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 6680886c1..03f99eaa3 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -347,12 +347,10 @@ static inline TileType GetEffectiveTileType(TileIndex tile)
if (t == MP_TUNNELBRIDGE) {
t = _m[tile].m5;
if ((t & 0x80) == 0) t >>= 1;
- if ((t & 6) == 0) {
- t = MP_RAILWAY;
- } else if ((t & 6) == 2) {
- t = MP_STREET;
- } else {
- t = MP_WATER;
+ switch (t & 0x06) {
+ case 0x00: t = MP_RAILWAY; break;
+ case 0x02: t = MP_STREET; break;
+ default: t = MP_WATER; break;
}
}
return t;
@@ -642,12 +640,10 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
y = 0;
for (;;) {
- uint32 mask;
+ uint32 mask = 0xFFFFFFFF;
int reps;
int t;
- mask = 0xFFFFFFFF;
-
/* distance from left edge */
if (x < 0) {
if (x < -3) goto skip_column;
@@ -895,7 +891,7 @@ void ShowSmallMap(void)
int x,y;
w = AllocateWindowDescFront(&_smallmap_desc, 0);
- if (w) {
+ if (w != NULL) {
w->click_state = ((1<<5) << _smallmap_type) | (_smallmap_show_towns << 12);
w->resize.width = 350;
w->resize.height = 250;
@@ -993,12 +989,10 @@ void ShowExtraViewPortWindow(void)
int i = 0;
// find next free window number for extra viewport
- while (FindWindowById(WC_EXTRA_VIEW_PORT, i) ) {
- i++;
- }
+ while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
w = AllocateWindowDescFront(&_extra_view_port_desc, i);
- if (w) {
+ if (w != NULL) {
int x, y;
// the main window with the main view
v = FindWindowById(WC_MAIN_WINDOW, 0);