Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading savegame with AI loaded as specific version of that AI fails to load correct version of AI #6468

Closed
DorpsGek opened this issue May 25, 2016 · 5 comments · Fixed by #8430
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) good first issue Good for newcomers

Comments

@DorpsGek
Copy link
Member

Wormnest opened the ticket and wrote:

I think there is a AI savegame bug.
Presuming you have both WormAI versions 4 and 5 available statt a new game, open console and do:
startai wormai.4

Run it for a while then save and reload the savegame.

Open console: it shows that savegame has an ai named ´wormai.4´ which is no longer available although obviously WormAI version 4 hasn't been deleted in the meantime.
It als shows that the latest version of the AI has been loaded instead but it didn't receive the savegame data because it's incompatible even though min version to load is 1. This might or might not be caused by the first error.

Note that version numbers are stored in the path inside the tar e.g. WormAI-v5, WormAI-v4 etc so this is not
https://bugs.openttd.org/task/6377

It looks at first glance that it saves the dot and version number as part of the ai name which looks wrong.

Attached example savegame showing the bug.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6468
@DorpsGek
Copy link
Member Author

Wormnest wrote:

See also discussion on IRC: http://irclogs.thegrebs.com/openttd/2016/05/25

Another savegame where I first removed WormAI v5 from content_download/ai and then started a game with the latest version of wormai (= 4).
Loading this again after adding v5 back loads version 5 but without the two complaints in the console. It also does load the savegame data for the AI in contrast to the other savegame.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6468#comment14194

@DorpsGek
Copy link
Member Author

Samu wrote:

Hi. From my limited understanding after dwelving into the code, the problem first arises in the console_cmds.cpp, line 1170.

config->Change(argv[1], -1, true);

It takes the value of argv[1], which is wormai.4 and uses that to find the correct version of the ai to start. That is fine, but this also sets the name of the AI, and this name is not corrected to the intended name that should have been retrieved from the ScriptInfo.

When the savegame function is asking for the name of the AI, it takes the wrong name, wormai.4, because it hasn't been corrected when it started via console. The savegame function also asks for the version of the AI, but there is no issue with this part: when the console found version 4 in the ScriptConfig, it also set the version to 4, the savegame functions retrieves version 4 as intended.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6468#comment14196

@DorpsGek
Copy link
Member Author

Samu wrote:

Perhaps it is intended that it doesn't correct the name of the AI, according to documentation.
https://noai.openttd.org/docs/trunk/classAIController.html# _details


This comment was imported from FlySpray: https://bugs.openttd.org/task/6468#comment14202

@DorpsGek
Copy link
Member Author

Samu wrote:

This fixes it, but my coding skills are horrible.

https://paste.openttdcoop.org/plsfqqmcn

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6468#comment14225

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 7, 2018
@TrueBrain TrueBrain added good first issue Good for newcomers patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay bug Something isn't working and removed bug from FlySpray labels Apr 13, 2018
@andythenorth andythenorth added the stale Stale issues label Jan 5, 2019
@andythenorth
Copy link
Contributor

The value of the attached patches is unclear, but the issue remains a bug. Re-labelling and leaving open, for now. It's not frequently reported, so may get closed in future.

@andythenorth andythenorth removed flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay stale Stale issues labels Jan 12, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 7, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 7, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Mar 1, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Mar 2, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Apr 7, 2019
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Jan 3, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Jan 8, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Jan 8, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 6, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 9, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Apr 1, 2020
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Dec 25, 2020
You can do: "startai myai.3", which starts version 3 of "myai".
This is very useful for testing save/load code between different
versions of your AI.

However, when using this syntax, the AI got saved as "myai.3" as
name of the AI, instead of "myai". This caused several problems,
like indicating to the user the AI could not be found, but still
load the AI. But in all cases, the AI never got the chance to
load the saved data, making the whole reason this exists pointless.

By splitting the name and version already in the console command,
the code becomes simpler and AIs started this way now follow the
normal flow after initialization.
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Dec 25, 2020
You can do: "startai myai.3", which starts version 3 of "myai".
This is very useful for testing save/load code between different
versions of your AI.

However, when using this syntax, the AI got saved as "myai.3" as
name of the AI, instead of "myai". This caused several problems,
like indicating to the user the AI could not be found, but still
load the AI. But in all cases, the AI never got the chance to
load the saved data, making the whole reason this exists pointless.

By splitting the name and version already in the console command,
the code becomes simpler and AIs started this way now follow the
normal flow after initialization.
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Dec 25, 2020
You can do: "startai myai.3", which starts version 3 of "myai".
This is very useful for testing save/load code between different
versions of your AI.

However, when using this syntax, the AI got saved as "myai.3" as
name of the AI, instead of "myai". This caused several problems,
like indicating to the user the AI could not be found, but still
load the AI. But in all cases, the AI never got the chance to
load the saved data, making the whole reason this exists pointless.

By splitting the name and version already in the console command,
the code becomes simpler and AIs started this way now follow the
normal flow after initialization.
TrueBrain added a commit that referenced this issue Dec 25, 2020
You can do: "startai myai.3", which starts version 3 of "myai".
This is very useful for testing save/load code between different
versions of your AI.

However, when using this syntax, the AI got saved as "myai.3" as
name of the AI, instead of "myai". This caused several problems,
like indicating to the user the AI could not be found, but still
load the AI. But in all cases, the AI never got the chance to
load the saved data, making the whole reason this exists pointless.

By splitting the name and version already in the console command,
the code becomes simpler and AIs started this way now follow the
normal flow after initialization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants