git: d86e9f39581e - main - games/simutrans: Fix build after net/miniupnpc API breakage

From: Dmitry Marakasov <amdmi3_at_FreeBSD.org>
Date: Thu, 18 Jul 2024 16:14:37 UTC
The branch main has been updated by amdmi3:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d86e9f39581e4e5cc1fa972b05ddb5d04c20a43e

commit d86e9f39581e4e5cc1fa972b05ddb5d04c20a43e
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2024-07-18 15:12:31 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2024-07-18 16:14:33 +0000

    games/simutrans: Fix build after net/miniupnpc API breakage
---
 games/simutrans/files/patch-upnp | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/games/simutrans/files/patch-upnp b/games/simutrans/files/patch-upnp
new file mode 100644
index 000000000000..38267818dc2c
--- /dev/null
+++ b/games/simutrans/files/patch-upnp
@@ -0,0 +1,34 @@
+From upstream commit b399b9c89b3369ebe3a9afa54459f74c9c5f52b1
+
+diff --git src/simutrans/network/network.cc src/simutrans/network/network.cc
+index 5acf10e5c7..52669ad9d0 100644
+--- src/simutrans/network/network.cc
++++ 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)