From c6eb3c8c1253b5d9822a79feda7bdc61875cd47c Mon Sep 17 00:00:00 2001 From: Yimura <24669514+Yimura@users.noreply.github.com> Date: Thu, 12 Jan 2023 18:30:11 +0100 Subject: [PATCH] feat: make rage::joaat consteval compatible (#96) * feat(joaat): make consteval compatible * fix(ObfVar): ctime include * feat(joaat): consteval -> constexpr --- CMakeLists.txt | 2 +- rage/joaat.hpp | 7 ++++--- security/ObfVar.hpp | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5760195..2f450e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(GTAV-Classes) include(CheckIncludeFileCXX) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_REQUIRED_QUIET ON) diff --git a/rage/joaat.hpp b/rage/joaat.hpp index 03fe86e..4823114 100644 --- a/rage/joaat.hpp +++ b/rage/joaat.hpp @@ -8,13 +8,14 @@ namespace rage using joaat_t = std::uint32_t; 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; - for (auto c : str) { + for (auto c : str) + { hash += joaat_to_lower(c); hash += (hash << 10); hash ^= (hash >> 6); diff --git a/security/ObfVar.hpp b/security/ObfVar.hpp index 02c6e26..64aad18 100644 --- a/security/ObfVar.hpp +++ b/security/ObfVar.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include namespace rage {