mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
Replace ERR_FAIL_COND
with ERR_FAIL_NULL
where applicable
This commit is contained in:
parent
6916349697
commit
f18aa00e85
@ -776,7 +776,7 @@ void GDExtension::initialize_library(InitializationLevel p_level) {
|
||||
|
||||
level_initialized = int32_t(p_level);
|
||||
|
||||
ERR_FAIL_COND(initialization.initialize == nullptr);
|
||||
ERR_FAIL_NULL(initialization.initialize);
|
||||
|
||||
initialization.initialize(initialization.userdata, GDExtensionInitializationLevel(p_level));
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static void godot_free(voidpf opaque, voidpf address) {
|
||||
} // extern "C"
|
||||
|
||||
void ZipArchive::close_handle(unzFile p_file) const {
|
||||
ERR_FAIL_COND_MSG(!p_file, "Cannot close a file if none is open.");
|
||||
ERR_FAIL_NULL_MSG(p_file, "Cannot close a file if none is open.");
|
||||
unzCloseCurrentFile(p_file);
|
||||
unzClose(p_file);
|
||||
}
|
||||
@ -136,7 +136,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
|
||||
io.free_mem = godot_free;
|
||||
|
||||
unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io);
|
||||
ERR_FAIL_COND_V_MSG(!pkg, nullptr, "Cannot open file '" + packages[file.package].filename + "'.");
|
||||
ERR_FAIL_NULL_V_MSG(pkg, nullptr, "Cannot open file '" + packages[file.package].filename + "'.");
|
||||
int unz_err = unzGoToFilePos(pkg, &file.file_pos);
|
||||
if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) {
|
||||
unzClose(pkg);
|
||||
@ -168,7 +168,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6
|
||||
io.zerror_file = godot_testerror;
|
||||
|
||||
unzFile zfile = unzOpen2(p_path.utf8().get_data(), &io);
|
||||
ERR_FAIL_COND_V(!zfile, false);
|
||||
ERR_FAIL_NULL_V(zfile, false);
|
||||
|
||||
unz_global_info64 gi;
|
||||
int err = unzGetGlobalInfo64(zfile, &gi);
|
||||
@ -241,7 +241,7 @@ Error FileAccessZip::open_internal(const String &p_path, int p_mode_flags) {
|
||||
ZipArchive *arch = ZipArchive::get_singleton();
|
||||
ERR_FAIL_NULL_V(arch, FAILED);
|
||||
zfile = arch->get_file_handle(p_path);
|
||||
ERR_FAIL_COND_V(!zfile, FAILED);
|
||||
ERR_FAIL_NULL_V(zfile, FAILED);
|
||||
|
||||
int err = unzGetCurrentFileInfo64(zfile, &file_info, nullptr, 0, nullptr, 0, nullptr, 0);
|
||||
ERR_FAIL_COND_V(err != UNZ_OK, FAILED);
|
||||
@ -265,28 +265,28 @@ bool FileAccessZip::is_open() const {
|
||||
}
|
||||
|
||||
void FileAccessZip::seek(uint64_t p_position) {
|
||||
ERR_FAIL_COND(!zfile);
|
||||
ERR_FAIL_NULL(zfile);
|
||||
|
||||
unzSeekCurrentFile(zfile, p_position);
|
||||
}
|
||||
|
||||
void FileAccessZip::seek_end(int64_t p_position) {
|
||||
ERR_FAIL_COND(!zfile);
|
||||
ERR_FAIL_NULL(zfile);
|
||||
unzSeekCurrentFile(zfile, get_length() + p_position);
|
||||
}
|
||||
|
||||
uint64_t FileAccessZip::get_position() const {
|
||||
ERR_FAIL_COND_V(!zfile, 0);
|
||||
ERR_FAIL_NULL_V(zfile, 0);
|
||||
return unztell(zfile);
|
||||
}
|
||||
|
||||
uint64_t FileAccessZip::get_length() const {
|
||||
ERR_FAIL_COND_V(!zfile, 0);
|
||||
ERR_FAIL_NULL_V(zfile, 0);
|
||||
return file_info.uncompressed_size;
|
||||
}
|
||||
|
||||
bool FileAccessZip::eof_reached() const {
|
||||
ERR_FAIL_COND_V(!zfile, true);
|
||||
ERR_FAIL_NULL_V(zfile, true);
|
||||
|
||||
return at_eof;
|
||||
}
|
||||
@ -299,7 +299,7 @@ uint8_t FileAccessZip::get_8() const {
|
||||
|
||||
uint64_t FileAccessZip::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
|
||||
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
|
||||
ERR_FAIL_COND_V(!zfile, -1);
|
||||
ERR_FAIL_NULL_V(zfile, -1);
|
||||
|
||||
at_eof = unzeof(zfile);
|
||||
if (at_eof) {
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
#endif
|
||||
call_with_variant_args(data.instance, data.method, p_arguments, p_argcount, r_call_error);
|
||||
}
|
||||
@ -154,7 +154,7 @@ public:
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
#endif
|
||||
call_with_variant_args_ret(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
}
|
||||
@ -209,7 +209,7 @@ public:
|
||||
|
||||
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
ERR_FAIL_NULL_MSG(ObjectDB::get_instance(ObjectID(data.object_id)), "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
|
||||
#endif
|
||||
call_with_variant_args_retc(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
|
||||
}
|
||||
|
@ -2117,7 +2117,7 @@ Variant::operator ::RID() const {
|
||||
} else if (type == OBJECT && _get_obj().obj) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (EngineDebugger::is_active()) {
|
||||
ERR_FAIL_COND_V_MSG(ObjectDB::get_instance(_get_obj().id) == nullptr, ::RID(), "Invalid pointer (object was freed).");
|
||||
ERR_FAIL_NULL_V_MSG(ObjectDB::get_instance(_get_obj().id), ::RID(), "Invalid pointer (object was freed).");
|
||||
}
|
||||
#endif
|
||||
Callable::CallError ce;
|
||||
|
@ -1236,7 +1236,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend
|
||||
}
|
||||
|
||||
void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index) {
|
||||
ERR_FAIL_COND(!state.canvas_instance_batches[state.current_batch_index].command);
|
||||
ERR_FAIL_NULL(state.canvas_instance_batches[state.current_batch_index].command);
|
||||
|
||||
// Used by Polygon and Mesh.
|
||||
static const GLenum prim[5] = { GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP };
|
||||
@ -2157,7 +2157,7 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe
|
||||
GLES3::Texture *t = texture_storage->get_texture(p_texture);
|
||||
|
||||
if (t) {
|
||||
ERR_FAIL_COND(!t->canvas_texture);
|
||||
ERR_FAIL_NULL(t->canvas_texture);
|
||||
ct = t->canvas_texture;
|
||||
if (t->render_target) {
|
||||
t->render_target->used_in_frame = true;
|
||||
|
@ -2396,7 +2396,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(shader->data == nullptr);
|
||||
ERR_FAIL_NULL(shader->data);
|
||||
|
||||
material->data = material_data_request_func[shader->mode](shader->data);
|
||||
material->data->self = p_material;
|
||||
|
@ -339,7 +339,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
||||
// prev_dir is the directory we are changing out of
|
||||
String prev_dir;
|
||||
char real_current_dir_name[2048];
|
||||
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(getcwd(real_current_dir_name, 2048), ERR_BUG);
|
||||
if (prev_dir.parse_utf8(real_current_dir_name) != OK) {
|
||||
prev_dir = real_current_dir_name; //no utf8, maybe latin?
|
||||
}
|
||||
@ -361,7 +361,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
||||
|
||||
String base = _get_root_path();
|
||||
if (!base.is_empty() && !try_dir.begins_with(base)) {
|
||||
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
|
||||
ERR_FAIL_NULL_V(getcwd(real_current_dir_name, 2048), ERR_BUG);
|
||||
String new_dir;
|
||||
new_dir.parse_utf8(real_current_dir_name);
|
||||
|
||||
@ -496,7 +496,7 @@ DirAccessUnix::DirAccessUnix() {
|
||||
|
||||
// set current directory to an absolute path of the current directory
|
||||
char real_current_dir_name[2048];
|
||||
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr);
|
||||
ERR_FAIL_NULL(getcwd(real_current_dir_name, 2048));
|
||||
if (current_dir.parse_utf8(real_current_dir_name) != OK) {
|
||||
current_dir = real_current_dir_name;
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) {
|
||||
#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \
|
||||
{ \
|
||||
fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
|
||||
ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \
|
||||
ERR_FAIL_NULL_V_MSG(fp##entrypoint, ERR_CANT_CREATE, \
|
||||
"vkGetInstanceProcAddr failed to find vk" #entrypoint); \
|
||||
}
|
||||
|
||||
@ -1689,7 +1689,7 @@ Error VulkanContext::_initialize_queues(VkSurfaceKHR p_surface) {
|
||||
if (!g_gdpa) \
|
||||
g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(inst, "vkGetDeviceProcAddr"); \
|
||||
fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \
|
||||
ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \
|
||||
ERR_FAIL_NULL_V_MSG(fp##entrypoint, ERR_CANT_CREATE, \
|
||||
"vkGetDeviceProcAddr failed to find vk" #entrypoint); \
|
||||
}
|
||||
|
||||
|
@ -3903,7 +3903,7 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
|
||||
ERR_FAIL_NULL(root);
|
||||
ERR_FAIL_COND(history->get_path_size() == 0);
|
||||
Object *obj = ObjectDB::get_instance(history->get_path_object(0));
|
||||
ERR_FAIL_COND(!Object::cast_to<Node>(obj));
|
||||
ERR_FAIL_NULL(Object::cast_to<Node>(obj));
|
||||
|
||||
// Let's build a node path.
|
||||
Node *node = Object::cast_to<Node>(obj);
|
||||
|
@ -686,7 +686,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
|
||||
zlib_filefunc_def io = zipio_create_io(&io_fa);
|
||||
|
||||
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
|
||||
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
|
||||
ERR_FAIL_NULL_V_MSG(pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
|
||||
|
||||
int ret = unzGoToFirstFile(pkg);
|
||||
int total_files = 0;
|
||||
|
@ -2197,7 +2197,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
|
||||
ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it...
|
||||
NodeJoint *nj = dynamic_cast<NodeJoint *>(state.scene_map[nodeid]);
|
||||
ERR_FAIL_NULL_V(nj, false);
|
||||
ERR_FAIL_COND_V(!nj->owner, false); //weird, node should have a skeleton owner
|
||||
ERR_FAIL_NULL_V(nj->owner, false); // Weird, node should have a skeleton owner.
|
||||
|
||||
NodeSkeleton *sk = nj->owner;
|
||||
|
||||
|
@ -96,7 +96,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
|
||||
Error err;
|
||||
Ref<FileAccess> file = FileAccess::open(p_source_file, FileAccess::READ, &err);
|
||||
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
|
||||
ERR_FAIL_COND_V(!file.operator->(), ERR_CANT_OPEN);
|
||||
ERR_FAIL_COND_V(!file.is_valid(), ERR_CANT_OPEN);
|
||||
|
||||
String file_txt = file->get_as_utf8_string();
|
||||
Ref<RDShaderFile> shader_file;
|
||||
|
@ -779,7 +779,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!get_tree());
|
||||
ERR_FAIL_NULL(get_tree());
|
||||
|
||||
HashSet<Ref<Script>> scripts;
|
||||
|
||||
|
@ -363,7 +363,7 @@ void Skeleton3DEditor::pose_to_rest(const bool p_all_bones) {
|
||||
|
||||
void Skeleton3DEditor::create_physical_skeleton() {
|
||||
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
||||
ERR_FAIL_COND(!get_tree());
|
||||
ERR_FAIL_NULL(get_tree());
|
||||
Node *owner = get_tree()->get_edited_scene_root();
|
||||
|
||||
const int bone_count = skeleton->get_bone_count();
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "scene/gui/separator.h"
|
||||
|
||||
#define CHECK_PLUGIN_INITIALIZED() \
|
||||
ERR_FAIL_COND_MSG(!EditorVCSInterface::get_singleton(), "No VCS plugin is initialized. Select a Version Control Plugin from Project menu.");
|
||||
ERR_FAIL_NULL_MSG(EditorVCSInterface::get_singleton(), "No VCS plugin is initialized. Select a Version Control Plugin from Project menu.");
|
||||
|
||||
VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr;
|
||||
|
||||
|
@ -397,7 +397,7 @@ void ProjectDialog::_nonempty_confirmation_ok_pressed() {
|
||||
}
|
||||
|
||||
void ProjectDialog::_renderer_selected() {
|
||||
ERR_FAIL_COND(!renderer_button_group->get_pressed_button());
|
||||
ERR_FAIL_NULL(renderer_button_group->get_pressed_button());
|
||||
|
||||
String renderer_type = renderer_button_group->get_pressed_button()->get_meta(SNAME("rendering_method"));
|
||||
|
||||
|
@ -651,8 +651,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
Node *top_node = selection[i];
|
||||
Node *bottom_node = selection[selection.size() - 1 - i];
|
||||
|
||||
ERR_FAIL_COND(!top_node->get_parent());
|
||||
ERR_FAIL_COND(!bottom_node->get_parent());
|
||||
ERR_FAIL_NULL(top_node->get_parent());
|
||||
ERR_FAIL_NULL(bottom_node->get_parent());
|
||||
|
||||
int bottom_node_pos = bottom_node->get_index(false);
|
||||
int top_node_pos_next = top_node->get_index(false) + (MOVING_DOWN ? 1 : -1);
|
||||
|
@ -252,7 +252,7 @@ int ENetConnection::get_max_channels() const {
|
||||
|
||||
int ENetConnection::get_local_port() const {
|
||||
ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_V_MSG(!(host->socket), 0, "The ENetConnection instance isn't currently bound");
|
||||
ERR_FAIL_NULL_V_MSG(host->socket, 0, "The ENetConnection instance isn't currently bound.");
|
||||
ENetAddress address;
|
||||
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), 0, "Unable to get socket address");
|
||||
return address.port;
|
||||
@ -344,7 +344,7 @@ void ENetConnection::_broadcast(int p_channel, PackedByteArray p_packet, int p_f
|
||||
|
||||
void ENetConnection::socket_send(const String &p_address, int p_port, const PackedByteArray &p_packet) {
|
||||
ERR_FAIL_NULL_MSG(host, "The ENetConnection instance isn't currently active.");
|
||||
ERR_FAIL_COND_MSG(!(host->socket), "The ENetConnection instance isn't currently bound");
|
||||
ERR_FAIL_NULL_MSG(host->socket, "The ENetConnection instance isn't currently bound.");
|
||||
ERR_FAIL_COND_MSG(p_port < 1 || p_port > 65535, "The remote port number must be between 1 and 65535 (inclusive).");
|
||||
|
||||
IPAddress ip;
|
||||
|
@ -5410,7 +5410,7 @@ void GDScriptParser::TreePrinter::print_while(WhileNode *p_while) {
|
||||
}
|
||||
|
||||
void GDScriptParser::TreePrinter::print_tree(const GDScriptParser &p_parser) {
|
||||
ERR_FAIL_COND_MSG(p_parser.get_tree() == nullptr, "Parse the code before printing the parse tree.");
|
||||
ERR_FAIL_NULL_MSG(p_parser.get_tree(), "Parse the code before printing the parse tree.");
|
||||
|
||||
if (p_parser.is_tool()) {
|
||||
push_line("@tool");
|
||||
|
@ -89,7 +89,7 @@ void ManagedCallable::call(const Variant **p_arguments, int p_argcount, Variant
|
||||
r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; // Can't find anything better
|
||||
r_return_value = Variant();
|
||||
|
||||
ERR_FAIL_COND(delegate_handle.value == nullptr);
|
||||
ERR_FAIL_NULL(delegate_handle.value);
|
||||
|
||||
GDMonoCache::managed_callbacks.DelegateUtils_InvokeWithVariantArgs(
|
||||
delegate_handle, trampoline, p_arguments, p_argcount, &r_return_value);
|
||||
|
@ -61,13 +61,13 @@
|
||||
#define GDEXTENSION_INIT_XR_FUNC(name) \
|
||||
do { \
|
||||
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
|
||||
ERR_FAIL_COND(name##_ptr == nullptr); \
|
||||
ERR_FAIL_NULL(name##_ptr); \
|
||||
} while (0)
|
||||
|
||||
#define GDEXTENSION_INIT_XR_FUNC_V(name) \
|
||||
do { \
|
||||
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
|
||||
ERR_FAIL_COND_V(name##_ptr == nullptr, false); \
|
||||
ERR_FAIL_NULL_V(name##_ptr, false); \
|
||||
} while (0)
|
||||
|
||||
#define EXT_PROTO_XRRESULT_FUNC1(func_name, arg1_type, arg1) \
|
||||
|
@ -4084,7 +4084,7 @@ bool TextServerAdvanced::_shaped_text_add_string(const RID &p_shaped, const Stri
|
||||
|
||||
MutexLock lock(sd->mutex);
|
||||
for (int i = 0; i < p_fonts.size(); i++) {
|
||||
ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false);
|
||||
ERR_FAIL_NULL_V(_get_font_data(p_fonts[i]), false);
|
||||
}
|
||||
|
||||
if (p_text.is_empty()) {
|
||||
|
@ -2939,7 +2939,7 @@ bool TextServerFallback::_shaped_text_add_string(const RID &p_shaped, const Stri
|
||||
ERR_FAIL_COND_V(p_size <= 0, false);
|
||||
|
||||
for (int i = 0; i < p_fonts.size(); i++) {
|
||||
ERR_FAIL_COND_V(!_get_font_data(p_fonts[i]), false);
|
||||
ERR_FAIL_NULL_V(_get_font_data(p_fonts[i]), false);
|
||||
}
|
||||
|
||||
if (p_text.is_empty()) {
|
||||
|
@ -317,37 +317,37 @@ String DisplayServerIOS::get_name() const {
|
||||
}
|
||||
|
||||
bool DisplayServerIOS::tts_is_speaking() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts isSpeaking];
|
||||
}
|
||||
|
||||
bool DisplayServerIOS::tts_is_paused() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts isPaused];
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> DisplayServerIOS::tts_get_voices() const {
|
||||
ERR_FAIL_COND_V_MSG(!tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_V_MSG(tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
return [tts getVoices];
|
||||
}
|
||||
|
||||
void DisplayServerIOS::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts speak:p_text voice:p_voice volume:p_volume pitch:p_pitch rate:p_rate utterance_id:p_utterance_id interrupt:p_interrupt];
|
||||
}
|
||||
|
||||
void DisplayServerIOS::tts_pause() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts pauseSpeaking];
|
||||
}
|
||||
|
||||
void DisplayServerIOS::tts_resume() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts resumeSpeaking];
|
||||
}
|
||||
|
||||
void DisplayServerIOS::tts_stop() {
|
||||
ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech.");
|
||||
[tts stopSpeaking];
|
||||
}
|
||||
|
||||
|
@ -2874,7 +2874,7 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
|
||||
*(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(cursor_image->pixels == nullptr);
|
||||
ERR_FAIL_NULL(cursor_image->pixels);
|
||||
|
||||
// Save it for a further usage
|
||||
cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image);
|
||||
|
@ -118,7 +118,7 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod
|
||||
WindowData wd;
|
||||
|
||||
wd.window_delegate = [[GodotWindowDelegate alloc] init];
|
||||
ERR_FAIL_COND_V_MSG(wd.window_delegate == nil, INVALID_WINDOW_ID, "Can't create a window delegate");
|
||||
ERR_FAIL_NULL_V_MSG(wd.window_delegate, INVALID_WINDOW_ID, "Can't create a window delegate");
|
||||
[wd.window_delegate setWindowID:window_id_counter];
|
||||
|
||||
int rq_screen = get_screen_from_rect(p_rect);
|
||||
@ -144,11 +144,11 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
ERR_FAIL_COND_V_MSG(wd.window_object == nil, INVALID_WINDOW_ID, "Can't create a window");
|
||||
ERR_FAIL_NULL_V_MSG(wd.window_object, INVALID_WINDOW_ID, "Can't create a window");
|
||||
[wd.window_object setWindowID:window_id_counter];
|
||||
|
||||
wd.window_view = [[GodotContentView alloc] init];
|
||||
ERR_FAIL_COND_V_MSG(wd.window_view == nil, INVALID_WINDOW_ID, "Can't create a window view");
|
||||
ERR_FAIL_NULL_V_MSG(wd.window_view, INVALID_WINDOW_ID, "Can't create a window view");
|
||||
[wd.window_view setWindowID:window_id_counter];
|
||||
[wd.window_view setWantsLayer:TRUE];
|
||||
|
||||
@ -567,7 +567,7 @@ NSImage *DisplayServerMacOS::_convert_to_nsimg(Ref<Image> &p_image) const {
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:int(p_image->get_width()) * 4
|
||||
bitsPerPixel:32];
|
||||
ERR_FAIL_COND_V(imgrep == nil, nil);
|
||||
ERR_FAIL_NULL_V(imgrep, nil);
|
||||
uint8_t *pixels = [imgrep bitmapData];
|
||||
|
||||
int len = p_image->get_width() * p_image->get_height();
|
||||
@ -583,7 +583,7 @@ NSImage *DisplayServerMacOS::_convert_to_nsimg(Ref<Image> &p_image) const {
|
||||
}
|
||||
|
||||
NSImage *nsimg = [[NSImage alloc] initWithSize:NSMakeSize(p_image->get_width(), p_image->get_height())];
|
||||
ERR_FAIL_COND_V(nsimg == nil, nil);
|
||||
ERR_FAIL_NULL_V(nsimg, nil);
|
||||
[nsimg addRepresentation:imgrep];
|
||||
return nsimg;
|
||||
}
|
||||
@ -1574,7 +1574,7 @@ void DisplayServerMacOS::global_menu_set_item_hover_callbacks(const String &p_me
|
||||
NSMenuItem *menu_item = [menu itemAtIndex:p_idx];
|
||||
if (menu_item) {
|
||||
GodotMenuItem *obj = [menu_item representedObject];
|
||||
ERR_FAIL_COND(!obj);
|
||||
ERR_FAIL_NULL(obj);
|
||||
obj->hover_callback = p_callback;
|
||||
}
|
||||
}
|
||||
@ -3858,7 +3858,7 @@ void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor,
|
||||
bytesPerRow:int(texture_size.width) * 4
|
||||
bitsPerPixel:32];
|
||||
|
||||
ERR_FAIL_COND(imgrep == nil);
|
||||
ERR_FAIL_NULL(imgrep);
|
||||
uint8_t *pixels = [imgrep bitmapData];
|
||||
|
||||
int len = int(texture_size.width * texture_size.height);
|
||||
@ -4124,7 +4124,7 @@ void DisplayServerMacOS::set_icon(const Ref<Image> &p_icon) {
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:img->get_width() * 4
|
||||
bitsPerPixel:32];
|
||||
ERR_FAIL_COND(imgrep == nil);
|
||||
ERR_FAIL_NULL(imgrep);
|
||||
uint8_t *pixels = [imgrep bitmapData];
|
||||
|
||||
int len = img->get_width() * img->get_height();
|
||||
@ -4140,7 +4140,7 @@ void DisplayServerMacOS::set_icon(const Ref<Image> &p_icon) {
|
||||
}
|
||||
|
||||
NSImage *nsimg = [[NSImage alloc] initWithSize:NSMakeSize(img->get_width(), img->get_height())];
|
||||
ERR_FAIL_COND(nsimg == nil);
|
||||
ERR_FAIL_NULL(nsimg);
|
||||
|
||||
[nsimg addRepresentation:imgrep];
|
||||
[NSApp setApplicationIconImage:nsimg];
|
||||
|
@ -50,10 +50,10 @@ Error GLManagerLegacy_MacOS::create_context(GLWindow &win) {
|
||||
};
|
||||
|
||||
NSOpenGLPixelFormat *pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
ERR_FAIL_COND_V(pixel_format == nil, ERR_CANT_CREATE);
|
||||
ERR_FAIL_NULL_V(pixel_format, ERR_CANT_CREATE);
|
||||
|
||||
win.context = [[NSOpenGLContext alloc] initWithFormat:pixel_format shareContext:shared_context];
|
||||
ERR_FAIL_COND_V(win.context == nil, ERR_CANT_CREATE);
|
||||
ERR_FAIL_NULL_V(win.context, ERR_CANT_CREATE);
|
||||
if (shared_context == nullptr) {
|
||||
shared_context = win.context;
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ OS_MacOS::OS_MacOS() {
|
||||
[NSApp finishLaunching];
|
||||
|
||||
id delegate = [[GodotApplicationDelegate alloc] init];
|
||||
ERR_FAIL_COND(!delegate);
|
||||
ERR_FAIL_NULL(delegate);
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
pre_wait_observer = CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, &pre_wait_observer_cb, nullptr);
|
||||
|
@ -163,7 +163,7 @@ void JavaScriptObjectImpl::_get_property_list(List<PropertyInfo> *p_list) const
|
||||
}
|
||||
|
||||
void JavaScriptObjectImpl::_free_lock(void **p_lock, int p_type) {
|
||||
ERR_FAIL_COND_MSG(*p_lock == nullptr, "No lock to free!");
|
||||
ERR_FAIL_NULL_MSG(*p_lock, "No lock to free!");
|
||||
const Variant::Type type = (Variant::Type)p_type;
|
||||
switch (type) {
|
||||
case Variant::STRING: {
|
||||
|
@ -544,12 +544,12 @@ bool AnimationPlayer::is_valid() const {
|
||||
}
|
||||
|
||||
double AnimationPlayer::get_current_animation_position() const {
|
||||
ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
|
||||
ERR_FAIL_NULL_V_MSG(playback.current.from, 0, "AnimationPlayer has no current animation.");
|
||||
return playback.current.pos;
|
||||
}
|
||||
|
||||
double AnimationPlayer::get_current_animation_length() const {
|
||||
ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
|
||||
ERR_FAIL_NULL_V_MSG(playback.current.from, 0, "AnimationPlayer has no current animation.");
|
||||
return playback.current.from->animation->get_length();
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ void GraphElement::gui_input(const Ref<InputEvent> &p_ev) {
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_ev;
|
||||
if (mb.is_valid()) {
|
||||
ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphElement must be the child of a GraphEdit node.");
|
||||
ERR_FAIL_NULL_MSG(get_parent_control(), "GraphElement must be the child of a GraphEdit node.");
|
||||
|
||||
if (mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
|
||||
Vector2 mpos = mb->get_position();
|
||||
|
@ -411,7 +411,7 @@ public:
|
||||
Window *get_last_exclusive_window() const;
|
||||
|
||||
_FORCE_INLINE_ SceneTree *get_tree() const {
|
||||
ERR_FAIL_COND_V(!data.tree, nullptr);
|
||||
ERR_FAIL_NULL_V(data.tree, nullptr);
|
||||
return data.tree;
|
||||
}
|
||||
|
||||
|
@ -2734,7 +2734,7 @@ Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subw
|
||||
|
||||
bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
|
||||
if (gui.subwindow_drag != SUB_WINDOW_DRAG_DISABLED) {
|
||||
ERR_FAIL_COND_V(gui.currently_dragged_subwindow == nullptr, false);
|
||||
ERR_FAIL_NULL_V(gui.currently_dragged_subwindow, false);
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
|
||||
|
@ -779,7 +779,7 @@ void Window::set_visible(bool p_visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_MSG(get_parent() == nullptr, "Can't change visibility of main window.");
|
||||
ERR_FAIL_NULL_MSG(get_parent(), "Can't change visibility of main window.");
|
||||
|
||||
visible = p_visible;
|
||||
|
||||
|
@ -186,7 +186,7 @@ void SkeletonModification2DPhysicalBones::set_physical_bone_chain_length(int p_l
|
||||
|
||||
void SkeletonModification2DPhysicalBones::fetch_physical_bones() {
|
||||
ERR_FAIL_NULL_MSG(stack, "No modification stack found! Cannot fetch physical bones!");
|
||||
ERR_FAIL_COND_MSG(!stack->skeleton, "No skeleton found! Cannot fetch physical bones!");
|
||||
ERR_FAIL_NULL_MSG(stack->skeleton, "No skeleton found! Cannot fetch physical bones!");
|
||||
|
||||
physical_bone_chain.clear();
|
||||
|
||||
|
@ -194,7 +194,7 @@ Variant GodotArea2D::get_param(PhysicsServer2D::AreaParameter p_param) const {
|
||||
}
|
||||
|
||||
void GodotArea2D::_queue_monitor_update() {
|
||||
ERR_FAIL_COND(!get_space());
|
||||
ERR_FAIL_NULL(get_space());
|
||||
|
||||
if (!monitor_query_list.in_list()) {
|
||||
get_space()->area_add_to_monitor_query_list(&monitor_query_list);
|
||||
|
@ -422,7 +422,7 @@ void GodotBody2D::integrate_forces(real_t p_step) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!get_space());
|
||||
ERR_FAIL_NULL(get_space());
|
||||
|
||||
int ac = areas.size();
|
||||
|
||||
|
@ -994,7 +994,7 @@ void GodotPhysicsServer2D::body_set_pickable(RID p_body, bool p_pickable) {
|
||||
bool GodotPhysicsServer2D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
|
||||
GodotBody2D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_NULL_V(body, false);
|
||||
ERR_FAIL_COND_V(!body->get_space(), false);
|
||||
ERR_FAIL_NULL_V(body->get_space(), false);
|
||||
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
|
||||
|
||||
_update_shapes();
|
||||
|
@ -223,7 +223,7 @@ Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
|
||||
}
|
||||
|
||||
void GodotArea3D::_queue_monitor_update() {
|
||||
ERR_FAIL_COND(!get_space());
|
||||
ERR_FAIL_NULL(get_space());
|
||||
|
||||
if (!monitor_query_list.in_list()) {
|
||||
get_space()->area_add_to_monitor_query_list(&monitor_query_list);
|
||||
|
@ -477,7 +477,7 @@ void GodotBody3D::integrate_forces(real_t p_step) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!get_space());
|
||||
ERR_FAIL_NULL(get_space());
|
||||
|
||||
int ac = areas.size();
|
||||
|
||||
|
@ -912,7 +912,7 @@ void GodotPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
|
||||
bool GodotPhysicsServer3D::body_test_motion(RID p_body, const MotionParameters &p_parameters, MotionResult *r_result) {
|
||||
GodotBody3D *body = body_owner.get_or_null(p_body);
|
||||
ERR_FAIL_NULL_V(body, false);
|
||||
ERR_FAIL_COND_V(!body->get_space(), false);
|
||||
ERR_FAIL_NULL_V(body->get_space(), false);
|
||||
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
|
||||
|
||||
_update_shapes();
|
||||
@ -1225,7 +1225,7 @@ void GodotPhysicsServer3D::joint_make_pin(RID p_joint, RID p_body_A, const Vecto
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
@ -1297,7 +1297,7 @@ void GodotPhysicsServer3D::joint_make_hinge(RID p_joint, RID p_body_A, const Tra
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
@ -1321,7 +1321,7 @@ void GodotPhysicsServer3D::joint_make_hinge_simple(RID p_joint, RID p_body_A, co
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
@ -1422,7 +1422,7 @@ void GodotPhysicsServer3D::joint_make_slider(RID p_joint, RID p_body_A, const Tr
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
@ -1462,7 +1462,7 @@ void GodotPhysicsServer3D::joint_make_cone_twist(RID p_joint, RID p_body_A, cons
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
@ -1502,7 +1502,7 @@ void GodotPhysicsServer3D::joint_make_generic_6dof(RID p_joint, RID p_body_A, co
|
||||
ERR_FAIL_NULL(body_A);
|
||||
|
||||
if (!p_body_B.is_valid()) {
|
||||
ERR_FAIL_COND(!body_A->get_space());
|
||||
ERR_FAIL_NULL(body_A->get_space());
|
||||
p_body_B = body_A->get_space()->get_static_global_body();
|
||||
}
|
||||
|
||||
|
@ -967,7 +967,7 @@ Vector3 GodotSoftBody3D::_compute_area_windforce(const GodotArea3D *p_area, cons
|
||||
void GodotSoftBody3D::predict_motion(real_t p_delta) {
|
||||
const real_t inv_delta = 1.0 / p_delta;
|
||||
|
||||
ERR_FAIL_COND(!get_space());
|
||||
ERR_FAIL_NULL(get_space());
|
||||
|
||||
bool gravity_done = false;
|
||||
Vector3 gravity;
|
||||
|
@ -2115,7 +2115,7 @@ void MaterialStorage::material_set_shader(RID p_material, RID p_shader) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(shader->data == nullptr);
|
||||
ERR_FAIL_NULL(shader->data);
|
||||
|
||||
material->data = material_data_request_func[shader->type](shader->data);
|
||||
material->data->self = p_material;
|
||||
|
@ -1377,7 +1377,7 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
|
||||
if (p_allow_reassign) {
|
||||
break;
|
||||
}
|
||||
ERR_FAIL_COND_V(!p_block->parent_block, false);
|
||||
ERR_FAIL_NULL_V(p_block->parent_block, false);
|
||||
p_block = p_block->parent_block;
|
||||
}
|
||||
}
|
||||
|
2
thirdparty/enet/godot.cpp
vendored
2
thirdparty/enet/godot.cpp
vendored
@ -458,7 +458,7 @@ int enet_host_dtls_client_setup(ENetHost *host, const char *p_for_hostname, void
|
||||
}
|
||||
|
||||
void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) {
|
||||
ERR_FAIL_COND(!host->socket);
|
||||
ERR_FAIL_NULL(host->socket);
|
||||
((ENetGodotSocket *)host->socket)->set_refuse_new_connections(p_refuse);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user