Skip to content

Commit

Permalink
Merge pull request #19907 from hrydgard/more-network-ui
Browse files Browse the repository at this point in the history
More network UI, add translation strings
  • Loading branch information
hrydgard authored Jan 22, 2025
2 parents b41c632 + f1cd1e6 commit b8938f4
Show file tree
Hide file tree
Showing 60 changed files with 512 additions and 97 deletions.
3 changes: 0 additions & 3 deletions Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,6 @@ int PSPOskDialog::NativeKeyboard() {
std::u16string defaultText;
GetWideStringFromPSPPointer(defaultText, oskParams->fields[0].intext);

if (defaultText.empty())
defaultText.assign(u"VALUE");

// There's already ConvertUCS2ToUTF8 in this file. Should we use that instead of the global ones?
System_InputBoxGetString(NON_EPHEMERAL_TOKEN, ::ConvertUCS2ToUTF8(titleText), ::ConvertUCS2ToUTF8(defaultText), false,
[&](const std::string &value, int) {
Expand Down
1 change: 1 addition & 0 deletions Core/HLE/SocketManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ InetSocket *SocketManager::CreateSocket(int *index, int *returned_errno, SocketS
if (inetSockets_[i].state == SocketState::Unused) {
*index = i;
InetSocket *inetSock = inetSockets_ + i;
*inetSock = {}; // Reset to default.
inetSock->sock = hostSock;
inetSock->state = state;
inetSock->domain = domain;
Expand Down
3 changes: 3 additions & 0 deletions Core/HLE/SocketManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct InetSocket {
int type;
int protocol;
bool nonblocking;
// Metadata for debug use only.
std::string addr;
int port;
};

// Only use this for sockets whose ID are exposed to the game.
Expand Down
3 changes: 3 additions & 0 deletions Core/HLE/proAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ bool isPTPPortInUse(uint16_t port, bool forListen, SceNetEtherAddr* dstmac, uint
std::string ip2str(in_addr in, bool maskPublicIP) {
char str[INET_ADDRSTRLEN] = "...";
u8* ipptr = (u8*)∈
#ifdef _DEBUG
maskPublicIP = false;
#endif
if (maskPublicIP && !isPrivateIP(in.s_addr))
snprintf(str, sizeof(str), "%u.%u.xx.%u", ipptr[0], ipptr[1], ipptr[3]);
else
Expand Down
4 changes: 4 additions & 0 deletions Core/HLE/sceNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,13 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {

bool found = false;

std::vector<std::string> workingIDs;

std::vector<std::string> ids;
if (workingIdsNode) {
JsonGet(workingIdsNode->value).getStringVector(&ids);
for (auto &id : ids) {
workingIDs.push_back(id);
if (id == gameID) {
found = true;
dns->state = InfraGameState::Working;
Expand Down Expand Up @@ -248,6 +251,7 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) {
continue;
}

dns->workingIDs = workingIDs;
dns->gameName = game.getStringOr("name", "");
dns->dns = game.getStringOr("dns", dns->dns.c_str());
dns->dyn_dns = game.getStringOr("dyn_dns", "");
Expand Down
3 changes: 3 additions & 0 deletions Core/HLE/sceNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ struct InfraDNSConfig {
std::string revivalTeam;
std::string revivalTeamURL;

// PPSSPP can suggest other version of the game if one is known not to work.
std::vector<std::string> workingIDs;

bool connectAdHocForGrouping;
};

Expand Down
21 changes: 17 additions & 4 deletions Core/HLE/sceNetInet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int UpdateErrnoFromHost(int hostErrno, const char *func) {
ERROR_LOG(Log::sceNet, "BAD: errno cleared (previously %s) in %s. Functions should not clear errno.", convertInetErrno2str(g_inetLastErrno), func);
g_inetLastErrno = 0;
} else if (g_inetLastErrno == newErrno) {
DEBUG_LOG(Log::sceNet, "errno remained %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
VERBOSE_LOG(Log::sceNet, "errno remained %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
} else {
INFO_LOG(Log::sceNet, "errno set to %s in %s (host: %d)", convertInetErrno2str(newErrno), func, hostErrno);
g_inetLastErrno = newErrno;
Expand Down Expand Up @@ -73,7 +73,11 @@ static int sceNetInetTerm() {
}

static int sceNetInetGetErrno() {
return hleLogSuccessInfoI(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc);
if (g_inetLastErrno == ERROR_INET_EAGAIN) {
return hleLogVerbose(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc);
} else {
return hleLogDebug(Log::sceNet, g_inetLastErrno, "returning %s at %08x", convertInetErrno2str(g_inetLastErrno), currentMIPS->pc);
}
}

static int sceNetInetGetPspError() {
Expand Down Expand Up @@ -618,7 +622,12 @@ static int sceNetInetBind(int socket, u32 namePtr, int namelen) {
}
// TODO: Make use Port Offset only for PPSSPP to PPSSPP communications (ie. IP addresses available in the group/friendlist), otherwise should be considered as Online Service thus should use the port as is.
//saddr.in.sin_port = htons(ntohs(saddr.in.sin_port) + portOffset);
DEBUG_LOG(Log::sceNet, "Bind: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));

INFO_LOG(Log::sceNet, "sceNetInetBind: Family = %s, Address = %s, Port = %d", inetSocketDomain2str(saddr.addr.sa_family).c_str(), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
// Update socket debug metadata
inetSock->addr = ip2str(saddr.in.sin_addr);
inetSock->port = ntohs(saddr.in.sin_port);

changeBlockingMode(inetSock->sock, 0);
int retval = bind(inetSock->sock, (struct sockaddr*)&saddr, len);
if (retval < 0) {
Expand Down Expand Up @@ -650,7 +659,6 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
}

// Still using warn log here so it stands out in the log
WARN_LOG(Log::sceNet, "sceNetInetConnect(%i, %08x, %i) at %08x", socket, sockAddrPtr, sockAddrLen, currentMIPS->pc);

SceNetInetSockaddr* dst = (SceNetInetSockaddr*)Memory::GetPointer(sockAddrPtr);
SockAddrIN4 saddr{};
Expand Down Expand Up @@ -679,6 +687,11 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
}
changeBlockingMode(inetSock->sock, 1);

if (saddr.in.sin_port == 53) {
WARN_LOG(Log::G3D, "Game connected to DNS server %s (port 53), likely for doing its own DNS lookups!", ip2str(saddr.in.sin_addr, false).c_str());
// We should sniff these messages...
}

return hleLogSuccessInfoI(Log::sceNet, retval, "Connect: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
}

Expand Down
3 changes: 2 additions & 1 deletion Core/HLE/scePower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ static int sceKernelVolatileMemTryLock(int type, u32 paddr, u32 psize) {
break;

case SCE_KERNEL_ERROR_POWER_VMEM_IN_USE:
ERROR_LOG(Log::HLE, "sceKernelVolatileMemTryLock(%i, %08x, %08x) - already locked!", type, paddr, psize);
// This is OK, let's not ERROR_LOG.
DEBUG_LOG(Log::HLE, "sceKernelVolatileMemTryLock(%i, %08x, %08x) - already locked!", type, paddr, psize);
break;

default:
Expand Down
9 changes: 7 additions & 2 deletions Core/HLE/sceUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,17 @@ static int sceUtilityCheckNetParam(int id)
* @param data - parameter data
* @return 0 on success
*/
// Let's figure out what games use this.
static int sceUtilityGetNetParam(int id, int param, u32 dataAddr) {
DEBUG_LOG(Log::sceUtility, "sceUtilityGetNetParam(%d, %d, %08x)", id, param, dataAddr);
if (id < 0 || id > 24) {
return hleLogWarning(Log::sceUtility, SCE_ERROR_NETPARAM_BAD_NETCONF, "invalid id=%d", id);
}

if (!g_netApctlInited) {
// Is this allowed?
WARN_LOG_REPORT_ONCE(getnetparam_early, Log::sceNet, "sceUtilityGetNetParam called before initializing netApctl!");
}

// TODO: Replace the temporary netApctlInfo with netConfInfo, since some of netApctlInfo contents supposed to be taken from netConfInfo during ApctlInit, while sceUtilityGetNetParam can be used before Apctl Initialized
char name[APCTL_PROFILENAME_MAXLEN];
truncate_cpy(name, sizeof(name), defaultNetConfigName + std::to_string(id == 0 ? netParamLatestId:id));
Expand Down Expand Up @@ -933,7 +938,7 @@ static int sceUtilityGetNetParam(int id, int param, u32 dataAddr) {
return hleLogWarning(Log::sceUtility, SCE_ERROR_NETPARAM_BAD_PARAM, "invalid param=%d", param);
}

return 0;
return hleLogDebug(Log::sceUtility, 0);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion GPU/Common/DrawEngineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ void DrawEngineCommon::UpdatePlanes() {
// * Compute min/max of the verts, and then compute a bounding sphere and check that against the planes.
// - Less accurate, but..
// - Only requires six plane evaluations then.

bool DrawEngineCommon::TestBoundingBox(const void *vdata, const void *inds, int vertexCount, VertexDecoder *dec, u32 vertType) {
// Grab temp buffer space from large offsets in decoded_. Not exactly safe for large draws.
if (vertexCount > 1024) {
Expand Down Expand Up @@ -375,6 +374,10 @@ bool DrawEngineCommon::TestBoundingBox(const void *vdata, const void *inds, int
}

// NOTE: This doesn't handle through-mode, indexing, morph, or skinning.
// TODO: For high vertex counts, we should just take the min/max of all the verts, and test the resulting six cube
// corners. That way we can cull more draws quite cheaply.
// We could take the min/max during the regular vertex decode, and just skip the draw call if it's trivially culled.
// This would help games like Midnight Club (that one does a lot of out-of-bounds drawing) immensely.
bool DrawEngineCommon::TestBoundingBoxFast(const void *vdata, int vertexCount, VertexDecoder *dec, u32 vertType) {
SimpleVertex *corners = (SimpleVertex *)(decoded_ + 65536 * 12);
float *verts = (float *)(decoded_ + 65536 * 18);
Expand Down
8 changes: 4 additions & 4 deletions Tools/langtool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
networkingSettings->Add(new CheckBox(&g_Config.bDiscordRichPresence, n->T("Send Discord Presence information")));
}

networkingSettings->Add(new ItemHeader(n->T("AdHoc Server")));
networkingSettings->Add(new ItemHeader(n->T("AdHoc server")));
networkingSettings->Add(new CheckBox(&g_Config.bEnableAdhocServer, n->T("Enable built-in PRO Adhoc Server", "Enable built-in PRO Adhoc Server")));
networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address", "Change proAdhocServer Address (localhost = multiple instance)"), I18NCat::NONE))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress);

Expand All @@ -951,8 +951,7 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
return UI::EVENT_DONE;
});


networkingSettings->Add(new CheckBox(&g_Config.bInfrastructureAutoDNS, "Auto DNS"));
networkingSettings->Add(new CheckBox(&g_Config.bInfrastructureAutoDNS, n->T("Autoconfigure")));
auto *dnsServer = networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sInfrastructureDNSServer, n->T("DNS server"), "", 32, screenManager()));
dnsServer->SetDisabledPtr(&g_Config.bInfrastructureAutoDNS);

Expand Down
11 changes: 8 additions & 3 deletions UI/ImDebugger/ImDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,16 @@ static void DrawSockets(ImConfig &cfg) {
ImGui::End();
return;
}
if (ImGui::BeginTable("sock", 7, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH | ImGuiTableFlags_Resizable)) {
if (ImGui::BeginTable("sock", 9, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH | ImGuiTableFlags_Resizable)) {
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Host", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Port", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("IP address", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Non-blocking", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Created by", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Domain", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("Protocol", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Host handle", ImGuiTableColumnFlags_WidthFixed);

ImGui::TableHeadersRow();

Expand All @@ -641,7 +643,9 @@ static void DrawSockets(ImConfig &cfg) {
ImGui::TableNextColumn();
ImGui::Text("%d", i);
ImGui::TableNextColumn();
ImGui::Text("%d", (int)inetSocket->sock);
ImGui::Text("%d", inetSocket->port);
ImGui::TableNextColumn();
ImGui::TextUnformatted(inetSocket->addr.c_str());
ImGui::TableNextColumn();
ImGui::TextUnformatted(inetSocket->nonblocking ? "Non-blocking" : "Blocking");
ImGui::TableNextColumn();
Expand All @@ -656,6 +660,7 @@ static void DrawSockets(ImConfig &cfg) {
str = inetSocketProto2str(inetSocket->protocol);
ImGui::TextUnformatted(str.c_str());
ImGui::TableNextColumn();
ImGui::Text("%d", (int)inetSocket->sock);
}

ImGui::EndTable();
Expand Down
16 changes: 13 additions & 3 deletions UI/PauseScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,17 @@ void GamePauseScreen::update() {
finishNextFrame_ = false;
}

if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected) {
const bool networkConnected = IsNetworkConnected();
if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected || lastOnline_ != networkConnected) {
INFO_LOG(Log::sceNet, "Network status changed, recreating views");
RecreateViews();
lastNetInetInited_ = netInetInited;
lastNetInited_ = g_netInited;
lastAdhocServerConnected_ = g_adhocServerConnected;
lastOnline_ = networkConnected;
}

bool mustRunBehind = MustRunBehind();
const bool mustRunBehind = MustRunBehind();
playButton_->SetVisibility(mustRunBehind ? UI::V_GONE : UI::V_VISIBLE);

SetVRAppMode(VRAppMode::VR_MENU_MODE);
Expand Down Expand Up @@ -394,11 +396,19 @@ void GamePauseScreen::CreateViews() {

if (g_infraDNSConfig.state == InfraGameState::NotWorking) {
leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Some network functionality in this game is not working"), ""));
if (!g_infraDNSConfig.workingIDs.empty()) {
std::string str(nw->T("Other versions of this game that should work:"));
for (auto &id : g_infraDNSConfig.workingIDs) {
str.append("\n - ");
str += id;
}
leftColumnItems->Add(new TextView(str));
}
} else if (g_infraDNSConfig.state == InfraGameState::Unknown) {
leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Network functionality in this game is not guaranteed"), ""));
}
if (!g_infraDNSConfig.revivalTeam.empty()) {
leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure Mode server by")) + ":"));
leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure server provided by:"))));
leftColumnItems->Add(new TextView(g_infraDNSConfig.revivalTeam));
if (!g_infraDNSConfig.revivalTeamURL.empty()) {
leftColumnItems->Add(new Button(g_infraDNSConfig.revivalTeamURL))->OnClick.Add([](UI::EventParams &e) {
Expand Down
1 change: 1 addition & 0 deletions UI/PauseScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class GamePauseScreen : public UIDialogScreenWithGameBackground {
DialogResult finishNextFrameResult_ = DR_CANCEL;

UI::Button *playButton_ = nullptr;
bool lastOnline_ = false;
bool lastNetInited_ = false;
bool lastNetInetInited_ = false;
bool lastAdhocServerConnected_ = false;
Expand Down
43 changes: 29 additions & 14 deletions assets/infra-dns.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,45 +155,60 @@
{
"name": "SOCOM Fireteam Bravo",
"known_working_ids": [
"UCUS98615"
],
"not_working_ids": [
"UCKS45021",
"UCUS98615",
"UCES00038"
],
"score": 4,
"domains": {
"socomftb2.psp.online.scea.com": "67.222.156.250",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.250"
"socomftb.online.scee.com": "67.222.156.251",
"socomftb2.psp.online.scea.com": "67.222.156.251",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.251",
"socom-ftb-prod-muis.pdonline.scek.co.kr": "67.222.156.251"
}
},
{
"name": "SOCOM Fireteam Bravo Public Beta",
"known_working_ids": [
"UCUS98637"
],
"score": 4,
"domains": {
"socompsp-pubeta.muis.pdonline.scea.com": "67.222.156.251"
}
},
{
"name": "SOCOM Fireteam Bravo 2",
"known_working_ids": [
"UCUS98645",
"UCES00543"
"UCUS98645"
],
"other_ids": [
"not_working_ids": [
"UCES00543",
"UCKS45043",
"UCUS80171"
],
"score": 4,
"domains": {
"socomftb2.psp.online.scea.com": "67.222.156.250",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.250"
"socomftb2.online.scee.com": "67.222.156.251",
"socomftb2.psp.online.scea.com": "67.222.156.251",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.251"
}
},
{
"name": "SOCOM Tactical Strike",
"known_working_ids": [
"UCUS98649",
"UCES00855"
"UCUS98649"
],
"other_ids": [
"NPUG80220"
"not_working_ids": [
"NPUG80220",
"UCES00855"
],
"score": 3,
"domains": {
"socomftb2.psp.online.scea.com": "67.222.156.250",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.250"
"socomftb2.psp.online.scea.com": "67.222.156.251",
"socompsp-prod.muis.pdonline.scea.com": "67.222.156.251"
}
},
{
Expand Down
Loading

0 comments on commit b8938f4

Please sign in to comment.