From 4a540f2a0253f4824b878e231bb3d9301a19623a Mon Sep 17 00:00:00 2001 From: Ordinary205 <125112932+Ordinary205@users.noreply.github.com> Date: Fri, 2 Feb 2024 21:56:17 +0400 Subject: [PATCH] SceNpWebApi + SceNpSignaling + SceNpScore functions (#182) * sceNpWebApiRegisterExtdPushEventCallbackA * sceNpSignalingCreateContext * libSceNpScore functions * + --------- Co-authored-by: red-prig --- src/np/ps4_libscenpcommon.pas | 8 +-- src/np/ps4_libscenpscore.pas | 94 +++++++++++++++++++++++--------- src/np/ps4_libscenpsignaling.pas | 24 +++++++- src/np/ps4_libscenpwebapi.pas | 32 +++++++++++ 4 files changed, 128 insertions(+), 30 deletions(-) diff --git a/src/np/ps4_libscenpcommon.pas b/src/np/ps4_libscenpcommon.pas index 960d1e6..698c012 100644 --- a/src/np/ps4_libscenpcommon.pas +++ b/src/np/ps4_libscenpcommon.pas @@ -29,15 +29,15 @@ type pSceNpOnlineId=^SceNpOnlineId; SceNpOnlineId=packed record - data:array[0..SCE_NP_ONLINEID_MAX_LENGTH-1] of AnsiChar; - term:AnsiChar; + data :array[0..SCE_NP_ONLINEID_MAX_LENGTH-1] of AnsiChar; + term :AnsiChar; dummy:array[0..2] of AnsiChar; end; PSceNpId=^SceNpId; SceNpId=packed record - handle:SceNpOnlineId; - opt:array[0..7] of Byte; + handle :SceNpOnlineId; + opt :array[0..7] of Byte; reserved:array[0..7] of Byte; end; diff --git a/src/np/ps4_libscenpscore.pas b/src/np/ps4_libscenpscore.pas index 19b541c..4de5e49 100644 --- a/src/np/ps4_libscenpscore.pas +++ b/src/np/ps4_libscenpscore.pas @@ -36,35 +36,35 @@ end; type pSceNpScoreRankData=^SceNpScoreRankData; SceNpScoreRankData=packed record - npId:SceNpId; - reserved:array[0..48] of Byte; - pad0:array[0..2] of Byte; - pcId:Integer; - serialRank:DWORD; - rank:DWORD; + npId :SceNpId; + reserved :array[0..48] of Byte; + pad0 :array[0..2] of Byte; + pcId :Integer; + serialRank :DWORD; + rank :DWORD; highestRank:DWORD; - scoreValue:Int64; + scoreValue :Int64; hasGameData:Integer; - pad1:array[0..3] of Byte; - recordDate:QWORD; + pad1 :array[0..3] of Byte; + recordDate :QWORD; end; PSceNpScoreRankDataA=^SceNpScoreRankDataA; SceNpScoreRankDataA=packed record - onlineId:SceNpOnlineId; - reserved0:array[0..15] of Byte; - reserved:array[0..48] of Byte; - pad0:array[0..2] of Byte; - pcId:Integer; - serialRank:DWORD; - rank:DWORD; + onlineId :SceNpOnlineId; + reserved0 :array[0..15] of Byte; + reserved :array[0..48] of Byte; + pad0 :array[0..2] of Byte; + pcId :Integer; + serialRank :DWORD; + rank :DWORD; highestRank:DWORD; hasGameData:Integer; - pad1:array[0..3] of Byte; - scoreValue:Int64; - recordDate:QWORD; - accountId:QWORD; - pad2:array[0..7] of Byte; + pad1 :array[0..3] of Byte; + scoreValue :Int64; + recordDate :QWORD; + accountId :QWORD; + pad2 :array[0..7] of Byte; end; const @@ -89,11 +89,24 @@ type PSceNpScoreGetFriendRankingOptParam=^SceNpScoreGetFriendRankingOptParam; SceNpScoreGetFriendRankingOptParam=packed record - size:size_t; + size :size_t; startSerialRank:PInteger; - hits:PInteger; + hits :PInteger; end; + pSceNpScoreBoardId=^SceNpScoreBoardId; + SceNpScoreBoardId=DWORD; + + pSceNpScorePlayerRankDataA=^SceNpScorePlayerRankDataA; + SceNpScorePlayerRankDataA=packed record + hasData :Integer; + pad0 :array[0..3] of Byte; + rankData:SceNpScoreRankDataA; + end; + + pSceNpScoreRankNumber=^SceNpScoreRankNumber; + SceNpScoreRankNumber=DWORD; + function ps4_sceNpScoreGetFriendsRanking( reqId:Integer; boardId:DWORD; @@ -213,7 +226,7 @@ function ps4_sceNpScoreRecordScore( score:Int64; //SceNpScoreValue scoreComment:pSceNpScoreComment; gameInfo:pSceNpScoreGameInfo; - tmpRank:PDWORD; //SceNpScoreRankNumber + tmpRank:pSceNpScoreRankNumber; compareDate:PQWORD; //SceRtcTick option:Pointer):Integer; SysV_ABI_CDecl; begin @@ -230,7 +243,7 @@ function ps4_sceNpScoreRecordScoreAsync( score:Int64; //SceNpScoreValue scoreComment:pSceNpScoreComment; gameInfo:pSceNpScoreGameInfo; - tmpRank:PDWORD; //SceNpScoreRankNumber + tmpRank:pSceNpScoreRankNumber; compareDate:PQWORD; //SceRtcTick option:Pointer):Integer; SysV_ABI_CDecl; begin @@ -252,6 +265,34 @@ begin Result:=0; end; +function ps4_sceNpScoreGetRankingByNpIdAsync():Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + +function ps4_sceNpScoreGetRankingByAccountId(reqId:Integer; + boardId:SceNpScoreBoardId; + const accountIdArray:SceNpAccountId; + accountIdArraySize:QWORD; + rankArray:pSceNpScorePlayerRankDataA; + rankArraySize:QWORD; + commentArray:pSceNpScoreComment; + commentArraySize:QWORD; + infoArray:pSceNpScoreGameInfo; + infoArraySize:QWORD; + arrayNum:QWORD; + lastSortDate:PQWORD; //SceRtcTick + totalRecord:pSceNpScoreRankNumber; + option:Pointer):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + +function ps4_sceNpScoreDeleteNpTitleCtx(titleCtxId:Integer):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + function Load_libSceNpScoreRanking(Const name:RawByteString):TElf_node; var lib:PLIBRARY; @@ -270,6 +311,9 @@ begin lib^.set_proc($CD3D1706D82D3922,@ps4_sceNpScoreRecordScore); lib^.set_proc($00D26CB0FCF7998D,@ps4_sceNpScoreRecordScoreAsync); lib^.set_proc($9B50DF351B2D9124,@ps4_sceNpScorePollAsync); + lib^.set_proc($45DDBB76A505655F,@ps4_sceNpScoreGetRankingByNpIdAsync); + lib^.set_proc($2BDB653834D0C777,@ps4_sceNpScoreGetRankingByAccountId); + lib^.set_proc($1B4A44F91342C1F9,@ps4_sceNpScoreDeleteNpTitleCtx); end; initialization diff --git a/src/np/ps4_libscenpsignaling.pas b/src/np/ps4_libscenpsignaling.pas index 0ea5059..3eca77a 100644 --- a/src/np/ps4_libscenpsignaling.pas +++ b/src/np/ps4_libscenpsignaling.pas @@ -5,7 +5,20 @@ unit ps4_libSceNpSignaling; interface uses - ps4_program; + ps4_program, + ps4_libSceNpCommon; + +const + SCE_NP_SIGNALING_CONTEXT_MAX=8; + +type + SceNpSignalingHandler=procedure( + ctxId :DWORD; + subjectId:DWORD; + event :Integer; + errorCode:Integer; + arg :Pointer + ); SysV_ABI_CDecl; implementation @@ -17,6 +30,14 @@ begin Result:=0; end; +function ps4_sceNpSignalingCreateContext(npId:pSceNpId; + handler:SceNpSignalingHandler; + arg:Pointer; + ctxId:PDWORD):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + function Load_libSceNpSignaling(Const name:RawByteString):TElf_node; var lib:PLIBRARY; @@ -26,6 +47,7 @@ begin lib:=Result._add_lib('libSceNpSignaling'); lib^.set_proc($DCA3AE0B84666595,@ps4_sceNpSignalingInitialize); + lib^.set_proc($E7262311D778B7C6,@ps4_sceNpSignalingCreateContext) end; initialization diff --git a/src/np/ps4_libscenpwebapi.pas b/src/np/ps4_libscenpwebapi.pas index 625d43b..bb2f073 100644 --- a/src/np/ps4_libscenpwebapi.pas +++ b/src/np/ps4_libscenpwebapi.pas @@ -182,6 +182,30 @@ type extdDataKeyNum:size_t; end; + pSceNpWebApiExtdPushEventExtdData=^SceNpWebApiExtdPushEventExtdData; + SceNpWebApiExtdPushEventExtdData=packed record + extdDataKey:SceNpWebApiExtdPushEventExtdDataKey; + pData :PChar; + dataLen :QWORD; + end; + + SceNpWebApiExtdPushEventCallbackA=procedure( + userCtxId :Integer; + callbackId :Integer; + pNpServiceName:PChar; + npServiceLabel:SceNpServiceLabel; + pTo :pSceNpPeerAddressA; + pToOnlineId :pSceNpOnlineId; + pFrom :pSceNpPeerAddressA; + pFromOnlineId :SceNpOnlineId; + pDataType :pSceNpWebApiPushEventDataType; + pData :PChar; + dataLen :QWORD; + pExtdData :pSceNpWebApiExtdPushEventExtdData; + extdDataNum :QWORD; + pUserArg :Pointer + ); SysV_ABI_CDecl; + function ps4_sceNpWebApiCreatePushEventFilter(libCtxId:Integer; pDataType:pSceNpWebApiPushEventDataType; dataTypeNum:size_t):Integer; SysV_ABI_CDecl; @@ -232,6 +256,13 @@ begin Result:=3; end; +function ps4_sceNpWebApiRegisterExtdPushEventCallbackA(userCtxId,filterId:Integer; + cbFunc:SceNpWebApiExtdPushEventCallbackA; + pUserArg:Pointer):Integer; SysV_ABI_CDecl; +begin + Result:=3; +end; + procedure ps4_sceNpWebApiCheckTimeout(); SysV_ABI_CDecl; begin // @@ -270,6 +301,7 @@ begin lib^.set_proc($909409134B8A9B9C,@ps4_sceNpWebApiRegisterServicePushEventCallback); lib^.set_proc($33605407E0CD1061,@ps4_sceNpWebApiCreateExtdPushEventFilter); lib^.set_proc($BEB334D80E46CB53,@ps4_sceNpWebApiRegisterExtdPushEventCallback); + lib^.set_proc($8E15CA1902787A02,@ps4_sceNpWebApiRegisterExtdPushEventCallbackA); lib^.set_proc($81534DCB17FFD528,@ps4_sceNpWebApiCheckTimeout); lib^.set_proc($5D48DDB124D36775,@ps4_sceNpWebApiDeleteContext); end;