From 04a72641bfe96e8fffc612e15b6360c7a5be3c5e Mon Sep 17 00:00:00 2001 From: Octavian Dima Date: Tue, 30 Jan 2018 03:47:58 +0100 Subject: [PATCH 1/4] Add "functional" header --- rage.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rage.hpp b/rage.hpp index 543a36e..7877d62 100644 --- a/rage.hpp +++ b/rage.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include From 5d773a0ffd82228df1e7b915e043094443c8c9e2 Mon Sep 17 00:00:00 2001 From: Octavian Dima Date: Tue, 30 Jan 2018 13:30:33 +0100 Subject: [PATCH 2/4] Fix compilation issue when you call "Call*" and "Invoke*" functions without parameters --- Entities.hpp | 8 ++++---- Pools.hpp | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Entities.hpp b/Entities.hpp index fab66e0..2d67bf2 100644 --- a/Entities.hpp +++ b/Entities.hpp @@ -210,9 +210,9 @@ namespace rage template void Call(const std::string& eventName, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_Call(eventName); else { @@ -224,9 +224,9 @@ namespace rage template void Invoke(uint64_t hash, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_Invoke(hash); else { diff --git a/Pools.hpp b/Pools.hpp index ac5c631..79eaf10 100644 --- a/Pools.hpp +++ b/Pools.hpp @@ -27,9 +27,9 @@ namespace rage template void Call(const std::string& eventName, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_Call(eventName); else { @@ -41,9 +41,9 @@ namespace rage template void CallInRange(const vector3& position, float range, dimensionId_t dimension, const std::string& eventName, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_CallInRange(position, range, dimension, eventName); else { @@ -55,9 +55,9 @@ namespace rage template void CallInDimension(dimensionId_t dimension, const std::string& eventName, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_CallInDimension(dimension, eventName); else { @@ -69,9 +69,9 @@ namespace rage template void Invoke(uint64_t hash, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_Invoke(hash); else { @@ -83,9 +83,9 @@ namespace rage template void InvokeInRange(const vector3& position, float range, dimensionId_t dimension, uint64_t hash, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_InvokeInRange(position, range, dimension, hash); else { @@ -97,9 +97,9 @@ namespace rage template void InvokeInDimension(dimensionId_t dimension, uint64_t hash, Args&&... args) { - const int count = sizeof...(Args); + constexpr auto count = sizeof...(args); - if (count == 0) + if constexpr (count == 0) this->_InvokeInDimension(dimension, hash); else { From 9b4ed52e03f7a0eade6c1d08b5caa13c5e0bf65a Mon Sep 17 00:00:00 2001 From: Octavian Dima Date: Tue, 30 Jan 2018 13:50:05 +0100 Subject: [PATCH 3/4] Remove "explicit" keyword from copy constructor --- Entity.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Entity.hpp b/Entity.hpp index df9fedc..4959396 100644 --- a/Entity.hpp +++ b/Entity.hpp @@ -113,7 +113,7 @@ namespace rage explicit arg_t(float f) : type(val_t::Float), v { f } { } explicit arg_t(const std::string& str) : type(val_t::String), v { new char[str.length() + 1] } { memcpy(v.str, str.c_str(), str.length()); v.str[str.length()] = 0; } explicit arg_t(entity_t entityType, entityId_t id, rage::IEntity *entity) : type(val_t::Entity), v{ entityType, id, entity } { } - explicit arg_t(const arg_t& r) : type(val_t::Null) { *this = r; } + arg_t(const arg_t& r) : type(val_t::Null) { *this = r; } void SetNull() { DeleteString(); type = val_t::Null; } void SetBoolean(bool b) { DeleteString(); type = val_t::Boolean; v.b = b; } From 98c2c2c76b2cb53ff2f7b822b91c589dc5b89996 Mon Sep 17 00:00:00 2001 From: Octavian Dima Date: Tue, 30 Jan 2018 20:56:23 +0100 Subject: [PATCH 4/4] Remove duplicate include --- rage.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rage.hpp b/rage.hpp index 117da27..42a5e3b 100644 --- a/rage.hpp +++ b/rage.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include