diff --git a/Core/Dialog/PSPDialog.cpp b/Core/Dialog/PSPDialog.cpp index f29c392cd2b0..812b5c493e99 100644 --- a/Core/Dialog/PSPDialog.cpp +++ b/Core/Dialog/PSPDialog.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include "Common/Data/Text/I18n.h" #include "Common/Serialize/Serializer.h" diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index a2255f1e640b..6e987e936f55 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -52,7 +52,7 @@ #include "Core/HLE/sceNetInet.h" #include "Core/HLE/sceNetResolver.h" -bool netInited; +bool g_netInited; u32 netDropRate = 0; u32 netDropDuration = 0; @@ -64,8 +64,9 @@ static struct SceNetMallocStat netMallocStat; static std::map apctlHandlers; -std::string defaultNetConfigName = "NetConf"; -std::string defaultNetSSID = "Wifi"; // fake AP/hotspot +const char * const defaultNetConfigName = "NetConf"; +const char * const defaultNetSSID = "Wifi"; // fake AP/hotspot + int netApctlInfoId = 0; SceNetApctlInfoInternal netApctlInfo; @@ -88,8 +89,13 @@ int NetApctl_Term(); void NetApctl_InitDefaultInfo(); void NetApctl_InitInfo(int confId); +bool IsNetworkConnected() { + // TODO: Tweak this. + return __NetApctlConnected() || __NetAdhocConnected(); +} + bool NetworkWarnUserIfOnlineAndCantSavestate() { - if (netInited && !g_Config.bAllowSavestateWhileConnected) { + if (IsNetworkConnected() && !g_Config.bAllowSavestateWhileConnected) { auto nw = GetI18NCategory(I18NCat::NETWORKING); g_OSD.Show(OSDType::MESSAGE_INFO, nw->T("Save states are not available when online"), 3.0f, "saveonline"); return true; @@ -99,7 +105,7 @@ bool NetworkWarnUserIfOnlineAndCantSavestate() { } bool NetworkWarnUserIfOnlineAndCantSpeed() { - if (netInited) { + if (IsNetworkConnected()) { auto nw = GetI18NCategory(I18NCat::NETWORKING); g_OSD.Show(OSDType::MESSAGE_INFO, nw->T("Speed controls are not available when online"), 3.0f, "speedonline"); return true; @@ -109,11 +115,11 @@ bool NetworkWarnUserIfOnlineAndCantSpeed() { } bool NetworkAllowSpeedControl() { - return !netInited; + return !IsNetworkConnected(); } bool NetworkAllowSaveState() { - return !netInited || g_Config.bAllowSavestateWhileConnected; + return !IsNetworkConnected() || g_Config.bAllowSavestateWhileConnected; } void AfterApctlMipsCall::DoState(PointerWrap & p) { @@ -165,6 +171,8 @@ bool LoadDNSForGameID(std::string_view gameID, InfraDNSConfig *dns) { return false; } + dns->loaded = true; + std::string_view jsonStr = std::string_view((const char *)data.get(), jsonSize); json::JsonReader reader(jsonStr.data(), jsonStr.length()); if (!reader.ok() || !reader.root()) { @@ -343,7 +351,7 @@ void __NetApctlInit() { } static void __ResetInitNetLib() { - netInited = false; + g_netInited = false; netInetInited = false; // shouldn't this actually do something? memset(&netMallocStat, 0, sizeof(netMallocStat)); @@ -435,11 +443,11 @@ void __NetDoState(PointerWrap &p) { if (!s) return; - auto cur_netInited = netInited; + auto cur_netInited = g_netInited; auto cur_netInetInited = netInetInited; auto cur_netApctlInited = g_netApctlInited; - Do(p, netInited); + Do(p, g_netInited); Do(p, netInetInited); Do(p, g_netApctlInited); Do(p, apctlHandlers); @@ -492,7 +500,7 @@ void __NetDoState(PointerWrap &p) { // Let's not change "Inited" value when Loading SaveState in the middle of multiplayer to prevent memory & port leaks g_netApctlInited = cur_netApctlInited; netInetInited = cur_netInetInited; - netInited = cur_netInited; + g_netInited = cur_netInited; // Discard leftover events apctlEvents.clear(); @@ -673,7 +681,7 @@ u32 Net_Term() { //NetInet_Term(); // Library is initialized - if (netInited) { + if (g_netInited) { // Delete Adhoc Sockets deleteAllAdhocSockets(); @@ -691,7 +699,7 @@ u32 Net_Term() { FreeUser(netPoolAddr); FreeUser(netThread1Addr); FreeUser(netThread2Addr); - netInited = false; + g_netInited = false; g_infraDNSConfig = {}; return 0; @@ -720,7 +728,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini // TODO: Create Network Threads using given priority & stack // TODO: The correct behavior is actually to allocate more and leak the other threads/pool. // But we reset here for historic reasons (GTA:VCS potentially triggers this.) - if (netInited) { + if (g_netInited) { // This cleanup attempt might not worked when SaveState were loaded in the middle of multiplayer game and re-entering multiplayer, thus causing memory leaks & wasting binded ports. // Maybe we shouldn't save/load "Inited" vars on SaveState? Net_Term(); @@ -805,7 +813,7 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini } } - netInited = true; + g_netInited = true; auto n = GetI18NCategory(I18NCat::NETWORKING); @@ -974,7 +982,7 @@ void NetApctl_InitInfo(int confId) { truncate_cpy(netApctlInfo.name, sizeof(netApctlInfo.name), defaultNetConfigName + std::to_string(confId)); truncate_cpy(netApctlInfo.ssid, sizeof(netApctlInfo.ssid), defaultNetSSID); memcpy(netApctlInfo.bssid, "\1\1\2\2\3\3", sizeof(netApctlInfo.bssid)); // fake AP's mac address - netApctlInfo.ssidLength = static_cast(defaultNetSSID.length()); + netApctlInfo.ssidLength = static_cast(strlen(defaultNetSSID)); netApctlInfo.strength = 99; netApctlInfo.channel = g_Config.iWlanAdhocChannel; if (netApctlInfo.channel == PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC) netApctlInfo.channel = defaultWlanChannel; diff --git a/Core/HLE/sceNet.h b/Core/HLE/sceNet.h index f5abfebd4830..46d35b511d31 100644 --- a/Core/HLE/sceNet.h +++ b/Core/HLE/sceNet.h @@ -108,12 +108,12 @@ class AfterApctlMipsCall : public PSPAction { u32_le argsAddr = 0; }; -extern bool netInited; +extern bool g_netInited; extern bool g_netApctlInited; extern u32 netApctlState; extern SceNetApctlInfoInternal netApctlInfo; -extern std::string defaultNetConfigName; -extern std::string defaultNetSSID; +extern const char * const defaultNetConfigName; +extern const char * const defaultNetSSID; void Register_sceNet(); void Register_sceNetApctl(); @@ -131,6 +131,9 @@ bool __NetApctlConnected(); int sceNetApctlConnect(int connIndex); +// Are we connected - for the purpose of disabling speed consoles and savestates etc. +bool IsNetworkConnected(); + // These return false if allowed to be consistent with the similar function for achievements. bool NetworkWarnUserIfOnlineAndCantSavestate(); bool NetworkWarnUserIfOnlineAndCantSpeed(); @@ -146,6 +149,7 @@ enum class InfraGameState { // Loaded an interpreted for a specific game from the JSON - doesn't represent the entire JSON. struct InfraDNSConfig { + bool loaded; std::string gameName; std::string dns; std::string dyn_dns; diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 4a0dfdcfc8c3..90e1b6ea86f3 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -14,27 +14,16 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +// sceNetAdhoc -#if defined(_WIN32) -#include -#include "Common/CommonWindows.h" -#endif +// This is a direct port of Coldbird's code from http://code.google.com/p/aemu/ +// All credit goes to him! -#if !defined(_WIN32) -#include -#include -#endif - -#ifndef MSG_NOSIGNAL -// Default value to 0x00 (do nothing) in systems where it's not supported. -#define MSG_NOSIGNAL 0x00 -#endif #include -// sceNetAdhoc +#include -// This is a direct port of Coldbird's code from http://code.google.com/p/aemu/ -// All credit goes to him! +#include "Common/Net/SocketCompat.h" #include "Common/Data/Text/I18n.h" #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" @@ -89,7 +78,6 @@ int adhocEventDelay = 2000000; //2000000 on real PSP ? constexpr u32 defaultLastRecvDelta = 10000; //10000 usec worked well for games published by Falcom (ie. Ys vs Sora Kiseki, Vantage Master Portable) - SceUID threadAdhocID; std::recursive_mutex adhocEvtMtx; @@ -1352,7 +1340,7 @@ int sceNetAdhocPdpCreate(const char *mac, int port, int bufferSize, u32 flag) { return hleLogError(Log::sceNet, -1, "WLAN"); } - if (!netInited) + if (!g_netInited) return hleLogError(Log::sceNet, 0x800201CA); //PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX; // Library is initialized diff --git a/Core/HLE/sceNetAdhoc.h b/Core/HLE/sceNetAdhoc.h index f9037cc750bf..dfeca86bcc4b 100644 --- a/Core/HLE/sceNetAdhoc.h +++ b/Core/HLE/sceNetAdhoc.h @@ -20,7 +20,6 @@ #include #include "Core/HLE/proAdhoc.h" - #ifdef _MSC_VER #pragma pack(push,1) #endif @@ -128,6 +127,8 @@ extern bool netAdhocInited; extern bool netAdhocctlInited; extern bool g_adhocServerConnected; extern bool netAdhocGameModeEntered; +extern s32 netAdhocDiscoverStatus; + extern int netAdhocEnterGameModeTimeout; extern int adhocDefaultTimeout; //3000000 usec extern int adhocDefaultDelay; //10000 diff --git a/Core/HLE/sceNetAdhocMatching.h b/Core/HLE/sceNetAdhocMatching.h index af48516b293d..0aeae59dfc79 100644 --- a/Core/HLE/sceNetAdhocMatching.h +++ b/Core/HLE/sceNetAdhocMatching.h @@ -42,3 +42,5 @@ void RestoreNetAdhocMatchingInited(); void Register_sceNetAdhocMatching(); void __NetAdhocMatchingInit(); void __NetAdhocMatchingShutdown(); + +extern bool netAdhocMatchingInited; diff --git a/Core/HLE/sceNetApctl.cpp b/Core/HLE/sceNetApctl.cpp index acf79bda5872..ff9d8415b3e3 100644 --- a/Core/HLE/sceNetApctl.cpp +++ b/Core/HLE/sceNetApctl.cpp @@ -1,3 +1,16 @@ // TODO: move apctl here #include "sceNetApctl.h" + +const char *ApctlStateToString(int apctlState) { + switch (apctlState) { + case PSP_NET_APCTL_STATE_DISCONNECTED: return "DISCONNECTED"; + case PSP_NET_APCTL_STATE_SCANNING: return "SCANNING"; + case PSP_NET_APCTL_STATE_JOINING: return "JOINING"; + case PSP_NET_APCTL_STATE_GETTING_IP: return "GETTING_IP"; + case PSP_NET_APCTL_STATE_GOT_IP: return "GOT_IP"; + case PSP_NET_APCTL_STATE_EAP_AUTH: return "EAP_AUTH"; + case PSP_NET_APCTL_STATE_KEY_EXCHANGE: return "KEY_EXCHANGE"; + default: return "N/A"; + } +} diff --git a/Core/HLE/sceNetApctl.h b/Core/HLE/sceNetApctl.h index 2ce8679af3f1..cb3dc819742a 100644 --- a/Core/HLE/sceNetApctl.h +++ b/Core/HLE/sceNetApctl.h @@ -27,6 +27,8 @@ enum { PSP_NET_APCTL_EVENT_SCAN_STOP = 11 // FIXME: not sure what this is, MGS:PW seems to check this value within ApctlHandler during Recruit, related to sceNetApctlScanSSID2 ? }; +const char *ApctlStateToString(int apctlState); + #define PSP_NET_APCTL_INFO_PROFILE_NAME 0 #define PSP_NET_APCTL_INFO_BSSID 1 #define PSP_NET_APCTL_INFO_SSID 2 diff --git a/Core/HLE/sceNetInet.h b/Core/HLE/sceNetInet.h index cc86c9a7dd65..f565776887a3 100644 --- a/Core/HLE/sceNetInet.h +++ b/Core/HLE/sceNetInet.h @@ -115,13 +115,13 @@ typedef struct InetSocket { class PointerWrap; -extern bool netInited; +extern bool g_netInited; extern bool netInetInited; extern bool g_netApctlInited; extern u32 netApctlState; extern SceNetApctlInfoInternal netApctlInfo; -extern std::string defaultNetConfigName; -extern std::string defaultNetSSID; +extern const char *const defaultNetConfigName; +extern const char *const defaultNetSSID; void Register_sceNetInet(); diff --git a/Core/HLE/scePspNpDrm_user.cpp b/Core/HLE/scePspNpDrm_user.cpp index d8194c890465..2663c299563e 100644 --- a/Core/HLE/scePspNpDrm_user.cpp +++ b/Core/HLE/scePspNpDrm_user.cpp @@ -5,37 +5,33 @@ #include "Core/HLE/sceIo.h" static int sceNpDrmSetLicenseeKey(u32 npDrmKeyAddr) { - WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmSetLicenseeKey(%08x)", npDrmKeyAddr); - return 0; + return hleLogWarning(Log::HLE, 0, "UNIMPL"); } static int sceNpDrmClearLicenseeKey() { - WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmClearLicenseeKey()"); - return 0; + return hleLogWarning(Log::HLE, 0, "UNIMPL"); } static int sceNpDrmRenameCheck(const char *filename) { - WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmRenameCheck(%s)", filename); - return 0; + return hleLogWarning(Log::HLE, 0, "UNIMPL"); } static int sceNpDrmEdataSetupKey(u32 edataFd) { - INFO_LOG(Log::HLE, "sceNpDrmEdataSetupKey(%x)", edataFd); int usec = 0; // set PGD offset int retval = __IoIoctl(edataFd, 0x04100002, 0x90, 0, 0, 0, usec); if (retval != 0) { - return hleDelayResult(retval, "io ctrl command", usec); + return hleDelayResult(hleLogError(Log::HLE, retval), "io ctrl command", usec); } // call PGD open // Note that usec accumulates. retval = __IoIoctl(edataFd, 0x04100001, 0, 0, 0, 0, usec); - return hleDelayResult(retval, "io ctrl command", usec); + return hleDelayResult(hleLogSuccessInfoI(Log::HLE, retval), "io ctrl command", usec); } static int sceNpDrmEdataGetDataSize(u32 edataFd) { - INFO_LOG(Log::HLE, "sceNpDrmEdataGetDataSize %x", edataFd); - return sceIoIoctl(edataFd, 0x04100010, 0, 0, 0, 0); + int retval = hleCall(IoFileMgrForKernel, u32, sceIoIoctl, edataFd, 0x04100010, 0, 0, 0, 0); + return hleLogSuccessInfoI(Log::HLE, retval); } static int sceNpDrmOpen() { diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index b4649264abcd..1fec2d688b42 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -456,7 +456,7 @@ namespace SaveState void Rewind(Callback callback, void *cbUserData) { - if (netInited) { + if (g_netInited) { return; } if (coreState == CoreState::CORE_RUNTIME_ERROR) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f57feb5cd01e..6cb2110a3826 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -939,7 +939,7 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) { break; case VIRTKEY_TOGGLE_WLAN: // Let's not allow the user to toggle wlan while connected, could get confusing. - if (down && !netInited) { + if (down && !g_netInited) { auto n = GetI18NCategory(I18NCat::NETWORKING); auto di = GetI18NCategory(I18NCat::DIALOG); g_Config.bEnableWlan = !g_Config.bEnableWlan; @@ -1884,7 +1884,7 @@ void EmuScreen::resized() { } bool MustRunBehind() { - return netInited || __NetAdhocConnected(); + return IsNetworkConnected(); } bool ShouldRunBehind() { diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index d720f20c7651..7e4ac77227ff 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -22,6 +22,11 @@ #include "Core/HLE/SocketManager.h" #include "Core/HLE/NetInetConstants.h" #include "Core/HLE/sceNp.h" +#include "Core/HLE/sceNet.h" +#include "Core/HLE/sceNetApctl.h" +#include "Core/HLE/sceNetAdhoc.h" +#include "Core/HLE/proAdhoc.h" +#include "Core/HLE/sceNetAdhocMatching.h" #include "Common/System/Request.h" #include "Core/HLE/sceAtrac.h" @@ -496,6 +501,115 @@ static void DrawNp(ImConfig &cfg) { SceNpId id{}; NpGetNpId(&id); ImGui::Text("User Handle: %s", id.handle.data); + + + ImGui::End(); +} + +static void DrawApctl(ImConfig &cfg) { + if (!ImGui::Begin("Apctl", &cfg.apctlOpen)) { + ImGui::End(); + return; + } + + ImGui::Text("State: %s", ApctlStateToString(netApctlState)); + if (netApctlState != PSP_NET_APCTL_STATE_DISCONNECTED && ImGui::CollapsingHeader("ApCtl Details")) { + ImGui::Text("Name: %s", netApctlInfo.name); + ImGui::Text("IP: %s", netApctlInfo.ip); + ImGui::Text("SubnetMask: %s", netApctlInfo.ip); + ImGui::Text("SSID: %.*s", netApctlInfo.ssidLength, netApctlInfo.ssid); + ImGui::Text("SSID: %.*s", netApctlInfo.ssidLength, netApctlInfo.ssid); + ImGui::Text("Gateway: %s", netApctlInfo.gateway); + ImGui::Text("PrimaryDNS: %s", netApctlInfo.primaryDns); + ImGui::Text("SecondaryDNS: %s", netApctlInfo.secondaryDns); + } + + if (g_Config.bInfrastructureAutoDNS) { + if (!g_infraDNSConfig.loaded) { + if (g_infraDNSConfig.gameName.empty()) { + ImGui::Text("Known game: %s", g_infraDNSConfig.gameName.c_str()); + } + ImGui::Text("connectAdhocForGrouping: %s", BoolStr(g_infraDNSConfig.connectAdHocForGrouping)); + ImGui::Text("DNS: %s", g_infraDNSConfig.dns.c_str()); + if (!g_infraDNSConfig.dyn_dns.empty()) { + ImGui::Text("DynDNS: %s", g_infraDNSConfig.dyn_dns.c_str()); + } + if (!g_infraDNSConfig.fixedDNS.empty()) { + ImGui::TextUnformatted("Fixed DNS"); + for (auto iter : g_infraDNSConfig.fixedDNS) { + ImGui::Text("%s -> %s", iter.first.c_str(), iter.second.c_str()); + } + } + } + } + + ImGui::End(); +} +static void DrawAdhoc(ImConfig &cfg) { + if (!ImGui::Begin("AdHoc", &cfg.adhocOpen)) { + ImGui::End(); + return; + } + + const char *discoverStatusStr = "N/A"; + switch (netAdhocDiscoverStatus) { + case 0: discoverStatusStr = "NONE"; break; + case 1: discoverStatusStr = "IN_PROGRESS"; break; + case 2: discoverStatusStr = "COMPLETED"; break; + default: break; + } + + auto &io = ImGui::GetIO(); + + /* + ImGui::Text("WantCaptureMouse: %s", BoolStr(io.WantCaptureMouse)); + ImGui::Text("WantCaptureKeyboard: %s", BoolStr(io.WantCaptureKeyboard)); + ImGui::Text("WantCaptureMouseUnlessPopupClose: %s", BoolStr(io.WantCaptureMouseUnlessPopupClose)); + ImGui::Text("WantTextInput: %s", BoolStr(io.WantTextInput)); + */ + + ImGui::Text("sceNetAdhoc inited: %s", BoolStr(netAdhocInited)); + ImGui::Text("sceNetAdhoc inited: %s", BoolStr(netAdhocInited)); + ImGui::Text("sceNetAdhocctl inited: %s", BoolStr(netAdhocctlInited)); + ImGui::Text("sceNetAdhocMatching inited: %s", BoolStr(netAdhocctlInited)); + ImGui::Text("GameMode entered: %s", BoolStr(netAdhocGameModeEntered)); + ImGui::Text("FriendFinder running: %s", BoolStr(g_adhocServerConnected)); + ImGui::Text("sceNetAdhocDiscover status: %s", discoverStatusStr); + + if (ImGui::BeginTable("sock", 5, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH | ImGuiTableFlags_Resizable)) { + ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Non-blocking", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("BufSize", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("IsClient", ImGuiTableColumnFlags_WidthFixed); + + ImGui::TableHeadersRow(); + + for (int i = 0; i < MAX_SOCKET; i++) { + const AdhocSocket *socket = adhocSockets[i]; + if (!socket) { + continue; + } + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%d", i + 1); + ImGui::TableNextColumn(); + switch (socket->type) { + case SOCK_PDP: ImGui::TextUnformatted("PDP"); break; + case SOCK_PTP: ImGui::TextUnformatted("PTP"); break; + default: ImGui::Text("(%d)", socket->type); break; + } + ImGui::TableNextColumn(); + ImGui::TextUnformatted(socket->nonblocking ? "Non-blocking" : "Blocking"); + ImGui::TableNextColumn(); + ImGui::Text("%d", socket->buffer_size); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(BoolStr(socket->isClient)); + } + ImGui::EndTable(); + } + ImGui::End(); } @@ -1145,8 +1259,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu ImGui::EndMenu(); } if (ImGui::BeginMenu("Network")) { + ImGui::MenuItem("ApCtl", nullptr, &cfg_.apctlOpen); ImGui::MenuItem("Sockets", nullptr, &cfg_.socketsOpen); ImGui::MenuItem("NP", nullptr, &cfg_.npOpen); + ImGui::MenuItem("AdHoc", nullptr, &cfg_.adhocOpen); ImGui::EndMenu(); } if (ImGui::BeginMenu("Tools")) { @@ -1279,6 +1395,14 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu DrawNp(cfg_); } + if (cfg_.adhocOpen) { + DrawAdhoc(cfg_); + } + + if (cfg_.apctlOpen) { + DrawApctl(cfg_); + } + // Process UI commands switch (control.command.cmd) { case ImCmd::SHOW_IN_CPU_DISASM: @@ -1643,6 +1767,8 @@ void ImConfig::SyncConfig(IniFile *ini, bool save) { sync.Sync("schedulerOpen", &schedulerOpen, false); sync.Sync("socketsOpen", &socketsOpen, false); sync.Sync("npOpen", &npOpen, false); + sync.Sync("adhocOpen", &adhocOpen, false); + sync.Sync("apctlOpen", &apctlOpen, false); sync.Sync("pixelViewerOpen", &pixelViewerOpen, false); for (int i = 0; i < 4; i++) { char name[64]; diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index d85d27e6c235..f2811c1c7b8f 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -143,6 +143,8 @@ struct ImConfig { bool pixelViewerOpen; bool npOpen; bool socketsOpen; + bool apctlOpen; + bool adhocOpen; bool memDumpOpen; bool memViewOpen[4]; @@ -231,3 +233,4 @@ void ShowInWindowMenuItems(uint32_t addr, ImControl &control); void ShowInMemoryViewerMenuItem(uint32_t addr, ImControl &control); void ShowInMemoryDumperMenuItem(uint32_t addr, uint32_t size, MemDumpMode mode, ImControl &control); void StatusBar(std::string_view str); +inline const char *BoolStr(bool s) { return s ? "true" : "false"; } diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 3936bd31c0d5..f88969231382 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -278,11 +278,11 @@ void GamePauseScreen::update() { finishNextFrame_ = false; } - if (netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected) { + if (g_netInited != lastNetInited_ || netInetInited != lastNetInetInited_ || lastAdhocServerConnected_ != g_adhocServerConnected) { INFO_LOG(Log::sceNet, "Network status changed, recreating views"); RecreateViews(); lastNetInetInited_ = netInetInited; - lastNetInited_ = netInited; + lastNetInited_ = g_netInited; lastAdhocServerConnected_ = g_adhocServerConnected; } @@ -386,19 +386,26 @@ void GamePauseScreen::CreateViews() { } } - if (netInited || g_adhocServerConnected) { + if (IsNetworkConnected()) { leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, nw->T("Network connected"), "")); - if (!g_infraDNSConfig.revivalTeam.empty() && netInetInited) { - leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure Mode server 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) { - if (!g_infraDNSConfig.revivalTeamURL.empty()) { - System_LaunchUrl(LaunchUrlType::BROWSER_URL, g_infraDNSConfig.revivalTeamURL.c_str()); - } - return UI::EVENT_DONE; - }); + if (g_infraDNSConfig.loaded) { + if (g_infraDNSConfig.state == InfraGameState::NotWorking) { + leftColumnItems->Add(new NoticeView(NoticeLevel::WARN, nw->T("Some network functionality in this game is not working"), "")); + } 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() && netInetInited) { + leftColumnItems->Add(new TextView(std::string(nw->T("Infrastructure Mode server 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) { + if (!g_infraDNSConfig.revivalTeamURL.empty()) { + System_LaunchUrl(LaunchUrlType::BROWSER_URL, g_infraDNSConfig.revivalTeamURL.c_str()); + } + return UI::EVENT_DONE; + }); + } } } @@ -409,7 +416,7 @@ void GamePauseScreen::CreateViews() { bool achievementsAllowSavestates = !Achievements::HardcoreModeActive() || g_Config.bAchievementsSaveStateInHardcoreMode; bool showSavestateControls = achievementsAllowSavestates; - if (netInited && !g_Config.bAllowSavestateWhileConnected) { + if (IsNetworkConnected() && !g_Config.bAllowSavestateWhileConnected) { showSavestateControls = false; }