Improved readability for failing error conditions

This commit is contained in:
Duroxxigar 2021-09-02 22:30:04 -04:00
parent c39d31899a
commit 54d305eebe
4 changed files with 6 additions and 6 deletions

View File

@ -489,7 +489,7 @@ NavigationMeshGenerator::~NavigationMeshGenerator() {
} }
void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) { void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) {
ERR_FAIL_COND(!p_nav_mesh.is_valid()); ERR_FAIL_COND_MSG(!p_nav_mesh.is_valid(), "Invalid navigation mesh.");
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorProgress *ep(nullptr); EditorProgress *ep(nullptr);

View File

@ -184,7 +184,7 @@ Vector2 NavigationAgent2D::get_target_location() const {
Vector2 NavigationAgent2D::get_next_location() { Vector2 NavigationAgent2D::get_next_location() {
update_navigation(); update_navigation();
if (navigation_path.size() == 0) { if (navigation_path.size() == 0) {
ERR_FAIL_COND_V(agent_parent == nullptr, Vector2()); ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector2(), "The agent has no parent.");
return agent_parent->get_global_position(); return agent_parent->get_global_position();
} else { } else {
return navigation_path[nav_path_index]; return navigation_path[nav_path_index];
@ -192,7 +192,7 @@ Vector2 NavigationAgent2D::get_next_location() {
} }
real_t NavigationAgent2D::distance_to_target() const { real_t NavigationAgent2D::distance_to_target() const {
ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
return agent_parent->get_global_position().distance_to(target_location); return agent_parent->get_global_position().distance_to(target_location);
} }

View File

@ -192,7 +192,7 @@ Vector3 NavigationAgent3D::get_target_location() const {
Vector3 NavigationAgent3D::get_next_location() { Vector3 NavigationAgent3D::get_next_location() {
update_navigation(); update_navigation();
if (navigation_path.size() == 0) { if (navigation_path.size() == 0) {
ERR_FAIL_COND_V(agent_parent == nullptr, Vector3()); ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector3(), "The agent has no parent.");
return agent_parent->get_global_transform().origin; return agent_parent->get_global_transform().origin;
} else { } else {
return navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0); return navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0);
@ -200,7 +200,7 @@ Vector3 NavigationAgent3D::get_next_location() {
} }
real_t NavigationAgent3D::distance_to_target() const { real_t NavigationAgent3D::distance_to_target() const {
ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
return agent_parent->get_global_transform().origin.distance_to(target_location); return agent_parent->get_global_transform().origin.distance_to(target_location);
} }

View File

@ -162,7 +162,7 @@ void _bake_navigation_mesh(void *p_user_data) {
} }
void NavigationRegion3D::bake_navigation_mesh() { void NavigationRegion3D::bake_navigation_mesh() {
ERR_FAIL_COND(bake_thread.is_started()); ERR_FAIL_COND_MSG(bake_thread.is_started(), "Unable to start another bake request. The navigation mesh bake thread is already baking a navigation mesh.");
BakeThreadsArgs *args = memnew(BakeThreadsArgs); BakeThreadsArgs *args = memnew(BakeThreadsArgs);
args->nav_region = this; args->nav_region = this;