mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 13:12:42 +00:00
[Modules] Replace ERR_FAIL_COND
with ERR_FAIL_NULL
where applicable
This commit is contained in:
parent
36945dad07
commit
517e9f8aef
@ -1887,7 +1887,7 @@ Error VulkanContext::_update_swap_chain(Window *window) {
|
||||
err = fpGetPhysicalDeviceSurfacePresentModesKHR(gpu, window->surface, &presentModeCount, nullptr);
|
||||
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);
|
||||
VkPresentModeKHR *presentModes = (VkPresentModeKHR *)malloc(presentModeCount * sizeof(VkPresentModeKHR));
|
||||
ERR_FAIL_COND_V(!presentModes, ERR_CANT_CREATE);
|
||||
ERR_FAIL_NULL_V(presentModes, ERR_CANT_CREATE);
|
||||
err = fpGetPhysicalDeviceSurfacePresentModesKHR(gpu, window->surface, &presentModeCount, presentModes);
|
||||
if (err) {
|
||||
free(presentModes);
|
||||
@ -2062,7 +2062,7 @@ Error VulkanContext::_update_swap_chain(Window *window) {
|
||||
}
|
||||
|
||||
VkImage *swapchainImages = (VkImage *)malloc(swapchainImageCount * sizeof(VkImage));
|
||||
ERR_FAIL_COND_V(!swapchainImages, ERR_CANT_CREATE);
|
||||
ERR_FAIL_NULL_V(swapchainImages, ERR_CANT_CREATE);
|
||||
err = fpGetSwapchainImagesKHR(device, window->swapchain, &swapchainImageCount, swapchainImages);
|
||||
if (err) {
|
||||
free(swapchainImages);
|
||||
|
@ -162,7 +162,7 @@ static Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size
|
||||
|
||||
const uint8_t *ptr = p_data;
|
||||
int size = p_size;
|
||||
ERR_FAIL_COND_V_MSG(p_data == nullptr, image, "Cannot unpack invalid basis universal data.");
|
||||
ERR_FAIL_NULL_V_MSG(p_data, image, "Cannot unpack invalid basis universal data.");
|
||||
|
||||
basist::transcoder_texture_format format = basist::transcoder_texture_format::cTFTotalTextureFormats;
|
||||
Image::Format imgfmt = Image::FORMAT_MAX;
|
||||
|
@ -300,7 +300,7 @@ void CSGShape3D::_update_shape() {
|
||||
root_mesh.unref(); //byebye root mesh
|
||||
|
||||
CSGBrush *n = _get_brush();
|
||||
ERR_FAIL_COND_MSG(!n, "Cannot get CSGBrush.");
|
||||
ERR_FAIL_NULL_MSG(n, "Cannot get CSGBrush.");
|
||||
|
||||
OAHashMap<Vector3, Vector3> vec_map;
|
||||
|
||||
@ -458,7 +458,7 @@ void CSGShape3D::_update_shape() {
|
||||
void CSGShape3D::_update_collision_faces() {
|
||||
if (use_collision && is_root_shape() && root_collision_shape.is_valid()) {
|
||||
CSGBrush *n = _get_brush();
|
||||
ERR_FAIL_COND_MSG(!n, "Cannot get CSGBrush.");
|
||||
ERR_FAIL_NULL_MSG(n, "Cannot get CSGBrush.");
|
||||
Vector<Vector3> physics_faces;
|
||||
physics_faces.resize(n->faces.size() * 3);
|
||||
Vector3 *physicsw = physics_faces.ptrw();
|
||||
|
@ -37,7 +37,7 @@
|
||||
#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.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_MSG(p_channel >= host->channelLimit, vformat("Unable to send packet on channel %d, max channels: %d", p_channel, (int)host->channelLimit));
|
||||
enet_host_broadcast(host, p_channel, p_packet);
|
||||
}
|
||||
@ -71,7 +71,7 @@ Error ENetConnection::create_host(int p_max_peers, int p_max_channels, int p_in_
|
||||
}
|
||||
|
||||
void ENetConnection::destroy() {
|
||||
ERR_FAIL_COND_MSG(!host, "Host already destroyed");
|
||||
ERR_FAIL_NULL_MSG(host, "Host already destroyed.");
|
||||
for (List<Ref<ENetPacketPeer>>::Element *E = peers.front(); E; E = E->next()) {
|
||||
E->get()->_on_disconnect();
|
||||
}
|
||||
@ -82,7 +82,7 @@ void ENetConnection::destroy() {
|
||||
|
||||
Ref<ENetPacketPeer> ENetConnection::connect_to_host(const String &p_address, int p_port, int p_channels, int p_data) {
|
||||
Ref<ENetPacketPeer> out;
|
||||
ERR_FAIL_COND_V_MSG(!host, out, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, out, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V_MSG(peers.size(), out, "The ENetConnection is already connected to a peer.");
|
||||
ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, out, "The remote port number must be between 1 and 65535 (inclusive).");
|
||||
|
||||
@ -160,7 +160,7 @@ ENetConnection::EventType ENetConnection::_parse_event(const ENetEvent &p_event,
|
||||
}
|
||||
|
||||
ENetConnection::EventType ENetConnection::service(int p_timeout, Event &r_event) {
|
||||
ERR_FAIL_COND_V_MSG(!host, EVENT_ERROR, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, EVENT_ERROR, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(r_event.peer.is_valid(), EVENT_ERROR);
|
||||
|
||||
// Drop peers that have already been disconnected.
|
||||
@ -186,7 +186,7 @@ ENetConnection::EventType ENetConnection::service(int p_timeout, Event &r_event)
|
||||
}
|
||||
|
||||
int ENetConnection::check_events(EventType &r_type, Event &r_event) {
|
||||
ERR_FAIL_COND_V_MSG(!host, -1, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, -1, "The ENetConnection instance isn't currently active.");
|
||||
ENetEvent event;
|
||||
int ret = enet_host_check_events(host, &event);
|
||||
if (ret < 0) {
|
||||
@ -198,32 +198,32 @@ int ENetConnection::check_events(EventType &r_type, Event &r_event) {
|
||||
}
|
||||
|
||||
void ENetConnection::flush() {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
enet_host_flush(host);
|
||||
}
|
||||
|
||||
void ENetConnection::bandwidth_limit(int p_in_bandwidth, int p_out_bandwidth) {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
enet_host_bandwidth_limit(host, p_in_bandwidth, p_out_bandwidth);
|
||||
}
|
||||
|
||||
void ENetConnection::channel_limit(int p_max_channels) {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
enet_host_channel_limit(host, p_max_channels);
|
||||
}
|
||||
|
||||
void ENetConnection::bandwidth_throttle() {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
enet_host_bandwidth_throttle(host);
|
||||
}
|
||||
|
||||
void ENetConnection::compress(CompressionMode p_mode) {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
Compressor::setup(host, p_mode);
|
||||
}
|
||||
|
||||
double ENetConnection::pop_statistic(HostStatistic p_stat) {
|
||||
ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active.");
|
||||
uint32_t *ptr = nullptr;
|
||||
switch (p_stat) {
|
||||
case HOST_TOTAL_SENT_DATA:
|
||||
@ -239,19 +239,19 @@ double ENetConnection::pop_statistic(HostStatistic p_stat) {
|
||||
ptr = &(host->totalReceivedPackets);
|
||||
break;
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(ptr == nullptr, 0, "Invalid statistic: " + itos(p_stat));
|
||||
ERR_FAIL_NULL_V_MSG(ptr, 0, "Invalid statistic: " + itos(p_stat) + ".");
|
||||
uint32_t ret = *ptr;
|
||||
*ptr = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ENetConnection::get_max_channels() const {
|
||||
ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active.");
|
||||
return host->channelLimit;
|
||||
}
|
||||
|
||||
int ENetConnection::get_local_port() const {
|
||||
ERR_FAIL_COND_V_MSG(!host, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V_MSG(!(host->socket), 0, "The ENetConnection instance isn't currently bound");
|
||||
ENetAddress address;
|
||||
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), 0, "Unable to get socket address");
|
||||
@ -265,7 +265,7 @@ void ENetConnection::get_peers(List<Ref<ENetPacketPeer>> &r_peers) {
|
||||
}
|
||||
|
||||
TypedArray<ENetPacketPeer> ENetConnection::_get_peers() {
|
||||
ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, Array(), "The ENetConnection instance isn't currently active.");
|
||||
TypedArray<ENetPacketPeer> out;
|
||||
for (const Ref<ENetPacketPeer> &I : peers) {
|
||||
out.push_back(I);
|
||||
@ -275,7 +275,7 @@ TypedArray<ENetPacketPeer> ENetConnection::_get_peers() {
|
||||
|
||||
Error ENetConnection::dtls_server_setup(const Ref<TLSOptions> &p_options) {
|
||||
#ifdef GODOT_ENET
|
||||
ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(p_options.is_null() || !p_options->is_server(), ERR_INVALID_PARAMETER);
|
||||
return enet_host_dtls_server_setup(host, const_cast<TLSOptions *>(p_options.ptr())) ? FAILED : OK;
|
||||
#else
|
||||
@ -285,7 +285,7 @@ Error ENetConnection::dtls_server_setup(const Ref<TLSOptions> &p_options) {
|
||||
|
||||
void ENetConnection::refuse_new_connections(bool p_refuse) {
|
||||
#ifdef GODOT_ENET
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
enet_host_refuse_new_connections(host, p_refuse);
|
||||
#else
|
||||
ERR_FAIL_MSG("ENet DTLS support not available in this build.");
|
||||
@ -294,7 +294,7 @@ void ENetConnection::refuse_new_connections(bool p_refuse) {
|
||||
|
||||
Error ENetConnection::dtls_client_setup(const String &p_hostname, const Ref<TLSOptions> &p_options) {
|
||||
#ifdef GODOT_ENET
|
||||
ERR_FAIL_COND_V_MSG(!host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(host, ERR_UNCONFIGURED, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V(p_options.is_null() || p_options->is_server(), ERR_INVALID_PARAMETER);
|
||||
return enet_host_dtls_client_setup(host, p_hostname.utf8().get_data(), const_cast<TLSOptions *>(p_options.ptr())) ? FAILED : OK;
|
||||
#else
|
||||
@ -315,7 +315,7 @@ Error ENetConnection::_create(ENetAddress *p_address, int p_max_peers, int p_max
|
||||
p_in_bandwidth /* limit incoming bandwidth if > 0 */,
|
||||
p_out_bandwidth /* limit outgoing bandwidth if > 0 */);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet host.");
|
||||
ERR_FAIL_NULL_V_MSG(host, ERR_CANT_CREATE, "Couldn't create an ENet host.");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ Array ENetConnection::_service(int p_timeout) {
|
||||
}
|
||||
|
||||
void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_flags) {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_MSG(p_channel < 0 || p_channel > (int)host->channelLimit, "Invalid channel");
|
||||
ERR_FAIL_COND_MSG(p_flags & ~ENetPacketPeer::FLAG_ALLOWED, "Invalid flags");
|
||||
ENetPacket *pkt = enet_packet_create(p_packet.ptr(), p_packet.size(), p_flags);
|
||||
@ -343,7 +343,7 @@ void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_f
|
||||
}
|
||||
|
||||
void ENetConnection::socket_send(const String &p_address, int p_port, const PackedByteArray &p_packet) {
|
||||
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_MSG(!(host->socket), "The ENetConnection instance isn't currently bound");
|
||||
ERR_FAIL_COND_MSG(p_port < 1 || p_port > 65535, "The remote port number must be between 1 and 65535 (inclusive).");
|
||||
|
||||
@ -497,7 +497,7 @@ size_t ENetConnection::Compressor::enet_decompress(void *context, const enet_uin
|
||||
}
|
||||
|
||||
void ENetConnection::Compressor::setup(ENetHost *p_host, CompressionMode p_mode) {
|
||||
ERR_FAIL_COND(!p_host);
|
||||
ERR_FAIL_NULL(p_host);
|
||||
switch (p_mode) {
|
||||
case COMPRESS_NONE: {
|
||||
enet_host_compress(p_host, nullptr);
|
||||
|
@ -31,51 +31,51 @@
|
||||
#include "enet_packet_peer.h"
|
||||
|
||||
void ENetPacketPeer::peer_disconnect(int p_data) {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
enet_peer_disconnect(peer, p_data);
|
||||
}
|
||||
|
||||
void ENetPacketPeer::peer_disconnect_later(int p_data) {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
enet_peer_disconnect_later(peer, p_data);
|
||||
}
|
||||
|
||||
void ENetPacketPeer::peer_disconnect_now(int p_data) {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
enet_peer_disconnect_now(peer, p_data);
|
||||
_on_disconnect();
|
||||
}
|
||||
|
||||
void ENetPacketPeer::ping() {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
enet_peer_ping(peer);
|
||||
}
|
||||
|
||||
void ENetPacketPeer::ping_interval(int p_interval) {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
enet_peer_ping_interval(peer, p_interval);
|
||||
}
|
||||
|
||||
int ENetPacketPeer::send(uint8_t p_channel, ENetPacket *p_packet) {
|
||||
ERR_FAIL_COND_V(peer == nullptr, -1);
|
||||
ERR_FAIL_COND_V(p_packet == nullptr, -1);
|
||||
ERR_FAIL_NULL_V(peer, -1);
|
||||
ERR_FAIL_NULL_V(p_packet, -1);
|
||||
ERR_FAIL_COND_V_MSG(p_channel >= peer->channelCount, -1, vformat("Unable to send packet on channel %d, max channels: %d", p_channel, (int)peer->channelCount));
|
||||
return enet_peer_send(peer, p_channel, p_packet);
|
||||
}
|
||||
|
||||
void ENetPacketPeer::reset() {
|
||||
ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected");
|
||||
ERR_FAIL_NULL_MSG(peer, "Peer not connected.");
|
||||
enet_peer_reset(peer);
|
||||
_on_disconnect();
|
||||
}
|
||||
|
||||
void ENetPacketPeer::throttle_configure(int p_interval, int p_acceleration, int p_deceleration) {
|
||||
ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected");
|
||||
ERR_FAIL_NULL_MSG(peer, "Peer not connected.");
|
||||
enet_peer_throttle_configure(peer, p_interval, p_acceleration, p_deceleration);
|
||||
}
|
||||
|
||||
void ENetPacketPeer::set_timeout(int p_timeout, int p_timeout_min, int p_timeout_max) {
|
||||
ERR_FAIL_COND_MSG(peer == nullptr, "Peer not connected");
|
||||
ERR_FAIL_NULL_MSG(peer, "Peer not connected.");
|
||||
ERR_FAIL_COND_MSG(p_timeout > p_timeout_min || p_timeout_min > p_timeout_max, "Timeout limit must be less than minimum timeout, which itself must be less than maximum timeout");
|
||||
enet_peer_timeout(peer, p_timeout, p_timeout_min, p_timeout_max);
|
||||
}
|
||||
@ -89,7 +89,7 @@ int ENetPacketPeer::get_available_packet_count() const {
|
||||
}
|
||||
|
||||
Error ENetPacketPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
||||
ERR_FAIL_COND_V(!peer, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(peer, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(!packet_queue.size(), ERR_UNAVAILABLE);
|
||||
if (last_packet) {
|
||||
enet_packet_destroy(last_packet);
|
||||
@ -103,13 +103,13 @@ Error ENetPacketPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
|
||||
}
|
||||
|
||||
Error ENetPacketPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
|
||||
ERR_FAIL_COND_V(!peer, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(peer, ERR_UNCONFIGURED);
|
||||
ENetPacket *packet = enet_packet_create(p_buffer, p_buffer_size, ENET_PACKET_FLAG_RELIABLE);
|
||||
return send(0, packet) < 0 ? FAILED : OK;
|
||||
}
|
||||
|
||||
IPAddress ENetPacketPeer::get_remote_address() const {
|
||||
ERR_FAIL_COND_V(!peer, IPAddress());
|
||||
ERR_FAIL_NULL_V(peer, IPAddress());
|
||||
IPAddress out;
|
||||
#ifdef GODOT_ENET
|
||||
out.set_ipv6((uint8_t *)&(peer->address.host));
|
||||
@ -120,7 +120,7 @@ IPAddress ENetPacketPeer::get_remote_address() const {
|
||||
}
|
||||
|
||||
int ENetPacketPeer::get_remote_port() const {
|
||||
ERR_FAIL_COND_V(!peer, 0);
|
||||
ERR_FAIL_NULL_V(peer, 0);
|
||||
return peer->address.port;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ bool ENetPacketPeer::is_active() const {
|
||||
}
|
||||
|
||||
double ENetPacketPeer::get_statistic(PeerStatistic p_stat) {
|
||||
ERR_FAIL_COND_V(!peer, 0);
|
||||
ERR_FAIL_NULL_V(peer, 0);
|
||||
switch (p_stat) {
|
||||
case PEER_PACKET_LOSS:
|
||||
return peer->packetLoss;
|
||||
@ -171,7 +171,7 @@ ENetPacketPeer::PeerState ENetPacketPeer::get_state() const {
|
||||
}
|
||||
|
||||
int ENetPacketPeer::get_channels() const {
|
||||
ERR_FAIL_COND_V_MSG(!peer, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_NULL_V_MSG(peer, 0, "The ENetConnection instance isn't currently active.");
|
||||
return peer->channelCount;
|
||||
}
|
||||
|
||||
@ -183,12 +183,12 @@ void ENetPacketPeer::_on_disconnect() {
|
||||
}
|
||||
|
||||
void ENetPacketPeer::_queue_packet(ENetPacket *p_packet) {
|
||||
ERR_FAIL_COND(!peer);
|
||||
ERR_FAIL_NULL(peer);
|
||||
packet_queue.push_back(p_packet);
|
||||
}
|
||||
|
||||
Error ENetPacketPeer::_send(int p_channel, PackedByteArray p_packet, int p_flags) {
|
||||
ERR_FAIL_COND_V_MSG(peer == nullptr, ERR_UNCONFIGURED, "Peer not connected");
|
||||
ERR_FAIL_NULL_V_MSG(peer, ERR_UNCONFIGURED, "Peer not connected.");
|
||||
ERR_FAIL_COND_V_MSG(p_channel < 0 || p_channel > (int)peer->channelCount, ERR_INVALID_PARAMETER, "Invalid channel");
|
||||
ERR_FAIL_COND_V_MSG(p_flags & ~FLAG_ALLOWED, ERR_INVALID_PARAMETER, "Invalid flags");
|
||||
ENetPacket *packet = enet_packet_create(p_packet.ptr(), p_packet.size(), p_flags);
|
||||
|
@ -83,7 +83,7 @@ void GDScriptNativeClass::_bind_methods() {
|
||||
|
||||
Variant GDScriptNativeClass::_new() {
|
||||
Object *o = instantiate();
|
||||
ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
|
||||
ERR_FAIL_NULL_V_MSG(o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
|
||||
|
||||
RefCounted *rc = Object::cast_to<RefCounted>(o);
|
||||
if (rc) {
|
||||
@ -215,7 +215,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
|
||||
} else {
|
||||
owner = memnew(RefCounted); //by default, no base means use reference
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(!owner, Variant(), "Can't inherit from a virtual class.");
|
||||
ERR_FAIL_NULL_V_MSG(owner, Variant(), "Can't inherit from a virtual class.");
|
||||
|
||||
RefCounted *r = Object::cast_to<RefCounted>(owner);
|
||||
if (r) {
|
||||
|
@ -1419,7 +1419,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, bo
|
||||
}
|
||||
|
||||
void GDScriptAnalyzer::resolve_node(GDScriptParser::Node *p_node, bool p_is_root) {
|
||||
ERR_FAIL_COND_MSG(p_node == nullptr, "Trying to resolve type of a null node.");
|
||||
ERR_FAIL_NULL_MSG(p_node, "Trying to resolve type of a null node.");
|
||||
|
||||
switch (p_node->type) {
|
||||
case GDScriptParser::Node::NONE:
|
||||
|
@ -59,7 +59,7 @@ GDScriptAnalyzer *GDScriptParserRef::get_analyzer() {
|
||||
}
|
||||
|
||||
Error GDScriptParserRef::raise_status(Status p_new_status) {
|
||||
ERR_FAIL_COND_V(parser == nullptr, ERR_INVALID_DATA);
|
||||
ERR_FAIL_NULL_V(parser, ERR_INVALID_DATA);
|
||||
|
||||
if (result != OK) {
|
||||
return result;
|
||||
|
@ -60,7 +60,7 @@ bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringNa
|
||||
scr = scr->_base;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!nc, false);
|
||||
ERR_FAIL_NULL_V(nc, false);
|
||||
|
||||
return ClassDB::has_property(nc->get_name(), p_name);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
|
||||
}
|
||||
|
||||
Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
||||
ERR_FAIL_COND_V(!function, Variant());
|
||||
ERR_FAIL_NULL_V(function, Variant());
|
||||
{
|
||||
MutexLock lock(GDScriptLanguage::singleton->mutex);
|
||||
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
}
|
||||
|
||||
GDScriptDataType get_container_element_type() const {
|
||||
ERR_FAIL_COND_V(container_element_type == nullptr, GDScriptDataType());
|
||||
ERR_FAIL_NULL_V(container_element_type, GDScriptDataType());
|
||||
return *container_element_type;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ void GDScriptParser::push_error(const String &p_message, const Node *p_origin) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_code, const Vector<String> &p_symbols) {
|
||||
ERR_FAIL_COND(p_source == nullptr);
|
||||
ERR_FAIL_NULL(p_source);
|
||||
if (is_ignoring_warnings) {
|
||||
return;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ DataType get_container_element_type() const {
|
||||
ERR_FAIL_COND_V(container_element_type == nullptr, DataType());
|
||||
ERR_FAIL_NULL_V(container_element_type, DataType());
|
||||
return *container_element_type;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ GDScriptRPCCallable::GDScriptRPCCallable(Object *p_object, const StringName &p_m
|
||||
h = method.hash();
|
||||
h = hash_murmur3_one_64(object->get_instance_id(), h);
|
||||
node = Object::cast_to<Node>(object);
|
||||
ERR_FAIL_COND_MSG(!node, "RPC can only be defined on class that extends Node.");
|
||||
ERR_FAIL_NULL_MSG(node, "RPC can only be defined on class that extends Node.");
|
||||
}
|
||||
|
||||
Error GDScriptRPCCallable::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const {
|
||||
|
@ -729,50 +729,50 @@ void GDScriptUtilityFunctions::unregister_functions() {
|
||||
|
||||
GDScriptUtilityFunctions::FunctionPtr GDScriptUtilityFunctions::get_function(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, nullptr);
|
||||
ERR_FAIL_NULL_V(info, nullptr);
|
||||
return info->function;
|
||||
}
|
||||
|
||||
bool GDScriptUtilityFunctions::has_function_return_value(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, false);
|
||||
ERR_FAIL_NULL_V(info, false);
|
||||
return info->info.return_val.type != Variant::NIL || bool(info->info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT);
|
||||
}
|
||||
|
||||
Variant::Type GDScriptUtilityFunctions::get_function_return_type(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, Variant::NIL);
|
||||
ERR_FAIL_NULL_V(info, Variant::NIL);
|
||||
return info->info.return_val.type;
|
||||
}
|
||||
|
||||
StringName GDScriptUtilityFunctions::get_function_return_class(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, StringName());
|
||||
ERR_FAIL_NULL_V(info, StringName());
|
||||
return info->info.return_val.class_name;
|
||||
}
|
||||
|
||||
Variant::Type GDScriptUtilityFunctions::get_function_argument_type(const StringName &p_function, int p_arg) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, Variant::NIL);
|
||||
ERR_FAIL_NULL_V(info, Variant::NIL);
|
||||
ERR_FAIL_COND_V(p_arg >= info->info.arguments.size(), Variant::NIL);
|
||||
return info->info.arguments[p_arg].type;
|
||||
}
|
||||
|
||||
int GDScriptUtilityFunctions::get_function_argument_count(const StringName &p_function, int p_arg) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, 0);
|
||||
ERR_FAIL_NULL_V(info, 0);
|
||||
return info->info.arguments.size();
|
||||
}
|
||||
|
||||
bool GDScriptUtilityFunctions::is_function_vararg(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, false);
|
||||
ERR_FAIL_NULL_V(info, false);
|
||||
return (bool)(info->info.flags & METHOD_FLAG_VARARG);
|
||||
}
|
||||
|
||||
bool GDScriptUtilityFunctions::is_function_constant(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, false);
|
||||
ERR_FAIL_NULL_V(info, false);
|
||||
return info->is_constant;
|
||||
}
|
||||
|
||||
@ -788,6 +788,6 @@ void GDScriptUtilityFunctions::get_function_list(List<StringName> *r_functions)
|
||||
|
||||
MethodInfo GDScriptUtilityFunctions::get_function_info(const StringName &p_function) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_COND_V(!info, MethodInfo());
|
||||
ERR_FAIL_NULL_V(info, MethodInfo());
|
||||
return info->info;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
|
||||
}
|
||||
ERR_FAIL_COND(!clients.has(p_client_id));
|
||||
Ref<LSPeer> peer = clients.get(p_client_id);
|
||||
ERR_FAIL_COND(peer == nullptr);
|
||||
ERR_FAIL_NULL(peer);
|
||||
|
||||
Dictionary message = make_notification(p_method, p_params);
|
||||
String msg = Variant(message).to_json_string();
|
||||
@ -311,7 +311,7 @@ void GDScriptLanguageProtocol::request_client(const String &p_method, const Vari
|
||||
}
|
||||
ERR_FAIL_COND(!clients.has(p_client_id));
|
||||
Ref<LSPeer> peer = clients.get(p_client_id);
|
||||
ERR_FAIL_COND(peer == nullptr);
|
||||
ERR_FAIL_NULL(peer);
|
||||
|
||||
Dictionary message = make_request(p_method, p_params, next_server_id);
|
||||
next_server_id++;
|
||||
|
@ -111,7 +111,7 @@ void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) {
|
||||
Ref<GLTFLight> GLTFLight::from_node(const Light3D *p_light) {
|
||||
Ref<GLTFLight> l;
|
||||
l.instantiate();
|
||||
ERR_FAIL_COND_V_MSG(!p_light, l, "Tried to create a GLTFLight from a Light3D node, but the given node was null.");
|
||||
ERR_FAIL_NULL_V_MSG(p_light, l, "Tried to create a GLTFLight from a Light3D node, but the given node was null.");
|
||||
l->color = p_light->get_color();
|
||||
if (cast_to<DirectionalLight3D>(p_light)) {
|
||||
l->light_type = "directional";
|
||||
|
@ -112,7 +112,7 @@ void GLTFPhysicsBody::set_inertia_tensor(Basis p_inertia_tensor) {
|
||||
Ref<GLTFPhysicsBody> GLTFPhysicsBody::from_node(const CollisionObject3D *p_body_node) {
|
||||
Ref<GLTFPhysicsBody> physics_body;
|
||||
physics_body.instantiate();
|
||||
ERR_FAIL_COND_V_MSG(!p_body_node, physics_body, "Tried to create a GLTFPhysicsBody from a CollisionObject3D node, but the given node was null.");
|
||||
ERR_FAIL_NULL_V_MSG(p_body_node, physics_body, "Tried to create a GLTFPhysicsBody from a CollisionObject3D node, but the given node was null.");
|
||||
if (cast_to<CharacterBody3D>(p_body_node)) {
|
||||
physics_body->body_type = "character";
|
||||
} else if (cast_to<AnimatableBody3D>(p_body_node)) {
|
||||
|
@ -5594,7 +5594,7 @@ void GLTFDocument::_create_gltf_node(Ref<GLTFState> p_state, Node *p_scene_paren
|
||||
}
|
||||
|
||||
void GLTFDocument::_convert_animation_player_to_gltf(AnimationPlayer *p_animation_player, Ref<GLTFState> p_state, GLTFNodeIndex p_gltf_current, GLTFNodeIndex p_gltf_root_index, Ref<GLTFNode> p_gltf_node, Node *p_scene_parent) {
|
||||
ERR_FAIL_COND(!p_animation_player);
|
||||
ERR_FAIL_NULL(p_animation_player);
|
||||
p_state->animation_players.push_back(p_animation_player);
|
||||
print_verbose(String("glTF: Converting animation player: ") + p_animation_player->get_name());
|
||||
}
|
||||
@ -5613,7 +5613,7 @@ void GLTFDocument::_check_visibility(Node *p_node, bool &r_retflag) {
|
||||
}
|
||||
|
||||
void GLTFDocument::_convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node) {
|
||||
ERR_FAIL_COND(!camera);
|
||||
ERR_FAIL_NULL(camera);
|
||||
GLTFCameraIndex camera_index = _convert_camera(p_state, camera);
|
||||
if (camera_index != -1) {
|
||||
p_gltf_node->camera = camera_index;
|
||||
@ -5621,7 +5621,7 @@ void GLTFDocument::_convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> p_st
|
||||
}
|
||||
|
||||
void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node) {
|
||||
ERR_FAIL_COND(!light);
|
||||
ERR_FAIL_NULL(light);
|
||||
GLTFLightIndex light_index = _convert_light(p_state, light);
|
||||
if (light_index != -1) {
|
||||
p_gltf_node->light = light_index;
|
||||
@ -5663,7 +5663,7 @@ void GLTFDocument::_convert_multi_mesh_instance_to_gltf(
|
||||
GLTFNodeIndex p_parent_node_index,
|
||||
GLTFNodeIndex p_root_node_index,
|
||||
Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state) {
|
||||
ERR_FAIL_COND(!p_multi_mesh_instance);
|
||||
ERR_FAIL_NULL(p_multi_mesh_instance);
|
||||
Ref<MultiMesh> multi_mesh = p_multi_mesh_instance->get_multimesh();
|
||||
if (multi_mesh.is_null()) {
|
||||
return;
|
||||
@ -6141,7 +6141,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
|
||||
const Ref<GLTFNode> gltf_node = p_state->nodes[track_i.key];
|
||||
|
||||
Node *root = p_animation_player->get_parent();
|
||||
ERR_FAIL_COND(root == nullptr);
|
||||
ERR_FAIL_NULL(root);
|
||||
HashMap<GLTFNodeIndex, Node *>::Iterator node_element = p_state->scene_nodes.find(node_index);
|
||||
ERR_CONTINUE_MSG(!node_element, vformat("Unable to find node %d for animation.", node_index));
|
||||
node_path = root->get_path_to(node_element->value);
|
||||
@ -6154,7 +6154,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
|
||||
|
||||
if (gltf_node->skeleton >= 0) {
|
||||
const Skeleton3D *sk = p_state->skeletons[gltf_node->skeleton]->godot_skeleton;
|
||||
ERR_FAIL_COND(sk == nullptr);
|
||||
ERR_FAIL_NULL(sk);
|
||||
|
||||
const String path = p_animation_player->get_parent()->get_path_to(sk);
|
||||
const String bone = gltf_node->get_name();
|
||||
|
@ -60,7 +60,7 @@ void GLTFCamera::_bind_methods() {
|
||||
Ref<GLTFCamera> GLTFCamera::from_node(const Camera3D *p_camera) {
|
||||
Ref<GLTFCamera> c;
|
||||
c.instantiate();
|
||||
ERR_FAIL_COND_V_MSG(!p_camera, c, "Tried to create a GLTFCamera from a Camera3D node, but the given node was null.");
|
||||
ERR_FAIL_NULL_V_MSG(p_camera, c, "Tried to create a GLTFCamera from a Camera3D node, but the given node was null.");
|
||||
c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE);
|
||||
// GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees.
|
||||
c->set_fov(Math::deg_to_rad(p_camera->get_fov()));
|
||||
|
@ -256,7 +256,7 @@ Error HMACContextMbedTLS::start(HashingContext::HashType p_hash_type, PackedByte
|
||||
}
|
||||
|
||||
Error HMACContextMbedTLS::update(PackedByteArray p_data) {
|
||||
ERR_FAIL_COND_V_MSG(ctx == nullptr, ERR_INVALID_DATA, "Start must be called before update.");
|
||||
ERR_FAIL_NULL_V_MSG(ctx, ERR_INVALID_DATA, "Start must be called before update.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(p_data.is_empty(), ERR_INVALID_PARAMETER, "Src must not be empty.");
|
||||
|
||||
@ -265,7 +265,7 @@ Error HMACContextMbedTLS::update(PackedByteArray p_data) {
|
||||
}
|
||||
|
||||
PackedByteArray HMACContextMbedTLS::finish() {
|
||||
ERR_FAIL_COND_V_MSG(ctx == nullptr, PackedByteArray(), "Start must be called before finish.");
|
||||
ERR_FAIL_NULL_V_MSG(ctx, PackedByteArray(), "Start must be called before finish.");
|
||||
ERR_FAIL_COND_V_MSG(hash_len == 0, PackedByteArray(), "Unsupported hash type.");
|
||||
|
||||
PackedByteArray out;
|
||||
@ -342,7 +342,7 @@ void CryptoMbedTLS::load_default_certificates(String p_path) {
|
||||
ERR_FAIL_COND(default_certs != nullptr);
|
||||
|
||||
default_certs = memnew(X509CertificateMbedTLS);
|
||||
ERR_FAIL_COND(default_certs == nullptr);
|
||||
ERR_FAIL_NULL(default_certs);
|
||||
|
||||
if (!p_path.is_empty()) {
|
||||
// Use certs defined in project settings.
|
||||
|
@ -40,7 +40,7 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len
|
||||
|
||||
PacketPeerMbedDTLS *sp = static_cast<PacketPeerMbedDTLS *>(ctx);
|
||||
|
||||
ERR_FAIL_COND_V(sp == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(sp, 0);
|
||||
|
||||
Error err = sp->base->put_packet((const uint8_t *)buf, len);
|
||||
if (err == ERR_BUSY) {
|
||||
@ -58,7 +58,7 @@ int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
|
||||
|
||||
PacketPeerMbedDTLS *sp = static_cast<PacketPeerMbedDTLS *>(ctx);
|
||||
|
||||
ERR_FAIL_COND_V(sp == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(sp, 0);
|
||||
|
||||
int pc = sp->base->get_available_packet_count();
|
||||
if (pc == 0) {
|
||||
|
@ -40,7 +40,7 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len)
|
||||
|
||||
StreamPeerMbedTLS *sp = static_cast<StreamPeerMbedTLS *>(ctx);
|
||||
|
||||
ERR_FAIL_COND_V(sp == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(sp, 0);
|
||||
|
||||
int sent;
|
||||
Error err = sp->base->put_partial_data((const uint8_t *)buf, len, sent);
|
||||
@ -60,7 +60,7 @@ int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
|
||||
|
||||
StreamPeerMbedTLS *sp = static_cast<StreamPeerMbedTLS *>(ctx);
|
||||
|
||||
ERR_FAIL_COND_V(sp == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(sp, 0);
|
||||
|
||||
int got;
|
||||
Error err = sp->base->get_partial_data((uint8_t *)buf, len, got);
|
||||
|
@ -47,7 +47,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
|
||||
|
||||
for (const StringName &E : class_list) {
|
||||
ClassDB::ClassInfo *t = ClassDB::classes.getptr(E);
|
||||
ERR_FAIL_COND(!t);
|
||||
ERR_FAIL_NULL(t);
|
||||
if (t->api != p_api || !t->exposed) {
|
||||
continue;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void update_godot_api_cache(const ManagedCallbacks &p_managed_callbacks) {
|
||||
|
||||
#define CHECK_CALLBACK_NOT_NULL_IMPL(m_var, m_class, m_method) \
|
||||
{ \
|
||||
ERR_FAIL_COND_MSG(m_var == nullptr, \
|
||||
ERR_FAIL_NULL_MSG(m_var, \
|
||||
"Mono Cache: Managed callback for '" #m_class "_" #m_method "' is null."); \
|
||||
checked_count += 1; \
|
||||
}
|
||||
|
@ -112,9 +112,9 @@ void ReplicationEditor::_pick_node_filter_input(const Ref<InputEvent> &p_ie) {
|
||||
|
||||
void ReplicationEditor::_pick_node_selected(NodePath p_path) {
|
||||
Node *root = current->get_node(current->get_root_path());
|
||||
ERR_FAIL_COND(!root);
|
||||
ERR_FAIL_NULL(root);
|
||||
Node *node = get_node(p_path);
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
NodePath path_to = root->get_path_to(node);
|
||||
adding_node_path = path_to;
|
||||
prop_selector->select_property_from_instance(node);
|
||||
|
@ -237,7 +237,7 @@ void MultiplayerDebugger::RPCProfiler::tick(double p_frame_time, double p_proces
|
||||
// ReplicationProfiler
|
||||
|
||||
MultiplayerDebugger::SyncInfo::SyncInfo(MultiplayerSynchronizer *p_sync) {
|
||||
ERR_FAIL_COND(!p_sync);
|
||||
ERR_FAIL_NULL(p_sync);
|
||||
synchronizer = p_sync->get_instance_id();
|
||||
if (p_sync->get_replication_config().is_valid()) {
|
||||
config = p_sync->get_replication_config()->get_instance_id();
|
||||
@ -305,7 +305,7 @@ void MultiplayerDebugger::ReplicationProfiler::add(const Array &p_data) {
|
||||
const ObjectID id = p_data[1];
|
||||
const uint64_t size = p_data[2];
|
||||
MultiplayerSynchronizer *sync = Object::cast_to<MultiplayerSynchronizer>(ObjectDB::get_instance(id));
|
||||
ERR_FAIL_COND(!sync);
|
||||
ERR_FAIL_NULL(sync);
|
||||
if (!sync_data.has(id)) {
|
||||
sync_data[id] = SyncInfo(sync);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ void MultiplayerSpawner::_spawn_notify(ObjectID p_id) {
|
||||
|
||||
void MultiplayerSpawner::_node_exit(ObjectID p_id) {
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(p_id));
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
if (tracked_nodes.has(p_id)) {
|
||||
tracked_nodes.erase(p_id);
|
||||
get_multiplayer()->object_configuration_remove(node, this);
|
||||
@ -323,10 +323,10 @@ Node *MultiplayerSpawner::spawn(const Variant &p_data) {
|
||||
ERR_FAIL_COND_V_MSG(!spawn_function.is_valid(), nullptr, "Custom spawn requires the 'spawn_function' property to be a valid callable.");
|
||||
|
||||
Node *parent = get_spawn_node();
|
||||
ERR_FAIL_COND_V_MSG(!parent, nullptr, "Cannot find spawn node.");
|
||||
ERR_FAIL_NULL_V_MSG(parent, nullptr, "Cannot find spawn node.");
|
||||
|
||||
Node *node = instantiate_custom(p_data);
|
||||
ERR_FAIL_COND_V_MSG(!node, nullptr, "The 'spawn_function' callable must return a valid node.");
|
||||
ERR_FAIL_NULL_V_MSG(node, nullptr, "The 'spawn_function' callable must return a valid node.");
|
||||
|
||||
_track(node, p_data);
|
||||
parent->add_child(node, true);
|
||||
|
@ -149,14 +149,14 @@ PackedStringArray MultiplayerSynchronizer::get_configuration_warnings() const {
|
||||
}
|
||||
|
||||
Error MultiplayerSynchronizer::get_state(const List<NodePath> &p_properties, Object *p_obj, Vector<Variant> &r_variant, Vector<const Variant *> &r_variant_ptrs) {
|
||||
ERR_FAIL_COND_V(!p_obj, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(p_obj, ERR_INVALID_PARAMETER);
|
||||
r_variant.resize(p_properties.size());
|
||||
r_variant_ptrs.resize(r_variant.size());
|
||||
int i = 0;
|
||||
for (const NodePath &prop : p_properties) {
|
||||
bool valid = false;
|
||||
const Object *obj = _get_prop_target(p_obj, prop);
|
||||
ERR_FAIL_COND_V(!obj, FAILED);
|
||||
ERR_FAIL_NULL_V(obj, FAILED);
|
||||
r_variant.write[i] = obj->get_indexed(prop.get_subnames(), &valid);
|
||||
r_variant_ptrs.write[i] = &r_variant[i];
|
||||
ERR_FAIL_COND_V_MSG(!valid, ERR_INVALID_DATA, vformat("Property '%s' not found.", prop));
|
||||
@ -166,11 +166,11 @@ Error MultiplayerSynchronizer::get_state(const List<NodePath> &p_properties, Obj
|
||||
}
|
||||
|
||||
Error MultiplayerSynchronizer::set_state(const List<NodePath> &p_properties, Object *p_obj, const Vector<Variant> &p_state) {
|
||||
ERR_FAIL_COND_V(!p_obj, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(p_obj, ERR_INVALID_PARAMETER);
|
||||
int i = 0;
|
||||
for (const NodePath &prop : p_properties) {
|
||||
Object *obj = _get_prop_target(p_obj, prop);
|
||||
ERR_FAIL_COND_V(!obj, FAILED);
|
||||
ERR_FAIL_NULL_V(obj, FAILED);
|
||||
obj->set_indexed(prop.get_subnames(), p_state[i]);
|
||||
i += 1;
|
||||
}
|
||||
@ -374,7 +374,7 @@ Error MultiplayerSynchronizer::_watch_changes(uint64_t p_usec) {
|
||||
return OK;
|
||||
}
|
||||
Node *node = get_root_node();
|
||||
ERR_FAIL_COND_V(!node, FAILED);
|
||||
ERR_FAIL_NULL_V(node, FAILED);
|
||||
int idx = -1;
|
||||
Watcher *ptr = watchers.ptrw();
|
||||
for (const NodePath &prop : props) {
|
||||
|
@ -53,7 +53,7 @@ void SceneCacheInterface::on_peer_change(int p_id, bool p_connected) {
|
||||
|
||||
void SceneCacheInterface::process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
|
||||
Node *root_node = SceneTree::get_singleton()->get_root()->get_node(multiplayer->get_root_path());
|
||||
ERR_FAIL_COND(!root_node);
|
||||
ERR_FAIL_NULL(root_node);
|
||||
ERR_FAIL_COND_MSG(p_packet_len < 38, "Invalid packet received. Size too small.");
|
||||
int ofs = 1;
|
||||
|
||||
@ -74,7 +74,7 @@ void SceneCacheInterface::process_simplify_path(int p_from, const uint8_t *p_pac
|
||||
}
|
||||
|
||||
Node *node = root_node->get_node(path);
|
||||
ERR_FAIL_COND(node == nullptr);
|
||||
ERR_FAIL_NULL(node);
|
||||
const bool valid_rpc_checksum = multiplayer->get_rpc_md5(node) == methods_md5;
|
||||
if (valid_rpc_checksum == false) {
|
||||
ERR_PRINT("The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: " + path);
|
||||
@ -119,7 +119,7 @@ void SceneCacheInterface::process_confirm_path(int p_from, const uint8_t *p_pack
|
||||
}
|
||||
|
||||
PathSentCache *psc = path_send_cache.getptr(path);
|
||||
ERR_FAIL_COND_MSG(!psc, "Invalid packet received. Tries to confirm a path which was not found in cache.");
|
||||
ERR_FAIL_NULL_MSG(psc, "Invalid packet received. Tries to confirm a path which was not found in cache.");
|
||||
|
||||
HashMap<int, bool>::Iterator E = psc->confirmed_peers.find(p_from);
|
||||
ERR_FAIL_COND_MSG(!E, "Invalid packet received. Source peer was not found in cache for the given path.");
|
||||
@ -165,7 +165,7 @@ Error SceneCacheInterface::_send_confirm_path(Node *p_node, NodePath p_path, Pat
|
||||
|
||||
bool SceneCacheInterface::is_cache_confirmed(NodePath p_path, int p_peer) {
|
||||
const PathSentCache *psc = path_send_cache.getptr(p_path);
|
||||
ERR_FAIL_COND_V(!psc, false);
|
||||
ERR_FAIL_NULL_V(psc, false);
|
||||
HashMap<int, bool>::ConstIterator F = psc->confirmed_peers.find(p_peer);
|
||||
ERR_FAIL_COND_V(!F, false); // Should never happen.
|
||||
return F->value;
|
||||
@ -173,7 +173,7 @@ bool SceneCacheInterface::is_cache_confirmed(NodePath p_path, int p_peer) {
|
||||
|
||||
int SceneCacheInterface::make_object_cache(Object *p_obj) {
|
||||
Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node, -1);
|
||||
ERR_FAIL_NULL_V(node, -1);
|
||||
NodePath for_path = multiplayer->get_root_path().rel_path_to(node->get_path());
|
||||
// See if the path is cached.
|
||||
PathSentCache *psc = path_send_cache.getptr(for_path);
|
||||
@ -188,7 +188,7 @@ int SceneCacheInterface::make_object_cache(Object *p_obj) {
|
||||
|
||||
bool SceneCacheInterface::send_object_cache(Object *p_obj, int p_peer_id, int &r_id) {
|
||||
Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node, false);
|
||||
ERR_FAIL_NULL_V(node, false);
|
||||
|
||||
r_id = make_object_cache(p_obj);
|
||||
ERR_FAIL_COND_V(r_id < 0, false);
|
||||
@ -233,7 +233,7 @@ bool SceneCacheInterface::send_object_cache(Object *p_obj, int p_peer_id, int &r
|
||||
|
||||
Object *SceneCacheInterface::get_cached_object(int p_from, uint32_t p_cache_id) {
|
||||
Node *root_node = SceneTree::get_singleton()->get_root()->get_node(multiplayer->get_root_path());
|
||||
ERR_FAIL_COND_V(!root_node, nullptr);
|
||||
ERR_FAIL_NULL_V(root_node, nullptr);
|
||||
HashMap<int, PathGetCache>::Iterator E = path_get_cache.find(p_from);
|
||||
ERR_FAIL_COND_V_MSG(!E, nullptr, vformat("No cache found for peer %d.", p_from));
|
||||
|
||||
|
@ -155,7 +155,7 @@ Error SceneReplicationInterface::on_spawn(Object *p_obj, Variant p_config) {
|
||||
Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node || p_config.get_type() != Variant::OBJECT, ERR_INVALID_PARAMETER);
|
||||
MultiplayerSpawner *spawner = Object::cast_to<MultiplayerSpawner>(p_config.get_validated_object());
|
||||
ERR_FAIL_COND_V(!spawner, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(spawner, ERR_INVALID_PARAMETER);
|
||||
// Track node.
|
||||
const ObjectID oid = node->get_instance_id();
|
||||
TrackedNode &tobj = _track(oid);
|
||||
@ -226,7 +226,7 @@ Error SceneReplicationInterface::on_replication_start(Object *p_obj, Variant p_c
|
||||
Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node || p_config.get_type() != Variant::OBJECT, ERR_INVALID_PARAMETER);
|
||||
MultiplayerSynchronizer *sync = Object::cast_to<MultiplayerSynchronizer>(p_config.get_validated_object());
|
||||
ERR_FAIL_COND_V(!sync, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(sync, ERR_INVALID_PARAMETER);
|
||||
|
||||
// Add to synchronizer list.
|
||||
TrackedNode &tobj = _track(p_obj->get_instance_id());
|
||||
@ -270,7 +270,7 @@ Error SceneReplicationInterface::on_replication_stop(Object *p_obj, Variant p_co
|
||||
Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node || p_config.get_type() != Variant::OBJECT, ERR_INVALID_PARAMETER);
|
||||
MultiplayerSynchronizer *sync = Object::cast_to<MultiplayerSynchronizer>(p_config.get_validated_object());
|
||||
ERR_FAIL_COND_V(!sync, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(sync, ERR_INVALID_PARAMETER);
|
||||
sync->disconnect("visibility_changed", callable_mp(this, &SceneReplicationInterface::_visibility_changed));
|
||||
// Untrack synchronizer.
|
||||
const ObjectID oid = node->get_instance_id();
|
||||
@ -291,9 +291,9 @@ Error SceneReplicationInterface::on_replication_stop(Object *p_obj, Variant p_co
|
||||
|
||||
void SceneReplicationInterface::_visibility_changed(int p_peer, ObjectID p_sid) {
|
||||
MultiplayerSynchronizer *sync = get_id_as<MultiplayerSynchronizer>(p_sid);
|
||||
ERR_FAIL_COND(!sync); // Bug.
|
||||
ERR_FAIL_NULL(sync); // Bug.
|
||||
Node *node = sync->get_root_node();
|
||||
ERR_FAIL_COND(!node); // Bug.
|
||||
ERR_FAIL_NULL(node); // Bug.
|
||||
const ObjectID oid = node->get_instance_id();
|
||||
if (spawned_nodes.has(oid) && p_peer != multiplayer->get_unique_id()) {
|
||||
_update_spawn_visibility(p_peer, oid);
|
||||
@ -341,7 +341,7 @@ bool SceneReplicationInterface::is_rpc_visible(const ObjectID &p_oid, int p_peer
|
||||
}
|
||||
|
||||
Error SceneReplicationInterface::_update_sync_visibility(int p_peer, MultiplayerSynchronizer *p_sync) {
|
||||
ERR_FAIL_COND_V(!p_sync, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(p_sync, ERR_BUG);
|
||||
if (!multiplayer->has_multiplayer_peer() || !p_sync->is_multiplayer_authority() || p_peer == multiplayer->get_unique_id()) {
|
||||
return OK;
|
||||
}
|
||||
@ -380,7 +380,7 @@ Error SceneReplicationInterface::_update_sync_visibility(int p_peer, Multiplayer
|
||||
|
||||
Error SceneReplicationInterface::_update_spawn_visibility(int p_peer, const ObjectID &p_oid) {
|
||||
const TrackedNode *tnode = tracked_nodes.getptr(p_oid);
|
||||
ERR_FAIL_COND_V(!tnode, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(tnode, ERR_BUG);
|
||||
MultiplayerSpawner *spawner = get_id_as<MultiplayerSpawner>(tnode->spawner);
|
||||
Node *node = get_id_as<Node>(p_oid);
|
||||
ERR_FAIL_COND_V(!node || !spawner || !spawner->is_multiplayer_authority(), ERR_BUG);
|
||||
@ -467,7 +467,7 @@ Error SceneReplicationInterface::_make_spawn_packet(Node *p_node, MultiplayerSpa
|
||||
|
||||
const ObjectID oid = p_node->get_instance_id();
|
||||
const TrackedNode *tnode = tracked_nodes.getptr(oid);
|
||||
ERR_FAIL_COND_V(!tnode, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(tnode, ERR_INVALID_PARAMETER);
|
||||
|
||||
uint32_t nid = tnode->net_id;
|
||||
ERR_FAIL_COND_V(!nid, ERR_UNCONFIGURED);
|
||||
@ -549,7 +549,7 @@ Error SceneReplicationInterface::_make_spawn_packet(Node *p_node, MultiplayerSpa
|
||||
Error SceneReplicationInterface::_make_despawn_packet(Node *p_node, int &r_len) {
|
||||
const ObjectID oid = p_node->get_instance_id();
|
||||
const TrackedNode *tnode = tracked_nodes.getptr(oid);
|
||||
ERR_FAIL_COND_V(!tnode, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_NULL_V(tnode, ERR_INVALID_PARAMETER);
|
||||
MAKE_ROOM(5);
|
||||
uint8_t *ptr = packet_cache.ptrw();
|
||||
ptr[0] = (uint8_t)SceneMultiplayer::NETWORK_COMMAND_DESPAWN;
|
||||
@ -568,7 +568,7 @@ Error SceneReplicationInterface::on_spawn_receive(int p_from, const uint8_t *p_b
|
||||
uint32_t node_target = decode_uint32(&p_buffer[ofs]);
|
||||
ofs += 4;
|
||||
MultiplayerSpawner *spawner = Object::cast_to<MultiplayerSpawner>(multiplayer->get_path_cache()->get_cached_object(p_from, node_target));
|
||||
ERR_FAIL_COND_V(!spawner, ERR_DOES_NOT_EXIST);
|
||||
ERR_FAIL_NULL_V(spawner, ERR_DOES_NOT_EXIST);
|
||||
ERR_FAIL_COND_V(p_from != spawner->get_multiplayer_authority(), ERR_UNAUTHORIZED);
|
||||
|
||||
uint32_t net_id = decode_uint32(&p_buffer[ofs]);
|
||||
@ -592,7 +592,7 @@ Error SceneReplicationInterface::on_spawn_receive(int p_from, const uint8_t *p_b
|
||||
|
||||
// Check that we can spawn.
|
||||
Node *parent = spawner->get_node_or_null(spawner->get_spawn_path());
|
||||
ERR_FAIL_COND_V(!parent, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_NULL_V(parent, ERR_UNCONFIGURED);
|
||||
ERR_FAIL_COND_V(parent->has_node(name), ERR_INVALID_DATA);
|
||||
|
||||
Node *node = nullptr;
|
||||
@ -611,7 +611,7 @@ Error SceneReplicationInterface::on_spawn_receive(int p_from, const uint8_t *p_b
|
||||
// Scene based spawn.
|
||||
node = spawner->instantiate_scene(scene_id);
|
||||
}
|
||||
ERR_FAIL_COND_V(!node, ERR_UNAUTHORIZED);
|
||||
ERR_FAIL_NULL_V(node, ERR_UNAUTHORIZED);
|
||||
node->set_name(name);
|
||||
|
||||
// Add and track remote
|
||||
@ -656,13 +656,13 @@ Error SceneReplicationInterface::on_despawn_receive(int p_from, const uint8_t *p
|
||||
PeerInfo &pinfo = peers_info[p_from];
|
||||
ERR_FAIL_COND_V(!pinfo.recv_nodes.has(net_id), ERR_UNAUTHORIZED);
|
||||
Node *node = get_id_as<Node>(pinfo.recv_nodes[net_id]);
|
||||
ERR_FAIL_COND_V(!node, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(node, ERR_BUG);
|
||||
pinfo.recv_nodes.erase(net_id);
|
||||
|
||||
const ObjectID oid = node->get_instance_id();
|
||||
ERR_FAIL_COND_V(!tracked_nodes.has(oid), ERR_BUG);
|
||||
MultiplayerSpawner *spawner = get_id_as<MultiplayerSpawner>(tracked_nodes[oid].spawner);
|
||||
ERR_FAIL_COND_V(!spawner, ERR_DOES_NOT_EXIST);
|
||||
ERR_FAIL_NULL_V(spawner, ERR_DOES_NOT_EXIST);
|
||||
ERR_FAIL_COND_V(p_from != spawner->get_multiplayer_authority(), ERR_UNAUTHORIZED);
|
||||
|
||||
if (node->get_parent() != nullptr) {
|
||||
|
@ -134,7 +134,7 @@ _FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, i
|
||||
|
||||
String SceneRPCInterface::get_rpc_md5(const Object *p_obj) {
|
||||
const Node *node = Object::cast_to<Node>(p_obj);
|
||||
ERR_FAIL_COND_V(!node, "");
|
||||
ERR_FAIL_NULL_V(node, "");
|
||||
const RPCConfigCache cache = _get_node_config(node);
|
||||
String rpc_list;
|
||||
for (const KeyValue<uint16_t, RPCConfig> &config : cache.configs) {
|
||||
@ -145,7 +145,7 @@ String SceneRPCInterface::get_rpc_md5(const Object *p_obj) {
|
||||
|
||||
Node *SceneRPCInterface::_process_get_node(int p_from, const uint8_t *p_packet, uint32_t p_node_target, int p_packet_len) {
|
||||
Node *root_node = SceneTree::get_singleton()->get_root()->get_node(multiplayer->get_root_path());
|
||||
ERR_FAIL_COND_V(!root_node, nullptr);
|
||||
ERR_FAIL_NULL_V(root_node, nullptr);
|
||||
Node *node = nullptr;
|
||||
|
||||
if (p_node_target & 0x80000000) {
|
||||
@ -225,7 +225,7 @@ void SceneRPCInterface::process_rpc(int p_from, const uint8_t *p_packet, int p_p
|
||||
}
|
||||
|
||||
Node *node = _process_get_node(p_from, p_packet, node_target, p_packet_len);
|
||||
ERR_FAIL_COND_MSG(node == nullptr, "Invalid packet received. Requested node was not found.");
|
||||
ERR_FAIL_NULL_MSG(node, "Invalid packet received. Requested node was not found.");
|
||||
|
||||
uint16_t name_id = 0;
|
||||
switch (name_id_compression) {
|
||||
|
@ -64,7 +64,7 @@ void NavigationMeshEditor::_notification(int p_what) {
|
||||
void NavigationMeshEditor::_bake_pressed() {
|
||||
button_bake->set_pressed(false);
|
||||
|
||||
ERR_FAIL_COND(!node);
|
||||
ERR_FAIL_NULL(node);
|
||||
Ref<NavigationMesh> navmesh = node->get_navigation_mesh();
|
||||
if (!navmesh.is_valid()) {
|
||||
err_dialog->set_text(TTR("A NavigationMesh resource must be set or created for this node to work."));
|
||||
|
@ -116,7 +116,7 @@ RID GodotNavigationServer::map_create() {
|
||||
|
||||
COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
if (p_active) {
|
||||
if (!map_is_active(p_map)) {
|
||||
@ -133,126 +133,126 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
|
||||
|
||||
bool GodotNavigationServer::map_is_active(RID p_map) const {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, false);
|
||||
ERR_FAIL_NULL_V(map, false);
|
||||
|
||||
return active_maps.find(map) >= 0;
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_up(p_up);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::map_get_up(RID p_map) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
|
||||
return map->get_up();
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_cell_size(p_cell_size);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::map_get_cell_size(RID p_map) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(map, 0);
|
||||
|
||||
return map->get_cell_size();
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_cell_height, RID, p_map, real_t, p_cell_height) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_cell_height(p_cell_height);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::map_get_cell_height(RID p_map) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(map, 0);
|
||||
|
||||
return map->get_cell_height();
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_use_edge_connections, RID, p_map, bool, p_enabled) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_use_edge_connections(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::map_get_use_edge_connections(RID p_map) const {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, false);
|
||||
ERR_FAIL_NULL_V(map, false);
|
||||
|
||||
return map->get_use_edge_connections();
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_edge_connection_margin(p_connection_margin);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::map_get_edge_connection_margin(RID p_map) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(map, 0);
|
||||
|
||||
return map->get_edge_connection_margin();
|
||||
}
|
||||
|
||||
COMMAND_2(map_set_link_connection_radius, RID, p_map, real_t, p_connection_radius) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
map->set_link_connection_radius(p_connection_radius);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::map_get_link_connection_radius(RID p_map) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(map, 0);
|
||||
|
||||
return map->get_link_connection_radius();
|
||||
}
|
||||
|
||||
Vector<Vector3> GodotNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize, uint32_t p_navigation_layers) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>());
|
||||
ERR_FAIL_NULL_V(map, Vector<Vector3>());
|
||||
|
||||
return map->get_path(p_origin, p_destination, p_optimize, p_navigation_layers, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
|
||||
return map->get_closest_point_to_segment(p_from, p_to, p_use_collision);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
|
||||
return map->get_closest_point(p_point);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
|
||||
return map->get_closest_point_normal(p_point);
|
||||
}
|
||||
|
||||
RID GodotNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const {
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, RID());
|
||||
ERR_FAIL_NULL_V(map, RID());
|
||||
|
||||
return map->get_closest_point_owner(p_point);
|
||||
}
|
||||
@ -260,7 +260,7 @@ RID GodotNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3
|
||||
TypedArray<RID> GodotNavigationServer::map_get_links(RID p_map) const {
|
||||
TypedArray<RID> link_rids;
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, link_rids);
|
||||
ERR_FAIL_NULL_V(map, link_rids);
|
||||
|
||||
const LocalVector<NavLink *> &links = map->get_links();
|
||||
link_rids.resize(links.size());
|
||||
@ -274,7 +274,7 @@ TypedArray<RID> GodotNavigationServer::map_get_links(RID p_map) const {
|
||||
TypedArray<RID> GodotNavigationServer::map_get_regions(RID p_map) const {
|
||||
TypedArray<RID> regions_rids;
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, regions_rids);
|
||||
ERR_FAIL_NULL_V(map, regions_rids);
|
||||
|
||||
const LocalVector<NavRegion *> ®ions = map->get_regions();
|
||||
regions_rids.resize(regions.size());
|
||||
@ -288,7 +288,7 @@ TypedArray<RID> GodotNavigationServer::map_get_regions(RID p_map) const {
|
||||
TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const {
|
||||
TypedArray<RID> agents_rids;
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, agents_rids);
|
||||
ERR_FAIL_NULL_V(map, agents_rids);
|
||||
|
||||
const LocalVector<NavAgent *> &agents = map->get_agents();
|
||||
agents_rids.resize(agents.size());
|
||||
@ -302,7 +302,7 @@ TypedArray<RID> GodotNavigationServer::map_get_agents(RID p_map) const {
|
||||
TypedArray<RID> GodotNavigationServer::map_get_obstacles(RID p_map) const {
|
||||
TypedArray<RID> obstacles_rids;
|
||||
const NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND_V(map == nullptr, obstacles_rids);
|
||||
ERR_FAIL_NULL_V(map, obstacles_rids);
|
||||
const LocalVector<NavObstacle *> obstacles = map->get_obstacles();
|
||||
obstacles_rids.resize(obstacles.size());
|
||||
for (uint32_t i = 0; i < obstacles.size(); i++) {
|
||||
@ -313,7 +313,7 @@ TypedArray<RID> GodotNavigationServer::map_get_obstacles(RID p_map) const {
|
||||
|
||||
RID GodotNavigationServer::region_get_map(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, RID());
|
||||
ERR_FAIL_NULL_V(region, RID());
|
||||
|
||||
if (region->get_map()) {
|
||||
return region->get_map()->get_self();
|
||||
@ -323,7 +323,7 @@ RID GodotNavigationServer::region_get_map(RID p_region) const {
|
||||
|
||||
RID GodotNavigationServer::agent_get_map(RID p_agent) const {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND_V(agent == nullptr, RID());
|
||||
ERR_FAIL_NULL_V(agent, RID());
|
||||
|
||||
if (agent->get_map()) {
|
||||
return agent->get_map()->get_self();
|
||||
@ -342,35 +342,35 @@ RID GodotNavigationServer::region_create() {
|
||||
|
||||
COMMAND_2(region_set_enabled, RID, p_region, bool, p_enabled) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::region_get_enabled(RID p_region) const {
|
||||
const NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, false);
|
||||
ERR_FAIL_NULL_V(region, false);
|
||||
|
||||
return region->get_enabled();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_use_edge_connections, RID, p_region, bool, p_enabled) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_use_edge_connections(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::region_get_use_edge_connections(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, false);
|
||||
ERR_FAIL_NULL_V(region, false);
|
||||
|
||||
return region->get_use_edge_connections();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
|
||||
@ -379,14 +379,14 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
|
||||
|
||||
COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_transform(p_transform);
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_enter_cost, RID, p_region, real_t, p_enter_cost) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
ERR_FAIL_COND(p_enter_cost < 0.0);
|
||||
|
||||
region->set_enter_cost(p_enter_cost);
|
||||
@ -394,14 +394,14 @@ COMMAND_2(region_set_enter_cost, RID, p_region, real_t, p_enter_cost) {
|
||||
|
||||
real_t GodotNavigationServer::region_get_enter_cost(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(region, 0);
|
||||
|
||||
return region->get_enter_cost();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_travel_cost, RID, p_region, real_t, p_travel_cost) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
ERR_FAIL_COND(p_travel_cost < 0.0);
|
||||
|
||||
region->set_travel_cost(p_travel_cost);
|
||||
@ -409,28 +409,28 @@ COMMAND_2(region_set_travel_cost, RID, p_region, real_t, p_travel_cost) {
|
||||
|
||||
real_t GodotNavigationServer::region_get_travel_cost(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(region, 0);
|
||||
|
||||
return region->get_travel_cost();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_owner_id, RID, p_region, ObjectID, p_owner_id) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_owner_id(p_owner_id);
|
||||
}
|
||||
|
||||
ObjectID GodotNavigationServer::region_get_owner_id(RID p_region) const {
|
||||
const NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, ObjectID());
|
||||
ERR_FAIL_NULL_V(region, ObjectID());
|
||||
|
||||
return region->get_owner_id();
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::region_owns_point(RID p_region, const Vector3 &p_point) const {
|
||||
const NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, false);
|
||||
ERR_FAIL_NULL_V(region, false);
|
||||
|
||||
if (region->get_map()) {
|
||||
RID closest_point_owner = map_get_closest_point_owner(region->get_map()->get_self(), p_point);
|
||||
@ -441,21 +441,21 @@ bool GodotNavigationServer::region_owns_point(RID p_region, const Vector3 &p_poi
|
||||
|
||||
COMMAND_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigation_layers) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_navigation_layers(p_navigation_layers);
|
||||
}
|
||||
|
||||
uint32_t GodotNavigationServer::region_get_navigation_layers(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(region == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(region, 0);
|
||||
|
||||
return region->get_navigation_layers();
|
||||
}
|
||||
|
||||
COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navigation_mesh) {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND(region == nullptr);
|
||||
ERR_FAIL_NULL(region);
|
||||
|
||||
region->set_mesh(p_navigation_mesh);
|
||||
}
|
||||
@ -463,7 +463,7 @@ COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref<NavigationMesh>, p_navi
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void GodotNavigationServer::region_bake_navigation_mesh(Ref<NavigationMesh> p_navigation_mesh, Node *p_root_node) {
|
||||
ERR_FAIL_COND(p_navigation_mesh.is_null());
|
||||
ERR_FAIL_COND(p_root_node == nullptr);
|
||||
ERR_FAIL_NULL(p_root_node);
|
||||
|
||||
WARN_PRINT_ONCE("NavigationServer3D::region_bake_navigation_mesh() is deprecated due to core threading changes. To upgrade existing code, first create a NavigationMeshSourceGeometryData3D resource. Use this resource with method parse_source_geometry_data() to parse the SceneTree for nodes that should contribute to the navigation mesh baking. The SceneTree parsing needs to happen on the main thread. After the parsing is finished use the resource with method bake_from_source_geometry_data() to bake a navigation mesh..");
|
||||
|
||||
@ -479,21 +479,21 @@ void GodotNavigationServer::region_bake_navigation_mesh(Ref<NavigationMesh> p_na
|
||||
|
||||
int GodotNavigationServer::region_get_connections_count(RID p_region) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(!region, 0);
|
||||
ERR_FAIL_NULL_V(region, 0);
|
||||
|
||||
return region->get_connections_count();
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::region_get_connection_pathway_start(RID p_region, int p_connection_id) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(!region, Vector3());
|
||||
ERR_FAIL_NULL_V(region, Vector3());
|
||||
|
||||
return region->get_connection_pathway_start(p_connection_id);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::region_get_connection_pathway_end(RID p_region, int p_connection_id) const {
|
||||
NavRegion *region = region_owner.get_or_null(p_region);
|
||||
ERR_FAIL_COND_V(!region, Vector3());
|
||||
ERR_FAIL_NULL_V(region, Vector3());
|
||||
|
||||
return region->get_connection_pathway_end(p_connection_id);
|
||||
}
|
||||
@ -509,7 +509,7 @@ RID GodotNavigationServer::link_create() {
|
||||
|
||||
COMMAND_2(link_set_map, RID, p_link, RID, p_map) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
|
||||
@ -518,7 +518,7 @@ COMMAND_2(link_set_map, RID, p_link, RID, p_map) {
|
||||
|
||||
RID GodotNavigationServer::link_get_map(const RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, RID());
|
||||
ERR_FAIL_NULL_V(link, RID());
|
||||
|
||||
if (link->get_map()) {
|
||||
return link->get_map()->get_self();
|
||||
@ -528,112 +528,112 @@ RID GodotNavigationServer::link_get_map(const RID p_link) const {
|
||||
|
||||
COMMAND_2(link_set_enabled, RID, p_link, bool, p_enabled) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::link_get_enabled(RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, false);
|
||||
ERR_FAIL_NULL_V(link, false);
|
||||
|
||||
return link->get_enabled();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_bidirectional, RID, p_link, bool, p_bidirectional) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_bidirectional(p_bidirectional);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::link_is_bidirectional(RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, false);
|
||||
ERR_FAIL_NULL_V(link, false);
|
||||
|
||||
return link->is_bidirectional();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_navigation_layers, RID, p_link, uint32_t, p_navigation_layers) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_navigation_layers(p_navigation_layers);
|
||||
}
|
||||
|
||||
uint32_t GodotNavigationServer::link_get_navigation_layers(const RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(link, 0);
|
||||
|
||||
return link->get_navigation_layers();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_start_position, RID, p_link, Vector3, p_position) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_start_position(p_position);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::link_get_start_position(RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(link, Vector3());
|
||||
|
||||
return link->get_start_position();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_end_position, RID, p_link, Vector3, p_position) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_end_position(p_position);
|
||||
}
|
||||
|
||||
Vector3 GodotNavigationServer::link_get_end_position(RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, Vector3());
|
||||
ERR_FAIL_NULL_V(link, Vector3());
|
||||
|
||||
return link->get_end_position();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_enter_cost, RID, p_link, real_t, p_enter_cost) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_enter_cost(p_enter_cost);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::link_get_enter_cost(const RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(link, 0);
|
||||
|
||||
return link->get_enter_cost();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_travel_cost, RID, p_link, real_t, p_travel_cost) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_travel_cost(p_travel_cost);
|
||||
}
|
||||
|
||||
real_t GodotNavigationServer::link_get_travel_cost(const RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, 0);
|
||||
ERR_FAIL_NULL_V(link, 0);
|
||||
|
||||
return link->get_travel_cost();
|
||||
}
|
||||
|
||||
COMMAND_2(link_set_owner_id, RID, p_link, ObjectID, p_owner_id) {
|
||||
NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND(link == nullptr);
|
||||
ERR_FAIL_NULL(link);
|
||||
|
||||
link->set_owner_id(p_owner_id);
|
||||
}
|
||||
|
||||
ObjectID GodotNavigationServer::link_get_owner_id(RID p_link) const {
|
||||
const NavLink *link = link_owner.get_or_null(p_link);
|
||||
ERR_FAIL_COND_V(link == nullptr, ObjectID());
|
||||
ERR_FAIL_NULL_V(link, ObjectID());
|
||||
|
||||
return link->get_owner_id();
|
||||
}
|
||||
@ -649,35 +649,35 @@ RID GodotNavigationServer::agent_create() {
|
||||
|
||||
COMMAND_2(agent_set_avoidance_enabled, RID, p_agent, bool, p_enabled) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_avoidance_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::agent_get_avoidance_enabled(RID p_agent) const {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND_V(agent == nullptr, false);
|
||||
ERR_FAIL_NULL_V(agent, false);
|
||||
|
||||
return agent->is_avoidance_enabled();
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_use_3d_avoidance, RID, p_agent, bool, p_enabled) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_use_3d_avoidance(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::agent_get_use_3d_avoidance(RID p_agent) const {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND_V(agent == nullptr, false);
|
||||
ERR_FAIL_NULL_V(agent, false);
|
||||
|
||||
return agent->get_use_3d_avoidance();
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
|
||||
@ -686,28 +686,28 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
|
||||
|
||||
COMMAND_2(agent_set_paused, RID, p_agent, bool, p_paused) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_paused(p_paused);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::agent_get_paused(RID p_agent) const {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND_V(agent == nullptr, false);
|
||||
ERR_FAIL_NULL_V(agent, false);
|
||||
|
||||
return agent->get_paused();
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_neighbor_distance, RID, p_agent, real_t, p_distance) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_neighbor_distance(p_distance);
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_max_neighbors(p_count);
|
||||
}
|
||||
@ -715,7 +715,7 @@ COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
|
||||
COMMAND_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon) {
|
||||
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizion must be positive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_time_horizon_agents(p_time_horizon);
|
||||
}
|
||||
@ -723,7 +723,7 @@ COMMAND_2(agent_set_time_horizon_agents, RID, p_agent, real_t, p_time_horizon) {
|
||||
COMMAND_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon) {
|
||||
ERR_FAIL_COND_MSG(p_time_horizon < 0.0, "Time horizion must be positive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_time_horizon_obstacles(p_time_horizon);
|
||||
}
|
||||
@ -731,7 +731,7 @@ COMMAND_2(agent_set_time_horizon_obstacles, RID, p_agent, real_t, p_time_horizon
|
||||
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0.0, "Radius must be positive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_radius(p_radius);
|
||||
}
|
||||
@ -739,7 +739,7 @@ COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
|
||||
COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height) {
|
||||
ERR_FAIL_COND_MSG(p_height < 0.0, "Height must be positive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_height(p_height);
|
||||
}
|
||||
@ -747,42 +747,42 @@ COMMAND_2(agent_set_height, RID, p_agent, real_t, p_height) {
|
||||
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
|
||||
ERR_FAIL_COND_MSG(p_max_speed < 0.0, "Max speed must be positive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_max_speed(p_max_speed);
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_velocity(p_velocity);
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_velocity_forced, RID, p_agent, Vector3, p_velocity) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_velocity_forced(p_velocity);
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_position(p_position);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND_V(agent == nullptr, false);
|
||||
ERR_FAIL_NULL_V(agent, false);
|
||||
|
||||
return agent->is_map_changed();
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
|
||||
agent->set_avoidance_callback(p_callback);
|
||||
|
||||
@ -797,13 +797,13 @@ COMMAND_2(agent_set_avoidance_callback, RID, p_agent, Callable, p_callback) {
|
||||
|
||||
COMMAND_2(agent_set_avoidance_layers, RID, p_agent, uint32_t, p_layers) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
agent->set_avoidance_layers(p_layers);
|
||||
}
|
||||
|
||||
COMMAND_2(agent_set_avoidance_mask, RID, p_agent, uint32_t, p_mask) {
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
agent->set_avoidance_mask(p_mask);
|
||||
}
|
||||
|
||||
@ -811,7 +811,7 @@ COMMAND_2(agent_set_avoidance_priority, RID, p_agent, real_t, p_priority) {
|
||||
ERR_FAIL_COND_MSG(p_priority < 0.0, "Avoidance priority must be between 0.0 and 1.0 inclusive.");
|
||||
ERR_FAIL_COND_MSG(p_priority > 1.0, "Avoidance priority must be between 0.0 and 1.0 inclusive.");
|
||||
NavAgent *agent = agent_owner.get_or_null(p_agent);
|
||||
ERR_FAIL_COND(agent == nullptr);
|
||||
ERR_FAIL_NULL(agent);
|
||||
agent->set_avoidance_priority(p_priority);
|
||||
}
|
||||
|
||||
@ -833,35 +833,35 @@ RID GodotNavigationServer::obstacle_create() {
|
||||
|
||||
COMMAND_2(obstacle_set_avoidance_enabled, RID, p_obstacle, bool, p_enabled) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
obstacle->set_avoidance_enabled(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::obstacle_get_avoidance_enabled(RID p_obstacle) const {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND_V(obstacle == nullptr, false);
|
||||
ERR_FAIL_NULL_V(obstacle, false);
|
||||
|
||||
return obstacle->is_avoidance_enabled();
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_use_3d_avoidance, RID, p_obstacle, bool, p_enabled) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
obstacle->set_use_3d_avoidance(p_enabled);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::obstacle_get_use_3d_avoidance(RID p_obstacle) const {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND_V(obstacle == nullptr, false);
|
||||
ERR_FAIL_NULL_V(obstacle, false);
|
||||
|
||||
return obstacle->get_use_3d_avoidance();
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_map, RID, p_obstacle, RID, p_map) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
|
||||
@ -870,7 +870,7 @@ COMMAND_2(obstacle_set_map, RID, p_obstacle, RID, p_map) {
|
||||
|
||||
RID GodotNavigationServer::obstacle_get_map(RID p_obstacle) const {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND_V(obstacle == nullptr, RID());
|
||||
ERR_FAIL_NULL_V(obstacle, RID());
|
||||
if (obstacle->get_map()) {
|
||||
return obstacle->get_map()->get_self();
|
||||
}
|
||||
@ -879,14 +879,14 @@ RID GodotNavigationServer::obstacle_get_map(RID p_obstacle) const {
|
||||
|
||||
COMMAND_2(obstacle_set_paused, RID, p_obstacle, bool, p_paused) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
obstacle->set_paused(p_paused);
|
||||
}
|
||||
|
||||
bool GodotNavigationServer::obstacle_get_paused(RID p_obstacle) const {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND_V(obstacle == nullptr, false);
|
||||
ERR_FAIL_NULL_V(obstacle, false);
|
||||
|
||||
return obstacle->get_paused();
|
||||
}
|
||||
@ -894,39 +894,39 @@ bool GodotNavigationServer::obstacle_get_paused(RID p_obstacle) const {
|
||||
COMMAND_2(obstacle_set_radius, RID, p_obstacle, real_t, p_radius) {
|
||||
ERR_FAIL_COND_MSG(p_radius < 0.0, "Radius must be positive.");
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
obstacle->set_radius(p_radius);
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_height, RID, p_obstacle, real_t, p_height) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
obstacle->set_height(p_height);
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_velocity, RID, p_obstacle, Vector3, p_velocity) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
|
||||
obstacle->set_velocity(p_velocity);
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_position, RID, p_obstacle, Vector3, p_position) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
obstacle->set_position(p_position);
|
||||
}
|
||||
|
||||
void GodotNavigationServer::obstacle_set_vertices(RID p_obstacle, const Vector<Vector3> &p_vertices) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
obstacle->set_vertices(p_vertices);
|
||||
}
|
||||
|
||||
COMMAND_2(obstacle_set_avoidance_layers, RID, p_obstacle, uint32_t, p_layers) {
|
||||
NavObstacle *obstacle = obstacle_owner.get_or_null(p_obstacle);
|
||||
ERR_FAIL_COND(obstacle == nullptr);
|
||||
ERR_FAIL_NULL(obstacle);
|
||||
obstacle->set_avoidance_layers(p_layers);
|
||||
}
|
||||
|
||||
@ -934,7 +934,7 @@ void GodotNavigationServer::parse_source_geometry_data(const Ref<NavigationMesh>
|
||||
#ifndef _3D_DISABLED
|
||||
ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "The SceneTree can only be parsed on the main thread. Call this function from the main thread or use call_deferred().");
|
||||
ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh.");
|
||||
ERR_FAIL_COND_MSG(p_root_node == nullptr, "No parsing root node specified.");
|
||||
ERR_FAIL_NULL_MSG(p_root_node, "No parsing root node specified.");
|
||||
ERR_FAIL_COND_MSG(!p_root_node->is_inside_tree(), "The root node needs to be inside the SceneTree.");
|
||||
|
||||
ERR_FAIL_NULL(NavMeshGenerator3D::get_singleton());
|
||||
@ -1079,7 +1079,7 @@ void GodotNavigationServer::flush_queries() {
|
||||
|
||||
void GodotNavigationServer::map_force_update(RID p_map) {
|
||||
NavMap *map = map_owner.get_or_null(p_map);
|
||||
ERR_FAIL_COND(map == nullptr);
|
||||
ERR_FAIL_NULL(map);
|
||||
|
||||
flush_queries();
|
||||
|
||||
@ -1166,7 +1166,7 @@ PathQueryResult GodotNavigationServer::_query_path(const PathQueryParameters &p_
|
||||
PathQueryResult r_query_result;
|
||||
|
||||
const NavMap *map = map_owner.get_or_null(p_parameters.map);
|
||||
ERR_FAIL_COND_V(map == nullptr, r_query_result);
|
||||
ERR_FAIL_NULL_V(map, r_query_result);
|
||||
|
||||
// run the pathfinding
|
||||
|
||||
|
@ -149,7 +149,7 @@ void NavMeshGenerator3D::finish() {
|
||||
void NavMeshGenerator3D::parse_source_geometry_data(Ref<NavigationMesh> p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_root_node, const Callable &p_callback) {
|
||||
ERR_FAIL_COND(!Thread::is_main_thread());
|
||||
ERR_FAIL_COND(!p_navigation_mesh.is_valid());
|
||||
ERR_FAIL_COND(p_root_node == nullptr);
|
||||
ERR_FAIL_NULL(p_root_node);
|
||||
ERR_FAIL_COND(!p_root_node->is_inside_tree());
|
||||
ERR_FAIL_COND(!p_source_geometry_data.is_valid());
|
||||
|
||||
@ -714,7 +714,7 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation
|
||||
bake_state = "Creating heightfield..."; // step #3
|
||||
hf = rcAllocHeightfield();
|
||||
|
||||
ERR_FAIL_COND(!hf);
|
||||
ERR_FAIL_NULL(hf);
|
||||
ERR_FAIL_COND(!rcCreateHeightfield(&ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch));
|
||||
|
||||
bake_state = "Marking walkable triangles..."; // step #4
|
||||
@ -744,7 +744,7 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation
|
||||
|
||||
chf = rcAllocCompactHeightfield();
|
||||
|
||||
ERR_FAIL_COND(!chf);
|
||||
ERR_FAIL_NULL(chf);
|
||||
ERR_FAIL_COND(!rcBuildCompactHeightfield(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf, *chf));
|
||||
|
||||
rcFreeHeightField(hf);
|
||||
@ -769,17 +769,17 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation
|
||||
|
||||
cset = rcAllocContourSet();
|
||||
|
||||
ERR_FAIL_COND(!cset);
|
||||
ERR_FAIL_NULL(cset);
|
||||
ERR_FAIL_COND(!rcBuildContours(&ctx, *chf, cfg.maxSimplificationError, cfg.maxEdgeLen, *cset));
|
||||
|
||||
bake_state = "Creating polymesh..."; // step #9
|
||||
|
||||
poly_mesh = rcAllocPolyMesh();
|
||||
ERR_FAIL_COND(!poly_mesh);
|
||||
ERR_FAIL_NULL(poly_mesh);
|
||||
ERR_FAIL_COND(!rcBuildPolyMesh(&ctx, *cset, cfg.maxVertsPerPoly, *poly_mesh));
|
||||
|
||||
detail_mesh = rcAllocPolyMeshDetail();
|
||||
ERR_FAIL_COND(!detail_mesh);
|
||||
ERR_FAIL_NULL(detail_mesh);
|
||||
ERR_FAIL_COND(!rcBuildPolyMeshDetail(&ctx, *poly_mesh, *chf, cfg.detailSampleDist, cfg.detailSampleMaxError, *detail_mesh));
|
||||
|
||||
rcFreeCompactHeightfield(chf);
|
||||
|
@ -89,13 +89,13 @@ int NavRegion::get_connections_count() const {
|
||||
}
|
||||
|
||||
Vector3 NavRegion::get_connection_pathway_start(int p_connection_id) const {
|
||||
ERR_FAIL_COND_V(!map, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
ERR_FAIL_INDEX_V(p_connection_id, connections.size(), Vector3());
|
||||
return connections[p_connection_id].pathway_start;
|
||||
}
|
||||
|
||||
Vector3 NavRegion::get_connection_pathway_end(int p_connection_id) const {
|
||||
ERR_FAIL_COND_V(!map, Vector3());
|
||||
ERR_FAIL_NULL_V(map, Vector3());
|
||||
ERR_FAIL_INDEX_V(p_connection_id, connections.size(), Vector3());
|
||||
return connections[p_connection_id].pathway_end;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ void RaycastOcclusionCull::occluder_initialize(RID p_occluder) {
|
||||
|
||||
void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices) {
|
||||
Occluder *occluder = occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
|
||||
occluder->vertices = p_vertices;
|
||||
occluder->indices = p_indices;
|
||||
@ -242,7 +242,7 @@ void RaycastOcclusionCull::occluder_set_mesh(RID p_occluder, const PackedVector3
|
||||
|
||||
void RaycastOcclusionCull::free_occluder(RID p_occluder) {
|
||||
Occluder *occluder = occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
memdelete(occluder);
|
||||
occluder_owner.free(p_occluder);
|
||||
}
|
||||
@ -291,7 +291,7 @@ void RaycastOcclusionCull::scenario_set_instance(RID p_scenario, RID p_instance,
|
||||
|
||||
if (p_occluder.is_valid()) {
|
||||
Occluder *occluder = occluder_owner.get_or_null(p_occluder);
|
||||
ERR_FAIL_COND(!occluder);
|
||||
ERR_FAIL_NULL(occluder);
|
||||
occluder->users.insert(InstanceID(p_scenario, p_instance));
|
||||
}
|
||||
changed = true;
|
||||
@ -398,7 +398,7 @@ void RaycastOcclusionCull::Scenario::_commit_scene(void *p_ud) {
|
||||
}
|
||||
|
||||
bool RaycastOcclusionCull::Scenario::update() {
|
||||
ERR_FAIL_COND_V(singleton == nullptr, false);
|
||||
ERR_FAIL_NULL_V(singleton, false);
|
||||
|
||||
if (commit_thread == nullptr) {
|
||||
commit_thread = memnew(Thread);
|
||||
@ -492,7 +492,7 @@ void RaycastOcclusionCull::Scenario::_raycast(uint32_t p_idx, const RaycastThrea
|
||||
}
|
||||
|
||||
void RaycastOcclusionCull::Scenario::raycast(CameraRayTile *r_rays, const uint32_t *p_valid_masks, uint32_t p_tile_count) const {
|
||||
ERR_FAIL_COND(singleton == nullptr);
|
||||
ERR_FAIL_NULL(singleton);
|
||||
if (raycast_singleton->ebr_device == nullptr) {
|
||||
return; // Embree is initialized on demand when there is some scenario with occluders in it.
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -242,14 +242,14 @@ Ref<UPNPDevice> UPNP::get_device(int index) const {
|
||||
}
|
||||
|
||||
void UPNP::add_device(Ref<UPNPDevice> device) {
|
||||
ERR_FAIL_COND(device == nullptr);
|
||||
ERR_FAIL_NULL(device);
|
||||
|
||||
devices.push_back(device);
|
||||
}
|
||||
|
||||
void UPNP::set_device(int index, Ref<UPNPDevice> device) {
|
||||
ERR_FAIL_INDEX(index, devices.size());
|
||||
ERR_FAIL_COND(device == nullptr);
|
||||
ERR_FAIL_NULL(device);
|
||||
|
||||
devices.set(index, device);
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ ssize_t WSLPeer::_wsl_send_callback(wslay_event_context_ptr ctx, const uint8_t *
|
||||
}
|
||||
|
||||
int WSLPeer::_wsl_genmask_callback(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, void *user_data) {
|
||||
ERR_FAIL_COND_V(!_static_rng, WSLAY_ERR_CALLBACK_FAILURE);
|
||||
ERR_FAIL_NULL_V(_static_rng, WSLAY_ERR_CALLBACK_FAILURE);
|
||||
Error err = _static_rng->get_random_bytes(buf, len);
|
||||
ERR_FAIL_COND_V(err != OK, WSLAY_ERR_CALLBACK_FAILURE);
|
||||
return 0;
|
||||
@ -676,7 +676,7 @@ void WSLPeer::poll() {
|
||||
}
|
||||
|
||||
if (ready_state == STATE_OPEN || ready_state == STATE_CLOSING) {
|
||||
ERR_FAIL_COND(!wsl_ctx);
|
||||
ERR_FAIL_NULL(wsl_ctx);
|
||||
int err = 0;
|
||||
if ((err = wslay_event_recv(wsl_ctx)) != 0 || (err = wslay_event_send(wsl_ctx)) != 0) {
|
||||
// Error close.
|
||||
|
@ -1763,37 +1763,37 @@ void DisplayServerMacOS::global_menu_clear(const String &p_menu_root) {
|
||||
}
|
||||
|
||||
bool DisplayServerMacOS::tts_is_speaking() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts isSpeaking];
|
||||
}
|
||||
|
||||
bool DisplayServerMacOS::tts_is_paused() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts isPaused];
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> DisplayServerMacOS::tts_get_voices() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, Array(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, Array(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts getVoices];
|
||||
}
|
||||
|
||||
void DisplayServerMacOS::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts speak:p_text voice:p_voice volume:p_volume pitch:p_pitch rate:p_rate utterance_id:p_utterance_id interrupt:p_interrupt];
|
||||
}
|
||||
|
||||
void DisplayServerMacOS::tts_pause() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts pauseSpeaking];
|
||||
}
|
||||
|
||||
void DisplayServerMacOS::tts_resume() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts resumeSpeaking];
|
||||
}
|
||||
|
||||
void DisplayServerMacOS::tts_stop() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts stopSpeaking];
|
||||
}
|
||||
|
||||
|
@ -2407,7 +2407,7 @@ void DisplayServerWindows::set_native_icon(const String &p_filename) {
|
||||
f->seek(pos);
|
||||
f->get_buffer((uint8_t *)&data_big.write[0], bytecount_big);
|
||||
HICON icon_big = CreateIconFromResource((PBYTE)&data_big.write[0], bytecount_big, TRUE, 0x00030000);
|
||||
ERR_FAIL_COND_MSG(!icon_big, "Could not create " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
|
||||
ERR_FAIL_NULL_MSG(icon_big, "Could not create " + itos(big_icon_width) + "x" + itos(big_icon_width) + " @" + itos(big_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
|
||||
|
||||
// Read the small icon.
|
||||
DWORD bytecount_small = icon_dir->idEntries[small_icon_index].dwBytesInRes;
|
||||
@ -2417,7 +2417,7 @@ void DisplayServerWindows::set_native_icon(const String &p_filename) {
|
||||
f->seek(pos);
|
||||
f->get_buffer((uint8_t *)&data_small.write[0], bytecount_small);
|
||||
HICON icon_small = CreateIconFromResource((PBYTE)&data_small.write[0], bytecount_small, TRUE, 0x00030000);
|
||||
ERR_FAIL_COND_MSG(!icon_small, "Could not create 16x16 @" + itos(small_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
|
||||
ERR_FAIL_NULL_MSG(icon_small, "Could not create 16x16 @" + itos(small_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
|
||||
|
||||
// Online tradition says to be sure last error is cleared and set the small icon first.
|
||||
int err = 0;
|
||||
|
2
thirdparty/enet/godot.cpp
vendored
2
thirdparty/enet/godot.cpp
vendored
@ -484,7 +484,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 == nullptr, -1);
|
||||
ERR_FAIL_NULL_V(address, -1);
|
||||
|
||||
ENetGodotSocket *sock = (ENetGodotSocket *)socket;
|
||||
IPAddress dest;
|
||||
|
Loading…
Reference in New Issue
Block a user