GTAV-Classes/rage/joaat.hpp
Yimura c6eb3c8c12
feat: make rage::joaat consteval compatible (#96)
* feat(joaat): make consteval compatible
* fix(ObfVar): ctime include
* feat(joaat): consteval -> constexpr
2023-01-12 17:30:11 +00:00

29 lines
592 B
C++

#pragma once
#include <cstdint>
#include <string_view>
namespace rage
{
using joaat_t = std::uint32_t;
inline constexpr char joaat_to_lower(char c)
{
return c >= 'A' && c <= 'Z' ? c | 1 << 5 : c;
}
inline constexpr joaat_t joaat(const std::string_view str)
{
joaat_t hash = 0;
for (auto c : str)
{
hash += joaat_to_lower(c);
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
};