Rail Type Introduction & its relationship to Introduction Date

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Rail Type Introduction & its relationship to Introduction Date

Post by Gwyd »

So I was playing around with making some of my own railtypes, and to make some railtypes that were required from a technical standpoint but should not available to the player (let's call it railtype X), I set the property "introduction_date" of the tracktype to the year 5000000, the quoted maximum from: https://newgrf-specs.tt-wiki.net/wiki/NML:Railtypes.

When I compiled this into a NewGRF regardless of the date, once the first train for railtype X was made available (~1980) railtype X was made available.

Some more digging on that same page tells me that the game will basically ignore the "introduction_date" property, unless no trains are explicitly allowed on it. To me this seem unintuitive and unhelpful. Yes, I am pushing the limits of the design for a specific use case, but nonetheless this implication does not appear to be the best possible.
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Eddi »

with openttd 1.9 was added the ability to hide railtypes from the construction menu. that sounds like what you're looking for here. (property 10 bit 2)
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Erato »

Eddi wrote: 14 Jul 2019 00:55 with openttd 1.9 was added the ability to hide railtypes from the construction menu. that sounds like what you're looking for here. (property 10 bit 2)
Is there a way to implement this using NML?
No pics no clicks. Seriously.
ImageImageImageImageImageImage
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Eddi »

yes, property 10 is called "railtype_flags" there. i imagine it hasn't got a name for the bit, though, so you'd have to use the raw number, like

Code: Select all

bitmask(2)
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Gwyd »

I tried to do something like that after reading the nfo specs about it, but I couldn't seem to get the desired result.
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Eddi »

i'm afraid you need to provide us with more details
User avatar
Gwyd
Chief Executive
Chief Executive
Posts: 721
Joined: 17 Apr 2017 16:52
Location: Western Ile-de-France Region

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Gwyd »

What I'm trying to ask is how would I set flags in the item block of some item which doesn't have a name implemented into NML like RAILTYPE_FLAG_CATENARY, but rather one that is defined under property 10 for NFO.
In this particular case, I want to set the railtype to have the "hidden in construction menu" flag enabled, which in NFO is defined as bit 2 with a value of 4 in property 10. I have attempted this in NML by trying the code

Code: Select all

bitmask(4)
In the item block of the railtype in question, but this didn't seem to work.
This suggests either:
I wasn't being rigorous in testing the change
or I'm doing it wrong.


EDIT: I just had to copy Eddi's post to hide the track type, thank you for your help. Still unsure on the behaviour of railtype releases.
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Transportman »

Gwyd wrote: 16 Jul 2019 22:18 What I'm trying to ask is how would I set flags in the item block of some item which doesn't have a name implemented into NML like RAILTYPE_FLAG_CATENARY, but rather one that is defined under property 10 for NFO.
In this particular case, I want to set the railtype to have the "hidden in construction menu" flag enabled, which in NFO is defined as bit 2 with a value of 4 in property 10. I have attempted this in NML by trying the code

Code: Select all

bitmask(4)
In the item block of the railtype in question, but this didn't seem to work.
This suggests either:
I wasn't being rigorous in testing the change
or I'm doing it wrong.


EDIT: I just had to copy Eddi's post to hide the track type, thank you for your help. Still unsure on the behaviour of railtype releases.
It didn't work because you misunderstood how the bitmask() function works, it sets the bit at the position you provide. So if you need to set a property to value 4, you can do that by setting bit 2 (1x2^n, where n is the bit you set, in this case 2).

I think the railtype release behavior is a bit of a safeguard against several things (vehicle introduction dates randomization, different vehicle and track NewGRFs), so the safe behavior is to forcefully introduce the railtype when a vehicle becomes available for it. But there are cases where a railtype should not become available as it is a technical type, which is now covered with the "hidden in construction menu" flag.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: Rail Type Introduction & its relationship to Introduction Date

Post by Eddi »

Gwyd wrote: 16 Jul 2019 22:18which in NFO is defined as bit 2 with a value of 4
this is the important information. if you use the "bitmask" function, you need to use the bit number (2), if you don't use the bitmask function, you can use the value (4). in other words, bitmask(2) == 4
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests