summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/README.md3
-rw-r--r--thirdparty/enet/godot.cpp91
-rw-r--r--thirdparty/misc/stb_vorbis.c15
3 files changed, 46 insertions, 63 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 43cd448a00..392abea85e 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -426,9 +426,8 @@ Collection of single-file libraries used in Godot components.
* License: zlib
- `stb_vorbis.c`
* Upstream: https://github.com/nothings/stb
- * Version: 1.19
+ * Version: 1.20
* License: Public Domain (Unlicense) or MIT
- * Modifications: `f->temp_offset += (sz+3)&~3;` changed to `f->temp_offset += (sz+7)&~7;` (needed until fixed upstream)
## nanosvg
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
index 36b5131f80..55b160d752 100644
--- a/thirdparty/enet/godot.cpp
+++ b/thirdparty/enet/godot.cpp
@@ -44,15 +44,14 @@
/// Abstract ENet interface for UDP/DTLS.
class ENetGodotSocket {
-
public:
virtual Error bind(IP_Address p_ip, uint16_t p_port) = 0;
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0;
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0;
virtual int set_option(ENetSocketOption p_option, int p_value) = 0;
virtual void close() = 0;
- virtual void set_refuse_new_connections(bool p_refuse) { /* Only used by dtls server */ }
- virtual ~ENetGodotSocket(){};
+ virtual void set_refuse_new_connections(bool p_enable) {} /* Only used by dtls server */
+ virtual ~ENetGodotSocket() {}
};
class ENetDTLSClient;
@@ -60,21 +59,19 @@ class ENetDTLSServer;
/// NetSocket interface
class ENetUDP : public ENetGodotSocket {
-
friend class ENetDTLSClient;
friend class ENetDTLSServer;
private:
Ref<NetSocket> sock;
IP_Address address;
- uint16_t port;
- bool bound;
+ uint16_t port = 0;
+ bool bound = false;
public:
ENetUDP() {
sock = Ref<NetSocket>(NetSocket::create());
IP::Type ip_type = IP::TYPE_ANY;
- bound = false;
sock->open(NetSocket::TYPE_UDP, ip_type);
}
@@ -95,8 +92,9 @@ public:
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
Error err = sock->poll(NetSocket::POLL_TYPE_IN, 0);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
return sock->recvfrom(p_buffer, p_len, r_read, r_ip, r_port);
}
@@ -149,11 +147,10 @@ public:
/// DTLS Client ENet interface
class ENetDTLSClient : public ENetGodotSocket {
-
- bool connected;
+ bool connected = false;
Ref<PacketPeerUDP> udp;
Ref<PacketPeerDTLS> dtls;
- bool verify;
+ bool verify = false;
String for_hostname;
Ref<X509Certificate> cert;
@@ -168,7 +165,6 @@ public:
if (p_base->bound) {
bind(p_base->address, p_base->port);
}
- connected = false;
}
~ENetDTLSClient() {
@@ -186,25 +182,29 @@ public:
connected = true;
}
dtls->poll();
- if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING)
+ if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) {
return ERR_BUSY;
- else if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED)
+ } else if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) {
return FAILED;
+ }
r_sent = p_len;
return dtls->put_packet(p_buffer, p_len);
}
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
dtls->poll();
- if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING)
+ if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) {
return ERR_BUSY;
- if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED)
+ }
+ if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) {
return FAILED;
+ }
int pc = dtls->get_available_packet_count();
- if (pc == 0)
+ if (pc == 0) {
return ERR_BUSY;
- else if (pc < 0)
+ } else if (pc < 0) {
return FAILED;
+ }
const uint8_t *buffer;
Error err = dtls->get_packet(&buffer, r_read);
@@ -229,15 +229,13 @@ public:
/// DTLSServer - ENet interface
class ENetDTLSServer : public ENetGodotSocket {
-
Ref<DTLSServer> server;
Ref<UDPServer> udp_server;
- Map<String, Ref<PacketPeerDTLS> > peers;
- int last_service;
+ Map<String, Ref<PacketPeerDTLS>> peers;
+ int last_service = 0;
public:
ENetDTLSServer(ENetUDP *p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) {
- last_service = 0;
udp_server.instance();
p_base->close();
if (p_base->bound) {
@@ -264,12 +262,13 @@ public:
ERR_FAIL_COND_V(!peers.has(key), ERR_UNAVAILABLE);
Ref<PacketPeerDTLS> peer = peers[key];
Error err = peer->put_packet(p_buffer, p_len);
- if (err == OK)
+ if (err == OK) {
r_sent = p_len;
- else if (err == ERR_BUSY)
+ } else if (err == ERR_BUSY) {
r_sent = 0;
- else
+ } else {
r_sent = -1;
+ }
return err;
}
@@ -291,13 +290,13 @@ public:
List<String> remove;
Error err = ERR_BUSY;
// TODO this needs to be fair!
- for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) {
+ for (Map<String, Ref<PacketPeerDTLS>>::Element *E = peers.front(); E; E = E->next()) {
Ref<PacketPeerDTLS> peer = E->get();
peer->poll();
- if (peer->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING)
+ if (peer->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) {
continue;
- else if (peer->get_status() != PacketPeerDTLS::STATUS_CONNECTED) {
+ } else if (peer->get_status() != PacketPeerDTLS::STATUS_CONNECTED) {
// Peer disconnected, removing it.
remove.push_back(E->key());
continue;
@@ -336,7 +335,7 @@ public:
}
void close() {
- for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) {
+ for (Map<String, Ref<PacketPeerDTLS>>::Element *E = peers.front(); E; E = E->next()) {
E->get()->disconnect_from_peer();
}
peers.clear();
@@ -348,7 +347,6 @@ public:
static enet_uint32 timeBase = 0;
int enet_initialize(void) {
-
return 0;
}
@@ -356,22 +354,18 @@ void enet_deinitialize(void) {
}
enet_uint32 enet_host_random_seed(void) {
-
return (enet_uint32)OS::get_singleton()->get_unix_time();
}
enet_uint32 enet_time_get(void) {
-
return OS::get_singleton()->get_ticks_msec() - timeBase;
}
void enet_time_set(enet_uint32 newTimeBase) {
-
timeBase = OS::get_singleton()->get_ticks_msec() - newTimeBase;
}
int enet_address_set_host(ENetAddress *address, const char *name) {
-
IP_Address ip = IP::get_singleton()->resolve_hostname(name);
ERR_FAIL_COND_V(!ip.is_valid(), -1);
@@ -380,24 +374,20 @@ int enet_address_set_host(ENetAddress *address, const char *name) {
}
void enet_address_set_ip(ENetAddress *address, const uint8_t *ip, size_t size) {
-
int len = size > 16 ? 16 : size;
memset(address->host, 0, 16);
memcpy(address->host, ip, len);
}
int enet_address_get_host_ip(const ENetAddress *address, char *name, size_t nameLength) {
-
return -1;
}
int enet_address_get_host(const ENetAddress *address, char *name, size_t nameLength) {
-
return -1;
}
ENetSocket enet_socket_create(ENetSocketType type) {
-
ENetUDP *socket = memnew(ENetUDP);
return socket;
@@ -421,7 +411,6 @@ void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) {
}
int enet_socket_bind(ENetSocket socket, const ENetAddress *address) {
-
IP_Address ip;
if (address->wildcard) {
ip = IP_Address("*");
@@ -443,8 +432,7 @@ void enet_socket_destroy(ENetSocket socket) {
}
int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBuffer *buffers, size_t bufferCount) {
-
- ERR_FAIL_COND_V(address == NULL, -1);
+ ERR_FAIL_COND_V(address == nullptr, -1);
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
IP_Address dest;
@@ -455,7 +443,7 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu
// Create a single packet.
Vector<uint8_t> out;
- uint8_t* w;
+ uint8_t *w;
int size = 0;
int pos = 0;
for (i = 0; i < bufferCount; i++) {
@@ -472,7 +460,6 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu
int sent = 0;
err = sock->sendto((const uint8_t *)&w[0], size, sent, dest, address->port);
if (err != OK) {
-
if (err == ERR_BUSY) { // Blocking call
return 0;
}
@@ -485,7 +472,6 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu
}
int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buffers, size_t bufferCount) {
-
ERR_FAIL_COND_V(bufferCount != 1, -1);
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
@@ -494,11 +480,13 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
IP_Address ip;
Error err = sock->recvfrom((uint8_t *)buffers[0].data, buffers[0].dataLength, read, ip, address->port);
- if (err == ERR_BUSY)
+ if (err == ERR_BUSY) {
return 0;
+ }
- if (err != OK)
+ if (err != OK) {
return -1;
+ }
enet_address_set_ip(address, ip.get_ipv6(), 16);
@@ -507,47 +495,38 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
// Not implemented
int enet_socket_wait(ENetSocket socket, enet_uint32 *condition, enet_uint32 timeout) {
-
return 0; // do we need this function?
}
int enet_socket_get_address(ENetSocket socket, ENetAddress *address) {
-
return -1; // do we need this function?
}
int enet_socketset_select(ENetSocket maxSocket, ENetSocketSet *readSet, ENetSocketSet *writeSet, enet_uint32 timeout) {
-
return -1;
}
int enet_socket_listen(ENetSocket socket, int backlog) {
-
return -1;
}
int enet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value) {
-
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
return sock->set_option(option, value);
}
int enet_socket_get_option(ENetSocket socket, ENetSocketOption option, int *value) {
-
return -1;
}
int enet_socket_connect(ENetSocket socket, const ENetAddress *address) {
-
return -1;
}
ENetSocket enet_socket_accept(ENetSocket socket, ENetAddress *address) {
-
- return NULL;
+ return nullptr;
}
int enet_socket_shutdown(ENetSocket socket, ENetSocketShutdown how) {
-
return -1;
}
diff --git a/thirdparty/misc/stb_vorbis.c b/thirdparty/misc/stb_vorbis.c
index 52c9c666a2..a8cbfa6c23 100644
--- a/thirdparty/misc/stb_vorbis.c
+++ b/thirdparty/misc/stb_vorbis.c
@@ -1,4 +1,4 @@
-// Ogg Vorbis audio decoder - v1.19 - public domain
+// Ogg Vorbis audio decoder - v1.20 - public domain
// http://nothings.org/stb_vorbis/
//
// Original version written by Sean Barrett in 2007.
@@ -31,9 +31,11 @@
// Phillip Bennefall Rohit Thiago Goulart
// github:manxorist saga musix github:infatum
// Timur Gagiev Maxwell Koo Peter Waller
-// github:audinowho Dougall Johnson
+// github:audinowho Dougall Johnson David Reid
+// github:Clownacy Pedro J. Estebanez Remi Verschelde
//
// Partial history:
+// 1.20 - 2020-07-11 - several small fixes
// 1.19 - 2020-02-05 - warnings
// 1.18 - 2020-02-02 - fix seek bugs; parse header comments; misc warnings etc.
// 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure)
@@ -577,7 +579,7 @@ enum STBVorbisError
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
- #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
+ #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__)
#include <alloca.h>
#endif
#else // STB_VORBIS_NO_CRT
@@ -599,7 +601,9 @@ enum STBVorbisError
#undef __forceinline
#endif
#define __forceinline
+ #ifndef alloca
#define alloca __builtin_alloca
+ #endif
#elif !defined(_MSC_VER)
#if __GNUC__
#define __forceinline inline
@@ -1600,7 +1604,8 @@ static uint32 get_bits(vorb *f, int n)
f->valid_bits += 8;
}
}
- if (f->valid_bits < 0) return 0;
+
+ assert(f->valid_bits >= n);
z = f->acc & ((1 << n)-1);
f->acc >>= n;
f->valid_bits -= n;
@@ -4256,7 +4261,7 @@ static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
if (z) {
p->alloc = *z;
- p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
+ p->alloc.alloc_buffer_length_in_bytes &= ~7;
p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
}
p->eof = 0;