From 1f702802254834be3d5a2918689020ae3806ae92 Mon Sep 17 00:00:00 2001 From: ugetab Date: Sat, 1 May 2010 18:48:42 +0000 Subject: [PATCH] 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. --- src/input.h | 1 + src/lua-engine.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/input.h b/src/input.h index 9a432e72..e7d11a91 100644 --- a/src/input.h +++ b/src/input.h @@ -94,6 +94,7 @@ void FCEU_UpdateInput(void); void InitializeInput(void); void FCEU_UpdateBot(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. extern void InputScanlineHook(uint8 *bg, uint8 *spr, uint32 linets, int final); diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index dcd13c00..c6dc6c64 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -12,10 +12,16 @@ #ifdef __linux #include +#define SetCurrentDir chdir #include #include #endif +#ifdef WIN32 +#include +#define SetCurrentDir _chdir +#endif + #include "types.h" #include "fceu.h" #include "video.h" @@ -4590,6 +4596,14 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) { 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 FCEU_LuaStop();