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 39e90ec: Integers for scripts are 64bit, but saved as 32bit #9415

Merged
merged 1 commit into from Jul 6, 2021

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Jul 6, 2021

Motivation / Problem

In 39e90ec, integer for scripts was made 64bits always.
But before this change they were always saved as 32bits, mainly for compatibility.

Description

Now they are saved as 64bit. A savegame bump is of course required.

Limitations

May need some documentation fixes and updates too.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Copy link
Contributor

@rubidium42 rubidium42 left a comment

Choose a reason for hiding this comment

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

I haven't found any documentation mentioning saving 32 bits values, so it's safe on that front. However, the links (2) in the documentation of ScriptController to the AI:Save/Load page on the wiki are broken. I guess they should now be https://wiki.openttd.org/en/Development/Script/Save%20and%20Load. That page does not seem to mention the values being 32 bits either, so it doesn't need to be updated.

src/saveload/saveload.h Outdated Show resolved Hide resolved
@@ -364,8 +364,8 @@ static const SaveLoad _script_byte[] = {
SQInteger res;
sq_getinteger(vm, index, &res);
if (!test) {
int value = (int)res;
SlCopy(&value, 1, SLE_INT32);
int64 value = (int64)res;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the cast should not be needed as SQInteger is already defined at __int64. Explicitly having a separate variable of the right type is definitely a good thing.

@glx22 glx22 merged commit ddafc0d into OpenTTD:master Jul 6, 2021
@glx22 glx22 deleted the script_save branch July 6, 2021 19:09
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.

None yet

2 participants