diff options
author | Karroffel <therzog@mail.de> | 2017-03-15 18:13:22 +0100 |
---|---|---|
committer | Karroffel <therzog@mail.de> | 2017-03-15 18:13:29 +0100 |
commit | bce9ac109d63d67c3e7f0b25df8aa9d72e094d1b (patch) | |
tree | 681da6ad6b24e08c1189047cd6513bb2dfb27817 /include/godot_cpp | |
parent | b0981479779f2deb3beb2fca5507453d78572bdb (diff) | |
download | redot-cpp-bce9ac109d63d67c3e7f0b25df8aa9d72e094d1b.tar.gz |
mistakes were made. I undid them.
Diffstat (limited to 'include/godot_cpp')
-rw-r--r-- | include/godot_cpp/core/Basis.cpp | 26 | ||||
-rw-r--r-- | include/godot_cpp/core/Color.cpp | 32 | ||||
-rw-r--r-- | include/godot_cpp/core/Defs.hpp | 9 | ||||
-rw-r--r-- | include/godot_cpp/core/InputEvent.cpp | 2 | ||||
-rw-r--r-- | include/godot_cpp/core/String.cpp | 2 | ||||
-rw-r--r-- | include/godot_cpp/core/String.hpp | 3 |
6 files changed, 24 insertions, 50 deletions
diff --git a/include/godot_cpp/core/Basis.cpp b/include/godot_cpp/core/Basis.cpp index 691edaa..dff6e4f 100644 --- a/include/godot_cpp/core/Basis.cpp +++ b/include/godot_cpp/core/Basis.cpp @@ -63,13 +63,9 @@ void Basis::invert() elements[0][1] * co[1]+ elements[0][2] * co[2]; - if ( det != 0 ) { - // WTF - __builtin_trap(); // WTF WTF WTF - - // I shouldn't do this - // @Todo @Fixme @Todo @Todo - } + + ERR_FAIL_COND(det != 0); + real_t s = 1.0/det; set( co[0]*s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, @@ -407,14 +403,7 @@ Basis Basis::transpose_xform(const Basis& m) const void Basis::orthonormalize() { - if (determinant() != 0) { - // not this crap again - __builtin_trap(); // WTF WTF WTF - // somebody please complain some day - // so I can fix this - - // need propert error reporting here. - } + ERR_FAIL_COND(determinant() != 0); // Gram-Schmidt Process @@ -576,12 +565,7 @@ int Basis::get_orthogonal_index() const void Basis::set_orthogonal_index(int p_index){ //there only exist 24 orthogonal bases in r3 - if (p_index >= 24) { - __builtin_trap(); // kiiiiill me - // I don't want to do shady stuff like that - // @Todo WTF WTF - } - + ERR_FAIL_COND(p_index >= 24); *this=_ortho_bases[p_index]; diff --git a/include/godot_cpp/core/Color.cpp b/include/godot_cpp/core/Color.cpp index 6d89cb8..985e04e 100644 --- a/include/godot_cpp/core/Color.cpp +++ b/include/godot_cpp/core/Color.cpp @@ -4,6 +4,8 @@ #include <cmath> +#include "Defs.hpp" + #include "String.hpp" namespace godot { @@ -270,20 +272,16 @@ Color Color::html(const String& p_color) } else if (color.length()==6) { alpha=false; } else { - // @Todo error reporting - // ERR_EXPLAIN("Invalid Color Code: "+p_color); - // ERR_FAIL_V(Color()); - return Color(); + ERR_PRINT(String("Invalid Color Code: ") + p_color); + ERR_FAIL_V(Color()); } int a=255; if (alpha) { a=_parse_col(color,0); if (a<0) { - // @Todo error reporting - // ERR_EXPLAIN("Invalid Color Code: "+p_color); - // ERR_FAIL_V(Color()); - return Color(); + ERR_PRINT("Invalid Color Code: "+p_color); + ERR_FAIL_V(Color()); } } @@ -291,24 +289,18 @@ Color Color::html(const String& p_color) int r=_parse_col(color,from+0); if (r<0) { - // @Todo error reporting - // ERR_EXPLAIN("Invalid Color Code: "+p_color); - // ERR_FAIL_V(Color()); - return Color(); + ERR_PRINT("Invalid Color Code: "+p_color); + ERR_FAIL_V(Color()); } int g=_parse_col(color,from+2); if (g<0) { - // @Todo error reporting - // ERR_EXPLAIN("Invalid Color Code: "+p_color); - // ERR_FAIL_V(Color()); - return Color(); + ERR_PRINT("Invalid Color Code: "+p_color); + ERR_FAIL_V(Color()); } int b=_parse_col(color,from+4); if (b<0) { - // @Todo error reporting - // ERR_EXPLAIN("Invalid Color Code: "+p_color); - // ERR_FAIL_V(Color()); - return Color(); + ERR_PRINT("Invalid Color Code: "+p_color); + ERR_FAIL_V(Color()); } return Color(r/255.0,g/255.0,b/255.0,a/255.0); diff --git a/include/godot_cpp/core/Defs.hpp b/include/godot_cpp/core/Defs.hpp index cdb67a1..b2da2cc 100644 --- a/include/godot_cpp/core/Defs.hpp +++ b/include/godot_cpp/core/Defs.hpp @@ -60,7 +60,7 @@ enum Error { } -// @Todo error handling stuff here plz +#include <stdio.h> typedef float real_t; @@ -87,19 +87,16 @@ typedef float real_t; #ifndef ERR_PRINT -#define ERR_PRINT(msg) +#define ERR_PRINT(msg) fprintf(stderr, "ERROR: %ls\n", (msg).c_string()) #endif #ifndef ERR_FAIL_INDEX_V #define ERR_FAIL_INDEX_V(a, b, c) #endif -#ifndef ERR_FAIL_INDEX -#define ERR_FAIL_INDEX(a, b) -#endif #ifndef ERR_FAIL_COND -#define ERR_FAIL_COND(a) +#define ERR_FAIL_COND(a) do { if (a) { fprintf(stderr, #a); return; } } while(0) #endif diff --git a/include/godot_cpp/core/InputEvent.cpp b/include/godot_cpp/core/InputEvent.cpp index 35906bb..b21bca6 100644 --- a/include/godot_cpp/core/InputEvent.cpp +++ b/include/godot_cpp/core/InputEvent.cpp @@ -64,7 +64,7 @@ bool InputEvent::operator==(const InputEvent &p_event) const { && action.pressed == p_event.action.pressed; /* clang-format on */ default: - ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen."); + ERR_PRINT(String("No logic to compare InputEvents of this type, this shouldn't happen.")); } return false; diff --git a/include/godot_cpp/core/String.cpp b/include/godot_cpp/core/String.cpp index 83b1f90..52923ff 100644 --- a/include/godot_cpp/core/String.cpp +++ b/include/godot_cpp/core/String.cpp @@ -114,7 +114,7 @@ bool String::operator >=(const String &s) return !(*this < s); } -const wchar_t *String::c_string() +const wchar_t *String::c_string() const { return godot_string_c_str(&_godot_string); } diff --git a/include/godot_cpp/core/String.hpp b/include/godot_cpp/core/String.hpp index 5a99964..6de7037 100644 --- a/include/godot_cpp/core/String.hpp +++ b/include/godot_cpp/core/String.hpp @@ -49,10 +49,11 @@ public: bool operator >=(const String &s); - const wchar_t *c_string(); + const wchar_t *c_string() const; }; +String operator +(const char *a, const String& b); } |