Fixed player avoidance code.

Speedup network message handling.
This commit is contained in:
joint 2019-08-12 14:16:28 +03:00 committed by jeefo
commit 9947e41549
26 changed files with 2398 additions and 2294 deletions

View file

@ -50,7 +50,7 @@ public:
rhs.reset ();
}
Array (std::initializer_list <T> list) {
Array (const std::initializer_list <T> &list) {
for (const auto &elem : list) {
push (elem);
}

View file

@ -40,6 +40,13 @@ template <typename K> struct IntHash {
}
};
// template for np hashing integers
template <typename K> struct IntNoHash {
uint32 operator () (K key) const {
return static_cast <uint32> (key);
}
};
namespace detail {
struct DictionaryList {
uint32 index;

View file

@ -862,6 +862,14 @@ public:
return buffer;
}
// checks if string is not empty
bool isEmpty (const char *input) const {
if (input == nullptr) {
return true;
}
return *input == '\0';
}
};
// expose global string pool
@ -1082,14 +1090,19 @@ public:
String strToUpper (const String &in) {
String result (in);
auto ptr = const_cast <char *> (result.chars ());
int32 len = 0;
wchar_t wide;
while (*ptr && len < static_cast <int32> (result.length ())) {
while (*ptr) {
wchar_t wide = 0;
multiByteToWideChar (&wide, ptr);
ptr += wideCharToMultiByte (ptr, toUpper (wide));
len += wideCharToMultiByte (ptr, toUpper (wide));
if (static_cast <size_t> (len) >= result.length ()) {
break;
}
}
return result;
}

View file

@ -160,8 +160,8 @@ public:
}
static const Vector &null () {
static const auto s_zero = Vector (0.0f, 0.0f, 0.0f);
return s_zero;
static const Vector &s_null {};
return s_null;
}
void clear () {
@ -224,6 +224,27 @@ public:
upward->z = cosines[roll] * cosines[pitch];
}
}
const Vector &forward () {
static Vector s_fwd {};
buildVectors (&s_fwd, nullptr, nullptr);
return s_fwd;
}
const Vector &upward () {
static Vector s_up {};
buildVectors (nullptr, nullptr, &s_up);
return s_up;
}
const Vector &right () {
static Vector s_right {};
buildVectors (nullptr, &s_right, nullptr);
return s_right;
}
};
// expose global null vector