Disable Open and Closure of Industries

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Disable Open and Closure of Industries

Post by burty »

http://www.tt-forums.net/viewtopic.php? ... 8&p=737264

See that post for the specification of this patch.

Version History
0.0.1 - Initial Release 17/10/08

o Added the choice to advanced settings to chose none or all are able to close
o Built against R14469

0.0.2 Added Open option as well 17/10/08
o Added the ability to stop industries opening.

0.0.3 18/10/08
o Update so that you do not have 'empty' primary industries any more.

Please can you post if you notice any weirdness with the opening and/or closing sections.
Also please post if the empty primaries do appear when this is enabled, thank you.


NOTE: code breaks the NewGRF specification and therefore, it may break NewIndustry GRF
Attachments
industry_open_close.patch
Patch
(6.34 KiB) Downloaded 155 times
OTTD.zip
Binary v0.0.3
(2.81 MiB) Downloaded 130 times
Last edited by burty on 19 Oct 2008 16:23, edited 3 times in total.
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: Disable Open and Closure of Industries

Post by Hirundo »

This is quite a nice option, although I doubt whether the devs will ever accept this because NewGRF is the preferred format. Even so it really has its benefits and personally I'd like to see this in-game.

Please allow me to give some comments about this patch:
patch wrote:{LTBLUE}Industries Allowed To Close During Gameplay {ORANGE}{STRING1}
Not Every Word Of A String Has To Be Capitalized.

Don't add the strings for openable industries if the option is not implemented (yet?)
patch wrote:if (_settings_game.construction.closeable_industries == 0) {
if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
Merge this into a single if(..)

SDT_VAR() breaks savegame compatibility because openttd now expects the variable in every savegame it opens, which is obviously not the case in older saves. Use SDT_CONDVAR() instead.
Create your own NewGRF? Check out this tutorial!
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

Sorry mate i forgot to thank you :( REALLY sorry man,
Thank you loads and loads for that :D.


Updated first post with new versions


Edit: Sorry mate forgot to thank you :(
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Disable Open and Closure of Industries

Post by CommanderZ »

Sounds good.

Btw I think it should be stored in savegames - it would allow for scenarios to have it as default "build-in" (but still disablable) option. I think most well-done scenarios like the Cindini really don't make sense with enabled closures and openings.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

CommanderZ wrote:Sounds good.

Btw I think it should be stored in savegames - it would allow for scenarios to have it as default "build-in" (but still disablable) option. I think most well-done scenarios like the Cindini really don't make sense with enabled closures and openings.

Thank you :D, i have (i think put it in save games).
The older save games do not work with this but then that does not surprise me... that may be something i look into for future refernce :D.
Thank you CommanderZ :D.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Disable Open and Closure of Industries

Post by Roujin »

You can preserve backward compatibility if you do it correctly..

To do it, you need to increase the version number (in saveload.cpp) by one, compared to the trunk version you based it on, and make all saved patch settings conditional (like Swallow said). That means they will only be expected in a certain range of revisions. And for this range you specify [number you increased to in saveload.cpp] to SL_MAX_VERSION.


PS: after looking at your code, you already use CONDVAR for one of them, but VAR for the other :? also you use the amount of parameters for the VAR line that would be expected by a CONDVAR.. :? I think you should change it to CONDVAR too. This in combination with bumping the savegame version and using that version where now stands "77" should solve the backward compatibility problem.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Disable Open and Closure of Industries

Post by Alberth »

I don't think you are there yet.
You have disabled actually closing of industry, but afaik all primary industries get exhausted when used, so your game will end up with a lot of 'empty' primary industries.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

Updated First Post with new Versions
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Disable Open and Closure of Industries

Post by CommanderZ »

Did you test this with ECS/Pikka's industries?
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

No this is a CLEAN OTTD eg No GRFs played with.
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Disable Open and Closure of Industries

Post by CommanderZ »

burty wrote:No this is a CLEAN OTTD eg No GRFs played with.

I mean...what does it do, when a GRF requests an industry closure? It just ignores the request?
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

CommanderZ wrote:
burty wrote:No this is a CLEAN OTTD eg No GRFs played with.

I mean...what does it do, when a GRF requests an industry closure? It just ignores the request?
To be honest i do not know since i rarely play with anything more than plain OTTD :D, i will try now but if the GRF requests the closure in the same way as normal industries do then yes the GRF request would be ignored however i am guessing it is not as simple as that therefore meaning that GRFs can still close industries.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

I tested this with Chemical vectors GRF and it seems that the chem plants did NOT close.
I played for ~roughly~ ONE game year give or take a month :D.
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: Disable Open and Closure of Industries

Post by PhilSophus »

burty wrote:I tested this with Chemical vectors GRF and it seems that the chem plants did NOT close.
I played for ~roughly~ ONE game year give or take a month :D.
Well, I guess the real question is not if they don't close (they won't if you don't let them :wink:), but if they are well-behaving after they requested closure. I doubt that NewGRF authors coded state transitions from closed state to a usable state, as that just can't happen normally. And even if by luck (or should I say by accident) it seems to work cleanly it can break at any time, so you should state clearly that your code breaks the NewGRF specification and therefore, it may break NewIndustry GRFs (you might have known that if you had read and understood the current topics on that in TTDPatch Graphics and OpenTTD Graphics forums :roll:).

BTW, one game year is not enough to test that given that ECS industries are protected of closure in the first five years.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Disable Open and Closure of Industries

Post by Terkhen »

This patch is great, I always play with it :D

I've run into the same problem Alberth has, though. Industries end having such a low production that you can't pick any cargo on them. Sometimes I have to enable closure just to get them out of the map.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Disable Open and Closure of Industries

Post by belugas »

Hehehe... how UNEXPECTED!

NOT!

It's nice people start to realize finally the price of simply preventing industry closure :)

/me feels rejoyced!
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: Disable Open and Closure of Industries

Post by SirkoZ »

Terkhen wrote:This patch is great, I always play with it :D

I've run into the same problem Alberth has, though. Industries end having such a low production that you can't pick any cargo on them. Sometimes I have to enable closure just to get them out of the map.
Well, Terkhen - and to rain on belugas' parade some - you can get those industries up, though gradually. The whole point of this patch is for such beautifully crafted scenarios as aforementioned, not for just any random game. If of course I make a newGRF for such behaviour (though limited to default industry set), it can be then used for such scenarios...
hickop
Engineer
Engineer
Posts: 16
Joined: 18 Nov 2008 23:01

Re: Disable Open and Closure of Industries

Post by hickop »

I wished this patch work with Pika's Basic Industries.
I'm getting so disappointed when I'm done building a station/network and seeing the industry next to it vanish the second after.

This is in my opinion a must have feature for advanced settings.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

I would be willing to get it working with NewGRF industries but would need someone who has knowledge of the workings (c++ code side) of the NewGRFs as whenever I have looked in there I end up go around in forever increasing circles and closeing the program for the next 2months.

Since the source is open as is this patch I am sure someone may be able to patch the patch to work with Pikka's sets
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Disable Open and Closure of Industries

Post by burty »

As requested updated to trunk
Attachments
industry_open_close 15879.patch
(5.08 KiB) Downloaded 79 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 35 guests