diff --git a/src/lua_hook.h b/src/lua_hook.h index e3a968bc2..f445b0c42 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -89,7 +89,7 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type boolean LUAh_FollowMobj(player_t *player, mobj_t *mo); // Hook for P_PlayerAfterThink Smiles mobj-following #ifdef HAVE_LUA_MUSICPLUS -boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusic, UINT16 *mflags, boolean *looping, +boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 99009f065..8d0ce2d16 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1196,14 +1196,12 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) #ifdef HAVE_LUA_MUSICPLUS // Hook for music changes -boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusic, UINT16 *mflags, boolean *looping, +boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms) { hook_p hookp; boolean hooked = false; - strncpy(newmusic, newname, 7); - if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8)))) return false; @@ -1231,7 +1229,7 @@ boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusi if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) hooked = true; else if (lua_isstring(gL, -6)) - strncpy(newmusic, lua_tostring(gL, -6), 7); + strncpy(newname, lua_tostring(gL, -6), 7); // output 2: mflags override if (lua_isnumber(gL, -5)) *mflags = lua_tonumber(gL, -5); @@ -1252,7 +1250,7 @@ boolean LUAh_MusicChange(const char *oldname, const char *newname, char *newmusi } lua_settop(gL, 0); - newmusic[6] = 0; + newname[6] = 0; return hooked; } diff --git a/src/s_sound.c b/src/s_sound.c index 129cc5f39..736a4ffd1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1553,14 +1553,11 @@ void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, U return; char newmusic[7]; - -#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) - if(LUAh_MusicChange(music_name, mmusic, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) - return; -#else strncpy(newmusic, mmusic, 7); +#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) + if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + return; #endif - newmusic[6] = 0; // No Music (empty string) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index b220178f3..30ddbd275 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1114,7 +1114,7 @@ boolean I_PlaySong(boolean looping) CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false; } - else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, -1) == -1) // if MOD, loop forever + else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false;