fix psvita being in trial mode + play game button freezing the entire game (#22)

fixed lock crash and enabled full mode for vita

---------

Co-authored-by: 552eden <552eden@gmail.com>
Reviewed-on: #22
Co-authored-by: ubergamer-pie <16+ubergamer-pie@noreply.localhost>
This commit was merged in pull request #22.
This commit is contained in:
2026-08-04 22:19:29 +00:00
committed by pieeebot
co-authored by 552eden
parent 5451249347
commit 2840b7620b
2 changed files with 27 additions and 9 deletions
@@ -57,6 +57,9 @@ std::vector<BYTE> NetworkSocketLayer::s_disconnectedSmallIds;
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
// only goes true on a successful Initialize(), and a failed one gets retried
static bool s_locksCreated = false;
bool g_MultiplayerHost = false;
bool g_MultiplayerJoin = true;
int g_MultiplayerPort = NETWORK_LAN_DEFAULT_PORT;
@@ -65,6 +68,19 @@ char g_MultiplayerIP[256] = "127.0.0.1";
bool NetworkSocketLayer::Initialize()
{
if (s_initialized) return true;
// Create the locks before touching the platform network stack.
if (!s_locksCreated)
{
InitializeCriticalSection(&s_sendLock);
InitializeCriticalSection(&s_connectionsLock);
InitializeCriticalSection(&s_advertiseLock);
InitializeCriticalSection(&s_discoveryLock);
InitializeCriticalSection(&s_disconnectLock);
InitializeCriticalSection(&s_freeSmallIdLock);
s_locksCreated = true;
}
#if defined _WINDOWS64 || defined _XBOX
WSADATA wsaData;
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
@@ -95,19 +111,13 @@ bool NetworkSocketLayer::Initialize()
param.flags = 0;
int result = sceNetInit(&param);
if (result < 0) {
app.DebugPrintf("sceNetInit failed: %d\n", result);
// libnet is brought up before us by the platform layer, which reports EBUSY here.
if (result < 0 && result != SCE_NET_ERROR_EBUSY) {
app.DebugPrintf("sceNetInit failed: 0x%08x\n", result);
return false;
}
#endif
InitializeCriticalSection(&s_sendLock);
InitializeCriticalSection(&s_connectionsLock);
InitializeCriticalSection(&s_advertiseLock);
InitializeCriticalSection(&s_discoveryLock);
InitializeCriticalSection(&s_disconnectLock);
InitializeCriticalSection(&s_freeSmallIdLock);
s_initialized = true;
StartDiscovery();
@@ -190,6 +200,7 @@ void NetworkSocketLayer::Shutdown()
s_disconnectedSmallIds.clear();
DeleteCriticalSection(&s_freeSmallIdLock);
s_freeSmallIds.clear();
s_locksCreated = false;
WSACleanup();
s_initialized = false;
}