From fa2ffcdcb902e065adffa1af3ee5a53d63308a86 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:50:19 -0400 Subject: [PATCH] Readd 'loaded' field to mod audio for CS compatibility --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/pc/lua/smlua_cobject_autogen.c | 3 ++- src/pc/lua/utils/smlua_audio_utils.c | 1 + src/pc/lua/utils/smlua_audio_utils.h | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 1994e114..3019d9f3 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -1071,6 +1071,7 @@ --- @field public baseVolume number --- @field public file ModFile --- @field public isStream boolean +--- @field public loaded boolean --- @field public sampleCopiesTail ModAudioSampleCopies --- @class ModAudioSampleCopies diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 46247b89..c17994e7 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1454,6 +1454,7 @@ | baseVolume | `number` | | | file | [ModFile](structs.md#ModFile) | | | isStream | `boolean` | | +| loaded | `boolean` | | | sampleCopiesTail | [ModAudioSampleCopies](structs.md#ModAudioSampleCopies) | | [:arrow_up_small:](#) diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 793e426a..bb86d9ac 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1199,11 +1199,12 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = { // { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED }; -#define LUA_MOD_AUDIO_FIELD_COUNT 4 +#define LUA_MOD_AUDIO_FIELD_COUNT 5 static struct LuaObjectField sModAudioFields[LUA_MOD_AUDIO_FIELD_COUNT] = { { "baseVolume", LVT_F32, offsetof(struct ModAudio, baseVolume), false, LOT_NONE }, { "file", LVT_COBJECT_P, offsetof(struct ModAudio, file), false, LOT_MODFILE }, { "isStream", LVT_BOOL, offsetof(struct ModAudio, isStream), false, LOT_NONE }, + { "loaded", LVT_BOOL, offsetof(struct ModAudio, loaded), false, LOT_NONE }, { "sampleCopiesTail", LVT_COBJECT_P, offsetof(struct ModAudio, sampleCopiesTail), false, LOT_MODAUDIOSAMPLECOPIES }, // { "sound", LVT_???, offsetof(struct ModAudio, sound), false, LOT_??? }, <--- UNIMPLEMENTED }; diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 192d0383..6b3ec9ee 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -262,6 +262,7 @@ struct ModAudio* audio_load_internal(const char* filename, bool isStream) { } audio->isStream = isStream; + audio->loaded = true; return audio; } diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index c33f294f..9a51b0e4 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -24,6 +24,7 @@ struct ModAudio { struct ModAudioSampleCopies* sampleCopiesTail; bool isStream; f32 baseVolume; + bool loaded; }; struct ModAudio* audio_stream_load(const char* filename);