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

GameScripts cant be upgraded in a running game #4933

Closed
DorpsGek opened this issue Jan 1, 2012 · 5 comments
Closed

GameScripts cant be upgraded in a running game #4933

DorpsGek opened this issue Jan 1, 2012 · 5 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jan 1, 2012

Zuu opened the ticket and wrote:

== Problem: ==
User starts a new game which includes a GameScript, version X.

Later version Y of the GameScript is made available on bananas which User get as he/she is regularly checking for bananas updates. Version Y contains a fix of an annoying bug in version X.

User loads his/her game and expects to get the new version of the GameScript where the annoying bug is fixed. After all this is how it works with AIs. However, with GameScripts, OpenTTD stays with version X in this particular savegame forever.

== Bad user workaround: ==
The only way the user could get around this is to remove version X from disk (or move it out of sight for OpenTTD), then untar version Y and change info.nut so that it looks like version X. However, this is a bad in two ways:

  1. It requires more knowledge about internals of OpenTTD/GameScript than the average user can be expected to have.
  2. The API for telling which GS version the game was previously saved with will not work as expected by the GS author. Thus it may cause the script to wrongly apply version conversion code.

Reported version: Version?
Operating system: All


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

DorpsGek commented Jan 1, 2012

Zuu wrote:

Clarification regarding
"The API for telling which GS version the game was previously saved with will not work as expected by the GS author"

I mean that GSController::Load(version, table) will be giver version X also after the user has used the hacky workaround. As A GS/AI author I expect to be able to check if version is equal to my current version ( => apply normal loading code ) or if it is less than current version ( => apply backward compatibility conversion code ). If a user fool OpenTTD to use my newer GS under the old version it will cause trouble here. OpenTTD will at each save+load of this savegame report version == X, while the user really runs version Y of the game script.

If all this is too confusing. Just ignore everything about the bad user workaround and fix the problem instead. ;-)


This comment was imported from FlySpray: https://bugs.openttd.org/task/4933#comment10646

@DorpsGek
Copy link
Member Author

Zuu wrote:

Actually, when reviewing the OpenTTD code to see if I could make a patch on this topic, I found out that the loading code of gamescripts follow the exact same logic as AIs in regard of which version to load.

So there is no problem that OpenTTD can't pick a newer GS to load a script. It does that already.

A different problem though is that MinVersionToLoad doesn't work as intended. Yes, first time it rejects loading but then because it can't find a working version it tries next time to use the last version. A solution could be that the step when OpenTTD scans for scripts/ais, it remembers not just the last version but also older versions.

Note also that the docs (http://nogo.openttd.org/api/trunk/classGSInfo.html# 44f99f7837e3fcbb863faebef07589b6) specify that the default behaviour when MinVersionToLoad should be that OpenTTD should not load the save game with a newer version of the script. Only if a script explicitly tells OpenTTD to do so, it should use a newer version of the script to load the save.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4933#comment10777

@DorpsGek
Copy link
Member Author

Zuu wrote:

Relevant places to look:
game_scanner.cpp, line 72 (here it rejects loading if min_version_to_load condition is not met)
game_sl.cpp, line 76 (here it first tries to load using the version specified in the save and then using -1 (latest) when that fails)


This comment was imported from FlySpray: https://bugs.openttd.org/task/4933#comment10778

@DorpsGek
Copy link
Member Author

Zuu wrote:

Sorry, the code works fine. My problem was that OpenTTD didn't find my old version of Tutorial unless I first untared them first for some reason.

This task can be closed :-)


This comment was imported from FlySpray: https://bugs.openttd.org/task/4933#comment10779

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Requested by user


This comment was imported from FlySpray: https://bugs.openttd.org/task/4933

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Goal/Game script labels Apr 7, 2018
@frosch123 frosch123 added the component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) label Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

2 participants