Fix Shadps4 crash

This commit is contained in:
2026-08-02 23:05:25 +03:00
parent 92209cf909
commit 5ebaab0ac9
2 changed files with 9 additions and 16 deletions
+3 -10
View File
@@ -74,12 +74,10 @@ PlayerUID::PlayerUID(wstring fromString)
wstring onlineID = fromString.substr(15 + userIdLen + 1);
if(onlineID.size() > 0)
{
wcstombs(m_onlineID, onlineID.c_str(), 16);
m_bSignedIntoPSN = true;
}
else
{
m_onlineID[0] = 0;
m_bSignedIntoPSN = false;
}
}
@@ -87,13 +85,8 @@ PlayerUID::PlayerUID(wstring fromString)
bool PlayerUID::operator==(const PlayerUID& rhs) const
{
// comparing online IDs
if(isSignedIntoPSN() && rhs.isSignedIntoPSN())
{
return (strcmp(m_onlineID, rhs.m_onlineID) == 0);
}
// comparing offline IDs
if(m_userID != rhs.m_userID)
if(XUID != rhs.XUID)
return false;
for(int i=0; i<SCE_NET_ETHER_ADDR_LEN;i++)
if(m_macAddress[i] != rhs.m_macAddress[i])return false;
@@ -147,13 +140,13 @@ std::wstring PlayerUID::toString() const
sprintf(macAddr, "%02x%02x%02x%02x%02x%02x", m[0],m[1],m[2],m[3],m[4],m[5]);
sprintf(finalString, "%s_%s_%08d_%s", isPrimaryUser() ? "P" : "N",
macAddr, m_userID,
isSignedIntoPSN() ? m_onlineID : "");
"");
mbstowcs(finalStringW, finalString, 64);
return std::wstring(finalStringW);
}
void PlayerUID::setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN)
{
memcpy(m_onlineID, id.data, SCE_NP_ONLINEID_MAX_LENGTH);
//memcpy(m_onlineID, id.data, SCE_NP_ONLINEID_MAX_LENGTH);
term = id.term;
m_bSignedIntoPSN = bSignedIntoPSN;
}
+6 -6
View File
@@ -9,16 +9,17 @@
// (2) An offline ID, where there is also a primary login on the system. This has m_onlineID set up to copy the primary SceNpOnlineId, except with dummy[0] set to the controller ID of this other player
// (3) An offline ID, where there isn't a primary PSN login on the system. This has SceNpOnlineId fully zeroed.
#pragma pack(push, 4)
class PlayerUID
{
char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
// PS4 4JLibs needs exactly 28 bytes for playerUID,
//char m_onlineID[SCE_NP_ONLINEID_MAX_LENGTH];
char term;
bool m_bSignedIntoPSN : 1;
unsigned char m_quadrant : 2;
uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN];
SceUserServiceUserId m_userID;
char m_padding[8];
public:
ULONGLONG XUID;
@@ -43,8 +44,7 @@ public:
void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN);
void setUserID(unsigned int id);
const char* getOnlineID() const { return m_onlineID; }
const char* getOnlineID() const { return ""; }
SceUserServiceUserId getUserID() const { return m_userID; }
int getQuadrant() const { return m_quadrant; }
bool isPrimaryUser() const; // only true if we're on the local machine and signed into the first quadrant;
@@ -64,7 +64,7 @@ namespace std
}
};
}
#pragma pack(pop)
#ifndef DISABLE_PSN