mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Move the logic for loading the json file to the function. Minor cleanup.
This commit is contained in:
parent
5815c3e3be
commit
ae15cba56c
3 changed files with 20 additions and 14 deletions
|
@ -134,13 +134,23 @@ void AfterApctlMipsCall::SetData(int HandlerID, int OldState, int NewState, int
|
||||||
argsAddr = ArgsAddr;
|
argsAddr = ArgsAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadDNSForGameID(std::string_view jsonStr, std::string_view gameID, InfraDNSConfig *dns) {
|
bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
|
||||||
using namespace json;
|
using namespace json;
|
||||||
json::JsonReader reader(jsonStr.data(), jsonStr.length());
|
|
||||||
if (!reader.ok() || !reader.root()) {
|
// TODO: Load from cache instead of zip (if possible), and sometimes update it.
|
||||||
ERROR_LOG(Log::IO, "Error parsing JSON from store");
|
size_t jsonSize;
|
||||||
|
std::unique_ptr<uint8_t[]> data(g_VFS.ReadFile("infra-dns.json", &jsonSize));
|
||||||
|
if (!data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view jsonStr = std::string_view((const char *)data.get(), jsonSize);
|
||||||
|
json::JsonReader reader(jsonStr.data(), jsonStr.length());
|
||||||
|
if (!reader.ok() || !reader.root()) {
|
||||||
|
ERROR_LOG(Log::IO, "Error parsing DNS JSON");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const JsonGet root = reader.root();
|
const JsonGet root = reader.root();
|
||||||
const JsonGet def = root.getDict("default");
|
const JsonGet def = root.getDict("default");
|
||||||
|
|
||||||
|
@ -210,7 +220,6 @@ bool LoadDNSForGameID(std::string_view jsonStr, std::string_view gameID, InfraDN
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check for not working platforms
|
// TODO: Check for not working platforms
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,6 +646,7 @@ u32 Net_Term() {
|
||||||
FreeUser(netThread2Addr);
|
FreeUser(netThread2Addr);
|
||||||
netInited = false;
|
netInited = false;
|
||||||
|
|
||||||
|
g_infraDNSConfig = {};
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,12 +714,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
|
||||||
if (g_Config.bInfrastructureAutoDNS) {
|
if (g_Config.bInfrastructureAutoDNS) {
|
||||||
// Load the automatic DNS config.
|
// Load the automatic DNS config.
|
||||||
std::string discID = g_paramSFO.GetDiscID();
|
std::string discID = g_paramSFO.GetDiscID();
|
||||||
size_t jsonSize;
|
LoadDNSForGameID(discID, &g_infraDNSConfig);
|
||||||
uint8_t *data = g_VFS.ReadFile("infra-dns.json", &jsonSize);
|
|
||||||
if (data && g_Config.bInfrastructureAutoDNS) {
|
|
||||||
std::string_view json = std::string_view((const char *)data, jsonSize);
|
|
||||||
LoadDNSForGameID(json, discID, &g_infraDNSConfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
netInited = true;
|
netInited = true;
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "Core/ELF/ParamSFO.h"
|
#include "Core/ELF/ParamSFO.h"
|
||||||
#include "Core/HLE/sceDisplay.h"
|
#include "Core/HLE/sceDisplay.h"
|
||||||
#include "Core/HLE/sceUmd.h"
|
#include "Core/HLE/sceUmd.h"
|
||||||
|
#include "Core/HLE/sceNet.h"
|
||||||
|
|
||||||
#include "GPU/GPUCommon.h"
|
#include "GPU/GPUCommon.h"
|
||||||
#include "GPU/GPUState.h"
|
#include "GPU/GPUState.h"
|
||||||
|
@ -415,8 +416,8 @@ void GamePauseScreen::CreateViews() {
|
||||||
rightColumnItems->Add(new Choice(pa->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings);
|
rightColumnItems->Add(new Choice(pa->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings);
|
||||||
rightColumnItems->Add(new Choice(pa->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig);
|
rightColumnItems->Add(new Choice(pa->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig);
|
||||||
}
|
}
|
||||||
UI::Choice *displayEditor_ = rightColumnItems->Add(new Choice(gr->T("Display layout & effects")));
|
|
||||||
displayEditor_->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
|
rightColumnItems->Add(new Choice(gr->T("Display layout & effects")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
|
||||||
screenManager()->push(new DisplayLayoutScreen(gamePath_));
|
screenManager()->push(new DisplayLayoutScreen(gamePath_));
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"comment": "This file contains our built-in DNS used by the Auto mode in Infrastructure. In addition to being shipped, it'll also be hosted on ppsspp.org. Key names below are not important.",
|
"comment": "This file contains our built-in DNS used by the Auto mode in Infrastructure. In addition to being shipped, it'll also be hosted on ppsspp.org. Game names below are not important.",
|
||||||
"default": {
|
"default": {
|
||||||
"dns": "67.222.156.251",
|
"dns": "67.222.156.251",
|
||||||
"revival_credits": {
|
"revival_credits": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue