Patch: Modifiable Air crash rates

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
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Patch: Modifiable Air crash rates

Post by RainierWatcher »

I've made a patch to change the rate of crashes of aircraft on large airports. This will not affect jets on small airports, there is a cheat for that one, this makes a more realistic rate of crashes (1:1000000) as opposed to the previous (1:1500).
This will also affect small aircraft on small airports.

Currently the option appears right at the bottom of the vehicles tab in configure patches, and is a bit difficult to see.

Down the page is newest version.
Last edited by RainierWatcher on 05 Jun 2007 20:28, edited 1 time in total.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Post by Rubidium »

First, this patch makes that chance 0, not 1000000.
Second, the lowest chance is 1 in about 65000 when you do not want to chance lots of code
Third, I personally think the chance becomes too little with this patch. Maybe in real life 1 in 1000000 planes crashes, but they make an average of say 500 flights a year, in the TTD world you would be happy if you get 12 flights a year. Furthermore you use much less planes than in real life, so calculating for all these factors 1 in 10000 might be more 'real life' than taking the actual real life number.
User avatar
Zojj
Engineer
Engineer
Posts: 97
Joined: 27 Apr 2007 17:58
Location: Vegas baby
Contact:

Post by Zojj »

What if you had the probability customizable? 1/1500, 1/10000, 1/65000, 0.
I'm on the Zoloft to keep me from killing yall

My patches: Better graphs - Train acceleration - Crash rates
User avatar
Ricki
Engineer
Engineer
Posts: 8
Joined: 14 Jul 2005 19:48
Location: Ciudad Real, Spain

Post by Ricki »

And why not a variable value based on the plane's reliability? Also with greater chance to crash if it has broken down.
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

Rubidium wrote:First, this patch makes that chance 0, not 1000000.
Second, the lowest chance is 1 in about 65000 when you do not want to chance lots of code
Third, I personally think the chance becomes too little with this patch. Maybe in real life 1 in 1000000 planes crashes, but they make an average of say 500 flights a year, in the TTD world you would be happy if you get 12 flights a year. Furthermore you use much less planes than in real life, so calculating for all these factors 1 in 10000 might be more 'real life' than taking the actual real life number.
How does it make it 0? Is it due to the size of the object to store the probability? I guess it is from the number quoted of 65000.

the average number of accidents and fatalities per year is as follows:
14 accidents, 340 fatalities


This is 14 air accidents a year, and the fatalities figure comes from the total killed in planes which are certified to carry more than 13 passengers.
(from the Aviation safety network)

Of course this is worldwide, and there are some airlines which haven't had a crash for about 10 years or more.

Having said that, a value that is ten times lower than the current one would seem fairly good.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
knedle
Traffic Manager
Traffic Manager
Posts: 158
Joined: 13 Apr 2007 17:07

Post by knedle »

Third, I personally think the chance becomes too little with this patch. Maybe in real life 1 in 1000000 planes crashes, but they make an average of say 500 flights a year, in the TTD world you would be happy if you get 12 flights a year.
Speaking of realism.
  • Trains may crash because of signals failure, switches failure or even because someone is sleeping when he shouldn't. Considering that real trains make about 90 000 kilometers per year and in OpenTTD you can be happy if your trains make 1 000 kilometers, chance to scrap your train should be about 1 in 10. Please note that I didn't think about brake failures, blown engines, terrorists attacks and other random problems with tracks (like in ICE or TGV cases).
  • Buses and trucks... oh yeah, there are plenty of accidents caused by truck drivers who were eighter sleeping while in their truck, or drunk or by break failure, loosing control of their vehicle or by violating traffic laws. There were even trucks/busses that crashed into bus stops killing more ppl than single airplane crash kills. Again it should be something around 1 in 1000, maybe 1 in 500 in urban area.
  • Ships don't crash too often, unless you like to watch Titanic every day, however there are many disasters, usually caused by weather or big companies which wanted to save couple of bucks and didn't repair everything they should in their tankers.
Why among all of those vehicles only planes have disasters? On top of that pretty offten and impossible to turn off. Why did you make breakdowns and disasters switches if even turning them off doesn't save even single airplane? If I remember correctly turning them off in TTD solved all my problems with plane crashes, or maybe it didn't, but chance of plane crashing was really small then, and together with small maps, using planes wasn't so reasonable.
It's just plain stupid to force disasters if someone doesn't want them to happen, thanks to it playing after year 2050 on big map is more like a challenge to replace all crashed airplanes before they get scraped, with no time to watch little trains/trams/trucks, no time to make any new connection.
Disasters are ok, but only if I can avoid them, I would prefere to avoid them by paying some extra money to enginers and my crew, so I can be assured they will work fine (like in Traffic Giant), since it isn't possible right now and probably not in future I have to mess with source to disable every disaster that I don't want. This is the easiest solution right now.
sc79
Director
Director
Posts: 586
Joined: 22 Feb 2005 09:51

Post by sc79 »

Why among all of those vehicles only planes have disasters?
Because, in order to have a balance between transport types, they must have positives and negatives. Without crashes, planes have no negatives, and are even more unbalanced. Hence the suggestions (in this thread and the previous discussion one) to come up with a constructive solution rather than just disabling crashes outright.

If you want to argue realism, then combine this with a patch to make planes 15-20 times more expensive to run (or divide profit by 15-20), so that it takes a little more intelligence than just throwing down 500+ planes and counting the profits.
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

I've modified the patch, it now still makes air crashes possible, thanks to rubidium pointing it out that before it made them impossible.

It should make crashes 20 times less frequent than they were before.

It now appears in the stations tab of the config. patches window. (It only affects aircraft at airports, which are stations).
Attachments
customisableaircrashes3.patch
(5.28 KiB) Downloaded 476 times
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

knedle wrote:It's just plain stupid to force disasters if someone doesn't want them to happen, thanks to it playing after year 2050 on big map is more like a challenge to replace all crashed airplanes before they get scraped, with no time to watch little trains/trams/trucks, no time to make any new connection.
:idea: A patch to autoreplace crashed vehicles is actually what is desperately needed. Anyone willing to make it a reality?
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
User avatar
Digitalfox
Chief Executive
Chief Executive
Posts: 703
Joined: 28 Oct 2004 04:42
Location: Catch the Fox if you can... 15 years and counting!

Post by Digitalfox »

RainierWatcher wrote:I've modified the patch, it now still makes air crashes possible, thanks to rubidium pointing it out that before it made them impossible.

It should make crashes 20 times less frequent than they were before.

It now appears in the stations tab of the config. patches window. (It only affects aircraft at airports, which are stations).
I love this patch :)

Oh boy with almost 500 planes in my games, this help a lot..

But could you make it customize, so we can change if we want 20 times less probability or no disasters at all?? Like some GUI in pach options.. And update patch to last trunk revision..

Thanks :)
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

Digitalfox wrote: I love this patch :)

Oh boy with almost 500 planes in my games, this help a lot..

But could you make it customize, so we can change if we want 20 times less probability or no disasters at all?? Like some GUI in pach options.. And update patch to last trunk revision..

Thanks :)
Right, sorry for the wait, I've tried to do this, and this is on latest revision (r10043).

Unfortunately it doesn't like it:

Code: Select all

 Compiling aircraft_cmd.cpp
C:/BuildOTTD/msys/home/ottdsrc/trunk/src/aircraft_cmd.cpp: In function `void MaybeCrashAirplane(Vehicle*)':
C:/BuildOTTD/msys/home/ottdsrc/trunk/src/aircraft_cmd.cpp:1458: error: `patches' undeclared (first use this function)
C:/BuildOTTD/msys/home/ottdsrc/trunk/src/aircraft_cmd.cpp:1458: error: (Each undeclared identifier is reported only once for each function it appears in.)
make[1]: *** [aircraft_cmd.o] Error 1
make[1]: Leaving directory `/home/ottdsrc/trunk/objs/release'
make: *** [all] Error 2
New patch attempt (edit to say, I think it doesn't like how I define my variable, but it accepted this sort of code when it was boolean):

Code: Select all

Index: src/aircraft_cmd.cpp
===================================================================
--- src/aircraft_cmd.cpp	(revision 10043)
+++ src/aircraft_cmd.cpp	(working copy)
@@ -1455,7 +1455,7 @@
 	Station *st = GetStation(v->u.air.targetairport);
 
 	/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
-	uint16 prob = 0x10000 / 1500;
+	uint16 prob = 0x10000 / (patches.less_air_crashes);
 	if (st->Airport()->flags & AirportFTAClass::SHORT_STRIP &&
 			AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
 			!_cheats.no_jetcrash.value) {
Index: src/lang/english.txt
===================================================================
--- src/lang/english.txt	(revision 10043)
+++ src/lang/english.txt	(working copy)
@@ -1108,6 +1108,7 @@
 STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Max road vehicles per player: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Max aircraft per player: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_MAX_SHIPS                                    :{LTBLUE}Max ships per player: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_LESS_AIR_CRASHES                             :{LTBLUE}Set probabilty level for air crashes of aircraft of suitable size for the airport: {ORANGE}{STRING1}
 
 STR_CONFIG_PATCHES_AI_BUILDS_TRAINS                             :{LTBLUE}Disable trains for computer: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH                            :{LTBLUE}Disable road vehicles for computer: {ORANGE}{STRING1}
Index: src/settings.cpp
===================================================================
--- src/settings.cpp	(revision 10043)
+++ src/settings.cpp	(working copy)
@@ -1239,7 +1239,7 @@
 #endif /* WIN32 */
 
 static const SettingDescGlobVarList _misc_settings[] = {
-	SDTG_MMANY("display_opt",     SLE_UINT8, S, 0, _display_opt,       (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
+	SDTG_MMANY("display_opt",     SLE_UINT8, S, 0, _display_opt,       (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
 	 SDTG_BOOL("news_ticker_sound",          S, 0, _news_ticker_sound,     true,    STR_NULL, NULL),
 	 SDTG_BOOL("fullscreen",                 S, 0, _fullscreen,           false,    STR_NULL, NULL),
 	  SDTG_STR("videodriver",      SLE_STRB,C|S,0, _ini_videodriver,       NULL,    STR_NULL, NULL),
@@ -1391,7 +1391,7 @@
 	SDT_BOOL(Patches, wagon_speed_limits,            0, 0,  true,                    STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,     NULL),
 	SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, 0, false,          STR_CONFIG_PATCHES_DISABLE_ELRAILS,      SettingsDisableElrail),
 	SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0, 0, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL),
-
+	
 	/***************************************************************************/
 	/* Station section of the GUI-configure patches window */
 	SDT_BOOL(Patches, join_stations,           0, 0,  true,        STR_CONFIG_PATCHES_JOINSTATIONS,       NULL),
@@ -1406,6 +1406,7 @@
 	SDT_CONDBOOL(Patches, gradual_loading, 40, SL_MAX_VERSION, 0, 0,  true, STR_CONFIG_PATCHES_GRADUAL_LOADING,    NULL),
 	SDT_CONDBOOL(Patches, road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
 	SDT_CONDBOOL(Patches, adjacent_stations,      62, SL_MAX_VERSION, 0, 0, true,  STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
+	SDT_VAR(Patches, less_air_crashes,SLE_UINT16, S, 0, 30000, 65000, 20, STR_CONFIG_PATCHES_LESS_AIR_CRASHES,     NULL),
 
 	/***************************************************************************/
 	/* Economy section of the GUI-configure patches window */
Index: src/settings_gui.cpp
===================================================================
--- src/settings_gui.cpp	(revision 10043)
+++ src/settings_gui.cpp	(working copy)
@@ -648,6 +648,7 @@
 	"gradual_loading",
 	"road_stop_on_town_road",
 	"adjacent_stations",
+	"less_air_crashes",
 };
 
 static const char *_patches_economy[] = {
@@ -703,7 +704,7 @@
 	"no_servicing_if_no_breakdowns",
 	"wagon_speed_limits",
 	"disable_elrails",
-	"freight_trains",
+	"freight_trains",	
 };
 
 struct PatchEntry {
Index: src/variables.h
===================================================================
--- src/variables.h	(revision 10043)
+++ src/variables.h	(working copy)
@@ -133,6 +133,7 @@
 	byte liveries;                      // Options for displaying company liveries, 0=none, 1=self, 2=all
 	bool prefer_teamchat;               // Choose the chat message target with <ENTER>, true=all players, false=your team
 	bool advanced_vehicle_list;         // Use the "advanced" vehicle list
+	uint16 less_air_crashes;              // Reduction in number of air crashes at large airports
 
 	uint8 toolbar_pos;                  // position of toolbars, 0=left, 1=center, 2=right
 	uint8 window_snap_radius;           // Windows snap at each other if closer than this
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
hertogjan
Director
Director
Posts: 560
Joined: 03 Jan 2006 20:45
Location: Netherlands

Post by hertogjan »

It might be better to modify the probability directly instead of by the division

Code: Select all

prob = 0x10000 / (patches.less_air_crashes);
The problem is that a whole lot of values of patches.less_air_crashes yield the same probabilty. For instance, any number from 32769 to 65535 gives 1 as the result of the division. By changing the number (for instance) from 35000 to 60000 the user expects that his/her planes crash less often, but this doesn't happen. That may be experienced as being a bug.
I think it is better to define the probability by percents of the default value, so that one could do it with

Code: Select all

prob = 0x10000 * (patches.air_crash_prob) / 150000;
so that setting the value to 100 gives the default value, and lower values give lower chances of crashing aircraft. The range may then be set from 5% (minimal probability) to something well over 100% (increased probability).
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

Got it working now, but the explanation trails off the edge of the patches window, and it comes up with an error stating that as well, but apart from that, it seems to work.
Attachments
modifiableplanecrashesv2.patch
Patch with user defined rates of crashes, against r10043
(5.28 KiB) Downloaded 344 times
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
User avatar
glx
OpenTTD Developer
OpenTTD Developer
Posts: 621
Joined: 02 Dec 2005 15:43
Location: Drancy(93) - France
Contact:

Post by glx »

In settings.cpp, the two first changes are wrong (the first reverts a fix in trunk, the second adds a tab).

In settings_gui.cpp, the second change is not needed either (you added a tab).

In variables.h, wrong comment align.
User avatar
Zojj
Engineer
Engineer
Posts: 97
Joined: 27 Apr 2007 17:58
Location: Vegas baby
Contact:

Post by Zojj »

Here it is with adjustable rates: 1/1500, 1/10000, 1/30000, 0.

After I finished I realized RainierWatcher had made it adjustable already.. oh well. =)
Attachments
adjustable_crash_rates_r10046.diff
(3.73 KiB) Downloaded 452 times
I'm on the Zoloft to keep me from killing yall

My patches: Better graphs - Train acceleration - Crash rates
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

Well, yours is probably more usable anyway, so I don't mind. Actually, I'm going to concede that yours is far better and more user friendly, so I think yours should be the one used. Not out of laziness, but I really think that was the better way to do it, to use set values.

I've tried to make mine right, but I only seem to be able to change the value to 65000 and 20, which should be the max and minimum values.

Anyway;
Attachments
modifiableplanecrashesv3.patch
(3.43 KiB) Downloaded 540 times
Last edited by RainierWatcher on 06 Jun 2007 16:04, edited 2 times in total.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
User avatar
glx
OpenTTD Developer
OpenTTD Developer
Posts: 621
Joined: 02 Dec 2005 15:43
Location: Drancy(93) - France
Contact:

Post by glx »

settings.cpp: ..., 30000, 65000, 20, ...
means default: 30000, min: 65000, max: 20, something looks wrong ;)
User avatar
RainierWatcher
Traffic Manager
Traffic Manager
Posts: 244
Joined: 14 Jan 2007 15:10
Location: West Norfolk, England

Post by RainierWatcher »

glx wrote:settings.cpp: ..., 30000, 65000, 20, ...
means default: 30000, min: 65000, max: 20, something looks wrong ;)
Oh well :)

The wiki must be wrong then:

Code: Select all

SDT_VAR( <settings group>, <varname>, <vardef>, <savewhereflags>, <gui flags>, <initial value>, <max value>, <min value>, <display string>, <onchange callback proc>),
In which case, I put them the other way round in the code, still doesn't work.
Ways of Preventing Death:
* Don't breathe air. Seriously. Everyone born before 1870 breathed the substance at some point in their life and every one of them is dead today. A coincidence? I think not.
Taken from uncyclopedia
hertogjan
Director
Director
Posts: 560
Joined: 03 Jan 2006 20:45
Location: Netherlands

Post by hertogjan »

This is from the macro in settings.cpp:

Code: Select all

SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, proc)
The problem might be that interval is set to 0. This number is used to increment/decrement the value of the variable. Keeping in mind that you want to be able to change te value, it might be a bad idea to set it to 0.* Try setting it to 1 or a to higher number; for instance, 5, 10 or 20 will be fine.


*Close inspection shows that many of the variables have interval set to 0. It might be that the game interprets 0 as 1 in this case.
SimpleRules
Engineer
Engineer
Posts: 15
Joined: 09 May 2007 18:46

Post by SimpleRules »

How I do I use this?

I'm more of a player than developer and not sure what to do, I just know my 500 planes are crashing quickly!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: TrueBrain and 3 guests