From a404138f825d8eb9fac5bf38238f0bc7da6b54df Mon Sep 17 00:00:00 2001 From: Fireball Wayne Date: Mon, 13 Feb 2017 21:18:14 -0500 Subject: [PATCH] Remember Last Remote ISO server --- Core/Config.cpp | 2 ++ Core/Config.h | 2 ++ UI/RemoteISOScreen.cpp | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/Core/Config.cpp b/Core/Config.cpp index 0a192d797b..e7ea6f5a64 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -339,6 +339,8 @@ static ConfigSetting generalSettings[] = { ConfigSetting("AutoSaveSymbolMap", &g_Config.bAutoSaveSymbolMap, false, true, true), ConfigSetting("CacheFullIsoInRam", &g_Config.bCacheFullIsoInRam, false, true, true), ConfigSetting("RemoteISOPort", &g_Config.iRemoteISOPort, 0, true, false), + ConfigSetting("LastRemoteISOServer", &g_Config.sLastRemoteISOServer, ""), + ConfigSetting("LastRemoteISOPort", &g_Config.iLastRemoteISOPort, 0), #ifdef __ANDROID__ ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, 1), diff --git a/Core/Config.h b/Core/Config.h index d76d1b2519..fac7a9513d 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -141,6 +141,8 @@ public: bool bAutoSaveSymbolMap; bool bCacheFullIsoInRam; int iRemoteISOPort; + std::string sLastRemoteISOServer; + int iLastRemoteISOPort; bool bMemStickInserted; int iScreenRotation; // The rotation angle of the PPSSPP UI. Only supported on Android and possibly other mobile platforms. diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 7bef93c999..5a0061c097 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -188,6 +188,17 @@ static bool FindServer(std::string &resultHost, int &resultPort) { Buffer result; int code = 500; + // Not sure why this is needed here, but windows fails without it. + net::Init(); + + // Try last server first, if it is set + if (g_Config.iLastRemoteISOPort && g_Config.sLastRemoteISOServer != "" && http.Resolve(g_Config.sLastRemoteISOServer.c_str(), g_Config.iLastRemoteISOPort) && http.Connect()) { + http.Disconnect(); + resultHost = g_Config.sLastRemoteISOServer; + resultPort = g_Config.iLastRemoteISOPort; + return true; + } + // Start by requesting a list of recent local ips for this network. if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) { if (http.Connect()) { @@ -269,6 +280,12 @@ static bool LoadGameList(const std::string &host, int port, std::vector