diff -r 2c27f9be3fb9 -r f82a4facea8b src/industry_gui.cpp --- a/src/industry_gui.cpp Sat Oct 20 10:14:05 2007 +0000 +++ b/src/industry_gui.cpp Sat Oct 20 10:42:28 2007 +0000 @@ -112,28 +112,23 @@ WP(w, fnd_d).timer_enabled = false; } - /* We'll perform two distinct loops, one for secondary industries, and the other one for - * primary ones. Each loop will fill the _fund_gui structure. */ + /* Fill the _fund_gui structure with industries. + * The tests performed after the enabled allow to load the industries + * In the same way they are inserted by grf (if any) + */ for (ind = 0; ind < NUM_INDUSTRYTYPES; ind++) { indsp = GetIndustrySpec(ind); - if (indsp->enabled && (!indsp->IsRawIndustry() || _game_mode == GM_EDITOR)) { + if (indsp->enabled){ + /* Rule is that editor mode loads all industries. + * In game mode, all non raw industries are loaded too + * and raw ones are loaded only when setting allows it */ + if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _patches.raw_industry_construction == 0) continue; _fund_gui.index[_fund_gui.count] = ind; _fund_gui.enabled[_fund_gui.count] = (_game_mode == GM_EDITOR) || CheckIfCallBackAllowsAvailability(ind, IACT_USERCREATION); _fund_gui.count++; } } - if (_patches.raw_industry_construction != 0 && _game_mode != GM_EDITOR) { - for (ind = 0; ind < NUM_INDUSTRYTYPES; ind++) { - indsp = GetIndustrySpec(ind); - if (indsp->enabled && indsp->IsRawIndustry()) { - _fund_gui.index[_fund_gui.count] = ind; - _fund_gui.enabled[_fund_gui.count] = (_game_mode == GM_EDITOR) || CheckIfCallBackAllowsAvailability(ind, IACT_USERCREATION); - _fund_gui.count++; - } - } - } - /* first indutry type is selected. * I'll be damned if there are none available ;) */ WP(w, fnd_d).index = 0; @@ -178,7 +173,7 @@ const IndustrySpec *indsp = GetIndustrySpec(_fund_gui.index[i + w->vscroll.pos]); /* Draw the name of the industry in white is selected, otherwise, in orange */ - DrawString(20, y + offset, indsp->name, selected ? 12 : 6); + DrawStringTruncated(20, y + offset, indsp->name, selected ? 12 : 6, max_width - 25); GfxFillRect(x, y + 1 + offset, x + 10, y + 7 + offset, selected ? 15 : 0); GfxFillRect(x + 1, y + 2 + offset, x + 9, y + 6 + offset, indsp->map_colour); } @@ -296,6 +291,7 @@ } break; case WE_PLACE_OBJ: { + bool success = true; /* We do not need to protect ourselves against "Random Many Industries" in this mode */ const IndustrySpec *indsp = GetIndustrySpec(WP(w, fnd_d).select); @@ -310,17 +306,20 @@ _current_player = OWNER_NONE; _generating_world = true; _ignore_restrictions = true; - if (!TryBuildIndustry(e->we.place.tile, WP(w, fnd_d).select)) { + success = TryBuildIndustry(e->we.place.tile, WP(w, fnd_d).select); + if (!success) { SetDParam(0, indsp->name); ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y); } _ignore_restrictions = false; _generating_world = false; - } else DoCommandP(e->we.place.tile, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); + } else { + success = DoCommandP(e->we.place.tile, WP(w, fnd_d).select, 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); + } - /* Whatever the outcome of the actions, just reset the cursor and the system */ - ResetObjectToPlace(); + /* If an industry has been built, just reset the cursor and the system */ + if (success) ResetObjectToPlace(); } break; case WE_TICK: @@ -504,7 +503,7 @@ if (message != STR_NULL && message != STR_UNDEFINED) { y += 10; - PrepareTextRefStackUsage(); + PrepareTextRefStackUsage(6); DrawString(2, y, message, 0); StopTextRefStackUsage(); }