Skip to content

Commit

Permalink
Merge pull request #82313 from AThousandShips/null_check_servers
Browse files Browse the repository at this point in the history
[Servers] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
  • Loading branch information
akien-mga committed Sep 26, 2023
2 parents a4bca12 + fdd3d36 commit 2c8c7b9
Show file tree
Hide file tree
Showing 48 changed files with 1,105 additions and 1,105 deletions.
2 changes: 1 addition & 1 deletion editor/plugins/gradient_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ bool EditorInspectorPluginGradient::can_handle(Object *p_object) {

void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
Gradient *gradient = Object::cast_to<Gradient>(p_object);
ERR_FAIL_COND(!gradient);
ERR_FAIL_NULL(gradient);
Ref<Gradient> g(gradient);

GradientEditor *editor = memnew(GradientEditor);
Expand Down
6 changes: 3 additions & 3 deletions servers/audio_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void AudioServer::_mix_step() {
}

AudioStreamPlaybackBusDetails *ptr = playback->bus_details.load();
ERR_FAIL_COND(ptr == nullptr);
ERR_FAIL_NULL(ptr);
// By putting null into the bus details pointers, we're taking ownership of their memory for the duration of this mix.
AudioStreamPlaybackBusDetails bus_details = *ptr;

Expand Down Expand Up @@ -620,8 +620,8 @@ void AudioServer::_mix_step_for_channel(AudioFrame *p_out_buf, AudioFrame *p_sou
filter.set_stages(1);
filter.set_gain(p_highshelf_gain);

ERR_FAIL_COND(p_processor_l == nullptr);
ERR_FAIL_COND(p_processor_r == nullptr);
ERR_FAIL_NULL(p_processor_l);
ERR_FAIL_NULL(p_processor_r);

bool is_just_started = p_vol_start.l == 0 && p_vol_start.r == 0;
p_processor_l->set_filter(&filter, /* clear_history= */ is_just_started);
Expand Down
2 changes: 1 addition & 1 deletion servers/debugger/servers_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void ServersDebugger::deinitialize() {
}

Error ServersDebugger::_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) {
ERR_FAIL_COND_V(!singleton, ERR_BUG);
ERR_FAIL_NULL_V(singleton, ERR_BUG);
r_captured = true;
if (p_cmd == "memory") {
singleton->_send_resource_usage();
Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d/godot_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
// Add default gravity and damping from space area.
if (!stopped) {
GodotArea2D *default_area = get_space()->get_default_area();
ERR_FAIL_COND(!default_area);
ERR_FAIL_NULL(default_area);

if (!gravity_done) {
Vector2 default_gravity;
Expand Down
2 changes: 1 addition & 1 deletion servers/physics_2d/godot_broad_phase_2d_bvh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void GodotBroadPhase2DBVH::remove(ID p_id) {
GodotCollisionObject2D *GodotBroadPhase2DBVH::get_object(ID p_id) const {
ERR_FAIL_COND_V(!p_id, nullptr);
GodotCollisionObject2D *it = bvh.get(p_id - 1);
ERR_FAIL_COND_V(!it, nullptr);
ERR_FAIL_NULL_V(it, nullptr);
return it;
}

Expand Down
4 changes: 2 additions & 2 deletions servers/physics_2d/godot_collision_solver_2d_sat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
int version_B = (pointcount_B > 2 ? 2 : pointcount_B) - 1;

GenerateContactsFunc contacts_func = generate_contacts_func_table[version_A][version_B];
ERR_FAIL_COND(!contacts_func);
ERR_FAIL_NULL(contacts_func);
contacts_func(points_A, pointcount_A, points_B, pointcount_B, p_collector);
}

Expand Down Expand Up @@ -1396,7 +1396,7 @@ bool sat_2d_calculate_penetration(const GodotShape2D *p_shape_A, const Transform
}
}

ERR_FAIL_COND_V(!collision_func, false);
ERR_FAIL_NULL_V(collision_func, false);

collision_func(A, *transform_A, B, *transform_B, &callback, *motion_A, *motion_B, margin_A, margin_B);

Expand Down
4 changes: 2 additions & 2 deletions servers/physics_2d/godot_joints_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool GodotPinJoint2D::setup(real_t p_step) {
}

GodotSpace2D *space = A->get_space();
ERR_FAIL_COND_V(!space, false);
ERR_FAIL_NULL_V(space, false);

rA = A->get_transform().basis_xform(anchor_A);
rB = B ? B->get_transform().basis_xform(anchor_B) : anchor_B;
Expand Down Expand Up @@ -391,7 +391,7 @@ bool GodotGrooveJoint2D::setup(real_t p_step) {
}

GodotSpace2D *space = A->get_space();
ERR_FAIL_COND_V(!space, false);
ERR_FAIL_NULL_V(space, false);

// calculate endpoints in worldspace
Vector2 ta = A->get_transform().xform(A_groove_1);
Expand Down
Loading

0 comments on commit 2c8c7b9

Please sign in to comment.