Dealt with bug 2746888. LUA now CDs to folder of LUA file on load. Added working Windows CD code, and test *NIX CD code. *NIX code still needs to be confirmed.

This commit is contained in:
ugetab 2010-05-01 18:48:42 +00:00
parent 0613eb2163
commit 1f70280225
2 changed files with 15 additions and 0 deletions

View File

@ -94,6 +94,7 @@ void FCEU_UpdateInput(void);
void InitializeInput(void); void InitializeInput(void);
void FCEU_UpdateBot(void); void FCEU_UpdateBot(void);
extern void (*PStrobe[2])(void); extern void (*PStrobe[2])(void);
void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp);
//called from PPU on scanline events. //called from PPU on scanline events.
extern void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final); extern void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final);

View File

@ -12,10 +12,16 @@
#ifdef __linux #ifdef __linux
#include <unistd.h> #include <unistd.h>
#define SetCurrentDir chdir
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#ifdef WIN32
#include <direct.h>
#define SetCurrentDir _chdir
#endif
#include "types.h" #include "types.h"
#include "fceu.h" #include "fceu.h"
#include "video.h" #include "video.h"
@ -4590,6 +4596,14 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) {
luaScriptName = strdup(filename); luaScriptName = strdup(filename);
} }
#if defined(WIN32) || defined(__linux)
std::string getfilepath = filename;
getfilepath = getfilepath.substr(0,getfilepath.find_last_of("/\\") + 1);
SetCurrentDir(getfilepath.c_str());
#endif
//stop any lua we might already have had running //stop any lua we might already have had running
FCEU_LuaStop(); FCEU_LuaStop();