fix(trophy2): accept a null data or details in sceNpTrophy2GetGameInfo

The Smurfs Dreams (Unreal Engine) asks only for the game details and
passes a null data pointer; on success it reads the trophy count from the
details, on a negative result it takes its error path. The function
already fills each output only when it is given, but rejected the call
unless both were. Only a call without either output is rejected now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pacuka
2026-10-06 17:58:35 +02:00
parent 5895ea721a
commit 30a6e03636
2 changed files with 17 additions and 1 deletions
@@ -9,7 +9,7 @@
extern "C" {
int APS5_VABI sceNpTrophy2GetGameInfo(int context, int handle, NpTrophy2GameDetails* details, NpTrophy2GameData* data) {
if (details == nullptr || data == nullptr) {
if (details == nullptr && data == nullptr) {
APS5_INVALID_ARG_EX;
}
(void)context;
+16
View File
@@ -1,9 +1,12 @@
#include "prx/libc/include/general/VabiMacros.hpp"
#include "prx/libSceNpTrophy2/include/NpTrophy2Types.hpp"
#include <cstdlib>
#include <stdexcept>
extern "C" {
int APS5_VABI sceNpTrophy2RegisterUnlockCallback(void*, void*);
int APS5_VABI sceNpTrophy2UnregisterUnlockCallback();
int APS5_VABI sceNpTrophy2GetGameInfo(int, int, NpTrophy2GameDetails*, NpTrophy2GameData*);
}
static void Require(bool value) { if (!value) std::abort(); }
@@ -17,4 +20,17 @@ int main() {
Require(sceNpTrophy2UnregisterUnlockCallback() == 0);
Require(sceNpTrophy2RegisterUnlockCallback(reinterpret_cast<void*>(&OnUnlock), &userdata) == 0);
Require(sceNpTrophy2UnregisterUnlockCallback() == 0);
NpTrophy2GameDetails details{};
NpTrophy2GameData data{};
Require(sceNpTrophy2GetGameInfo(1, 1, &details, nullptr) == 0);
Require(details.num_trophies != 0);
Require(sceNpTrophy2GetGameInfo(1, 1, nullptr, &data) == 0);
bool threw = false;
try {
sceNpTrophy2GetGameInfo(1, 1, nullptr, nullptr);
} catch (const std::invalid_argument&) {
threw = true;
}
Require(threw);
}