feat: make rage::joaat consteval compatible (#96)

* feat(joaat): make consteval compatible
* fix(ObfVar): ctime include
* feat(joaat): consteval -> constexpr
This commit is contained in:
Yimura 2023-01-12 18:30:11 +01:00 committed by GitHub
parent 2a2d9aedc7
commit c6eb3c8c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@ project(GTAV-Classes)
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_REQUIRED_QUIET ON) set(CMAKE_REQUIRED_QUIET ON)

View File

@ -8,13 +8,14 @@ namespace rage
using joaat_t = std::uint32_t; using joaat_t = std::uint32_t;
inline constexpr char joaat_to_lower(char c) inline constexpr char joaat_to_lower(char c)
{ {
return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c; return c >= 'A' && c <= 'Z' ? c | 1 << 5 : c;
} }
inline joaat_t joaat(std::string_view str) inline constexpr joaat_t joaat(const std::string_view str)
{ {
joaat_t hash = 0; joaat_t hash = 0;
for (auto c : str) { for (auto c : str)
{
hash += joaat_to_lower(c); hash += joaat_to_lower(c);
hash += (hash << 10); hash += (hash << 10);
hash ^= (hash >> 6); hash ^= (hash >> 6);

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <ctime>
namespace rage namespace rage
{ {