OpenTTD Version Check

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

OpenTTD Version Check

Post by FooBar »

As it seems we should now be able to check the OTTD version number.
Commit by rubidium :: r11330 /trunk/ (6 files in 4 dirs): wrote:-Add: OTTD version checking for NewGRFs. This allows NewGRFs to do something different for different versions of OpenTTD, like disabling it for too low versions or loading different graphics.
I figured I should use it in my GRF to disable an error message (action B). This works as expected in builds which support version checking, but gives me troubles in builds without it (i.e. < r11330).

Seems Action 7 Variable A1 evaluates as 'true' in builds without Action 7 Var A1 support, rendering it useless (to me). Is this normal behaviour, or am I doing something wrong?

Little example:

Code: Select all

-1 * 0 07 A1 04 \7> 41 2C 00 06 01
-1 * 0 0B 00 7F FF "Notice: This set requires OpenTTD r10549 or higher." 00
The first line of code checks the OTTD version number. The comparison value is set to 41 2C 00 06 (or 0.6.0 r11329). If the version number is higher than the one specified, the next sprite should be skipped.
Using r11339 it skips the error message as expected.
Using r11293 it _also_ skips the error message, and that's exactly what I don't want it to do.

If this normal behaviour, is there an other method to disable that error message in rxxxxx and up, and still having it displayed in versions < r10549?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: OpenTTD Version Check

Post by DaleStan »

That is, I believe, as specified. Use of undefined variables causes the jump to be ignored. I think the appropriate solution is two action 7/9s:

Code: Select all

-1 * 0 07 A1 04 \7< \w10549 00 06 01
-1 * 0 07 A1 04 \7> \d0 01
-1 * 0 0B 00 7F FF "Notice: This set requires OpenTTD r10549 or higher." 00
This skips to the action B if A1 is defined and too small, and then skips over the action B if A1 is defined (and therefore sufficiently large).

Note that above I'm testing for the specified revision, not the first revision where A1 is defined. This is functionally equivalent, and, IMO, easier to follow.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: OpenTTD Version Check

Post by Wile E. Coyote »

It's probably OT, but I haven't found nothing with search: which checks in Actions 7/9 are supported? Is it supported check is cargo type available?
(There is nothing in Wiki about Action 7/9 support; nothing is written, so I suppose there is no support for check above.)
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: OpenTTD Version Check

Post by FooBar »

Thanks for you reply, DaleStan, but that didn't work either. For some reason, older versions still skip the message.

By trial and error I came to this:

Code: Select all

-1 * 0 07 A1 04 \7< \w10548 00 06 01
-1 * 0 0B 00 7F FF "Notice: Version not detected." 00
This gives an error in r11339 (as expected) AND an error in r10166.

This got me thinking that var A1 could as well be a very big value in pre-r11330, possibly FF FF FF FF.

With that in mind, I tried this:

Code: Select all

-1 * 0 07 A1 04 \7= FF FF FF FF 01
-1 * 0 07 A1 04 \7> \w10548 00 06 01
-1 * 0 0B 00 7F FF "Notice: Version not detected." 00
So if A1 is undefined (or FF FF FF FF), the real check gets skipped resulting in an notice being displayed.
If A1 is defined (r11330 or higher), the real check is executed, resulting in the notice being skipped.


I attached a small grf containing this code. It does the wonderful job of determining if the OTTD version can be determined*. So it's pretty useless indeed, but it gives an idea on how to put var A1 to good use.

*) Does not work on OTTD versions without Action B support. Well, maybe it does, but it can't display the result.


@Wile E.
Are you looking in the NewGRF Specs Wiki? It's true that the OpenTTD Wiki doesn't have anything useful on creating GRFs.
Attachments
vcheck.grf
OTTD Version Check Checker
(194 Bytes) Downloaded 73 times
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: OpenTTD Version Check

Post by Wile E. Coyote »

FooBar wrote:@Wile E.
Are you looking in the NewGRF Specs Wiki? It's true that the OpenTTD Wiki doesn't have anything useful on creating GRFs.
Yes, but there is also nothing about OTTD support (except, of course, var. A1).
I'm interested which <variable> and <condition-type> are supported, in this case especially <condition-type> \7c and \7C (testing availability of cargos).

EDIT: Here is example:

Code: Select all

 3063 * 9	 07 88 04 \7C "TOUR" 08 //is cargo labeled "TOUR" available (<condition-type> \7C)? If yes, skip next 8 sprites
 3064 * 7	 00 00 01 01 31 06 00   //those 8 sprites make vehicles carrying this cargo unavailable (their climate is set to 0)
 3065 * 7	 00 00 01 01 32 06 00
 3066 * 7	 00 00 01 01 33 06 00
 3067 * 7	 00 00 01 01 45 06 00
 3068 * 7	 00 00 01 01 48 06 00
 3069 * 7	 00 00 01 01 63 06 00
 3070 * 7	 00 00 01 01 64 06 00
 3071 * 7	 00 00 01 01 65 06 00
So, if OTTD don't recognizes <condition-type> \7C, it simply ignores sprite 3063, and goes ahead. Thus following 8 vehicles will be no available even if cargo labeled "TOUR" is present.
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: OpenTTD Version Check

Post by Rubidium »

What version of OpenTTD are you talking about in this case? Because it should be working in current trunk, or basically everything since newcargos has been implemented. It will, however, not work in "old" (read: 0.5.3) versions where newcargos is not implemented.
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: OpenTTD Version Check

Post by Wile E. Coyote »

:oops: Sorry, I forgot to state version, it's Nightly 11255.
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: OpenTTD Version Check

Post by Rubidium »

It is actually implemented. Maybe the implementation is broken. What does it do when you pass it the inverse of "TOUR", i.e. "RUOT"?
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8515
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: OpenTTD Version Check

Post by Wile E. Coyote »

I've just downloaded new Nightly (11339) and I'll check everything and inform you.

EDIT: I checked with both "TOUR" and "RUOT" labels. In both cases there were no vehicles appear, so it seems that check is skipped. I must note that under Patch everything is OK.
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot] and 19 guests