nn_nfp: Avoid current app from showing up as "???" for others in Friend List + View friends' status (#1157)

This commit is contained in:
47463915 2024-04-08 19:33:50 -03:00 committed by GitHub
parent 7b635e7eb8
commit 33a74c2035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 9 deletions

View File

@ -214,6 +214,12 @@ namespace iosu
friendData->friendExtraData.gameKey.ukn08 = frd->presence.gameKey.ukn; friendData->friendExtraData.gameKey.ukn08 = frd->presence.gameKey.ukn;
NexPresenceToGameMode(&frd->presence, &friendData->friendExtraData.gameMode); NexPresenceToGameMode(&frd->presence, &friendData->friendExtraData.gameMode);
auto fixed_presence_msg = '\0' + frd->presence.msg; // avoid first character of comment from being cut off
friendData->friendExtraData.gameModeDescription.assignFromUTF8(fixed_presence_msg);
auto fixed_comment = '\0' + frd->comment.commentString; // avoid first character of comment from being cut off
friendData->friendExtraData.comment.assignFromUTF8(fixed_comment);
// set valid dates // set valid dates
friendData->uknDate.year = 2018; friendData->uknDate.year = 2018;
friendData->uknDate.day = 1; friendData->uknDate.day = 1;
@ -750,9 +756,18 @@ namespace iosu
{ {
if(numVecIn != 0 || numVecOut != 1) if(numVecIn != 0 || numVecOut != 1)
return FPResult_InvalidIPCParam; return FPResult_InvalidIPCParam;
SelfPlayingGame selfPlayingGame{0}; GameKey selfPlayingGame
cemuLog_log(LogType::Force, "GetMyPlayingGame is todo"); {
return WriteValueOutput<SelfPlayingGame>(vecOut, selfPlayingGame); CafeSystem::GetForegroundTitleId(),
CafeSystem::GetForegroundTitleVersion(),
{0,0,0,0,0,0}
};
if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) != 0x00050000)
{
selfPlayingGame.titleId = 0;
selfPlayingGame.ukn08 = 0;
}
return WriteValueOutput<GameKey>(vecOut, selfPlayingGame);
} }
nnResult CallHandler_GetFriendAccountId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) nnResult CallHandler_GetFriendAccountId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut)
@ -1410,8 +1425,16 @@ namespace iosu
act::getCountryIndex(currentSlot, &countryCode); act::getCountryIndex(currentSlot, &countryCode);
// init presence // init presence
g_fpd.myPresence.isOnline = 1; g_fpd.myPresence.isOnline = 1;
g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) == 0x00050000)
g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); {
g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId();
g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion();
}
else
{
g_fpd.myPresence.gameKey.titleId = 0; // icon will not be ??? or invalid to others
g_fpd.myPresence.gameKey.ukn = 0;
}
// resolve potential domain to IP address // resolve potential domain to IP address
struct addrinfo hints = {0}, *addrs; struct addrinfo hints = {0}, *addrs;
hints.ai_family = AF_INET; hints.ai_family = AF_INET;

View File

@ -94,7 +94,7 @@ namespace iosu
/* +0x1EC */ uint8 isOnline; /* +0x1EC */ uint8 isOnline;
/* +0x1ED */ uint8 _padding1ED[3]; /* +0x1ED */ uint8 _padding1ED[3];
// some other sub struct? // some other sub struct?
/* +0x1F0 */ char comment[36]; // pops up every few seconds in friend list /* +0x1F0 */ CafeWideString<0x12> comment; // pops up every few seconds in friend list
/* +0x214 */ uint32be _padding214; /* +0x214 */ uint32be _padding214;
/* +0x218 */ FPDDate approvalTime; /* +0x218 */ FPDDate approvalTime;
/* +0x220 */ FPDDate lastOnline; /* +0x220 */ FPDDate lastOnline;
@ -263,4 +263,4 @@ namespace iosu
IOSUModule* GetModule(); IOSUModule* GetModule();
} }
} }

View File

@ -1,6 +1,7 @@
#include "prudp.h" #include "prudp.h"
#include "nex.h" #include "nex.h"
#include "nexFriends.h" #include "nexFriends.h"
#include "Cafe/CafeSystem.h"
static const int NOTIFICATION_SRV_FRIEND_OFFLINE = 0x0A; // the opposite event (friend online) is notified via _PRESENCE_CHANGE static const int NOTIFICATION_SRV_FRIEND_OFFLINE = 0x0A; // the opposite event (friend online) is notified via _PRESENCE_CHANGE
static const int NOTIFICATION_SRV_FRIEND_PRESENCE_CHANGE = 0x18; static const int NOTIFICATION_SRV_FRIEND_PRESENCE_CHANGE = 0x18;
@ -912,6 +913,18 @@ void NexFriends::markFriendRequestsAsReceived(uint64* messageIdList, sint32 coun
void NexFriends::updateMyPresence(nexPresenceV2& myPresence) void NexFriends::updateMyPresence(nexPresenceV2& myPresence)
{ {
this->myPresence = myPresence; this->myPresence = myPresence;
if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) == 0x00050000)
{
myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId();
myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion();
}
else
{
myPresence.gameKey.titleId = 0; // icon will not be ??? or invalid to others
myPresence.gameKey.ukn = 0;
}
if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED)
{ {
// not connected // not connected

View File

@ -431,7 +431,7 @@ public:
{ {
nnaInfo.readData(pb); nnaInfo.readData(pb);
presence.readData(pb); presence.readData(pb);
gameModeMessage.readData(pb); comment.readData(pb);
friendsSinceTimestamp = pb->readU64(); friendsSinceTimestamp = pb->readU64();
lastOnlineTimestamp = pb->readU64(); lastOnlineTimestamp = pb->readU64();
ukn6 = pb->readU64(); ukn6 = pb->readU64();
@ -439,7 +439,7 @@ public:
public: public:
nexNNAInfo nnaInfo; nexNNAInfo nnaInfo;
nexPresenceV2 presence; nexPresenceV2 presence;
nexComment gameModeMessage; nexComment comment;
uint64 friendsSinceTimestamp; uint64 friendsSinceTimestamp;
uint64 lastOnlineTimestamp; uint64 lastOnlineTimestamp;
uint64 ukn6; uint64 ukn6;