summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp9
-rw-r--r--modules/bmp/image_loader_bmp.cpp4
-rw-r--r--modules/bullet/bullet_physics_server.cpp3
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp6
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp9
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp6
-rw-r--r--modules/bullet/pin_joint_bullet.cpp3
-rw-r--r--modules/bullet/shape_bullet.cpp3
-rw-r--r--modules/bullet/space_bullet.cpp14
-rw-r--r--modules/bullet/space_bullet.h2
-rw-r--r--modules/dds/texture_loader_dds.cpp10
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp11
-rw-r--r--modules/etc/texture_loader_pkm.cpp3
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp3
-rw-r--r--modules/gdnative/gdnative.cpp3
-rw-r--r--modules/gdnative/gdnative_builders.py2
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp74
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp45
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp25
-rw-r--r--modules/gdscript/gdscript.cpp33
-rw-r--r--modules/gdscript/gdscript_compiler.cpp6
-rw-r--r--modules/gdscript/gdscript_function.cpp9
-rw-r--r--modules/gdscript/gdscript_functions.cpp3
-rw-r--r--modules/gdscript/gdscript_parser.cpp19
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp9
-rw-r--r--modules/gdscript/register_types.cpp4
-rw-r--r--modules/gridmap/grid_map.cpp6
-rw-r--r--modules/hdr/image_loader_hdr.cpp5
-rw-r--r--modules/mono/.gitignore2
-rw-r--r--modules/mono/csharp_script.cpp115
-rw-r--r--modules/mono/editor/bindings_generator.cpp123
-rw-r--r--modules/mono/editor/bindings_generator.h2
-rw-r--r--modules/mono/editor/csharp_project.cpp10
-rw-r--r--modules/mono/editor/godotsharp_export.cpp13
-rw-r--r--modules/mono/editor/script_class_parser.cpp18
-rw-r--r--modules/mono/glue/Managed/Files/AABB.cs3
-rw-r--r--modules/mono/glue/Managed/Files/Basis.cs78
-rw-r--r--modules/mono/glue/Managed/Files/Color.cs30
-rw-r--r--modules/mono/glue/Managed/Files/Mathf.cs8
-rw-r--r--modules/mono/glue/Managed/Files/Plane.cs3
-rw-r--r--modules/mono/glue/Managed/Files/Quat.cs1
-rw-r--r--modules/mono/glue/Managed/Files/Rect2.cs1
-rw-r--r--modules/mono/glue/Managed/Files/Transform.cs1
-rw-r--r--modules/mono/glue/Managed/Files/Transform2D.cs1
-rw-r--r--modules/mono/glue/Managed/Files/Vector2.cs1
-rw-r--r--modules/mono/glue/Managed/Files/Vector3.cs1
-rw-r--r--modules/mono/glue/gd_glue.cpp5
-rw-r--r--modules/mono/godotsharp_defs.h4
-rw-r--r--modules/mono/icons/icon_c_#.svg5
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp118
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp10
-rw-r--r--modules/mono/mono_gd/gd_mono_class.cpp8
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp14
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp9
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp21
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp20
-rw-r--r--modules/mono/signal_awaiter_utils.cpp6
-rw-r--r--modules/mono/utils/string_utils.cpp5
-rw-r--r--modules/opus/audio_stream_opus.cpp3
-rw-r--r--modules/pvr/texture_loader_pvr.cpp3
-rw-r--r--modules/squish/image_compress_squish.cpp3
-rw-r--r--modules/svg/image_loader_svg.cpp6
-rw-r--r--modules/tinyexr/image_saver_tinyexr.cpp279
-rw-r--r--modules/tinyexr/image_saver_tinyexr.h38
-rw-r--r--modules/tinyexr/register_types.cpp5
-rw-r--r--modules/visual_script/visual_script.cpp31
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp14
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp3
-rw-r--r--modules/webm/video_stream_webm.cpp3
-rw-r--r--modules/webp/image_loader_webp.cpp3
-rw-r--r--modules/webrtc/webrtc_data_channel_js.cpp6
-rw-r--r--modules/webrtc/webrtc_multiplayer.cpp6
-rw-r--r--modules/webrtc/webrtc_peer_connection_gdnative.cpp6
-rw-r--r--modules/websocket/emws_peer.cpp6
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp15
-rw-r--r--modules/websocket/wsl_client.cpp33
-rw-r--r--modules/websocket/wsl_server.cpp30
78 files changed, 761 insertions, 699 deletions
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 65fa8b6459..05f9120a07 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -150,8 +150,7 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f
0;
const aiScene *scene = importer.ReadFile(s_path.c_str(),
post_process_Steps);
- ERR_EXPLAIN(String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
- ERR_FAIL_COND_V(scene == NULL, NULL);
+ ERR_FAIL_COND_V_MSG(scene == NULL, NULL, String("Open Asset Import failed to open: ") + String(importer.GetErrorString()) + ".");
return _generate_scene(p_path, scene, p_flags, p_bake_fps, max_bone_weights);
}
@@ -348,8 +347,7 @@ void EditorSceneImporterAssimp::_fill_node_relationships(ImportState &state, con
} else if (ownership[name] != p_skeleton_id) {
//oh, it's from another skeleton? fine.. reparent all bones to this skeleton.
int prev_owner = ownership[name];
- ERR_EXPLAIN("A previous skeleton exists for bone '" + name + "', this type of skeleton layout is unsupported.");
- ERR_FAIL_COND(skeleton_map.has(prev_owner));
+ ERR_FAIL_COND_MSG(skeleton_map.has(prev_owner), "A previous skeleton exists for bone '" + name + "', this type of skeleton layout is unsupported.");
for (Map<String, int>::Element *E = ownership.front(); E; E = E->next()) {
if (E->get() == prev_owner) {
E->get() = p_skeleton_id;
@@ -779,8 +777,7 @@ Ref<Texture> EditorSceneImporterAssimp::_load_texture(ImportState &state, String
t->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
return t;
} else if (tex->CheckFormat("dds")) {
- ERR_EXPLAIN("Open Asset Import: Embedded dds not implemented");
- ERR_FAIL_COND_V(true, Ref<Texture>());
+ ERR_FAIL_V_MSG(Ref<Texture>(), "Open Asset Import: Embedded dds not implemented.");
//Ref<Image> img = Image::_dds_mem_loader_func((uint8_t *)tex->pcData, tex->mWidth);
//ERR_FAIL_COND_V(img.is_null(), Ref<Texture>());
//Ref<ImageTexture> t;
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 88732dff33..5a32fa1c2c 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -241,9 +241,9 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
case BI_CMYKRLE8:
case BI_CMYKRLE4: {
// Stop parsing
- ERR_EXPLAIN("Compressed BMP files are not supported: " + f->get_path());
+ String bmp_path = f->get_path();
f->close();
- ERR_FAIL_V(ERR_UNAVAILABLE);
+ ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Compressed BMP files are not supported: " + bmp_path + ".");
} break;
}
// Don't rely on sizeof(bmp_file_header) as structure padding
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 038001996d..e01928191a 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -1548,8 +1548,7 @@ void BulletPhysicsServer::free(RID p_rid) {
bulletdelete(space);
} else {
- ERR_EXPLAIN("Invalid ID");
- ERR_FAIL();
+ ERR_FAIL_MSG("Invalid ID.");
}
}
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index bc7fd52cf6..97b9a81f77 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -83,8 +83,7 @@ void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param,
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value);
break;
default:
- ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
break;
}
}
@@ -102,8 +101,7 @@ real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_para
case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
return coneConstraint->getRelaxationFactor();
default:
- ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
return 0;
}
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 0d2c46c579..4aae87c220 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -174,8 +174,7 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value;
break;
default:
- ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
break;
}
}
@@ -216,8 +215,7 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6
case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint;
default:
- ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
return 0;
}
}
@@ -255,8 +253,7 @@ void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOF
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
break;
default:
- ERR_EXPLAIN("This flag " + itos(p_flag) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The flag " + itos(p_flag) + " is deprecated.");
break;
}
}
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index b7e1e1a4c2..4d26e729db 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -117,8 +117,7 @@ void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t
hingeConstraint->setMaxMotorImpulse(p_value);
break;
default:
- ERR_EXPLAIN("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
break;
}
}
@@ -143,8 +142,7 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const
case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return hingeConstraint->getMaxMotorImpulse();
default:
- ERR_EXPLAIN("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
return 0;
}
}
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index c9c4d1af7e..8d404e7f04 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -85,8 +85,7 @@ real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
return p2pConstraint->m_setting.m_impulseClamp;
default:
- ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
return 0;
}
}
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index f15bcec914..85f47c3bbb 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -505,8 +505,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
}
} else {
- ERR_EXPLAIN("Expected PoolRealArray or float Image.");
- ERR_FAIL();
+ ERR_FAIL_MSG("Expected PoolRealArray or float Image.");
}
ERR_FAIL_COND(l_width <= 0);
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index 9d632aaf83..d2b16b0fd1 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -581,10 +581,8 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) {
} else {
world_mem = malloc(sizeof(btDiscreteDynamicsWorld));
}
- if (!world_mem) {
- ERR_EXPLAIN("Out of memory");
- ERR_FAIL();
- }
+
+ ERR_FAIL_COND_MSG(!world_mem, "Out of memory.");
if (p_create_soft_world) {
collisionConfiguration = bulletnew(GodotSoftCollisionConfiguration(static_cast<btDiscreteDynamicsWorld *>(world_mem)));
@@ -1234,7 +1232,7 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
ERR_FAIL_COND_V(shape_idx < 0 || shape_idx >= cs->getNumChildShapes(), false);
if (cs->getChildShape(shape_idx)->isConvex()) {
- if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(cs->getChildShape(shape_idx)), otherObject, shape_idx, shape_transform, otherObject->getWorldTransform() * cs->getChildTransform(shape_idx), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
+ if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(cs->getChildShape(shape_idx)), otherObject, kinIndex, shape_idx, shape_transform, otherObject->getWorldTransform() * cs->getChildTransform(shape_idx), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
@@ -1245,7 +1243,7 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
}
}
} else if (otherObject->getCollisionShape()->isConvex()) { /// Execute GJK test against object shape
- if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(otherObject->getCollisionShape()), otherObject, 0, shape_transform, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
+ if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(otherObject->getCollisionShape()), otherObject, kinIndex, 0, shape_transform, otherObject->getWorldTransform(), p_recover_movement_scale, r_delta_recover_movement, r_recover_result)) {
penetration = true;
}
@@ -1261,7 +1259,7 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
return penetration;
}
-bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) {
+bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result) {
// Initialize GJK input
btGjkPairDetector::ClosestPointInput gjk_input;
@@ -1279,6 +1277,7 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt
if (r_recover_result) {
if (result.m_distance < r_recover_result->penetration_distance) {
r_recover_result->hasPenetration = true;
+ r_recover_result->local_shape_most_recovered = p_shapeId_A;
r_recover_result->other_collision_object = p_objectB;
r_recover_result->other_compound_shape_index = p_shapeId_B;
r_recover_result->penetration_distance = result.m_distance;
@@ -1314,6 +1313,7 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC
if (r_recover_result) {
if (contactPointResult.m_penetration_distance < r_recover_result->penetration_distance) {
r_recover_result->hasPenetration = true;
+ r_recover_result->local_shape_most_recovered = p_shapeId_A;
r_recover_result->other_collision_object = p_objectB;
r_recover_result->other_compound_shape_index = p_shapeId_B;
r_recover_result->penetration_distance = contactPointResult.m_penetration_distance;
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index eb4a065e54..ecf8a2db9d 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -208,7 +208,7 @@ private:
bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
/// This is an API that recover a kinematic object from penetration
/// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions
- bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
+ bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
/// This is an API that recover a kinematic object from penetration
/// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm
bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 4628bd9a5b..0220dcae4a 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -108,8 +108,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (r_error)
*r_error = ERR_FILE_CORRUPT;
- ERR_EXPLAIN("Unable to open DDS texture file: " + p_path);
- ERR_FAIL_COND_V(err != OK, RES());
+ ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open DDS texture file: " + p_path + ".");
uint32_t magic = f->get_32();
uint32_t hsize = f->get_32();
@@ -128,8 +127,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (magic != DDS_MAGIC || hsize != 124 || !(flags & DDSD_PIXELFORMAT) || !(flags & DDSD_CAPS)) {
- ERR_EXPLAIN("Invalid or Unsupported DDS texture file: " + p_path);
- ERR_FAIL_V(RES());
+ ERR_FAIL_V_MSG(RES(), "Invalid or unsupported DDS texture file: " + p_path + ".");
}
/* uint32_t format_size = */ f->get_32();
@@ -218,9 +216,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
} else {
printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask);
- ERR_EXPLAIN("Unrecognized or Unsupported color layout in DDS: " + p_path);
-
- ERR_FAIL_V(RES());
+ ERR_FAIL_V_MSG(RES(), "Unrecognized or unsupported color layout in DDS: " + p_path + ".");
}
if (!(flags & DDSD_MIPMAPCOUNT))
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index a5a356ced2..44f69ca261 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -543,10 +543,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
if (target_peer != 0) {
E = peer_map.find(ABS(target_peer));
- if (!E) {
- ERR_EXPLAIN("Invalid Target Peer: " + itos(target_peer));
- ERR_FAIL_V(ERR_INVALID_PARAMETER);
- }
+ ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer: " + itos(target_peer) + ".");
}
ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags);
@@ -794,11 +791,7 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const {
void NetworkedMultiplayerENet::set_transfer_channel(int p_channel) {
ERR_FAIL_COND(p_channel < -1 || p_channel >= channel_count);
-
- if (p_channel == SYSCH_CONFIG) {
- ERR_EXPLAIN("Channel " + itos(SYSCH_CONFIG) + " is reserved");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(p_channel == SYSCH_CONFIG, "Channel " + itos(SYSCH_CONFIG) + " is reserved.");
transfer_channel = p_channel;
}
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index ff925480b8..3337460dfc 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -56,8 +56,7 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
if (r_error)
*r_error = ERR_FILE_CORRUPT;
- ERR_EXPLAIN("Unable to open PKM texture file: " + p_path);
- ERR_FAIL_COND_V(err != OK, RES());
+ ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file: " + p_path + ".");
// big endian
f->set_endian_swap(true);
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index 64e2c362b2..bd6eb575d0 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -245,8 +245,7 @@ extern "C" {
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface) {
// If our major version is 0 or bigger then 10, we're likely looking at our constructor pointer from an older plugin
- ERR_EXPLAINC("GDNative ARVR interfaces build for Godot 3.0 are not supported");
- ERR_FAIL_COND((p_interface->version.major == 0) || (p_interface->version.major > 10));
+ ERR_FAIL_COND_MSG((p_interface->version.major == 0) || (p_interface->version.major > 10), "GDNative ARVR interfaces build for Godot 3.0 are not supported.");
Ref<ARVRInterfaceGDNative> new_interface;
new_interface.instance();
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 4eb9a2a0a3..783ad4e147 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -268,8 +268,7 @@ void GDNative::_bind_methods() {
}
void GDNative::set_library(Ref<GDNativeLibrary> p_library) {
- ERR_EXPLAIN("Tried to change library of GDNative when it is already set");
- ERR_FAIL_COND(library.is_valid());
+ ERR_FAIL_COND_MSG(library.is_valid(), "Tried to change library of GDNative when it is already set.");
library = p_library;
}
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 7ab0e01108..20c1a2233c 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -185,7 +185,7 @@ def _build_gdnative_api_struct_source(api):
'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {',
'\tGDNATIVE_' + core['type'] + ',',
'\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},',
- '\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['version']['major'], core['version']['minor']))) + ','
+ '\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['next']['version']['major'], core['next']['version']['minor']))) + ','
]
for funcdef in core['api']:
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index 863999d6d4..979e47f7b9 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -104,11 +104,7 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to register method on non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Method method;
method.method = p_method;
@@ -123,11 +119,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to register method on non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Property property;
property.default_value = *(Variant *)&p_attr->default_value;
@@ -148,11 +140,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to register method on non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
List<PropertyInfo> args;
Vector<Variant> default_args;
@@ -213,17 +201,10 @@ void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_h
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to add argument information for a method on a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
- if (!method) {
- ERR_EXPLAIN("Attempted to add argument information to non-existent method!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method.");
MethodInfo *method_information = &method->get().info;
@@ -247,11 +228,7 @@ void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, c
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to add documentation to a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class.");
E->get().documentation = *(String *)&p_documentation;
}
@@ -260,17 +237,10 @@ void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle,
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to add documentation to a method on a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
- if (!method) {
- ERR_EXPLAIN("Attempted to add documentatino to non-existent method!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method.");
method->get().documentation = *(String *)&p_documentation;
}
@@ -279,17 +249,10 @@ void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to add documentation to a property on a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class.");
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path);
- if (!property) {
- ERR_EXPLAIN("Attempted to add documentation to non-existent property!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!property, "Attempted to add documentation to non-existent property.");
property.get().documentation = *(String *)&p_documentation;
}
@@ -298,17 +261,10 @@ void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle,
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to add documentation to a signal on a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class.");
Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name);
- if (!signal) {
- ERR_EXPLAIN("Attempted to add documentation to non-existent signal!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal.");
signal->get().documentation = *(String *)&p_documentation;
}
@@ -325,11 +281,7 @@ void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
-
- if (!E) {
- ERR_EXPLAIN("Attempted to set type tag on a non-existent class!");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class.");
E->get().type_tag = p_type_tag;
}
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index f30c9da4c1..9f7c3880ec 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -402,10 +402,7 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
String NativeScript::get_class_documentation() const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data) {
- ERR_EXPLAIN("Attempt to get class documentation on invalid NativeScript");
- ERR_FAIL_V("");
- }
+ ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get class documentation on invalid NativeScript.");
return script_data->documentation;
}
@@ -413,10 +410,7 @@ String NativeScript::get_class_documentation() const {
String NativeScript::get_method_documentation(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data) {
- ERR_EXPLAIN("Attempt to get method documentation on invalid NativeScript");
- ERR_FAIL_V("");
- }
+ ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript.");
while (script_data) {
@@ -429,17 +423,13 @@ String NativeScript::get_method_documentation(const StringName &p_method) const
script_data = script_data->base_data;
}
- ERR_EXPLAIN("Attempt to get method documentation for non-existent method");
- ERR_FAIL_V("");
+ ERR_FAIL_V_MSG("", "Attempt to get method documentation for non-existent method.");
}
String NativeScript::get_signal_documentation(const StringName &p_signal_name) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data) {
- ERR_EXPLAIN("Attempt to get signal documentation on invalid NativeScript");
- ERR_FAIL_V("");
- }
+ ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript.");
while (script_data) {
@@ -452,17 +442,13 @@ String NativeScript::get_signal_documentation(const StringName &p_signal_name) c
script_data = script_data->base_data;
}
- ERR_EXPLAIN("Attempt to get signal documentation for non-existent signal");
- ERR_FAIL_V("");
+ ERR_FAIL_V_MSG("", "Attempt to get signal documentation for non-existent signal.");
}
String NativeScript::get_property_documentation(const StringName &p_path) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data) {
- ERR_EXPLAIN("Attempt to get property documentation on invalid NativeScript");
- ERR_FAIL_V("");
- }
+ ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get property documentation on invalid NativeScript.");
while (script_data) {
@@ -475,8 +461,7 @@ String NativeScript::get_property_documentation(const StringName &p_path) const
script_data = script_data->base_data;
}
- ERR_EXPLAIN("Attempt to get property documentation for non-existent signal");
- ERR_FAIL_V("");
+ ERR_FAIL_V_MSG("", "Attempt to get property documentation for non-existent signal.");
}
Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
@@ -655,10 +640,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
Variant res = *(Variant *)&result;
godot_variant_destroy(&result);
- if (res.get_type() != Variant::ARRAY) {
- ERR_EXPLAIN("_get_property_list must return an array of dictionaries");
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(res.get_type() != Variant::ARRAY, "_get_property_list must return an array of dictionaries.");
Array arr = res;
for (int i = 0; i < arr.size(); i++) {
@@ -780,8 +762,7 @@ String NativeScriptInstance::to_string(bool *r_valid) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
- ERR_EXPLAIN("Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
- ERR_FAIL_V(String());
+ ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
if (r_valid)
*r_valid = true;
@@ -1344,10 +1325,7 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL);
- if (!binding_functions[p_idx].first) {
- ERR_EXPLAIN("Tried to get binding data for a nativescript binding that does not exist");
- ERR_FAIL_V(NULL);
- }
+ ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, NULL, "Tried to get binding data for a nativescript binding that does not exist.");
Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
@@ -1499,8 +1477,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
#endif
// See if this library was "registered" already.
const String &lib_path = lib->get_current_library_path();
- ERR_EXPLAIN(lib->get_name() + " does not have a library for the current platform");
- ERR_FAIL_COND(lib_path.length() == 0);
+ ERR_FAIL_COND_MSG(lib_path.length() == 0, lib->get_name() + " does not have a library for the current platform.");
Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path);
if (!E) {
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 3ecb29404a..b82823ab64 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -35,16 +35,14 @@
#include "pluginscript_script.h"
#ifdef DEBUG_ENABLED
-#define __ASSERT_SCRIPT_REASON "Cannot retrieve pluginscript class for this script, is you code correct ?"
-#define ASSERT_SCRIPT_VALID() \
- { \
- ERR_EXPLAIN(__ASSERT_SCRIPT_REASON); \
- ERR_FAIL_COND(!can_instance()); \
+#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
+#define ASSERT_SCRIPT_VALID() \
+ { \
+ ERR_FAIL_COND_MSG(!can_instance(), __ASSERT_SCRIPT_REASON); \
}
-#define ASSERT_SCRIPT_VALID_V(ret) \
- { \
- ERR_EXPLAIN(__ASSERT_SCRIPT_REASON); \
- ERR_FAIL_COND_V(!can_instance(), ret); \
+#define ASSERT_SCRIPT_VALID_V(ret) \
+ { \
+ ERR_FAIL_COND_V_MSG(!can_instance(), ret, __ASSERT_SCRIPT_REASON); \
}
#else
#define ASSERT_SCRIPT_VALID()
@@ -197,8 +195,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
// if (ScriptDebugger::get_singleton()) {
// _language->debug_break_parse(get_path(), 0, msg);
// }
- ERR_EXPLAIN(msg);
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, msg);
}
}
@@ -272,8 +269,7 @@ Error PluginScript::reload(bool p_keep_state) {
_ref_base_parent = res;
} else {
String name = *(StringName *)&manifest.name;
- ERR_EXPLAIN(_path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'.");
- ERR_FAIL_V(ERR_PARSE_ERROR);
+ ERR_FAIL_V_MSG(ERR_PARSE_ERROR, _path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'.");
}
}
}
@@ -420,8 +416,7 @@ Error PluginScript::load_source_code(const String &p_path) {
String s;
if (s.parse_utf8((const char *)w.ptr())) {
- ERR_EXPLAIN("Script '" + p_path + "' contains invalid unicode (utf-8), so it was not loaded. Please ensure that scripts are saved in valid utf-8 unicode.");
- ERR_FAIL_V(ERR_INVALID_DATA);
+ ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
_source = s;
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index bc28f7009e..d929bdb3e5 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -67,10 +67,7 @@ void GDScriptNativeClass::_bind_methods() {
Variant GDScriptNativeClass::_new() {
Object *o = instance();
- if (!o) {
- ERR_EXPLAIN("Class type: '" + String(name) + "' is not instantiable.");
- ERR_FAIL_V(Variant());
- }
+ ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
Reference *ref = Object::cast_to<Reference>(o);
if (ref) {
@@ -158,8 +155,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
} else {
owner = memnew(Reference); //by default, no base means use reference
}
- ERR_EXPLAIN("Can't inherit from a virtual class");
- ERR_FAIL_COND_V(!owner, Variant());
+ ERR_FAIL_COND_V_MSG(!owner, Variant(), "Can't inherit from a virtual class.");
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
@@ -326,8 +322,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
if (ScriptDebugger::get_singleton()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 0, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
- ERR_EXPLAIN("Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
}
}
@@ -648,10 +643,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p
Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method);
if (E) {
- if (!E->get()->is_static()) {
- ERR_EXPLAIN("Can't call non-static function: '" + String(p_method) + "' in script.");
- ERR_FAIL_V(Variant());
- }
+ ERR_FAIL_COND_V_MSG(!E->get()->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script.");
return E->get()->call(NULL, p_args, p_argcount, r_error);
}
@@ -826,8 +818,7 @@ Error GDScript::load_source_code(const String &p_path) {
String s;
if (s.parse_utf8((const char *)w.ptr())) {
- ERR_EXPLAIN("Script '" + p_path + "' contains invalid unicode (utf-8), so it was not loaded. Please ensure that scripts are saved in valid utf-8 unicode.");
- ERR_FAIL_V(ERR_INVALID_DATA);
+ ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
source = s;
@@ -1079,11 +1070,8 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err);
if (err.error == Variant::CallError::CALL_OK) {
- if (ret.get_type() != Variant::ARRAY) {
+ ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
- ERR_EXPLAIN("Wrong type for _get_property list, must be an array of dictionaries.");
- ERR_FAIL();
- }
Array arr = ret;
for (int i = 0; i < arr.size(); i++) {
@@ -1243,8 +1231,7 @@ String GDScriptInstance::to_string(bool *r_valid) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
- ERR_EXPLAIN("Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
- ERR_FAIL_V(String());
+ ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
if (r_valid)
*r_valid = true;
@@ -2057,8 +2044,7 @@ String GDScriptWarning::get_message() const {
} break;
case WARNING_MAX: break; // Can't happen, but silences warning
}
- ERR_EXPLAIN("Invalid GDScript warning code: " + get_name_from_code(code));
- ERR_FAIL_V(String());
+ ERR_FAIL_V_MSG(String(), "Invalid GDScript warning code: " + get_name_from_code(code) + ".");
#undef CHECK_SYMBOLS
}
@@ -2110,8 +2096,7 @@ GDScriptWarning::Code GDScriptWarning::get_code_from_name(const String &p_name)
}
}
- ERR_EXPLAIN("Invalid GDScript warning name: " + p_name);
- ERR_FAIL_V(WARNING_MAX);
+ ERR_FAIL_V_MSG(WARNING_MAX, "Invalid GDScript warning name: " + p_name);
}
#endif // DEBUG_ENABLED
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 4c976bd2e0..7166189416 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1241,8 +1241,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
default: {
- ERR_EXPLAIN("Bug in bytecode compiler, unexpected operator #" + itos(on->op) + " in parse tree while parsing expression.");
- ERR_FAIL_V(0); //unreachable code
+ ERR_FAIL_V_MSG(0, "Bug in bytecode compiler, unexpected operator #" + itos(on->op) + " in parse tree while parsing expression."); //unreachable code
} break;
}
@@ -1255,8 +1254,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//TYPE_TYPE,
default: {
- ERR_EXPLAIN("Bug in bytecode compiler, unexpected node in parse tree while parsing expression.");
- ERR_FAIL_V(-1); //unreachable code
+ ERR_FAIL_V_MSG(-1, "Bug in bytecode compiler, unexpected node in parse tree while parsing expression."); //unreachable code
} break;
}
}
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 42f349ffc0..dc0e64fd03 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -86,8 +86,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
o = o->_owner;
}
- ERR_EXPLAIN("GDScriptCompiler bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "GDScriptCompiler bug.");
} break;
case ADDR_TYPE_LOCAL_CONSTANT: {
#ifdef DEBUG_ENABLED
@@ -128,8 +127,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
} break;
}
- ERR_EXPLAIN("Bad Code! (Addressing Mode)");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Bad code! (unknown addressing mode).");
return NULL;
}
@@ -1834,8 +1832,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
- ERR_FAIL_V(Variant());
+ ERR_FAIL_V_MSG(Variant(), "Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
#else
return Variant();
#endif
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index f5f245b25f..ad8bf5b2c0 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -349,8 +349,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
r_ret = Math::step_decimals((double)*p_args[0]);
- ERR_EXPLAIN("GDScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("GDScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
} break;
case MATH_STEP_DECIMALS: {
VALIDATE_ARG_COUNT(1);
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index f006d50a83..9a25e788c7 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -898,6 +898,10 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_IS && tokenizer->get_token(1) == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
// 'is' operator with built-in type
+ if (!expr) {
+ _set_error("Expected identifier before 'is' operator");
+ return NULL;
+ }
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_IS_BUILTIN;
op->arguments.push_back(expr);
@@ -1136,10 +1140,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
return NULL; //nothing
}
- if (!expr) {
- ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is...");
- ERR_FAIL_V(NULL);
- }
+ ERR_FAIL_COND_V_MSG(!expr, NULL, "GDScriptParser bug, couldn't figure out what expression is.");
/******************/
/* Parse Indexing */
@@ -3487,6 +3488,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
case GDScriptTokenizer::TK_PR_CLASS_NAME: {
+ _mark_line_as_safe(tokenizer->get_token_line());
if (p_class->owner) {
_set_error("'class_name' is only valid for the main class namespace.");
return;
@@ -4018,8 +4020,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
- ERR_EXPLAIN("Exporting bit flags hint requires string constants.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("Exporting bit flags hint requires string constants.");
break;
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
@@ -6694,8 +6695,7 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
}
if (!ClassDB::class_exists(native)) {
if (!check_types) return false;
- ERR_EXPLAIN("Parser bug: Class '" + String(native) + "' not found.");
- ERR_FAIL_V(false);
+ ERR_FAIL_V_MSG(false, "Parser bug: Class '" + String(native) + "' not found.");
}
MethodBind *method = ClassDB::get_method(native, p_function);
@@ -7203,8 +7203,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
}
if (!ClassDB::class_exists(native)) {
if (!check_types) return false;
- ERR_EXPLAIN("Parser bug: Class '" + String(native) + "' not found.");
- ERR_FAIL_V(false);
+ ERR_FAIL_V_MSG(false, "Parser bug: Class '" + String(native) + "' not found.");
}
bool valid = false;
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 59b53b5f9a..64b354bdb8 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -357,8 +357,7 @@ StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
}
}
}
- ERR_EXPLAIN("Failed to get token literal");
- ERR_FAIL_V("");
+ ERR_FAIL_V_MSG("", "Failed to get token literal.");
}
static bool _is_text_char(CharType c) {
@@ -1219,10 +1218,8 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
ERR_FAIL_COND_V(p_buffer.size() < 24 || p_buffer[0] != 'G' || p_buffer[1] != 'D' || p_buffer[2] != 'S' || p_buffer[3] != 'C', ERR_INVALID_DATA);
int version = decode_uint32(&buf[4]);
- if (version > BYTECODE_VERSION) {
- ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version.");
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
+ ERR_FAIL_COND_V_MSG(version > BYTECODE_VERSION, ERR_INVALID_DATA, "Bytecode is too recent! Please use a newer engine version.");
+
int identifier_count = decode_uint32(&buf[8]);
int constant_count = decode_uint32(&buf[12]);
int line_count = decode_uint32(&buf[16]);
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index b8a13ed91b..62117dcaf3 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -32,6 +32,7 @@
#include "core/io/file_access_encrypted.h"
#include "core/io/resource_loader.h"
+#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "editor/gdscript_highlighter.h"
#include "gdscript.h"
@@ -117,6 +118,9 @@ public:
file = FileAccess::get_file_as_array(tmp_path);
add_file(p_path.get_basename() + ".gde", file, true);
+ // Clean up temporary file.
+ DirAccess::remove_file_or_error(tmp_path);
+
} else {
add_file(p_path.get_basename() + ".gdc", file, true);
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index bdecbbdbad..b36afd4386 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -196,16 +196,14 @@ bool GridMap::get_collision_layer_bit(int p_bit) const {
#ifndef DISABLE_DEPRECATED
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
- ERR_EXPLAIN("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
set_mesh_library(p_theme);
}
Ref<MeshLibrary> GridMap::get_theme() const {
- ERR_EXPLAIN("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
return get_mesh_library();
}
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index f75a4a926a..e610619b54 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -102,10 +102,7 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
len <<= 8;
len |= f->get_8();
- if (len != width) {
- ERR_EXPLAIN("invalid decoded scanline length, corrupt HDR");
- ERR_FAIL_V(ERR_FILE_CORRUPT);
- }
+ ERR_FAIL_COND_V_MSG(len != width, ERR_FILE_CORRUPT, "Invalid decoded scanline length, corrupt HDR.");
for (int k = 0; k < 4; ++k) {
int i = 0;
diff --git a/modules/mono/.gitignore b/modules/mono/.gitignore
new file mode 100644
index 0000000000..fa6d00cbbb
--- /dev/null
+++ b/modules/mono/.gitignore
@@ -0,0 +1,2 @@
+# Do not ignore solution files inside the mono module. Overrides Godot's global gitignore.
+!*.sln
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 846c84d222..8c17bac3c9 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -115,7 +115,7 @@ void CSharpLanguage::init() {
gdmono->initialize();
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
- // Generate bindings here, before loading assemblies. `initialize_load_assemblies` aborts
+ // Generate bindings here, before loading assemblies. 'initialize_load_assemblies' aborts
// the applications if the api assemblies or the main tools assembly is missing, but this
// is not a problem for BindingsGenerator as it only needs the tools project editor assembly.
List<String> cmdline_args = OS::get_singleton()->get_cmdline_args();
@@ -123,7 +123,7 @@ void CSharpLanguage::init() {
#endif
#ifndef MONO_GLUE_ENABLED
- print_line("Run this binary with `--generate-mono-glue path/to/modules/mono/glue`");
+ print_line("Run this binary with '--generate-mono-glue path/to/modules/mono/glue'");
#endif
gdmono->initialize_load_assemblies();
@@ -1036,6 +1036,7 @@ void CSharpLanguage::_load_scripts_metadata() {
String old_json;
Error ferr = read_all_file_utf8(scripts_metadata_path, old_json);
+
ERR_FAIL_COND(ferr != OK);
Variant old_dict_var;
@@ -1043,7 +1044,7 @@ void CSharpLanguage::_load_scripts_metadata() {
int err_line;
Error json_err = JSON::parse(old_json, old_dict_var, err_str, err_line);
if (json_err != OK) {
- ERR_PRINTS("Failed to parse metadata file: '" + err_str + "' (" + String::num_int64(err_line) + ")");
+ ERR_PRINTS("Failed to parse metadata file: '" + err_str + "' (" + String::num_int64(err_line) + ").");
return;
}
@@ -1053,7 +1054,7 @@ void CSharpLanguage::_load_scripts_metadata() {
print_verbose("Successfully loaded scripts metadata");
} else {
if (!Engine::get_singleton()->is_editor_hint()) {
- ERR_PRINT("Missing scripts metadata file");
+ ERR_PRINT("Missing scripts metadata file.");
}
}
}
@@ -1768,12 +1769,8 @@ MonoObject *CSharpInstance::_internal_new_managed() {
// Search the constructor first, to fail with an error if it's not found before allocating anything else.
GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0);
- if (ctor == NULL) {
- ERR_PRINTS("Cannot create script instance because the class does not define a parameterless constructor: " + script->get_path());
-
- ERR_EXPLAIN("Constructor not found");
- ERR_FAIL_V(NULL);
- }
+ ERR_FAIL_NULL_V_MSG(ctor, NULL,
+ "Cannot create script instance because the class does not define a parameterless constructor: '" + script->get_path() + "'.");
CSharpLanguage::get_singleton()->release_script_gchandle(gchandle);
@@ -1792,8 +1789,7 @@ MonoObject *CSharpInstance::_internal_new_managed() {
owner = NULL;
- ERR_EXPLAIN("Failed to allocate memory for the object");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object.");
}
// Tie managed to unmanaged
@@ -2233,7 +2229,7 @@ bool CSharpScript::_update_exports() {
MonoObject *tmp_object = mono_object_new(mono_domain_get(), script_class->get_mono_ptr());
if (!tmp_object) {
- ERR_PRINT("Failed to allocate temporary MonoObject");
+ ERR_PRINT("Failed to allocate temporary MonoObject.");
return false;
}
@@ -2241,12 +2237,8 @@ bool CSharpScript::_update_exports() {
GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), 0);
- if (ctor == NULL) {
- ERR_PRINTS("Cannot construct temporary MonoObject because the class does not define a parameterless constructor: " + get_path());
-
- ERR_EXPLAIN("Constructor not found");
- ERR_FAIL_V(NULL);
- }
+ ERR_FAIL_NULL_V_MSG(ctor, NULL,
+ "Cannot construct temporary MonoObject because the class does not define a parameterless constructor: '" + get_path() + "'.");
MonoException *ctor_exc = NULL;
ctor->invoke(tmp_object, NULL, &ctor_exc);
@@ -2399,7 +2391,7 @@ bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Ve
arg.type = GDMonoMarshal::managed_to_variant_type(types[i]);
if (arg.type == Variant::NIL) {
- ERR_PRINTS("Unknown type of signal parameter: " + arg.name + " in " + p_class->get_full_name());
+ ERR_PRINTS("Unknown type of signal parameter: '" + arg.name + "' in '" + p_class->get_full_name() + "'.");
return false;
}
@@ -2427,7 +2419,7 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
if (p_member->is_static()) {
if (p_member->has_attribute(CACHED_CLASS(ExportAttribute)))
- ERR_PRINTS("Cannot export member because it is static: " + MEMBER_FULL_QUALIFIED_NAME(p_member));
+ ERR_PRINTS("Cannot export member because it is static: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
return false;
}
@@ -2450,12 +2442,12 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
GDMonoProperty *property = static_cast<GDMonoProperty *>(p_member);
if (!property->has_getter()) {
if (exported)
- ERR_PRINTS("Read-only property cannot be exported: " + MEMBER_FULL_QUALIFIED_NAME(p_member));
+ ERR_PRINTS("Read-only property cannot be exported: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
return false;
}
if (!property->has_setter()) {
if (exported)
- ERR_PRINTS("Write-only property (without getter) cannot be exported: " + MEMBER_FULL_QUALIFIED_NAME(p_member));
+ ERR_PRINTS("Write-only property (without getter) cannot be exported: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
return false;
}
}
@@ -2474,16 +2466,15 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
String hint_string;
if (variant_type == Variant::NIL) {
- ERR_PRINTS("Unknown exported member type: " + MEMBER_FULL_QUALIFIED_NAME(p_member));
+ ERR_PRINTS("Unknown exported member type: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
return false;
}
int hint_res = _try_get_member_export_hint(p_member, type, variant_type, /* allow_generics: */ true, hint, hint_string);
- if (hint_res == -1) {
- ERR_EXPLAIN("Error while trying to determine information about the exported member: " + MEMBER_FULL_QUALIFIED_NAME(p_member));
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(hint_res == -1, false,
+ "Error while trying to determine information about the exported member: '" +
+ MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
if (hint_res == 0) {
hint = PropertyHint(CACHED_FIELD(ExportAttribute, hint)->get_int_value(attr));
@@ -2532,17 +2523,11 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, NULL);
- if (val_obj == NULL) {
- ERR_EXPLAIN("Failed to get '" + enum_field_name + "' constant enum value");
- ERR_FAIL_V(-1);
- }
+ ERR_FAIL_NULL_V_MSG(val_obj, -1, "Failed to get '" + enum_field_name + "' constant enum value.");
bool r_error;
uint64_t val = GDMonoUtils::unbox_enum_value(val_obj, enum_basetype, r_error);
- if (r_error) {
- ERR_EXPLAIN("Failed to unbox '" + enum_field_name + "' constant enum value");
- ERR_FAIL_V(-1);
- }
+ ERR_FAIL_COND_V_MSG(r_error, -1, "Failed to unbox '" + enum_field_name + "' constant enum value.");
if (val != (unsigned int)i) {
uses_default_values = false;
@@ -2577,17 +2562,11 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
PropertyHint elem_hint = PROPERTY_HINT_NONE;
String elem_hint_string;
- if (elem_variant_type == Variant::NIL) {
- ERR_EXPLAIN("Unknown array element type");
- ERR_FAIL_V(-1);
- }
+ ERR_FAIL_COND_V_MSG(elem_variant_type == Variant::NIL, -1, "Unknown array element type.");
int hint_res = _try_get_member_export_hint(p_member, elem_type, elem_variant_type, /* allow_generics: */ false, elem_hint, elem_hint_string);
- if (hint_res == -1) {
- ERR_EXPLAIN("Error while trying to determine information about the array element type");
- ERR_FAIL_V(-1);
- }
+ ERR_FAIL_COND_V_MSG(hint_res == -1, -1, "Error while trying to determine information about the array element type.");
// Format: type/hint:hint_string
r_hint_string = itos(elem_variant_type) + "/" + itos(elem_hint) + ":" + elem_hint_string;
@@ -2775,7 +2754,7 @@ bool CSharpScript::can_instance() const {
"Compile",
ProjectSettings::get_singleton()->globalize_path(get_path()));
} else {
- ERR_PRINTS("Cannot add " + get_path() + " to the C# project because it could not be created.");
+ ERR_PRINTS("C# project could not be created; cannot add file: '" + get_path() + "'.");
}
}
}
@@ -2793,12 +2772,10 @@ bool CSharpScript::can_instance() const {
if (extra_cond && !script_class) {
if (GDMono::get_singleton()->get_project_assembly() == NULL) {
// The project assembly is not loaded
- ERR_EXPLAIN("Cannot instance script because the project assembly is not loaded. Script: " + get_path());
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'.");
} else {
// The project assembly is loaded, but the class could not found
- ERR_EXPLAIN("Cannot instance script because the class '" + name + "' could not be found. Script: " + get_path());
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'.");
}
}
@@ -2820,14 +2797,12 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
// Search the constructor first, to fail with an error if it's not found before allocating anything else.
GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount);
if (ctor == NULL) {
- if (p_argcount == 0) {
- String path = get_path();
- ERR_PRINTS("Cannot create script instance. The class '" + script_class->get_full_name() +
- "' does not define a parameterless constructor." + (path.empty() ? String() : ". Path: " + path));
- }
+ ERR_FAIL_COND_V_MSG(p_argcount == 0, NULL,
+ "Cannot create script instance. The class '" + script_class->get_full_name() +
+ "' does not define a parameterless constructor." +
+ (get_path().empty() ? String() : " Path: '" + get_path() + "'."));
- ERR_EXPLAIN("Constructor not found");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Constructor not found.");
}
Ref<Reference> ref;
@@ -2878,8 +2853,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
p_owner->set_script_instance(NULL);
r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
- ERR_EXPLAIN("Failed to allocate memory for the object");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object.");
}
// Tie managed to unmanaged
@@ -2913,11 +2887,10 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Variant::Call
r_error.error = Variant::CallError::CALL_OK;
REF ref;
- Object *owner = NULL;
ERR_FAIL_NULL_V(native, Variant());
- owner = ClassDB::instance(NATIVE_GDMONOCLASS_NAME(native));
+ Object *owner = ClassDB::instance(NATIVE_GDMONOCLASS_NAME(native));
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
@@ -2951,8 +2924,8 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
if (ScriptDebugger::get_singleton()) {
CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0, "Script inherits from native type '" + native_name + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
- ERR_EXPLAIN("Script inherits from native type '" + native_name + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + native_name +
+ "', so it can't be instanced in object of type: '" + p_this->get_class() + "'.");
}
}
@@ -3204,12 +3177,12 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
Error CSharpScript::load_source_code(const String &p_path) {
Error ferr = read_all_file_utf8(p_path, source);
- if (ferr != OK) {
- if (ferr == ERR_INVALID_DATA) {
- ERR_EXPLAIN("Script '" + p_path + "' contains invalid unicode (utf-8), so it was not loaded. Please ensure that scripts are saved in valid utf-8 unicode.");
- }
- ERR_FAIL_V(ferr);
- }
+
+ ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
+ ferr == ERR_INVALID_DATA ?
+ "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded."
+ " Please ensure that scripts are saved in valid UTF-8 unicode." :
+ "Failed to read file: '" + p_path + "'.");
#ifdef TOOLS_ENABLED
source_changed_cache = true;
@@ -3278,8 +3251,7 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p
#ifdef DEBUG_ENABLED
// User is responsible for thread attach/detach
- ERR_EXPLAIN("Thread is not attached");
- CRASH_COND(mono_domain_get() == NULL);
+ CRASH_COND_MSG(mono_domain_get() == NULL, "Thread is not attached.");
#endif
#endif
@@ -3346,8 +3318,7 @@ Error ResourceFormatSaverCSharpScript::save(const String &p_path, const RES &p_r
"Compile",
ProjectSettings::get_singleton()->globalize_path(p_path));
} else {
- ERR_PRINTS("Failed to create C# project");
- ERR_PRINTS("Cannot add " + p_path + " to the C# project");
+ ERR_PRINTS("C# project could not be created; cannot add file: '" + p_path + "'.");
}
}
#endif
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 45037bf637..1888bb3cb9 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -279,7 +279,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
Vector<String> link_target_parts = link_target.split(".");
if (link_target_parts.size() <= 0 || link_target_parts.size() > 2) {
- ERR_PRINTS("Invalid reference format: " + tag);
+ ERR_PRINTS("Invalid reference format: '" + tag + "'.");
xml_output.append("<c>");
xml_output.append(tag);
@@ -375,7 +375,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(target_enum_itype.proxy_name); // Includes nesting class if any
xml_output.append("\"/>");
} else {
- ERR_PRINTS("Cannot resolve enum reference in documentation: " + link_target);
+ ERR_PRINTS("Cannot resolve enum reference in documentation: '" + link_target + "'.");
xml_output.append("<c>");
xml_output.append(link_target);
@@ -424,7 +424,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(target_iconst->proxy_name);
xml_output.append("\"/>");
} else {
- ERR_PRINTS("Cannot resolve global constant reference in documentation: " + link_target);
+ ERR_PRINTS("Cannot resolve global constant reference in documentation: '" + link_target + "'.");
xml_output.append("<c>");
xml_output.append(link_target);
@@ -464,7 +464,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(target_iconst->proxy_name);
xml_output.append("\"/>");
} else {
- ERR_PRINTS("Cannot resolve constant reference in documentation: " + link_target);
+ ERR_PRINTS("Cannot resolve constant reference in documentation: '" + link_target + "'.");
xml_output.append("<c>");
xml_output.append(link_target);
@@ -534,7 +534,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(target_itype->proxy_name);
xml_output.append("\"/>");
} else {
- ERR_PRINTS("Cannot resolve type reference in documentation: " + tag);
+ ERR_PRINTS("Cannot resolve type reference in documentation: '" + tag + "'.");
xml_output.append("<c>");
xml_output.append(tag);
@@ -812,7 +812,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
CRASH_COND(enum_class_name != "Variant"); // Hard-coded...
- _log("Declaring global enum `%s` inside static class `%s`\n", enum_proxy_name.utf8().get_data(), enum_class_name.utf8().get_data());
+ _log("Declaring global enum '%s' inside static class '%s'\n", enum_proxy_name.utf8().get_data(), enum_class_name.utf8().get_data());
p_output.append("\n" INDENT1 "public static partial class ");
p_output.append(enum_class_name);
@@ -1083,7 +1083,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
proj_err = generate_cs_core_project(core_proj_dir, core_compile_items);
if (proj_err != OK) {
- ERR_PRINT("Generation of the Core API C# project failed");
+ ERR_PRINT("Generation of the Core API C# project failed.");
return proj_err;
}
@@ -1094,7 +1094,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
proj_err = generate_cs_editor_project(editor_proj_dir, editor_compile_items);
if (proj_err != OK) {
- ERR_PRINT("Generation of the Editor API C# project failed");
+ ERR_PRINT("Generation of the Editor API C# project failed.");
return proj_err;
}
@@ -1112,7 +1112,7 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
// FIXME: There are some members that hide other inherited members.
// - In the case of both members being the same kind, the new one must be declared
-// explicitly as `new` to avoid the warning (and we must print a message about it).
+// explicitly as 'new' to avoid the warning (and we must print a message about it).
// - In the case of both members being of a different kind, then the new one must
// be renamed to avoid the name collision (and we must print a warning about it).
// - Csc warning e.g.:
@@ -1186,7 +1186,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.append(obj_types[itype.base_name].proxy_name);
output.append("\n");
} else {
- ERR_PRINTS("Base type '" + itype.base_name.operator String() + "' does not exist, for class " + itype.name);
+ ERR_PRINTS("Base type '" + itype.base_name.operator String() + "' does not exist, for class '" + itype.name + "'.");
return ERR_INVALID_DATA;
}
}
@@ -1273,11 +1273,9 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) {
const PropertyInterface &iprop = E->get();
Error prop_err = _generate_cs_property(itype, iprop, output);
- if (prop_err != OK) {
- ERR_EXPLAIN("Failed to generate property '" + iprop.cname.operator String() +
- "' for class '" + itype.name + "'");
- ERR_FAIL_V(prop_err);
- }
+ ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err,
+ "Failed to generate property '" + iprop.cname.operator String() +
+ "' for class '" + itype.name + "'.");
}
}
@@ -1340,10 +1338,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) {
const MethodInterface &imethod = E->get();
Error method_err = _generate_cs_method(itype, imethod, method_bind_count, output);
- if (method_err != OK) {
- ERR_EXPLAIN("Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'");
- ERR_FAIL_V(method_err);
- }
+ ERR_FAIL_COND_V_MSG(method_err != OK, method_err,
+ "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'.");
}
if (itype.is_singleton) {
@@ -1626,7 +1622,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
if (p_imethod.is_deprecated) {
if (p_imethod.deprecation_message.empty())
- WARN_PRINTS("An empty deprecation message is discouraged. Method: " + p_imethod.proxy_name);
+ WARN_PRINTS("An empty deprecation message is discouraged. Method: '" + p_imethod.proxy_name + "'.");
p_output.append(MEMBER_BEGIN "[Obsolete(\"");
p_output.append(p_imethod.deprecation_message);
@@ -1708,8 +1704,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
Error BindingsGenerator::generate_glue(const String &p_output_dir) {
bool dir_exists = DirAccess::exists(p_output_dir);
- ERR_EXPLAIN("The output directory does not exist.");
- ERR_FAIL_COND_V(!dir_exists, ERR_FILE_BAD_PATH);
+ ERR_FAIL_COND_V_MSG(!dir_exists, ERR_FILE_BAD_PATH, "The output directory does not exist.");
StringBuilder output;
@@ -1742,10 +1737,8 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) {
const MethodInterface &imethod = E->get();
Error method_err = _generate_glue_method(itype, imethod, output);
- if (method_err != OK) {
- ERR_EXPLAIN("Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'");
- ERR_FAIL_V(method_err);
- }
+ ERR_FAIL_COND_V_MSG(method_err != OK, method_err,
+ "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'.");
}
if (itype.is_singleton) {
@@ -1879,8 +1872,7 @@ Error BindingsGenerator::_save_file(const String &p_path, const StringBuilder &p
FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE);
- ERR_EXPLAIN("Cannot open file: " + p_path);
- ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
+ ERR_FAIL_COND_V_MSG(!file, ERR_FILE_CANT_WRITE, "Cannot open file: '" + p_path + "'.");
file->store_string(p_content.as_string());
file->close();
@@ -2091,7 +2083,7 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placehol
if (found)
return found;
- ERR_PRINTS(String() + "Type not found. Creating placeholder: " + p_typeref.cname.operator String());
+ ERR_PRINTS(String() + "Type not found. Creating placeholder: '" + p_typeref.cname.operator String() + "'.");
const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_typeref.cname);
@@ -2175,13 +2167,13 @@ void BindingsGenerator::_populate_object_type_interfaces() {
}
if (!ClassDB::is_class_exposed(type_cname)) {
- _log("Ignoring type `%s` because it's not exposed\n", String(type_cname).utf8().get_data());
+ _log("Ignoring type '%s' because it's not exposed\n", String(type_cname).utf8().get_data());
class_list.pop_front();
continue;
}
if (!ClassDB::is_class_enabled(type_cname)) {
- _log("Ignoring type `%s` because it's not enabled\n", String(type_cname).utf8().get_data());
+ _log("Ignoring type '%s' because it's not enabled\n", String(type_cname).utf8().get_data());
class_list.pop_front();
continue;
}
@@ -2240,7 +2232,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
// Prevent the property and its enclosing type from sharing the same name
if (iprop.proxy_name == itype.proxy_name) {
- _log("Name of property `%s` is ambiguous with the name of its enclosing class `%s`. Renaming property to `%s_`\n",
+ _log("Name of property '%s' is ambiguous with the name of its enclosing class '%s'. Renaming property to '%s_'\n",
iprop.proxy_name.utf8().get_data(), itype.proxy_name.utf8().get_data(), iprop.proxy_name.utf8().get_data());
iprop.proxy_name += "_";
@@ -2298,28 +2290,26 @@ void BindingsGenerator::_populate_object_type_interfaces() {
imethod.is_vararg = m && m->is_vararg();
if (!m && !imethod.is_virtual) {
- if (virtual_method_list.find(method_info)) {
- // A virtual method without the virtual flag. This is a special case.
-
- // There is no method bind, so let's fallback to Godot's object.Call(string, params)
- imethod.requires_object_call = true;
-
- // The method Object.free is registered as a virtual method, but without the virtual flag.
- // This is because this method is not supposed to be overridden, but called.
- // We assume the return type is void.
- imethod.return_type.cname = name_cache.type_void;
-
- // Actually, more methods like this may be added in the future,
- // which could actually will return something different.
- // Let's put this to notify us if that ever happens.
- if (itype.cname != name_cache.type_Object || imethod.name != "free") {
- ERR_PRINTS("Notification: New unexpected virtual non-overridable method found.\n"
- "We only expected Object.free, but found " +
- itype.name + "." + imethod.name);
- }
- } else {
- ERR_EXPLAIN("Missing MethodBind for non-virtual method: " + itype.name + "." + imethod.name);
- ERR_FAIL();
+ ERR_FAIL_COND_MSG(!virtual_method_list.find(method_info),
+ "Missing MethodBind for non-virtual method: '" + itype.name + "." + imethod.name + "'.");
+
+ // A virtual method without the virtual flag. This is a special case.
+
+ // There is no method bind, so let's fallback to Godot's object.Call(string, params)
+ imethod.requires_object_call = true;
+
+ // The method Object.free is registered as a virtual method, but without the virtual flag.
+ // This is because this method is not supposed to be overridden, but called.
+ // We assume the return type is void.
+ imethod.return_type.cname = name_cache.type_void;
+
+ // Actually, more methods like this may be added in the future,
+ // which could actually will return something different.
+ // Let's put this to notify us if that ever happens.
+ if (itype.cname != name_cache.type_Object || imethod.name != "free") {
+ ERR_PRINTS("Notification: New unexpected virtual non-overridable method found."
+ " We only expected Object.free, but found '" +
+ itype.name + "." + imethod.name + "'.");
}
} else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
imethod.return_type.cname = return_info.class_name;
@@ -2328,8 +2318,8 @@ void BindingsGenerator::_populate_object_type_interfaces() {
imethod.return_type.cname = return_info.class_name;
if (!imethod.is_virtual && ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference) && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE) {
/* clang-format off */
- ERR_PRINTS("Return type is reference but hint is not " _STR(PROPERTY_HINT_RESOURCE_TYPE) "."
- " Are you returning a reference type by pointer? Method: " + itype.name + "." + imethod.name);
+ ERR_PRINTS("Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'."
+ " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'.");
/* clang-format on */
ERR_FAIL();
}
@@ -2394,7 +2384,7 @@ void BindingsGenerator::_populate_object_type_interfaces() {
// Prevent the method and its enclosing type from sharing the same name
if (imethod.proxy_name == itype.proxy_name) {
- _log("Name of method `%s` is ambiguous with the name of its enclosing class `%s`. Renaming method to `%s_`\n",
+ _log("Name of method '%s' is ambiguous with the name of its enclosing class '%s'. Renaming method to '%s_'\n",
imethod.proxy_name.utf8().get_data(), itype.proxy_name.utf8().get_data(), imethod.proxy_name.utf8().get_data());
imethod.proxy_name += "_";
@@ -2880,8 +2870,7 @@ void BindingsGenerator::_populate_global_constants() {
if (global_constants_count > 0) {
Map<String, DocData::ClassDoc>::Element *match = EditorHelp::get_doc_data()->class_list.find("@GlobalScope");
- ERR_EXPLAIN("Could not find `@GlobalScope` in DocData");
- CRASH_COND(!match);
+ CRASH_COND_MSG(!match, "Could not find '@GlobalScope' in DocData.");
const DocData::ClassDoc &global_scope_doc = match->value();
@@ -2935,7 +2924,7 @@ void BindingsGenerator::_populate_global_constants() {
// HARDCODED: The Error enum have the prefix 'ERR_' for everything except 'OK' and 'FAILED'.
if (ienum.cname == name_cache.enum_Error) {
if (prefix_length > 0) { // Just in case it ever changes
- ERR_PRINTS("Prefix for enum 'Error' is not empty");
+ ERR_PRINTS("Prefix for enum '" _STR(Error) "' is not empty.");
}
prefix_length = 1; // 'ERR_'
@@ -3024,7 +3013,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
glue_dir_path = path_elem->get();
elem = elem->next();
} else {
- ERR_PRINTS(generate_all_glue_option + ": No output directory specified (expected path to {GODOT_ROOT}/modules/mono/glue)");
+ ERR_PRINTS(generate_all_glue_option + ": No output directory specified (expected path to '{GODOT_ROOT}/modules/mono/glue').");
}
--options_left;
@@ -3035,7 +3024,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
cs_dir_path = path_elem->get();
elem = elem->next();
} else {
- ERR_PRINTS(generate_cs_glue_option + ": No output directory specified");
+ ERR_PRINTS(generate_cs_glue_option + ": No output directory specified.");
}
--options_left;
@@ -3046,7 +3035,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
cpp_dir_path = path_elem->get();
elem = elem->next();
} else {
- ERR_PRINTS(generate_cpp_glue_option + ": No output directory specified");
+ ERR_PRINTS(generate_cpp_glue_option + ": No output directory specified.");
}
--options_left;
@@ -3061,20 +3050,20 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
if (glue_dir_path.length()) {
if (bindings_generator.generate_glue(glue_dir_path) != OK)
- ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C++ glue");
+ ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C++ glue.");
if (bindings_generator.generate_cs_api(glue_dir_path.plus_file("Managed/Generated")) != OK)
- ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C# API");
+ ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C# API.");
}
if (cs_dir_path.length()) {
if (bindings_generator.generate_cs_api(cs_dir_path) != OK)
- ERR_PRINTS(generate_cs_glue_option + ": Failed to generate the C# API");
+ ERR_PRINTS(generate_cs_glue_option + ": Failed to generate the C# API.");
}
if (cpp_dir_path.length()) {
if (bindings_generator.generate_glue(cpp_dir_path) != OK)
- ERR_PRINTS(generate_cpp_glue_option + ": Failed to generate the C++ glue");
+ ERR_PRINTS(generate_cpp_glue_option + ": Failed to generate the C++ glue.");
}
// Exit once done
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 8be51a6c55..6f0c297575 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -147,7 +147,7 @@ class BindingsGenerator {
bool requires_object_call;
/**
- * Determines if the method visibility is `internal` (visible only to files in the same assembly).
+ * Determines if the method visibility is 'internal' (visible only to files in the same assembly).
* Currently, we only use this for methods that are not meant to be exposed,
* but are required by properties as getters or setters.
* Methods that are not meant to be exposed are those that begin with underscore and are not virtual.
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index d88b08c646..0e6c58c9d7 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -81,16 +81,14 @@ bool generate_api_solution(const String &p_solution_dir, const String &p_core_pr
_GDMONO_SCOPE_DOMAIN_(temp_domain);
- GDMonoAssembly *tools_project_editor_assembly = NULL;
+ GDMonoAssembly *tools_project_editor_asm = NULL;
- if (!GDMono::get_singleton()->load_assembly("GodotTools.ProjectEditor", &tools_project_editor_assembly)) {
- ERR_EXPLAIN("Failed to load assembly: 'GodotTools.ProjectEditor'");
- ERR_FAIL_V(false);
- }
+ bool assembly_loaded = GDMono::get_singleton()->load_assembly(TOOLS_PROJECT_EDITOR_ASM_NAME, &tools_project_editor_asm);
+ ERR_FAIL_COND_V_MSG(!assembly_loaded, false, "Failed to load assembly: '" TOOLS_PROJECT_EDITOR_ASM_NAME "'.");
return generate_api_solution_impl(p_solution_dir, p_core_proj_dir, p_core_compile_items,
p_editor_proj_dir, p_editor_compile_items,
- tools_project_editor_assembly);
+ tools_project_editor_asm);
}
}
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index 020bb70a08..80a7335b1d 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -85,18 +85,12 @@ Error GodotSharpExport::get_assembly_dependencies(GDMonoAssembly *p_assembly, co
}
}
- if (!ref_assembly) {
- ERR_EXPLAIN("Cannot load assembly (refonly): " + ref_name);
- ERR_FAIL_V(ERR_CANT_RESOLVE);
- }
+ ERR_FAIL_COND_V_MSG(!ref_assembly, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + ref_name + "'.");
r_dependencies[ref_name] = ref_assembly->get_path();
Error err = get_assembly_dependencies(ref_assembly, p_search_dirs, r_dependencies);
- if (err != OK) {
- ERR_EXPLAIN("Cannot load one of the dependencies for the assembly: " + ref_name);
- ERR_FAIL_V(err);
- }
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot load one of the dependencies for the assembly: '" + ref_name + "'.");
}
return OK;
@@ -113,8 +107,7 @@ Error GodotSharpExport::get_exported_assembly_dependencies(const String &p_proje
bool load_success = GDMono::get_singleton()->load_assembly_from(p_project_dll_name,
p_project_dll_src_path, &scripts_assembly, /* refonly: */ true);
- ERR_EXPLAIN("Cannot load assembly (refonly): " + p_project_dll_name);
- ERR_FAIL_COND_V(!load_success, ERR_CANT_RESOLVE);
+ ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + p_project_dll_name + "'.");
Vector<String> search_dirs;
GDMonoAssembly::fill_search_dirs(search_dirs, p_build_config, p_custom_lib_dir);
diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp
index dfb652a7aa..dcb0ca5a80 100644
--- a/modules/mono/editor/script_class_parser.cpp
+++ b/modules/mono/editor/script_class_parser.cpp
@@ -162,8 +162,8 @@ ScriptClassParser::Token ScriptClassParser::get_token() {
error = true;
return TK_ERROR;
} else if (code[idx] == begin_str) {
- if (verbatim && code[idx + 1] == '"') { // `""` is verbatim string's `\"`
- idx += 2; // skip next `"` as well
+ if (verbatim && code[idx + 1] == '"') { // '""' is verbatim string's '\"'
+ idx += 2; // skip next '"' as well
continue;
}
@@ -590,7 +590,7 @@ Error ScriptClassParser::parse(const String &p_code) {
name = String(value);
} else if (tk == TK_CURLY_BRACKET_OPEN) {
if (name.empty()) {
- error_str = "Expected " + get_token_name(TK_IDENTIFIER) + " after keyword `struct`, found " + get_token_name(TK_CURLY_BRACKET_OPEN);
+ error_str = "Expected " + get_token_name(TK_IDENTIFIER) + " after keyword 'struct', found " + get_token_name(TK_CURLY_BRACKET_OPEN);
error = true;
return ERR_PARSE_ERROR;
}
@@ -657,12 +657,12 @@ Error ScriptClassParser::parse_file(const String &p_filepath) {
String source;
Error ferr = read_all_file_utf8(p_filepath, source);
- if (ferr != OK) {
- if (ferr == ERR_INVALID_DATA) {
- ERR_EXPLAIN("File '" + p_filepath + "' contains invalid unicode (utf-8), so it was not loaded. Please ensure that scripts are saved in valid utf-8 unicode.");
- }
- ERR_FAIL_V(ferr);
- }
+
+ ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
+ ferr == ERR_INVALID_DATA ?
+ "File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded."
+ " Please ensure that scripts are saved in valid UTF-8 unicode." :
+ "Failed to read file: '" + p_filepath + "'.");
return parse(source);
}
diff --git a/modules/mono/glue/Managed/Files/AABB.cs b/modules/mono/glue/Managed/Files/AABB.cs
index a2ebbc0736..98a73382f4 100644
--- a/modules/mono/glue/Managed/Files/AABB.cs
+++ b/modules/mono/glue/Managed/Files/AABB.cs
@@ -5,6 +5,7 @@
// file: core/variant_call.cpp
// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685
using System;
+using System.Runtime.InteropServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -13,6 +14,8 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
public struct AABB : IEquatable<AABB>
{
private Vector3 _position;
diff --git a/modules/mono/glue/Managed/Files/Basis.cs b/modules/mono/glue/Managed/Files/Basis.cs
index 5a6a5ff658..0eb76e9c63 100644
--- a/modules/mono/glue/Managed/Files/Basis.cs
+++ b/modules/mono/glue/Managed/Files/Basis.cs
@@ -8,43 +8,10 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Basis : IEquatable<Basis>
{
- private static readonly Basis identity = new Basis
- (
- 1f, 0f, 0f,
- 0f, 1f, 0f,
- 0f, 0f, 1f
- );
-
- private static readonly Basis[] orthoBases = {
- new Basis(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f),
- new Basis(0f, -1f, 0f, 1f, 0f, 0f, 0f, 0f, 1f),
- new Basis(-1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f),
- new Basis(0f, 1f, 0f, -1f, 0f, 0f, 0f, 0f, 1f),
- new Basis(1f, 0f, 0f, 0f, 0f, -1f, 0f, 1f, 0f),
- new Basis(0f, 0f, 1f, 1f, 0f, 0f, 0f, 1f, 0f),
- new Basis(-1f, 0f, 0f, 0f, 0f, 1f, 0f, 1f, 0f),
- new Basis(0f, 0f, -1f, -1f, 0f, 0f, 0f, 1f, 0f),
- new Basis(1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, -1f),
- new Basis(0f, 1f, 0f, 1f, 0f, 0f, 0f, 0f, -1f),
- new Basis(-1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, -1f),
- new Basis(0f, -1f, 0f, -1f, 0f, 0f, 0f, 0f, -1f),
- new Basis(1f, 0f, 0f, 0f, 0f, 1f, 0f, -1f, 0f),
- new Basis(0f, 0f, -1f, 1f, 0f, 0f, 0f, -1f, 0f),
- new Basis(-1f, 0f, 0f, 0f, 0f, -1f, 0f, -1f, 0f),
- new Basis(0f, 0f, 1f, -1f, 0f, 0f, 0f, -1f, 0f),
- new Basis(0f, 0f, 1f, 0f, 1f, 0f, -1f, 0f, 0f),
- new Basis(0f, -1f, 0f, 0f, 0f, 1f, -1f, 0f, 0f),
- new Basis(0f, 0f, -1f, 0f, -1f, 0f, -1f, 0f, 0f),
- new Basis(0f, 1f, 0f, 0f, 0f, -1f, -1f, 0f, 0f),
- new Basis(0f, 0f, 1f, 0f, -1f, 0f, 1f, 0f, 0f),
- new Basis(0f, 1f, 0f, 0f, 0f, 1f, 1f, 0f, 0f),
- new Basis(0f, 0f, -1f, 0f, 1f, 0f, 1f, 0f, 0f),
- new Basis(0f, -1f, 0f, 0f, 0f, -1f, 1f, 0f, 0f)
- };
-
// NOTE: x, y and z are public-only. Use Column0, Column1 and Column2 internally.
/// <summary>
@@ -63,7 +30,6 @@ namespace Godot
/// </summary>
public Vector3 y
{
-
get => Column1;
set => Column1 = value;
}
@@ -74,7 +40,6 @@ namespace Godot
/// </summary>
public Vector3 z
{
-
get => Column2;
set => Column2 = value;
}
@@ -114,8 +79,6 @@ namespace Godot
}
}
- public static Basis Identity => identity;
-
public Vector3 Scale
{
get
@@ -360,7 +323,7 @@ namespace Godot
for (int i = 0; i < 24; i++)
{
- if (orthoBases[i] == orth)
+ if (orth == _orthoBases[i])
return i;
}
@@ -530,6 +493,43 @@ namespace Godot
}
}
+ private static readonly Basis[] _orthoBases = {
+ new Basis(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f),
+ new Basis(0f, -1f, 0f, 1f, 0f, 0f, 0f, 0f, 1f),
+ new Basis(-1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f),
+ new Basis(0f, 1f, 0f, -1f, 0f, 0f, 0f, 0f, 1f),
+ new Basis(1f, 0f, 0f, 0f, 0f, -1f, 0f, 1f, 0f),
+ new Basis(0f, 0f, 1f, 1f, 0f, 0f, 0f, 1f, 0f),
+ new Basis(-1f, 0f, 0f, 0f, 0f, 1f, 0f, 1f, 0f),
+ new Basis(0f, 0f, -1f, -1f, 0f, 0f, 0f, 1f, 0f),
+ new Basis(1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, -1f),
+ new Basis(0f, 1f, 0f, 1f, 0f, 0f, 0f, 0f, -1f),
+ new Basis(-1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, -1f),
+ new Basis(0f, -1f, 0f, -1f, 0f, 0f, 0f, 0f, -1f),
+ new Basis(1f, 0f, 0f, 0f, 0f, 1f, 0f, -1f, 0f),
+ new Basis(0f, 0f, -1f, 1f, 0f, 0f, 0f, -1f, 0f),
+ new Basis(-1f, 0f, 0f, 0f, 0f, -1f, 0f, -1f, 0f),
+ new Basis(0f, 0f, 1f, -1f, 0f, 0f, 0f, -1f, 0f),
+ new Basis(0f, 0f, 1f, 0f, 1f, 0f, -1f, 0f, 0f),
+ new Basis(0f, -1f, 0f, 0f, 0f, 1f, -1f, 0f, 0f),
+ new Basis(0f, 0f, -1f, 0f, -1f, 0f, -1f, 0f, 0f),
+ new Basis(0f, 1f, 0f, 0f, 0f, -1f, -1f, 0f, 0f),
+ new Basis(0f, 0f, 1f, 0f, -1f, 0f, 1f, 0f, 0f),
+ new Basis(0f, 1f, 0f, 0f, 0f, 1f, 1f, 0f, 0f),
+ new Basis(0f, 0f, -1f, 0f, 1f, 0f, 1f, 0f, 0f),
+ new Basis(0f, -1f, 0f, 0f, 0f, -1f, 1f, 0f, 0f)
+ };
+
+ private static readonly Basis _identity = new Basis(1, 0, 0, 0, 1, 0, 0, 0, 1);
+ private static readonly Basis _flipX = new Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1);
+ private static readonly Basis _flipY = new Basis(1, 0, 0, 0, -1, 0, 0, 0, 1);
+ private static readonly Basis _flipZ = new Basis(1, 0, 0, 0, 1, 0, 0, 0, -1);
+
+ public static Basis Identity { get { return _identity; } }
+ public static Basis FlipX { get { return _flipX; } }
+ public static Basis FlipY { get { return _flipY; } }
+ public static Basis FlipZ { get { return _flipZ; } }
+
public Basis(Quat quat)
{
real_t s = 2.0f / quat.LengthSquared;
diff --git a/modules/mono/glue/Managed/Files/Color.cs b/modules/mono/glue/Managed/Files/Color.cs
index 84ff19fc54..447697c671 100644
--- a/modules/mono/glue/Managed/Files/Color.cs
+++ b/modules/mono/glue/Managed/Files/Color.cs
@@ -1,7 +1,10 @@
using System;
+using System.Runtime.InteropServices;
namespace Godot
{
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
public struct Color : IEquatable<Color>
{
public float r;
@@ -375,7 +378,7 @@ namespace Godot
return c;
}
- public string ToHtml(bool include_alpha = true)
+ public string ToHtml(bool includeAlpha = true)
{
var txt = string.Empty;
@@ -383,7 +386,7 @@ namespace Godot
txt += ToHex32(g);
txt += ToHex32(b);
- if (include_alpha)
+ if (includeAlpha)
txt = ToHex32(a) + txt;
return txt;
@@ -465,13 +468,13 @@ namespace Godot
for (int i = 0; i < 2; i++)
{
- char[] c = { (char)0, (char)0 };
+ char c;
int lv = v & 0xF;
if (lv < 10)
- c[0] = (char)('0' + lv);
+ c = (char)('0' + lv);
else
- c[0] = (char)('a' + lv - 10);
+ c = (char)('a' + lv - 10);
v >>= 4;
ret = c + ret;
@@ -490,12 +493,17 @@ namespace Godot
bool alpha;
- if (color.Length == 8)
- alpha = true;
- else if (color.Length == 6)
- alpha = false;
- else
- return false;
+ switch (color.Length)
+ {
+ case 8:
+ alpha = true;
+ break;
+ case 6:
+ alpha = false;
+ break;
+ default:
+ return false;
+ }
if (alpha)
{
diff --git a/modules/mono/glue/Managed/Files/Mathf.cs b/modules/mono/glue/Managed/Files/Mathf.cs
index 6c1a51fcf9..15adf0a13b 100644
--- a/modules/mono/glue/Managed/Files/Mathf.cs
+++ b/modules/mono/glue/Managed/Files/Mathf.cs
@@ -336,14 +336,14 @@ namespace Godot
public static int Wrap(int value, int min, int max)
{
- int rng = max - min;
- return rng != 0 ? min + ((value - min) % rng + rng) % rng : min;
+ int range = max - min;
+ return range == 0 ? min : min + ((value - min) % range + range) % range;
}
public static real_t Wrap(real_t value, real_t min, real_t max)
{
- real_t rng = max - min;
- return !IsEqualApprox(rng, default(real_t)) ? min + ((value - min) % rng + rng) % rng : min;
+ real_t range = max - min;
+ return IsZeroApprox(range) ? min : min + ((value - min) % range + range) % range;
}
}
}
diff --git a/modules/mono/glue/Managed/Files/Plane.cs b/modules/mono/glue/Managed/Files/Plane.cs
index e16d4315be..a13161d2e6 100644
--- a/modules/mono/glue/Managed/Files/Plane.cs
+++ b/modules/mono/glue/Managed/Files/Plane.cs
@@ -1,4 +1,5 @@
using System;
+using System.Runtime.InteropServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -7,6 +8,8 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential)]
public struct Plane : IEquatable<Plane>
{
private Vector3 _normal;
diff --git a/modules/mono/glue/Managed/Files/Quat.cs b/modules/mono/glue/Managed/Files/Quat.cs
index f1d97b9b5c..845c7c730e 100644
--- a/modules/mono/glue/Managed/Files/Quat.cs
+++ b/modules/mono/glue/Managed/Files/Quat.cs
@@ -8,6 +8,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Quat : IEquatable<Quat>
{
diff --git a/modules/mono/glue/Managed/Files/Rect2.cs b/modules/mono/glue/Managed/Files/Rect2.cs
index 888f300347..f3dc9d8490 100644
--- a/modules/mono/glue/Managed/Files/Rect2.cs
+++ b/modules/mono/glue/Managed/Files/Rect2.cs
@@ -8,6 +8,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Rect2 : IEquatable<Rect2>
{
diff --git a/modules/mono/glue/Managed/Files/Transform.cs b/modules/mono/glue/Managed/Files/Transform.cs
index de70ccbe98..cc4d26158d 100644
--- a/modules/mono/glue/Managed/Files/Transform.cs
+++ b/modules/mono/glue/Managed/Files/Transform.cs
@@ -8,6 +8,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Transform : IEquatable<Transform>
{
diff --git a/modules/mono/glue/Managed/Files/Transform2D.cs b/modules/mono/glue/Managed/Files/Transform2D.cs
index 12a3811230..814332dc07 100644
--- a/modules/mono/glue/Managed/Files/Transform2D.cs
+++ b/modules/mono/glue/Managed/Files/Transform2D.cs
@@ -8,6 +8,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Transform2D : IEquatable<Transform2D>
{
diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs
index 3fb40d8a61..b1c1dae3c2 100644
--- a/modules/mono/glue/Managed/Files/Vector2.cs
+++ b/modules/mono/glue/Managed/Files/Vector2.cs
@@ -14,6 +14,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Vector2 : IEquatable<Vector2>
{
diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs
index 68601da1e7..c2da7b8bb1 100644
--- a/modules/mono/glue/Managed/Files/Vector3.cs
+++ b/modules/mono/glue/Managed/Files/Vector3.cs
@@ -14,6 +14,7 @@ using real_t = System.Single;
namespace Godot
{
+ [Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Vector3 : IEquatable<Vector3>
{
diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp
index 7c30092855..27fd715f60 100644
--- a/modules/mono/glue/gd_glue.cpp
+++ b/modules/mono/glue/gd_glue.cpp
@@ -167,7 +167,7 @@ MonoObject *godot_icall_GD_str2var(MonoString *p_str) {
int line;
Error err = VariantParser::parse(&ss, ret, errs, line);
if (err != OK) {
- String err_str = "Parse error at line " + itos(line) + ": " + errs;
+ String err_str = "Parse error at line " + itos(line) + ": " + errs + ".";
ERR_PRINTS(err_str);
ret = err_str;
}
@@ -193,8 +193,7 @@ MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_object
PoolByteArray barr;
int len;
Error err = encode_variant(var, NULL, len, p_full_objects);
- ERR_EXPLAIN("Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).");
- ERR_FAIL_COND_V(err != OK, NULL);
+ ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).");
barr.resize(len);
{
diff --git a/modules/mono/godotsharp_defs.h b/modules/mono/godotsharp_defs.h
index 4ad4088514..4c17a6ec9d 100644
--- a/modules/mono/godotsharp_defs.h
+++ b/modules/mono/godotsharp_defs.h
@@ -39,8 +39,8 @@
#define API_SOLUTION_NAME "GodotSharp"
#define CORE_API_ASSEMBLY_NAME "GodotSharp"
#define EDITOR_API_ASSEMBLY_NAME "GodotSharpEditor"
-#define TOOLS_ASSEMBLY_NAME "GodotTools"
-#define TOOLS_PROJECT_EDITOR_ASSEMBLY_NAME "GodotTools.ProjectEditor"
+#define TOOLS_ASM_NAME "GodotTools"
+#define TOOLS_PROJECT_EDITOR_ASM_NAME "GodotTools.ProjectEditor"
#define BINDINGS_CLASS_NATIVECALLS "NativeCalls"
#define BINDINGS_CLASS_NATIVECALLS_EDITOR "EditorNativeCalls"
diff --git a/modules/mono/icons/icon_c_#.svg b/modules/mono/icons/icon_c_#.svg
new file mode 100644
index 0000000000..69664ca553
--- /dev/null
+++ b/modules/mono/icons/icon_c_#.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path d="m6 1046.4c-1.6569 0-3 1.3431-3 3s1.3431 3 3 3h1v-2h-1c-0.55228 0-1-0.4478-1-1 0-0.5523 0.44772-1 1-1h1v-2zm1-9-0.56445 2.2578c-0.23643 0.076-0.46689 0.1692-0.68945 0.2793l-1.9883-1.1933-1.4141 1.414 1.1953 1.9942c-0.11191 0.2211-0.20723 0.4502-0.28516 0.6855l-2.2539 0.5625v2h5.2715c-0.17677-0.3037-0.27041-0.6486-0.27148-1 9.6e-6 -1.1046 0.89543-2 2-2s2 0.8954 2 2c-4.817e-4 0.3512-0.093442 0.6961-0.26953 1h5.2695v-2l-2.2578-0.5645c-0.07594-0.2357-0.1693-0.4655-0.2793-0.6875l1.1934-1.9902-1.4141-1.414-1.9941 1.1953c-0.22113-0.1119-0.45028-0.2073-0.68555-0.2852l-0.5625-2.2539zm4 9c-0.71466-1e-4 -1.3751 0.3811-1.7324 1-0.35727 0.6188-0.35727 1.3812 0 2 0.35733 0.6189 1.0178 1.0001 1.7324 1h-2v2h2c0.71466 1e-4 1.3751-0.3811 1.7324-1 0.35727-0.6188 0.35727-1.3812 0-2-0.35733-0.6189-1.0178-1.0001-1.7324-1h2v-2z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 45f79074be..ee1ecf3be7 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -265,7 +265,7 @@ void GDMono::initialize() {
#ifdef WINDOWS_ENABLED
if (assembly_rootdir.empty() || config_dir.empty()) {
- ERR_PRINT("Cannot find Mono in the registry");
+ ERR_PRINT("Cannot find Mono in the registry.");
// Assertion: if they are not set, then they weren't found in the registry
CRASH_COND(mono_reg_info.assembly_dir.length() > 0 || mono_reg_info.config_dir.length() > 0);
}
@@ -318,9 +318,7 @@ void GDMono::initialize() {
#endif
root_domain = mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319");
-
- ERR_EXPLAIN("Mono: Failed to initialize runtime");
- ERR_FAIL_NULL(root_domain);
+ ERR_FAIL_NULL_MSG(root_domain, "Mono: Failed to initialize runtime.");
GDMonoUtils::set_main_thread(GDMonoUtils::get_current_thread());
@@ -331,11 +329,11 @@ void GDMono::initialize() {
print_verbose("Mono: Runtime initialized");
// mscorlib assembly MUST be present at initialization
- ERR_EXPLAIN("Mono: Failed to load mscorlib assembly");
- ERR_FAIL_COND(!_load_corlib_assembly());
+ bool corlib_loaded = _load_corlib_assembly();
+ ERR_FAIL_COND_MSG(!corlib_loaded, "Mono: Failed to load mscorlib assembly.");
- ERR_EXPLAIN("Mono: Failed to load scripts domain");
- ERR_FAIL_COND(_load_scripts_domain() != OK);
+ Error domain_load_err = _load_scripts_domain();
+ ERR_FAIL_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain.");
#ifdef DEBUG_ENABLED
bool debugger_attached = _wait_for_debugger_msecs(500);
@@ -351,8 +349,7 @@ void GDMono::initialize() {
void GDMono::initialize_load_assemblies() {
#ifndef MONO_GLUE_ENABLED
- ERR_EXPLAIN("Mono: This binary was built with `mono_glue=no`; cannot load assemblies");
- CRASH_NOW();
+ CRASH_NOW_MSG("Mono: This binary was built with 'mono_glue=no'; cannot load assemblies.");
#endif
// Load assemblies. The API and tools assemblies are required,
@@ -361,10 +358,8 @@ void GDMono::initialize_load_assemblies() {
_load_api_assemblies();
#if defined(TOOLS_ENABLED)
- if (!_load_tools_assemblies()) {
- ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
- CRASH_NOW();
- }
+ bool tool_assemblies_loaded = _load_tools_assemblies();
+ CRASH_COND_MSG(!tool_assemblies_loaded, "Mono: Failed to load '" TOOLS_ASM_NAME "' assemblies.");
#endif
// Load the project's main assembly. This doesn't necessarily need to succeed.
@@ -428,12 +423,12 @@ void GDMono::_initialize_and_check_api_hashes() {
#ifdef MONO_GLUE_ENABLED
if (get_api_core_hash() != GodotSharpBindings::get_core_api_hash()) {
- ERR_PRINT("Mono: Core API hash mismatch!");
+ ERR_PRINT("Mono: Core API hash mismatch.");
}
#ifdef TOOLS_ENABLED
if (get_api_editor_hash() != GodotSharpBindings::get_editor_api_hash()) {
- ERR_PRINT("Mono: Editor API hash mismatch!");
+ ERR_PRINT("Mono: Editor API hash mismatch.");
}
#endif // TOOLS_ENABLED
#endif // MONO_GLUE_ENABLED
@@ -579,7 +574,7 @@ bool GDMono::copy_prebuilt_api_assembly(APIAssembly::Type p_api_type) {
memdelete(da);
if (err != OK) {
- ERR_PRINTS("Failed to create destination directory for the API assemblies. Error: " + itos(err));
+ ERR_PRINTS("Failed to create destination directory for the API assemblies. Error: " + itos(err) + ".");
return false;
}
}
@@ -593,16 +588,16 @@ bool GDMono::copy_prebuilt_api_assembly(APIAssembly::Type p_api_type) {
String xml_file = assembly_name + ".xml";
if (da->copy(src_dir.plus_file(xml_file), dst_dir.plus_file(xml_file)) != OK)
- WARN_PRINTS("Failed to copy " + xml_file);
+ WARN_PRINTS("Failed to copy '" + xml_file + "'.");
String pdb_file = assembly_name + ".pdb";
if (da->copy(src_dir.plus_file(pdb_file), dst_dir.plus_file(pdb_file)) != OK)
- WARN_PRINTS("Failed to copy " + pdb_file);
+ WARN_PRINTS("Failed to copy '" + pdb_file + "'.");
Error err = da->copy(assembly_src, assembly_dst);
if (err != OK) {
- ERR_PRINTS("Failed to copy " + assembly_file);
+ ERR_PRINTS("Failed to copy '" + assembly_file + "'.");
return false;
}
@@ -617,11 +612,11 @@ String GDMono::update_api_assemblies_from_prebuilt() {
#define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \
( \
(m_out_of_sync ? \
- String("The assembly is invalidated") : \
- String("The assembly was not found")) + \
+ String("The assembly is invalidated ") : \
+ String("The assembly was not found ")) + \
(m_prebuilt_exists ? \
- String(" and the prebuilt assemblies are missing") : \
- String(" and we failed to copy the prebuilt assemblies")))
+ String("and the prebuilt assemblies are missing.") : \
+ String("and we failed to copy the prebuilt assemblies.")))
bool api_assembly_out_of_sync = core_api_assembly_out_of_sync || editor_api_assembly_out_of_sync;
@@ -755,29 +750,19 @@ void GDMono::_load_api_assemblies() {
// update them from the prebuilt assemblies directory before trying to load them.
// Shouldn't happen. The project manager loads the prebuilt API assemblies
- if (Main::is_project_manager()) {
- ERR_EXPLAIN("Failed to load one of the prebuilt API assemblies");
- CRASH_NOW();
- }
+ CRASH_COND_MSG(Main::is_project_manager(), "Failed to load one of the prebuilt API assemblies.");
// 1. Unload the scripts domain
- if (_unload_scripts_domain() != OK) {
- ERR_EXPLAIN("Mono: Failed to unload scripts domain");
- CRASH_NOW();
- }
+ Error domain_unload_err = _unload_scripts_domain();
+ CRASH_COND_MSG(domain_unload_err != OK, "Mono: Failed to unload scripts domain.");
// 2. Update the API assemblies
String update_error = update_api_assemblies_from_prebuilt();
- if (!update_error.empty()) {
- ERR_EXPLAIN(update_error);
- CRASH_NOW();
- }
+ CRASH_COND_MSG(!update_error.empty(), update_error);
// 3. Load the scripts domain again
- if (_load_scripts_domain() != OK) {
- ERR_EXPLAIN("Mono: Failed to load scripts domain");
- CRASH_NOW();
- }
+ Error domain_load_err = _load_scripts_domain();
+ CRASH_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain.");
// 4. Try loading the updated assemblies
if (!_try_load_api_assemblies()) {
@@ -785,24 +770,22 @@ void GDMono::_load_api_assemblies() {
if (_are_api_assemblies_out_of_sync()) {
if (core_api_assembly_out_of_sync) {
- ERR_PRINT("The assembly '" CORE_API_ASSEMBLY_NAME "' is out of sync");
+ ERR_PRINT("The assembly '" CORE_API_ASSEMBLY_NAME "' is out of sync.");
} else if (!GDMonoUtils::mono_cache.godot_api_cache_updated) {
- ERR_PRINT("The loaded assembly '" CORE_API_ASSEMBLY_NAME "' is in sync, but the cache update failed");
+ ERR_PRINT("The loaded assembly '" CORE_API_ASSEMBLY_NAME "' is in sync, but the cache update failed.");
}
if (editor_api_assembly_out_of_sync) {
- ERR_PRINT("The assembly '" EDITOR_API_ASSEMBLY_NAME "' is out of sync");
+ ERR_PRINT("The assembly '" EDITOR_API_ASSEMBLY_NAME "' is out of sync.");
}
CRASH_NOW();
} else {
- ERR_EXPLAIN("Failed to load one of the API assemblies");
- CRASH_NOW();
+ CRASH_NOW_MSG("Failed to load one of the API assemblies.");
}
}
#else
- ERR_EXPLAIN("Failed to load one of the API assemblies");
- CRASH_NOW();
+ CRASH_NOW_MSG("Failed to load one of the API assemblies.");
#endif
}
}
@@ -813,8 +796,8 @@ bool GDMono::_load_tools_assemblies() {
if (tools_assembly && tools_project_editor_assembly)
return true;
- bool success = load_assembly(TOOLS_ASSEMBLY_NAME, &tools_assembly) &&
- load_assembly(TOOLS_PROJECT_EDITOR_ASSEMBLY_NAME, &tools_project_editor_assembly);
+ bool success = load_assembly(TOOLS_ASM_NAME, &tools_assembly) &&
+ load_assembly(TOOLS_PROJECT_EDITOR_ASM_NAME, &tools_project_editor_assembly);
return success;
}
@@ -851,7 +834,7 @@ void GDMono::_install_trace_listener() {
(DebuggingUtils_InstallTraceListener)debug_utils->get_method_thunk("InstallTraceListener");
install_func((MonoObject **)&exc);
if (exc) {
- ERR_PRINT("Failed to install System.Diagnostics.Trace listener");
+ ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener.");
GDMonoUtils::debug_print_unhandled_exception(exc);
}
#endif
@@ -865,8 +848,7 @@ Error GDMono::_load_scripts_domain() {
scripts_domain = GDMonoUtils::create_domain("GodotEngine.ScriptsDomain");
- ERR_EXPLAIN("Mono: Could not create scripts app domain");
- ERR_FAIL_NULL_V(scripts_domain, ERR_CANT_CREATE);
+ ERR_FAIL_NULL_V_MSG(scripts_domain, ERR_CANT_CREATE, "Mono: Could not create scripts app domain.");
mono_domain_set(scripts_domain, true);
@@ -885,7 +867,7 @@ Error GDMono::_unload_scripts_domain() {
finalizing_scripts_domain = true;
if (!mono_domain_finalize(scripts_domain, 2000)) {
- ERR_PRINT("Mono: Domain finalization timeout");
+ ERR_PRINT("Mono: Domain finalization timeout.");
}
finalizing_scripts_domain = false;
@@ -911,7 +893,7 @@ Error GDMono::_unload_scripts_domain() {
mono_domain_try_unload(domain, (MonoObject **)&exc);
if (exc) {
- ERR_PRINT("Exception thrown when unloading scripts domain");
+ ERR_PRINT("Exception thrown when unloading scripts domain.");
GDMonoUtils::debug_unhandled_exception(exc);
return FAILED;
}
@@ -925,20 +907,14 @@ Error GDMono::reload_scripts_domain() {
ERR_FAIL_COND_V(!runtime_initialized, ERR_BUG);
if (scripts_domain) {
- Error err = _unload_scripts_domain();
- if (err != OK) {
- ERR_PRINT("Mono: Failed to unload scripts domain");
- return err;
- }
+ Error domain_unload_err = _unload_scripts_domain();
+ ERR_FAIL_COND_V_MSG(domain_unload_err != OK, domain_unload_err, "Mono: Failed to unload scripts domain.");
}
CSharpLanguage::get_singleton()->_on_scripts_domain_unloaded();
- Error err = _load_scripts_domain();
- if (err != OK) {
- ERR_PRINT("Mono: Failed to load scripts domain");
- return err;
- }
+ Error domain_load_err = _load_scripts_domain();
+ ERR_FAIL_COND_V_MSG(domain_load_err != OK, domain_load_err, "Mono: Failed to load scripts domain.");
// Load assemblies. The API and tools assemblies are required,
// the application is aborted if these assemblies cannot be loaded.
@@ -946,10 +922,8 @@ Error GDMono::reload_scripts_domain() {
_load_api_assemblies();
#if defined(TOOLS_ENABLED)
- if (!_load_tools_assemblies()) {
- ERR_EXPLAIN("Mono: Failed to load GodotTools assemblies");
- CRASH_NOW();
- }
+ bool tools_assemblies_loaded = _load_tools_assemblies();
+ CRASH_COND_MSG(!tools_assemblies_loaded, "Mono: Failed to load '" TOOLS_ASM_NAME "' assemblies.");
#endif
// Load the project's main assembly. Here, during hot-reloading, we do
@@ -971,13 +945,13 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
String domain_name = mono_domain_get_friendly_name(p_domain);
- print_verbose("Mono: Unloading domain `" + domain_name + "`...");
+ print_verbose("Mono: Unloading domain '" + domain_name + "'...");
if (mono_domain_get() == p_domain)
mono_domain_set(root_domain, true);
if (!mono_domain_finalize(p_domain, 2000)) {
- ERR_PRINT("Mono: Domain finalization timeout");
+ ERR_PRINT("Mono: Domain finalization timeout.");
}
mono_gc_collect(mono_gc_max_generation());
@@ -988,7 +962,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
mono_domain_try_unload(p_domain, (MonoObject **)&exc);
if (exc) {
- ERR_PRINTS("Exception thrown when unloading domain `" + domain_name + "`");
+ ERR_PRINTS("Exception thrown when unloading domain '" + domain_name + "'.");
GDMonoUtils::debug_print_unhandled_exception(exc);
return FAILED;
}
@@ -1105,7 +1079,7 @@ GDMono::~GDMono() {
if (scripts_domain) {
Error err = _unload_scripts_domain();
if (err != OK) {
- ERR_PRINT("Mono: Failed to unload scripts domain");
+ ERR_PRINT("Mono: Failed to unload scripts domain.");
}
}
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index 761c7f6fcb..a82bb42731 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -151,14 +151,14 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, vo
}
{
- // If we find the assembly here, we load it with `mono_assembly_load_from_full`,
+ // If we find the assembly here, we load it with 'mono_assembly_load_from_full',
// which in turn invokes load hooks before returning the MonoAssembly to us.
- // One of the load hooks is `load_aot_module`. This hook can end up calling preload hooks
- // again for the same assembly in certain in certain circumstances (the `do_load_image` part).
+ // One of the load hooks is 'load_aot_module'. This hook can end up calling preload hooks
+ // again for the same assembly in certain in certain circumstances (the 'do_load_image' part).
// If this is the case and we return NULL due to the no_search condition below,
// it will result in an internal crash later on. Therefore we need to return the assembly we didn't
- // get yet from `mono_assembly_load_from_full`. Luckily we have the image, which already got it.
- // This must be done here. If done in search hooks, it would cause `mono_assembly_load_from_full`
+ // get yet from 'mono_assembly_load_from_full'. Luckily we have the image, which already got it.
+ // This must be done here. If done in search hooks, it would cause 'mono_assembly_load_from_full'
// to think another MonoAssembly for this assembly was already loaded, making it delete its own,
// when in fact both pointers were the same... This hooks thing is confusing.
if (image_corlib_loading) {
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp
index 1c10d3c8eb..89a88fcfb2 100644
--- a/modules/mono/mono_gd/gd_mono_class.cpp
+++ b/modules/mono/mono_gd/gd_mono_class.cpp
@@ -165,8 +165,8 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
#ifdef DEBUG_ENABLED
String fullname = method->get_ret_type_full_name() + " " + name + "(" + method->get_signature_desc(true) + ")";
- WARN_PRINTS("Method `" + fullname + "` is hidden by Godot API method. Should be `" +
- method->get_full_name_no_class() + "`. In class `" + namespace_name + "." + class_name + "`.");
+ WARN_PRINTS("Method '" + fullname + "' is hidden by Godot API method. Should be '" +
+ method->get_full_name_no_class() + "'. In class '" + namespace_name + "." + class_name + "'.");
#endif
continue;
}
@@ -184,8 +184,8 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
if (m && m->get_name() != name) {
// found
String fullname = m->get_ret_type_full_name() + " " + name + "(" + m->get_signature_desc(true) + ")";
- WARN_PRINTS("Method `" + fullname + "` should be `" + m->get_full_name_no_class() +
- "`. In class `" + namespace_name + "." + class_name + "`.");
+ WARN_PRINTS("Method '" + fullname + "' should be '" + m->get_full_name_no_class() +
+ "'. In class '" + namespace_name + "." + class_name + "'.");
break;
}
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index 3999658f93..7b8e6f89e9 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -219,16 +219,14 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
break;
}
default: {
- ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
- ERR_FAIL();
+ ERR_FAIL_MSG("Attempted to convert Variant to a managed enum value of unmarshallable base type.");
}
}
break;
}
- ERR_EXPLAIN(String() + "Attempted to set the value of a field of unmarshallable type: " + tclass->get_name());
- ERR_FAIL();
+ ERR_FAIL_MSG("Attempted to set the value of a field of unmarshallable type: '" + tclass->get_name() + "'.");
} break;
case MONO_TYPE_ARRAY:
@@ -275,8 +273,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
break;
}
- ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed array of unmarshallable element type.");
- ERR_FAIL();
+ ERR_FAIL_MSG("Attempted to convert Variant to a managed array of unmarshallable element type.");
} break;
case MONO_TYPE_CLASS: {
@@ -351,8 +348,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
}
}
- ERR_EXPLAIN(String() + "Attempted to set the value of a field of unmarshallable type: " + type_class->get_name());
- ERR_FAIL();
+ ERR_FAIL_MSG("Attempted to set the value of a field of unmarshallable type: '" + type_class->get_name() + "'.");
} break;
case MONO_TYPE_OBJECT: {
@@ -508,7 +504,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
} break;
default: {
- ERR_PRINTS(String() + "Attempted to set the value of a field of unexpected type encoding: " + itos(type.type_encoding));
+ ERR_PRINTS("Attempted to set the value of a field of unexpected type encoding: " + itos(type.type_encoding) + ".");
} break;
}
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index e50e3b0794..3324ecb3a8 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -48,7 +48,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
CRASH_COND(!unmanaged);
- // All mono objects created from the managed world (e.g.: `new Player()`)
+ // All mono objects created from the managed world (e.g.: 'new Player()')
// need to have a CSharpScript in order for their methods to be callable from the unmanaged side
Reference *ref = Object::cast_to<Reference>(unmanaged);
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index a6e04e561d..5a0d728953 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -72,7 +72,7 @@ static void mono_log_callback(const char *log_domain, const char *log_level, con
}
if (fatal) {
- ERR_PRINTS("Mono: FATAL ERROR, ABORTING! Logfile: " + GDMonoLog::get_singleton()->get_log_file_path() + "\n");
+ ERR_PRINTS("Mono: FATAL ERROR, ABORTING! Logfile: '" + GDMonoLog::get_singleton()->get_log_file_path() + "'.");
// Make sure to flush before aborting
f->flush();
f->close();
@@ -90,8 +90,7 @@ bool GDMonoLog::_try_create_logs_dir(const String &p_logs_dir) {
DirAccessRef diraccess = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(!diraccess, false);
Error logs_mkdir_err = diraccess->make_dir_recursive(p_logs_dir);
- ERR_EXPLAIN("Failed to create mono logs directory");
- ERR_FAIL_COND_V(logs_mkdir_err != OK, false);
+ ERR_FAIL_COND_V_MSG(logs_mkdir_err != OK, false, "Failed to create mono logs directory.");
}
return true;
@@ -131,7 +130,7 @@ void GDMonoLog::initialize() {
CharString log_level = OS::get_singleton()->get_environment("GODOT_MONO_LOG_LEVEL").utf8();
if (log_level.length() != 0 && log_level_get_id(log_level.get_data()) == -1) {
- ERR_PRINTS(String() + "Mono: Ignoring invalid log level (GODOT_MONO_LOG_LEVEL): " + log_level.get_data());
+ ERR_PRINTS(String() + "Mono: Ignoring invalid log level (GODOT_MONO_LOG_LEVEL): '" + log_level.get_data() + "'.");
log_level = CharString();
}
@@ -160,7 +159,7 @@ void GDMonoLog::initialize() {
log_file = FileAccess::open(log_file_path, FileAccess::WRITE);
if (!log_file) {
- ERR_PRINT("Mono: Cannot create log file");
+ ERR_PRINT("Mono: Cannot create log file.");
}
}
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 42102ed835..7aac691102 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -276,7 +276,7 @@ String mono_to_utf8_string(MonoString *p_mono_string) {
char *utf8 = mono_string_to_utf8_checked(p_mono_string, &error);
if (!mono_error_ok(&error)) {
- ERR_PRINTS(String("Failed to convert MonoString* to UTF-8: ") + mono_error_get_message(&error));
+ ERR_PRINTS(String() + "Failed to convert MonoString* to UTF-8: '" + mono_error_get_message(&error) + "'.");
mono_error_cleanup(&error);
return String();
}
@@ -474,8 +474,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return BOX_ENUM(enum_baseclass, val);
}
default: {
- ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
}
}
}
@@ -509,8 +508,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
- ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed array of unmarshallable element type.");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed array of unmarshallable element type.");
} break;
case MONO_TYPE_CLASS: {
@@ -695,9 +693,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
} break;
}
- ERR_EXPLAIN(String() + "Attempted to convert Variant to an unmarshallable managed type. Name: \'" +
- p_type.type_class->get_name() + "\' Encoding: " + itos(p_type.type_encoding));
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to an unmarshallable managed type. Name: '" +
+ p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + ".");
}
Variant mono_object_to_variant(MonoObject *p_obj) {
@@ -809,8 +806,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return mono_array_to_PoolColorArray((MonoArray *)p_obj);
- ERR_EXPLAIN(String() + "Attempted to convert a managed array of unmarshallable element type to Variant.");
- ERR_FAIL_V(Variant());
+ ERR_FAIL_V_MSG(Variant(), "Attempted to convert a managed array of unmarshallable element type to Variant.");
} break;
case MONO_TYPE_CLASS: {
@@ -908,9 +904,8 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
} break;
}
- ERR_EXPLAIN(String() + "Attempted to convert an unmarshallable managed type to Variant. Name: \'" +
- type.type_class->get_name() + "\' Encoding: " + itos(type.type_encoding));
- ERR_FAIL_V(Variant());
+ ERR_FAIL_V_MSG(Variant(), "Attempted to convert an unmarshallable managed type to Variant. Name: '" +
+ type.type_class->get_name() + "' Encoding: " + itos(type.type_encoding) + ".");
}
MonoArray *Array_to_mono_array(const Array &p_array) {
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 7afdfc8ac8..e385f4c601 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -52,14 +52,11 @@ namespace GDMonoUtils {
MonoCache mono_cache;
-#define CACHE_AND_CHECK(m_var, m_val) \
- { \
- CRASH_COND(m_var != NULL); \
- m_var = m_val; \
- if (!m_var) { \
- ERR_EXPLAIN("Mono Cache: Member " #m_var " is null"); \
- ERR_FAIL(); \
- } \
+#define CACHE_AND_CHECK(m_var, m_val) \
+ { \
+ CRASH_COND(m_var != NULL); \
+ m_var = m_val; \
+ ERR_FAIL_COND_MSG(!m_var, "Mono Cache: Member " #m_var " is null."); \
}
#define CACHE_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(GDMonoUtils::mono_cache.class_##m_class, m_val)
@@ -453,10 +450,9 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) {
}
MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object) {
- if (!ClassDB::is_parent_class(p_object->get_class_name(), p_native)) {
- ERR_EXPLAIN("Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'");
- ERR_FAIL_V(NULL);
- }
+ bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), p_native);
+ ERR_FAIL_COND_V_MSG(!parent_is_object_class, NULL,
+ "Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'.");
MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
ERR_FAIL_NULL_V(mono_object, NULL);
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index 54d73c971f..189ceaab1b 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -67,10 +67,8 @@ Error connect_signal_awaiter(Object *p_source, const String &p_signal, Object *p
Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
#ifdef DEBUG_ENABLED
- if (conn_target_id && !ObjectDB::get_instance(conn_target_id)) {
- ERR_EXPLAIN("Resumed after await, but class instance is gone");
- ERR_FAIL_V(Variant());
- }
+ ERR_FAIL_COND_V_MSG(conn_target_id && !ObjectDB::get_instance(conn_target_id), Variant(),
+ "Resumed after await, but class instance is gone.");
#endif
if (p_argcount < 1) {
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 2b014c2a45..ae5a2cde81 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -55,10 +55,7 @@ int sfind(const String &p_text, int p_from) {
for (int j = 0; j < src_len; j++) {
int read_pos = i + j;
- if (read_pos >= len) {
- ERR_PRINT("read_pos >= len");
- return -1;
- };
+ ERR_FAIL_COND_V(read_pos >= len, -1);
switch (j) {
case 0:
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index 615081d818..d3e8d3c9bb 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -287,8 +287,7 @@ int AudioStreamPlaybackOpus::mix(int16_t *p_buffer, int p_frames) {
int ret = op_read(opus_file, (opus_int16 *)p_buffer, todo * stream_channels, &current_section);
if (ret < 0) {
playing = false;
- ERR_EXPLAIN("Error reading Opus File: " + file);
- ERR_BREAK(ret < 0);
+ ERR_BREAK_MSG(ret < 0, "Error reading Opus file: " + file + ".");
} else if (ret == 0) { // end of song, reload?
op_free(opus_file);
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 8b1f21d95d..cf6b396180 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -149,8 +149,7 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
format = Image::FORMAT_ETC;
break;
default:
- ERR_EXPLAIN("Unsupported format in PVR texture: " + itos(flags & 0xFF));
- ERR_FAIL_V(RES());
+ ERR_FAIL_V_MSG(RES(), "Unsupported format in PVR texture: " + itos(flags & 0xFF) + ".");
}
w.release();
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 64f4c169cb..9b0a55eae3 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -57,8 +57,7 @@ void image_decompress_squish(Image *p_image) {
} else if (p_image->get_format() == Image::FORMAT_RGTC_RG) {
squish_flags = squish::kBc5;
} else {
- ERR_EXPLAIN("Squish: Can't decompress unknown format: " + itos(p_image->get_format()));
- ERR_FAIL_COND(true);
+ ERR_FAIL_MSG("Squish: Can't decompress unknown format: " + itos(p_image->get_format()) + ".");
return;
}
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index b0cd648734..a2ef88d130 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -109,12 +109,10 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
float upscale = upsample ? 2.0 : 1.0;
int w = (int)(svg_image->width * p_scale * upscale);
- ERR_EXPLAIN(vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max width.", rtos(p_scale)));
- ERR_FAIL_COND_V(w > Image::MAX_WIDTH, ERR_PARAMETER_RANGE_ERROR);
+ ERR_FAIL_COND_V_MSG(w > Image::MAX_WIDTH, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max width.", rtos(p_scale)));
int h = (int)(svg_image->height * p_scale * upscale);
- ERR_EXPLAIN(vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale)));
- ERR_FAIL_COND_V(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR);
+ ERR_FAIL_COND_V_MSG(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale)));
PoolVector<uint8_t> dst_image;
dst_image.resize(w * h * 4);
diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp
new file mode 100644
index 0000000000..e1d42d3217
--- /dev/null
+++ b/modules/tinyexr/image_saver_tinyexr.cpp
@@ -0,0 +1,279 @@
+/*************************************************************************/
+/* image_saver_tinyexr.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "image_saver_tinyexr.h"
+#include "core/math/math_funcs.h"
+
+#include "thirdparty/tinyexr/tinyexr.h"
+
+static bool is_supported_format(Image::Format p_format) {
+ // This is checked before anything else.
+ // Mostly uncompressed formats are considered.
+ switch (p_format) {
+ case Image::FORMAT_RF:
+ case Image::FORMAT_RGF:
+ case Image::FORMAT_RGBF:
+ case Image::FORMAT_RGBAF:
+ case Image::FORMAT_RH:
+ case Image::FORMAT_RGH:
+ case Image::FORMAT_RGBH:
+ case Image::FORMAT_RGBAH:
+ case Image::FORMAT_R8:
+ case Image::FORMAT_RG8:
+ case Image::FORMAT_RGB8:
+ case Image::FORMAT_RGBA8:
+ return true;
+ default:
+ return false;
+ }
+}
+
+enum SrcPixelType {
+ SRC_FLOAT,
+ SRC_HALF,
+ SRC_BYTE
+};
+
+static SrcPixelType get_source_pixel_type(Image::Format p_format) {
+ switch (p_format) {
+ case Image::FORMAT_RF:
+ case Image::FORMAT_RGF:
+ case Image::FORMAT_RGBF:
+ case Image::FORMAT_RGBAF:
+ return SRC_FLOAT;
+ case Image::FORMAT_RH:
+ case Image::FORMAT_RGH:
+ case Image::FORMAT_RGBH:
+ case Image::FORMAT_RGBAH:
+ return SRC_HALF;
+ case Image::FORMAT_R8:
+ case Image::FORMAT_RG8:
+ case Image::FORMAT_RGB8:
+ case Image::FORMAT_RGBA8:
+ return SRC_BYTE;
+ default:
+ CRASH_NOW();
+ }
+}
+
+static int get_target_pixel_type(Image::Format p_format) {
+ switch (p_format) {
+ case Image::FORMAT_RF:
+ case Image::FORMAT_RGF:
+ case Image::FORMAT_RGBF:
+ case Image::FORMAT_RGBAF:
+ return TINYEXR_PIXELTYPE_FLOAT;
+ case Image::FORMAT_RH:
+ case Image::FORMAT_RGH:
+ case Image::FORMAT_RGBH:
+ case Image::FORMAT_RGBAH:
+ // EXR doesn't support 8-bit channels so in that case we'll convert
+ case Image::FORMAT_R8:
+ case Image::FORMAT_RG8:
+ case Image::FORMAT_RGB8:
+ case Image::FORMAT_RGBA8:
+ return TINYEXR_PIXELTYPE_HALF;
+ default:
+ CRASH_NOW();
+ }
+}
+
+static int get_pixel_type_size(int p_pixel_type) {
+ switch (p_pixel_type) {
+ case TINYEXR_PIXELTYPE_HALF:
+ return 2;
+ case TINYEXR_PIXELTYPE_FLOAT:
+ return 4;
+ }
+ CRASH_NOW();
+}
+
+static int get_channel_count(Image::Format p_format) {
+ switch (p_format) {
+ case Image::FORMAT_RF:
+ case Image::FORMAT_RH:
+ case Image::FORMAT_R8:
+ return 1;
+ case Image::FORMAT_RGF:
+ case Image::FORMAT_RGH:
+ case Image::FORMAT_RG8:
+ return 2;
+ case Image::FORMAT_RGBF:
+ case Image::FORMAT_RGBH:
+ case Image::FORMAT_RGB8:
+ return 3;
+ case Image::FORMAT_RGBAF:
+ case Image::FORMAT_RGBAH:
+ case Image::FORMAT_RGBA8:
+ return 4;
+ default:
+ CRASH_NOW();
+ }
+}
+
+Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) {
+
+ Image::Format format = p_img->get_format();
+
+ if (!is_supported_format(format)) {
+ // Format not supported
+ print_error("Image format not supported for saving as EXR. Consider saving as PNG.");
+ return ERR_UNAVAILABLE;
+ }
+
+ EXRHeader header;
+ InitEXRHeader(&header);
+
+ EXRImage image;
+ InitEXRImage(&image);
+
+ const int max_channels = 4;
+
+ // Godot does not support more than 4 channels,
+ // so we can preallocate header infos on the stack and use only the subset we need
+ PoolByteArray channels[max_channels];
+ unsigned char *channels_ptrs[max_channels];
+ EXRChannelInfo channel_infos[max_channels];
+ int pixel_types[max_channels];
+ int requested_pixel_types[max_channels] = { -1 };
+
+ // Gimp and Blender are a bit annoying so order of channels isn't straightforward.
+ const int channel_mappings[4][4] = {
+ { 0 }, // R
+ { 1, 0 }, // GR
+ { 2, 1, 0 }, // BGR
+ { 2, 1, 0, 3 } // BGRA
+ };
+
+ int channel_count = get_channel_count(format);
+ ERR_FAIL_COND_V(p_grayscale && channel_count != 1, ERR_INVALID_PARAMETER);
+
+ int target_pixel_type = get_target_pixel_type(format);
+ int target_pixel_type_size = get_pixel_type_size(target_pixel_type);
+ SrcPixelType src_pixel_type = get_source_pixel_type(format);
+ const int pixel_count = p_img->get_width() * p_img->get_height();
+
+ const int *channel_mapping = channel_mappings[channel_count - 1];
+
+ {
+ PoolByteArray src_data = p_img->get_data();
+ PoolByteArray::Read src_r = src_data.read();
+
+ for (int channel_index = 0; channel_index < channel_count; ++channel_index) {
+
+ // De-interleave channels
+
+ PoolByteArray &dst = channels[channel_index];
+ dst.resize(pixel_count * target_pixel_type_size);
+
+ PoolByteArray::Write dst_w = dst.write();
+
+ if (src_pixel_type == SRC_FLOAT && target_pixel_type == TINYEXR_PIXELTYPE_FLOAT) {
+
+ // Note: we don't save mipmaps
+ CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
+
+ const float *src_rp = (float *)src_r.ptr();
+ float *dst_wp = (float *)dst_w.ptr();
+
+ for (int i = 0; i < pixel_count; ++i) {
+ dst_wp[i] = src_rp[channel_index + i * channel_count];
+ }
+
+ } else if (src_pixel_type == SRC_HALF && target_pixel_type == TINYEXR_PIXELTYPE_HALF) {
+
+ CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
+
+ const uint16_t *src_rp = (uint16_t *)src_r.ptr();
+ uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+
+ for (int i = 0; i < pixel_count; ++i) {
+ dst_wp[i] = src_rp[channel_index + i * channel_count];
+ }
+
+ } else if (src_pixel_type == SRC_BYTE && target_pixel_type == TINYEXR_PIXELTYPE_HALF) {
+
+ CRASH_COND(src_data.size() < pixel_count * channel_count);
+
+ const uint8_t *src_rp = (uint8_t *)src_r.ptr();
+ uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+
+ for (int i = 0; i < pixel_count; ++i) {
+ dst_wp[i] = Math::make_half_float(src_rp[channel_index + i * channel_count] / 255.f);
+ }
+
+ } else {
+ CRASH_NOW();
+ }
+
+ int remapped_index = channel_mapping[channel_index];
+
+ channels_ptrs[remapped_index] = dst_w.ptr();
+
+ // No conversion
+ pixel_types[remapped_index] = target_pixel_type;
+ requested_pixel_types[remapped_index] = target_pixel_type;
+
+ // Write channel name
+ if (p_grayscale) {
+ channel_infos[remapped_index].name[0] = 'Y';
+ channel_infos[remapped_index].name[1] = '\0';
+ } else {
+ const char *rgba = "RGBA";
+ channel_infos[remapped_index].name[0] = rgba[channel_index];
+ channel_infos[remapped_index].name[1] = '\0';
+ }
+ }
+ }
+
+ image.images = channels_ptrs;
+ image.num_channels = channel_count;
+ image.width = p_img->get_width();
+ image.height = p_img->get_height();
+
+ header.num_channels = image.num_channels;
+ header.channels = channel_infos;
+ header.pixel_types = pixel_types;
+ header.requested_pixel_types = requested_pixel_types;
+ // TODO DEBUG REMOVE
+ for (int i = 0; i < 4; ++i) {
+ print_line(String("requested_pixel_types{0}: {1}").format(varray(i, requested_pixel_types[i])));
+ }
+
+ CharString utf8_filename = p_path.utf8();
+ const char *err;
+ int ret = SaveEXRImageToFile(&image, &header, utf8_filename.ptr(), &err);
+ if (ret != TINYEXR_SUCCESS) {
+ print_error(String("Saving EXR failed. Error: {0}").format(varray(err)));
+ return ERR_FILE_CANT_WRITE;
+ }
+
+ return OK;
+}
diff --git a/modules/tinyexr/image_saver_tinyexr.h b/modules/tinyexr/image_saver_tinyexr.h
new file mode 100644
index 0000000000..298bd1d21c
--- /dev/null
+++ b/modules/tinyexr/image_saver_tinyexr.h
@@ -0,0 +1,38 @@
+/*************************************************************************/
+/* image_saver_tinyexr.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef IMAGE_SAVER_TINYEXR_H
+#define IMAGE_SAVER_TINYEXR_H
+
+#include "core/os/os.h"
+
+Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
+
+#endif // IMAGE_SAVER_TINYEXR_H
diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp
index 5473a55687..233b3afa08 100644
--- a/modules/tinyexr/register_types.cpp
+++ b/modules/tinyexr/register_types.cpp
@@ -31,6 +31,7 @@
#include "register_types.h"
#include "image_loader_tinyexr.h"
+#include "image_saver_tinyexr.h"
static ImageLoaderTinyEXR *image_loader_tinyexr = NULL;
@@ -38,9 +39,13 @@ void register_tinyexr_types() {
image_loader_tinyexr = memnew(ImageLoaderTinyEXR);
ImageLoader::add_image_format_loader(image_loader_tinyexr);
+
+ Image::save_exr_func = save_exr;
}
void unregister_tinyexr_types() {
memdelete(image_loader_tinyexr);
+
+ Image::save_exr_func = NULL;
}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 4425565afa..3f8b2b1831 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -328,8 +328,7 @@ void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<Visual
if (Object::cast_to<VisualScriptFunction>(*p_node)) {
//the function indeed
- ERR_EXPLAIN("A function node already has been set here.");
- ERR_FAIL_COND(func.function_id >= 0);
+ ERR_FAIL_COND_MSG(func.function_id >= 0, "A function node has already been set here.");
func.function_id = p_id;
}
@@ -1917,8 +1916,7 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
if (!E) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
- ERR_EXPLAIN("No VisualScriptFunction node in function!");
- ERR_FAIL_V(Variant());
+ ERR_FAIL_V_MSG(Variant(), "No VisualScriptFunction node in function.");
}
VisualScriptNodeInstance *node = E->get();
@@ -1974,8 +1972,7 @@ String VisualScriptInstance::to_string(bool *r_valid) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
- ERR_EXPLAIN("Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
- ERR_FAIL_V(String());
+ ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
if (r_valid)
*r_valid = true;
@@ -2262,15 +2259,10 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
- if (instance_id && !ObjectDB::get_instance(instance_id)) {
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
- ERR_FAIL_V(Variant());
- }
- if (script_id && !ObjectDB::get_instance(script_id)) {
- ERR_EXPLAIN("Resumed after yield, but script is gone");
- ERR_FAIL_V(Variant());
- }
+ ERR_FAIL_COND_V_MSG(instance_id && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
+ ERR_FAIL_COND_V_MSG(script_id && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
+
#endif
r_error.error = Variant::CallError::CALL_OK;
@@ -2329,15 +2321,10 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
- if (instance_id && !ObjectDB::get_instance(instance_id)) {
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
- ERR_FAIL_V(Variant());
- }
- if (script_id && !ObjectDB::get_instance(script_id)) {
- ERR_EXPLAIN("Resumed after yield, but script is gone");
- ERR_FAIL_V(Variant());
- }
+ ERR_FAIL_COND_V_MSG(instance_id && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
+ ERR_FAIL_COND_V_MSG(script_id && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
+
#endif
Variant::CallError r_error;
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 41828f040e..764807cffd 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -130,12 +130,14 @@ void VisualScriptPropertySelector::_update_search() {
{
String b = String(E->get());
category = search_options->create_item(root);
- category->set_text(0, b.replace_first("*", ""));
- category->set_selectable(0, false);
- Ref<Texture> icon;
- String rep = b.replace("*", "");
- icon = EditorNode::get_singleton()->get_class_icon(rep);
- category->set_icon(0, icon);
+ if (category) {
+ category->set_text(0, b.replace_first("*", ""));
+ category->set_selectable(0, false);
+ Ref<Texture> icon;
+ String rep = b.replace("*", "");
+ icon = EditorNode::get_singleton()->get_class_icon(rep);
+ category->set_icon(0, icon);
+ }
}
if (properties || seq_connect) {
if (instance) {
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index 2f4a45f108..2f56e778b9 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -116,8 +116,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t *p_buffer, int p_frames) {
if (ret < 0) {
playing = false;
- ERR_EXPLAIN("Error reading OGG Vorbis File: " + file);
- ERR_BREAK(ret < 0);
+ ERR_BREAK_MSG(ret < 0, "Error reading OGG Vorbis file: " + file + ".");
} else if (ret == 0) { // end of song, reload?
ov_clear(&vf);
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 3670edc9ea..fa3602ad27 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -53,8 +53,7 @@ public:
file = FileAccess::open(p_file, FileAccess::READ);
- ERR_EXPLAIN("Failed loading resource: '" + p_file + "';");
- ERR_FAIL_COND(!file);
+ ERR_FAIL_COND_MSG(!file, "Failed loading resource: '" + p_file + "'.");
}
~MkvReader() {
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 630c15f140..8986e49cf0 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -84,8 +84,7 @@ static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V(r[0] != 'W' || r[1] != 'E' || r[2] != 'B' || r[3] != 'P', Ref<Image>());
WebPBitstreamFeatures features;
if (WebPGetFeatures(&r[4], size, &features) != VP8_STATUS_OK) {
- ERR_EXPLAIN("Error unpacking WEBP image:");
- ERR_FAIL_V(Ref<Image>());
+ ERR_FAIL_V_MSG(Ref<Image>(), "Error unpacking WEBP image.");
}
/*
diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp
index 069918cc9c..996db35cba 100644
--- a/modules/webrtc/webrtc_data_channel_js.cpp
+++ b/modules/webrtc/webrtc_data_channel_js.cpp
@@ -68,10 +68,8 @@ void WebRTCDataChannelJS::_on_error() {
}
void WebRTCDataChannelJS::_on_message(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
- if (in_buffer.space_left() < (int)(p_size + 5)) {
- ERR_EXPLAIN("Buffer full! Dropping data");
- ERR_FAIL();
- }
+
+ ERR_FAIL_COND_MSG(in_buffer.space_left() < (int)(p_size + 5), "Buffer full! Dropping data.");
uint8_t is_string = p_is_string ? 1 : 0;
in_buffer.write((uint8_t *)&p_size, 4);
diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp
index 17dafff93a..a759b17b83 100644
--- a/modules/webrtc/webrtc_multiplayer.cpp
+++ b/modules/webrtc/webrtc_multiplayer.cpp
@@ -321,10 +321,8 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size)
if (target_peer > 0) {
E = peer_map.find(target_peer);
- if (!E) {
- ERR_EXPLAIN("Invalid Target Peer: " + itos(target_peer));
- ERR_FAIL_V(ERR_INVALID_PARAMETER);
- }
+ ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer: " + itos(target_peer) + ".");
+
ERR_FAIL_COND_V(E->value()->channels.size() <= ch, ERR_BUG);
ERR_FAIL_COND_V(!E->value()->channels[ch].is_valid(), ERR_BUG);
return E->value()->channels[ch]->put_packet(p_buffer, p_buffer_size);
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
index af98aa750a..5e9dcb5366 100644
--- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp
+++ b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
@@ -51,13 +51,11 @@ Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_l
WebRTCPeerConnection *WebRTCPeerConnectionGDNative::_create() {
WebRTCPeerConnectionGDNative *obj = memnew(WebRTCPeerConnectionGDNative);
- ERR_EXPLAIN("Default GDNative WebRTC implementation not defined.");
- ERR_FAIL_COND_V(!default_library, obj);
+ ERR_FAIL_COND_V_MSG(!default_library, obj, "Default GDNative WebRTC implementation not defined.");
// Call GDNative constructor
Error err = (Error)default_library->create_peer_connection(obj);
- ERR_EXPLAIN("GDNative default library constructor returned an error");
- ERR_FAIL_COND_V(err != OK, obj);
+ ERR_FAIL_COND_V_MSG(err != OK, obj, "GDNative default library constructor returned an error.");
return obj;
}
diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp
index a9f38f1a82..58d4c52688 100644
--- a/modules/websocket/emws_peer.cpp
+++ b/modules/websocket/emws_peer.cpp
@@ -131,14 +131,12 @@ void EMWSPeer::close(int p_code, String p_reason) {
IP_Address EMWSPeer::get_connected_host() const {
- ERR_EXPLAIN("Not supported in HTML5 export");
- ERR_FAIL_V(IP_Address());
+ ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
};
uint16_t EMWSPeer::get_connected_port() const {
- ERR_EXPLAIN("Not supported in HTML5 export");
- ERR_FAIL_V(0);
+ ERR_FAIL_V_MSG(0, "Not supported in HTML5 export.");
};
EMWSPeer::EMWSPeer() {
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index e24cb850ec..62f09bfbf9 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -98,16 +98,14 @@ void WebSocketMultiplayerPeer::_bind_methods() {
//
int WebSocketMultiplayerPeer::get_available_packet_count() const {
- ERR_EXPLAIN("Please use get_peer(ID).get_available_packet_count to get available packet count from peers when not using the MultiplayerAPI.");
- ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).get_available_packet_count to get available packet count from peers when not using the MultiplayerAPI.");
return _incoming_packets.size();
}
Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_EXPLAIN("Please use get_peer(ID).get_packet/var to communicate with peers when not using the MultiplayerAPI.");
- ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).get_packet/var to communicate with peers when not using the MultiplayerAPI.");
r_buffer_size = 0;
@@ -127,8 +125,7 @@ Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buff
Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_EXPLAIN("Please use get_peer(ID).put_packet/var to communicate with peers when not using the MultiplayerAPI.");
- ERR_FAIL_COND_V(!_is_multiplayer, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).put_packet/var to communicate with peers when not using the MultiplayerAPI.");
PoolVector<uint8_t> buffer = _make_pkt(SYS_NONE, get_unique_id(), _target_peer, p_buffer, p_buffer_size);
@@ -160,8 +157,7 @@ void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) {
int WebSocketMultiplayerPeer::get_packet_peer() const {
- ERR_EXPLAIN("This function is not available when not using the MultiplayerAPI.");
- ERR_FAIL_COND_V(!_is_multiplayer, 1);
+ ERR_FAIL_COND_V_MSG(!_is_multiplayer, 1, "This function is not available when not using the MultiplayerAPI.");
ERR_FAIL_COND_V(_incoming_packets.size() == 0, 1);
return _incoming_packets.front()->get().source;
@@ -354,8 +350,7 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u
_peer_id = id;
break;
default:
- ERR_EXPLAIN("Invalid multiplayer message");
- ERR_FAIL();
+ ERR_FAIL_MSG("Invalid multiplayer message.");
break;
}
}
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index af75f2a320..cf2ad55b4a 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -53,8 +53,7 @@ void WSLClient::_do_handshake() {
// Header is too big
disconnect_from_host();
_on_error();
- ERR_EXPLAIN("Response headers too big");
- ERR_FAIL();
+ ERR_FAIL_MSG("Response headers too big.");
}
Error err = _connection->get_partial_data(&_resp_buf[_resp_pos], 1, read);
if (err == ERR_FILE_EOF) {
@@ -81,8 +80,7 @@ void WSLClient::_do_handshake() {
if (!_verify_headers(protocol)) {
disconnect_from_host();
_on_error();
- ERR_EXPLAIN("Invalid response headers");
- ERR_FAIL();
+ ERR_FAIL_MSG("Invalid response headers.");
}
// Create peer.
WSLPeer::PeerData *data = memnew(struct WSLPeer::PeerData);
@@ -103,29 +101,18 @@ bool WSLClient::_verify_headers(String &r_protocol) {
String s = (char *)_resp_buf;
Vector<String> psa = s.split("\r\n");
int len = psa.size();
- if (len < 4) {
- ERR_EXPLAIN("Not enough response headers.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers, got: " + itos(len) + ", expected >= 4.");
Vector<String> req = psa[0].split(" ", false);
- if (req.size() < 2) {
- ERR_EXPLAIN("Invalid protocol or status code.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(req.size() < 2, false, "Invalid protocol or status code.");
+
// Wrong protocol
- if (req[0] != "HTTP/1.1" || req[1] != "101") {
- ERR_EXPLAIN("Invalid protocol or status code.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(req[0] != "HTTP/1.1" || req[1] != "101", false, "Invalid protocol or status code.");
Map<String, String> headers;
for (int i = 1; i < len; i++) {
Vector<String> header = psa[i].split(":", false, 1);
- if (header.size() != 2) {
- ERR_EXPLAIN("Invalid header -> " + psa[i]);
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(header.size() != 2, false, "Invalid header -> " + psa[i] + ".");
String name = header[0].to_lower();
String value = header[1].strip_edges();
if (headers.has(name))
@@ -251,8 +238,7 @@ void WSLClient::poll() {
if (_connection == _tcp) {
// Start SSL handshake
ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
- ERR_EXPLAIN("SSL is not available in this build");
- ERR_FAIL_COND(ssl.is_null());
+ ERR_FAIL_COND_MSG(ssl.is_null(), "SSL is not available in this build.");
ssl->set_blocking_handshake_enabled(false);
if (ssl->connect_to_stream(_tcp, verify_ssl, _host) != OK) {
disconnect_from_host();
@@ -332,8 +318,7 @@ uint16_t WSLClient::get_connected_port() const {
}
Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
- ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
- ERR_FAIL_COND_V(_connection.is_valid(), FAILED);
+ ERR_FAIL_COND_V_MSG(_connection.is_valid(), FAILED, "Buffers sizes can only be set before listening or connecting.");
_in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
_in_pkt_size = nearest_shift(p_in_packets - 1);
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index 0d09a4d74e..1feae420b9 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -45,29 +45,18 @@ WSLServer::PendingPeer::PendingPeer() {
bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) {
Vector<String> psa = String((char *)req_buf).split("\r\n");
int len = psa.size();
- if (len < 4) {
- ERR_EXPLAIN("Not enough response headers.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers, got: " + itos(len) + ", expected >= 4.");
Vector<String> req = psa[0].split(" ", false);
- if (req.size() < 2) {
- ERR_EXPLAIN("Invalid protocol or status code.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(req.size() < 2, false, "Invalid protocol or status code.");
+
// Wrong protocol
- if (req[0] != "GET" || req[2] != "HTTP/1.1") {
- ERR_EXPLAIN("Invalid method or HTTP version.");
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(req[0] != "GET" || req[2] != "HTTP/1.1", false, "Invalid method or HTTP version.");
Map<String, String> headers;
for (int i = 1; i < len; i++) {
Vector<String> header = psa[i].split(":", false, 1);
- if (header.size() != 2) {
- ERR_EXPLAIN("Invalid header -> " + psa[i]);
- ERR_FAIL_V(false);
- }
+ ERR_FAIL_COND_V_MSG(header.size() != 2, false, "Invalid header -> " + psa[i]);
String name = header[0].to_lower();
String value = header[1].strip_edges();
if (headers.has(name))
@@ -115,11 +104,7 @@ Error WSLServer::PendingPeer::do_handshake(PoolStringArray p_protocols) {
if (!has_request) {
int read = 0;
while (true) {
- if (req_pos >= WSL_MAX_HEADER_SIZE) {
- // Header is too big
- ERR_EXPLAIN("Response headers too big");
- ERR_FAIL_V(ERR_OUT_OF_MEMORY);
- }
+ ERR_FAIL_COND_V_MSG(req_pos >= WSL_MAX_HEADER_SIZE, ERR_OUT_OF_MEMORY, "Response headers too big.");
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
if (err != OK) // Got an error
return FAILED;
@@ -277,8 +262,7 @@ void WSLServer::disconnect_peer(int p_peer_id, int p_code, String p_reason) {
}
Error WSLServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
- ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
- ERR_FAIL_COND_V(_server->is_listening(), FAILED);
+ ERR_FAIL_COND_V_MSG(_server->is_listening(), FAILED, "Buffers sizes can only be set before listening or connecting.");
_in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
_in_pkt_size = nearest_shift(p_in_packets - 1);