Changed CheckEnum to use lua_isnoneornil so that enum args can be made properly optional. Changed PlayMusicPart to allow nil for optional args so optional args would be independent.

This commit is contained in:
Kyzentun
2014-08-02 00:38:33 -07:00
committed by Jonathan Payne
parent fe08728393
commit adfc259b71
2 changed files with 19 additions and 21 deletions
+1 -3
View File
@@ -6,9 +6,7 @@
int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const char *szType, bool bAllowInvalid, bool bAllowAnything ) int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const char *szType, bool bAllowInvalid, bool bAllowAnything )
{ {
luaL_checkany( L, iPos ); if( lua_isnoneornil(L, iPos) )
if( lua_isnil(L, iPos) )
{ {
if( bAllowInvalid ) if( bAllowInvalid )
return iInvalid; return iInvalid;
+10 -10
View File
@@ -728,7 +728,7 @@ void GameSoundManager::PlayMusic( PlayMusicParams params, PlayMusicParams Fallba
ToPlay.fFadeInLengthSeconds = params.fFadeInLengthSeconds; ToPlay.fFadeInLengthSeconds = params.fFadeInLengthSeconds;
ToPlay.fFadeOutLengthSeconds = params.fFadeOutLengthSeconds; ToPlay.fFadeOutLengthSeconds = params.fFadeOutLengthSeconds;
ToPlay.bAlignBeat = params.bAlignBeat; ToPlay.bAlignBeat = params.bAlignBeat;
ToPlay.bApplyMusicRate = params.bApplyMusicRate; x ToPlay.bApplyMusicRate = params.bApplyMusicRate;
/* Add the MusicToPlay to the g_MusicsToPlay queue. */ /* Add the MusicToPlay to the g_MusicsToPlay queue. */
g_Mutex->Lock(); g_Mutex->Lock();
@@ -835,26 +835,26 @@ public:
bool loop= false; bool loop= false;
bool applyRate= false; bool applyRate= false;
bool alignBeat= true; bool alignBeat= true;
if (lua_gettop(L) >= 4 && !lua_isnil(L,4)) if(!lua_isnoneornil(L, 4))
{ {
fadeIn = FArg(4); fadeIn = FArg(4);
if (lua_gettop(L) >= 5 && !lua_isnil(L,5)) }
if(!lua_isnoneornil(L, 5))
{ {
fadeOut = FArg(5); fadeOut = FArg(5);
if (lua_gettop(L) >= 6 && !lua_isnil(L,6)) }
if(!lua_isnoneornil(L, 6))
{ {
loop = BArg(6); loop = BArg(6);
if (lua_gettop(L) >= 7 && !lua_isnil(L,7)) }
if(!lua_isnoneornil(L, 7))
{ {
applyRate = BArg(7); applyRate = BArg(7);
if (lua_gettop(L) >= 8 && !lua_isnil(L,8)) }
if(!lua_isnoneornil(L, 8))
{ {
alignBeat = BArg(8); alignBeat = BArg(8);
} }
}
}
}
}
p->PlayMusic(musicPath, NULL, loop, musicStart, musicLength, p->PlayMusic(musicPath, NULL, loop, musicStart, musicLength,
fadeIn, fadeOut, alignBeat, applyRate); fadeIn, fadeOut, alignBeat, applyRate);
return 0; return 0;