This script took tool long in the Load function

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
User avatar
GoldMine
Traffic Manager
Traffic Manager
Posts: 197
Joined: 31 Oct 2024 20:59

This script took tool long in the Load function

Post by GoldMine »

Image

This error happened in my AI while I was testing saving/loading.
Is there some sort of limit on how much data can be saved to save file?

I checked the size of save file and it's really not that big (607 KiB):

Image

Why this happens and what are the limits?

edit:

I took a look into source and there appears this:

Code: Select all

/** The maximum number of operations for saving or loading the data of a script. */
static const int MAX_SL_OPS             = 100000;
Does this mean there is no limit to how much data can be stored, but as long as the script is able to load all data within 100K ops?
Or is there also limit to data saved?
Logging, error and exception handling is the father and mother of all debugging.
User avatar
jfs
Tycoon
Tycoon
Posts: 1987
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: This script took tool long in the Load function

Post by jfs »

Yes, as long as the script can process its data load fast it can store as much as it want.

Which makes an argument for AI/GS scripts to use an internal data model that requires minimal (ideally zero) transformation for load/save.
User avatar
GoldMine
Traffic Manager
Traffic Manager
Posts: 197
Joined: 31 Oct 2024 20:59

Re: This script took tool long in the Load function

Post by GoldMine »

jfs wrote: 02 Oct 2026 08:39 Which makes an argument for AI/GS scripts to use an internal data model that requires minimal (ideally zero) transformation for load/save.
Yes this makes sense, I taken a look into hogex AI and noticed it uses separate function for delayed load (at the expense of ops after those 100K),
the actual Load function only assigns raw data from save file into a variable, without any processing of the save data.

However according to comment in my OP, this limit also applies to Save but saving is for some reason much cheaper.
Logging, error and exception handling is the father and mother of all debugging.
User avatar
GoldMine
Traffic Manager
Traffic Manager
Posts: 197
Joined: 31 Oct 2024 20:59

Re: This script took tool long in the Load function

Post by GoldMine »

Btw. I think this limit of 100K should really depend on map size.

On small maps there is not much data to save, but on big maps there is a lot more to save, therefore the limit should scale.
Logging, error and exception handling is the father and mother of all debugging.
carlpeeter32
Engineer
Engineer
Posts: 2
Joined: 04 Oct 2026 20:25

Re: This script took tool long in the Load function

Post by carlpeeter32 »

The map-size-dependent limit sounds sensible to me. On a tiny map there is hardly any data to save, but on a huge map the same save routine has way more work to do and blows past the same limit. Scaling it with map size would keep small maps fast while giving big maps the headroom they need.
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 5 guests