0001-godot-socket.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
  2. index 3001018763..ccd8382c23 100644
  3. --- a/thirdparty/enet/enet/enet.h
  4. +++ b/thirdparty/enet/enet/enet.h
  5. @@ -10,13 +10,17 @@ extern "C"
  6. {
  7. #endif
  8. +#include <stdint.h>
  9. #include <stdlib.h>
  10. +#if 0
  11. #ifdef _WIN32
  12. #include "enet/win32.h"
  13. #else
  14. #include "enet/unix.h"
  15. #endif
  16. +#endif
  17. +#include "enet/enet_godot.h"
  18. #include "enet/types.h"
  19. #include "enet/protocol.h"
  20. @@ -87,11 +91,13 @@ typedef enum _ENetSocketShutdown
  21. * but not for enet_host_create. Once a server responds to a broadcast, the
  22. * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
  23. */
  24. +#if 0
  25. typedef struct _ENetAddress
  26. {
  27. enet_uint32 host;
  28. enet_uint16 port;
  29. } ENetAddress;
  30. +#endif
  31. /**
  32. * Packet flag bit constants.
  33. @@ -608,6 +614,8 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,
  34. extern size_t enet_protocol_command_size (enet_uint8);
  35. +#include "enet/enet_godot_ext.h"
  36. +
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c
  41. index fff946a392..adb3533cf1 100644
  42. --- a/thirdparty/enet/host.c
  43. +++ b/thirdparty/enet/host.c
  44. @@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
  45. host -> commandCount = 0;
  46. host -> bufferCount = 0;
  47. host -> checksum = NULL;
  48. - host -> receivedAddress.host = ENET_HOST_ANY;
  49. + memset(host -> receivedAddress.host, 0, 16);
  50. host -> receivedAddress.port = 0;
  51. host -> receivedData = NULL;
  52. host -> receivedDataLength = 0;
  53. diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
  54. index 843a719af3..5f18700599 100644
  55. --- a/thirdparty/enet/protocol.c
  56. +++ b/thirdparty/enet/protocol.c
  57. @@ -318,7 +318,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
  58. }
  59. else
  60. if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
  61. - currentPeer -> address.host == host -> receivedAddress.host)
  62. + enet_host_equal(currentPeer -> address.host, host -> receivedAddress.host))
  63. {
  64. if (currentPeer -> address.port == host -> receivedAddress.port &&
  65. currentPeer -> connectID == command -> connect.connectID)
  66. @@ -1043,9 +1043,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
  67. if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
  68. peer -> state == ENET_PEER_STATE_ZOMBIE ||
  69. - ((host -> receivedAddress.host != peer -> address.host ||
  70. - host -> receivedAddress.port != peer -> address.port) &&
  71. - peer -> address.host != ENET_HOST_BROADCAST) ||
  72. + (!enet_host_equal(host -> receivedAddress.host, peer -> address.host) ||
  73. + host -> receivedAddress.port != peer -> address.port) ||
  74. (peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&
  75. sessionID != peer -> incomingSessionID))
  76. return 0;
  77. @@ -1090,7 +1089,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
  78. if (peer != NULL)
  79. {
  80. - peer -> address.host = host -> receivedAddress.host;
  81. + enet_address_set_ip(&(peer -> address), host -> receivedAddress.host, 16);
  82. peer -> address.port = host -> receivedAddress.port;
  83. peer -> incomingDataTotal += host -> receivedDataLength;
  84. }