EMI: Fix implementation of ImStateHasEnded.

This commit is contained in:
Joni Vähämäki 2014-07-20 15:19:14 +03:00
parent 2a8820bbee
commit 146af5a498
3 changed files with 11 additions and 2 deletions

View File

@ -111,8 +111,7 @@ void Lua_V2::ImStateHasEnded() {
int state = (int)lua_getnumber(stateObj);
// FIXME: Make sure this logic is correct.
pushbool(g_imuseState != state);
pushbool(g_emiSound->stateHasEnded(state));
Debug::debug(Debug::Sound | Debug::Scripts, "Lua_V2::ImStateHasEnded: state %d.", state);
}

View File

@ -315,6 +315,15 @@ bool EMISound::stateHasLooped(int stateId) {
return false;
}
bool EMISound::stateHasEnded(int stateId) {
if (stateId == _curMusicState) {
if (_musicChannel != -1 && _channels[_musicChannel] != nullptr) {
return !_channels[_musicChannel]->isPlaying();
}
}
return true;
}
void EMISound::setMusicState(int stateId) {
Common::StackLock lock(_mutex);
if (stateId == _curMusicState)

View File

@ -75,6 +75,7 @@ public:
void selectMusicSet(int setId);
bool stateHasLooped(int stateId);
bool stateHasEnded(int stateId);
void restoreState(SaveGame *savedState);
void saveState(SaveGame *savedState);