Add: [Script] GSAsyncMode to set async mode of gamescript commands (#10913)

In asynchronous mode, don't wait for result of executed command,
just fire-and-forget, and return estimated cost/result
This commit is contained in:
Jonathan G Rennison
2023-06-04 10:15:35 +01:00
committed by GitHub
parent 5821194ad1
commit 3effb8931c
6 changed files with 189 additions and 10 deletions

View File

@@ -26,6 +26,11 @@
*/
typedef bool (ScriptModeProc)();
/**
* The callback function for Async Mode-classes.
*/
typedef bool (ScriptAsyncModeProc)();
/**
* The storage for each script. It keeps track of important information.
*/
@@ -34,6 +39,8 @@ friend class ScriptObject;
private:
ScriptModeProc *mode; ///< The current build mode we are int.
class ScriptObject *mode_instance; ///< The instance belonging to the current build mode.
ScriptAsyncModeProc *async_mode; ///< The current command async mode we are in.
class ScriptObject *async_mode_instance; ///< The instance belonging to the current command async mode.
CompanyID root_company; ///< The root company, the company that the script really belongs to.
CompanyID company; ///< The current company.
@@ -61,6 +68,8 @@ public:
ScriptStorage() :
mode (nullptr),
mode_instance (nullptr),
async_mode (nullptr),
async_mode_instance (nullptr),
root_company (INVALID_OWNER),
company (INVALID_OWNER),
delay (1),