move LAN/netplay stuff to net-utils
This commit is contained in:
parent
bdbcd9c351
commit
7b40d3f6ca
|
@ -52,8 +52,6 @@ set(SOURCES_QT_SDL
|
||||||
CLI.h
|
CLI.h
|
||||||
CLI.cpp
|
CLI.cpp
|
||||||
|
|
||||||
LAN.cpp
|
|
||||||
Netplay.cpp
|
|
||||||
LANDialog.cpp
|
LANDialog.cpp
|
||||||
NetplayDialog.cpp
|
NetplayDialog.cpp
|
||||||
)
|
)
|
||||||
|
@ -93,8 +91,6 @@ add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
|
||||||
|
|
||||||
add_executable(melonDS ${SOURCES_QT_SDL})
|
add_executable(melonDS ${SOURCES_QT_SDL})
|
||||||
|
|
||||||
find_package(ENet REQUIRED)
|
|
||||||
|
|
||||||
add_subdirectory("../../net"
|
add_subdirectory("../../net"
|
||||||
"${CMAKE_BINARY_DIR}/net"
|
"${CMAKE_BINARY_DIR}/net"
|
||||||
)
|
)
|
||||||
|
@ -182,7 +178,6 @@ endif()
|
||||||
target_link_libraries(melonDS PRIVATE core)
|
target_link_libraries(melonDS PRIVATE core)
|
||||||
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::LibArchive PkgConfig::Zstd)
|
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::LibArchive PkgConfig::Zstd)
|
||||||
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
|
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||||
target_link_libraries(melonDS PRIVATE ${ENET_LIBRARIES})
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" ON)
|
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" ON)
|
||||||
|
|
|
@ -17,37 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
|
|
||||||
#define socket_t SOCKET
|
|
||||||
#define sockaddr_t SOCKADDR
|
|
||||||
#define sockaddr_in_t SOCKADDR_IN
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#define socket_t int
|
|
||||||
#define sockaddr_t struct sockaddr
|
|
||||||
#define sockaddr_in_t struct sockaddr_in
|
|
||||||
#define closesocket close
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INVALID_SOCKET
|
|
||||||
#define INVALID_SOCKET (socket_t)-1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <enet/enet.h>
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
@ -232,7 +205,8 @@ void LANStartClientDialog::updateDiscoveryList()
|
||||||
|
|
||||||
void LANStartClientDialog::doUpdateDiscoveryList()
|
void LANStartClientDialog::doUpdateDiscoveryList()
|
||||||
{
|
{
|
||||||
LAN::DiscoveryMutex.lock();
|
if (LAN::DiscoveryMutex)
|
||||||
|
Platform::Mutex_Lock(LAN::DiscoveryMutex);
|
||||||
|
|
||||||
QStandardItemModel* model = (QStandardItemModel*)ui->tvAvailableGames->model();
|
QStandardItemModel* model = (QStandardItemModel*)ui->tvAvailableGames->model();
|
||||||
int curcount = model->rowCount();
|
int curcount = model->rowCount();
|
||||||
|
@ -277,7 +251,8 @@ void LANStartClientDialog::doUpdateDiscoveryList()
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
LAN::DiscoveryMutex.unlock();
|
if (LAN::DiscoveryMutex)
|
||||||
|
Platform::Mutex_Unlock(LAN::DiscoveryMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,9 @@ add_library(net-utils STATIC
|
||||||
Net_Slirp.cpp
|
Net_Slirp.cpp
|
||||||
PacketDispatcher.cpp
|
PacketDispatcher.cpp
|
||||||
LocalMP.cpp
|
LocalMP.cpp
|
||||||
MPInterface.h
|
LAN.cpp
|
||||||
MPInterface.cpp
|
Netplay.cpp
|
||||||
|
MPInterface.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(net-utils PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(net-utils PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
@ -21,3 +22,6 @@ else()
|
||||||
target_include_directories(net-utils SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/libslirp/glib")
|
target_include_directories(net-utils SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/libslirp/glib")
|
||||||
target_link_libraries(net-utils PRIVATE slirp)
|
target_link_libraries(net-utils PRIVATE slirp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_package(ENet REQUIRED)
|
||||||
|
target_link_libraries(net-utils PRIVATE ${ENET_LIBRARIES})
|
||||||
|
|
|
@ -91,7 +91,7 @@ const int kLANPort = 7064;
|
||||||
socket_t DiscoverySocket;
|
socket_t DiscoverySocket;
|
||||||
u32 DiscoveryLastTick;
|
u32 DiscoveryLastTick;
|
||||||
std::map<u32, DiscoveryData> DiscoveryList;
|
std::map<u32, DiscoveryData> DiscoveryList;
|
||||||
QMutex DiscoveryMutex;
|
Platform::Mutex* DiscoveryMutex = nullptr;
|
||||||
|
|
||||||
bool Active;
|
bool Active;
|
||||||
bool IsHost;
|
bool IsHost;
|
||||||
|
@ -120,6 +120,8 @@ u32 FrameCount;
|
||||||
|
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
|
DiscoveryMutex = Platform::Mutex_Create();
|
||||||
|
|
||||||
DiscoverySocket = INVALID_SOCKET;
|
DiscoverySocket = INVALID_SOCKET;
|
||||||
DiscoveryLastTick = 0;
|
DiscoveryLastTick = 0;
|
||||||
|
|
||||||
|
@ -183,6 +185,9 @@ void DeInit()
|
||||||
Host = nullptr;
|
Host = nullptr;
|
||||||
|
|
||||||
enet_deinitialize();
|
enet_deinitialize();
|
||||||
|
|
||||||
|
Platform::Mutex_Free(DiscoveryMutex);
|
||||||
|
DiscoveryMutex = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -413,7 +418,7 @@ void ProcessDiscovery()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DiscoveryMutex.lock();
|
Platform::Mutex_Lock(DiscoveryMutex);
|
||||||
|
|
||||||
// listen for LAN sessions
|
// listen for LAN sessions
|
||||||
|
|
||||||
|
@ -467,7 +472,7 @@ void ProcessDiscovery()
|
||||||
DiscoveryList.erase(key);
|
DiscoveryList.erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscoveryMutex.unlock();
|
Platform::Mutex_Unlock(DiscoveryMutex);
|
||||||
|
|
||||||
// update the list in the connect dialog if needed
|
// update the list in the connect dialog if needed
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "Platform.h"
|
||||||
|
|
||||||
namespace LAN
|
namespace LAN
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ struct DiscoveryData
|
||||||
extern bool Active;
|
extern bool Active;
|
||||||
|
|
||||||
extern std::map<u32, DiscoveryData> DiscoveryList;
|
extern std::map<u32, DiscoveryData> DiscoveryList;
|
||||||
extern QMutex DiscoveryMutex; // TODO: turn into Platform::Mutex or rework this to be nicer
|
extern Platform::Mutex* DiscoveryMutex; // TODO: turn into Platform::Mutex or rework this to be nicer
|
||||||
|
|
||||||
extern Player Players[16];
|
extern Player Players[16];
|
||||||
extern u32 PlayerPing[16];
|
extern u32 PlayerPing[16];
|
|
@ -23,9 +23,6 @@
|
||||||
|
|
||||||
#include <enet/enet.h>
|
#include <enet/enet.h>
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
#include "NDS.h"
|
#include "NDS.h"
|
||||||
#include "NDSCart.h"
|
#include "NDSCart.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -33,14 +30,10 @@
|
||||||
#include "Netplay.h"
|
#include "Netplay.h"
|
||||||
//#include "Input.h"
|
//#include "Input.h"
|
||||||
//#include "ROMManager.h"
|
//#include "ROMManager.h"
|
||||||
#include "Config.h"
|
//#include "Config.h"
|
||||||
#include "Savestate.h"
|
#include "Savestate.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
#include "ui_NetplayStartHostDialog.h"
|
|
||||||
#include "ui_NetplayStartClientDialog.h"
|
|
||||||
#include "ui_NetplayDialog.h"
|
|
||||||
|
|
||||||
using namespace melonDS;
|
using namespace melonDS;
|
||||||
|
|
||||||
namespace Netplay
|
namespace Netplay
|
Loading…
Reference in New Issue