Fix Shadps4 crash

This commit is contained in:
pieeebot committed 2026-08-02 23:05:25 +03:00
1 parent 92209cf909
commit 5ebaab0ac9
2 files changed
+9 -16

No files matched your search

+3 -10
View File
@@ -74,12 +74,10 @@ PlayerUID::PlayerUID(wstring fromString)
wstring onlineID = fromString.substr(15 + userIdLen + 1); wstring onlineID = fromString.substr(15 + userIdLen + 1);
if(onlineID.size() > 0) if(onlineID.size() > 0)
{ {
wcstombs(m_onlineID, onlineID.c_str(), 16);
m_bSignedIntoPSN = true; m_bSignedIntoPSN = true;
} }
else else
{ {
m_onlineID[0] = 0;
m_bSignedIntoPSN = false; m_bSignedIntoPSN = false;
} }
} }
@@ -87,13 +85,8 @@ PlayerUID::PlayerUID(wstring fromString)
bool PlayerUID::operator==(const PlayerUID& rhs) const 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 // comparing offline IDs
if(m_userID != rhs.m_userID) if(XUID != rhs.XUID)
return false; return false;
for(int i=0; i<SCE_NET_ETHER_ADDR_LEN;i++) for(int i=0; i<SCE_NET_ETHER_ADDR_LEN;i++)
if(m_macAddress[i] != rhs.m_macAddress[i])return false; 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(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", sprintf(finalString, "%s_%s_%08d_%s", isPrimaryUser() ? "P" : "N",
macAddr, m_userID, macAddr, m_userID,
isSignedIntoPSN() ? m_onlineID : ""); "");
mbstowcs(finalStringW, finalString, 64); mbstowcs(finalStringW, finalString, 64);
return std::wstring(finalStringW); return std::wstring(finalStringW);
} }
void PlayerUID::setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN) 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; term = id.term;
m_bSignedIntoPSN = bSignedIntoPSN; 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 // (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. // (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 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; char term;
bool m_bSignedIntoPSN : 1; bool m_bSignedIntoPSN : 1;
unsigned char m_quadrant : 2; unsigned char m_quadrant : 2;
uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN]; uint8_t m_macAddress[SCE_NET_ETHER_ADDR_LEN];
SceUserServiceUserId m_userID; SceUserServiceUserId m_userID;
char m_padding[8];
public: public:
ULONGLONG XUID; ULONGLONG XUID;
@@ -43,8 +44,7 @@ public:
void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN); void setOnlineID(SceNpOnlineId& id, bool bSignedIntoPSN);
void setUserID(unsigned int id); void setUserID(unsigned int id);
const char* getOnlineID() const { return ""; }
const char* getOnlineID() const { return m_onlineID; }
SceUserServiceUserId getUserID() const { return m_userID; } SceUserServiceUserId getUserID() const { return m_userID; }
int getQuadrant() const { return m_quadrant; } int getQuadrant() const { return m_quadrant; }
bool isPrimaryUser() const; // only true if we're on the local machine and signed into the first 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 #ifndef DISABLE_PSN