Skip to content

Commit 12ddcb0

Browse files
committed
Move the logic for loading the json file to the function. Minor cleanup.
1 parent 8e643f7 commit 12ddcb0

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

Core/HLE/sceNet.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,23 @@ void AfterApctlMipsCall::SetData(int HandlerID, int OldState, int NewState, int
134134
argsAddr = ArgsAddr;
135135
}
136136

137-
bool LoadDNSForGameID(std::string_view jsonStr, std::string_view gameID, InfraDNSConfig *dns) {
137+
bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
138138
using namespace json;
139+
140+
// TODO: Load from cache instead of zip (if possible), and sometimes update it.
141+
size_t jsonSize;
142+
std::unique_ptr<uint8_t[]> data(g_VFS.ReadFile("infra-dns.json", &jsonSize));
143+
if (!data) {
144+
return false;
145+
}
146+
147+
std::string_view jsonStr = std::string_view((const char *)data.get(), jsonSize);
139148
json::JsonReader reader(jsonStr.data(), jsonStr.length());
140149
if (!reader.ok() || !reader.root()) {
141-
ERROR_LOG(Log::IO, "Error parsing JSON from store");
150+
ERROR_LOG(Log::IO, "Error parsing DNS JSON");
142151
return false;
143152
}
153+
144154
const JsonGet root = reader.root();
145155
const JsonGet def = root.getDict("default");
146156

@@ -210,7 +220,6 @@ bool LoadDNSForGameID(std::string_view jsonStr, std::string_view gameID, InfraDN
210220
}
211221

212222
// TODO: Check for not working platforms
213-
214223
break;
215224
}
216225

@@ -642,6 +651,7 @@ u32 Net_Term() {
642651
FreeUser(netThread2Addr);
643652
netInited = false;
644653

654+
g_infraDNSConfig = {};
645655
return 0;
646656
}
647657

@@ -709,12 +719,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
709719
if (g_Config.bInfrastructureAutoDNS) {
710720
// Load the automatic DNS config.
711721
std::string discID = g_paramSFO.GetDiscID();
712-
size_t jsonSize;
713-
uint8_t *data = g_VFS.ReadFile("infra-dns.json", &jsonSize);
714-
if (data && g_Config.bInfrastructureAutoDNS) {
715-
std::string_view json = std::string_view((const char *)data, jsonSize);
716-
LoadDNSForGameID(json, discID, &g_infraDNSConfig);
717-
}
722+
LoadDNSForGameID(discID, &g_infraDNSConfig);
718723
}
719724

720725
netInited = true;

UI/PauseScreen.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "Core/ELF/ParamSFO.h"
4343
#include "Core/HLE/sceDisplay.h"
4444
#include "Core/HLE/sceUmd.h"
45+
#include "Core/HLE/sceNet.h"
4546

4647
#include "GPU/GPUCommon.h"
4748
#include "GPU/GPUState.h"
@@ -415,8 +416,8 @@ void GamePauseScreen::CreateViews() {
415416
rightColumnItems->Add(new Choice(pa->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings);
416417
rightColumnItems->Add(new Choice(pa->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig);
417418
}
418-
UI::Choice *displayEditor_ = rightColumnItems->Add(new Choice(gr->T("Display layout & effects")));
419-
displayEditor_->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
419+
420+
rightColumnItems->Add(new Choice(gr->T("Display layout & effects")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
420421
screenManager()->push(new DisplayLayoutScreen(gamePath_));
421422
return UI::EVENT_DONE;
422423
});

assets/infra-dns.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"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.",
2+
"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.",
33
"default": {
44
"dns": "67.222.156.251",
55
"revival_credits": {

0 commit comments

Comments
 (0)