From df69c922e2775e5bd7d378fac55542f6272cfcb1 Mon Sep 17 00:00:00 2001 From: yellowtd <ren_amon@hotmail.com> Date: Sun, 13 Jul 2014 00:11:27 -0400 Subject: [PATCH] Fix: Added missing function to lua music freeslots Completely forgot the function required to get the music to be allocated in the first place. oops --- src/dehacked.c | 26 ++++++++++++++++++++++++++ src/sounds.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 9529486ae3..a15d4cea16 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -627,6 +627,8 @@ static void readfreeslots(MYFILE *f) // TODO: Name too long (truncated) warnings. if (fastcmp(type, "SFX")) S_AddSoundFx(word, false, 0, false); + else if (fastcmp(type, "MUS")) + S_AddMusic(word, -1); else if (fastcmp(type, "SPR")) { for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++) @@ -3454,6 +3456,19 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } DEH_WriteUndoline(word, word2, UNDO_HEADER); } + else if (fastcmp(word, "MUSIC")) + { + if (i == 0 && word2[0] != '0') // If word2 isn't a number + i = get_mus(word2); // find a sound by name + if (i < NUMMUSIC && i >= 0) + readmusic(f, i, savemusicnames); + else + { + deh_warning("Music %d out of range (0 - %d)", i, NUMMUSIC-1); + ignorelines(f); + } + DEH_WriteUndoline(word, word2, UNDO_HEADER); + } /* else if (fastcmp(word, "SPRITE")) { if (i < NUMSPRITES && i >= 0) @@ -8191,6 +8206,17 @@ static inline int lib_freeslot(lua_State *L) } else return r; } + else if (fastcmp(type, "MUS")) { + musicenum_t music; + strlwr(word); + CONS_Printf("Music mus_%s allocated.\n",word); + music = S_AddMusic(word, -1); + if (music != mus_None) { + lua_pushinteger(L, music); + r++; + } else + return r; + } else if (fastcmp(type, "SPR")) { char wad; diff --git a/src/sounds.h b/src/sounds.h index a2650b378b..04e729db83 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1647,6 +1647,7 @@ typedef enum void S_InitRuntimeSounds(void); sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound); +musicenum_t S_AddMusic(const char *name, INT32 dummyval); void S_RemoveSoundFx(sfxenum_t id); #endif -- GitLab