diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 62481ac7..27d804ac 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -187,16 +187,16 @@ void EmuInstance::deleteWindow(int id, bool close) emuThread->detachWindow(win); - if (close) - win->close(); - windowList[id] = nullptr; numWindows--; if (topWindow == win) topWindow = nullptr; if (mainWindow == win) mainWindow = nullptr; - if ((!mainWindow) && !deleting) + if (close) + win->close(); + + if ((!mainWindow) && (!deleting)) { // if we closed this instance's main window, delete the instance deleteEmuInstance(instanceID); diff --git a/src/frontend/qt_sdl/LAN.cpp b/src/frontend/qt_sdl/LAN.cpp index 322ce05d..9b4e5bbd 100644 --- a/src/frontend/qt_sdl/LAN.cpp +++ b/src/frontend/qt_sdl/LAN.cpp @@ -1,5 +1,5 @@ /* - Copyright 2016-2022 melonDS team + Copyright 2016-2024 melonDS team This file is part of melonDS. diff --git a/src/frontend/qt_sdl/LAN.h b/src/frontend/qt_sdl/LAN.h index 347980ac..5a732fed 100644 --- a/src/frontend/qt_sdl/LAN.h +++ b/src/frontend/qt_sdl/LAN.h @@ -1,5 +1,5 @@ /* - Copyright 2016-2022 melonDS team + Copyright 2016-2024 melonDS team This file is part of melonDS. diff --git a/src/frontend/qt_sdl/Netplay.cpp b/src/frontend/qt_sdl/Netplay.cpp index 1e1a3a36..b1bdea84 100644 --- a/src/frontend/qt_sdl/Netplay.cpp +++ b/src/frontend/qt_sdl/Netplay.cpp @@ -1,5 +1,5 @@ /* - Copyright 2016-2022 melonDS team + Copyright 2016-2024 melonDS team This file is part of melonDS. diff --git a/src/frontend/qt_sdl/Netplay.h b/src/frontend/qt_sdl/Netplay.h index b869fefc..1eff54b0 100644 --- a/src/frontend/qt_sdl/Netplay.h +++ b/src/frontend/qt_sdl/Netplay.h @@ -1,5 +1,5 @@ /* - Copyright 2016-2022 melonDS team + Copyright 2016-2024 melonDS team This file is part of melonDS. diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt index 082c00fb..0b0be117 100644 --- a/src/net/CMakeLists.txt +++ b/src/net/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(net-utils STATIC Net_Slirp.cpp PacketDispatcher.cpp LocalMP.cpp + MPInterface.h ) target_include_directories(net-utils PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/net/MPInterface.h b/src/net/MPInterface.h new file mode 100644 index 00000000..e86736e6 --- /dev/null +++ b/src/net/MPInterface.h @@ -0,0 +1,50 @@ +/* + Copyright 2016-2024 melonDS team + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#ifndef MPINTERFACE_H +#define MPINTERFACE_H + +#include "types.h" + +namespace melonDS +{ + +class MPInterface +{ +public: + [[nodiscard]] int GetRecvTimeout() const noexcept { return RecvTimeout; } + void SetRecvTimeout(int timeout) noexcept { RecvTimeout = timeout; } + + virtual void Begin(int inst) = 0; + virtual void End(int inst) = 0; + + virtual int SendPacket(int inst, u8* data, int len, u64 timestamp) = 0; + virtual int RecvPacket(int inst, u8* data, u64* timestamp) = 0; + virtual int SendCmd(int inst, u8* data, int len, u64 timestamp) = 0; + virtual int SendReply(int inst, u8* data, int len, u64 timestamp, u16 aid) = 0; + virtual int SendAck(int inst, u8* data, int len, u64 timestamp) = 0; + virtual int RecvHostPacket(int inst, u8* data, u64* timestamp) = 0; + virtual u16 RecvReplies(int inst, u8* data, u64 timestamp, u16 aidmask) = 0; + +protected: + int RecvTimeout = 25; +}; + +} + +#endif // MPINTERFACE_H