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

Fix #6468: don't store version of AIs-started-via-console in name #8430

Merged
merged 2 commits into from Dec 25, 2020

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Dec 25, 2020

Motivation / Problem

AI started from the console with an exact version behaved strangely. This is a long outstanding issue. #7193 tries to solve it, but the solution felt rather complicated. So I dived in to find the root-cause .. turns out it is a 10 year old bug :D

I wrote out my full analysis here:
#7193 (comment)

Fixes #6468

Description

Fix #6468: don't store version of AIs started via console in name

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.

Limitations

  • Save/load loads the latest compatible AI; one could think that when started with the exact version, it should retain that. This makes no sense to me, as the only real reason I can think of that you want to load an older version, is to check if your save/load code still works. If other use-cases present themself, we can always store the force_exact_match variable next to the AI. But as I currently do not see the use-case, I left that out.
  • This does not fix old savegames; in fact, one could argue it breaks old savegames more, as it doesn't even try to load the AI anymore with any version (which it did use to do, despite telling in the console it did not).

It was rather confusing that "library_name" was calculated, and
then not used to do the FindLibrary() call. Flipping those two
blocks around makes it a bit more sane to read.
@TrueBrain TrueBrain changed the title Ai version Fix #6468: don't store version of AIs started via console in name Dec 25, 2020
@TrueBrain TrueBrain changed the title Fix #6468: don't store version of AIs started via console in name Fix #6468: don't store version of AIs-started-via-console in name 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.
Copy link
Contributor

@glx22 glx22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading savegame with AI loaded as specific version of that AI fails to load correct version of AI
2 participants