Patch: Long format model life for vehicles

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
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Patch: Long format model life for vehicles

Post by Terkhen »

After starting my work with the Millenium conversion set, I realized that, to give full support to long format introduction dates, the model life value could not be limited to 254 years. I have written a patch that adds a new word sized Action 0 property for all vehicle types called long format model life. This property allows to set model life values between 0 and 5000 (88 13 in little endian byte order). This limit is set to prevent overflows calculating duration phases, and there's no interest for bigger values anyways. Any number greater than 5000 will be treated as 5000. A value of 0xFFFF means that the model never expires. This new property is compatible with all existing sets that use the standard model life property.

The long format model life property has the following property numbers:

Trains: 0x2B
Road vehicles: 0x21
Airplanes: 0x1C
Ships: 0x1C

I am providing a win32 binary in this post. The source code of the patch and two simple GRFs for testing purposes can be found on its Flyspray task [#3044]. In the next posts there are some GRFs that are more interesting to test this patch.
Attachments
long_format_model_life_win32_r17273.rar
(2.71 MiB) Downloaded 140 times
Last edited by Terkhen on 25 Aug 2009 07:06, edited 1 time in total.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Patch: Long format model life for vehicles

Post by Terkhen »

To test this patch, I am posting a complete version of the Millenium conversion set. Since it needs this patch to work properly, these GRF files are posted here instead of in their thread to prevent confusions.

In this post is a rar file that includes all parts of the MCS (standard trains, road vehicles, ships, planes, bridges and houses) each on its separate file. This is to allow anyone to select what parts of the game they want to be affected by the conversion. A single, complete GRF can be found at the next post. These GRFs accept a parameter that allows to set how many centuries you want to play.

Code: Select all

Starting
Date		Parameter
1950			1
1850			2
1750			3
1650			4
1550			5
1450			6
1350			7
1250			8
1150			9
1050			10
950 			11
850 			12
750 			13
650 			14
550 			15
450 			16
If there's no parameter, a starting date of 1050 will be used. The GRFs scales the introduction dates and model life values to fit in the new time scale. The GRFs and their sources can be found below:
Attachments
Millenium_Conversion_Set_v3_nfo_(Modules).rar
(28.56 KiB) Downloaded 129 times
Millenium_Conversion_Set_v3_grf_(Modules).rar
(14.01 KiB) Downloaded 144 times
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Patch: Long format model life for vehicles

Post by Terkhen »

Finally, here is a single GRF file that implements the complete MCS. This file makes life easier to anyone that wants to use the complete conversion without having to set 6 different GRF files with the same parameter.

As you may know, my aim with this patch and the MCS is to achieve the same goal as the different daylength patches (really long games) but changing OpenTTD source code as little as possible. With the current implementation this is already possible (only for standard vehicles), having the following issues (there may be more):
  • Euro introduction date can be changed by GRF, but it is not implemented.
  • New objects introduction dates can be changed by GRF, but they are not implemented.
  • Oil wells can only be built before 1950, and oil rigs can only be built after 1960. These flags can't be changed by GRF, but variable limits could be coded with a callback. This is not implemented.
  • Inflation still maxes out 170 years after game starts.
  • Airport introduction dates can't be changed by GRF. Planes are still converted in the MCS.
Attachments
Millenium_Conversion_Set_v3.nfo
(536.44 KiB) Downloaded 168 times
Millenium_Conversion_Set_v3.grf
(77.05 KiB) Downloaded 142 times
Last edited by Terkhen on 29 Aug 2009 07:39, edited 1 time in total.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Patch: Long format model life for vehicles

Post by FooBar »

Terkhen wrote:Oil wells can only be built before 1950, and oil rigs can only be built after 1960. These values can't be changed by GRF...
You can use a callback to set a custom date instead of using the industry flags.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Patch: Long format model life for vehicles

Post by Terkhen »

Thanks, I have edited the issue.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Patch: Long format model life for vehicles

Post by frosch »

FooBar wrote:
Terkhen wrote:Oil wells can only be built before 1950, and oil rigs can only be built after 1960. These values can't be changed by GRF...
You can use a callback to set a custom date instead of using the industry flags.
Good idea. I suggest to use 0x22 for the callback ID. :p
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Semrush [Bot] and 22 guests