Ported: Visual/Physics/Navigation Servers validate RIDs with documentation update - tinmanjuggernaut

2be0738304
This commit is contained in:
Relintai 2022-08-19 02:52:31 +02:00
parent 1b503ad711
commit 2a13c65298
4 changed files with 29 additions and 7 deletions

View File

@ -566,6 +566,11 @@ COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_
}
COMMAND_1(free, RID, p_object) {
if (!p_object.is_valid()) {
ERR_FAIL_MSG("Invalid RID.");
return;
}
if (map_owner.owns(p_object)) {
NavMap *map = map_owner.getornull(p_object);
@ -614,7 +619,7 @@ COMMAND_1(free, RID, p_object) {
memdelete(agent);
} else {
ERR_FAIL_COND("Invalid ID.");
ERR_FAIL_COND("Invalid RID.");
}
}

View File

@ -33,9 +33,9 @@
#include "broad_phase_basic.h"
#include "broad_phase_bvh.h"
#include "broad_phase_octree.h"
#include "core/os/os.h"
#include "core/config/project_settings.h"
#include "core/object/script_language.h"
#include "core/os/os.h"
#include "joints/cone_twist_joint_sw.h"
#include "joints/generic_6dof_joint_sw.h"
#include "joints/hinge_joint_sw.h"
@ -1199,6 +1199,11 @@ bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_a
}
void PhysicsServerSW::free(RID p_rid) {
if (!p_rid.is_valid()) {
ERR_FAIL_MSG("Invalid RID.");
return;
}
_update_shapes(); //just in case
if (shape_owner.owns(p_rid)) {
@ -1271,7 +1276,7 @@ void PhysicsServerSW::free(RID p_rid) {
memdelete(joint);
} else {
ERR_FAIL_MSG("Invalid ID.");
ERR_FAIL_MSG("Invalid RID.");
}
};

View File

@ -33,9 +33,9 @@
#include "broad_phase_2d_bvh.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
#include "core/os/os.h"
#include "core/config/project_settings.h"
#include "core/object/script_language.h"
#include "core/os/os.h"
#define FLUSH_QUERY_CHECK(m_object) \
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
@ -1121,6 +1121,11 @@ Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const
}
void Physics2DServerSW::free(RID p_rid) {
if (!p_rid.is_valid()) {
ERR_FAIL_MSG("Invalid RID.");
return;
}
_update_shapes(); // just in case
if (shape_owner.owns(p_rid)) {
@ -1188,7 +1193,7 @@ void Physics2DServerSW::free(RID p_rid) {
memdelete(joint);
} else {
ERR_FAIL_MSG("Invalid ID.");
ERR_FAIL_MSG("Invalid RID.");
}
};

View File

@ -30,10 +30,10 @@
#include "visual_server_raster.h"
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "core/config/project_settings.h"
#include "core/containers/sort_array.h"
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "visual_server_canvas.h"
#include "visual_server_globals.h"
#include "visual_server_scene.h"
@ -65,6 +65,11 @@ void VisualServerRaster::_draw_margins() {
/* FREE */
void VisualServerRaster::free(RID p_rid) {
if (!p_rid.is_valid()) {
ERR_FAIL_MSG("Invalid RID.");
return;
}
if (VSG::storage->free(p_rid)) {
return;
}
@ -80,6 +85,8 @@ void VisualServerRaster::free(RID p_rid) {
if (VSG::scene_render->free(p_rid)) {
return;
}
ERR_FAIL_MSG("Invalid RID.");
}
/* EVENT QUEUING */