Merge branch 'musicplus-core' into musicplus-feature-postboss

This commit is contained in:
mazmazz 2018-08-28 10:23:13 -04:00
commit 9a5b8ec671
4 changed files with 8 additions and 13 deletions

View file

@ -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_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 boolean LUAh_FollowMobj(player_t *player, mobj_t *mo); // Hook for P_PlayerAfterThink Smiles mobj-following
#ifdef HAVE_LUA_MUSICPLUS #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 UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
#endif #endif

View file

@ -1196,14 +1196,12 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj)
#ifdef HAVE_LUA_MUSICPLUS #ifdef HAVE_LUA_MUSICPLUS
// Hook for music changes // 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) UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms)
{ {
hook_p hookp; hook_p hookp;
boolean hooked = false; boolean hooked = false;
strncpy(newmusic, newname, 7);
if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8)))) if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8))))
return false; 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)) if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6))
hooked = true; hooked = true;
else if (lua_isstring(gL, -6)) else if (lua_isstring(gL, -6))
strncpy(newmusic, lua_tostring(gL, -6), 7); strncpy(newname, lua_tostring(gL, -6), 7);
// output 2: mflags override // output 2: mflags override
if (lua_isnumber(gL, -5)) if (lua_isnumber(gL, -5))
*mflags = lua_tonumber(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); lua_settop(gL, 0);
newmusic[6] = 0; newname[6] = 0;
return hooked; return hooked;
} }

View file

@ -1553,14 +1553,11 @@ void S_ChangeMusicAdvanced(const char *mmusic, UINT16 mflags, boolean looping, U
return; return;
char newmusic[7]; 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); 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 #endif
newmusic[6] = 0; newmusic[6] = 0;
// No Music (empty string) // No Music (empty string)

View file

@ -1114,7 +1114,7 @@ boolean I_PlaySong(boolean looping)
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false; 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()); CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false; return false;