summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/http_client_javascript.cpp39
-rw-r--r--platform/osx/SCsub7
-rw-r--r--platform/osx/detect.py13
-rw-r--r--platform/osx/os_osx.h4
-rw-r--r--platform/osx/os_osx.mm8
-rw-r--r--platform/uwp/SCsub3
-rw-r--r--platform/uwp/os_uwp.cpp8
-rw-r--r--platform/windows/SCsub3
-rw-r--r--platform/windows/context_gl_win.cpp2
-rw-r--r--platform/windows/detect.py7
-rw-r--r--platform/windows/os_windows.cpp16
-rw-r--r--platform/windows/os_windows.h4
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp293
-rw-r--r--platform/windows/packet_peer_udp_winsock.h84
-rw-r--r--platform/windows/stream_peer_winsock.cpp371
-rw-r--r--platform/windows/stream_peer_winsock.h91
-rw-r--r--platform/windows/tcp_server_winsock.cpp183
-rw-r--r--platform/windows/tcp_server_winsock.h56
-rw-r--r--platform/x11/detect.py6
-rw-r--r--platform/x11/os_x11.cpp9
-rw-r--r--platform/x11/os_x11.h3
21 files changed, 91 insertions, 1119 deletions
diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp
index 0b105dcb40..b170ba6f35 100644
--- a/platform/javascript/http_client_javascript.cpp
+++ b/platform/javascript/http_client_javascript.cpp
@@ -37,16 +37,31 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
WARN_PRINT("Disabling HTTPClient's host verification is not supported for the HTML5 platform, host will be verified");
}
+ port = p_port;
+ use_tls = p_ssl;
+
host = p_host;
- if (host.begins_with("http://")) {
- host.replace_first("http://", "");
- } else if (host.begins_with("https://")) {
- host.replace_first("https://", "");
+
+ String host_lower = host.to_lower();
+ if (host_lower.begins_with("http://")) {
+ host = host.substr(7, host.length() - 7);
+ } else if (host_lower.begins_with("https://")) {
+ use_tls = true;
+ host = host.substr(8, host.length() - 8);
+ }
+
+ ERR_FAIL_COND_V(host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER);
+
+ if (port < 0) {
+ if (use_tls) {
+ port = PORT_HTTPS;
+ } else {
+ port = PORT_HTTP;
+ }
}
status = host.is_valid_ip_address() ? STATUS_CONNECTING : STATUS_RESOLVING;
- port = p_port;
- use_tls = p_ssl;
+
return OK;
}
@@ -68,17 +83,7 @@ Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Ve
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(host.empty(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(port < 0, ERR_UNCONFIGURED);
-
- static const char *_methods[HTTPClient::METHOD_MAX] = {
- "GET",
- "HEAD",
- "POST",
- "PUT",
- "DELETE",
- "OPTIONS",
- "TRACE",
- "CONNECT"
- };
+ ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER);
String url = (use_tls ? "https://" : "http://") + host + ":" + itos(port) + "/" + p_url;
godot_xhr_reset(xhr_id);
diff --git a/platform/osx/SCsub b/platform/osx/SCsub
index cb88bc470a..029e3d808c 100644
--- a/platform/osx/SCsub
+++ b/platform/osx/SCsub
@@ -4,7 +4,12 @@ import os
Import('env')
def make_debug(target, source, env):
- os.system('dsymutil %s -o %s.dSYM' % (target[0], target[0]))
+ if (env["macports_clang"] != 'no'):
+ mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
+ mpclangver = env["macports_clang"]
+ os.system(mpprefix + '/libexec/llvm-' + mpclangver + '/bin/llvm-dsymutil %s -o %s.dSYM' % (target[0], target[0]))
+ else:
+ os.system('dsymutil %s -o %s.dSYM' % (target[0], target[0]))
files = [
'crash_handler_osx.mm',
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index ff7cf2ad2f..e8a8319431 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -72,6 +72,19 @@ def configure(env):
else: # 64-bit, default
env.Append(CCFLAGS=['-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'x86_64'])
+ if (env["macports_clang"] != 'no'):
+ mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
+ mpclangver = env["macports_clang"]
+ env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang"
+ env["LD"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++"
+ env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++"
+ env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar"
+ env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
+ env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as"
+ env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define
+ if (env["openmp"]):
+ env.Append(CPPFLAGS=['-fopenmp'])
+ env.Append(LINKFLAGS=['-fopenmp'])
else: # osxcross build
root = os.environ.get("OSXCROSS_ROOT", 0)
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 6543ca7dd2..ede50a05ba 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -204,7 +204,7 @@ public:
virtual void request_attention();
virtual String get_joy_guid(int p_device) const;
- virtual void set_borderless_window(int p_borderless);
+ virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window();
virtual void set_ime_position(const Point2 &p_pos);
virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp);
@@ -228,6 +228,8 @@ public:
virtual Error move_to_trash(const String &p_path);
+ void force_process_input();
+
OS_OSX();
private:
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 75d0bd1648..f3809e6eed 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1818,7 +1818,7 @@ void OS_OSX::request_attention() {
[NSApp requestUserAttention:NSCriticalRequest];
}
-void OS_OSX::set_borderless_window(int p_borderless) {
+void OS_OSX::set_borderless_window(bool p_borderless) {
// OrderOut prevents a lose focus bug with the window
[window_object orderOut:nil];
@@ -1971,6 +1971,12 @@ void OS_OSX::push_input(const Ref<InputEvent> &p_event) {
input->parse_input_event(ev);
}
+void OS_OSX::force_process_input() {
+
+ process_events(); // get rid of pending events
+ joypad_osx->process_joypads();
+}
+
void OS_OSX::run() {
force_quit = false;
diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub
index f0d69fef33..fb0c4a92ae 100644
--- a/platform/uwp/SCsub
+++ b/platform/uwp/SCsub
@@ -4,9 +4,6 @@ Import('env')
files = [
'thread_uwp.cpp',
- '#platform/windows/tcp_server_winsock.cpp',
- '#platform/windows/packet_peer_udp_winsock.cpp',
- '#platform/windows/stream_peer_winsock.cpp',
'#platform/windows/key_mapping_win.cpp',
'#platform/windows/windows_terminal_logger.cpp',
'joypad_uwp.cpp',
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 659f162724..3018ac0bef 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -34,13 +34,13 @@
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/mutex_windows.h"
+#include "drivers/windows/packet_peer_udp_winsock.h"
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
+#include "drivers/windows/stream_peer_tcp_winsock.h"
+#include "drivers/windows/tcp_server_winsock.h"
#include "io/marshalls.h"
#include "main/main.h"
-#include "platform/windows/packet_peer_udp_winsock.h"
-#include "platform/windows/stream_peer_winsock.h"
-#include "platform/windows/tcp_server_winsock.h"
#include "platform/windows/windows_terminal_logger.h"
#include "project_settings.h"
#include "servers/audio_server.h"
@@ -163,7 +163,7 @@ void OSUWP::initialize_core() {
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM);
TCPServerWinsock::make_default();
- StreamPeerWinsock::make_default();
+ StreamPeerTCPWinsock::make_default();
PacketPeerUDPWinsock::make_default();
// We need to know how often the clock is updated
diff --git a/platform/windows/SCsub b/platform/windows/SCsub
index 135ccd902a..5030f4b3e0 100644
--- a/platform/windows/SCsub
+++ b/platform/windows/SCsub
@@ -19,9 +19,6 @@ common_win = [
"os_windows.cpp",
"ctxgl_procaddr.cpp",
"key_mapping_win.cpp",
- "tcp_server_winsock.cpp",
- "packet_peer_udp_winsock.cpp",
- "stream_peer_winsock.cpp",
"joypad.cpp",
"power_windows.cpp",
"windows_terminal_logger.cpp"
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index 81aa18dd23..ccb0a41d13 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -181,8 +181,6 @@ Error ContextGL_Win::initialize() {
MessageBox(NULL, "Can't Activate The GL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return FALSE
}
-
- printf("Activated GL 3.3 context");
}
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index d85e1b061c..01eb50e69c 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -188,6 +188,9 @@ def configure(env):
else:
VC_PATH = ""
+ if (env["openmp"]):
+ env.Append(CPPFLAGS=['/openmp'])
+
env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")])
env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")])
@@ -264,6 +267,10 @@ def configure(env):
env.Append(CCFLAGS=['-flto'])
env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
+ if (env["openmp"]):
+ env.Append(CPPFLAGS=['-fopenmp'])
+ env.Append(LINKFLAGS=['-fopenmp'])
+
## Compile flags
env.Append(CCFLAGS=['-DWINDOWS_ENABLED', '-mwindows'])
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 41730d33af..6cab683e83 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -34,19 +34,19 @@
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/mutex_windows.h"
+#include "drivers/windows/packet_peer_udp_winsock.h"
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
+#include "drivers/windows/stream_peer_tcp_winsock.h"
+#include "drivers/windows/tcp_server_winsock.h"
#include "drivers/windows/thread_windows.h"
#include "io/marshalls.h"
#include "joypad.h"
#include "lang_table.h"
#include "main/main.h"
-#include "packet_peer_udp_winsock.h"
#include "servers/audio_server.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
-#include "stream_peer_winsock.h"
-#include "tcp_server_winsock.h"
#include "version_generated.gen.h"
#include "windows_terminal_logger.h"
@@ -196,7 +196,7 @@ void OS_Windows::initialize_core() {
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM);
TCPServerWinsock::make_default();
- StreamPeerWinsock::make_default();
+ StreamPeerTCPWinsock::make_default();
PacketPeerUDPWinsock::make_default();
// We need to know how often the clock is updated
@@ -1253,7 +1253,7 @@ void OS_Windows::finalize_core() {
memdelete(process_map);
TCPServerWinsock::cleanup();
- StreamPeerWinsock::cleanup();
+ StreamPeerTCPWinsock::cleanup();
}
void OS_Windows::alert(const String &p_alert, const String &p_title) {
@@ -1598,7 +1598,7 @@ bool OS_Windows::is_window_maximized() const {
return maximized;
}
-void OS_Windows::set_borderless_window(int p_borderless) {
+void OS_Windows::set_borderless_window(bool p_borderless) {
if (video_mode.borderless_window == p_borderless)
return;
@@ -2156,6 +2156,10 @@ void OS_Windows::swap_buffers() {
gl_context->swap_buffers();
}
+void OS_Windows::force_process_input() {
+ process_events(); // get rid of pending events
+}
+
void OS_Windows::run() {
if (!main_loop)
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index af1ccd4446..f2226a53a9 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -210,7 +210,7 @@ public:
virtual bool is_window_maximized() const;
virtual void request_attention();
- virtual void set_borderless_window(int p_borderless);
+ virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window();
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
@@ -287,6 +287,8 @@ public:
void disable_crash_handler();
bool is_disable_crash_handler() const;
+ void force_process_input();
+
virtual Error move_to_trash(const String &p_path);
OS_Windows(HINSTANCE _hInstance);
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
deleted file mode 100644
index d414ec891e..0000000000
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/*************************************************************************/
-/* packet_peer_udp_winsock.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#include "packet_peer_udp_winsock.h"
-
-#include <winsock2.h>
-#include <ws2tcpip.h>
-
-#include "drivers/unix/socket_helpers.h"
-
-int PacketPeerUDPWinsock::get_available_packet_count() const {
-
- Error err = const_cast<PacketPeerUDPWinsock *>(this)->_poll(false);
- if (err != OK)
- return 0;
-
- return queue_count;
-}
-
-Error PacketPeerUDPWinsock::get_packet(const uint8_t **r_buffer, int &r_buffer_size) const {
-
- Error err = const_cast<PacketPeerUDPWinsock *>(this)->_poll(false);
- if (err != OK)
- return err;
- if (queue_count == 0)
- return ERR_UNAVAILABLE;
-
- uint32_t size;
- uint8_t type;
- rb.read(&type, 1, true);
- if (type == IP::TYPE_IPV4) {
- uint8_t ip[4];
- rb.read(ip, 4, true);
- packet_ip.set_ipv4(ip);
- } else {
- uint8_t ip[16];
- rb.read(ip, 16, true);
- packet_ip.set_ipv6(ip);
- };
- rb.read((uint8_t *)&packet_port, 4, true);
- rb.read((uint8_t *)&size, 4, true);
- rb.read(packet_buffer, size, true);
- --queue_count;
- *r_buffer = packet_buffer;
- r_buffer_size = size;
- return OK;
-}
-Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
- ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED);
-
- if (sock_type == IP::TYPE_NONE)
- sock_type = peer_addr.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
-
- int sock = _get_socket();
- ERR_FAIL_COND_V(sock == -1, FAILED);
- struct sockaddr_storage addr;
- size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, sock_type);
-
- _set_sock_blocking(blocking);
-
- errno = 0;
- int err;
- while ((err = sendto(sock, (const char *)p_buffer, p_buffer_size, 0, (struct sockaddr *)&addr, addr_size)) != p_buffer_size) {
-
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- return FAILED;
- } else if (!blocking) {
- return ERR_UNAVAILABLE;
- }
- }
-
- return OK;
-}
-
-int PacketPeerUDPWinsock::get_max_packet_size() const {
-
- return 512; // uhm maybe not
-}
-
-void PacketPeerUDPWinsock::_set_sock_blocking(bool p_blocking) {
-
- if (sock_blocking == p_blocking)
- return;
-
- sock_blocking = p_blocking;
- unsigned long par = sock_blocking ? 0 : 1;
- if (ioctlsocket(sockfd, FIONBIO, &par)) {
- perror("setting non-block mode");
- //close();
- //return -1;
- };
-}
-
-Error PacketPeerUDPWinsock::listen(int p_port, const IP_Address &p_bind_address, int p_recv_buffer_size) {
-
- ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
- ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
-
- sock_type = IP::TYPE_ANY;
-
- if (p_bind_address.is_valid())
- sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
-
- int sock = _get_socket();
- if (sock == -1)
- return ERR_CANT_CREATE;
-
- struct sockaddr_storage addr = { 0 };
- size_t addr_size = _set_listen_sockaddr(&addr, p_port, sock_type, IP_Address());
-
- if (bind(sock, (struct sockaddr *)&addr, addr_size) == -1) {
- close();
- return ERR_UNAVAILABLE;
- }
-
- printf("UDP Connection listening on port %i\n", p_port);
- rb.resize(nearest_shift(p_recv_buffer_size));
- return OK;
-}
-
-void PacketPeerUDPWinsock::close() {
-
- if (sockfd != -1)
- ::closesocket(sockfd);
- sockfd = -1;
- sock_type = IP::TYPE_NONE;
- rb.resize(16);
- queue_count = 0;
-}
-
-Error PacketPeerUDPWinsock::wait() {
-
- return _poll(true);
-}
-Error PacketPeerUDPWinsock::_poll(bool p_wait) {
-
- if (sockfd == -1) {
- return FAILED;
- }
-
- _set_sock_blocking(p_wait);
-
- struct sockaddr_storage from = { 0 };
- int len = sizeof(struct sockaddr_storage);
- int ret;
- while ((ret = recvfrom(sockfd, (char *)recv_buffer, MIN((int)sizeof(recv_buffer), MAX(rb.space_left() - 24, 0)), 0, (struct sockaddr *)&from, &len)) > 0) {
-
- uint32_t port = 0;
-
- if (from.ss_family == AF_INET) {
- uint8_t type = (uint8_t)IP::TYPE_IPV4;
- rb.write(&type, 1);
- struct sockaddr_in *sin_from = (struct sockaddr_in *)&from;
- rb.write((uint8_t *)&sin_from->sin_addr, 4);
- port = ntohs(sin_from->sin_port);
-
- } else if (from.ss_family == AF_INET6) {
-
- uint8_t type = (uint8_t)IP::TYPE_IPV6;
- rb.write(&type, 1);
-
- struct sockaddr_in6 *s6_from = (struct sockaddr_in6 *)&from;
- rb.write((uint8_t *)&s6_from->sin6_addr, 16);
-
- port = ntohs(s6_from->sin6_port);
-
- } else {
- // WARN_PRINT("Ignoring packet with unknown address family");
- uint8_t type = (uint8_t)IP::TYPE_NONE;
- rb.write(&type, 1);
- };
-
- rb.write((uint8_t *)&port, 4);
- rb.write((uint8_t *)&ret, 4);
- rb.write(recv_buffer, ret);
-
- len = sizeof(struct sockaddr_storage);
- ++queue_count;
- if (p_wait)
- break;
- };
-
- if (ret == SOCKET_ERROR) {
- int error = WSAGetLastError();
-
- if (error == WSAEWOULDBLOCK) {
- // Expected when doing non-blocking sockets, retry later.
- } else if (error == WSAECONNRESET) {
- // If the remote target does not accept messages, this error may occur, but is harmless.
- // Once the remote target gets available, this message will disappear for new messages.
- } else {
- close();
- return FAILED;
- }
- }
-
- if (ret == 0) {
- close();
- return FAILED;
- };
-
- return OK;
-}
-
-bool PacketPeerUDPWinsock::is_listening() const {
-
- return sockfd != -1;
-}
-
-IP_Address PacketPeerUDPWinsock::get_packet_address() const {
-
- return packet_ip;
-}
-
-int PacketPeerUDPWinsock::get_packet_port() const {
-
- return packet_port;
-}
-
-int PacketPeerUDPWinsock::_get_socket() {
-
- ERR_FAIL_COND_V(sock_type == IP::TYPE_NONE, -1);
-
- if (sockfd != -1)
- return sockfd;
-
- sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP);
-
- if (sockfd != -1)
- _set_sock_blocking(false);
-
- return sockfd;
-}
-
-void PacketPeerUDPWinsock::set_dest_address(const IP_Address &p_address, int p_port) {
-
- peer_addr = p_address;
- peer_port = p_port;
-}
-
-void PacketPeerUDPWinsock::make_default() {
-
- PacketPeerUDP::_create = PacketPeerUDPWinsock::_create;
-};
-
-PacketPeerUDP *PacketPeerUDPWinsock::_create() {
-
- return memnew(PacketPeerUDPWinsock);
-};
-
-PacketPeerUDPWinsock::PacketPeerUDPWinsock() {
-
- blocking = true;
- sock_blocking = true;
- sockfd = -1;
- packet_port = 0;
- queue_count = 0;
- peer_port = 0;
- sock_type = IP::TYPE_NONE;
- rb.resize(16);
-}
-
-PacketPeerUDPWinsock::~PacketPeerUDPWinsock() {
-
- close();
-}
diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h
deleted file mode 100644
index 8a6951fd6e..0000000000
--- a/platform/windows/packet_peer_udp_winsock.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*************************************************************************/
-/* packet_peer_udp_winsock.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#ifndef PACKET_PEER_UDP_WINSOCK_H
-#define PACKET_PEER_UDP_WINSOCK_H
-
-#include "io/packet_peer_udp.h"
-#include "ring_buffer.h"
-
-class PacketPeerUDPWinsock : public PacketPeerUDP {
-
- enum {
- PACKET_BUFFER_SIZE = 65536
- };
-
- mutable RingBuffer<uint8_t> rb;
- uint8_t recv_buffer[PACKET_BUFFER_SIZE];
- mutable uint8_t packet_buffer[PACKET_BUFFER_SIZE];
- mutable IP_Address packet_ip;
- mutable int packet_port;
- mutable int queue_count;
- int sockfd;
- bool sock_blocking;
- IP::Type sock_type;
-
- IP_Address peer_addr;
- int peer_port;
-
- _FORCE_INLINE_ int _get_socket();
-
- static PacketPeerUDP *_create();
-
- void _set_sock_blocking(bool p_blocking);
-
- Error _poll(bool p_wait);
-
-public:
- virtual int get_available_packet_count() const;
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) const;
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
-
- virtual int get_max_packet_size() const;
-
- virtual Error listen(int p_port, const IP_Address &p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536);
- virtual void close();
- virtual Error wait();
- virtual bool is_listening() const;
-
- virtual IP_Address get_packet_address() const;
- virtual int get_packet_port() const;
-
- virtual void set_dest_address(const IP_Address &p_address, int p_port);
-
- static void make_default();
- PacketPeerUDPWinsock();
- ~PacketPeerUDPWinsock();
-};
-#endif // PACKET_PEER_UDP_WINSOCK_H
diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp
deleted file mode 100644
index 8b83215325..0000000000
--- a/platform/windows/stream_peer_winsock.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/*************************************************************************/
-/* stream_peer_winsock.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#ifdef WINDOWS_ENABLED
-
-#include "stream_peer_winsock.h"
-
-#include <winsock2.h>
-#include <ws2tcpip.h>
-
-#include "drivers/unix/socket_helpers.h"
-
-int winsock_refcount = 0;
-
-StreamPeerTCP *StreamPeerWinsock::_create() {
-
- return memnew(StreamPeerWinsock);
-};
-
-void StreamPeerWinsock::make_default() {
-
- StreamPeerTCP::_create = StreamPeerWinsock::_create;
-
- if (winsock_refcount == 0) {
- WSADATA data;
- WSAStartup(MAKEWORD(2, 2), &data);
- };
- ++winsock_refcount;
-};
-
-void StreamPeerWinsock::cleanup() {
-
- --winsock_refcount;
- if (winsock_refcount == 0) {
-
- WSACleanup();
- };
-};
-
-Error StreamPeerWinsock::_block(int p_sockfd, bool p_read, bool p_write) const {
-
- fd_set read, write;
- FD_ZERO(&read);
- FD_ZERO(&write);
-
- if (p_read)
- FD_SET(p_sockfd, &read);
- if (p_write)
- FD_SET(p_sockfd, &write);
-
- int ret = select(p_sockfd + 1, &read, &write, NULL, NULL); // block forever
- return ret < 0 ? FAILED : OK;
-};
-
-Error StreamPeerWinsock::_poll_connection() const {
-
- ERR_FAIL_COND_V(status != STATUS_CONNECTING || sockfd == INVALID_SOCKET, FAILED);
-
- struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, sock_type);
-
- if (::connect(sockfd, (struct sockaddr *)&their_addr, addr_size) == SOCKET_ERROR) {
-
- int err = WSAGetLastError();
- if (err == WSAEISCONN) {
- status = STATUS_CONNECTED;
- return OK;
- };
-
- if (err == WSAEINPROGRESS || err == WSAEALREADY) {
- return OK;
- }
-
- status = STATUS_ERROR;
- return ERR_CONNECTION_ERROR;
- } else {
-
- status = STATUS_CONNECTED;
- return OK;
- };
-
- return OK;
-};
-
-Error StreamPeerWinsock::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool p_block) {
-
- if (status == STATUS_NONE || status == STATUS_ERROR) {
-
- return FAILED;
- };
-
- if (status != STATUS_CONNECTED) {
-
- if (_poll_connection() != OK) {
-
- return FAILED;
- };
-
- if (status != STATUS_CONNECTED) {
- r_sent = 0;
- return OK;
- };
- };
-
- int data_to_send = p_bytes;
- const uint8_t *offset = p_data;
- if (sockfd == -1) return FAILED;
- int total_sent = 0;
-
- while (data_to_send) {
-
- int sent_amount = send(sockfd, (const char *)offset, data_to_send, 0);
-
- if (sent_amount == -1) {
-
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
-
- perror("Nothing sent");
- disconnect_from_host();
- ERR_PRINT("Server disconnected!\n");
- return FAILED;
- };
-
- if (!p_block) {
- r_sent = total_sent;
- return OK;
- };
-
- _block(sockfd, false, true);
- } else {
-
- data_to_send -= sent_amount;
- offset += sent_amount;
- total_sent += sent_amount;
- };
- }
-
- r_sent = total_sent;
-
- return OK;
-};
-
-Error StreamPeerWinsock::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool p_block) {
-
- if (!is_connected_to_host()) {
-
- return FAILED;
- };
-
- if (status != STATUS_CONNECTED) {
-
- if (_poll_connection() != OK) {
-
- return FAILED;
- };
-
- if (status != STATUS_CONNECTED) {
- r_received = 0;
- return OK;
- };
- };
-
- int to_read = p_bytes;
- int total_read = 0;
-
- while (to_read) {
-
- int read = recv(sockfd, (char *)p_buffer + total_read, to_read, 0);
-
- if (read == -1) {
-
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
-
- perror("Nothing read");
- disconnect_from_host();
- ERR_PRINT("Server disconnected!\n");
- return FAILED;
- };
-
- if (!p_block) {
-
- r_received = total_read;
- return OK;
- };
- _block(sockfd, true, false);
- } else if (read == 0) {
- disconnect_from_host();
- return ERR_FILE_EOF;
- } else {
-
- to_read -= read;
- total_read += read;
- };
- };
-
- r_received = total_read;
-
- return OK;
-};
-
-Error StreamPeerWinsock::put_data(const uint8_t *p_data, int p_bytes) {
-
- int total;
- return write(p_data, p_bytes, total, true);
-};
-
-Error StreamPeerWinsock::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
- return write(p_data, p_bytes, r_sent, false);
-};
-
-Error StreamPeerWinsock::get_data(uint8_t *p_buffer, int p_bytes) {
-
- int total;
- return read(p_buffer, p_bytes, total, true);
-};
-
-Error StreamPeerWinsock::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
- return read(p_buffer, p_bytes, r_received, false);
-};
-
-StreamPeerTCP::Status StreamPeerWinsock::get_status() const {
-
- if (status == STATUS_CONNECTING) {
- _poll_connection();
- };
-
- return status;
-};
-
-bool StreamPeerWinsock::is_connected_to_host() const {
-
- if (status == STATUS_NONE || status == STATUS_ERROR) {
-
- return false;
- };
- if (status != STATUS_CONNECTED) {
- return true;
- };
-
- return (sockfd != INVALID_SOCKET);
-};
-
-void StreamPeerWinsock::disconnect_from_host() {
-
- if (sockfd != INVALID_SOCKET)
- closesocket(sockfd);
- sockfd = INVALID_SOCKET;
- sock_type = IP::TYPE_NONE;
-
- status = STATUS_NONE;
-
- peer_host = IP_Address();
- peer_port = 0;
-};
-
-void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type) {
-
- sockfd = p_sockfd;
- sock_type = p_sock_type;
- status = STATUS_CONNECTING;
- peer_host = p_host;
- peer_port = p_port;
-};
-
-Error StreamPeerWinsock::connect_to_host(const IP_Address &p_host, uint16_t p_port) {
-
- ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
-
- sock_type = p_host.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
- sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
- if (sockfd == INVALID_SOCKET) {
- ERR_PRINT("Socket creation failed!");
- disconnect_from_host();
- //perror("socket");
- return FAILED;
- };
-
- unsigned long par = 1;
- if (ioctlsocket(sockfd, FIONBIO, &par)) {
- perror("setting non-block mode");
- disconnect_from_host();
- return FAILED;
- };
-
- struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, sock_type);
-
- if (::connect(sockfd, (struct sockaddr *)&their_addr, addr_size) == SOCKET_ERROR) {
-
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
- ERR_PRINT("Connection to remote host failed!");
- disconnect_from_host();
- return FAILED;
- };
- status = STATUS_CONNECTING;
- } else {
- status = STATUS_CONNECTED;
- };
-
- peer_host = p_host;
- peer_port = p_port;
-
- return OK;
-};
-
-void StreamPeerWinsock::set_nodelay(bool p_enabled) {
- ERR_FAIL_COND(!is_connected_to_host());
- int flag = p_enabled ? 1 : 0;
- setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
-}
-
-int StreamPeerWinsock::get_available_bytes() const {
-
- unsigned long len;
- int ret = ioctlsocket(sockfd, FIONREAD, &len);
- ERR_FAIL_COND_V(ret == -1, 0)
- return len;
-}
-
-IP_Address StreamPeerWinsock::get_connected_host() const {
-
- return peer_host;
-};
-
-uint16_t StreamPeerWinsock::get_connected_port() const {
-
- return peer_port;
-};
-
-StreamPeerWinsock::StreamPeerWinsock() {
-
- sock_type = IP::TYPE_NONE;
- sockfd = INVALID_SOCKET;
- status = STATUS_NONE;
- peer_port = 0;
-};
-
-StreamPeerWinsock::~StreamPeerWinsock() {
-
- disconnect_from_host();
-};
-
-#endif
diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h
deleted file mode 100644
index 26e2a3e4c9..0000000000
--- a/platform/windows/stream_peer_winsock.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************************/
-/* stream_peer_winsock.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#ifdef WINDOWS_ENABLED
-
-#ifndef STREAM_PEER_WINSOCK_H
-#define STREAM_PEER_WINSOCK_H
-
-#include "error_list.h"
-
-#include "core/io/ip_address.h"
-#include "core/io/stream_peer_tcp.h"
-
-class StreamPeerWinsock : public StreamPeerTCP {
-
-protected:
- mutable Status status;
- IP::Type sock_type;
-
- int sockfd;
-
- Error _block(int p_sockfd, bool p_read, bool p_write) const;
-
- Error _poll_connection() const;
-
- IP_Address peer_host;
- int peer_port;
-
- Error write(const uint8_t *p_data, int p_bytes, int &r_sent, bool p_block);
- Error read(uint8_t *p_buffer, int p_bytes, int &r_received, bool p_block);
-
- static StreamPeerTCP *_create();
-
-public:
- virtual Error connect_to_host(const IP_Address &p_host, uint16_t p_port);
-
- virtual Error put_data(const uint8_t *p_data, int p_bytes);
- virtual Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent);
-
- virtual Error get_data(uint8_t *p_buffer, int p_bytes);
- virtual Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received);
-
- virtual int get_available_bytes() const;
-
- void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type);
-
- virtual IP_Address get_connected_host() const;
- virtual uint16_t get_connected_port() const;
-
- virtual bool is_connected_to_host() const;
- virtual Status get_status() const;
- virtual void disconnect_from_host();
-
- static void make_default();
- static void cleanup();
-
- virtual void set_nodelay(bool p_enabled);
-
- StreamPeerWinsock();
- ~StreamPeerWinsock();
-};
-
-#endif // TCP_SOCKET_POSIX_H
-
-#endif
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
deleted file mode 100644
index de300befa7..0000000000
--- a/platform/windows/tcp_server_winsock.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*************************************************************************/
-/* tcp_server_winsock.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#include "tcp_server_winsock.h"
-
-#include "stream_peer_winsock.h"
-
-#include <winsock2.h>
-#include <ws2tcpip.h>
-
-#include "drivers/unix/socket_helpers.h"
-
-extern int winsock_refcount;
-
-TCP_Server *TCPServerWinsock::_create() {
-
- return memnew(TCPServerWinsock);
-};
-
-void TCPServerWinsock::make_default() {
-
- TCP_Server::_create = TCPServerWinsock::_create;
-
- if (winsock_refcount == 0) {
- WSADATA data;
- WSAStartup(MAKEWORD(2, 2), &data);
- };
- ++winsock_refcount;
-};
-
-void TCPServerWinsock::cleanup() {
-
- --winsock_refcount;
- if (winsock_refcount == 0) {
-
- WSACleanup();
- };
-};
-
-Error TCPServerWinsock::listen(uint16_t p_port, const IP_Address &p_bind_address) {
-
- ERR_FAIL_COND_V(listen_sockfd != -1, ERR_ALREADY_IN_USE);
- ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
-
- int sockfd;
- sock_type = IP::TYPE_ANY;
-
- // If the bind address is valid use its type as the socket type
- if (p_bind_address.is_valid())
- sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
-
- sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
- ERR_FAIL_COND_V(sockfd == INVALID_SOCKET, FAILED);
-
- unsigned long par = 1;
- if (ioctlsocket(sockfd, FIONBIO, &par)) {
- perror("setting non-block mode");
- stop();
- return FAILED;
- };
-
- struct sockaddr_storage my_addr;
- size_t addr_size = _set_listen_sockaddr(&my_addr, p_port, sock_type, p_bind_address);
-
- int reuse = 1;
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) {
-
- printf("REUSEADDR failed!");
- }
-
- if (bind(sockfd, (struct sockaddr *)&my_addr, addr_size) != SOCKET_ERROR) {
-
- if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {
-
- closesocket(sockfd);
- ERR_FAIL_V(FAILED);
- };
- } else {
- return ERR_ALREADY_IN_USE;
- };
-
- if (listen_sockfd != INVALID_SOCKET) {
-
- stop();
- };
-
- listen_sockfd = sockfd;
-
- return OK;
-};
-
-bool TCPServerWinsock::is_connection_available() const {
-
- if (listen_sockfd == -1) {
- return false;
- };
-
- timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
-
- fd_set pfd;
- FD_ZERO(&pfd);
- FD_SET(listen_sockfd, &pfd);
-
- int ret = select(listen_sockfd + 1, &pfd, NULL, NULL, &timeout);
- ERR_FAIL_COND_V(ret < 0, 0);
-
- if (ret && (FD_ISSET(listen_sockfd, &pfd))) {
-
- return true;
- };
-
- return false;
-};
-
-Ref<StreamPeerTCP> TCPServerWinsock::take_connection() {
-
- if (!is_connection_available()) {
- return NULL;
- };
-
- struct sockaddr_storage their_addr;
- int sin_size = sizeof(their_addr);
- int fd = accept(listen_sockfd, (struct sockaddr *)&their_addr, &sin_size);
- ERR_FAIL_COND_V(fd == INVALID_SOCKET, NULL);
-
- Ref<StreamPeerWinsock> conn = memnew(StreamPeerWinsock);
- IP_Address ip;
- int port;
- _set_ip_addr_port(ip, port, &their_addr);
-
- conn->set_socket(fd, ip, port, sock_type);
-
- return conn;
-};
-
-void TCPServerWinsock::stop() {
-
- if (listen_sockfd != INVALID_SOCKET) {
- closesocket(listen_sockfd);
- };
-
- listen_sockfd = -1;
- sock_type = IP::TYPE_NONE;
-};
-
-TCPServerWinsock::TCPServerWinsock() {
-
- listen_sockfd = INVALID_SOCKET;
- sock_type = IP::TYPE_NONE;
-};
-
-TCPServerWinsock::~TCPServerWinsock() {
-
- stop();
-};
diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h
deleted file mode 100644
index a3e01098ed..0000000000
--- a/platform/windows/tcp_server_winsock.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*************************************************************************/
-/* tcp_server_winsock.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-#ifndef TCP_SERVER_WINSOCK_H
-#define TCP_SERVER_WINSOCK_H
-
-#include "core/io/tcp_server.h"
-
-class TCPServerWinsock : public TCP_Server {
-
- int listen_sockfd;
- IP::Type sock_type;
-
- static TCP_Server *_create();
-
-public:
- virtual Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*"));
- virtual bool is_connection_available() const;
- virtual Ref<StreamPeerTCP> take_connection();
-
- virtual void stop(); //stop listening
-
- static void make_default();
- static void cleanup();
-
- TCPServerWinsock();
- ~TCPServerWinsock();
-};
-
-#endif
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index d7dbe71da4..09bf57c5f1 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -158,6 +158,7 @@ def configure(env):
if not env['builtin_libwebp']:
env.ParseConfig('pkg-config libwebp --cflags --libs')
+
# freetype depends on libpng and zlib, so bundling one of them while keeping others
# as shared libraries leads to weird issues
if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']:
@@ -263,5 +264,10 @@ def configure(env):
env.Append(CPPFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu'])
+
+ if env["openmp"]:
+ env.Append(CPPFLAGS=['-fopenmp'])
+ env.Append(LINKFLAGS=['-fopenmp'])
+
if env['use_static_cpp']:
env.Append(LINKFLAGS=['-static-libstdc++'])
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index b59fab7088..0c0bc1a8a3 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1098,7 +1098,7 @@ bool OS_X11::is_window_maximized() const {
return false;
}
-void OS_X11::set_borderless_window(int p_borderless) {
+void OS_X11::set_borderless_window(bool p_borderless) {
if (current_videomode.borderless_window == p_borderless)
return;
@@ -2264,6 +2264,13 @@ void OS_X11::set_icon(const Ref<Image> &p_icon) {
XFlush(x11_display);
}
+void OS_X11::force_process_input() {
+ process_xevents(); // get rid of pending events
+#ifdef JOYDEV_ENABLED
+ joypad->process_joypads();
+#endif
+}
+
void OS_X11::run() {
force_quit = false;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 244c69ee2b..c8cea1e30c 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -258,7 +258,7 @@ public:
virtual bool is_window_maximized() const;
virtual void request_attention();
- virtual void set_borderless_window(int p_borderless);
+ virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window();
virtual void set_ime_position(const Point2 &p_pos);
@@ -279,6 +279,7 @@ public:
virtual bool _check_internal_feature_support(const String &p_feature);
+ virtual void force_process_input();
void run();
void disable_crash_handler();