Codechange: [Script] rework how compat-scripts work and are loaded (#13504)

- compat_NNN.nut files now only defines what is needed to downgrade from API NNN + 1 to NNN.
- Automatically load all required compatibility files based on the API version of the script, starting with the latest.
This commit is contained in:
Patric Stout
2025-02-09 16:04:04 +01:00
committed by GitHub
parent 2824e790ec
commit f60b3d7f79
42 changed files with 78 additions and 850 deletions

View File

@@ -261,11 +261,11 @@ protected:
/**
* Load squirrel scripts to emulate an older API.
* @param api_version: API version to load scripts for
* @param dir Subdirectory to find the scripts in
* @return true iff script loading should proceed
* @param dir Subdirectory to find the scripts in.
* @param api_versions List of available versions of the script type.
* @return true iff script loading should proceed.
*/
bool LoadCompatibilityScripts(const std::string &api_version, Subdirectory dir);
bool LoadCompatibilityScripts(Subdirectory dir, std::span<const std::string_view> api_versions);
/**
* Tell the script it died.
@@ -302,6 +302,14 @@ private:
*/
bool CallLoad();
/**
* Load squirrel script for a specific version to emulate an older API.
* @param api_version: API version to load scripts for.
* @param dir Subdirectory to find the scripts in.
* @return true iff script loading should proceed.
*/
bool LoadCompatibilityScript(std::string_view api_version, Subdirectory dir);
/**
* Save one object (int / string / array / table) to the savegame.
* @param vm The virtual machine to get all the data from.