fixes to lua engine

- loading script does an implicit stop first
 - script dying of natural causes triggers a stop, and thus an OnStop event in lua first (for proper cleanup)
This commit is contained in:
zeromus 2008-07-29 22:51:24 +00:00
parent b47c5a9cf7
commit f0fb3d140e
4 changed files with 5 additions and 22 deletions

View File

@ -3,7 +3,6 @@ iuplua_open()
local iupcontrolslua_open = package.loadlib("iupluacontrols51.dll", "iupcontrolslua_open")
iupcontrolslua_open()
function emu.OnClose.iuplua()
if(emu.OnCloseIup ~= nil) then
emu.OnCloseIup();

View File

@ -163,7 +163,6 @@ void FCEUD_SetInput(bool fourscore, ESI port0, ESI port1, ESIFC fcexp);
void FCEUD_MovieRecordTo(void);
void FCEUD_MovieReplayFrom(void);
void FCEUD_LuaRunFrom(void);
void FCEUD_UpdateLuaMenus(void);
int32 FCEUI_GetDesiredFPS(void);
void FCEUI_SaveSnapshot(void);

View File

@ -1674,14 +1674,3 @@ void FCEUD_LuaRunFrom(void)
DialogBoxParam(fceu_hInstance, "IDD_LUA_ADD", hAppWnd, DlgLuaScriptDialog,(LPARAM) &success);
}
void FCEUD_UpdateLuaMenus()
{
MENUITEMINFO mii;
ZeroMemory( &mii, sizeof( mii));
mii.cbSize = sizeof( mii);
mii.fMask = MIIM_STATE;
mii.fState = MFS_UNCHECKED;
SetMenuItemInfo (fceumenu, ID_FILE_RUNLUASCRIPT, FALSE, &mii);
if (!FCEU_LuaRunning()) mii.fState |= MFS_DISABLED;
SetMenuItemInfo (fceumenu, ID_FILE_STOPLUASCRIPT, FALSE, &mii);
}

View File

@ -115,7 +115,6 @@ static void FCEU_LuaOnStop() {
if (wasPaused && !FCEUI_EmulationPaused())
FCEUI_ToggleEmulationPause();
FCEUD_SetEmulationSpeed(EMUSPEED_NORMAL);
FCEUD_UpdateLuaMenus();
}
@ -1463,7 +1462,7 @@ void FCEU_LuaFrameBoundary() {
#endif
} else {
FCEU_LuaOnStop();
FCEU_LuaStop();
FCEU_DispMessage("Script died of natural causes.\n");
}
@ -1491,6 +1490,9 @@ int FCEU_LoadLuaCode(const char *filename) {
luaScriptName = strdup(filename);
}
//stop any lua we might already have had running
FCEU_LuaStop();
if (!L) {
#ifdef WIN32
@ -1601,7 +1603,7 @@ void FCEU_ReloadLuaCode()
*/
void FCEU_LuaStop() {
// Kill it.
//already killed
if (!L) return;
//execute the user's shutdown callbacks
@ -1735,9 +1737,3 @@ void FCEU_LuaGui(uint8 *XBuf) {
return;
}
#ifndef WIN32
// stub for now
void FCEUD_UpdateLuaMenus()
{
}
#endif