Page 1 of 1

Station ID 0xFF returns error

Posted: 05 Nov 2020 16:31
by Erato
Hey guys.

I figured out how to make long stations work. Now I want to add them to my NewGRF, and it had exactly as many IDs left as I needed.
The last one, of course, has the ID 0xFF, but OpenTTD doesn't appreciate that.

Code: Select all

//!!Error (141): ID 08 4B out of valid range (00..FF).
//!!Fatal Error (47): Offset 7: Invalid property 50.
  493 * 14	 00 04 03 01 ff
        08 "KPPL"    
		0B  02  
		11 00  

  494 * 27	 04 04 FF 01 ff C5 "Long roofed platform" 00    
Is the max number of station tiles an odd number or something stupid?

Re: Station ID 0xFF returns error

Posted: 05 Nov 2020 17:42
by JGR
Erato wrote: 05 Nov 2020 16:31 Hey guys.

I figured out how to make long stations work. Now I want to add them to my NewGRF, and it had exactly as many IDs left as I needed.
The last one, of course, has the ID 0xFF, but OpenTTD doesn't appreciate that.

Code: Select all

//!!Error (141): ID 08 4B out of valid range (00..FF).
//!!Fatal Error (47): Offset 7: Invalid property 50.
  493 * 14	 00 04 03 01 ff
        08 "KPPL"    
		0B  02  
		11 00  

  494 * 27	 04 04 FF 01 ff C5 "Long roofed platform" 00    
Is the max number of station tiles an odd number or something stupid?
The Action 0 ID field is an extended byte, see: https://newgrf-specs.tt-wiki.net/wiki/Action0 and https://newgrf-specs.tt-wiki.net/wiki/G ... nformation.
You'll need something like FF FF 00 instead of FF.

Re: Station ID 0xFF returns error

Posted: 05 Nov 2020 17:53
by Erato
JGR wrote: 05 Nov 2020 17:42 The Action 0 ID field is an extended byte, see: https://newgrf-specs.tt-wiki.net/wiki/Action0 and https://newgrf-specs.tt-wiki.net/wiki/G ... nformation.
You'll need something like FF FF 00 instead of FF.
I don't have that kind of freedom in m4nfo sadly. The rest of my tiles all just have the normal hex code there, like this:

Code: Select all

  491 * 14	 00 04 03 01 fc
        08 "KPPL"   
		0B  02 
		11 00  

  492 * 27	 04 04 FF 01 fc C5 "Long roofed platform" 00    
OpenTTD has no issues with this.

Re: Station ID 0xFF returns error

Posted: 05 Nov 2020 20:07
by JGR
Erato wrote: 05 Nov 2020 17:53
JGR wrote: 05 Nov 2020 17:42 The Action 0 ID field is an extended byte, see: https://newgrf-specs.tt-wiki.net/wiki/Action0 and https://newgrf-specs.tt-wiki.net/wiki/G ... nformation.
You'll need something like FF FF 00 instead of FF.
I don't have that kind of freedom in m4nfo sadly. The rest of my tiles all just have the normal hex code there, like this:

Code: Select all

  491 * 14	 00 04 03 01 fc
        08 "KPPL"   
		0B  02 
		11 00  

  492 * 27	 04 04 FF 01 fc C5 "Long roofed platform" 00    
OpenTTD has no issues with this.
It's nothing to do with m4nfo.
Your NFO is incorrect because the action 0 ID field which you want to set to the value FF is an extended byte. You cannot use the one byte form to encode this value, you must use the three byte form. This is as per the specification.

Re: Station ID 0xFF returns error

Posted: 05 Nov 2020 20:25
by Erato
JGR wrote: 05 Nov 2020 20:07 It's nothing to do with m4nfo.
Your NFO is incorrect because the action 0 ID field which you want to set to the value FF is an extended byte. You cannot use the one byte form to encode this value, you must use the three byte form. This is as per the specification.
I think you don't understand m4nfo. I don't control what the output NFO looks like at all. I can't make it an extended byte.

I just reckoned that by posting the NFO I'd get a more helpful response.

But yeah that basically confirms that it can't be done in m4nfo, a shame, but it's fine.
Thanks for your help.

Re: Station ID 0xFF returns error

Posted: 05 Nov 2020 20:31
by JGR
Erato wrote: 05 Nov 2020 20:25
JGR wrote: 05 Nov 2020 20:07 It's nothing to do with m4nfo.
Your NFO is incorrect because the action 0 ID field which you want to set to the value FF is an extended byte. You cannot use the one byte form to encode this value, you must use the three byte form. This is as per the specification.
I think you don't understand m4nfo. I don't control what the output NFO looks like at all. I can't make it an extended byte.

I just reckoned that by posting the NFO I'd get a more helpful response.

But yeah that basically confirms that it can't be done in m4nfo, a shame, but it's fine.
Thanks for your help.
Ah I see now, fair enough. If you raise it with mb directly, he may well be able to sort this out on the m4nfo side.

Re: Station ID 0xFF returns error

Posted: 06 Nov 2020 09:09
by michael blunck
JGR wrote: The Action 0 ID field is an extended byte, see: https://newgrf-specs.tt-wiki.net/wiki/Action0 and https://newgrf-specs.tt-wiki.net/wiki/G ... nformation.
The nfo docs on the wiki are misleading.

IIRC, the first feature getting extended their ID range was sounds (already in ttd times), then vehicles in OTTD.
However, from the beginning, being all on the same text line with stations, they got marked by that (*).

But I've never read about station ID range being extended beyond 255.

Anyway, in r31 I've added this in m4nfo functions definestation(), makestation(), and layout() (maybe there's more ID usage?).

However, I did not test it, rather than successfully compile my own NewStations grf.

@erato
Please try with r31, and report any problems.

regards
Michael

Re: Station ID 0xFF returns error

Posted: 06 Nov 2020 11:43
by Erato
michael blunck wrote: 06 Nov 2020 09:09
JGR wrote: The Action 0 ID field is an extended byte, see: https://newgrf-specs.tt-wiki.net/wiki/Action0 and https://newgrf-specs.tt-wiki.net/wiki/G ... nformation.
The nfo docs on the wiki are misleading.

IIRC, the first feature getting extended their ID range was sounds (already in ttd times), then vehicles in OTTD.
However, from the beginning, being all on the same text line with stations, they got marked by that (*).

But I've never read about station ID range being extended beyond 255.

Anyway, in r31 I've added this in m4nfo functions definestation(), makestation(), and layout() (maybe there's more ID usage?).

However, I did not test it, rather than successfully compile my own NewStations grf.

@erato
Please try with r31, and report any problems.

regards
Michael
Thanks for taking your time to help me, the nfo generated by this is

Code: Select all

  493 * 16	 00 04 03 01 ff ff 00
        08 "KPPL"    
		0B  02  
		11 00  
It's no longer picked on by nforenum, but OpenTTD doesn't seem to like it
Image

Re: Station ID 0xFF returns error

Posted: 06 Nov 2020 14:41
by michael blunck
Ah yes.
@JGR
Is that really implemented for stations?
Var68 has only 8 bits for station ID?

regards
Michael

Re: Station ID 0xFF returns error

Posted: 06 Nov 2020 19:50
by JGR
michael blunck wrote: 06 Nov 2020 14:41 Ah yes.
@JGR
Is that really implemented for stations?
Var68 has only 8 bits for station ID?

regards
Michael
I had another dig through the source and it seems that station ID/spec slots are capped at 255 (not 256) per GRF, so it seems that you can't use 255 as an ID after all.
See: https://github.com/OpenTTD/OpenTTD/blob ... f.cpp#L302
Sorry about time wasted trying to get this working.
michael blunck wrote: 06 Nov 2020 09:09 The nfo docs on the wiki are misleading.

IIRC, the first feature getting extended their ID range was sounds (already in ttd times), then vehicles in OTTD.
However, from the beginning, being all on the same text line with stations, they got marked by that (*).

But I've never read about station ID range being extended beyond 255.
There is only one action 0 parser, and all action 0 features have the same format.
It is an extended byte for all features, even if the usable ID range can be encoded in one byte.
See: https://github.com/OpenTTD/OpenTTD/blob ... 4709-L4746

Re: Station ID 0xFF returns error

Posted: 06 Nov 2020 21:15
by Erato
JGR wrote: 06 Nov 2020 19:50 I had another dig through the source and it seems that station ID/spec slots are capped at 255 (not 256) per GRF, so it seems that you can't use 255 as an ID after all.
See: https://github.com/OpenTTD/OpenTTD/blob ... f.cpp#L302
Sorry about time wasted trying to get this working.
That is such a shame. I need exactly 256 IDs for this one NewGRF. But that's fine. I'll just move some stuff over to another NewGRF.

Thanks michael and JGR for taking your time to try to help me out.