MusicPlus core: Lua separation fixes

This commit is contained in:
mazmazz 2018-09-18 10:32:38 -04:00
parent c5ea6b5efe
commit 66283ce36a
3 changed files with 20 additions and 18 deletions

View file

@ -720,13 +720,8 @@ static int lib_pRestoreMusic(lua_State *L)
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
else if (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)
@ -1780,13 +1775,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)
@ -1802,10 +1792,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)
@ -2130,6 +2133,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

@ -43,7 +43,6 @@ enum hook {
hook_PlayerMsg, hook_PlayerMsg,
hook_HurtMsg, hook_HurtMsg,
hook_PlayerSpawn, hook_PlayerSpawn,
hook_MusicChange,
hook_MAX // last hook hook_MAX // last hook
}; };

View file

@ -54,7 +54,6 @@ const char *const hookNames[hook_MAX+1] = {
"PlayerMsg", "PlayerMsg",
"HurtMsg", "HurtMsg",
"PlayerSpawn", "PlayerSpawn",
"MusicChange",
NULL NULL
}; };