diff --git a/src/BizHawk.Client.Common/Api/MemoryMappedFiles.cs b/src/BizHawk.Client.Common/Api/MemoryMappedFiles.cs index 7bd779bb95..c41f35000b 100644 --- a/src/BizHawk.Client.Common/Api/MemoryMappedFiles.cs +++ b/src/BizHawk.Client.Common/Api/MemoryMappedFiles.cs @@ -27,7 +27,15 @@ namespace BizHawk.Client.Common return Encoding.UTF8.GetString(bytes); } - public int ScreenShotToFile() => WriteToFile(Filename, _takeScreenshotCallback()); + public int ScreenShotToFile() + { + if (Filename is null) + { + Console.WriteLine("MMF screenshot target not set; start EmuHawk with `--mmf=filename`"); + return 0; + } + return WriteToFile(Filename, _takeScreenshotCallback()); + } public int WriteToFile(string filename, byte[] outputBytes) { diff --git a/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs b/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs index 2c5574264a..78d1de1af0 100644 --- a/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs +++ b/src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.Common return APIs.Comm.Sockets.SendString(SendString); } - [LuaMethod("socketServerSendBytes", "sends a string to the Socket server")] + [LuaMethod("socketServerSendBytes", "sends bytes to the Socket server")] public int SocketServerSendBytes(LuaTable byteArray) { if (!CheckSocketServer()) return -1; @@ -133,43 +133,30 @@ namespace BizHawk.Client.Common [LuaMethod("mmfSetFilename", "Sets the filename for the screenshots")] public void MmfSetFilename(string filename) { - CheckMmf(); APIs.Comm.MMF.Filename = filename; } [LuaMethod("mmfGetFilename", "Gets the filename for the screenshots")] public string MmfGetFilename() { - CheckMmf(); - return APIs.Comm.MMF?.Filename; + return APIs.Comm.MMF.Filename; } [LuaMethod("mmfScreenshot", "Saves screenshot to memory mapped file")] public int MmfScreenshot() { - CheckMmf(); return APIs.Comm.MMF.ScreenShotToFile(); } [LuaMethod("mmfWrite", "Writes a string to a memory mapped file")] public int MmfWrite(string mmf_filename, string outputString) { - CheckMmf(); return APIs.Comm.MMF.WriteToFile(mmf_filename, outputString); } [LuaMethod("mmfRead", "Reads a string from a memory mapped file")] public string MmfRead(string mmf_filename, int expectedSize) { - CheckMmf(); - return APIs.Comm.MMF?.ReadFromFile(mmf_filename, expectedSize); - } - - private void CheckMmf() - { - if (APIs.Comm.MMF == null) - { - Log("Memory mapped file was not initialized, please initialize it via the command line"); - } + return APIs.Comm.MMF.ReadFromFile(mmf_filename, expectedSize); } // All HTTP related methods diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 5dc6bc29b2..fe5d421d1c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -605,9 +605,7 @@ namespace BizHawk.Client.EmuHawk _argParser.HTTPAddresses == null ? null : new HttpCommunication(NetworkingTakeScreenshot, _argParser.HTTPAddresses.Value.UrlGet, _argParser.HTTPAddresses.Value.UrlPost), - _argParser.MMFFilename == null - ? null - : new MemoryMappedFiles(NetworkingTakeScreenshot, _argParser.MMFFilename), + new MemoryMappedFiles(NetworkingTakeScreenshot, _argParser.MMFFilename), _argParser.SocketAddress == null ? null : new SocketServer(NetworkingTakeScreenshot, _argParser.SocketAddress.Value.IP, _argParser.SocketAddress.Value.Port)