feat: Switch to C++20 (#508)

This commit is contained in:
Yimura 2022-10-24 14:08:37 +02:00 committed by GitHub
parent 34f2302c90
commit c948305a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 48 additions and 77 deletions

4
.gitmodules vendored
View File

@ -1,7 +1,3 @@
[submodule "vendor/fmtlib"]
path = vendor/fmtlib
url = https://github.com/fmtlib/fmt
ignore = dirty
[submodule "vendor/json"]
path = vendor/json
url = https://github.com/nlohmann/json

View File

@ -111,7 +111,7 @@ namespace big
if ((int)state > 0 && (int)std::size(transition_states))
{
HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING");
auto const spinner_text = fmt::format("{} | {}", transition_states[(int)state], state);
auto const spinner_text = std::format("{} | {}", transition_states[(int)state], static_cast<int>(state));
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(spinner_text.c_str());
HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(5);
}

View File

@ -45,8 +45,7 @@
#include <optional>
#include <variant>
#define FMT_HEADER_ONLY
#include <fmt/format.h>
#include <format>
#include <nlohmann/json.hpp>
#include "logger.hpp"

View File

@ -13,7 +13,7 @@ namespace big
{
fix_hook_address();
if (auto status = MH_CreateHook(m_target, m_detour, &m_original); status != MH_OK)
throw std::runtime_error(fmt::format("Failed to create hook '{}' at 0x{:X} (error: {})", m_name, uintptr_t(m_target), MH_StatusToString(status)));
throw std::runtime_error(std::format("Failed to create hook '{}' at 0x{:X} (error: {})", m_name, uintptr_t(m_target), MH_StatusToString(status)));
}
detour_hook::~detour_hook() noexcept
@ -25,7 +25,7 @@ namespace big
void detour_hook::enable()
{
if (auto status = MH_QueueEnableHook(m_target); status != MH_OK)
throw std::runtime_error(fmt::format("Failed to enable hook 0x{:X} ({})", uintptr_t(m_target), MH_StatusToString(status)));
throw std::runtime_error(std::format("Failed to enable hook 0x{:X} ({})", uintptr_t(m_target), MH_StatusToString(status)));
}
void detour_hook::disable()
@ -51,7 +51,7 @@ namespace big
}
__except (exp_handler(GetExceptionInformation(), m_name)) {
[this]() {
throw std::runtime_error(fmt::format("Failed to fix hook address for '{}'", m_name));
throw std::runtime_error(std::format("Failed to fix hook address for '{}'", m_name));
}();
}
}

View File

@ -59,7 +59,7 @@ namespace rage
m_size += size;
auto i = old_capacity;
for (auto weapon_hash : value_array)
for (auto weapon_hash : array_value)
{
m_data[i] = weapon_hash;
i++;

View File

@ -43,7 +43,7 @@ namespace rage
public:
static sysMemAllocator* sysMemAllocator::UpdateAllocatorValue()
static sysMemAllocator* UpdateAllocatorValue()
{
//B9 ? ? ? ? 48 8B 0C 01 45 33 C9 49 8B D2 48
auto g_gtaTlsEntry = *(sysMemAllocator**)(*(uintptr_t*)(__readgsqword(88)) + 0xC8); //This has been 0xC8 since 323, I'm not adding this signature to pointers...

View File

@ -123,7 +123,7 @@ namespace big
void gui::script_func()
{
g_notification_service->push("Welcome", fmt::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g->settings.hotkeys.menu_toggle]));
g_notification_service->push("Welcome", std::format("Loaded YimMenu. Press {} to open", ImGui::key_names[g->settings.hotkeys.menu_toggle]));
while (true)
{
g_gui.script_on_tick();

View File

@ -10,7 +10,7 @@ namespace big
if (g->notifications.gta_thread_kill.log)
LOG(INFO) << "Script Thread '" << thread->m_name << "' terminated.";
if (g->notifications.gta_thread_kill.notify)
g_notification_service->push("Script Thread Termination", fmt::format("Script Thread '{}' terminated.", thread->m_name));
g_notification_service->push("Script Thread Termination", std::format("Script Thread '{}' terminated.", thread->m_name));
g_native_hooks->do_cleanup_for_thread(thread);

View File

@ -12,7 +12,7 @@ namespace big
if (g->notifications.gta_thread_kill.log)
LOG(INFO) << "Script Thread '" << name << "' started.";
if (g->notifications.gta_thread_kill.notify)
g_notification_service->push("Script Thread Startup", fmt::format("Script Thread '{}' started.", name));
g_notification_service->push("Script Thread Startup", std::format("Script Thread '{}' started.", name));
}
if (new_thread != nullptr)

View File

@ -21,7 +21,7 @@ namespace big
<< " with Rockstar ID: " << net_player_data->m_gamer_handle_2.m_rockstar_id;
if (g->notifications.player_leave.notify)
g_notification_service->push("Player Left", fmt::format("{} freeing slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
g_notification_service->push("Player Left", std::format("{} freeing slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
}
return result;
@ -39,7 +39,7 @@ namespace big
<< " with Rockstar ID: " << net_player_data->m_gamer_handle_2.m_rockstar_id;
if (g->notifications.player_join.notify)
g_notification_service->push("Player Joined", fmt::format("{} taking slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
g_notification_service->push("Player Joined", std::format("{} taking slot #{} with Rockstar ID: {}", net_player_data->m_name, player->m_player_id, net_player_data->m_gamer_handle_2.m_rockstar_id));
}
return result;
}

View File

@ -16,7 +16,7 @@ namespace big
case RAGE_JOAAT("MPPLY_TC_HATE"):
case RAGE_JOAAT("MPPLY_VC_ANNOYINGME"):
case RAGE_JOAAT("MPPLY_VC_HATE"):
const auto report = fmt::format("From: {}", sender->get_name());
const auto report = std::format("From: {}", sender->get_name());
if (g->notifications.reports.log)
LOG(INFO) << "Blocked report; " << report;

View File

@ -49,7 +49,7 @@ namespace big
{
if (player->m_num_failed_transition_attempts++ == 20)
{
g_notification_service->push_error("Protections", fmt::format("{} tried to OOM kick you!", player->get_name()));
g_notification_service->push_error("Protections", std::format("{} tried to OOM kick you!", player->get_name()));
}
return true;
}
@ -83,7 +83,7 @@ namespace big
}
if (player && pl && player->id() != pl->id() && count == 1 && frame->m_msg_id == -1)
{
g_notification_service->push_error("Warning!", fmt::format("{} breakup kicked {}!", player->get_name(), pl->get_name()));
g_notification_service->push_error("Warning!", std::format("{} breakup kicked {}!", player->get_name(), pl->get_name()));
}
break;
}

View File

@ -34,14 +34,14 @@ namespace big
if (g->notifications.out_of_allowed_range_sync_type.log)
LOG(WARNING) << "Out of range sync: " << "Type: " << sync_type << " Tree name: " << tree_name << " From: " << src->get_name();
if (g->notifications.out_of_allowed_range_sync_type.notify)
g_notification_service->push_warning(fmt::format("Out Of Allowed Sync Range from {}", src->get_name()), fmt::format("Type {} in sync tree {}", sync_type, tree_name));
g_notification_service->push_warning(std::format("Out Of Allowed Sync Range from {}", src->get_name()), std::format("Type {} in sync tree {}", std::uint16_t(sync_type), tree_name));
}
else if (net_obj->m_object_type != sync_type)
{
if (g->notifications.mismatch_sync_type.log)
LOG(WARNING) << "Mismatch sync: " << "Type: " << sync_type << " Tree name: " << tree_name << " From: " << src->get_name();
if (g->notifications.mismatch_sync_type.notify)
g_notification_service->push_warning(fmt::format("Mismatch Sync from {}", src->get_name()), fmt::format("Type {} in sync tree {}", sync_type, tree_name));
g_notification_service->push_warning(std::format("Mismatch Sync from {}", src->get_name()), std::format("Type {} in sync tree {}", std::uint16_t(sync_type), tree_name));
return SyncResponse::WrongOwner;
}

View File

@ -41,7 +41,7 @@ namespace big
LOG(INFO) << "RECEIVED_EVENT_HANDLER : " << source_player->get_name() << " is voting to kick us.";
if (g->notifications.received_event.kick_vote.notify)
g_notification_service->push_warning("Kick Vote",
fmt::format("{} is voting to kick us.", source_player->get_name()));
std::format("{} is voting to kick us.", source_player->get_name()));
}
buffer->Seek(0);
break;
@ -79,7 +79,7 @@ namespace big
LOG(INFO) << "RECEIVED_EVENT_HANDLER : " << source_player->get_name() << " sent TASK_VEHICLE_TEMP_ACTION crash.";
if (g->notifications.received_event.vehicle_temp_action.notify)
g_notification_service->push_warning("Protection",
fmt::format("{} sent TASK_VEHICLE_TEMP_ACTION crash.", source_player->get_name()));
std::format("{} sent TASK_VEHICLE_TEMP_ACTION crash.", source_player->get_name()));
return;
}
@ -115,7 +115,7 @@ namespace big
if (g->notifications.received_event.clear_ped_task.notify)
g_notification_service->push_warning("Protection",
fmt::format("{} possible attempt at freezing entity.", source_player->get_name())
std::format("{} possible attempt at freezing entity.", source_player->get_name())
);
return;
@ -140,7 +140,7 @@ namespace big
if (g->notifications.received_event.report_cash_spawn.notify)
g_notification_service->push_warning("Protection",
fmt::format("{} is spawning cash.", source_player->get_name())
std::format("{} is spawning cash.", source_player->get_name())
);
}
@ -155,7 +155,7 @@ namespace big
if (g->notifications.received_event.modder_detect.notify)
g_notification_service->push_warning("Protection",
fmt::format("{} sent out a modder event.", source_player->get_name())
std::format("{} sent out a modder event.", source_player->get_name())
);
break;
@ -169,7 +169,7 @@ namespace big
if (g->notifications.received_event.request_control_event.notify)
g_notification_service->push_warning("Protection",
fmt::format("Denied player control request from {}", source_player->get_name())
std::format("Denied player control request from {}", source_player->get_name())
);
return;

View File

@ -10,7 +10,7 @@ namespace big
if (should_notify)
g_notification_service->push_warning("Script Event Protection",
fmt::format("From: {}\nEvent Type: {}", player_name.data(), protection_type.data())
std::format("From: {}\nEvent Type: {}", player_name.data(), protection_type.data())
);
}

View File

@ -109,7 +109,7 @@ namespace big
auto local_time = std::localtime(&time_t);
m_file.move(
fmt::format(
std::format(
"./backup/{:0>2}-{:0>2}-{}-{:0>2}-{:0>2}-{:0>2}_{}",
local_time->tm_mon + 1,
local_time->tm_mday,

View File

@ -13,7 +13,7 @@ namespace big
m_hash = *m_vehicle_idx.at(66).as<Hash*>();
m_state_bitfield = m_vehicle_idx.at(103).as<int*>();
m_name = fmt::format(
m_name = std::format(
"{} ({})",
HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(m_hash)),
m_plate

View File

@ -245,7 +245,7 @@ namespace big
void vehicle_service::set_active_profile(std::uint32_t hash, std::string share_code)
{
if (auto& it = this->m_active_profiles.find(hash); it != this->m_active_profiles.end())
if (const auto& it = this->m_active_profiles.find(hash); it != this->m_active_profiles.end())
it->second = share_code;
else
this->m_active_profiles.emplace(hash, share_code);

View File

@ -177,8 +177,8 @@ namespace big
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION("CMOD_WHE_B_0");
}
if (mod >= mod_count / 2)
//return fmt::format("{} {}", HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION("CHROME"), HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_MOD_TEXT_LABEL(vehicle, mod_slot, mod))).c_str(); //Bug with FMT library? Returns Chrome Chrome...
return fmt::format("Chrome {}", HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_MOD_TEXT_LABEL(vehicle, mod_slot, mod))).c_str();
//return std::format("{} {}", HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION("CHROME"), HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_MOD_TEXT_LABEL(vehicle, mod_slot, mod))).c_str(); //Bug with FMT library? Returns Chrome Chrome...
return std::format("Chrome {}", HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_MOD_TEXT_LABEL(vehicle, mod_slot, mod))).c_str();
else
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(VEHICLE::GET_MOD_TEXT_LABEL(vehicle, mod_slot, mod));
}
@ -186,17 +186,17 @@ namespace big
switch (mod_slot)
{
case MOD_ARMOR:
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(fmt::format("CMOD_ARM_{}", (mod + 1)).c_str());
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(std::format("CMOD_ARM_{}", (mod + 1)).c_str());
case MOD_BRAKES:
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(fmt::format("CMOD_BRA_{}", (mod + 1)).c_str());
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(std::format("CMOD_BRA_{}", (mod + 1)).c_str());
case MOD_ENGINE:
if (mod == -1)
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION("CMOD_ARM_0");
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(fmt::format("CMOD_ENG_{}", (mod + 1)).c_str());
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(std::format("CMOD_ENG_{}", (mod + 1)).c_str());
case MOD_SUSPENSION:
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(fmt::format("CMOD_SUS_{}", (mod + 1)).c_str());
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(std::format("CMOD_SUS_{}", (mod + 1)).c_str());
case MOD_TRANSMISSION:
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(fmt::format("CMOD_GBX_{}", (mod + 1)).c_str());
return HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(std::format("CMOD_GBX_{}", (mod + 1)).c_str());
}

View File

@ -50,7 +50,7 @@ namespace big::notify
inline void player_joined(CNetGamePlayer* net_game_player)
{
above_map(
fmt::format("<C>{}</C> joined.", net_game_player->get_name())
std::format("<C>{}</C> joined.", net_game_player->get_name())
);
}
}

View File

@ -11,7 +11,7 @@ namespace big
{
void view::view_player() {
std::string title = fmt::format("Player Options: {}", g_player_service->get_selected()->get_name());
std::string title = std::format("Player Options: {}", g_player_service->get_selected()->get_name());
ImGui::Text(title.c_str());
ImGui::Checkbox("Spectate", &g->player.spectating);

View File

@ -17,7 +17,7 @@ namespace big
components::button("Mors Mutual Fix All Vehicles", [] {
int amount_fixed = mobile::mors_mutual::fix_all();
g_notification_service->push("Mobile",
fmt::format("{} vehicle{} been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have")
std::format("{} vehicle{} been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have")
);
});
}

View File

@ -87,7 +87,7 @@ namespace big
{
float auto_drive_speed_user_unit = vehicle::mps_to_speed(g->vehicle.auto_drive_speed, g->vehicle.speed_unit);
if (ImGui::SliderFloat(
fmt::format("Top Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(),
std::format("Top Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(),
&auto_drive_speed_user_unit,
vehicle::mps_to_speed(0.f, g->vehicle.speed_unit),
vehicle::mps_to_speed(150.f, g->vehicle.speed_unit),
@ -106,7 +106,7 @@ namespace big
g->vehicle.auto_drive_style = (AutoDriveStyle)i;
g_notification_service->push_warning(
"Auto Drive",
fmt::format("Driving style set to {}.", driving_style_names[i])
std::format("Driving style set to {}.", driving_style_names[i])
);
}
@ -221,7 +221,7 @@ namespace big
float fly_speed_user_unit = vehicle::mps_to_speed(g->vehicle.fly.speed, g->vehicle.speed_unit);
if (ImGui::SliderFloat(
fmt::format("Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(),
std::format("Speed({})", speed_unit_strings[(int)g->vehicle.speed_unit]).c_str(),
&fly_speed_user_unit,
vehicle::mps_to_speed(0.f, g->vehicle.speed_unit),
vehicle::mps_to_speed(150.f, g->vehicle.speed_unit),

View File

@ -80,7 +80,7 @@ namespace big
{
const auto& item = g_gta_data_service->vehicle_by_hash(veh_hash);
components::selectable(fmt::format("Current Vehicle [{}]", item.m_display_name), false, [] {
components::selectable(std::format("Current Vehicle [{}]", item.m_display_name), false, [] {
if (self::veh)
{
Vector3 spawn_location = vehicle::get_spawn_location(g->spawn_vehicle.spawn_inside);

View File

@ -11,7 +11,7 @@ namespace big
components::button("MMI Fix All PV", [] {
int amount_fixed = mobile::mors_mutual::fix_all();
g_notification_service->push("Mobile",
fmt::format("{} vehicle{} been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have")
std::format("{} vehicle{} been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have")
);
});
ImGui::SameLine();

View File

@ -10,7 +10,7 @@ workspace "BigBaseV2"
outputdir = "%{cfg.buildcfg}"
CppVersion = "C++17"
CppVersion = "C++20"
MsvcToolset = "v143"
WindowsSdkVersion = "10.0"
@ -26,8 +26,8 @@ workspace "BigBaseV2"
{
"_CRT_SECURE_NO_WARNINGS",
"NOMINMAX",
"WIN32_LEAN_AND_MEAN",
"_WIN32_WINNT=0x601" -- Support Windows 7
"WIN32_LEAN_AND_MEAN"
-- "_WIN32_WINNT=0x601" -- Support Windows 7
}
disablewarnings
@ -51,28 +51,6 @@ workspace "BigBaseV2"
filter "not configurations:Debug"
defines { "NDEBUG" }
end
project "fmtlib"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C++"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
files
{
"vendor/%{prj.name}/include/**.h",
"vendor/%{prj.name}/src/**.cc"
}
includedirs
{
"vendor/%{prj.name}/include"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "g3log"
location "vendor/%{prj.name}"
@ -87,8 +65,9 @@ workspace "BigBaseV2"
"vendor/%{prj.name}/src"
}
if(file_exists("vendor\\g3log\\src\\g3log\\generated_definitions.hpp") == false) then
file = io.open("vendor\\g3log\\src\\g3log\\generated_definitions.hpp", "w")
g3log_file = "vendor/g3log/src/g3log/generated_definitions.hpp"
if(file_exists(g3log_file) == false) then
file = io.open(g3log_file, "w")
if(file == nil) then
premake.error("Failed to locate vendor directories. Try doing git pull --recurse-submodules.")
end
@ -224,7 +203,6 @@ workspace "BigBaseV2"
includedirs
{
"%{prj.name}/src/",
"vendor/fmtlib/include",
"vendor/g3log/src",
"vendor/GTAV-Classes",
"vendor/ImGui",
@ -240,7 +218,6 @@ workspace "BigBaseV2"
links
{
"fmtlib",
"g3log",
"ImGui",
"MinHook",

1
vendor/fmtlib vendored

@ -1 +0,0 @@
Subproject commit a6fafe2f0191cd456d6df66a3071c35c087188a0