Replace Array return types with TypedArray 3

This commit is contained in:
kobewi
2022-08-08 00:52:20 +02:00
parent 0626ce50cf
commit f7f4873ed0
34 changed files with 182 additions and 170 deletions

View File

@ -118,7 +118,7 @@
</description>
</method>
<method name="get_peers">
<return type="Array" />
<return type="ENetPacketPeer[]" />
<description>
Returns the list of peers associated with this host.
[b]Note:[/b] This list might include some peers that are not fully connected or are still being disconnected.

View File

@ -34,6 +34,7 @@
#include "core/io/compression.h"
#include "core/io/ip.h"
#include "core/variant/typed_array.h"
void ENetConnection::broadcast(enet_uint8 p_channel, ENetPacket *p_packet) {
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
@ -263,9 +264,9 @@ void ENetConnection::get_peers(List<Ref<ENetPacketPeer>> &r_peers) {
}
}
Array ENetConnection::_get_peers() {
TypedArray<ENetPacketPeer> ENetConnection::_get_peers() {
ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active.");
Array out;
TypedArray<ENetPacketPeer> out;
for (const Ref<ENetPacketPeer> &I : peers) {
out.push_back(I);
}

View File

@ -38,6 +38,9 @@
#include <enet/enet.h>
template <typename T>
class TypedArray;
class ENetConnection : public RefCounted {
GDCLASS(ENetConnection, RefCounted);
@ -83,7 +86,7 @@ private:
Error _create(ENetAddress *p_address, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth);
Array _service(int p_timeout = 0);
void _broadcast(int p_channel, PackedByteArray p_packet, int p_flags);
Array _get_peers();
TypedArray<ENetPacketPeer> _get_peers();
class Compressor {
private: