# adapted from <https://github.com/simutrans/simutrans/commit/089b83b>

From 089b83b03acfb2c1db9f2d22cc10e94ff8ed63be Mon Sep 17 00:00:00 2001
From: prissi <prissi@8aca7d54-2c30-db11-9de9-000461428c89>
Date: Mon, 3 Jun 2024 03:31:47 +0000
Subject: [PATCH] Back to nightly and fix the API for miniupnpc

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11273 8aca7d54-2c30-db11-9de9-000461428c89
---

diff --git a/src/simutrans/network/network.cc b/src/simutrans/network/network.cc
index 5acf10e5c..52669ad9d 100644
--- a/src/simutrans/network/network.cc
+++ b/src/simutrans/network/network.cc
@@ -981,7 +981,12 @@ bool prepare_for_server( char *externalIPAddress, char *externalAltIPAddress, in
 		struct UPNPUrls urls;
 		struct IGDdatas data;
 
+#if MINIUPNPC_API_VERSION <= 17
 		UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof(lanaddr) );
+#else
+		char wanaddr[64] = "uset";
+		UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(lanaddr));
+#endif
 		// we must know our IP address first
 		if(  UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress) ==  UPNPCOMMAND_SUCCESS  ) {
 			// this is our ID (at least the routes tells us this)
@@ -1040,7 +1045,13 @@ void remove_port_forwarding( int port )
 		struct UPNPUrls urls;
 		struct IGDdatas data;
 
-		UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof(lanaddr) );
+#if MINIUPNPC_API_VERSION <= 17
+		UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
+#else
+		char wanaddr[64] = "uset";
+		UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), wanaddr, sizeof(lanaddr));
+#endif
+
 		// we must know our IP address first
 		if(  UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress) ==  UPNPCOMMAND_SUCCESS  ) {
 			// this is our ID (at least the routes tells us this)