From 0450e6539ea77f8c56b244aef27ec45c69e1dcdb Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 23 Mar 2017 13:27:41 +0100 Subject: [PATCH] ENet code cleanup and changes from review. --- modules/enet/networked_multiplayer_enet.cpp | 7 ----- thirdparty/README.md | 4 ++- thirdparty/enet/enet/godot.h | 29 ++++++++++++++++++++ thirdparty/enet/godot.cpp | 30 ++++++++++++++++++++- 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 9e6a171d7fc..13760b33aae 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -163,13 +163,6 @@ void NetworkedMultiplayerENet::poll() { break; } - IP_Address ip; -#ifdef GODOT_ENET - ip.set_ipv6((uint8_t *)&(event.peer->address.host)); -#else - ip.set_ipv4((uint8_t *)&(event.peer->address.host)); -#endif - int *new_id = memnew(int); *new_id = event.data; diff --git a/thirdparty/README.md b/thirdparty/README.md index 1959be5f068..f35a95df370 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -22,8 +22,10 @@ Files extracted from upstream source: Important: enet.h, host.c, protocol.c have been slightly modified to be usable by godot socket implementation and allow IPv6. -Two files (godot.cpp and enet/godot.h) has been added to provide +Two files (godot.cpp and enet/godot.h) have been added to provide enet socket implementation using Godot classes. +It is still possible to build against a system wide ENet but doing so +will limit it's functionality to IPv4 only. Check the diff of enet.h, protocol.c, and host.c with the 1.3.13 tarball before the next update. diff --git a/thirdparty/enet/enet/godot.h b/thirdparty/enet/enet/godot.h index a0a5f82e2d3..8f543966b58 100644 --- a/thirdparty/enet/enet/godot.h +++ b/thirdparty/enet/enet/godot.h @@ -1,7 +1,36 @@ +/*************************************************************************/ +/* godot.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ /** @file godot.h @brief ENet Godot header */ + #ifndef __ENET_GODOT_H__ #define __ENET_GODOT_H__ diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index 18ccc02c50e..e26340092df 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -1,5 +1,33 @@ +/*************************************************************************/ +/* godot.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ /** - @file godot.c + @file godot.cpp @brief ENet Godot specific functions */