Page 1 of 2

A dirty fix to stop industries being deleted ...

Posted: 10 Jan 2008 02:36
by one billion daleks
There's a thread in the Development MB about patching the game's ability to randomly close down and create industries. The patch is a good idea, because whilst this function is fine in computer-generated maps, it's darned annoying to see the game trash a carefully thought-out scenario.

For example, in the scenario I'm currently working on, the game closed down 18 industries in the first two game-years, completely undermining the design of the scenario. This can be rather disheartening, and I believe would tend to discourage players from bothering to create elaborate scenarios once they realised what the game will do to them!

I hope the patch gets into trunk, but at the moment for me the game crashes even when the patch is compiled against a (supposedly) compatible nightly.

So here's a very simple workaround that I came up with for the time being, to prevent the game trashing scenarios, that I thought perhaps might be useful for other players ...

Instead of placing industries into a scenario from the outset, just place a sign at the intended location. Then once the scenario is loaded into the game, use the ingame cheat to switch to an unused player slot (say Player 8 ) ... allocate that player $20 million, then use the 'Fund Industry' to establish the industry when you're ready to connect to it. (Note, you'll probably need to Configure Patches to 'Local Authority being permisssive' about demolishing things!)

Of course, signs can be switched on /off from the tools button, so the map doesn't need to be 'contaminated' with lots of signs being displayed during gameplay.

I've found this simple workaround to be useful, especially as I prefer to develop passenger and mail networks before I start on industries, and this way the scenario is protected from the code's enthusiasm for completely trashing things!

Re: A dirty fix to stop industries being deleted ...

Posted: 10 Jan 2008 05:30
by Bilbo
Wouldn't it be better to fix this properly by a patch? This is a bit awkward solution.

Re: A dirty fix to stop industries being deleted ...

Posted: 10 Jan 2008 06:32
by one billion daleks
Yes certainly, a patch is a far more preferable solution.

This approach is just offered as a suggestion (a dirty fix really, as indicated in the thread title) for anyone using the Scenario Editor, to use as an intermin solution - until a permanent patch is accepted into trunk. There again, there's no indication of plans to permanently address this difficulty with scenarios ... so this approach might turn out to be the only way for scenario creators to get around the glitch. Well, it's the only solution I could think of anyway!

At the moment, when I'm play-testing scenarios, they're all completely trashed within 3 to 5 game-years ... and this makes it impossible to see how factors like city-growth would influence the positioning of farms, forests etc within the scenario.

I'm also testing the use of motorways as a mechanism for limiting the growth and shape of cities, given that town-growth seems to be (conveniently) halted by the presence of dual carriageways ... but if all the industries I've set up in a city get deleted by the game within a few years, it distorts the outcomes for these playtests.

As I hinted in my first post, it really is a complete waste of time trying to create scenarios of any complexity given the current code. But yep, you're right - this is an awkward solution, it is only suggested as a usable workaround for the time being.

Re: A dirty fix to stop industries being deleted ...

Posted: 10 Jan 2008 11:08
by andrewas
A hacky patch to do this involves rewriting CheckIndustryCloseDownProtection in industry_cmd.cpp to always return true. Ill post a diff with a proper patch tonight, if nobody else does it first.

Re: A dirty fix to stop industries being deleted ...

Posted: 10 Jan 2008 13:24
by RMJ
would be so nice with an options if the game, to enable or disable closing and spawning of new industries :)

Re: A dirty fix to stop industries being deleted ...

Posted: 11 Jan 2008 04:10
by one billion daleks
andrewas ... well, occasionally problems do have very simple solutions, so it wouldn't necessarily be a hack.

If all that is needed to fix this is to just set a single Boolean flag somewhere, then hopefully your fix could be added to 'Configure Patches' as a simple on/off option, and find its way into trunk fairly quickly.

Fingers crossed anyway! :)

Re: A dirty fix to stop industries being deleted ...

Posted: 11 Jan 2008 12:34
by andrewas
Actually, you can fix the problem with the other patch - its actually a bug in OTTD, and its being aggravated by additional checking. Patch against revision 11771 or earlier and you wont get that assert, or remove checking in date.cpp, fairly simple to do, check the SVN repository for the relevant diff.

Re: A dirty fix to stop industries being deleted ...

Posted: 11 Jan 2008 15:57
by belugas
one billion daleks wrote:... fix this is to just set a single Boolean flag somewhere, then hopefully your fix could be added to 'Configure Patches' as a simple on/off option, and find its way into trunk fairly quickly.
That is out of the question, as far as i am involved.
andrewas wrote:A hacky patch to do this involves rewriting CheckIndustryCloseDownProtection in industry_cmd.cpp to always return true.
That would not be enough, i fear.
The BEST way to do so would be do play in ChangeIndustryProduction, and follow the work been on the Industry member prod_level.

Re: A dirty fix to stop industries being deleted ...

Posted: 11 Jan 2008 23:56
by one billion daleks
Oh well, never mind.
Actually, I've found the method of creating labels as 'place-holders' for industries is working perfectly well, and isn't proving awkward at all.
So this workaround has made the problem with industry go away. Now I just get the occasional new industry generated, and those ones can just be left in situ, or demolished by the player.

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 09:42
by Nemesis
use the ingame cheat to switch to an unused player slot (say Player 8 ) ... allocate that player $20 million
And how do you do this?

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 10:08
by one billion daleks
The ingame cheats are accessed with keypress [Ctrl][Alt][C]

But if this doesn't work, then it will be because you already have [Ctrl][Alt][C] defined to perform some other function on your PC. For example, I used to have it set up as a keyboard shortcut to access the Windows Calculator. So I had to redefine that shortcut to something else before the OTTD cheats could be accessed.

You'll see a message saying "By using cheats, you betray your fellow competitors. Keep in mind that such a disgrace will be remembered for eternity" ...

... but hey, I wouldn't worry about that! :) ...
... as far as I'm concerned, cheats are essential to make the game run properly! ;)

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 11:45
by Bilbo
one billion daleks wrote:But if this doesn't work, then it will be because you already have [Ctrl][Alt][C] defined to perform some other function on your PC. For example, I used to have it set up as a keyboard shortcut to access the Windows Calculator. So I had to redefine that shortcut to something else before the OTTD cheats could be accessed.
I wrote a patch than allowed also to use Ctrl+alt+shift+C in these cases (as ctrl+alt+something is very often used as hotkey for something) but the patch was rejected for trunk.
As I can't redefine the ctrl-alt-c shortcut (it is non-redefinable as it is in openttd) I can't use cheats unless I compile my own version with the patch.

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 12:44
by one billion daleks
That's odd that your patch was rejected Bilbo, as it sounds like a perfectly reasonable idea to me!

Another alternative would be to activate cheats from the console, like in other games, but I couldn't find anything on the wiki that says you can use that method.

So how come you can't redefine [Ctrl][Alt][C] on your PC ... what happens when you use that hotkey outside the game ...?

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 13:23
by Nemesis
Doesn't work with Beta 2.

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 13:29
by one billion daleks
Oh, I didn't know that ... I'm running beta-1.
Do you know if that's a bug in beta-2, or a deliberate change to the code ...?

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 14:26
by sforget
In windows versions the cheat is: [ctrl] + [alt] + [WIN] + [C] (WIN = Windows Key)

Re: A dirty fix to stop industries being deleted ...

Posted: 12 Jan 2008 14:57
by Bilbo
sforget wrote:In windows versions the cheat is: [ctrl] + [alt] + [WIN] + [C] (WIN = Windows Key)
I know, I read than on the wiki too. Unfortunatly, my keyboard lacks the "windows" keys, so I cannot use this either. I find them annoying, so I actually never bought a keyboard equipped with them.

Re: A dirty fix to stop industries being deleted ...

Posted: 13 Jan 2008 10:02
by Nemesis
sforget wrote:In windows versions the cheat is: [ctrl] + [alt] + [WIN] + [C] (WIN = Windows Key)
Yes.. this worked.. whaha.. what a great function. Crossing tunnels.. is really a neat function!!!

Re: A dirty fix to stop industries being deleted ...

Posted: 13 Jan 2008 10:45
by one billion daleks
That's good news Nemesis ... now you can switch off those pesky AI players and start managing all eight companies y'self! ;)

Re: A dirty fix to stop industries being deleted ...

Posted: 14 Jan 2008 08:00
by Nemesis
one billion daleks wrote:That's good news Nemesis ... now you can switch off those pesky AI players and start managing all eight companies y'self! ;)

I never play with the computer. They ruin (?) the world!