# HG changeset patch # User Darkvater # Date 1154271400 0 # Node ID 18a32dace8ba09240015858b12329c27447134be # Parent ef08dda0369edce3b78f734c55abeff3699453f6 (svn r5654) -Cleanup: Change an ugly define into a function diff -r ef08dda0369e -r 18a32dace8ba industry_gui.c --- a/industry_gui.c Sun Jul 30 14:55:25 2006 +0000 +++ b/industry_gui.c Sun Jul 30 14:56:40 2006 +0000 @@ -270,7 +270,12 @@ AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0); } -#define NEED_ALTERB ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES)) +static inline bool IsProductionAlterable(const Industry *i) +{ + return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && + (i->accepts_cargo[0] == CT_INVALID || i->accepts_cargo[0] == CT_VALUABLES)); +} + static void IndustryViewWndProc(Window *w, WindowEvent *e) { // WP(w,vp2_d).data_1 is for the editbox line @@ -307,20 +312,19 @@ SetDParam(1, i->total_production[0]); SetDParam(2, i->pct_transported[0] * 100 >> 8); - DrawString(4 + (NEED_ALTERB ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); + DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); // Let's put out those buttons.. - if (NEED_ALTERB) + if (IsProductionAlterable(i)) DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, true); if (i->produced_cargo[1] != CT_INVALID) { SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]); SetDParam(1, i->total_production[1]); SetDParam(2, i->pct_transported[1] * 100 >> 8); - DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); + DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); // Let's put out those buttons.. - if (NEED_ALTERB) { + if (IsProductionAlterable(i)) DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, true); - } } } @@ -338,7 +342,7 @@ i = GetIndustry(w->window_number); // We should work if needed.. - if (!NEED_ALTERB) return; + if (!IsProductionAlterable(i)) return; x = e->click.pt.x; line = (e->click.pt.y - 127) / 10;