summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.h13
-rw-r--r--core/image.cpp32
-rw-r--r--core/io/multiplayer_api.cpp5
3 files changed, 32 insertions, 18 deletions
diff --git a/core/class_db.h b/core/class_db.h
index 490deb7873..34301d6cba 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -114,6 +114,7 @@ public:
APIType api;
ClassInfo *inherits_ptr;
+ void *class_ptr;
HashMap<StringName, MethodBind *> method_map;
HashMap<StringName, int> constant_map;
HashMap<StringName, List<StringName> > enum_map;
@@ -177,6 +178,7 @@ public:
ERR_FAIL_COND(!t);
t->creation_func = &creator<T>;
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
T::register_custom_data_to_otdb();
}
@@ -188,6 +190,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
//nothing
}
@@ -206,6 +209,7 @@ public:
ERR_FAIL_COND(!t);
t->creation_func = &_create_ptr_func<T>;
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
T::register_custom_data_to_otdb();
}
@@ -293,6 +297,15 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 7);
}
+ template <class N, class M>
+ static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7, const Variant &p_def8) {
+
+ MethodBind *bind = create_method_bind(p_method);
+ const Variant *ptr[8] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7, &p_def8 };
+
+ return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 8);
+ }
+
template <class M>
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
diff --git a/core/image.cpp b/core/image.cpp
index 5f99fe1532..672f850a1f 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -2432,19 +2432,19 @@ Color Image::get_pixel(int p_x, int p_y) const {
}
case FORMAT_RGBA4444: {
uint16_t u = ((uint16_t *)ptr)[ofs];
- float r = (u & 0xF) / 15.0;
- float g = ((u >> 4) & 0xF) / 15.0;
- float b = ((u >> 8) & 0xF) / 15.0;
- float a = ((u >> 12) & 0xF) / 15.0;
+ float r = ((u >> 12) & 0xF) / 15.0;
+ float g = ((u >> 8) & 0xF) / 15.0;
+ float b = ((u >> 4) & 0xF) / 15.0;
+ float a = (u & 0xF) / 15.0;
return Color(r, g, b, a);
}
case FORMAT_RGBA5551: {
uint16_t u = ((uint16_t *)ptr)[ofs];
- float r = (u & 0x1F) / 15.0;
- float g = ((u >> 5) & 0x1F) / 15.0;
- float b = ((u >> 10) & 0x1F) / 15.0;
- float a = ((u >> 15) & 0x1) / 1.0;
+ float r = ((u >> 11) & 0x1F) / 15.0;
+ float g = ((u >> 6) & 0x1F) / 15.0;
+ float b = ((u >> 1) & 0x1F) / 15.0;
+ float a = (u & 0x1) / 1.0;
return Color(r, g, b, a);
}
case FORMAT_RF: {
@@ -2558,10 +2558,10 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
uint16_t rgba = 0;
- rgba = uint16_t(CLAMP(p_color.r * 15.0, 0, 15));
- rgba |= uint16_t(CLAMP(p_color.g * 15.0, 0, 15)) << 4;
- rgba |= uint16_t(CLAMP(p_color.b * 15.0, 0, 15)) << 8;
- rgba |= uint16_t(CLAMP(p_color.a * 15.0, 0, 15)) << 12;
+ rgba = uint16_t(CLAMP(p_color.r * 15.0, 0, 15)) << 12;
+ rgba |= uint16_t(CLAMP(p_color.g * 15.0, 0, 15)) << 8;
+ rgba |= uint16_t(CLAMP(p_color.b * 15.0, 0, 15)) << 4;
+ rgba |= uint16_t(CLAMP(p_color.a * 15.0, 0, 15));
((uint16_t *)ptr)[ofs] = rgba;
@@ -2570,10 +2570,10 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
uint16_t rgba = 0;
- rgba = uint16_t(CLAMP(p_color.r * 31.0, 0, 31));
- rgba |= uint16_t(CLAMP(p_color.g * 31.0, 0, 31)) << 5;
- rgba |= uint16_t(CLAMP(p_color.b * 31.0, 0, 31)) << 10;
- rgba |= uint16_t(p_color.a > 0.5 ? 1 : 0) << 15;
+ rgba = uint16_t(CLAMP(p_color.r * 31.0, 0, 31)) << 11;
+ rgba |= uint16_t(CLAMP(p_color.g * 31.0, 0, 31)) << 6;
+ rgba |= uint16_t(CLAMP(p_color.b * 31.0, 0, 31)) << 1;
+ rgba |= uint16_t(p_color.a > 0.5 ? 1 : 0);
((uint16_t *)ptr)[ofs] = rgba;
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index aaa7eb64c9..2708cb8c01 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -139,6 +139,9 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
if (p_peer == network_peer) return; // Nothing to do
+ ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED,
+ "Supplied NetworkedMultiplayerPeer must be connecting or connected.");
+
if (network_peer.is_valid()) {
network_peer->disconnect("peer_connected", this, "_add_peer");
network_peer->disconnect("peer_disconnected", this, "_del_peer");
@@ -150,8 +153,6 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
network_peer = p_peer;
- ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Supplied NetworkedNetworkPeer must be connecting or connected.");
-
if (network_peer.is_valid()) {
network_peer->connect("peer_connected", this, "_add_peer");
network_peer->connect("peer_disconnected", this, "_del_peer");