sceNpGetAccountCountryA

This commit is contained in:
Pavel 2022-12-07 15:50:25 +03:00
parent 0b7a4631f2
commit e4127bf26a
1 changed files with 40 additions and 16 deletions

View File

@ -151,6 +151,31 @@ function GetUserGeoID(GeoClass: GEOCLASS):GEOID; stdcall external kernel32;
function GetGeoInfoA(Location: GEOID; GeoType: GEOTYPE; lpGeoData: LPSTR;
cchData: Integer; LangId: LANGID): Integer; stdcall external kernel32;
function sys_get_country_code(p:pSceNpCountryCode):Integer;
var
g:GEOID;
s:integer;
b:RawByteString;
begin
Result:=0;
g:=GetUserGeoID(GEOCLASS_NATION);
s:=GetGeoInfoA(g,GEO_ISO2,nil,0,0);
b:='';
SetLength(b,s);
GetGeoInfoA(g,GEO_ISO2,PChar(b),s,0);
if (s>=2) then
begin
p^.data[0]:=LowerCase(b[1]);
p^.data[1]:=LowerCase(b[2]);
end else
begin
p^.data[0]:='u';
p^.data[1]:='s';
end;
end;
function ps4_sceNpGetAccountCountry(onlineId:pSceNpOnlineId;pCountryCode:pSceNpCountryCode):Integer; SysV_ABI_CDecl;
var
g:GEOID;
@ -160,24 +185,22 @@ begin
if (onlineId=nil) then Exit(SCE_NP_ERROR_INVALID_ARGUMENT);
if (pCountryCode=nil) then Exit(SCE_NP_ERROR_INVALID_ARGUMENT);
g:=GetUserGeoID(GEOCLASS_NATION);
s:=GetGeoInfoA(g,GEO_ISO2,nil,0,0);
SetLength(b,s);
GetGeoInfoA(g,GEO_ISO2,PChar(b),s,0);
pCountryCode^:=Default(SceNpCountryCode);
if (s>=2) then
begin
pCountryCode^:=Default(SceNpCountryCode);
pCountryCode^.data[0]:=LowerCase(b[1]);
pCountryCode^.data[1]:=LowerCase(b[2]);
end else
begin
pCountryCode^:=Default(SceNpCountryCode);
pCountryCode^.data[0]:='u';
pCountryCode^.data[1]:='s';
end;
Result:=sys_get_country_code(pCountryCode);
end;
Result:=0;
function ps4_sceNpGetAccountCountryA(userId:Integer;pCountryCode:pSceNpCountryCode):Integer; SysV_ABI_CDecl;
var
g:GEOID;
s:integer;
b:RawByteString;
begin
if (pCountryCode=nil) then Exit(SCE_NP_ERROR_INVALID_ARGUMENT);
pCountryCode^:=Default(SceNpCountryCode);
Result:=sys_get_country_code(pCountryCode);
end;
function ps4_sceNpGetNpId(userId:Integer;npId:PSceNpId):Integer; SysV_ABI_CDecl;
@ -426,6 +449,7 @@ begin
lib^.set_proc($036090DE4812A294,@ps4_sceNpSetContentRestriction);
lib^.set_proc($ADB9276948E9A96A,@ps4_sceNpGetAccountIdA);
lib^.set_proc($1A1CFD8960D4B42E,@ps4_sceNpGetAccountCountry);
lib^.set_proc($253FADD346B74F10,@ps4_sceNpGetAccountCountryA);
lib^.set_proc($A7FA3BE029E83736,@ps4_sceNpGetNpId);
lib^.set_proc($5C39DC5D02095129,@ps4_sceNpGetOnlineId);
lib^.set_proc($7901FB9D63DC0207,@ps4_sceNpGetState);