godot_socket.patch 3.5 KB

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