summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp68
-rw-r--r--core/bind/core_bind.h1
2 files changed, 25 insertions, 44 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index ba9bd10bfd..b41b84ab1e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -34,13 +34,12 @@
#include "core/io/file_access_encrypted.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
+#include "core/math/crypto_core.h"
#include "core/math/geometry.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
-#include "thirdparty/misc/base64.h"
-
/**
* Time constants borrowed from loc_time.h
*/
@@ -1933,13 +1932,15 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
ERR_FAIL_COND_V(p_length < 0, data);
if (p_length == 0)
return data;
+
Error err = data.resize(p_length);
ERR_FAIL_COND_V(err != OK, data);
+
PoolVector<uint8_t>::Write w = data.write();
int len = f->get_buffer(&w[0], p_length);
ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (len < p_length)
data.resize(p_length);
@@ -2114,11 +2115,11 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
PoolVector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND(err != OK);
- w = PoolVector<uint8_t>::Write();
+ w.release();
store_32(len);
store_buffer(buff);
@@ -2433,15 +2434,8 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_V(err != OK, "");
- int b64len = len / 3 * 4 + 4 + 1;
- PoolVector<uint8_t> b64buff;
- b64buff.resize(b64len);
- PoolVector<uint8_t>::Write w64 = b64buff.write();
-
- int strlen = base64_encode((char *)(&w64[0]), (char *)(&w[0]), len);
- //OS::get_singleton()->print("len is %i, vector size is %i\n", b64len, strlen);
- w64[strlen] = 0;
- String ret = (char *)&w64[0];
+ String ret = CryptoCore::b64_encode_str(&w[0], len);
+ ERR_FAIL_COND_V(ret == "", ret);
return ret;
};
@@ -2455,7 +2449,8 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
buf.resize(strlen / 4 * 3 + 1);
PoolVector<uint8_t>::Write w = buf.write();
- int len = base64_decode((char *)(&w[0]), (char *)cstr.get_data(), strlen);
+ size_t len = 0;
+ ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, Variant());
Variant v;
Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects);
@@ -2466,18 +2461,8 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
String _Marshalls::raw_to_base64(const PoolVector<uint8_t> &p_arr) {
- int len = p_arr.size();
- PoolVector<uint8_t>::Read r = p_arr.read();
-
- int b64len = len / 3 * 4 + 4 + 1;
- PoolVector<uint8_t> b64buff;
- b64buff.resize(b64len);
- PoolVector<uint8_t>::Write w64 = b64buff.write();
-
- int strlen = base64_encode((char *)(&w64[0]), (char *)(&r[0]), len);
- w64[strlen] = 0;
- String ret = (char *)&w64[0];
-
+ String ret = CryptoCore::b64_encode_str(p_arr.read().ptr(), p_arr.size());
+ ERR_FAIL_COND_V(ret == "", ret);
return ret;
};
@@ -2486,35 +2471,24 @@ PoolVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
int strlen = p_str.length();
CharString cstr = p_str.ascii();
- int arr_len;
+ size_t arr_len = 0;
PoolVector<uint8_t> buf;
{
buf.resize(strlen / 4 * 3 + 1);
PoolVector<uint8_t>::Write w = buf.write();
- arr_len = base64_decode((char *)(&w[0]), (char *)cstr.get_data(), strlen);
- };
+ ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &arr_len, (unsigned char *)cstr.get_data(), strlen) != OK, PoolVector<uint8_t>());
+ }
buf.resize(arr_len);
- // conversion from PoolVector<uint8_t> to raw array?
return buf;
};
String _Marshalls::utf8_to_base64(const String &p_str) {
CharString cstr = p_str.utf8();
- int len = cstr.length();
-
- int b64len = len / 3 * 4 + 4 + 1;
- PoolVector<uint8_t> b64buff;
- b64buff.resize(b64len);
- PoolVector<uint8_t>::Write w64 = b64buff.write();
-
- int strlen = base64_encode((char *)(&w64[0]), (char *)cstr.get_data(), len);
-
- w64[strlen] = 0;
- String ret = (char *)&w64[0];
-
+ String ret = CryptoCore::b64_encode_str((unsigned char *)cstr.get_data(), cstr.length());
+ ERR_FAIL_COND_V(ret == "", ret);
return ret;
};
@@ -2527,7 +2501,8 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
buf.resize(strlen / 4 * 3 + 1 + 1);
PoolVector<uint8_t>::Write w = buf.write();
- int len = base64_decode((char *)(&w[0]), (char *)cstr.get_data(), strlen);
+ size_t len = 0;
+ ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, String());
w[len] = 0;
String ret = String::utf8((char *)&w[0]);
@@ -2966,6 +2941,10 @@ float _Engine::get_physics_jitter_fix() const {
return Engine::get_singleton()->get_physics_jitter_fix();
}
+float _Engine::get_physics_interpolation_fraction() const {
+ return Engine::get_singleton()->get_physics_interpolation_fraction();
+}
+
void _Engine::set_target_fps(int p_fps) {
Engine::get_singleton()->set_target_fps(p_fps);
}
@@ -3054,6 +3033,7 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
ClassDB::bind_method(D_METHOD("set_physics_jitter_fix", "physics_jitter_fix"), &_Engine::set_physics_jitter_fix);
ClassDB::bind_method(D_METHOD("get_physics_jitter_fix"), &_Engine::get_physics_jitter_fix);
+ ClassDB::bind_method(D_METHOD("get_physics_interpolation_fraction"), &_Engine::get_physics_interpolation_fraction);
ClassDB::bind_method(D_METHOD("set_target_fps", "target_fps"), &_Engine::set_target_fps);
ClassDB::bind_method(D_METHOD("get_target_fps"), &_Engine::get_target_fps);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 3be5a08752..f0f86e003f 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -746,6 +746,7 @@ public:
void set_physics_jitter_fix(float p_threshold);
float get_physics_jitter_fix() const;
+ float get_physics_interpolation_fraction() const;
void set_target_fps(int p_fps);
int get_target_fps() const;