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: pieeebot/cafeberry#22
Co-authored-by: ubergamer-pie <16+ubergamer-pie@noreply.localhost>
This commit is contained in:
ubergamer-pieand552eden authored and pieeebot committed 2026-08-04 22:19:29 +00:00
1 parent 5451249347
commit 2840b7620b
2 files changed
+27 -9

No files matched your search

@@ -57,6 +57,9 @@ std::vector<BYTE> NetworkSocketLayer::s_disconnectedSmallIds;
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock; CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds; 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_MultiplayerHost = false;
bool g_MultiplayerJoin = true; bool g_MultiplayerJoin = true;
int g_MultiplayerPort = NETWORK_LAN_DEFAULT_PORT; int g_MultiplayerPort = NETWORK_LAN_DEFAULT_PORT;
@@ -65,6 +68,19 @@ char g_MultiplayerIP[256] = "127.0.0.1";
bool NetworkSocketLayer::Initialize() bool NetworkSocketLayer::Initialize()
{ {
if (s_initialized) return true; 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 #if defined _WINDOWS64 || defined _XBOX
WSADATA wsaData; WSADATA wsaData;
int result = WSAStartup(MAKEWORD(2, 2), &wsaData); int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
@@ -95,19 +111,13 @@ bool NetworkSocketLayer::Initialize()
param.flags = 0; param.flags = 0;
int result = sceNetInit(&param); int result = sceNetInit(&param);
if (result < 0) { // libnet is brought up before us by the platform layer, which reports EBUSY here.
app.DebugPrintf("sceNetInit failed: %d\n", result); if (result < 0 && result != SCE_NET_ERROR_EBUSY) {
app.DebugPrintf("sceNetInit failed: 0x%08x\n", result);
return false; return false;
} }
#endif #endif
InitializeCriticalSection(&s_sendLock);
InitializeCriticalSection(&s_connectionsLock);
InitializeCriticalSection(&s_advertiseLock);
InitializeCriticalSection(&s_discoveryLock);
InitializeCriticalSection(&s_disconnectLock);
InitializeCriticalSection(&s_freeSmallIdLock);
s_initialized = true; s_initialized = true;
StartDiscovery(); StartDiscovery();
@@ -190,6 +200,7 @@ void NetworkSocketLayer::Shutdown()
s_disconnectedSmallIds.clear(); s_disconnectedSmallIds.clear();
DeleteCriticalSection(&s_freeSmallIdLock); DeleteCriticalSection(&s_freeSmallIdLock);
s_freeSmallIds.clear(); s_freeSmallIds.clear();
s_locksCreated = false;
WSACleanup(); WSACleanup();
s_initialized = false; s_initialized = false;
} }
@@ -674,6 +674,13 @@ int main()
// debug switch to trial version // debug switch to trial version
//ProfileManager.SetDebugFullOverride(false); //ProfileManager.SetDebugFullOverride(false);
#ifdef DISABLE_PSN
// Set full mode. on DISABLE_PSN we cannot check if its trial or not.
ProfileManager.SetFullVersion(true);
ProfileManager.SetDebugFullOverride(true);
StorageManager.SetSaveDisabled(false);
#endif
//ProfileManager.AddDLC(2); //ProfileManager.AddDLC(2);
StorageManager.SetDLCPackageRoot("DLCDrive"); StorageManager.SetDLCPackageRoot("DLCDrive");
#if 0 #if 0