summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp19
-rw-r--r--core/io/ip.cpp4
-rw-r--r--core/io/resource_import.cpp2
-rw-r--r--core/io/stream_peer_tcp.cpp3
-rw-r--r--core/math/quat.cpp2
-rw-r--r--core/os/os.h2
6 files changed, 17 insertions, 15 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 7778169995..08bb9a35c3 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1133,20 +1133,23 @@ template <class Component, int CC, bool renormalize,
static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint32_t p_width, uint32_t p_height) {
//fast power of 2 mipmap generation
- uint32_t dst_w = p_width >> 1;
- uint32_t dst_h = p_height >> 1;
+ uint32_t dst_w = MAX(p_width >> 1, 1);
+ uint32_t dst_h = MAX(p_height >> 1, 1);
+
+ int right_step = (p_width == 1) ? 0 : CC;
+ int down_step = (p_height == 1) ? 0 : (p_width * CC);
for (uint32_t i = 0; i < dst_h; i++) {
- const Component *rup_ptr = &p_src[i * 2 * p_width * CC];
- const Component *rdown_ptr = rup_ptr + p_width * CC;
+ const Component *rup_ptr = &p_src[i * 2 * down_step];
+ const Component *rdown_ptr = rup_ptr + down_step;
Component *dst_ptr = &p_dst[i * dst_w * CC];
uint32_t count = dst_w;
while (count--) {
for (int j = 0; j < CC; j++) {
- average_func(dst_ptr[j], rup_ptr[j], rup_ptr[j + CC], rdown_ptr[j], rdown_ptr[j + CC]);
+ average_func(dst_ptr[j], rup_ptr[j], rup_ptr[j + right_step], rdown_ptr[j], rdown_ptr[j + right_step]);
}
if (renormalize) {
@@ -1154,8 +1157,8 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3
}
dst_ptr += CC;
- rup_ptr += CC * 2;
- rdown_ptr += CC * 2;
+ rup_ptr += right_step * 2;
+ rdown_ptr += right_step * 2;
}
}
}
@@ -1313,7 +1316,7 @@ Error Image::generate_mipmaps(bool p_renormalize) {
int prev_h = height;
int prev_w = width;
- for (int i = 1; i < mmcount; i++) {
+ for (int i = 1; i <= mmcount; i++) {
int ofs, w, h;
_get_mipmap_offset_and_size(i, ofs, w, h);
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 66bd96df4f..82c94ca0b2 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -117,7 +117,7 @@ IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
resolver->mutex->lock();
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
- if (resolver->cache.has(key)) {
+ if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
IP_Address res = resolver->cache[key];
resolver->mutex->unlock();
return res;
@@ -144,7 +144,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
resolver->queue[id].hostname = p_hostname;
resolver->queue[id].type = p_type;
- if (resolver->cache.has(key)) {
+ if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
resolver->queue[id].response = resolver->cache[key];
resolver->queue[id].status = IP::RESOLVER_STATUS_DONE;
} else {
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index 83e8a40da9..cfe6655504 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -78,7 +78,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
if (assign != String()) {
if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) {
String feature = assign.get_slicec('.', 1);
- if (feature == "fallback" || OS::get_singleton()->has_feature(feature)) {
+ if (OS::get_singleton()->has_feature(feature)) {
r_path_and_type.path = value;
path_found = true; //first match must have priority
}
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index 5d008904ff..54ebb3ae0d 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -43,8 +43,7 @@ Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
return ERR_CANT_RESOLVE;
}
- connect_to_host(ip, p_port);
- return OK;
+ return connect_to_host(ip, p_port);
}
void StreamPeerTCP::_bind_methods() {
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 67c9048a41..2251571146 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -134,7 +134,7 @@ Quat Quat::normalized() const {
}
bool Quat::is_normalized() const {
- return Math::is_equal_approx(length(), 1.0);
+ return Math::is_equal_approx(length_squared(), 1.0);
}
Quat Quat::inverse() const {
diff --git a/core/os/os.h b/core/os/os.h
index 6f9a72d451..100af95ef1 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -256,7 +256,7 @@ public:
virtual String get_executable_path() const;
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;
- virtual Error kill(const ProcessID &p_pid, const int p_max_wait_msec = -1) = 0;
+ virtual Error kill(const ProcessID &p_pid) = 0;
virtual int get_process_id() const;
virtual Error shell_open(String p_uri);