Commands (#725)
* feat(Commands): Prototype command system * feat(Commands): Chat commands * refactor(Toxic): convert most options into commands * feat(Protections): block breakup kicks on other players as host * refactor(Kicks): convert most options into commands * refactor(Commands): add labels and descriptions to all commands * feat(Commands): cleanup on unload * refactor(Troll): convert most options into commands * refactor(Misc): convert most options into commands * refactor(Teleport): convert most options into commands * feat(Commands): Variadic commands and toggleable bools * feat(Hotkeys): hotkeys now use commands * fix(Chat): fix the chat window locking up when a message is sent * fix(Commands): properly handle spoofed username * fix(Spam): update filter Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
This commit is contained in:
@ -8,26 +8,25 @@
|
||||
|
||||
namespace rage
|
||||
{
|
||||
template <std::size_t CharCount>
|
||||
struct constexpr_joaat {
|
||||
char data[CharCount];
|
||||
template <std::size_t... Indices>
|
||||
constexpr constexpr_joaat(const char *str, std::index_sequence<Indices...>) : data{ (str[Indices])... } {}
|
||||
constexpr joaat_t operator()()
|
||||
inline consteval joaat_t consteval_joaat(const std::span<const char>& data)
|
||||
{
|
||||
joaat_t hash = 0;
|
||||
|
||||
for (std::size_t i = 0; i < data.size() - 1; ++i)
|
||||
{
|
||||
joaat_t hash = 0;
|
||||
for (std::size_t i = 0; i < CharCount; ++i) {
|
||||
hash += joaat_to_lower(data[i]);
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
return hash;
|
||||
hash += joaat_to_lower(data[i]);
|
||||
hash += (hash << 10);
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
};
|
||||
|
||||
hash += (hash << 3);
|
||||
hash ^= (hash >> 11);
|
||||
hash += (hash << 15);
|
||||
|
||||
return hash;
|
||||
}
|
||||
static_assert(consteval_joaat("test") == 0x3f75ccc1);
|
||||
}
|
||||
|
||||
#define RAGE_JOAAT_IMPL(str) (::rage::constexpr_joaat<sizeof(str) - 1>((str), std::make_index_sequence<sizeof(str) - 1>())())
|
||||
#define RAGE_JOAAT_IMPL(str) (::rage::consteval_joaat(str))
|
||||
#define RAGE_JOAAT(str) (std::integral_constant<rage::joaat_t, RAGE_JOAAT_IMPL(str)>::value)
|
Reference in New Issue
Block a user