diff options
author | tron <tron@openttd.org> | 2005-11-14 19:48:04 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-11-14 19:48:04 +0000 |
commit | 9d0e7b6458124277d850e9bc524d06fd2046c424 (patch) | |
tree | a9ba5d4f3c5c47ab3857060c5f95ed482530ed97 /subsidy_gui.c | |
parent | a7843e154653745799ccdc1288d366ce63ef5802 (diff) | |
download | openttd-9d0e7b6458124277d850e9bc524d06fd2046c424.tar.xz |
(svn r3181) -Bracing
-Indentation
-Whitespace
-DeMorgan's Law
-Test with NULL or 0 for non-booleans
-'\0' instead of 0 for chars
-Remove redundantly redundant comments (like DoFoo(); // Do foo)
-Join multiple short lines with a single statement
-Split single lines with multiple statements
-Avoid assignments in if
Diffstat (limited to 'subsidy_gui.c')
-rw-r--r-- | subsidy_gui.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/subsidy_gui.c b/subsidy_gui.c index 70cc3078c..647cefc3e 100644 --- a/subsidy_gui.c +++ b/subsidy_gui.c @@ -17,14 +17,14 @@ static void HandleSubsidyClick(int y) { const Subsidy* s; - int num,offs; + uint num; + int offs; TileIndex xy; - if (y < 0) - return; + if (y < 0) return; num = 0; - for(s=_subsidies; s != endof(_subsidies); s++) { + for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type != CT_INVALID && s->age < 12) { y -= 10; if (y < 0) goto handle_click; @@ -40,7 +40,7 @@ static void HandleSubsidyClick(int y) y -= 11; if (y < 0) return; - for(s=_subsidies; s != endof(_subsidies); s++) { + for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type != CT_INVALID && s->age >= 12) { y -= 10; if (y < 0) goto handle_click; @@ -78,7 +78,9 @@ static void DrawSubsidiesWindow(const Window* w) { YearMonthDay ymd; const Subsidy* s; - int x,xt,y,num,x2; + uint num; + int x; + int y; DrawWindowWidgets(w); @@ -90,10 +92,12 @@ static void DrawSubsidiesWindow(const Window* w) y += 10; num = 0; - for(s=_subsidies; s != endof(_subsidies); s++) { + for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type != CT_INVALID && s->age < 12) { + int x2; + SetupSubsidyDecodeParam(s, 1); - x2 = DrawString(x+2, y, STR_2027_FROM_TO, 0); + x2 = DrawString(x + 2, y, STR_2027_FROM_TO, 0); SetDParam(0, _date - ymd.day + 384 - s->age * 32); DrawString(x2, y, STR_2028_BY, 0); @@ -103,17 +107,18 @@ static void DrawSubsidiesWindow(const Window* w) } if (num == 0) { - DrawString(x+2, y, STR_202A_NONE, 0); + DrawString(x + 2, y, STR_202A_NONE, 0); y += 10; } - DrawString(x, y+1, STR_202B_SERVICES_ALREADY_SUBSIDISED, 0); + DrawString(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, 0); y += 10; num = 0; - for(s=_subsidies; s != endof(_subsidies); s++) { + for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type != CT_INVALID && s->age >= 12) { const Player* p; + int xt; SetupSubsidyDecodeParam(s, 1); @@ -121,7 +126,7 @@ static void DrawSubsidiesWindow(const Window* w) SetDParam(3, p->name_1); SetDParam(4, p->name_2); - xt = DrawString(x+2, y, STR_202C_FROM_TO, 0); + xt = DrawString(x + 2, y, STR_202C_FROM_TO, 0); SetDParam(0, _date - ymd.day + 768 - s->age * 32); DrawString(xt, y, STR_202D_UNTIL, 0); @@ -130,21 +135,19 @@ static void DrawSubsidiesWindow(const Window* w) } } - if (num == 0) { - DrawString(x+2, y, STR_202A_NONE, 0); - } + if (num == 0) DrawString(x + 2, y, STR_202A_NONE, 0); } static void SubsidiesListWndProc(Window *w, WindowEvent *e) { - switch(e->event) { - case WE_PAINT: DrawSubsidiesWindow(w); break; - case WE_CLICK: { - switch(e->click.widget) { - case 2: HandleSubsidyClick(e->click.pt.y - 25); break; - } - } - break; + switch (e->event) { + case WE_PAINT: DrawSubsidiesWindow(w); break; + + case WE_CLICK: + switch (e->click.widget) { + case 2: HandleSubsidyClick(e->click.pt.y - 25); break; + } + break; } } |