Skip to content

Commit

Permalink
FPD: Fix a crash due to incorrect instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed Oct 17, 2023
1 parent 2959802 commit c440ecd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/Cafe/IOSU/legacy/iosu_fpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace iosu
return t;
}

void NexPresenceToGameMode(nexPresenceV2* presence, GameMode* gameMode)
void NexPresenceToGameMode(const nexPresenceV2* presence, GameMode* gameMode)
{
memset(gameMode, 0, sizeof(GameMode));
gameMode->joinFlagMask = presence->joinFlagMask;
Expand All @@ -185,9 +185,9 @@ namespace iosu
memcpy(gameMode->appSpecificData, presence->appSpecificData, 0x14);
}

void GameModeToNexPresence(GameMode* gameMode, nexPresenceV2* presence)
void GameModeToNexPresence(const GameMode* gameMode, nexPresenceV2* presence)
{
memset(presence, 0, sizeof(nexPresenceV2));
*presence = {};
presence->joinFlagMask = gameMode->joinFlagMask;
presence->joinAvailability = (uint8)(uint32)gameMode->matchmakeType;
presence->gameId = gameMode->joinGameId;
Expand All @@ -197,7 +197,7 @@ namespace iosu
memcpy(presence->appSpecificData, gameMode->appSpecificData, 0x14);
}

void NexFriendToFPDFriendData(FriendData* friendData, nexFriend* frd)
void NexFriendToFPDFriendData(const nexFriend* frd, FriendData* friendData)
{
memset(friendData, 0, sizeof(FriendData));
// setup friend data
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace iosu
convertFPDTimestampToDate(frd->lastOnlineTimestamp, &friendData->friendExtraData.lastOnline);
}

void NexFriendRequestToFPDFriendData(FriendData* friendData, nexFriendRequest* frdReq, bool isIncoming)
void NexFriendRequestToFPDFriendData(const nexFriendRequest* frdReq, bool isIncoming, FriendData* friendData)
{
memset(friendData, 0, sizeof(FriendData));
// setup friend data
Expand Down Expand Up @@ -282,7 +282,7 @@ namespace iosu
convertFPDTimestampToDate(frdReq->message.expireTimestamp, &friendData->requestExtraData.uknData1);
}

void NexFriendRequestToFPDFriendRequest(FriendRequest* friendRequest, nexFriendRequest* frdReq, bool isIncoming)
void NexFriendRequestToFPDFriendRequest(const nexFriendRequest* frdReq, bool isIncoming, FriendRequest* friendRequest)
{
memset(friendRequest, 0, sizeof(FriendRequest));

Expand Down Expand Up @@ -1007,7 +1007,7 @@ namespace iosu
cemuLog_log(LogType::Force, "GetFriendRequestListEx: Failed to get friend request");
return FPResult_RequestFailed;
}
NexFriendRequestToFPDFriendRequest(friendRequests + i, &frdReq, incoming);
NexFriendRequestToFPDFriendRequest(&frdReq, incoming, friendRequests + i);
}
return FPResult_Ok;
}
Expand Down Expand Up @@ -1063,13 +1063,13 @@ namespace iosu
nexFriendRequest frdReq;
if (g_fpd.nexFriendSession->getFriendByPID(frd, pid))
{
NexFriendToFPDFriendData(friendData, &frd);
NexFriendToFPDFriendData(&frd, friendData);
continue;
}
bool incoming = false;
if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid))
{
NexFriendRequestToFPDFriendData(friendData, &frdReq, incoming);
NexFriendRequestToFPDFriendData(&frdReq, incoming, friendData);
continue;
}
cemuLog_logDebug(LogType::Force, "GetFriendListEx: Failed to find friend or request with pid {}", pid);
Expand Down
4 changes: 3 additions & 1 deletion src/Cemu/nex/nexTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class nexMetaType

class nexType
{
public:
public:
virtual ~nexType(){};

virtual const char* getMetaName()
{
cemu_assert_unimplemented();
Expand Down

0 comments on commit c440ecd

Please sign in to comment.