GSGoal Hidden limit

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Aphid
Traffic Manager
Traffic Manager
Posts: 168
Joined: 16 Dec 2011 17:08

GSGoal Hidden limit

Post by Aphid »

I've discovered that there's a limit of 255 goal objects in total using the GSGoal interface. (Calling GSGoal.New() 256 times yields a problem) It took me about an hour of digging through openTTD's code base to actually find this, so let's state the following for the record:

This limit is mentioned nowhere in the API. It should probably be mentioned as it can quite lead to problems. There is also no communication to the script whatsoever as to the status of this limit, so the gamescript writer is forced to either book-keep himself, which is double-counting something that needn't be, or forced to be left guessing. Also, the behaviour when creating the 256th-object is unknown to me, and also undocumented. Furthermore, if a gamescript that uses goals is hoped to be included in another gamescript, that second gamescript has to incorporate the former's counting into its own, and this will quickly get messy, especially with libraries around using Goal objects.

And, last but not least, it maybe a bit low of a limit. Sure, in a game with one company most scripts will not reach this number. But with, say, 16 companies, even keeping a simple score list, or a goal for each (rival) company that exists, is all but impossible due to 16*16 = 256 > 255.

If I wanted to have a goal for each cargo type, that's 32 * 16 = 512, also more.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: GSGoal Hidden limit

Post by Kogut »

Reporting it to http://bugs.openttd.org/ may be a good idea.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: GSGoal Hidden limit

Post by Zuu »

In tomorrows nightly you will have to work harder to reach the limit.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests