[PATCH] new disasters framework

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

Post Reply
dev_null42
Engineer
Engineer
Posts: 4
Joined: 13 Jun 2007 02:36

[PATCH] new disasters framework

Post by dev_null42 »

Many years ago I proposed a new disasters framework (http://www.tt-forums.net/viewtopic.php?f=33&t=32514). I finally got around to writing it, and attached to this post is a patch that changes a number of things with disasters:

1. Instead of a single disaster timer (_disaster_delay), each non-vehicle disaster has its own timer. When the timer reaches zero, there is a chance that disaster can be triggered. On the rare setting, this is 1 in 8; for normal it is 1 in 4; for frequent it is 1 in 2. Furthermore, specific disasters can be disabled.

1a. A side effect of having concurrent timers is that multiple disasters can occur in a short amount of time.
1b. I changed the start and stop years for the disasters. There is no reason why coal mines stop collapsing in 1985.

2. There is a console command, "disaster", which can be used to introspect the new disaster system. Disasters can be invoked manually from the console; see the usage text for "disaster".

3. This applies bumps the saved game version to 154. For save files prior to 154, the old _disaster_delay value is used to initialize all disaster timers.

The first screenshot shows the console in use. In this situation, both a coal mine and small UFO occurred. [attachment=2]Multiple Disasters.png[/attachment]

The second screenshot shows how one can adjust disaster settings. UFOs, for example, are disabled in this screenshot. [attachment=0]Disaster Timer Settings.png[/attachment]

This patch applies cleanly to SVN r21329, and has been tested on OS X 10.4 and 10.6. I do not play multiplayer, so I do not know if it works for that environment. Prior to applying the patch, please adjust my FIX ME in saveload.cpp to point to the correct SVN revision. If this patch is accepted, I would like to create new disasters: wildfire, oil spill, etc.
Attachments
Simultaneous disasters (faked using console commands)
Simultaneous disasters (faked using console commands)
Multiple Disasters.png (23.46 KiB) Viewed 6084 times
disaster-timers.patch
Patch to create new disasters framework.
(42.67 KiB) Downloaded 216 times
Adjusting specific disaster settings.
Adjusting specific disaster settings.
Disaster Timer Settings.png (104.78 KiB) Viewed 6084 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [PATCH] new disasters framework

Post by Kogut »

It looks very, very interesting. I hope that it is desync-free.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [PATCH] new disasters framework

Post by Terkhen »

IMO activating disasters manually (even if done via the console) should be marked as a cheat (as already done for things like getting more money or changing companies). You might also consider adding the manual activation of these disasters to the cheat GUI.

You should also consider implementing the patch as a patch queue, which makes the code easier to review and test.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [PATCH] new disasters framework

Post by Kogut »

Terkhen wrote:IMO activating disasters manually (even if done via the console) should be marked as a cheat (as already done for things like getting more money or changing companies). You might also consider adding the manual activation of these disasters to the cheat GUI.
I think it is test-command like stop_ai (not marked as cheat).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
WWTBAM
Moderator
Moderator
Posts: 3689
Joined: 02 Apr 2005 07:01
Location: Sydney NSW Antipodea
Contact:

Re: [PATCH] new disasters framework

Post by WWTBAM »

Terkhen wrote:IMO activating disasters manually (even if done via the console) should be marked as a cheat (as already done for things like getting more money or changing companies). You might also consider adding the manual activation of these disasters to the cheat GUI.

You should also consider implementing the patch as a patch queue, which makes the code easier to review and test.
I personaly disagree. I like to play with the more realistic disasters that don't nesecarily affect the company as often on in TTDPatch and leave the UFO's off.
Formerly known as r0b0t_b0y2003, robotboy, roboboy and beclawat. The best place to get the most recent nightly builds of TTDPatch is: http://roboboy.users.tt-forums.net/TTDPatch/nightlies/
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [PATCH] new disasters framework

Post by Terkhen »

robotboy wrote:I personaly disagree. I like to play with the more realistic disasters that don't nesecarily affect the company as often on in TTDPatch and leave the UFO's off.
I'm only talking about the activation of disasters manually, not about the timer settings.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [PATCH] new disasters framework

Post by Kogut »

Terkhen wrote:I'm only talking about the activation of disasters manually, not about the timer settings.
And cheats have positive effects (well, it is possible to drain cash), not negative (like disasters).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: [PATCH] new disasters framework

Post by Terkhen »

Kogut wrote:And cheats have positive effects (well, it is possible to drain cash), not negative (like disasters).
That only means that they can easily be used to mess with the competition.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: [PATCH] new disasters framework

Post by Alberth »

I did a quick check of the patch, and attached you will find my comments.

I quoted some part of the patch, and added my comment below it, prefixed with ">>".
For ease of reading I also added lines of "----------------" to seperate parts.

I like the idea, but the patch needs some more work.
Please also add a revision number somewhere, eg in the file name, making it easier to keep different versions apart from each other.

You may also want to create a FlySpray issue for it (bugs.openttd.org) if you think it is ready for trunk, patches less likely get lost there.
Attachments
disaster_comments.txt
comments on parts of disaster-timers.patch
(11.73 KiB) Downloaded 225 times
dev_null42
Engineer
Engineer
Posts: 4
Joined: 13 Jun 2007 02:36

Re: [PATCH] new disasters framework

Post by dev_null42 »

>> Why not make 4 strings 'none', ... , 'frequent', and one string for each disaster?
>> Having zillion of the same strings just creates more maintenance work.

How can I reuse the strings in settings_gui.cpp? When using SGF_MULTISTRING, the displayed string is referenced offset to the base string. I suppose I could play tricks by manipulating the minimum value, but that would obfuscate the code worse. Ideally I would declare a new SettingGuiFlagLong (maybe SGF_FREQUENCY?), but the comment on line 41 of settings_internal.h suggests that there is no space available.

Once this issue is resolved, I will have a new version available, broken into several smaller patches.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: [PATCH] new disasters framework

Post by Alberth »

Sorry for the confusion, I was wrong here, the strings seem quite hard-coded together.
Please ignore my remark, and just keep the strings as you have them.

We'd like to change this connection, it should be a different patch than disasters.
(your patch makes the problem a bit more urgent :) )

Albert
dev_null42
Engineer
Engineer
Posts: 4
Joined: 13 Jun 2007 02:36

Re: [PATCH] new disasters framework

Post by dev_null42 »

Thanks, Albert. I posted my patches to FlySpray.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [PATCH] new disasters framework

Post by Kogut »

Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [PATCH] new disasters framework

Post by Kogut »

coal mine - 1970 - 2020
factory - 1970 - 2020
refinery - 1960 - 2010
zeppeliner - 1890 - 1955
small ufo - 1940 - 1970
big ufo - 2000 - 2100
small sub - 1920 - 1960
big sub - 1970 - 2100

I can imagine that zeppeliner is disabled after 1955, but:
- ufos , coal mine etc can stay forever
- I would like to play with zeppeliner after 1955.

And one more thing - how coal mine/factory/refinery disaster works with, say ECS? Or FIRS?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: [PATCH] new disasters framework

Post by frosch »

Industries define which disasters can happen to them (basically grfs provide IndustrySpec::behaviour):

Code: Select all

11   800   The industry can be exploded by a military airplane (oil refinery)
12  1000   The industry can be exploded by a military helicopter (factory)
13  2000   The industry can cause a subsidence (coal mine)
Then they work as usual.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests