Fix always true/false values

This commit is contained in:
qarmin 2019-06-20 16:59:48 +02:00
parent 7a8dcb9a11
commit 072e40368e
32 changed files with 128 additions and 184 deletions

View file

@ -666,10 +666,8 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
if (!type) {
ERR_FAIL_COND(!type);
}
ERR_FAIL_COND(!type);
if (type->constant_map.has(p_name)) {

View file

@ -141,9 +141,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
int left = cache_data_left();
if (left == 0) {
if (to_read > 0) {
file.offset += to_read;
};
file.offset += to_read;
return total_read;
};
if (left < 0) {

View file

@ -103,10 +103,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
const uint8_t *buf = p_buffer;
int len = p_len;
if (len < 4) {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
}
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
uint32_t type = decode_uint32(buf);

View file

@ -991,10 +991,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err != OK) {
ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>());
}
ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>());
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
String path = p_original_path != "" ? p_original_path : p_path;
@ -1129,9 +1126,8 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
Error err;
f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err != OK) {
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
}
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);

View file

@ -486,9 +486,7 @@ Error XMLParser::open(const String &p_path) {
Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
ERR_FAIL_COND_V(err != OK, err);
}
ERR_FAIL_COND_V(err != OK, err);
length = file->get_len();
ERR_FAIL_COND_V(length < 1, ERR_FILE_CORRUPT);

View file

@ -600,9 +600,8 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
if (!f) {
if (r_error) { // if error requested, do not throw error
return Vector<uint8_t>();
} else {
ERR_FAIL_COND_V(!f, Vector<uint8_t>());
}
ERR_FAIL_COND_V(!f, Vector<uint8_t>());
}
Vector<uint8_t> data;
data.resize(f->get_len());
@ -621,9 +620,8 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
if (err != OK) {
if (r_error) {
return String();
} else {
ERR_FAIL_COND_V(err != OK, String());
}
ERR_FAIL_COND_V(err != OK, String());
}
String ret;

View file

@ -500,9 +500,7 @@ void *PoolAllocator::get(ID p_mem) {
if (!needs_locking) {
Entry *e = get_entry(p_mem);
if (!e) {
ERR_FAIL_COND_V(!e, NULL);
};
ERR_FAIL_COND_V(!e, NULL);
return &pool[e->pos];
}

View file

@ -4505,9 +4505,7 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene
ERR_FAIL_COND(!inst);
} break;
default: {
if (!inst) {
ERR_FAIL();
}
ERR_FAIL();
}
}
@ -4552,15 +4550,10 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc
ERR_FAIL_COND(!inst);
} break;
default: {
if (!inst) {
ERR_FAIL();
}
ERR_FAIL();
}
}
ERR_FAIL_COND(!inst);
inst->instance_list.remove(&p_instance->dependency_item);
}

View file

@ -327,9 +327,6 @@ void RasterizerCanvasGLES3::_draw_polygon(const int *p_indices, int p_index_coun
uint32_t buffer_ofs = 0;
//vertex
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(buffer_ofs > data.polygon_buffer_size);
#endif
glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_vertices);
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));

View file

@ -4290,7 +4290,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
use_mrt = use_mrt && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS];
use_mrt = use_mrt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW;
use_mrt = use_mrt && env && (env->bg_mode != VS::ENV_BG_KEEP && env->bg_mode != VS::ENV_BG_CANVAS);
use_mrt = use_mrt && (env->bg_mode != VS::ENV_BG_KEEP && env->bg_mode != VS::ENV_BG_CANVAS);
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);

View file

@ -6702,9 +6702,7 @@ void RasterizerStorageGLES3::instance_add_dependency(RID p_base, RasterizerScene
ERR_FAIL_COND(!inst);
} break;
default: {
if (!inst) {
ERR_FAIL();
}
ERR_FAIL();
}
}
@ -6749,15 +6747,10 @@ void RasterizerStorageGLES3::instance_remove_dependency(RID p_base, RasterizerSc
ERR_FAIL_COND(!inst);
} break;
default: {
if (!inst) {
ERR_FAIL();
}
ERR_FAIL();
}
}
ERR_FAIL_COND(!inst);
inst->instance_list.remove(&p_instance->dependency_item);
}

View file

@ -421,7 +421,7 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
pfd.events = POLLOUT;
break;
case POLL_TYPE_IN_OUT:
pfd.events = POLLOUT || POLLIN;
pfd.events = POLLOUT | POLLIN;
}
int ret = ::poll(&pfd, 1, p_timeout);

View file

@ -77,9 +77,8 @@ void ResourceImporterImage::get_import_options(List<ImportOption> *r_options, in
Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
if (!f) {
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
}
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
size_t len = f->get_len();

View file

@ -215,7 +215,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
bool flip_faces = false;
int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
Vector<Vector3> vertices;
@ -293,7 +292,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
int idx = j;
if (!flip_faces && idx < 2) {
if (idx < 2) {
idx = 1 ^ idx;
}

View file

@ -1868,9 +1868,7 @@ Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error
Ref<TextFile> text_res(text_file);
Error err = text_file->load_text(path);
if (err != OK) {
ERR_FAIL_COND_V(err != OK, RES());
}
ERR_FAIL_COND_V(err != OK, RES());
text_file->set_file_path(local_path);
text_file->set_path(local_path, true);

View file

@ -1275,13 +1275,13 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_edit.mode = TRANSFORM_TRANSLATE;
}
if (cursor.region_select && nav_mode == NAVIGATION_NONE) {
if (cursor.region_select) {
cursor.region_end = m->get_position();
surface->update();
return;
}
if (_edit.mode == TRANSFORM_NONE && nav_mode == NAVIGATION_NONE)
if (_edit.mode == TRANSFORM_NONE)
return;
Vector3 ray_pos = _get_ray_pos(m->get_position());

View file

@ -573,13 +573,11 @@ void VisualShaderEditor::_update_graph() {
name_box->connect("text_entered", this, "_change_input_port_name", varray(name_box, nodes[n_i], i));
name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, nodes[n_i], i, false));
if (is_group) {
Button *remove_btn = memnew(Button);
remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
remove_btn->connect("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
}
Button *remove_btn = memnew(Button);
remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
remove_btn->set_tooltip(TTR("Remove") + " " + name_left);
remove_btn->connect("pressed", this, "_remove_input_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
} else {
Label *label = memnew(Label);

View file

@ -305,49 +305,51 @@ void ScriptEditorDebugger::_scene_tree_rmb_selected(const Vector2 &p_position) {
}
void ScriptEditorDebugger::_file_selected(const String &p_file) {
if (file_dialog_mode == SAVE_NODE) {
switch (file_dialog_mode) {
case SAVE_NODE: {
Array msg;
msg.push_back("save_node");
msg.push_back(inspected_object_id);
msg.push_back(p_file);
ppeer->put_var(msg);
} break;
case SAVE_CSV: {
Error err;
FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
Array msg;
msg.push_back("save_node");
msg.push_back(inspected_object_id);
msg.push_back(p_file);
ppeer->put_var(msg);
} else if (file_dialog_mode == SAVE_CSV) {
if (err != OK) {
ERR_PRINTS("Failed to open " + p_file);
return;
}
Vector<String> line;
line.resize(Performance::MONITOR_MAX);
Error err;
FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINTS("Failed to open " + p_file);
return;
}
Vector<String> line;
line.resize(Performance::MONITOR_MAX);
// signatures
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
}
file->store_csv_line(line);
// values
List<Vector<float> >::Element *E = perf_history.back();
while (E) {
Vector<float> &perf_data = E->get();
for (int i = 0; i < perf_data.size(); i++) {
line.write[i] = String::num_real(perf_data[i]);
// signatures
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
}
file->store_csv_line(line);
E = E->prev();
}
file->store_string("\n");
Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
for (int i = 0; i < profiler_data.size(); i++) {
file->store_csv_line(profiler_data[i]);
}
// values
List<Vector<float> >::Element *E = perf_history.back();
while (E) {
Vector<float> &perf_data = E->get();
for (int i = 0; i < perf_data.size(); i++) {
line.write[i] = String::num_real(perf_data[i]);
}
file->store_csv_line(line);
E = E->prev();
}
file->store_string("\n");
Vector<Vector<String> > profiler_data = profiler->get_data_as_csv();
for (int i = 0; i < profiler_data.size(); i++) {
file->store_csv_line(profiler_data[i]);
}
} break;
}
}

View file

@ -1834,12 +1834,12 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb ? pb->get_global_transform() : Transform(),
pbp ? pbp->get_global_transform() : Transform(),
pb->get_global_transform(),
pbp->get_global_transform(),
cjd->swing_span,
cjd->twist_span,
pb ? &points : NULL,
pbp ? &points : NULL);
&points,
&points);
} break;
case PhysicalBone::JOINT_TYPE_HINGE: {
@ -1847,14 +1847,14 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateHingeJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb ? pb->get_global_transform() : Transform(),
pbp ? pbp->get_global_transform() : Transform(),
pb->get_global_transform(),
pbp->get_global_transform(),
hjd->angular_limit_lower,
hjd->angular_limit_upper,
hjd->angular_limit_enabled,
points,
pb ? &points : NULL,
pbp ? &points : NULL);
&points,
&points);
} break;
case PhysicalBone::JOINT_TYPE_SLIDER: {
@ -1862,15 +1862,15 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
JointSpatialGizmoPlugin::CreateSliderJointGizmo(
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb ? pb->get_global_transform() : Transform(),
pbp ? pbp->get_global_transform() : Transform(),
pb->get_global_transform(),
pbp->get_global_transform(),
sjd->angular_limit_lower,
sjd->angular_limit_upper,
sjd->linear_limit_lower,
sjd->linear_limit_upper,
points,
pb ? &points : NULL,
pbp ? &points : NULL);
&points,
&points);
} break;
case PhysicalBone::JOINT_TYPE_6DOF: {
@ -1879,8 +1879,8 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
physical_bone->get_joint_offset(),
physical_bone->get_global_transform() * physical_bone->get_joint_offset(),
pb ? pb->get_global_transform() : Transform(),
pbp ? pbp->get_global_transform() : Transform(),
pb->get_global_transform(),
pbp->get_global_transform(),
sdofjd->axis_data[0].angular_limit_lower,
sdofjd->axis_data[0].angular_limit_upper,
@ -1904,8 +1904,8 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
sdofjd->axis_data[2].linear_limit_enabled,
points,
pb ? &points : NULL,
pbp ? &points : NULL);
&points,
&points);
} break;
default:
return;

View file

@ -261,12 +261,10 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
ERR_FAIL_COND_V(color_table_size == 0, ERR_BUG);
PoolVector<uint8_t> bmp_color_table;
if (color_table_size > 0) {
// Color table is usually 4 bytes per color -> [B][G][R][0]
err = bmp_color_table.resize(color_table_size * 4);
PoolVector<uint8_t>::Write bmp_color_table_w = bmp_color_table.write();
f->get_buffer(bmp_color_table_w.ptr(), color_table_size * 4);
}
// Color table is usually 4 bytes per color -> [B][G][R][0]
err = bmp_color_table.resize(color_table_size * 4);
PoolVector<uint8_t>::Write bmp_color_table_w = bmp_color_table.write();
f->get_buffer(bmp_color_table_w.ptr(), color_table_size * 4);
f->seek(bmp_header.bmp_file_header.bmp_file_offset);

View file

@ -1018,15 +1018,15 @@ int CSGBrushOperation::MeshMerge::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from
max_depth = p_depth;
}
if (p_size <= BVH_LIMIT) {
if (p_size == 0) {
return -1;
} else if (p_size <= BVH_LIMIT) {
for (int i = 0; i < p_size - 1; i++) {
p_bb[p_from + i]->next = p_bb[p_from + i + 1] - p_bvh;
}
return p_bb[p_from] - p_bvh;
} else if (p_size == 0) {
return -1;
}
AABB aabb;

View file

@ -1816,11 +1816,9 @@ CSGBrush *CSGPolygon::_build_brush() {
path_cache = path;
if (path_cache) {
path_cache->connect("tree_exited", this, "_path_exited");
path_cache->connect("curve_changed", this, "_path_changed");
path_cache = NULL;
}
path_cache->connect("tree_exited", this, "_path_exited");
path_cache->connect("curve_changed", this, "_path_changed");
path_cache = NULL;
}
curve = path->get_curve();
if (curve.is_null())

View file

@ -82,9 +82,8 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
float loop_offset = p_options["loop_offset"];
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
if (!f) {
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
}
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
size_t len = f->get_len();

View file

@ -1692,7 +1692,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
if ((ret == output || ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) && node->sequence_output_count) {
//if no exit bit was set, and has sequence outputs, guess next node
if (output < 0 || output >= node->sequence_output_count) {
if (output >= node->sequence_output_count) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Node returned an invalid sequence output: ") + itos(output);
error = true;

View file

@ -188,7 +188,6 @@ void VisualScriptPropertySelector::_update_search() {
}
}
}
bool script_methods = false;
{
if (type != Variant::NIL) {
Variant v;
@ -211,7 +210,7 @@ void VisualScriptPropertySelector::_update_search() {
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
String name = M->get().name.get_slice(":", 0);
if (!script_methods && name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL))
if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL))
continue;
if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL))

View file

@ -61,9 +61,7 @@ void Joint2D::_update_joint(bool p_only_free) {
if (!body_a || !body_b)
return;
if (!body_a) {
SWAP(body_a, body_b);
}
SWAP(body_a, body_b);
joint = _configure_joint(body_a, body_b);

View file

@ -439,27 +439,26 @@ double ScrollBar::get_grabber_size() const {
}
double ScrollBar::get_area_size() const {
if (orientation == VERTICAL) {
double area = get_size().height;
area -= get_stylebox("scroll")->get_minimum_size().height;
area -= get_icon("increment")->get_height();
area -= get_icon("decrement")->get_height();
area -= get_grabber_min_size();
return area;
} else if (orientation == HORIZONTAL) {
double area = get_size().width;
area -= get_stylebox("scroll")->get_minimum_size().width;
area -= get_icon("increment")->get_width();
area -= get_icon("decrement")->get_width();
area -= get_grabber_min_size();
return area;
} else {
return 0;
switch (orientation) {
case VERTICAL: {
double area = get_size().height;
area -= get_stylebox("scroll")->get_minimum_size().height;
area -= get_icon("increment")->get_height();
area -= get_icon("decrement")->get_height();
area -= get_grabber_min_size();
return area;
} break;
case HORIZONTAL: {
double area = get_size().width;
area -= get_stylebox("scroll")->get_minimum_size().width;
area -= get_icon("increment")->get_width();
area -= get_icon("decrement")->get_width();
area -= get_grabber_min_size();
return area;
} break;
default: {
return 0.0;
}
}
}

View file

@ -3148,10 +3148,7 @@ bool Tree::is_anything_selected() {
void Tree::clear() {
if (blocked > 0) {
ERR_FAIL_COND(blocked > 0);
}
ERR_FAIL_COND(blocked > 0);
if (pressing_for_editor) {
if (range_drag_enabled) {

View file

@ -1456,9 +1456,7 @@ void Viewport::_gui_show_tooltip() {
return;
}
Control *rp = which; //->get_root_parent_control();
if (!rp)
return;
Control *rp = which;
gui.tooltip_popup = which->make_custom_tooltip(tooltip);

View file

@ -1225,10 +1225,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err != OK) {
ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>());
}
ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>());
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
String path = p_original_path != "" ? p_original_path : p_path;
@ -1324,10 +1321,7 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path,
Error err;
FileAccess *f = FileAccess::open(p_src_path, FileAccess::READ, &err);
if (err != OK) {
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
}
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
String path = p_src_path;

View file

@ -346,8 +346,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian
//biased_angular_velocity=Vector3();
set_active(false);
} else {
if (mode != PhysicsServer::BODY_MODE_STATIC)
set_active(true);
set_active(true);
}
} break;
case PhysicsServer::BODY_STATE_CAN_SLEEP: {

View file

@ -722,7 +722,10 @@ struct GJK
append(m_stock,face);
return(0);
}
m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
// -- GODOT start --
//m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces;
m_status=eStatus::OutOfFaces;
// -- GODOT end --
return(0);
}
sFace* findbest()