From 38e3f5cec04f29f747515248ca3f002bd1cc52a8 Mon Sep 17 00:00:00 2001 From: Stan Date: Tue, 30 Jul 2024 18:44:38 +0000 Subject: [PATCH] Fix build with miniupnpc 2.2.8 See https://github.com/miniupnp/miniupnp/blob/miniupnpc_2_2_8/miniupnpc/Changelog.txt. And https://github.com/0ad/0ad/pull/45 Patch by: @emily Accepted: by @Stan Comments by: @phosit, @sera Differential Revision: https://code.wildfiregames.com/D5307 This was SVN commit r28167. --- .../public/gui/credits/texts/programming.json | 1 + source/network/NetServer.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json index 1d3be88bcb..258b3b17e2 100644 --- a/binaries/data/mods/public/gui/credits/texts/programming.json +++ b/binaries/data/mods/public/gui/credits/texts/programming.json @@ -91,6 +91,7 @@ { "nick": "edoput", "name": "Edoardo Putti"}, { "nick": "eihrul", "name": "Lee Salzman" }, { "nick": "elexis", "name": "Alexander Heinsius" }, + { "name": "Emily" }, { "nick": "EmjeR", "name": "Matthijs de Rijk" }, { "nick": "EMontana" }, { "nick": "ericb" }, diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index 63868526e9..7f22be1a1b 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -252,7 +252,11 @@ void CNetServerWorker::SetupUPnP() else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL) #endif { +#if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18 + ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress), nullptr, 0); +#else ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress)); +#endif allocatedUrls = ret != 0; // urls is allocated on non-zero return values } else @@ -270,17 +274,28 @@ void CNetServerWorker::SetupUPnP() case 1: LOGMESSAGE("Net server: found valid IGD = %s", urls.controlURL); break; +#if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18 case 2: - LOGMESSAGE("Net server: found a valid, not connected IGD = %s, will try to continue anyway", urls.controlURL); + LOGMESSAGE("Net server: found IGD with reserved IP = %s, will try to continue anyway", urls.controlURL); break; case 3: +#else + case 2: +#endif + LOGMESSAGE("Net server: found a valid, not connected IGD = %s, will try to continue anyway", urls.controlURL); + break; +#if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18 + case 4: +#else + case 3: +#endif LOGMESSAGE("Net server: found a UPnP device unrecognized as IGD = %s, will try to continue anyway", urls.controlURL); break; default: debug_warn(L"Unrecognized return value from UPNP_GetValidIGD"); } - // Try getting our external/internet facing IP. TODO: Display this on the game-setup page for conviniance. + // Try getting our external/internet facing IP. TODO: Display this on the game-setup page for convenience. ret = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); if (ret != UPNPCOMMAND_SUCCESS) {