summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.cpp1
-rw-r--r--core/io/packet_peer.cpp5
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/make_binders.py3
-rw-r--r--core/map.h2
-rw-r--r--core/math/camera_matrix.cpp4
-rw-r--r--core/math/math_funcs.cpp9
-rw-r--r--core/math/math_funcs.h1
-rw-r--r--core/object.h6
-rw-r--r--core/os/dir_access.cpp8
-rw-r--r--core/os/dir_access.h1
-rw-r--r--core/set.h2
-rw-r--r--core/ustring.cpp45
-rw-r--r--core/ustring.h4
-rw-r--r--core/variant_call.cpp7
15 files changed, 78 insertions, 22 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 794d990083..49e3f94d8f 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -480,6 +480,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
PropertySetGet *psg = t->property_setget.getptr(F->get());
+ ERR_FAIL_COND_V(!psg, 0);
hash = hash_djb2_one_64(F->get().hash(), hash);
hash = hash_djb2_one_64(psg->setter.hash(), hash);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index c77c81f9e2..1e4ea715b3 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -110,10 +110,11 @@ Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) {
Variant PacketPeer::_bnd_get_var(bool p_allow_objects) {
Variant var;
- get_var(var, p_allow_objects);
+ Error err = get_var(var, p_allow_objects);
+ ERR_FAIL_COND_V(err != OK, Variant());
return var;
-};
+}
Error PacketPeer::_put_packet(const PoolVector<uint8_t> &p_buffer) {
return put_packet_buffer(p_buffer);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 38bef2768e..146480e5a2 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -718,8 +718,8 @@ Error ResourceInteractiveLoaderBinary::poll() {
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error = ERR_FILE_CORRUPT;
- memdelete(obj); //bye
ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
+ memdelete(obj); //bye
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
diff --git a/core/make_binders.py b/core/make_binders.py
index 24901c42a1..c38db5cef4 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -334,9 +334,6 @@ def make_version(template, nargs, argmax, const, ret):
elif (cmd == "noarg"):
for i in range(nargs + 1, argmax + 1):
outtext += data.replace("@", str(i))
- elif (cmd == "noarg"):
- for i in range(nargs + 1, argmax + 1):
- outtext += data.replace("@", str(i))
from_pos = end + 1
diff --git a/core/map.h b/core/map.h
index a701ba36f7..c8197639f2 100644
--- a/core/map.h
+++ b/core/map.h
@@ -38,7 +38,7 @@
*/
// based on the very nice implementation of rb-trees by:
-// http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
+// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
template <class K, class V, class C = Comparator<K>, class A = DefaultAllocator>
class Map {
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 8b3b6c82f3..30c0cab909 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -302,8 +302,8 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform)
/** Fast Plane Extraction from combined modelview/projection matrices.
* References:
- * http://www.markmorley.com/opengl/frustumculling.html
- * http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
+ * https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
+ * https://web.archive.org/web/20061020020112/http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
*/
Vector<Plane> planes;
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 7a2e74a413..f04e40cb6c 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -79,6 +79,15 @@ int Math::step_decimals(double p_step) {
return 0;
}
+// Only meant for editor usage in float ranges, where a step of 0
+// means that decimal digits should not be limited in String::num.
+int Math::range_step_decimals(double p_step) {
+ if (p_step < 0.0000000000001) {
+ return 16; // Max value hardcoded in String::num
+ }
+ return step_decimals(p_step);
+}
+
double Math::dectime(double p_value, double p_amount, double p_step) {
double sgn = p_value < 0 ? -1.0 : 1.0;
double val = Math::abs(p_value);
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index b8b5151802..a712356ddc 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -270,6 +270,7 @@ public:
// double only, as these functions are mainly used by the editor and not performance-critical,
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
+ static int range_step_decimals(double p_step);
static double stepify(double p_value, double p_step);
static double dectime(double p_value, double p_amount, double p_step);
diff --git a/core/object.h b/core/object.h
index e6c5b7c5b9..dce1cc74ae 100644
--- a/core/object.h
+++ b/core/object.h
@@ -58,7 +58,7 @@ enum PropertyHint {
PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease) use "attenuation" hint string to revert (flip h), "full" to also include in/out. (ie: "attenuation,inout")
PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
- PROPERTY_HINT_SPRITE_FRAME,
+ PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat. Keeping now for GDNative compat.
PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
PROPERTY_HINT_LAYERS_2D_RENDER,
@@ -104,7 +104,8 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
PROPERTY_USAGE_CATEGORY = 256,
- //those below are deprecated thanks to ClassDB's now class value cache
+ // FIXME: Drop in 4.0, possibly reorder other flags?
+ // Those below are deprecated thanks to ClassDB's now class value cache
//PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero
//PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false
PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
@@ -121,6 +122,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_HIGH_END_GFX = 1 << 22,
PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 23,
PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 24,
+ PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 25, // Used in inspector to increment property when keyed in animation player
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 0cdb5b41b7..b444f0ae1e 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -179,14 +179,6 @@ Error DirAccess::make_dir_recursive(String p_dir) {
return OK;
}
-String DirAccess::get_next(bool *p_is_dir) {
-
- String next = get_next();
- if (p_is_dir)
- *p_is_dir = current_is_dir();
- return next;
-}
-
String DirAccess::fix_path(String p_path) const {
switch (_access_type) {
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index bde19bd5ae..704eedae5b 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -71,7 +71,6 @@ protected:
public:
virtual Error list_dir_begin() = 0; ///< This starts dir listing
- virtual String get_next(bool *p_is_dir); // compatibility
virtual String get_next() = 0;
virtual bool current_is_dir() const = 0;
virtual bool current_is_hidden() const = 0;
diff --git a/core/set.h b/core/set.h
index 81250068af..b2c717880d 100644
--- a/core/set.h
+++ b/core/set.h
@@ -39,7 +39,7 @@
*/
// based on the very nice implementation of rb-trees by:
-// http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
+// https://web.archive.org/web/20120507164830/http://web.mit.edu/~emin/www/source_code/red_black_tree/index.html
template <class T, class C = Comparator<T>, class A = DefaultAllocator>
class Set {
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 75e3b6f22e..ed401c3763 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2729,6 +2729,51 @@ bool String::is_quoted() const {
return is_enclosed_in("\"") || is_enclosed_in("'");
}
+int String::_count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const {
+ if (p_string.empty()) {
+ return 0;
+ }
+ int len = length();
+ int slen = p_string.length();
+ if (len < slen) {
+ return 0;
+ }
+ String str;
+ if (p_from >= 0 && p_to >= 0) {
+ if (p_to == 0) {
+ p_to = len;
+ } else if (p_from >= p_to) {
+ return 0;
+ }
+ if (p_from == 0 && p_to == len) {
+ str = String();
+ str.copy_from_unchecked(&c_str()[0], len);
+ } else {
+ str = substr(p_from, p_to - p_from);
+ }
+ } else {
+ return 0;
+ }
+ int c = 0;
+ int idx = -1;
+ do {
+ idx = p_case_insensitive ? str.findn(p_string) : str.find(p_string);
+ if (idx != -1) {
+ str = str.substr(idx + slen, str.length() - slen);
+ ++c;
+ }
+ } while (idx != -1);
+ return c;
+}
+
+int String::count(const String &p_string, int p_from, int p_to) const {
+ return _count(p_string, p_from, p_to, false);
+}
+
+int String::countn(const String &p_string, int p_from, int p_to) const {
+ return _count(p_string, p_from, p_to, true);
+}
+
bool String::_base_is_subsequence_of(const String &p_string, bool case_insensitive) const {
int len = length();
diff --git a/core/ustring.h b/core/ustring.h
index 8a52c53238..3eb5c47b3a 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -137,6 +137,7 @@ class String {
void copy_from(const CharType &p_char);
void copy_from_unchecked(const CharType *p_char, const int p_length);
bool _base_is_subsequence_of(const String &p_string, bool case_insensitive) const;
+ int _count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const;
public:
enum {
@@ -279,6 +280,9 @@ public:
String to_upper() const;
String to_lower() const;
+ int count(const String &p_string, int p_from = 0, int p_to = 0) const;
+ int countn(const String &p_string, int p_from = 0, int p_to = 0) const;
+
String left(int p_pos) const;
String right(int p_pos) const;
String dedent() const;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index b637e745af..1f6e5bb653 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -237,6 +237,8 @@ struct _VariantCall {
VCALL_LOCALMEM1R(String, casecmp_to);
VCALL_LOCALMEM1R(String, nocasecmp_to);
VCALL_LOCALMEM0R(String, length);
+ VCALL_LOCALMEM3R(String, count);
+ VCALL_LOCALMEM3R(String, countn);
VCALL_LOCALMEM2R(String, substr);
VCALL_LOCALMEM2R(String, find);
VCALL_LOCALMEM1R(String, find_last);
@@ -912,7 +914,7 @@ struct _VariantCall {
static void Quat_init2(Variant &r_ret, const Variant **p_args) {
- r_ret = Quat(((Vector3)(*p_args[0])), ((float)(*p_args[1])));
+ r_ret = Quat(((Vector3)(*p_args[0])), ((real_t)(*p_args[1])));
}
static void Quat_init3(Variant &r_ret, const Variant **p_args) {
@@ -1502,6 +1504,9 @@ void register_variant_methods() {
ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0));
+ ADDFUNC3R(STRING, INT, String, count, STRING, "what", INT, "from", INT, "to", varray(0, 0));
+ ADDFUNC3R(STRING, INT, String, countn, STRING, "what", INT, "from", INT, "to", varray(0, 0));
+
ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray());
ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));