From 4cb41925b9413108279550e40cb3c4b7dc508b2c Mon Sep 17 00:00:00 2001 From: clayjohn Date: Mon, 18 Nov 2024 16:05:28 -0800 Subject: [PATCH 1/6] Normalize normal tangent and binormal before interpolating in the mobile renderer to avoid precision errors on heavily scaled meshes (backport for 4.3) --- .../shaders/forward_mobile/scene_forward_mobile.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index 409a71dc782..205e5d20f7b 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -439,12 +439,12 @@ void main() { vertex_interp = vertex; #ifdef NORMAL_USED - normal_interp = normal; + normal_interp = normalize(normal); #endif #if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED) - tangent_interp = tangent; - binormal_interp = binormal; + tangent_interp = normalize(tangent); + binormal_interp = normalize(binormal); #endif #ifdef MODE_RENDER_DEPTH From 7b1b99e4c8e27d626a210c56a497173ddecb1454 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 10 Oct 2024 00:10:58 -0700 Subject: [PATCH 2/6] [4.3] GLTF: Fix bad pointer to ImporterMeshInstance3D root node at runtime --- ...cument_extension_convert_importer_mesh.cpp | 43 +++++++++++-------- ...document_extension_convert_importer_mesh.h | 3 ++ modules/gltf/gltf_document.cpp | 6 +++ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp index 204b2df6386..0cbd4d581f9 100644 --- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp +++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp @@ -46,6 +46,29 @@ void GLTFDocumentExtensionConvertImporterMesh::_copy_meta(Object *p_src_object, } } +MeshInstance3D *GLTFDocumentExtensionConvertImporterMesh::convert_importer_mesh_instance_3d(ImporterMeshInstance3D *p_importer_mesh_instance_3d) { + // Convert the node itself first. + MeshInstance3D *mesh_instance_node_3d = memnew(MeshInstance3D); + ERR_FAIL_NULL_V(p_importer_mesh_instance_3d, mesh_instance_node_3d); + mesh_instance_node_3d->set_name(p_importer_mesh_instance_3d->get_name()); + mesh_instance_node_3d->set_transform(p_importer_mesh_instance_3d->get_transform()); + mesh_instance_node_3d->set_skin(p_importer_mesh_instance_3d->get_skin()); + mesh_instance_node_3d->set_skeleton_path(p_importer_mesh_instance_3d->get_skeleton_path()); + mesh_instance_node_3d->set_visible(p_importer_mesh_instance_3d->is_visible()); + p_importer_mesh_instance_3d->replace_by(mesh_instance_node_3d); + _copy_meta(p_importer_mesh_instance_3d, mesh_instance_node_3d); + // Convert the mesh data in the mesh resource. + Ref importer_mesh = p_importer_mesh_instance_3d->get_mesh(); + if (importer_mesh.is_valid()) { + Ref array_mesh = importer_mesh->get_mesh(); + mesh_instance_node_3d->set_mesh(array_mesh); + _copy_meta(importer_mesh.ptr(), array_mesh.ptr()); + } else { + WARN_PRINT("glTF: ImporterMeshInstance3D does not have a valid mesh. This should not happen. Continuing anyway."); + } + return mesh_instance_node_3d; +} + Error GLTFDocumentExtensionConvertImporterMesh::import_post(Ref p_state, Node *p_root) { ERR_FAIL_NULL_V(p_root, ERR_INVALID_PARAMETER); ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER); @@ -57,24 +80,8 @@ Error GLTFDocumentExtensionConvertImporterMesh::import_post(Ref p_sta Node *node = E->get(); ImporterMeshInstance3D *importer_mesh_3d = Object::cast_to(node); if (importer_mesh_3d) { - MeshInstance3D *mesh_instance_node_3d = memnew(MeshInstance3D); - Ref mesh = importer_mesh_3d->get_mesh(); - if (mesh.is_valid()) { - Ref array_mesh = mesh->get_mesh(); - mesh_instance_node_3d->set_name(node->get_name()); - mesh_instance_node_3d->set_transform(importer_mesh_3d->get_transform()); - mesh_instance_node_3d->set_mesh(array_mesh); - mesh_instance_node_3d->set_skin(importer_mesh_3d->get_skin()); - mesh_instance_node_3d->set_skeleton_path(importer_mesh_3d->get_skeleton_path()); - mesh_instance_node_3d->set_visible(importer_mesh_3d->is_visible()); - node->replace_by(mesh_instance_node_3d); - _copy_meta(importer_mesh_3d, mesh_instance_node_3d); - _copy_meta(mesh.ptr(), array_mesh.ptr()); - delete_queue.push_back(node); - node = mesh_instance_node_3d; - } else { - memdelete(mesh_instance_node_3d); - } + delete_queue.push_back(importer_mesh_3d); + node = convert_importer_mesh_instance_3d(importer_mesh_3d); } int child_count = node->get_child_count(); for (int i = 0; i < child_count; i++) { diff --git a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h index ca10444eb57..09547c12b71 100644 --- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h +++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h @@ -33,6 +33,8 @@ #include "gltf_document_extension.h" +class MeshInstance3D; + class GLTFDocumentExtensionConvertImporterMesh : public GLTFDocumentExtension { GDCLASS(GLTFDocumentExtensionConvertImporterMesh, GLTFDocumentExtension); @@ -41,6 +43,7 @@ class GLTFDocumentExtensionConvertImporterMesh : public GLTFDocumentExtension { static void _copy_meta(Object *p_src_object, Object *p_dst_object); public: + static MeshInstance3D *convert_importer_mesh_instance_3d(ImporterMeshInstance3D *p_importer_mesh_instance_3d); Error import_post(Ref p_state, Node *p_root) override; }; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index ec4b240ff89..e4c683f2645 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -30,6 +30,7 @@ #include "gltf_document.h" +#include "extensions/gltf_document_extension_convert_importer_mesh.h" #include "extensions/gltf_spec_gloss.h" #include "gltf_state.h" #include "skin_tool.h" @@ -7339,6 +7340,11 @@ Node *GLTFDocument::generate_scene(Ref p_state, float p_bake_fps, boo ERR_CONTINUE(err != OK); } } + ImporterMeshInstance3D *root_importer_mesh = Object::cast_to(root); + if (unlikely(root_importer_mesh)) { + root = GLTFDocumentExtensionConvertImporterMesh::convert_importer_mesh_instance_3d(root_importer_mesh); + memdelete(root_importer_mesh); + } for (Ref ext : document_extensions) { ERR_CONTINUE(ext.is_null()); err = ext->import_post(p_state, root); From 7798c0028a7689ce848eb17227c0b02e5fa3bdc9 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sat, 21 Dec 2024 02:44:31 +0100 Subject: [PATCH 3/6] Fix various code examples in documentation --- doc/classes/Array.xml | 6 +++--- doc/classes/DTLSServer.xml | 6 +++--- doc/classes/Window.xml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 79e74c4cc4a..ed234a57eb1 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -21,11 +21,11 @@ var array = new Godot.Collections.Array{"First", 2, 3, "Last"}; GD.Print(array[0]); // Prints "First" GD.Print(array[2]); // Prints 3 - GD.Print(array[array.Count - 1]); // Prints "Last" + GD.Print(array[^1]); // Prints "Last" - array[2] = "Second"; + array[1] = "Second"; GD.Print(array[1]); // Prints "Second" - GD.Print(array[array.Count - 3]); // Prints "Second" + GD.Print(array[^3]); // Prints "Second" [/csharp] [/codeblocks] [b]Note:[/b] Arrays are always passed by [b]reference[/b]. To get a copy of an array that can be modified independently of the original array, use [method duplicate]. diff --git a/doc/classes/DTLSServer.xml b/doc/classes/DTLSServer.xml index 41e241779a9..7fc45d80bf8 100644 --- a/doc/classes/DTLSServer.xml +++ b/doc/classes/DTLSServer.xml @@ -19,7 +19,7 @@ server.listen(4242) var key = load("key.key") # Your private key. var cert = load("cert.crt") # Your X509 certificate. - dtls.setup(key, cert) + dtls.setup(TlsOptions.server(key, cert)) func _process(delta): while server.is_connection_available(): @@ -52,12 +52,12 @@ _server.Listen(4242); var key = GD.Load<CryptoKey>("key.key"); // Your private key. var cert = GD.Load<X509Certificate>("cert.crt"); // Your X509 certificate. - _dtls.Setup(key, cert); + _dtls.Setup(TlsOptions.Server(key, cert)); } public override void _Process(double delta) { - while (Server.IsConnectionAvailable()) + while (_server.IsConnectionAvailable()) { PacketPeerUdp peer = _server.TakeConnection(); PacketPeerDtls dtlsPeer = _dtls.TakeConnection(peer); diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index ca155881c8e..64ff78e647a 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -638,13 +638,13 @@ [/gdscript] [csharp] // Set region, using Path2D node. - GetNode<Window>("Window").MousePassthrough = GetNode<Path2D>("Path2D").Curve.GetBakedPoints(); + GetNode<Window>("Window").MousePassthroughPolygon = GetNode<Path2D>("Path2D").Curve.GetBakedPoints(); // Set region, using Polygon2D node. - GetNode<Window>("Window").MousePassthrough = GetNode<Polygon2D>("Polygon2D").Polygon; + GetNode<Window>("Window").MousePassthroughPolygon = GetNode<Polygon2D>("Polygon2D").Polygon; // Reset region to default. - GetNode<Window>("Window").MousePassthrough = new Vector2[] {}; + GetNode<Window>("Window").MousePassthroughPolygon = new Vector2[] {}; [/csharp] [/codeblocks] [b]Note:[/b] This property is ignored if [member mouse_passthrough] is set to [code]true[/code]. From 5e5e1a2182e30ca805d101fa8e5b4ab91c00fcd7 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:32:05 +0100 Subject: [PATCH 4/6] Remove outer navigation map read locks Removes outer navigation map read locks. --- modules/navigation/nav_map.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp index f917c988eaa..f0218b1af4d 100644 --- a/modules/navigation/nav_map.cpp +++ b/modules/navigation/nav_map.cpp @@ -670,7 +670,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector } Vector3 NavMap::get_closest_point(const Vector3 &p_point) const { - RWLockRead read_lock(map_rwlock); if (iteration_id == 0) { NAVMAP_ITERATION_ZERO_ERROR_MSG(); return Vector3(); @@ -680,7 +679,6 @@ Vector3 NavMap::get_closest_point(const Vector3 &p_point) const { } Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const { - RWLockRead read_lock(map_rwlock); if (iteration_id == 0) { NAVMAP_ITERATION_ZERO_ERROR_MSG(); return Vector3(); @@ -690,7 +688,6 @@ Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const { } RID NavMap::get_closest_point_owner(const Vector3 &p_point) const { - RWLockRead read_lock(map_rwlock); if (iteration_id == 0) { NAVMAP_ITERATION_ZERO_ERROR_MSG(); return RID(); From 3aafddd63bd0dbdaa74f9fc7c4760f12a774e31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 25 Jan 2025 14:55:12 +0100 Subject: [PATCH 5/6] Add missing `cstdint` includes for GCC 15 (cherry picked from commit 1823460787a6c1bb8e4eaf21ac2a3f90d24d5ee0) --- thirdparty/glslang/SPIRV/SpvBuilder.h | 1 + thirdparty/glslang/patches/fix-build-gcc15.patch | 12 ++++++++++++ thirdparty/thorvg/inc/thorvg.h | 1 + thirdparty/thorvg/patches/fix-build-gcc15.patch | 12 ++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 thirdparty/glslang/patches/fix-build-gcc15.patch create mode 100644 thirdparty/thorvg/patches/fix-build-gcc15.patch diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.h b/thirdparty/glslang/SPIRV/SpvBuilder.h index a65a98e3377..1499592c4f8 100644 --- a/thirdparty/glslang/SPIRV/SpvBuilder.h +++ b/thirdparty/glslang/SPIRV/SpvBuilder.h @@ -56,6 +56,7 @@ namespace spv { } #include +#include #include #include #include diff --git a/thirdparty/glslang/patches/fix-build-gcc15.patch b/thirdparty/glslang/patches/fix-build-gcc15.patch new file mode 100644 index 00000000000..69ccf8e34c3 --- /dev/null +++ b/thirdparty/glslang/patches/fix-build-gcc15.patch @@ -0,0 +1,12 @@ +diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.h b/thirdparty/glslang/SPIRV/SpvBuilder.h +index a65a98e337..1499592c4f 100644 +--- a/thirdparty/glslang/SPIRV/SpvBuilder.h ++++ b/thirdparty/glslang/SPIRV/SpvBuilder.h +@@ -56,6 +56,7 @@ namespace spv { + } + + #include ++#include + #include + #include + #include diff --git a/thirdparty/thorvg/inc/thorvg.h b/thirdparty/thorvg/inc/thorvg.h index 4303092a5ea..607b7b37825 100644 --- a/thirdparty/thorvg/inc/thorvg.h +++ b/thirdparty/thorvg/inc/thorvg.h @@ -1,6 +1,7 @@ #ifndef _THORVG_H_ #define _THORVG_H_ +#include #include #include #include diff --git a/thirdparty/thorvg/patches/fix-build-gcc15.patch b/thirdparty/thorvg/patches/fix-build-gcc15.patch new file mode 100644 index 00000000000..4071e1dd6e6 --- /dev/null +++ b/thirdparty/thorvg/patches/fix-build-gcc15.patch @@ -0,0 +1,12 @@ +diff --git a/thirdparty/thorvg/inc/thorvg.h b/thirdparty/thorvg/inc/thorvg.h +index 8e3ab4e6ce..f515a03136 100644 +--- a/thirdparty/thorvg/inc/thorvg.h ++++ b/thirdparty/thorvg/inc/thorvg.h +@@ -1,6 +1,7 @@ + #ifndef _THORVG_H_ + #define _THORVG_H_ + ++#include + #include + #include + #include From cad4caa81b39ed555f1b9554c4e4beca79e25969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 18 Sep 2024 11:50:54 +0200 Subject: [PATCH 6/6] miniupnpc: Update to 2.2.8 (new major 18) Keep support for major 17 by using a version check for the changed API. Fixes #93907. (cherry picked from commit 4c72d599f0a171a96e47004239f42756115b723f) --- modules/upnp/upnp.cpp | 4 + thirdparty/README.md | 2 +- thirdparty/miniupnpc/include/miniupnpc.h | 19 +++-- thirdparty/miniupnpc/src/addr_is_reserved.c | 11 ++- thirdparty/miniupnpc/src/minisoap.c | 7 +- thirdparty/miniupnpc/src/minissdpc.c | 9 +- thirdparty/miniupnpc/src/miniupnpc.c | 93 +++++++++------------ thirdparty/miniupnpc/src/miniupnpcstrings.h | 2 +- thirdparty/miniupnpc/src/miniwget.c | 44 +--------- thirdparty/miniupnpc/src/win32_snprintf.h | 4 +- 10 files changed, 79 insertions(+), 116 deletions(-) diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 70f0ea346b1..f10fc40136d 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -131,7 +131,11 @@ void UPNP::parse_igd(Ref dev, UPNPDev *devlist) { GetUPNPUrls(&urls, &data, dev->get_description_url().utf8().get_data(), 0); char addr[16]; +#if MINIUPNPC_API_VERSION >= 18 + int i = UPNP_GetValidIGD(devlist, &urls, &data, (char *)&addr, 16, nullptr, 0); +#else int i = UPNP_GetValidIGD(devlist, &urls, &data, (char *)&addr, 16); +#endif if (i != 1) { FreeUPNPUrls(&urls); diff --git a/thirdparty/README.md b/thirdparty/README.md index fd9634691da..208f919421f 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -610,7 +610,7 @@ to solve some MSVC warnings. See the patches in the `patches` directory. ## miniupnpc - Upstream: https://github.com/miniupnp/miniupnp -- Version: 2.2.7 (d4d5ec7d48c093b37b2ea5d7171ede21ce9d7ff2, 2024) +- Version: 2.2.8 (b55145ec095652289a59c33603f3abafee898273, 2024) - License: BSD-3-Clause Files extracted from upstream source: diff --git a/thirdparty/miniupnpc/include/miniupnpc.h b/thirdparty/miniupnpc/include/miniupnpc.h index 808c6ad975f..fd951a0836b 100644 --- a/thirdparty/miniupnpc/include/miniupnpc.h +++ b/thirdparty/miniupnpc/include/miniupnpc.h @@ -1,9 +1,9 @@ -/* $Id: miniupnpc.h,v 1.63 2024/01/04 00:45:17 nanard Exp $ */ +/* $Id: miniupnpc.h,v 1.66 2024/06/08 22:13:14 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project: miniupnp * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author: Thomas Bernard - * Copyright (c) 2005-2022 Thomas Bernard + * Copyright (c) 2005-2024 Thomas Bernard * This software is subjects to the conditions detailed * in the LICENCE file provided within this distribution */ #ifndef MINIUPNPC_H_INCLUDED @@ -20,8 +20,8 @@ #define UPNPDISCOVER_MEMORY_ERROR (-102) /* versions : */ -#define MINIUPNPC_VERSION "2.2.6" -#define MINIUPNPC_API_VERSION 17 +#define MINIUPNPC_VERSION "2.2.8" +#define MINIUPNPC_API_VERSION 18 /* Source port: Using "1" as an alias for 1900 for backwards compatibility @@ -108,9 +108,11 @@ struct UPNPUrls { * return values : * 0 = NO IGD found * 1 = A valid connected IGD has been found - * 2 = A valid IGD has been found but it reported as + * 2 = A valid connected IGD has been found but its + * IP address is reserved (non routable) + * 3 = A valid IGD has been found but it reported as * not connected - * 3 = an UPnP device has been found but was not recognized as an IGD + * 4 = an UPnP device has been found but was not recognized as an IGD * * In any non zero return case, the urls and data structures * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to @@ -119,8 +121,9 @@ struct UPNPUrls { MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen); + struct IGDdatas * data, + char * lanaddr, int lanaddrlen, + char * wanaddr, int wanaddrlen); /* UPNP_GetIGDFromUrl() * Used when skipping the discovery process. diff --git a/thirdparty/miniupnpc/src/addr_is_reserved.c b/thirdparty/miniupnpc/src/addr_is_reserved.c index 18c64242015..145b504823a 100644 --- a/thirdparty/miniupnpc/src/addr_is_reserved.c +++ b/thirdparty/miniupnpc/src/addr_is_reserved.c @@ -3,7 +3,7 @@ * Project : miniupnp * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author : Thomas BERNARD - * copyright (c) 2005-2021 Thomas Bernard + * copyright (c) 2005-2024 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #ifdef _WIN32 @@ -21,6 +21,9 @@ typedef unsigned long uint32_t; #include #include #endif /* _WIN32 */ +#ifdef DEBUG +#include +#endif /* List of IP address blocks which are private / reserved and therefore not suitable for public external IP addresses */ #define IP(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) @@ -71,8 +74,12 @@ int addr_is_reserved(const char * addr_str) address = ntohl(addr_n); for (i = 0; i < sizeof(reserved)/sizeof(reserved[0]); ++i) { - if ((address >> reserved[i].rmask) == (reserved[i].address >> reserved[i].rmask)) + if ((address >> reserved[i].rmask) == (reserved[i].address >> reserved[i].rmask)) { +#ifdef DEBUG + printf("IP address %s is reserved\n", addr_str); +#endif return 1; + } } return 0; diff --git a/thirdparty/miniupnpc/src/minisoap.c b/thirdparty/miniupnpc/src/minisoap.c index 903ac5ffc61..5c6bf016845 100644 --- a/thirdparty/miniupnpc/src/minisoap.c +++ b/thirdparty/miniupnpc/src/minisoap.c @@ -2,7 +2,7 @@ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005-2023 Thomas Bernard + * Copyright (c) 2005-2024 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * @@ -83,7 +83,7 @@ int soapPostSubmit(SOCKET fd, * Using HTTP/1.1 means we need to support chunked transfer-encoding : * When using HTTP/1.1, the router "BiPAC 7404VNOX" always use chunked * transfer encoding. */ - /* Connection: Close is normally there only in HTTP/1.1 but who knows */ + /* Connection: close is normally there only in HTTP/1.1 but who knows */ portstr[0] = '\0'; if(port != 80) snprintf(portstr, sizeof(portstr), ":%hu", port); @@ -98,9 +98,8 @@ int soapPostSubmit(SOCKET fd, "Content-Type: text/xml; charset=\"utf-8\"\r\n" #endif "SOAPAction: \"%s\"\r\n" - "Connection: Close\r\n" + "Connection: close\r\n" "Cache-Control: no-cache\r\n" /* ??? */ - "Pragma: no-cache\r\n" "\r\n", url, httpversion, host, portstr, bodysize, action); if ((unsigned int)headerssize >= sizeof(headerbuf)) diff --git a/thirdparty/miniupnpc/src/minissdpc.c b/thirdparty/miniupnpc/src/minissdpc.c index 98c5b37463f..57cb99962e6 100644 --- a/thirdparty/miniupnpc/src/minissdpc.c +++ b/thirdparty/miniupnpc/src/minissdpc.c @@ -1,9 +1,9 @@ -/* $Id: minissdpc.c,v 1.49 2021/05/13 11:00:36 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.51 2024/05/16 00:12:05 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author : Thomas BERNARD - * copyright (c) 2005-2021 Thomas Bernard + * copyright (c) 2005-2024 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include @@ -548,7 +548,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], #ifdef _WIN32 unsigned long _ttl = (unsigned long)ttl; #endif - int linklocal = 1; + int linklocal = 0; /* try first with site-local multicast */ int sentok; if(error) @@ -1007,9 +1007,10 @@ ssdpDiscoverDevices(const char * const deviceTypes[], /* switch linklocal flag */ if(linklocal) { linklocal = 0; - --deviceIndex; } else { + /* try again with linklocal multicast */ linklocal = 1; + --deviceIndex; } } } diff --git a/thirdparty/miniupnpc/src/miniupnpc.c b/thirdparty/miniupnpc/src/miniupnpc.c index 696af932372..9da1496b378 100644 --- a/thirdparty/miniupnpc/src/miniupnpc.c +++ b/thirdparty/miniupnpc/src/miniupnpc.c @@ -3,7 +3,7 @@ * Project : miniupnp * Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author : Thomas BERNARD - * copyright (c) 2005-2021 Thomas Bernard + * copyright (c) 2005-2024 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #include @@ -92,15 +92,15 @@ MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGD #endif } -/* simpleUPnPcommand2 : +/* simpleUPnPcommand : * not so simple ! * return values : * pointer - OK * NULL - error */ -static char * -simpleUPnPcommand2(SOCKET s, const char * url, const char * service, - const char * action, struct UPNParg * args, - int * bufsize, const char * httpversion) +char * +simpleUPnPcommand(int s, const char * url, const char * service, + const char * action, struct UPNParg * args, + int * bufsize) { char hostname[MAXHOSTNAMELEN+1]; unsigned short port = 0; @@ -197,15 +197,15 @@ simpleUPnPcommand2(SOCKET s, const char * url, const char * service, return NULL; } if(!parseURL(url, hostname, &port, &path, NULL)) return NULL; - if(ISINVALID(s)) { + if(ISINVALID((SOCKET)s)) { s = connecthostport(hostname, port, 0); - if(ISINVALID(s)) { + if(ISINVALID((SOCKET)s)) { /* failed to connect */ return NULL; } } - n = soapPostSubmit(s, path, hostname, port, soapact, soapbody, httpversion); + n = soapPostSubmit(s, path, hostname, port, soapact, soapbody, "1.1"); if(n<=0) { #ifdef DEBUG printf("Error sending SOAP request\n"); @@ -229,33 +229,6 @@ simpleUPnPcommand2(SOCKET s, const char * url, const char * service, return buf; } -/* simpleUPnPcommand : - * not so simple ! - * return values : - * pointer - OK - * NULL - error */ -char * -simpleUPnPcommand(int s, const char * url, const char * service, - const char * action, struct UPNParg * args, - int * bufsize) -{ - char * buf; - -#if 1 - buf = simpleUPnPcommand2((SOCKET)s, url, service, action, args, bufsize, "1.1"); -#else - buf = simpleUPnPcommand2((SOCKET)s, url, service, action, args, bufsize, "1.0"); - if (!buf || *bufsize == 0) - { -#if DEBUG - printf("Error or no result from SOAP request; retrying with HTTP/1.1\n"); -#endif - buf = simpleUPnPcommand2((SOCKET)s, url, service, action, args, bufsize, "1.1"); - } -#endif - return buf; -} - /* upnpDiscoverDevices() : * return a chained list of all devices found or NULL if * no devices was found. @@ -534,9 +507,11 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data) * -1 = Internal error * 0 = NO IGD found * 1 = A valid connected IGD has been found - * 2 = A valid IGD has been found but it reported as + * 2 = A valid connected IGD has been found but its + * IP address is reserved (non routable) + * 3 = A valid IGD has been found but it reported as * not connected - * 3 = an UPnP device has been found but was not recognized as an IGD + * 4 = an UPnP device has been found but was not recognized as an IGD * * In any positive non zero return case, the urls and data structures * passed as parameters are set. Don't forget to call FreeUPNPUrls(urls) to @@ -545,11 +520,13 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data) MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen) + struct IGDdatas * data, + char * lanaddr, int lanaddrlen, + char * wanaddr, int wanaddrlen) { struct xml_desc { char lanaddr[40]; + char wanaddr[40]; char * xml; int size; int is_igd; @@ -557,8 +534,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPDev * dev; int ndev = 0; int i; - int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */ - char extIpAddr[16]; + int state = -1; /* state 1 : IGD connected. State 2 : connected with reserved IP. + * State 3 : IGD. State 4 : anything */ int status_code = -1; if(!devlist) @@ -602,7 +579,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, } } /* iterate the list to find a device depending on state */ - for(state = 1; state <= 3; state++) + for(state = 1; state <= 4; state++) { for(dev = devlist, i = 0; dev; dev = dev->pNext, i++) { @@ -611,14 +588,14 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, memset(data, 0, sizeof(struct IGDdatas)); memset(urls, 0, sizeof(struct UPNPUrls)); parserootdesc(desc[i].xml, desc[i].size, data); - if(desc[i].is_igd || state >= 3 ) + if(desc[i].is_igd || state >= 4 ) { int is_connected; GetUPNPUrls(urls, data, dev->descURL, dev->scope_id); - /* in state 2 and 3 we don't test if device is connected ! */ - if(state >= 2) + /* in state 3 and 4 we don't test if device is connected ! */ + if(state >= 3) goto free_and_return; is_connected = UPNPIGD_IsConnected(urls, data); #ifdef DEBUG @@ -626,9 +603,11 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, urls->controlURL, is_connected); #endif /* checks that status is connected AND there is a external IP address assigned */ - if(is_connected && - (UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, extIpAddr) == 0)) { - if(!addr_is_reserved(extIpAddr)) + if(is_connected) { + if(state >= 2) + goto free_and_return; + if(UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, desc[i].wanaddr) == 0 + && !addr_is_reserved(desc[i].wanaddr)) goto free_and_return; } FreeUPNPUrls(urls); @@ -647,9 +626,11 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, printf("UPNPIGD_IsConnected(%s) = %d\n", urls->controlURL, is_connected); #endif - if(is_connected && - (UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, extIpAddr) == 0)) { - if(!addr_is_reserved(extIpAddr)) + if(is_connected) { + if(state >= 2) + goto free_and_return; + if(UPNP_GetExternalIPAddress(urls->controlURL, data->first.servicetype, desc[i].wanaddr) == 0 + && !addr_is_reserved(desc[i].wanaddr)) goto free_and_return; } FreeUPNPUrls(urls); @@ -661,8 +642,12 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, } state = 0; free_and_return: - if (lanaddr != NULL && state >= 1 && state <= 3 && i < ndev) - strncpy(lanaddr, desc[i].lanaddr, lanaddrlen); + if (state >= 1 && state <= 4 && i < ndev) { + if (lanaddr != NULL) + strncpy(lanaddr, desc[i].lanaddr, lanaddrlen); + if (wanaddr != NULL) + strncpy(wanaddr, desc[i].wanaddr, wanaddrlen); + } for(i = 0; i < ndev; i++) free(desc[i].xml); free(desc); diff --git a/thirdparty/miniupnpc/src/miniupnpcstrings.h b/thirdparty/miniupnpc/src/miniupnpcstrings.h index f5730111af5..d40c2455ba8 100644 --- a/thirdparty/miniupnpc/src/miniupnpcstrings.h +++ b/thirdparty/miniupnpc/src/miniupnpcstrings.h @@ -2,7 +2,7 @@ #define MINIUPNPCSTRINGS_H_INCLUDED #define OS_STRING "Godot Engine/1.0" -#define MINIUPNPC_VERSION_STRING "2.2.7" +#define MINIUPNPC_VERSION_STRING "2.2.8" #if 0 /* according to "UPnP Device Architecture 1.0" */ diff --git a/thirdparty/miniupnpc/src/miniwget.c b/thirdparty/miniupnpc/src/miniwget.c index e76a5e516b4..a7a32dfdbaf 100644 --- a/thirdparty/miniupnpc/src/miniwget.c +++ b/thirdparty/miniupnpc/src/miniwget.c @@ -2,7 +2,7 @@ /* Project : miniupnp * Website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ * Author : Thomas Bernard - * Copyright (c) 2005-2023 Thomas Bernard + * Copyright (c) 2005-2024 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -443,9 +443,8 @@ miniwget3(const char * host, len = snprintf(buf, sizeof(buf), "GET %s HTTP/%s\r\n" "Host: %s:%d\r\n" - "Connection: Close\r\n" + "Connection: close\r\n" "User-Agent: " OS_STRING " " UPNP_VERSION_STRING " MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" - "\r\n", path, httpversion, host, port); if ((unsigned int)len >= sizeof(buf)) @@ -474,41 +473,6 @@ miniwget3(const char * host, return content; } -/* miniwget2() : - * Call miniwget3(); retry with HTTP/1.1 if 1.0 fails. */ -static void * -miniwget2(const char * host, - unsigned short port, const char * path, - int * size, char * addr_str, int addr_str_len, - unsigned int scope_id, int * status_code) -{ - char * respbuffer; - -#if 1 - respbuffer = miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.1", - scope_id, status_code); -#else - respbuffer = miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.0", - scope_id, status_code); - if (*size == 0) - { -#ifdef DEBUG - printf("Retrying with HTTP/1.1\n"); -#endif - free(respbuffer); - respbuffer = miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.1", - scope_id, status_code); - } -#endif - return respbuffer; -} - - - - /* parseURL() * arguments : * url : source string not modified @@ -639,7 +603,7 @@ miniwget(const char * url, int * size, printf("parsed url : hostname='%s' port=%hu path='%s' scope_id=%u\n", hostname, port, path, scope_id); #endif - return miniwget2(hostname, port, path, size, 0, 0, scope_id, status_code); + return miniwget3(hostname, port, path, size, 0, 0, "1.1", scope_id, status_code); } void * @@ -660,5 +624,5 @@ miniwget_getaddr(const char * url, int * size, printf("parsed url : hostname='%s' port=%hu path='%s' scope_id=%u\n", hostname, port, path, scope_id); #endif - return miniwget2(hostname, port, path, size, addr, addrlen, scope_id, status_code); + return miniwget3(hostname, port, path, size, addr, addrlen, "1.1", scope_id, status_code); } diff --git a/thirdparty/miniupnpc/src/win32_snprintf.h b/thirdparty/miniupnpc/src/win32_snprintf.h index 1fc284ecffc..5064df63bcb 100644 --- a/thirdparty/miniupnpc/src/win32_snprintf.h +++ b/thirdparty/miniupnpc/src/win32_snprintf.h @@ -23,9 +23,9 @@ (defined(_MSC_VER) && _MSC_VER < 1900) /* Visual Studio older than 2015 */ || \ (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) && defined(__NO_ISOCEXT)) /* mingw32 without iso c ext */ || \ (defined(__MINGW64_VERSION_MAJOR) && /* mingw-w64 not ... */ !( \ - (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0)) /* ... with ansi stdio */ || \ + (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) /* ... with ansi stdio */ || \ (__MINGW64_VERSION_MAJOR >= 6 && defined(_UCRT)) /* ... at least 6.0.0 with ucrt */ || \ - (__MINGW64_VERSION_MAJOR >= 8 && !defined(__NO_ISOCEXT)) /* ... at least 8.0.0 with iso c ext */ || \ + (__MINGW64_VERSION_MAJOR >= 8 && !defined(__NO_ISOCEXT))) /* ... at least 8.0.0 with iso c ext */ || \ 0) || \ 0)