From 6042441275075bfff1c1e13e829819cd1721d0ff Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 8 May 2025 00:50:40 +0200 Subject: [PATCH] Update to new engine API version --- src/plugin_api.h | 19 +++++++++++++------ src/stingray_sdk.rs | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/plugin_api.h b/src/plugin_api.h index fe29b8c..6cb4c3c 100644 --- a/src/plugin_api.h +++ b/src/plugin_api.h @@ -69,7 +69,7 @@ typedef void *(*GetApiFunction)(unsigned api); struct PluginApi { #ifdef __cplusplus - uint32_t version = 65; + uint32_t version = 69; uint32_t flags = 3; // lua plugin #else uint32_t version; @@ -83,13 +83,19 @@ struct PluginApi { loaded. */ void (*loaded)(GetApiFunction get_engine_api); + // Seemingly not called by current versions of the engine, at least in release + // mode. /* Called at the start of a "hot reload" of the plugin DLL. Should return a pointer to a serialized "state" for the plugin.*/ void *(*start_reload)(GetApiFunction get_engine_api); + // Seemingly not called by current versions of the engine, at least in release + // mode. /* Called just before the plugin is unloaded. */ void (*unloaded)(); + // Seemingly not called by current versions of the engine, at least in release + // mode. /* Called to finalized the "hot reload" after the plugin has been reloaded with the new code. Should restore the state from the serialized state data. Note that it is the responsibility of the plugin to free the state data. */ @@ -223,9 +229,8 @@ struct LuaApi { int (*checkstack)(lua_State *L, int sz); void (*xmove)(lua_State *from, lua_State *to, int n); - const void *(*fnx1)(lua_State *L, int idx); - /* Access functions */ + int (*isnil)(lua_State *L, int idx); int (*isnumber)(lua_State *L, int idx); int (*isstring)(lua_State *L, int idx); int (*iscfunction)(lua_State *L, int idx); @@ -313,8 +318,6 @@ struct LuaApi { int (*gethookmask)(lua_State *L); int (*gethookcount)(lua_State *L); - // int (*fnx3) (lua_State* L); - /* Library functions */ void (*lib_openlib)(lua_State *L, const char *libname, const luaL_Reg *l, int nup); @@ -399,6 +402,8 @@ struct LuaApi { /* Gets a Unit at the specified index. */ CApiUnit *(*getunit)(lua_State *L, int i); + void *(*getunknown)(lua_State *L, int i); + /* Gets the Lua state where the main scripts execute. */ lua_State *(*getscriptenvironmentstate)(); @@ -423,8 +428,10 @@ struct LuaApi { /* Returns true if the stack entry is a UnitReference. */ int (*isunitreference)(lua_State *L, int i); + size_t (*objlen2)(lua_State *L, int idx); + /* Reserved for expansion of the API. */ - void *reserved[32]; + // void *reserved[30]; }; struct LoggingApi { diff --git a/src/stingray_sdk.rs b/src/stingray_sdk.rs index b046b63..1631c5c 100644 --- a/src/stingray_sdk.rs +++ b/src/stingray_sdk.rs @@ -13,16 +13,16 @@ use std::ffi::CString; use std::os::raw::c_char; use std::os::raw::c_void; -use bindings::lua_CFunction; -pub use bindings::lua_State; pub use bindings::GetApiFunction; pub use bindings::PluginApi; pub use bindings::PluginApiID; +use bindings::lua_CFunction; +pub use bindings::lua_State; impl std::default::Default for PluginApi { fn default() -> Self { Self { - version: 65, + version: 69, flags: 3, setup_game: None, update_game: None,