MusicPlus core: Lua separation fixes

This commit is contained in:
mazmazz 2018-09-18 10:32:38 -04:00
parent 94393e759d
commit 41964e084d
4 changed files with 22 additions and 20 deletions

View file

@ -954,14 +954,9 @@ static int lib_pRestoreMusic(lua_State *L)
INLEVEL INLEVEL
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
if (!player || P_IsLocalPlayer(player)) else if (P_IsLocalPlayer(player))
{
P_RestoreMusic(player); P_RestoreMusic(player);
lua_pushboolean(L, true); return 0;
}
else
lua_pushnil(L);
return 1;
} }
static int lib_pSpawnShieldOrb(lua_State *L) static int lib_pSpawnShieldOrb(lua_State *L)
@ -2241,13 +2236,8 @@ static int lib_sChangeMusic(lua_State *L)
fadeinms = (UINT32)luaL_optinteger(L, 7, 0); fadeinms = (UINT32)luaL_optinteger(L, 7, 0);
if (!player || P_IsLocalPlayer(player)) if (!player || P_IsLocalPlayer(player))
{
S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms); S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms);
lua_pushboolean(L, true); return 0;
}
else
lua_pushnil(L);
return 1;
} }
static int lib_sSpeedMusic(lua_State *L) static int lib_sSpeedMusic(lua_State *L)
@ -2263,10 +2253,23 @@ static int lib_sSpeedMusic(lua_State *L)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
} }
if (!player || P_IsLocalPlayer(player)) if (!player || P_IsLocalPlayer(player))
lua_pushboolean(L, S_SpeedMusic(speed)); S_SpeedMusic(speed);
else return 0;
lua_pushnil(L); }
return 1;
static int lib_sStopMusic(lua_State *L)
{
player_t *player = NULL;
NOHUD
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (!player || P_IsLocalPlayer(player))
S_StopMusic();
return 0;
} }
static int lib_sOriginPlaying(lua_State *L) static int lib_sOriginPlaying(lua_State *L)
@ -2646,6 +2649,7 @@ static luaL_Reg lib[] = {
{"S_StopSound",lib_sStopSound}, {"S_StopSound",lib_sStopSound},
{"S_ChangeMusic",lib_sChangeMusic}, {"S_ChangeMusic",lib_sChangeMusic},
{"S_SpeedMusic",lib_sSpeedMusic}, {"S_SpeedMusic",lib_sSpeedMusic},
{"S_StopMusic",lib_sStopMusic},
{"S_OriginPlaying",lib_sOriginPlaying}, {"S_OriginPlaying",lib_sOriginPlaying},
{"S_IdPlaying",lib_sIdPlaying}, {"S_IdPlaying",lib_sIdPlaying},
{"S_SoundPlaying",lib_sSoundPlaying}, {"S_SoundPlaying",lib_sSoundPlaying},

View file

@ -48,7 +48,6 @@ enum hook {
hook_MobjMoveBlocked, hook_MobjMoveBlocked,
hook_MapThingSpawn, hook_MapThingSpawn,
hook_FollowMobj, hook_FollowMobj,
hook_MusicChange,
hook_MAX // last hook hook_MAX // last hook
}; };

View file

@ -59,7 +59,6 @@ const char *const hookNames[hook_MAX+1] = {
"MobjMoveBlocked", "MobjMoveBlocked",
"MapThingSpawn", "MapThingSpawn",
"FollowMobj", "FollowMobj",
"MusicChange",
NULL NULL
}; };

View file

@ -38,7 +38,7 @@ extern INT32 msg_id;
#include "p_local.h" // camera info #include "p_local.h" // camera info
#include "fastcmp.h" #include "fastcmp.h"
#ifdef HAVE_BLUA #if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
#include "lua_hook.h" // MusicChange hook #include "lua_hook.h" // MusicChange hook
#endif #endif