Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Dec 12, 2018 1:25 pm

All times are UTC




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [GS] FGVersionController
PostPosted: Sat Nov 02, 2013 9:01 pm 
Offline
Engineer
Engineer

Joined: Mon Jun 21, 2010 11:54 am
Posts: 58
This library help to use new features of GS, while the old versions of OpenTTD remain supported.

Version 2 is available!
Special thanks for the help of krinn.

And usage is simple:
create an instance of this class (with minimum supported system):
Code:
this.versionController = FGVersionController(1, 3, 1);

and example tests:
Code:
if (this.versionController.IsCurrentVersionLessThan(1, 3, 0) {…}
if (this.versionController.IsCurrentVersionGreatherThanOrEqualTo(1, 3, 0)) {. . .}


Full documentation: http://feca.homedns.org/documentations/ ... index.html
lastest version available:
Bananas download link: http://binaries.openttd.org/bananas/gsl ... r-2.tar.gz

_________________
Sorry my bad english, I don't speak english!


Last edited by idioty on Sun Nov 03, 2013 11:28 am, edited 1 time in total.

Top
   
PostPosted: Sun Nov 03, 2013 2:48 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Why hardcoding openttd versions like that, that's somehow strange.
Would be easier (and better no update need when new openttd version is out) to simply :

user_maj = user_maj << 8;
user_min = user_min << 4;
user_version = user_maj + user_min + user_build;

ottd_version = AIController.GetVersion() >> 0x14;
ottd_maj = ottd_version & 0xf00;
ottd_min = ottd_version & 0xf0;
ottd_build = ottd_version & 0xf;

now you can easy compare : ottd_version < user_version...


Top
   
PostPosted: Sun Nov 03, 2013 8:43 am 
Offline
Engineer
Engineer

Joined: Mon Jun 21, 2010 11:54 am
Posts: 58
Thanks!
That it is a good idea! There's something to learn! :D

But this does'nt work for me:
Code:
ottd_version = AIController.GetVersion() >> 0x14;
ottd_maj = ottd_version & 0xf00;
ottd_min = ottd_version & 0xf0;
ottd_build = ottd_version & 0xf;


But I found a solution on this forum:
Code:
local v = GSController.GetVersion();
local major =   (v & 0xF0000000) >> 28;
local minor =   (v & 0x0F000000) >> 24;
local build =   (v & 0x00F00000) >> 20;
local release = (v & 0x00080000) != 0;
local revision = v & 0x0007FFFF;


And this work! Thanks again for the replay.
I will write a special thanks for you in the next release :D :bow:

this is the topic:
viewtopic.php?f=65&t=43521&p=787612&hilit=AIController.GetVersion#p787612

_________________
Sorry my bad english, I don't speak english!


Top
   
PostPosted: Sun Nov 03, 2013 1:11 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
You're welcome.
BTW, did you check AI/GSInfo.GetAPIVersion setting ? Because it should solve the need to check openttd version.


Top
   
PostPosted: Sun Nov 03, 2013 2:58 pm 
Offline
Engineer
Engineer

Joined: Mon Jun 21, 2010 11:54 am
Posts: 58
I do not think is necessary, because I set the minimum was 1.2 Api version.
This is GS only and the GS available only from 1.2 version.
And the user can set the minimum script requirement.
In my game script is 1.3.0 because I need the GSCargoMonitor.

_________________
Sorry my bad english, I don't speak english!


Top
   
PostPosted: Sun Nov 03, 2013 3:22 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
An alternative to checking for OpenTTD version is to check for the availability of an API method.
Code:
if ("GetName" in GSTown) { /* do something */ }

If you need to check for an entire class you need to use some magic by krinn included in SuperLib.Story.IsStoryBookAvailable().

If you plan to check for availability of StoryBook, I recommend using SuperLib.Story.IsStoryBookAvailable() because it will return false for some revisions when the API is available but there was a save/load bug in the Story book feature causing trouble at loading. So it is best to just not use the Story Book feature at those revisions and rely on the above mentioned method to detect if a user has a new enough nighly/release. As long as you obey GPL v2, you can of course copy this check method from SuperLib if you do not want to add it as dependency for just this method.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun Nov 03, 2013 8:20 pm 
Offline
Engineer
Engineer

Joined: Mon Jun 21, 2010 11:54 am
Posts: 58
I understand, but I think the nigthly edition contains many errors, and users know this.
My source code is included in the new API options, but I do not recommend the use of going live.
And users are aware that (I guess).

_________________
Sorry my bad english, I don't speak english!


Top
   
PostPosted: Sun Nov 03, 2013 9:16 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2364
Location: Location, Location
Nightly/trunk usually doesn't actually contain anymore bugs than stable (other than the rare build breaking bugs) I would say a fair proportion of users use nightly as their main version (I do)

_________________
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra


Top
   
PostPosted: Mon Nov 04, 2013 4:34 pm 
Offline
Engineer
Engineer

Joined: Mon Jun 21, 2010 11:54 am
Posts: 58
I am also think same way.

And why it's better
Code:
if (("GetName" in GSTown) && ("FoundTown" in GSTown) && ...  {}

than
Code:
if (this.versionController.IsCurrentVersionGreatherThanOrEqualTo(1, 4, 0) {}
?

Actually, no matter, I wrote to myself :D

_________________
Sorry my bad english, I don't speak english!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.