diff --git a/UE4SS/include/LuaType/LuaUObject.hpp b/UE4SS/include/LuaType/LuaUObject.hpp index ea81196a..e5e9f62b 100644 --- a/UE4SS/include/LuaType/LuaUObject.hpp +++ b/UE4SS/include/LuaType/LuaUObject.hpp @@ -778,7 +778,7 @@ No overload found for function 'UObject.ProcessConsoleExec'. // We can either throw an error and kill the execution /**/ std::wstring property_type_name = property_type.ToString(); - lua.throw_error(std::format( + lua.throw_error(fmt::format( "[LocalUnrealParam::prepare_to_handle] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", to_string(property_type_name))); //*/ @@ -840,6 +840,6 @@ No overload found for function 'UObject.ProcessConsoleExec'. break; } - params.lua.throw_error(std::format("[push_integer] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_integer] Unknown Operation ({}) not supported", static_cast(params.operation))); } } // namespace RC::LuaType diff --git a/UE4SS/src/CrashDumper.cpp b/UE4SS/src/CrashDumper.cpp index 5e35de5f..d500eece 100644 --- a/UE4SS/src/CrashDumper.cpp +++ b/UE4SS/src/CrashDumper.cpp @@ -1,10 +1,8 @@ #include - -#include #include #include #include - +#include #include #include @@ -27,13 +25,13 @@ namespace RC LONG WINAPI ExceptionHandler(_EXCEPTION_POINTERS* exception_pointers) { const auto now = time_point_cast(system_clock::now()); - const std::wstring dump_path = std::format(L"{}\\crash_{:%Y_%m_%d_%H_%M_%S}.dmp", StringType{UE4SSProgram::get_program().get_working_directory()}, now); + const std::wstring dump_path = fmt::format(L"{}\\crash_{:%Y_%m_%d_%H_%M_%S}.dmp", StringType{UE4SSProgram::get_program().get_working_directory()}, now); const HANDLE file = CreateFileW(dump_path.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file == INVALID_HANDLE_VALUE) { - const std::wstring message = std::format(L"Failed to create crashdump file, reason: {:x}", GetLastError()); + const std::wstring message = fmt::format(L"Failed to create crashdump file, reason: {:x}", GetLastError()); MessageBoxW(NULL, message.c_str(), L"Fatal Error!", MB_OK); return EXCEPTION_CONTINUE_SEARCH; } @@ -55,12 +53,12 @@ namespace RC if (!ok) { - const std::wstring message = std::format(L"Failed to write crashdump file, reason: {:x}", GetLastError()); + const std::wstring message = fmt::format(L"Failed to write crashdump file, reason: {:x}", GetLastError()); MessageBoxW(NULL, message.c_str(), L"Fatal Error!", MB_OK); return EXCEPTION_CONTINUE_SEARCH; } - const std::wstring message = std::format(L"Crashdump written to: {}", dump_path); + const std::wstring message = fmt::format(L"Crashdump written to: {}", dump_path); MessageBoxW(NULL, message.c_str(), L"Fatal Error!", MB_OK); return EXCEPTION_EXECUTE_HANDLER; diff --git a/UE4SS/src/GUI/BPMods.cpp b/UE4SS/src/GUI/BPMods.cpp index b5507c6b..04afce1a 100644 --- a/UE4SS/src/GUI/BPMods.cpp +++ b/UE4SS/src/GUI/BPMods.cpp @@ -95,13 +95,13 @@ namespace RC::GUI::BPMods auto mod_name_parts = explode_by_occurrence(mod_full_name, STR('/')); mod_info.ModName = to_string(mod_name_parts[mod_name_parts.size() - 1 - 1]); - if (ImGui_TreeNodeEx(std::format("{}", mod_info.ModName).c_str(), std::format("{}_{}", mod_info.ModName, i).c_str(), ImGuiTreeNodeFlags_CollapsingHeader)) + if (ImGui_TreeNodeEx(fmt::format("{}", mod_info.ModName).c_str(), fmt::format("{}_{}", mod_info.ModName, i).c_str(), ImGuiTreeNodeFlags_CollapsingHeader)) { ImGui::Indent(); ImGui::Text("Author: %s", mod_info.ModAuthor.c_str()); ImGui::Text("Description: %s", mod_info.ModDescription.c_str()); ImGui::Text("Version: %s", mod_info.ModVersion.c_str()); - if (ImGui_TreeNodeEx("Mod Buttons", std::format("{}_{}_ModButtons", mod_info.ModName, i).c_str(), ImGuiTreeNodeFlags_CollapsingHeader)) + if (ImGui_TreeNodeEx("Mod Buttons", fmt::format("{}_{}_ModButtons", mod_info.ModName, i).c_str(), ImGuiTreeNodeFlags_CollapsingHeader)) { ImGui::Indent(); for (size_t i2 = 0; i2 < mod_info.ModButtons.size(); ++i2) @@ -111,7 +111,7 @@ namespace RC::GUI::BPMods continue; } const auto& mod_button = mod_info.ModButtons[i2]; - if (ImGui::Button(std::format("{}", mod_button).c_str())) + if (ImGui::Button(fmt::format("{}", mod_button).c_str())) { Output::send(STR("Mod button {} hit.\n"), to_wstring(mod_button)); mod_info.ModActor->ModMenuButtonPressed(static_cast(i2)); diff --git a/UE4SS/src/GUI/Dumpers.cpp b/UE4SS/src/GUI/Dumpers.cpp index a2ddc002..640b1864 100644 --- a/UE4SS/src/GUI/Dumpers.cpp +++ b/UE4SS/src/GUI/Dumpers.cpp @@ -90,17 +90,17 @@ namespace RC::GUI::Dumpers auto location = root_component->GetValuePtrByPropertyNameInChain(STR("RelativeLocation")); FString location_string{}; location_property->ExportTextItem(location_string, location, nullptr, nullptr, 0); - root_actor_buffer.append(std::format(STR("\"{}\","), location_string.GetCharArray())); + root_actor_buffer.append(fmt::format(STR("\"{}\","), location_string.GetCharArray())); auto rotation = root_component->GetValuePtrByPropertyNameInChain(STR("RelativeRotation")); FString rotation_string{}; rotation_property->ExportTextItem(rotation_string, rotation, nullptr, nullptr, 0); - root_actor_buffer.append(std::format(STR("\"{}\","), rotation_string.GetCharArray())); + root_actor_buffer.append(fmt::format(STR("\"{}\","), rotation_string.GetCharArray())); auto scale = root_component->GetValuePtrByPropertyNameInChain(STR("RelativeScale3D")); FString scale_string{}; scale_property->ExportTextItem(scale_string, scale, nullptr, nullptr, 0); - root_actor_buffer.append(std::format(STR("\"{}\","), scale_string.GetCharArray())); + root_actor_buffer.append(fmt::format(STR("\"{}\","), scale_string.GetCharArray())); return root_actor_buffer; } @@ -128,13 +128,13 @@ namespace RC::GUI::Dumpers StringType actor_buffer{}; - actor_buffer.append(std::format(STR("Row_{},"), actor_count)); + actor_buffer.append(fmt::format(STR("Row_{},"), actor_count)); static auto game_mode_base = UObjectGlobals::FindFirstOf(STR("GameModeBase")); static auto class_property = game_mode_base->GetPropertyByNameInChain(STR("GameStateClass")); FString actor_class_string{}; class_property->ExportTextItem(actor_class_string, &actor->GetClassPrivate(), nullptr, nullptr, 0); - actor_buffer.append(std::format(STR("{},"), actor_class_string.GetCharArray())); + actor_buffer.append(fmt::format(STR("{},"), actor_class_string.GetCharArray())); // TODO: build system to handle other types of components - possibly including a way to specify which components to dump and which properties are important via a config file actor_buffer.append(generate_root_component_csv(*root_component)); @@ -157,7 +157,7 @@ namespace RC::GUI::Dumpers static auto mesh_property = static_mesh_component_ptr->GetPropertyByNameInChain(STR("StaticMesh")); FString mesh_string{}; mesh_property->ExportTextItem(mesh_string, &mesh, nullptr, nullptr, 0); - actor_buffer.append(std::format(STR("(StaticMesh={}',"), mesh_string.GetCharArray())); + actor_buffer.append(fmt::format(STR("(StaticMesh={}',"), mesh_string.GetCharArray())); auto materials_for_each_body = [&](const UObject* material_interface) { if (material_interface) @@ -178,8 +178,8 @@ namespace RC::GUI::Dumpers auto material_typeless_name = StringViewType{material_full_name.begin() + static_cast(material_type_space_location) + 1, material_full_name.end()}; - actor_buffer.append(std::format(STR("{}'"), material_interface->GetClassPrivate()->GetName())); - actor_buffer.append(std::format(STR("\"\"{}"), material_typeless_name)); + actor_buffer.append(fmt::format(STR("{}'"), material_interface->GetClassPrivate()->GetName())); + actor_buffer.append(fmt::format(STR("\"\"{}"), material_typeless_name)); actor_buffer.append(STR("\"\"'")); } }; @@ -264,19 +264,19 @@ namespace RC::GUI::Dumpers auto& actor_json_object = global_json_array.new_object(); - actor_json_object.new_string(STR("Name"), std::format(STR("Row_{}"), actor_count)); + actor_json_object.new_string(STR("Name"), fmt::format(STR("Row_{}"), actor_count)); static auto game_mode_base = UObjectGlobals::FindFirstOf(STR("GameModeBase")); static auto class_property = game_mode_base->GetPropertyByNameInChain(STR("GameStateClass")); FString actor_class_string{}; class_property->ExportTextItem(actor_class_string, &actor->GetClassPrivate(), nullptr, nullptr, 0); - actor_json_object.new_string(STR("Actor"), std::format(STR("{}"), StringViewType{actor_class_string.GetCharArray()})); + actor_json_object.new_string(STR("Actor"), fmt::format(STR("{}"), StringViewType{actor_class_string.GetCharArray()})); auto& root_component_json_object = actor_json_object.new_object(STR("RootComponent")); FString root_component_class_string{}; class_property->ExportTextItem(root_component_class_string, &(*root_component)->GetClassPrivate(), nullptr, nullptr, 0); - root_component_json_object.new_string(STR("SceneComponentClass"), std::format(STR("{}"), StringViewType{root_component_class_string.GetCharArray()})); + root_component_json_object.new_string(STR("SceneComponentClass"), fmt::format(STR("{}"), StringViewType{root_component_class_string.GetCharArray()})); auto& location_json_object = root_component_json_object.new_object(STR("Location")); auto location = (*root_component)->GetValuePtrByPropertyNameInChain(STR("RelativeLocation")); @@ -313,7 +313,7 @@ namespace RC::GUI::Dumpers std::wstring file_buffer{}; file_buffer.append(generate_actors_csv_file(dump_actor_class)); auto file = - File::open(std::format(STR("{}\\{}-ue4ss_static_mesh_data.csv"), UE4SSProgram::get_program().get_working_directory(), long(std::time(nullptr))), + File::open(fmt::format(STR("{}\\{}-ue4ss_static_mesh_data.csv"), UE4SSProgram::get_program().get_working_directory(), long(std::time(nullptr))), File::OpenFor::Writing, File::OverwriteExistingFile::Yes, File::CreateIfNonExistent::Yes); @@ -326,7 +326,7 @@ namespace RC::GUI::Dumpers Output::send(STR("Dumping CSV of all loaded actor types, positions and mesh properties\n")); std::wstring file_buffer{}; file_buffer.append(generate_actors_csv_file(AActor::StaticClass())); - auto file = File::open(std::format(STR("{}\\{}-ue4ss_actor_data.csv"), UE4SSProgram::get_program().get_working_directory(), long(std::time(nullptr))), + auto file = File::open(fmt::format(STR("{}\\{}-ue4ss_actor_data.csv"), UE4SSProgram::get_program().get_working_directory(), long(std::time(nullptr))), File::OpenFor::Writing, File::OverwriteExistingFile::Yes, File::CreateIfNonExistent::Yes); diff --git a/UE4SS/src/GUI/LiveView.cpp b/UE4SS/src/GUI/LiveView.cpp index 70cbaec7..92b95b0e 100644 --- a/UE4SS/src/GUI/LiveView.cpp +++ b/UE4SS/src/GUI/LiveView.cpp @@ -48,6 +48,7 @@ #include #include #include +#include namespace RC::GUI { @@ -341,7 +342,7 @@ namespace RC::GUI } auto json_file = - File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + std::format(STR("\\liveview\\filters.meta.json")), + File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + fmt::format(STR("\\liveview\\filters.meta.json")), File::OpenFor::Writing, File::OverwriteExistingFile::Yes, File::CreateIfNonExistent::Yes); @@ -364,7 +365,7 @@ namespace RC::GUI json_array.for_each([&](JSON::Value& item) { if (!item.is()) { - throw std::runtime_error{std::format("Invalid {} in 'filters.meta.json'", to_string(type))}; + throw std::runtime_error{fmt::format("Invalid {} in 'filters.meta.json'", to_string(type))}; } list.emplace_back(item.as()->get_view()); return LoopAction::Continue; @@ -390,7 +391,7 @@ namespace RC::GUI static auto internal_load_filters_from_disk() -> void { const auto json_file = - File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + std::format(STR("\\liveview\\filters.meta.json")), + File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + fmt::format(STR("\\liveview\\filters.meta.json")), File::OpenFor::Reading, File::OverwriteExistingFile::No, File::CreateIfNonExistent::Yes); @@ -578,8 +579,8 @@ namespace RC::GUI static auto internal_load_watches_from_disk() -> void { - auto working_directory_path = StringType{UE4SSProgram::get_program().get_working_directory()} + std::format(STR("\\watches\\watches.meta.json")); - auto legacy_root_directory_path = StringType{UE4SSProgram::get_program().get_legacy_root_directory()} + std::format(STR("\\watches\\watches.meta.json")); + auto working_directory_path = StringType{UE4SSProgram::get_program().get_working_directory()} + fmt::format(STR("\\watches\\watches.meta.json")); + auto legacy_root_directory_path = StringType{UE4SSProgram::get_program().get_legacy_root_directory()} + fmt::format(STR("\\watches\\watches.meta.json")); StringType json_file_contents; bool is_legacy = !std::filesystem::exists(working_directory_path) && std::filesystem::exists(legacy_root_directory_path); @@ -673,7 +674,7 @@ namespace RC::GUI } } - auto json_file = File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + std::format(STR("\\watches\\watches.meta.json")), + auto json_file = File::open(StringType{UE4SSProgram::get_program().get_working_directory()} + fmt::format(STR("\\watches\\watches.meta.json")), File::OpenFor::Writing, File::OverwriteExistingFile::Yes, File::CreateIfNonExistent::Yes); @@ -714,10 +715,10 @@ namespace RC::GUI { auto& file_device = output.get_device(); file_device.set_file_name_and_path(StringType{UE4SSProgram::get_program().get_working_directory()} + - std::format(STR("\\watches\\ue4ss_watch_{}_{}.txt"), object_name, property_name)); + fmt::format(STR("\\watches\\ue4ss_watch_{}_{}.txt"), object_name, property_name)); file_device.set_formatter([](File::StringViewType string) -> File::StringType { - const auto when_as_string = std::format(STR("{:%Y-%m-%d %H:%M:%S}"), std::chrono::system_clock::now()); - return std::format(STR("[{}] {}"), when_as_string, string); + const auto when_as_string = fmt::format(STR("{:%Y-%m-%d %H:%M:%S}"), std::chrono::system_clock::now()); + return fmt::format(STR("[{}] {}"), when_as_string, string); }); } @@ -1782,7 +1783,7 @@ namespace RC::GUI bool open_edit_value_popup{}; auto render_property_value_context_menu = [&](std::string_view id_override = "") { - if (ImGui::BeginPopupContextItem(id_override.empty() ? property_name.c_str() : std::format("context-menu-{}", id_override).c_str())) + if (ImGui::BeginPopupContextItem(id_override.empty() ? property_name.c_str() : fmt::format("context-menu-{}", id_override).c_str())) { if (ImGui::MenuItem("Copy name")) { @@ -1862,14 +1863,14 @@ namespace RC::GUI { ImGui::Text("0x%X%s %s:", first_offset, - container_type == ContainerType::Array ? std::format("").c_str() : std::format(" (0x{:X})", property_offset).c_str(), + container_type == ContainerType::Array ? fmt::format("").c_str() : fmt::format(" (0x{:X})", property_offset).c_str(), property_name.c_str()); } if (auto struct_property = CastField(property); struct_property && struct_property->GetStruct()->GetFirstProperty()) { ImGui::SameLine(); - auto tree_node_id = std::format("{}{}", static_cast(container_ptr), property_name); - if (ImGui_TreeNodeEx(std::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog)) + auto tree_node_id = fmt::format("{}{}", static_cast(container_ptr), property_name); + if (ImGui_TreeNodeEx(fmt::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog)) { render_property_value_context_menu(tree_node_id); @@ -1902,8 +1903,8 @@ namespace RC::GUI else if (auto array_property = CastField(property); array_property) { ImGui::SameLine(); - auto tree_node_id = std::format("{}{}", static_cast(container_ptr), property_name); - if (ImGui_TreeNodeEx(std::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog)) + auto tree_node_id = fmt::format("{}{}", static_cast(container_ptr), property_name); + if (ImGui_TreeNodeEx(fmt::format("{}", to_string(property_text.GetCharArray())).c_str(), tree_node_id.c_str(), ImGuiTreeNodeFlags_NoAutoOpenOnLog)) { render_property_value_context_menu(tree_node_id); @@ -1987,7 +1988,7 @@ namespace RC::GUI { parent_name = obj ? obj->GetName() : STR("None"); } - auto edit_property_value_modal_name = to_string(std::format(STR("Edit value of property: {}->{}"), parent_name, property->GetName())); + auto edit_property_value_modal_name = to_string(fmt::format(STR("Edit value of property: {}->{}"), parent_name, property->GetName())); if (open_edit_value_popup) { @@ -2077,7 +2078,7 @@ namespace RC::GUI ImGui::TableNextColumn(); ImGui::Text("%S", enum_name.c_str()); - if (ImGui::BeginPopupContextItem(to_string(std::format(STR("context-menu-{}"), enum_name)).c_str())) + if (ImGui::BeginPopupContextItem(to_string(fmt::format(STR("context-menu-{}"), enum_name)).c_str())) { if (ImGui::MenuItem("Copy name")) { @@ -2096,7 +2097,7 @@ namespace RC::GUI ImGui::TableNextColumn(); ImGui::Text("%lld", name.Value); - if (ImGui::BeginPopupContextItem(to_string(std::format(STR("context-menu-{}-{}"), enum_name, name.Value)).c_str())) + if (ImGui::BeginPopupContextItem(to_string(fmt::format(STR("context-menu-{}-{}"), enum_name, name.Value)).c_str())) { if (ImGui::MenuItem("Copy value")) { @@ -2111,7 +2112,7 @@ namespace RC::GUI } ImGui::TableNextColumn(); - ImGui::PushID(to_string(std::format(STR("button_add_{}"), enum_name)).c_str()); + ImGui::PushID(to_string(fmt::format(STR("button_add_{}"), enum_name)).c_str()); if (ImGui::Button("+")) { open_add_name_popup = true; @@ -2119,18 +2120,18 @@ namespace RC::GUI } ImGui::PopID(); ImGui::SameLine(); - ImGui::PushID(to_string(std::format(STR("button_remove_{}"), enum_name)).c_str()); + ImGui::PushID(to_string(fmt::format(STR("button_remove_{}"), enum_name)).c_str()); if (ImGui::Button("-")) { uenum->RemoveFromNamesAt(index, 1); } ImGui::PopID(); - std::string edit_enum_name_modal_name = to_string(std::format(STR("Edit enum name for: {}"), name.Key.ToString())); + std::string edit_enum_name_modal_name = to_string(fmt::format(STR("Edit enum name for: {}"), name.Key.ToString())); - std::string edit_enum_value_modal_name = to_string(std::format(STR("Edit enum value for: {}"), name.Key.ToString())); + std::string edit_enum_value_modal_name = to_string(fmt::format(STR("Edit enum value for: {}"), name.Key.ToString())); - std::string add_enum_name_modal_name = to_string(std::format(STR("Enter new enum name after: {}"), name.Key.ToString())); + std::string add_enum_name_modal_name = to_string(fmt::format(STR("Enter new enum name after: {}"), name.Key.ToString())); if (open_edit_name_popup) { @@ -2465,7 +2466,7 @@ namespace RC::GUI { if (ImGui::MenuItem("Copy raw flags")) { - ImGui::SetClipboardText(std::format("0x{:X}", static_cast(raw_unsafe_object_flags)).c_str()); + ImGui::SetClipboardText(fmt::format("0x{:X}", static_cast(raw_unsafe_object_flags)).c_str()); } ImGui::EndPopup(); } @@ -2474,7 +2475,7 @@ namespace RC::GUI std::string current_flag_line{}; std::string all_flags{}; auto create_menu_for_copy_flags = [&](size_t menu_index) { - if (ImGui::BeginPopupContextItem(std::format("{}_{}", Stringifier::popup_context_item_id, menu_index).c_str())) + if (ImGui::BeginPopupContextItem(fmt::format("{}_{}", Stringifier::popup_context_item_id, menu_index).c_str())) { if (ImGui::MenuItem("Copy flags")) { @@ -2533,7 +2534,7 @@ namespace RC::GUI { if (ImGui::MenuItem("Copy address")) { - ImGui::SetClipboardText(std::format("{:016X}", std::bit_cast(object)).c_str()); + ImGui::SetClipboardText(fmt::format("{:016X}", std::bit_cast(object)).c_str()); } ImGui::EndPopup(); } @@ -2618,7 +2619,7 @@ namespace RC::GUI { if (ImGui::MenuItem("Copy address")) { - ImGui::SetClipboardText(std::format("{:016X}", std::bit_cast(property)).c_str()); + ImGui::SetClipboardText(fmt::format("{:016X}", std::bit_cast(property)).c_str()); } ImGui::EndPopup(); } @@ -2635,7 +2636,7 @@ namespace RC::GUI { if (ImGui::MenuItem("Copy raw flags")) { - ImGui::SetClipboardText(std::format("0x{:X}", static_cast(property_flags)).c_str()); + ImGui::SetClipboardText(fmt::format("0x{:X}", static_cast(property_flags)).c_str()); } ImGui::EndPopup(); } @@ -2644,7 +2645,7 @@ namespace RC::GUI std::string current_flag_line{}; std::string all_flags{}; auto create_menu_for_copy_flags = [&](size_t menu_index) { - if (ImGui::BeginPopupContextItem(std::format("property_flags_menu_{}", menu_index).c_str())) + if (ImGui::BeginPopupContextItem(fmt::format("property_flags_menu_{}", menu_index).c_str())) { if (ImGui::MenuItem("Copy flags")) { @@ -2701,7 +2702,7 @@ namespace RC::GUI }; int go_to_property_menu_count{}; auto create_go_to_property_menu = [&](FProperty* goto_to_property) { - if (ImGui::BeginPopupContextItem(std::format("property_link_next_menu_{}", go_to_property_menu_count++).c_str())) + if (ImGui::BeginPopupContextItem(fmt::format("property_link_next_menu_{}", go_to_property_menu_count++).c_str())) { if (ImGui::MenuItem("Go to property")) { @@ -2785,7 +2786,7 @@ namespace RC::GUI } else { - if (ImGui::MenuItem(std::format("{}. {}", item_index, item.GetFullName()).c_str())) + if (ImGui::MenuItem(fmt::format("{}. {}", item_index, item.GetFullName()).c_str())) { next_item_index = item_index; selected_an_item = true; @@ -2907,7 +2908,7 @@ namespace RC::GUI watch.property_value = std::move(live_value_string); - const auto when_as_string = std::format(STR("{:%H:%M:%S}"), std::chrono::system_clock::now()); + const auto when_as_string = fmt::format(STR("{:%H:%M:%S}"), std::chrono::system_clock::now()); watch.history.append(to_string(when_as_string + STR(" ") + watch.property_value + STR("\n"))); if (watch.write_to_file) @@ -2943,10 +2944,10 @@ namespace RC::GUI auto num_params = function->GetNumParms(); - const auto when_as_string = std::format(STR("{:%H:%M:%S}"), std::chrono::system_clock::now()); - StringType buffer{std::format(STR("Received call @ {}.\n"), when_as_string)}; + const auto when_as_string = fmt::format(STR("{:%H:%M:%S}"), std::chrono::system_clock::now()); + StringType buffer{fmt::format(STR("Received call @ {}.\n"), when_as_string)}; - buffer.append(std::format(STR(" Context:\n {}\n"), context.Context->GetFullName())); + buffer.append(fmt::format(STR(" Context:\n {}\n"), context.Context->GetFullName())); buffer.append(STR(" Locals:\n")); bool has_local_params{}; @@ -2960,7 +2961,7 @@ namespace RC::GUI FString param_text{}; auto container_ptr = param->ContainerPtrToValuePtr(context.TheStack.Locals()); param->ExportTextItem(param_text, container_ptr, container_ptr, std::bit_cast(function), NULL); - buffer.append(std::format(STR(" {} = {}\n"), param->GetName(), param_text.GetCharArray())); + buffer.append(fmt::format(STR(" {} = {}\n"), param->GetName(), param_text.GetCharArray())); } if (!has_local_params) { @@ -2983,7 +2984,7 @@ namespace RC::GUI FString param_text{}; auto container_ptr = FindOutParamValueAddress(context.TheStack, param); param->ExportTextItem(param_text, container_ptr, container_ptr, std::bit_cast(function), NULL); - buffer.append(std::format(STR(" {} = {}\n"), param->GetName(), param_text.GetCharArray())); + buffer.append(fmt::format(STR(" {} = {}\n"), param->GetName(), param_text.GetCharArray())); } if (!has_out_params) { @@ -2997,7 +2998,7 @@ namespace RC::GUI FString return_property_text{}; auto container_ptr = context.RESULT_DECL; return_property->ExportTextItem(return_property_text, container_ptr, container_ptr, std::bit_cast(function), NULL); - buffer.append(std::format(STR(" {}"), return_property_text.GetCharArray())); + buffer.append(fmt::format(STR(" {}"), return_property_text.GetCharArray())); } else { @@ -3584,7 +3585,7 @@ namespace RC::GUI auto& watch = *watch_ptr; ImGui::TableNextRow(); ImGui::TableNextColumn(); - if (ImGui::Checkbox(to_string(std::format(STR("##watch-on-off-{}"), watch.hash)).c_str(), &watch.enabled)) + if (ImGui::Checkbox(to_string(fmt::format(STR("##watch-on-off-{}"), watch.hash)).c_str(), &watch.enabled)) { if (watch.container->IsA()) { @@ -3598,7 +3599,7 @@ namespace RC::GUI ImGui::EndTooltip(); } ImGui::SameLine(0.0f, 2.0f); - ImGui::Checkbox(to_string(std::format(STR("##watch-write-to-file-{}"), watch.hash)).c_str(), &watch.write_to_file); + ImGui::Checkbox(to_string(fmt::format(STR("##watch-write-to-file-{}"), watch.hash)).c_str(), &watch.write_to_file); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -3607,7 +3608,7 @@ namespace RC::GUI } ImGui::SameLine(0.0f, 2.0f); ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f, 0.5f)); - ImGui::PushID(std::format("collapse_history_{}", watch.hash).c_str()); + ImGui::PushID(fmt::format("collapse_history_{}", watch.hash).c_str()); ImGui::Selectable(watch.show_history ? ICON_FA_MINUS : ICON_FA_PLUS, &watch.show_history, ImGuiSelectableFlags_NoPadWithHalfSpacing); ImGui::PopID(); ImGui::PopStyleVar(); @@ -3616,7 +3617,7 @@ namespace RC::GUI ImGui::Text("%S.%S", watch.object_name.c_str(), watch.property_name.c_str()); if (watch.show_history) { - ImGui::PushID(std::format("history_{}", watch.hash).c_str()); + ImGui::PushID(fmt::format("history_{}", watch.hash).c_str()); ImGui::InputTextMultiline("##history", &watch.history, {-2.0f, ImGui::GetTextLineHeight() * 10.0f + ImGui::GetStyle().FramePadding.y * 2.0f}, @@ -3625,12 +3626,12 @@ namespace RC::GUI ImGui::PopID(); } ImGui::TableNextColumn(); - if (ImGui::Checkbox(to_string(std::format(STR("##watch-from-disk-{}"), watch.hash)).c_str(), &watch.load_on_startup)) + if (ImGui::Checkbox(to_string(fmt::format(STR("##watch-from-disk-{}"), watch.hash)).c_str(), &watch.load_on_startup)) { save_watches_to_disk(); } ImGui::SetNextWindowSize({690.0f, 0.0f}); - if (ImGui::BeginPopupContextItem(to_string(std::format(STR("##watch-from-disk-settings-popup-{}"), watch.hash)).c_str())) + if (ImGui::BeginPopupContextItem(to_string(fmt::format(STR("##watch-from-disk-settings-popup-{}"), watch.hash)).c_str())) { ImGui::Text("Acquisition Method"); ImGui::Text("This determines how the watch will be reacquired."); diff --git a/UE4SS/src/GUI/UFunctionCallerWidget.cpp b/UE4SS/src/GUI/UFunctionCallerWidget.cpp index e072e633..83373faf 100644 --- a/UE4SS/src/GUI/UFunctionCallerWidget.cpp +++ b/UE4SS/src/GUI/UFunctionCallerWidget.cpp @@ -82,7 +82,7 @@ namespace RC::GUI } } - cached_function.cached_name = std::format("{}{}", to_string(function->GetName()), cached_function.has_out_params ? " | CPF_OutParm" : ""); + cached_function.cached_name = fmt::format("{}{}", to_string(function->GetName()), cached_function.has_out_params ? " | CPF_OutParm" : ""); } m_is_cache_valid = true; } @@ -164,10 +164,10 @@ namespace RC::GUI } auto function = m_currently_selected_function->function; - auto cmd = std::format(STR("{}"), function->GetName()); + auto cmd = fmt::format(STR("{}"), function->GetName()); for (const auto& param : m_params_for_selected_function) { - cmd.append(std::format(STR(" {}"), to_wstring(param.value_from_ui))); + cmd.append(fmt::format(STR(" {}"), to_wstring(param.value_from_ui))); } Output::send(STR("Queueing command: {}\n"), cmd); @@ -299,7 +299,7 @@ namespace RC::GUI const auto object_name_typeless = get_typeless_object_name(object); if (!object_name_typeless.empty()) { - if (ImGui::MenuItem(std::format("#{}: {}", i, object_name_typeless).c_str())) + if (ImGui::MenuItem(fmt::format("#{}: {}", i, object_name_typeless).c_str())) { param.value_from_ui.insert(param.current_cursor_position_in_ui, object_name_typeless); } @@ -313,7 +313,7 @@ namespace RC::GUI { m_prev_instance = instance; - auto popup_modal_id = to_string(std::format(STR("##functions-for-{}"), instance->HashObject())); + auto popup_modal_id = to_string(fmt::format(STR("##functions-for-{}"), instance->HashObject())); auto& is_open = is_widget_open(); if (is_open) { @@ -375,7 +375,7 @@ namespace RC::GUI ImGui::EndTooltip(); } ImGui::SetNextItemWidth(-2.0f); - ImGui::InputText(std::format("##param-input-{}", param.cached_name).c_str(), + ImGui::InputText(fmt::format("##param-input-{}", param.cached_name).c_str(), ¶m.value_from_ui, ImGuiInputTextFlags_CallbackAlways, &value_from_ui_callback, @@ -393,7 +393,7 @@ namespace RC::GUI const auto pc_name_typeless = get_typeless_object_name(player_controller); if (!pc_name_typeless.empty()) { - if (ImGui::MenuItem(std::format("#{}: {}", i, pc_name_typeless).c_str())) + if (ImGui::MenuItem(fmt::format("#{}: {}", i, pc_name_typeless).c_str())) { param.value_from_ui.insert(param.current_cursor_position_in_ui, pc_name_typeless); } diff --git a/UE4SS/src/LuaLibrary.cpp b/UE4SS/src/LuaLibrary.cpp index 2d5e608e..6f0c8b45 100644 --- a/UE4SS/src/LuaLibrary.cpp +++ b/UE4SS/src/LuaLibrary.cpp @@ -150,7 +150,7 @@ namespace RC::LuaLibrary auto* mod = UE4SSProgram::find_lua_mod_by_name(mod_name); if (!mod || !mod->is_installed() || !mod->is_started()) { - auto error_message = std::format("No mod by name '{}' found.", mod_name); + auto error_message = fmt::format("No mod by name '{}' found.", mod_name); std::memcpy(output_buffer, error_message.data(), error_message.size()); return output_buffer; } @@ -159,12 +159,12 @@ namespace RC::LuaLibrary { if (int status = luaL_loadstring(mod->lua().get_lua_state(), script); status != LUA_OK) { - mod->lua().throw_error(std::format("luaL_loadstring returned {}", mod->lua().resolve_status_message(status, true))); + mod->lua().throw_error(fmt::format("luaL_loadstring returned {}", mod->lua().resolve_status_message(status, true))); } if (int status = lua_pcall(mod->lua().get_lua_state(), 0, LUA_MULTRET, 0); status != LUA_OK) { - mod->lua().throw_error(std::format("lua_pcall returned {}", mod->lua().resolve_status_message(status, true))); + mod->lua().throw_error(fmt::format("lua_pcall returned {}", mod->lua().resolve_status_message(status, true))); } } catch (std::runtime_error& e) diff --git a/UE4SS/src/LuaType/LuaTArray.cpp b/UE4SS/src/LuaType/LuaTArray.cpp index af33b855..2371aae2 100644 --- a/UE4SS/src/LuaType/LuaTArray.cpp +++ b/UE4SS/src/LuaType/LuaTArray.cpp @@ -158,7 +158,7 @@ namespace RC::LuaType } else { - lua.throw_error(std::format("[TArray:ForEach] Tried iterating an array but the unreal property has no registered handler (via ArrayProperty). " + lua.throw_error(fmt::format("[TArray:ForEach] Tried iterating an array but the unreal property has no registered handler (via ArrayProperty). " "Property type '{}' not supported.", to_string(property_type_name.ToString()))); } @@ -211,7 +211,7 @@ namespace RC::LuaType else { std::string property_type_name = to_string(property_type_fname.ToString()); - lua.throw_error(std::format("Tried accessing unreal property without a registered handler (via ArrayProperty). Property type '{}' not supported.", + lua.throw_error(fmt::format("Tried accessing unreal property without a registered handler (via ArrayProperty). Property type '{}' not supported.", property_type_name)); } } diff --git a/UE4SS/src/LuaType/LuaUObject.cpp b/UE4SS/src/LuaType/LuaUObject.cpp index 7ea83076..969d1b75 100644 --- a/UE4SS/src/LuaType/LuaUObject.cpp +++ b/UE4SS/src/LuaType/LuaUObject.cpp @@ -136,7 +136,7 @@ namespace RC::LuaType if (num_supplied_params != num_expected_params_with_return_value) { - lua.throw_error(std::format("[UFunction::setup_metamethods -> __call] UFunction expected {} parameters, received {}", + lua.throw_error(fmt::format("[UFunction::setup_metamethods -> __call] UFunction expected {} parameters, received {}", num_expected_params, num_supplied_params)); } @@ -219,7 +219,7 @@ namespace RC::LuaType std::string parameter_type_name = to_string(property_type_fname.ToString()); std::string parameter_name = to_string(param_next->GetName()); lua.throw_error( - std::format("Tried calling UFunction without a registered handler for parameter. Parameter '{}' of type '{}' not supported.", + fmt::format("Tried calling UFunction without a registered handler for parameter. Parameter '{}' of type '{}' not supported.", parameter_name, parameter_type_name)); } @@ -272,7 +272,7 @@ namespace RC::LuaType else { std::string param_type_name = to_string(param_type_fname.ToString()); - lua.throw_error(std::format("Tried calling UFunction without a registered handler 'Out' param. Type '{}' not supported.", param_type_name)); + lua.throw_error(fmt::format("Tried calling UFunction without a registered handler 'Out' param. Type '{}' not supported.", param_type_name)); } if (!reuse_same_table) @@ -303,7 +303,7 @@ namespace RC::LuaType else { std::string return_value_type_name = to_string(return_value_property_type.ToString()); - lua.throw_error(std::format("Tried calling UFunction without a registered handler for return value. Return value of type '{}' not supported.", + lua.throw_error(fmt::format("Tried calling UFunction without a registered handler for return value. Return value of type '{}' not supported.", return_value_type_name)); } @@ -563,7 +563,7 @@ namespace RC::LuaType else { std::string field_type_name = to_string(field_type.ToString()); - lua.throw_error(std::format("Tried getting without a registered handler. 'StructProperty'.'{}' not supported. Field: '{}'", + lua.throw_error(fmt::format("Tried getting without a registered handler. 'StructProperty'.'{}' not supported. Field: '{}'", field_type_name, field_name)); } @@ -623,7 +623,7 @@ namespace RC::LuaType else { std::string field_type_name = to_string(field_type_fname.ToString()); - params.lua.throw_error(std::format("Tried pushing (Operation::Set) StructProperty without a registered handler for field '{} {}'.", + params.lua.throw_error(fmt::format("Tried pushing (Operation::Set) StructProperty without a registered handler for field '{} {}'.", field_type_name, field_name)); } @@ -676,7 +676,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_structproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_structproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_arrayproperty(const PusherParams& params) -> void @@ -726,7 +726,7 @@ namespace RC::LuaType { std::string property_type_name = to_string(property_type_fname.ToString()); lua.throw_error( - std::format("Tried interacting with an array but the inner property has no registered handler. Property type '{}' not supported.", + fmt::format("Tried interacting with an array but the inner property has no registered handler. Property type '{}' not supported.", property_type_name)); } }; @@ -740,7 +740,7 @@ namespace RC::LuaType if (!StaticState::m_property_value_pushers.contains(name_comparison_index)) { std::string inner_type_name = to_string(inner_type_fname.ToString()); - params.lua.throw_error(std::format("Tried pushing (Operation::Set) ArrayProperty with unsupported inner type of '{}'", inner_type_name)); + params.lua.throw_error(fmt::format("Tried pushing (Operation::Set) ArrayProperty with unsupported inner type of '{}'", inner_type_name)); } size_t array_element_size = inner->GetElementSize(); @@ -841,7 +841,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_arrayproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_arrayproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_functionproperty(const FunctionPusherParams& params) -> void @@ -874,7 +874,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_floatproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_floatproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_doubleproperty(const PusherParams& params) -> void @@ -902,7 +902,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_doubleproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_doubleproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_boolproperty(const PusherParams& params) -> void @@ -940,7 +940,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_boolproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_boolproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_enumproperty(const PusherParams& params) -> void @@ -990,7 +990,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_enumproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_enumproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_weakobjectproperty(const PusherParams& params) -> void @@ -1026,7 +1026,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_weakobjectproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_weakobjectproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_nameproperty(const PusherParams& params) -> void @@ -1056,7 +1056,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_nameproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_nameproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_textproperty(const PusherParams& params) -> void @@ -1086,7 +1086,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_textproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_textproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_strproperty(const PusherParams& params) -> void @@ -1129,7 +1129,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_strproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_strproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_softclassproperty(const PusherParams& params) -> void @@ -1159,7 +1159,7 @@ namespace RC::LuaType break; } - params.lua.throw_error(std::format("[push_softclassproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); + params.lua.throw_error(fmt::format("[push_softclassproperty] Unknown Operation ({}) not supported", static_cast(params.operation))); } auto push_interfaceproperty(const PusherParams& params) -> void @@ -1298,7 +1298,7 @@ No overload found for function 'IsA'. // We can either throw an error and kill the execution /**/ std::string property_type_name = to_string(property_type.ToString()); - lua.throw_error(std::format( + lua.throw_error(fmt::format( "[handle_unreal_property_value] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", property_type_name)); //*/ @@ -1423,7 +1423,7 @@ No overload found for function 'IsA'. // We can either throw an error and kill the execution /**/ std::string property_type_name = to_string(lua_object.m_type.ToString()); - lua.throw_error(std::format( + lua.throw_error(fmt::format( "[RemoteUnrealParam::prepare_to_handle] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", property_type_name)); //*/ diff --git a/UE4SS/src/LuaType/LuaUScriptStruct.cpp b/UE4SS/src/LuaType/LuaUScriptStruct.cpp index b0474fe7..14ee6cd4 100644 --- a/UE4SS/src/LuaType/LuaUScriptStruct.cpp +++ b/UE4SS/src/LuaType/LuaUScriptStruct.cpp @@ -169,7 +169,7 @@ namespace RC::LuaType auto property = static_cast(struct_data.script_struct->FindProperty(property_name)); if (!property) { - lua.throw_error(std::format("[handle_unreal_property_value]: Was unable to retrieve property '{}' mapped to '{}'", + lua.throw_error(fmt::format("[handle_unreal_property_value]: Was unable to retrieve property '{}' mapped to '{}'", to_string(property_name.ToString()), to_string(struct_data.script_struct->GetFullName()))); } @@ -187,7 +187,7 @@ namespace RC::LuaType else { std::string property_type_name = to_string(property_type_fname.ToString()); - lua.throw_error(std::format("Tried accessing unreal property without a registered handler (via StructProperty). Property type '{}' not supported.", + lua.throw_error(fmt::format("Tried accessing unreal property without a registered handler (via StructProperty). Property type '{}' not supported.", property_type_name)); } } diff --git a/UE4SS/src/Mod/CppUserModBase.cpp b/UE4SS/src/Mod/CppUserModBase.cpp index 8d93279d..ee8dd1a5 100644 --- a/UE4SS/src/Mod/CppUserModBase.cpp +++ b/UE4SS/src/Mod/CppUserModBase.cpp @@ -8,7 +8,7 @@ namespace RC { if (ModIntendedSDKVersion.empty()) { - ModIntendedSDKVersion = std::format(STR("{}.{}.{}"), UE4SS_LIB_VERSION_MAJOR, UE4SS_LIB_VERSION_MINOR, UE4SS_LIB_VERSION_HOTFIX); + ModIntendedSDKVersion = fmt::format(STR("{}.{}.{}"), UE4SS_LIB_VERSION_MAJOR, UE4SS_LIB_VERSION_MINOR, UE4SS_LIB_VERSION_HOTFIX); } } diff --git a/UE4SS/src/Mod/LuaMod.cpp b/UE4SS/src/Mod/LuaMod.cpp index b3bb5ed3..5fb4bf67 100644 --- a/UE4SS/src/Mod/LuaMod.cpp +++ b/UE4SS/src/Mod/LuaMod.cpp @@ -191,7 +191,7 @@ namespace RC } else { - lua_data.lua.throw_error(std::format( + lua_data.lua.throw_error(fmt::format( "[unreal_script_function_hook] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", to_string(property_type.ToString()))); } @@ -346,7 +346,7 @@ namespace RC } else { - lua_data.lua.throw_error(std::format( + lua_data.lua.throw_error(fmt::format( "[unreal_script_function_hook] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", to_string(property_type.ToString()))); } @@ -817,17 +817,17 @@ namespace RC lua_getfield(lua_state, -1, "path"); std::string current_paths = lua_tostring(lua_state, -1); - current_paths.append(std::format(";{}\\{}\\Scripts\\?.lua", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); - current_paths.append(std::format(";{}\\shared\\?.lua", to_string(m_program.get_mods_directory()).c_str())); - current_paths.append(std::format(";{}\\shared\\?\\?.lua", to_string(m_program.get_mods_directory()).c_str())); + current_paths.append(fmt::format(";{}\\{}\\Scripts\\?.lua", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); + current_paths.append(fmt::format(";{}\\shared\\?.lua", to_string(m_program.get_mods_directory()).c_str())); + current_paths.append(fmt::format(";{}\\shared\\?\\?.lua", to_string(m_program.get_mods_directory()).c_str())); lua_pop(lua_state, 1); lua_pushstring(lua_state, current_paths.c_str()); lua_setfield(lua_state, -2, "path"); lua_getfield(lua_state, -1, "cpath"); std::string current_cpaths = lua_tostring(lua_state, -1); - current_cpaths.append(std::format(";{}\\{}\\Scripts\\?.dll", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); - current_cpaths.append(std::format(";{}\\{}\\?.dll", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); + current_cpaths.append(fmt::format(";{}\\{}\\Scripts\\?.dll", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); + current_cpaths.append(fmt::format(";{}\\{}\\?.dll", to_string(m_program.get_mods_directory()).c_str(), to_string(get_name()))); lua_pop(lua_state, 1); lua_pushstring(lua_state, current_cpaths.c_str()); lua_setfield(lua_state, -2, "cpath"); @@ -1698,18 +1698,18 @@ No overload found for function 'RegisterCustomProperty'. if (second_field_name.empty()) { - error_field_names = std::format("{}", field_name); + error_field_names = fmt::format("{}", field_name); } else if (third_field_name.empty()) { - error_field_names = std::format("{}.{}", field_name, second_field_name); + error_field_names = fmt::format("{}.{}", field_name, second_field_name); } else { - error_field_names = std::format("{}.{}.{}", field_name, second_field_name, third_field_name); + error_field_names = fmt::format("{}.{}.{}", field_name, second_field_name, third_field_name); } - lua.throw_error(std::format( + lua.throw_error(fmt::format( "Parameter #1 for function 'RegisterCustomProperty'. The table value for key '{}' is outside the range of a 32-bit integer", error_field_names)); } @@ -1778,7 +1778,7 @@ No overload found for function 'RegisterCustomProperty'. Unreal::FProperty* oi_property = belongs_to_class->FindProperty(name); if (!oi_property) { - lua.throw_error(std::format("Was unable to find property '{}' in class '{}' for use for relative Offset_Internal", + lua.throw_error(fmt::format("Was unable to find property '{}' in class '{}' for use for relative Offset_Internal", oi_property_name, to_string(property_info.belongs_to_class))); } @@ -1788,14 +1788,14 @@ No overload found for function 'RegisterCustomProperty'. if (property_info.type.size == 0) { - lua.throw_error(std::format("The size for property '{}' was unknown. Custom sizes are unsupported but will likely be supported in the future.", + lua.throw_error(fmt::format("The size for property '{}' was unknown. Custom sizes are unsupported but will likely be supported in the future.", property_info.type.name)); } if (property_info.is_array_property && property_info.array_inner.size == 0) { lua.throw_error( - std::format("The size for inner property '{}' was unknown. Custom sizes are unsupported but will likely be supported in the future.", + fmt::format("The size for inner property '{}' was unknown. Custom sizes are unsupported but will likely be supported in the future.", property_info.array_inner.name)); } @@ -3042,10 +3042,10 @@ No overload found for function 'RegisterHook'. else { std::string error_message{"Was unable to register a hook with Lua function 'RegisterHook', information:\n"}; - error_message.append(std::format("UFunction::Func: {}\n", std::bit_cast(func_ptr))); - error_message.append(std::format("ProcessInternal: {}\n", Unreal::UObject::ProcessInternalInternal.get_function_address())); + error_message.append(fmt::format("UFunction::Func: {}\n", std::bit_cast(func_ptr))); + error_message.append(fmt::format("ProcessInternal: {}\n", Unreal::UObject::ProcessInternalInternal.get_function_address())); error_message.append( - std::format("FUNC_Native: {}\n", static_cast(unreal_function->HasAnyFunctionFlags(Unreal::EFunctionFlags::FUNC_Native)))); + fmt::format("FUNC_Native: {}\n", static_cast(unreal_function->HasAnyFunctionFlags(Unreal::EFunctionFlags::FUNC_Native)))); lua.throw_error(error_message); } @@ -3532,7 +3532,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } else { - lua.throw_error(std::format( + lua.throw_error(fmt::format( "[script_hook] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", to_string(param_type.ToString()))); } @@ -4017,7 +4017,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. // Lua from the in-game console. Unreal::Hook::RegisterProcessConsoleExecCallback([](Unreal::UObject* context, const TCHAR* cmd, Unreal::FOutputDevice& ar, Unreal::UObject* executor) -> bool { auto logln = [&ar](const File::StringType& log_message) { - Output::send(std::format(STR("{}\n"), log_message)); + Output::send(fmt::format(STR("{}\n"), log_message)); ar.Log(log_message.c_str()); }; @@ -4064,20 +4064,20 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. LuaLibrary::set_outputdevice_ref(*LuaStatics::console_executor, &ar); - // logln(std::format(STR("Executing '{}' as Lua"), cmd)); + // logln(fmt::format(STR("Executing '{}' as Lua"), cmd)); try { if (int status = luaL_loadstring(LuaStatics::console_executor->get_lua_state(), to_string(cmd).c_str()); status != LUA_OK) { LuaStatics::console_executor->throw_error( - std::format("luaL_loadstring returned {}", LuaStatics::console_executor->resolve_status_message(status, true))); + fmt::format("luaL_loadstring returned {}", LuaStatics::console_executor->resolve_status_message(status, true))); } if (int status = lua_pcall(LuaStatics::console_executor->get_lua_state(), 0, LUA_MULTRET, 0); status != LUA_OK) { LuaStatics::console_executor->throw_error( - std::format("lua_pcall returned {}", LuaStatics::console_executor->resolve_status_message(status, true))); + fmt::format("lua_pcall returned {}", LuaStatics::console_executor->resolve_status_message(status, true))); } } catch (std::runtime_error& e) diff --git a/UE4SS/src/ObjectDumper/ObjectToString.cpp b/UE4SS/src/ObjectDumper/ObjectToString.cpp index 22784d9e..86f838fa 100644 --- a/UE4SS/src/ObjectDumper/ObjectToString.cpp +++ b/UE4SS/src/ObjectDumper/ObjectToString.cpp @@ -60,9 +60,9 @@ namespace RC::ObjectDumper { UObject* p_typed_this = static_cast(p_this); - out_line.append(std::format(L"[{:016X}] ", reinterpret_cast(p_this))); + out_line.append(fmt::format(L"[{:016X}] ", reinterpret_cast(p_this))); out_line.append(p_typed_this->GetFullName()); - out_line.append(std::format(L" [n: {:X}] [c: {:016X}] [or: {:016X}]", + out_line.append(fmt::format(L" [n: {:X}] [c: {:016X}] [or: {:016X}]", p_typed_this->GetNamePrivate().GetComparisonIndex(), reinterpret_cast(p_typed_this->GetClassPrivate()), reinterpret_cast(p_typed_this->GetOuterPrivate()))); @@ -77,16 +77,16 @@ namespace RC::ObjectDumper { FProperty* p_typed_this = static_cast(p_this); - out_line.append(std::format(L"[{:016X}] ", reinterpret_cast(p_this))); + out_line.append(fmt::format(L"[{:016X}] ", reinterpret_cast(p_this))); out_line.append(p_typed_this->GetFullName()); - out_line.append(std::format(L" [o: {:X}] ", p_typed_this->GetOffset_Internal())); + out_line.append(fmt::format(L" [o: {:X}] ", p_typed_this->GetOffset_Internal())); auto property_class = p_typed_this->GetClass(); - out_line.append(std::format(L"[n: {:X}] [c: {:016X}]", p_typed_this->GetFName().GetComparisonIndex(), property_class.HashObject())); + out_line.append(fmt::format(L"[n: {:X}] [c: {:016X}]", p_typed_this->GetFName().GetComparisonIndex(), property_class.HashObject())); if (Version::IsAtLeast(4, 25)) { - out_line.append(std::format(L" [owr: {:016X}]", p_typed_this->GetOwnerVariant().HashObject())); + out_line.append(fmt::format(L" [owr: {:016X}]", p_typed_this->GetOwnerVariant().HashObject())); } } @@ -100,7 +100,7 @@ namespace RC::ObjectDumper property_trivial_dump_to_string(p_this, out_line); FArrayProperty* p_typed_this = static_cast(p_this); - out_line.append(std::format(L" [ai: {:016X}]", reinterpret_cast(p_typed_this->GetInner()))); + out_line.append(fmt::format(L" [ai: {:016X}]", reinterpret_cast(p_typed_this->GetInner()))); } auto arrayproperty_to_string_complex(void* p_this, std::wstring& out_line, ObjectToStringComplexDeclCallable callable) -> void @@ -139,7 +139,7 @@ namespace RC::ObjectDumper FMapProperty* typed_this = static_cast(p_this); FProperty* key_property = typed_this->GetKeyProp(); FProperty* value_property = typed_this->GetValueProp(); - out_line.append(std::format(L" [kp: {:016X}] [vp: {:016X}]", reinterpret_cast(key_property), reinterpret_cast(value_property))); + out_line.append(fmt::format(L" [kp: {:016X}] [vp: {:016X}]", reinterpret_cast(key_property), reinterpret_cast(value_property))); } auto mapproperty_to_string_complex(void* p_this, std::wstring& out_line, ObjectToStringComplexDeclCallable callable) -> void @@ -183,7 +183,7 @@ namespace RC::ObjectDumper property_trivial_dump_to_string(p_this, out_line); // mc = MetaClass - out_line.append(std::format(L" [mc: {:016X}]", reinterpret_cast(typed_this->GetMetaClass()))); + out_line.append(fmt::format(L" [mc: {:016X}]", reinterpret_cast(typed_this->GetMetaClass()))); } auto delegateproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -191,7 +191,7 @@ namespace RC::ObjectDumper property_trivial_dump_to_string(p_this, out_line); FDelegateProperty* p_typed_this = static_cast(p_this); - out_line.append(std::format(L" [df: {:016X}]", reinterpret_cast(p_typed_this->GetSignatureFunction()))); + out_line.append(fmt::format(L" [df: {:016X}]", reinterpret_cast(p_typed_this->GetSignatureFunction()))); } auto fieldpathproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -199,7 +199,7 @@ namespace RC::ObjectDumper FFieldPathProperty* typed_this = static_cast(p_this); property_trivial_dump_to_string(p_this, out_line); - out_line.append(std::format(L" [pc: {:016X}]", reinterpret_cast(typed_this->GetPropertyClass()))); + out_line.append(fmt::format(L" [pc: {:016X}]", reinterpret_cast(typed_this->GetPropertyClass()))); } auto interfaceproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -207,7 +207,7 @@ namespace RC::ObjectDumper FInterfaceProperty* typed_this = static_cast(p_this); property_trivial_dump_to_string(p_this, out_line); - out_line.append(std::format(L" [ic: {:016X}]", reinterpret_cast(typed_this->GetInterfaceClass()))); + out_line.append(fmt::format(L" [ic: {:016X}]", reinterpret_cast(typed_this->GetInterfaceClass()))); } auto multicastdelegateproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -215,7 +215,7 @@ namespace RC::ObjectDumper property_trivial_dump_to_string(p_this, out_line); FMulticastDelegateProperty* p_typed_this = static_cast(p_this); - out_line.append(std::format(L" [df: {:016X}]", reinterpret_cast(p_typed_this->GetSignatureFunction()))); + out_line.append(fmt::format(L" [df: {:016X}]", reinterpret_cast(p_typed_this->GetSignatureFunction()))); } auto objectproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -223,7 +223,7 @@ namespace RC::ObjectDumper FObjectProperty* typed_this = static_cast(p_this); property_trivial_dump_to_string(p_this, out_line); - out_line.append(std::format(L" [pc: {:016X}]", reinterpret_cast(typed_this->GetPropertyClass()))); + out_line.append(fmt::format(L" [pc: {:016X}]", reinterpret_cast(typed_this->GetPropertyClass()))); } auto structproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -231,7 +231,7 @@ namespace RC::ObjectDumper FStructProperty* typed_this = static_cast(p_this); property_trivial_dump_to_string(p_this, out_line); - out_line.append(std::format(L" [ss: {:016X}]", reinterpret_cast(typed_this->GetStruct()))); + out_line.append(fmt::format(L" [ss: {:016X}]", reinterpret_cast(typed_this->GetStruct()))); } auto enumproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -239,7 +239,7 @@ namespace RC::ObjectDumper property_trivial_dump_to_string(p_this, out_line); auto* typed_this = static_cast(p_this); - out_line.append(std::format(L" [em: {:016X}]", reinterpret_cast(typed_this->GetEnum()))); + out_line.append(fmt::format(L" [em: {:016X}]", reinterpret_cast(typed_this->GetEnum()))); } auto boolproperty_to_string(void* p_this, std::wstring& out_line) -> void @@ -249,7 +249,7 @@ namespace RC::ObjectDumper auto* typed_this = static_cast(p_this); if (typed_this->GetFieldMask() != 255) { - out_line.append(std::format(L" [fm: {:X}] [bm: {:X}]", typed_this->GetFieldMask(), typed_this->GetByteMask())); + out_line.append(fmt::format(L" [fm: {:X}] [bm: {:X}]", typed_this->GetFieldMask(), typed_this->GetByteMask())); } } @@ -261,7 +261,7 @@ namespace RC::ObjectDumper for (auto& Elem : typed_this->ForEachName()) { - out_line.append(std::format(L"\n[{:016X}] {} [n: {:X}] [v: {}]", 0, Elem.Key.ToString(), Elem.Key.GetComparisonIndex(), Elem.Value)); + out_line.append(fmt::format(L"\n[{:016X}] {} [n: {:X}] [v: {}]", 0, Elem.Key.ToString(), Elem.Key.GetComparisonIndex(), Elem.Value)); } } @@ -270,7 +270,7 @@ namespace RC::ObjectDumper UStruct* typed_this = static_cast(p_this); object_trivial_dump_to_string(p_this, out_line); - out_line.append(std::format(L" [sps: {:016X}]", reinterpret_cast(typed_this->GetSuperStruct()))); + out_line.append(fmt::format(L" [sps: {:016X}]", reinterpret_cast(typed_this->GetSuperStruct()))); } auto function_to_string(void* p_this, std::wstring& out_line) -> void diff --git a/UE4SS/src/SDKGenerator/Common.cpp b/UE4SS/src/SDKGenerator/Common.cpp index 3948dbf5..77439bb4 100644 --- a/UE4SS/src/SDKGenerator/Common.cpp +++ b/UE4SS/src/SDKGenerator/Common.cpp @@ -124,7 +124,7 @@ namespace RC::UEGenerator auto generate_delegate_name(FProperty* property, const File::StringType& context_name) -> File::StringType { const std::wstring property_name = sanitize_property_name(property->GetName()); - return std::format(STR("F{}{}"), context_name, property_name); + return fmt::format(STR("F{}{}"), context_name, property_name); } auto generate_property_cxx_name(FProperty* property, bool is_top_level_declaration, UObject* class_context, EnableForwardDeclarations enable_forward_declarations) @@ -142,7 +142,7 @@ namespace RC::UEGenerator { // Non-EnumClass enumerations should be wrapped into TEnumAsByte according to UHT const std::wstring enum_type_name = get_native_enum_name(enum_value); - return std::format(STR("TEnumAsByte<{}>"), enum_type_name); + return fmt::format(STR("TEnumAsByte<{}>"), enum_type_name); } return STR("uint8"); } @@ -228,7 +228,7 @@ namespace RC::UEGenerator meta_class_name = STR("class "); } meta_class_name.append(get_native_class_name(meta_class, false)); - return std::format(STR("TSubclassOf<{}>"), meta_class_name); + return fmt::format(STR("TSubclassOf<{}>"), meta_class_name); } if (auto* class_property = CastField(property); class_property) @@ -252,7 +252,7 @@ namespace RC::UEGenerator } const std::wstring meta_class_name = get_native_class_name(meta_class, false); - return std::format(STR("TSoftClassPtr<{}>"), meta_class_name); + return fmt::format(STR("TSoftClassPtr<{}>"), meta_class_name); } // Object Properties @@ -269,7 +269,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("{}*"), property_class_name); + return fmt::format(STR("{}*"), property_class_name); } if (auto* object_property = CastField(property); object_property) @@ -283,7 +283,7 @@ namespace RC::UEGenerator else { const auto property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TObjectPtr<{}>"), property_class_name); } } @@ -300,10 +300,10 @@ namespace RC::UEGenerator File::StringType property_class_name{}; if (enable_forward_declarations == EnableForwardDeclarations::Yes) { - property_class_name = std::format(STR("class ")); + property_class_name = fmt::format(STR("class ")); } property_class_name.append(get_native_class_name(property_class, false)); - return std::format(STR("TWeakObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TWeakObjectPtr<{}>"), property_class_name); } if (property->IsA()) @@ -322,7 +322,7 @@ namespace RC::UEGenerator property_class_name = STR("class "); } property_class_name.append(get_native_class_name(property_class, false)); - return std::format(STR("TLazyObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TLazyObjectPtr<{}>"), property_class_name); } if (property->IsA()) @@ -336,7 +336,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TSoftObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TSoftObjectPtr<{}>"), property_class_name); } // Interface Property @@ -356,7 +356,7 @@ namespace RC::UEGenerator interface_class_name = STR("class "); } interface_class_name.append(get_native_class_name(interface_class, true)); - return std::format(STR("TScriptInterface<{}>"), interface_class_name); + return fmt::format(STR("TScriptInterface<{}>"), interface_class_name); } // Struct Property @@ -406,7 +406,7 @@ namespace RC::UEGenerator { FFieldPathProperty* field_path_property = static_cast(property); const std::wstring property_class_name = field_path_property->GetPropertyClass()->GetName(); - return std::format(STR("TFieldPath"), property_class_name); + return fmt::format(STR("TFieldPath"), property_class_name); } // Collection and Map Properties @@ -425,7 +425,7 @@ namespace RC::UEGenerator } } inner_property_type.append(generate_property_cxx_name(inner_property, is_top_level_declaration, class_context)); - return std::format(STR("TArray<{}>"), inner_property_type); + return fmt::format(STR("TArray<{}>"), inner_property_type); } if (property->IsA()) @@ -434,7 +434,7 @@ namespace RC::UEGenerator FProperty* element_prop = set_property->GetElementProp(); const std::wstring element_property_type = generate_property_cxx_name(element_prop, is_top_level_declaration, class_context); - return std::format(STR("TSet<{}>"), element_property_type); + return fmt::format(STR("TSet<{}>"), element_property_type); } // TODO: This is missing support for freeze image map properties because XMapProperty is incomplete. (low priority) @@ -461,7 +461,7 @@ namespace RC::UEGenerator key_type.append(generate_property_cxx_name(key_property, is_top_level_declaration, class_context)); value_type.append(generate_property_cxx_name(value_property, is_top_level_declaration, class_context)); - return std::format(STR("TMap<{}, {}>"), key_type, value_type); + return fmt::format(STR("TMap<{}, {}>"), key_type, value_type); } // Standard properties that do not have any special attributes @@ -494,7 +494,7 @@ namespace RC::UEGenerator { // Non-EnumClass enumerations should be wrapped into TEnumAsByte according to UHT const std::wstring enum_type_name = get_native_enum_name(enum_value); - return std::format(STR("{}"), enum_type_name); + return fmt::format(STR("{}"), enum_type_name); } return STR("uint8"); } @@ -572,7 +572,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("{}"), property_class_name); + return fmt::format(STR("{}"), property_class_name); } if (auto* object_property = CastField(property); object_property) @@ -586,7 +586,7 @@ namespace RC::UEGenerator else { const auto property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TObjectPtr<{}>"), property_class_name); } } @@ -602,7 +602,7 @@ namespace RC::UEGenerator File::StringType property_class_name{}; property_class_name.append(get_native_class_name(property_class, false)); - return std::format(STR("TWeakObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TWeakObjectPtr<{}>"), property_class_name); } if (field_class_name == STR("LazyObjectProperty")) @@ -617,7 +617,7 @@ namespace RC::UEGenerator File::StringType property_class_name{}; property_class_name.append(get_native_class_name(property_class, false)); - return std::format(STR("TLazyObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TLazyObjectPtr<{}>"), property_class_name); } if (field_class_name == STR("SoftObjectProperty")) @@ -631,7 +631,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TSoftObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TSoftObjectPtr<{}>"), property_class_name); } // Class Properties @@ -647,7 +647,7 @@ namespace RC::UEGenerator File::StringType meta_class_name{}; meta_class_name.append(get_native_class_name(meta_class, false)); - return std::format(STR("TSubclassOf<{}>"), meta_class_name); + return fmt::format(STR("TSubclassOf<{}>"), meta_class_name); } if (auto* class_property = CastField(property); class_property) @@ -667,7 +667,7 @@ namespace RC::UEGenerator } const std::wstring meta_class_name = get_native_class_name(meta_class, false); - return std::format(STR("TSoftClassPtr<{}>"), meta_class_name); + return fmt::format(STR("TSoftClassPtr<{}>"), meta_class_name); } // Interface Property @@ -683,7 +683,7 @@ namespace RC::UEGenerator File::StringType interface_class_name{}; interface_class_name.append(get_native_class_name(interface_class, true)); - return std::format(STR("TScriptInterface<{}>"), interface_class_name); + return fmt::format(STR("TScriptInterface<{}>"), interface_class_name); } // Struct Property @@ -733,7 +733,7 @@ namespace RC::UEGenerator { FFieldPathProperty* field_path_property = static_cast(property); const std::wstring property_class_name = field_path_property->GetPropertyClass()->GetName(); - return std::format(STR("TFieldPath"), property_class_name); + return fmt::format(STR("TFieldPath"), property_class_name); } // Collection and Map Properties @@ -745,7 +745,7 @@ namespace RC::UEGenerator File::StringType inner_property_type{}; inner_property_type.append(generate_property_lua_name(inner_property, is_top_level_declaration, class_context)); - return std::format(STR("TArray<{}>"), inner_property_type); + return fmt::format(STR("TArray<{}>"), inner_property_type); } if (field_class_name == STR("SetProperty")) @@ -754,7 +754,7 @@ namespace RC::UEGenerator FProperty* element_prop = set_property->GetElementProp(); const std::wstring element_property_type = generate_property_lua_name(element_prop, is_top_level_declaration, class_context); - return std::format(STR("TSet<{}>"), element_property_type); + return fmt::format(STR("TSet<{}>"), element_property_type); } // TODO: This is missing support for freeze image map properties because XMapProperty is incomplete. (low priority) @@ -769,7 +769,7 @@ namespace RC::UEGenerator key_type.append(generate_property_lua_name(key_property, is_top_level_declaration, class_context)); value_type.append(generate_property_lua_name(value_property, is_top_level_declaration, class_context)); - return std::format(STR("TMap<{}, {}>"), key_type, value_type); + return fmt::format(STR("TMap<{}, {}>"), key_type, value_type); } // Standard properties that do not have any special attributes diff --git a/UE4SS/src/SDKGenerator/Generator.cpp b/UE4SS/src/SDKGenerator/Generator.cpp index 6980cd16..cb3b5d11 100644 --- a/UE4SS/src/SDKGenerator/Generator.cpp +++ b/UE4SS/src/SDKGenerator/Generator.cpp @@ -269,7 +269,7 @@ namespace RC::UEGenerator { if (UE4SSProgram::settings_manager.CXXHeaderGenerator.DumpOffsetsAndSizes) { - return std::format(STR("{:85} // 0x{:04X} (size: 0x{:X})"), line, property->GetOffset_Internal(), property->GetSize()); + return fmt::format(STR("{:85} // 0x{:04X} (size: 0x{:X})"), line, property->GetOffset_Internal(), property->GetSize()); } else { @@ -549,7 +549,7 @@ namespace RC::UEGenerator { // File name collision auto& file_name = m_file_names[package_name_all_lower]; - package_name.append(std::format(STR("_DUPL_{}"), ++file_name.num_collisions)); + package_name.append(fmt::format(STR("_DUPL_{}"), ++file_name.num_collisions)); Output::send(STR("File name collision, renamed to '{}'\n"), package_name); } else @@ -674,36 +674,36 @@ namespace RC::UEGenerator auto generate_file_header(GeneratedFile& generated_file) -> void { generated_file.primary_file.write_string_to_file( - std::format(STR("#ifndef UE4SS_SDK_{}_HPP\n#define UE4SS_SDK_{}_HPP\n\n"), generated_file.package_name, generated_file.package_name)); + fmt::format(STR("#ifndef UE4SS_SDK_{}_HPP\n#define UE4SS_SDK_{}_HPP\n\n"), generated_file.package_name, generated_file.package_name)); if (!generated_file.secondary_file_has_no_contents) { - generated_file.primary_file.write_string_to_file(std::format(STR("#include \"{}\"\n\n"), generated_file.secondary_file_name.filename().c_str())); + generated_file.primary_file.write_string_to_file(fmt::format(STR("#include \"{}\"\n\n"), generated_file.secondary_file_name.filename().c_str())); } } auto generate_file_footer(GeneratedFile& generated_file) -> void { - generated_file.primary_file.write_string_to_file(std::format(STR("#endif\n"))); + generated_file.primary_file.write_string_to_file(fmt::format(STR("#endif\n"))); } auto generate_enum_declaration(File::StringType& content_buffer, UEnum* uenum) -> void { const auto cpp_form = uenum->GetCppForm(); if (cpp_form == UEnum::ECppForm::Regular) { - content_buffer.append(std::format(STR("enum {} {{\n"), get_native_enum_name(uenum, false))); + content_buffer.append(fmt::format(STR("enum {} {{\n"), get_native_enum_name(uenum, false))); } else if (cpp_form == UEnum::ECppForm::Namespaced) { - content_buffer.append(std::format(STR("namespace {} {{\n{}enum Type {{\n"), get_native_enum_name(uenum, false), generate_tab())); + content_buffer.append(fmt::format(STR("namespace {} {{\n{}enum Type {{\n"), get_native_enum_name(uenum, false), generate_tab())); } else if (cpp_form == UEnum::ECppForm::EnumClass) { - content_buffer.append(std::format(STR("enum class {} {{\n"), get_native_enum_name(uenum, false))); + content_buffer.append(fmt::format(STR("enum class {} {{\n"), get_native_enum_name(uenum, false))); } } auto generate_enum_member(File::StringType& content_buffer, UEnum* uenum, const File::StringType& enum_value_name, const Unreal::FEnumNamePair& elem) -> void { - content_buffer.append(std::format(STR("{}{}{} = {},\n"), + content_buffer.append(fmt::format(STR("{}{}{} = {},\n"), generate_tab(), uenum->GetCppForm() == UEnum::ECppForm::Namespaced ? generate_tab() : STR(""), enum_value_name, @@ -712,7 +712,7 @@ namespace RC::UEGenerator auto generate_enum_end(File::StringType& content_buffer, UEnum* uenum) -> void { const auto cpp_form = uenum->GetCppForm(); - content_buffer.append(std::format(STR("{}}};"), cpp_form == UEnum::ECppForm::Namespaced ? generate_tab() : STR(""))); + content_buffer.append(fmt::format(STR("{}}};"), cpp_form == UEnum::ECppForm::Namespaced ? generate_tab() : STR(""))); if (cpp_form == UEnum::ECppForm::Namespaced) { @@ -775,7 +775,7 @@ namespace RC::UEGenerator StringType part_one{}; try { - part_one = std::format(STR("{}{}{} {};"), + part_one = fmt::format(STR("{}{}{} {};"), generate_tab(), property_info.should_forward_declare ? STR("class ") : STR(""), generate_property_cxx_name(property, true, native_class, EnableForwardDeclarations::Yes), @@ -787,7 +787,7 @@ namespace RC::UEGenerator continue; } - content_buffer.append(std::format(STR("{}\n"), generator->generate_offset_comment(property, part_one))); + content_buffer.append(fmt::format(STR("{}\n"), generator->generate_offset_comment(property, part_one))); if (property->IsA()) { @@ -839,12 +839,12 @@ namespace RC::UEGenerator int32_t padding_property_offset = current_property_end_location; int32_t padding_property_size = next_property_offset - padding_property_offset; - auto padding_part_one = std::format(STR("{}char {}[0x{:X}];"), + auto padding_part_one = fmt::format(STR("{}char {}[0x{:X}];"), generate_tab(), - std::format(STR("padding_{}"), num_padding_elements++), + fmt::format(STR("padding_{}"), num_padding_elements++), padding_property_size); content_buffer.append( - std::format(STR("{:85} // 0x{:04X} (size: 0x{:X})\n"), padding_part_one, padding_property_offset, padding_property_size)); + fmt::format(STR("{:85} // 0x{:04X} (size: 0x{:X})\n"), padding_part_one, padding_property_offset, padding_property_size)); } } } @@ -878,11 +878,11 @@ namespace RC::UEGenerator if (inherits_from_class) { content_buffer.append( - std::format(STR("{} {} : public {}\n{{\n"), generate_prefix(native_class), class_name, generate_class_name(inherits_from_class))); + fmt::format(STR("{} {} : public {}\n{{\n"), generate_prefix(native_class), class_name, generate_class_name(inherits_from_class))); } else { - content_buffer.append(std::format(STR("{} {}\n{{\n"), generate_prefix(native_class), class_name)); + content_buffer.append(fmt::format(STR("{} {}\n{{\n"), generate_prefix(native_class), class_name)); } } auto generate_class_struct_end(File::StringType& content_buffer, @@ -912,8 +912,8 @@ namespace RC::UEGenerator printf_s("last_property_offset: %X\n", last_property_offset); printf_s("first_property_offset: %X\n", first_property_offset); - auto padding_part_one = std::format(STR("{}char {}[0x{:X}];"), generate_tab(), std::format(STR("padding_{}"), num_padding_elements), padding_size); - out.append(std::format(STR("{:85} // 0x{:04X} (size: 0x{:X})\n"), padding_part_one, last_property_offset + last_property_size, padding_size)); + auto padding_part_one = fmt::format(STR("{}char {}[0x{:X}];"), generate_tab(), fmt::format(STR("padding_{}"), num_padding_elements), padding_size); + out.append(fmt::format(STR("{:85} // 0x{:04X} (size: 0x{:X})\n"), padding_part_one, last_property_offset + last_property_size, padding_size)); } } //*/ @@ -923,8 +923,8 @@ namespace RC::UEGenerator // No reflected member variables exist but there are non-reflected member variables // Add padding for non-reflected member variables, for alignment purposes auto padding_part_one = - std::format(STR("{}char {}[0x{:X}];"), generate_tab(), std::format(STR("padding_{}"), num_padding_elements), class_size); - content_buffer.append(std::format(STR("{:85} // 0x0000 (size: 0x{:X})\n"), padding_part_one, 0x0)); + fmt::format(STR("{}char {}[0x{:X}];"), generate_tab(), fmt::format(STR("padding_{}"), num_padding_elements), class_size); + content_buffer.append(fmt::format(STR("{:85} // 0x0000 (size: 0x{:X})\n"), padding_part_one, 0x0)); } } } @@ -932,7 +932,7 @@ namespace RC::UEGenerator { if (UE4SSProgram::settings_manager.CXXHeaderGenerator.DumpOffsetsAndSizes) { - content_buffer.append(std::format(STR("}}; // Size: 0x{:X}"), class_size)); + content_buffer.append(fmt::format(STR("}}; // Size: 0x{:X}"), class_size)); } else { @@ -973,7 +973,7 @@ namespace RC::UEGenerator function_type_name = STR("void"); } - current_class_content.append(std::format(STR("{}{} {}("), generate_tab(), function_type_name, function_name)); + current_class_content.append(fmt::format(STR("{}{} {}("), generate_tab(), function_type_name, function_name)); for (size_t i = 0; i < function_info.params.size(); ++i) { @@ -983,7 +983,7 @@ namespace RC::UEGenerator try { current_class_content.append( - std::format(STR("{}{}{}{} {}"), + fmt::format(STR("{}{}{}{} {}"), param_info.property->HasAnyPropertyFlags(Unreal::CPF_ConstParm) ? STR("const ") : STR(""), param_info.should_forward_declare ? STR("class ") : STR(""), generate_property_cxx_name(param_info.property, true, function_info.function, EnableForwardDeclarations::Yes), @@ -1091,11 +1091,11 @@ namespace RC::UEGenerator auto generate_enum_declaration(File::StringType& content_buffer, UEnum* uenum) -> void { auto enum_name = uenum->GetName(); - content_buffer.append(std::format(STR("---@enum {}\n{} = {{\n"), enum_name, enum_name)); + content_buffer.append(fmt::format(STR("---@enum {}\n{} = {{\n"), enum_name, enum_name)); } auto generate_enum_member(File::StringType& content_buffer, UEnum* uenum, const File::StringType& enum_value_name, const Unreal::FEnumNamePair& elem) -> void { - content_buffer.append(std::format(STR("{}{} = {},\n"), generate_tab(), enum_value_name, elem.Value)); + content_buffer.append(fmt::format(STR("{}{} = {},\n"), generate_tab(), enum_value_name, elem.Value)); } auto generate_enum_end(File::StringType& content_buffer, UEnum* uenum) -> void { @@ -1161,12 +1161,12 @@ namespace RC::UEGenerator const auto& property_name = property->GetName(); if (is_valid_lua_symbol(property_name)) { - content_buffer.append(std::format(STR("---@field {} {}\n"), property_name, generate_property_lua_name(property, true, native_class))); + content_buffer.append(fmt::format(STR("---@field {} {}\n"), property_name, generate_property_lua_name(property, true, native_class))); } else { content_buffer.append( - std::format(STR("---@field [{}] {}\n"), quote_lua_symbol(property_name), generate_property_lua_name(property, true, native_class))); + fmt::format(STR("---@field [{}] {}\n"), quote_lua_symbol(property_name), generate_property_lua_name(property, true, native_class))); } } catch (std::exception& e) @@ -1204,11 +1204,11 @@ namespace RC::UEGenerator auto class_name = generate_class_name(native_class); if (inherits_from_class) { - content_buffer.append(std::format(STR("---@class {} : {}\n"), class_name, generate_class_name(inherits_from_class))); + content_buffer.append(fmt::format(STR("---@class {} : {}\n"), class_name, generate_class_name(inherits_from_class))); } else { - content_buffer.append(std::format(STR("---@class {}\n"), class_name)); + content_buffer.append(fmt::format(STR("---@class {}\n"), class_name)); } } auto generate_class_struct_end(File::StringType& content_buffer, @@ -1217,7 +1217,7 @@ namespace RC::UEGenerator int32_t num_padding_elements, XProperty* last_property_in_this_class) -> void { - content_buffer.append(std::format(STR("{} = {{}}\n"), class_name)); + content_buffer.append(fmt::format(STR("{} = {{}}\n"), class_name)); } auto generate_class_end(File::StringType& content_buffer, size_t class_size) -> void { @@ -1240,7 +1240,7 @@ namespace RC::UEGenerator { auto param_name = param_info.property->GetName(); // TODO disambiguate param renames - current_class_content.append(std::format(STR("---@param {} {}\n"), + current_class_content.append(fmt::format(STR("---@param {} {}\n"), make_valid_symbol(param_name), generate_property_lua_name(param_info.property, true, function_info.function))); } @@ -1258,7 +1258,7 @@ namespace RC::UEGenerator { try { - current_class_content.append(std::format(STR("---@return {}\n"), generate_property_lua_name(return_property, true, function_info.function))); + current_class_content.append(fmt::format(STR("---@return {}\n"), generate_property_lua_name(return_property, true, function_info.function))); } catch (std::exception& e) { @@ -1273,11 +1273,11 @@ namespace RC::UEGenerator if (is_valid_lua_symbol(function_name)) { - current_class_content.append(std::format(STR("function {}:{}("), class_name, function_name)); + current_class_content.append(fmt::format(STR("function {}:{}("), class_name, function_name)); } else { - current_class_content.append(std::format(STR("{}[{}] = function("), class_name, quote_lua_symbol(function_name))); + current_class_content.append(fmt::format(STR("{}[{}] = function("), class_name, quote_lua_symbol(function_name))); } for (size_t i = 0; i < function_info.params.size(); ++i) @@ -1287,7 +1287,7 @@ namespace RC::UEGenerator { auto param_name = param_info.property->GetName(); // TODO disambiguate param renames - current_class_content.append(std::format(STR("{}"), make_valid_symbol(param_name))); + current_class_content.append(fmt::format(STR("{}"), make_valid_symbol(param_name))); if (i + 1 < function_info.params.size()) { diff --git a/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp b/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp index ab08e03f..c5ebb9e7 100644 --- a/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp +++ b/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp @@ -248,16 +248,16 @@ namespace RC::UEGenerator auto UEHeaderGenerator::generate_module_build_file(const std::wstring& module_name) -> void { - const FFilePath module_file_path = m_root_directory / module_name / std::format(STR("{}.Build.cs"), module_name); + const FFilePath module_file_path = m_root_directory / module_name / fmt::format(STR("{}.Build.cs"), module_name); GeneratedFile module_build_file = GeneratedFile(module_file_path); module_build_file.append_line(STR("using UnrealBuildTool;")); module_build_file.append_line(STR("")); - module_build_file.append_line(std::format(STR("public class {} : ModuleRules {{"), module_name)); + module_build_file.append_line(fmt::format(STR("public class {} : ModuleRules {{"), module_name)); module_build_file.begin_indent_level(); - module_build_file.append_line(std::format(STR("public {}(ReadOnlyTargetRules Target) : base(Target) {{"), module_name)); + module_build_file.append_line(fmt::format(STR("public {}(ReadOnlyTargetRules Target) : base(Target) {{"), module_name)); module_build_file.begin_indent_level(); module_build_file.append_line(STR("PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;")); @@ -280,7 +280,7 @@ namespace RC::UEGenerator for (const std::wstring& other_module_name : all_module_dependencies) { - module_build_file.append_line(std::format(STR("\"{}\","), other_module_name)); + module_build_file.append_line(fmt::format(STR("\"{}\","), other_module_name)); } module_build_file.end_indent_level(); @@ -297,18 +297,18 @@ namespace RC::UEGenerator auto UEHeaderGenerator::generate_module_implementation_file(const std::wstring& module_name) -> void { - const FFilePath module_file_path = m_root_directory / module_name / STR("Private") / std::format(STR("{}Module.cpp"), module_name); + const FFilePath module_file_path = m_root_directory / module_name / STR("Private") / fmt::format(STR("{}Module.cpp"), module_name); GeneratedFile module_impl_file = GeneratedFile(module_file_path); module_impl_file.append_line(STR("#include \"Modules/ModuleManager.h\"")); module_impl_file.append_line(STR("")); if (module_name != m_primary_module_name) { - module_impl_file.append_line(std::format(STR("IMPLEMENT_MODULE(FDefaultGameModuleImpl, {});"), module_name)); + module_impl_file.append_line(fmt::format(STR("IMPLEMENT_MODULE(FDefaultGameModuleImpl, {});"), module_name)); } else { - module_impl_file.append_line(std::format(STR("IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, {}, {});"), module_name, module_name)); + module_impl_file.append_line(fmt::format(STR("IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, {}, {});"), module_name, module_name)); } module_impl_file.serialize_file_content_to_disk(); @@ -332,8 +332,8 @@ namespace RC::UEGenerator std::wstring parent_interface_class_name = get_native_class_name(super_class); // Generate interface UCLASS declaration - header_data.append_line(std::format(STR("UINTERFACE({})"), interface_flags_string)); - header_data.append_line(std::format(STR("class {}{} : public {} {{"), maybe_api_name, interface_class_native_name, parent_interface_class_name)); + header_data.append_line(fmt::format(STR("UINTERFACE({})"), interface_flags_string)); + header_data.append_line(fmt::format(STR("class {}{} : public {} {{"), maybe_api_name, interface_class_native_name, parent_interface_class_name)); header_data.begin_indent_level(); header_data.append_line(STR("GENERATED_BODY()")); @@ -346,7 +346,7 @@ namespace RC::UEGenerator const std::wstring interface_native_name = get_native_class_name(uclass, true); const std::wstring parent_interface_name = get_native_class_name(super_class, true); - header_data.append_line(std::format(STR("class {}{} : public {} {{"), maybe_api_name, interface_native_name, parent_interface_name)); + header_data.append_line(fmt::format(STR("class {}{} : public {} {{"), maybe_api_name, interface_native_name, parent_interface_name)); header_data.begin_indent_level(); header_data.append_line(STR("GENERATED_BODY()")); @@ -423,8 +423,8 @@ namespace RC::UEGenerator interface_list_string.append(interface_name); } - header_data.append_line(std::format(STR("UCLASS({})"), class_flags_string)); - header_data.append_line(std::format(STR("class {}{} : public {}{} {{"), maybe_api_name, class_native_name, parent_class_name, interface_list_string)); + header_data.append_line(fmt::format(STR("UCLASS({})"), class_flags_string)); + header_data.append_line(fmt::format(STR("class {}{} : public {}{} {{"), maybe_api_name, class_native_name, parent_class_name, interface_list_string)); header_data.begin_indent_level(); header_data.append_line(STR("GENERATED_BODY()")); @@ -476,7 +476,7 @@ namespace RC::UEGenerator { constructor_string.append(STR("const FObjectInitializer& ObjectInitializer")); } - header_data.append_line(std::format(STR("{}({});"), class_native_name, constructor_string)); + header_data.append_line(fmt::format(STR("{}({});"), class_native_name, constructor_string)); header_data.append_line_no_indent(STR("")); // Generate GetLifetimeReplicatedProps override if we have encountered replicated properties @@ -538,11 +538,11 @@ namespace RC::UEGenerator header_data.add_dependency_object(super_struct, DependencyLevel::Include); const std::wstring super_struct_native_name = get_native_struct_name(super_struct); - parent_struct_declaration.append(std::format(STR(" : public {}"), super_struct_native_name)); + parent_struct_declaration.append(fmt::format(STR(" : public {}"), super_struct_native_name)); } - header_data.append_line(std::format(STR("USTRUCT({})"), struct_flags_string)); - header_data.append_line(std::format(STR("struct {}{}{} {{"), is_struct_exported ? api_macro_name : STR(""), struct_native_name, parent_struct_declaration)); + header_data.append_line(fmt::format(STR("USTRUCT({})"), struct_flags_string)); + header_data.append_line(fmt::format(STR("struct {}{}{} {{"), is_struct_exported ? api_macro_name : STR(""), struct_native_name, parent_struct_declaration)); header_data.begin_indent_level(); header_data.append_line(STR("GENERATED_BODY()")); @@ -568,7 +568,7 @@ namespace RC::UEGenerator // Generate constructor and make sure it's public append_access_modifier(header_data, AccessModifier::Public, current_access_modifier); - header_data.append_line(std::format(STR("{}{}();"), !is_struct_exported ? api_macro_name : STR(""), struct_native_name)); + header_data.append_line(fmt::format(STR("{}{}();"), !is_struct_exported ? api_macro_name : STR(""), struct_native_name)); header_data.end_indent_level(); header_data.append_line(STR("};")); @@ -585,17 +585,17 @@ namespace RC::UEGenerator UEnum::ECppForm cpp_form = uenum->GetCppForm(); bool enum_is_uint8{false}; - header_data.append_line(std::format(STR("UENUM({})"), enum_flags_string)); + header_data.append_line(fmt::format(STR("UENUM({})"), enum_flags_string)); if (cpp_form == UEnum::ECppForm::Namespaced) { - header_data.append_line(std::format(STR("namespace {} {{"), native_enum_name)); + header_data.append_line(fmt::format(STR("namespace {} {{"), native_enum_name)); header_data.begin_indent_level(); header_data.append_line(STR("enum Type {")); } else if (cpp_form == UEnum::ECppForm::Regular) { - header_data.append_line(std::format(STR("enum {} {{"), native_enum_name)); + header_data.append_line(fmt::format(STR("enum {} {{"), native_enum_name)); } else if (cpp_form == UEnum::ECppForm::EnumClass) { @@ -603,20 +603,20 @@ namespace RC::UEGenerator { if (UE4SSProgram::settings_manager.UHTHeaderGenerator.MakeEnumClassesBlueprintType && can_use_uint8_override) { - header_data.append_line(std::format(STR("enum class {} : uint8 {{"), native_enum_name)); + header_data.append_line(fmt::format(STR("enum class {} : uint8 {{"), native_enum_name)); enum_is_uint8 = true; } else { // Enum has never been used in any native classes or structures, go with implicit type - header_data.append_line(std::format(STR("enum class {} {{"), native_enum_name)); + header_data.append_line(fmt::format(STR("enum class {} {{"), native_enum_name)); } } else { std::wstring underlying_type_string = underlying_type->second; - header_data.append_line(std::format(STR("enum class {} : {} {{"), native_enum_name, underlying_type_string)); + header_data.append_line(fmt::format(STR("enum class {} : {} {{"), native_enum_name, underlying_type_string)); } } @@ -647,13 +647,13 @@ namespace RC::UEGenerator StringType first_name_with_value = uenum->GetNameByValue(Value).ToString(); if (first_name_with_value != Name.ToString()) { - result_enumeration_line.append(std::format(STR(" = {}"), sanitize_enumeration_name(first_name_with_value))); + result_enumeration_line.append(fmt::format(STR(" = {}"), sanitize_enumeration_name(first_name_with_value))); } else if (Value != expected_next_enum_value || last_value_was_negative_one) { const StringType CastString = (enum_is_uint8 && Value < 0) ? STR("(uint8)") : STR(""); const StringType MinusSign = Value < 0 ? STR("-") : STR(""); - result_enumeration_line.append(std::format(STR(" = {}{}{}"), CastString, MinusSign, std::abs(Value))); + result_enumeration_line.append(fmt::format(STR(" = {}{}{}"), CastString, MinusSign, std::abs(Value))); } expected_next_enum_value = Value + 1; last_value_was_negative_one = (Value == -1); @@ -662,7 +662,7 @@ namespace RC::UEGenerator std::transform(pre_append_result_line_lower.begin(), pre_append_result_line_lower.end(), pre_append_result_line_lower.begin(), ::towlower); if (pre_append_result_line_lower.ends_with(STR("_max"))) { - const StringType expected_full_constant_name = std::format(STR("{}_MAX"), enum_prefix); + const StringType expected_full_constant_name = fmt::format(STR("{}_MAX"), enum_prefix); StringType expected_full_constant_name_lower = expected_full_constant_name; std::transform(expected_full_constant_name_lower.begin(), expected_full_constant_name_lower.end(), expected_full_constant_name_lower.begin(), ::towlower); @@ -751,7 +751,7 @@ namespace RC::UEGenerator return_value_declaration.append(STR(", ")); } - std::wstring delegate_declaration_string = std::format(STR("{}DECLARE_DYNAMIC{}{}_DELEGATE{}{}{}({}{}{}{});"), + std::wstring delegate_declaration_string = fmt::format(STR("{}DECLARE_DYNAMIC{}{}_DELEGATE{}{}{}({}{}{}{});"), delegate_macro_string, is_multicast ? STR("_MULTICAST") : STR(""), is_sparse ? STR("_SPARSE") : STR(""), @@ -761,7 +761,7 @@ namespace RC::UEGenerator return_value_declaration, delegate_type_name, // TODO: Actually get delegate property name. - is_sparse ? std::format(STR("{}, {}"), owning_class, STR("EnterPropertyName")) : STR(""), + is_sparse ? fmt::format(STR("{}, {}"), owning_class, STR("EnterPropertyName")) : STR(""), delegate_parameter_list); header_data.append_line(delegate_declaration_string); @@ -784,17 +784,17 @@ namespace RC::UEGenerator if (uclass->IsChildOf() || uclass->IsChildOf()) { constructor_content_string.append(STR("const FObjectInitializer& ObjectInitializer")); - constructor_postfix_string.append(std::format(STR(") : Super(ObjectInitializer{}"), object_initializer_overrides)); + constructor_postfix_string.append(fmt::format(STR(") : Super(ObjectInitializer{}"), object_initializer_overrides)); } // If parent class contains the UObjectInitializer constructor without default value, // we need to create the explicit call to such constructor and pass UObjectInitializer::Get() as the argument. else if (m_classes_with_object_initializer.contains(native_parent_class_name)) { - constructor_postfix_string.append(std::format(STR(") : {}(FObjectInitializer::Get()"), native_parent_class_name)); + constructor_postfix_string.append(fmt::format(STR(") : {}(FObjectInitializer::Get()"), native_parent_class_name)); } implementation_file.m_implementation_constructor.append( - std::format(STR("{}::{}({}{}"), class_native_name, class_native_name, constructor_content_string, constructor_postfix_string)); + fmt::format(STR("{}::{}({}{}"), class_native_name, class_native_name, constructor_content_string, constructor_postfix_string)); implementation_file.begin_indent_level(); @@ -859,7 +859,7 @@ namespace RC::UEGenerator implementation_file.add_extra_include(STR("Net/UnrealNetwork.h")); implementation_file.append_line( - std::format(STR("void {}::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const {{"), class_native_name)); + fmt::format(STR("void {}::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const {{"), class_native_name)); implementation_file.begin_indent_level(); implementation_file.append_line(STR("Super::GetLifetimeReplicatedProps(OutLifetimeProps);")); @@ -869,7 +869,7 @@ namespace RC::UEGenerator { if ((property->GetPropertyFlags() & CPF_Net) != 0) { - implementation_file.append_line(std::format(STR("DOREPLIFETIME({}, {});"), class_native_name, property->GetName())); + implementation_file.append_line(fmt::format(STR("DOREPLIFETIME({}, {});"), class_native_name, property->GetName())); } } @@ -884,7 +884,7 @@ namespace RC::UEGenerator const std::wstring struct_native_name = get_native_struct_name(script_struct); // Generate constructor implementation and initialize properties inside - implementation_file.m_implementation_constructor.append(std::format(STR("{}::{}() {{"), struct_native_name, struct_native_name)); + implementation_file.m_implementation_constructor.append(fmt::format(STR("{}::{}() {{"), struct_native_name, struct_native_name)); implementation_file.begin_indent_level(); // Generate properties @@ -928,9 +928,9 @@ namespace RC::UEGenerator if (!type_is_valid) { Output::send(STR("Warning: {}\n"), error_string); - header_data.append_line(std::format(STR("// UPROPERTY({})"), property_flags_string)); - header_data.append_line(std::format(STR("// Missed Property: {}"), property->GetName())); - header_data.append_line(std::format(STR("// {}"), error_string)); + header_data.append_line(fmt::format(STR("// UPROPERTY({})"), property_flags_string)); + header_data.append_line(fmt::format(STR("// Missed Property: {}"), property->GetName())); + header_data.append_line(fmt::format(STR("// {}"), error_string)); header_data.append_line(STR("")); return; } @@ -947,8 +947,8 @@ namespace RC::UEGenerator property_extra_declaration.append(STR(": 1")); } - header_data.append_line(std::format(STR("UPROPERTY({})"), property_flags_string)); - header_data.append_line(std::format(STR("{} {}{};"), property_type_string, property->GetName(), property_extra_declaration)); + header_data.append_line(fmt::format(STR("UPROPERTY({})"), property_flags_string)); + header_data.append_line(fmt::format(STR("{} {}{};"), property_type_string, property->GetName(), property_extra_declaration)); header_data.append_line(STR("")); } @@ -1001,23 +1001,23 @@ namespace RC::UEGenerator if (return_property != NULL) { const std::wstring default_property_value = generate_default_property_value(return_property, header_data, context_name); - return_statement_string = std::format(STR(" return {};"), default_property_value); + return_statement_string = fmt::format(STR(" return {};"), default_property_value); } if (generate_as_override) { function_extra_postfix_string.append(STR(" override")); } - function_extra_postfix_string.append(std::format(STR(" PURE_VIRTUAL({},{})"), function->GetName(), return_statement_string)); + function_extra_postfix_string.append(fmt::format(STR(" PURE_VIRTUAL({},{})"), function->GetName(), return_statement_string)); } std::wstring function_argument_list = generate_function_parameter_list(uclass, function, header_data, false, context_name, blacklisted_property_names); const std::wstring function_flags_string = generate_function_flags(function, is_function_pure_virtual); - header_data.append_line(std::format(STR("UFUNCTION({})"), function_flags_string)); + header_data.append_line(fmt::format(STR("UFUNCTION({})"), function_flags_string)); // Format for virtual functions // virtual () PURE_VIRTUAL(, ) - header_data.append_line(std::format(STR("{}{} {}({}){};"), + header_data.append_line(fmt::format(STR("{}{} {}({}){};"), function_modifier_string, return_property_string, function->GetName(), @@ -1044,7 +1044,7 @@ namespace RC::UEGenerator Output::send(STR("Warning: Invalid value for enum '{}', casting instead of using enum name. Value '{}' will be cast to the enum.\n"), enum_native_name, enum_value); - return std::format(STR("({}){}"), enum_native_name, enum_value); + return fmt::format(STR("({}){}"), enum_native_name, enum_value); } else { @@ -1053,7 +1053,7 @@ namespace RC::UEGenerator { return enum_constant_name; } - return std::format(STR("{}::{}"), enum_native_name, enum_constant_name); + return fmt::format(STR("{}::{}"), enum_native_name, enum_constant_name); } } @@ -1066,13 +1066,13 @@ namespace RC::UEGenerator const std::wstring field_class_name = property->GetName(); if (property->GetArrayDim() == 1) { - implementation_file.append_line(std::format(STR("{}{}{}{};"), property_scope, field_class_name, operator_type, value)); + implementation_file.append_line(fmt::format(STR("{}{}{}{};"), property_scope, field_class_name, operator_type, value)); } else { for (int32_t i = 0; i < property->GetArrayDim(); i++) { - implementation_file.append_line(std::format(STR("{}{}[{}]{}{};"), property_scope, field_class_name, i, operator_type, value)); + implementation_file.append_line(fmt::format(STR("{}{}[{}]{}{};"), property_scope, field_class_name, i, operator_type, value)); } } } @@ -1085,17 +1085,17 @@ namespace RC::UEGenerator const std::wstring& operator_type) -> void { const std::wstring field_class_name = property->GetName(); - implementation_file.append_line(std::format(STR("const FProperty* p_{} = GetClass()->FindPropertyByName(\"{}\");"), field_class_name, field_class_name)); + implementation_file.append_line(fmt::format(STR("const FProperty* p_{} = GetClass()->FindPropertyByName(\"{}\");"), field_class_name, field_class_name)); if (property->GetArrayDim() == 1) { - implementation_file.append_line(std::format(STR("(*p_{}->ContainerPtrToValuePtr<{}>(this)){}{};"), field_class_name, property_type, operator_type, value)); + implementation_file.append_line(fmt::format(STR("(*p_{}->ContainerPtrToValuePtr<{}>(this)){}{};"), field_class_name, property_type, operator_type, value)); } else { for (int32_t i = 0; i < property->GetArrayDim(); i++) { implementation_file.append_line( - std::format(STR("*p_{}->ContainerPtrToValuePtr<{}>(this){}[{}]{}{};"), field_class_name, property_scope, field_class_name, i, operator_type, value)); + fmt::format(STR("*p_{}->ContainerPtrToValuePtr<{}>(this){}[{}]{}{};"), field_class_name, property_scope, field_class_name, i, operator_type, value)); } } } @@ -1276,7 +1276,7 @@ namespace RC::UEGenerator if (name_value_string != STR("None")) { - const std::wstring result_property_value = std::format(STR("TEXT(\"{}\")"), name_value_string); + const std::wstring result_property_value = fmt::format(STR("TEXT(\"{}\")"), name_value_string); if (!super_and_no_access) { generate_simple_assignment_expression(property, result_property_value, implementation_file, property_scope); @@ -1342,7 +1342,7 @@ namespace RC::UEGenerator if (text_value_string != STR("")) { - const std::wstring result_property_value = std::format(STR("FText::FromString({})"), create_string_literal(text_value_string)); + const std::wstring result_property_value = fmt::format(STR("FText::FromString({})"), create_string_literal(text_value_string)); if (!super_and_no_access) { generate_simple_assignment_expression(property, result_property_value, implementation_file, property_scope); @@ -1391,7 +1391,7 @@ namespace RC::UEGenerator // Otherwise, generate StaticClass call, assuming the class is native const std::wstring object_class_name = get_native_class_name(class_value); - const std::wstring initializer = std::format(STR("{}::StaticClass()"), object_class_name); + const std::wstring initializer = fmt::format(STR("{}::StaticClass()"), object_class_name); if (!super_and_no_access) { @@ -1507,17 +1507,17 @@ namespace RC::UEGenerator prior_prop_class_name = get_native_class_name(check_sub_object_value->GetClassPrivate()); } implementation_file.append_line( - std::format(STR("FProperty* p_{}_Prior = GetClass()->FindPropertyByName(\"{}\");"), initializer, initializer)); - initializer = std::format(STR("*p_{}_Prior->ContainerPtrToValuePtr<{}*>(this)"), initializer, prior_prop_class_name); + fmt::format(STR("FProperty* p_{}_Prior = GetClass()->FindPropertyByName(\"{}\");"), initializer, initializer)); + initializer = fmt::format(STR("*p_{}_Prior->ContainerPtrToValuePtr<{}*>(this)"), initializer, prior_prop_class_name); } if (!super_and_no_access) { - initializer = std::format(STR("({}*){}"), get_native_class_name(object_property->GetPropertyClass()), initializer); + initializer = fmt::format(STR("({}*){}"), get_native_class_name(object_property->GetPropertyClass()), initializer); generate_simple_assignment_expression(property, initializer, implementation_file, property_scope); } else { - initializer = std::format(STR("({}*){}"), get_native_class_name(object_property->GetPropertyClass()), initializer); + initializer = fmt::format(STR("({}*){}"), get_native_class_name(object_property->GetPropertyClass()), initializer); generate_advanced_assignment_expression(property, initializer, implementation_file, property_scope, property_type); } } @@ -1526,7 +1526,7 @@ namespace RC::UEGenerator // Add an objectinitializer default subobject class override to the constructor implementation_file.add_dependency_object(object_class_type, DependencyLevel::Include); implementation_file.m_implementation_constructor.append( - std::format(STR(".SetDefaultSubobjectClass<{}>(TEXT(\"{}\"))"), get_native_class_name(object_class_type), object_name)); + fmt::format(STR(".SetDefaultSubobjectClass<{}>(TEXT(\"{}\"))"), get_native_class_name(object_class_type), object_name)); m_class_subobjects.try_emplace(object_name, property->GetName()); } else @@ -1534,7 +1534,7 @@ namespace RC::UEGenerator // Generate a CreateDefaultSubobject function call implementation_file.add_dependency_object(object_class_type, DependencyLevel::Include); const std::wstring object_class_name = get_native_class_name(object_class_type); - initializer = std::format(STR("CreateDefaultSubobject<{}>(TEXT(\"{}\"))"), object_class_name, object_name); + initializer = fmt::format(STR("CreateDefaultSubobject<{}>(TEXT(\"{}\"))"), object_class_name, object_name); m_class_subobjects.try_emplace(object_name, property->GetName()); if (!super_and_no_access) { @@ -1561,7 +1561,7 @@ namespace RC::UEGenerator if (auto it = m_class_subobjects.find(attach_parent_object_name); it != m_class_subobjects.end()) { // Set property to equal previous property referencing the same object - attach_string = std::format(STR("SetupAttachment({})"), it->second); + attach_string = fmt::format(STR("SetupAttachment({})"), it->second); parent_found = true; } else if (as_class) @@ -1579,11 +1579,11 @@ namespace RC::UEGenerator { if (get_property_access_modifier(check_object_property) != AccessModifier::Private) { - attach_string = std::format(STR("SetupAttachment({})"), check_property->GetName()); + attach_string = fmt::format(STR("SetupAttachment({})"), check_property->GetName()); } else { - StringType parent_property_name = std::format(STR("const FProperty* p_{}_Parent = GetClass()->FindPropertyByName(\"{}\");"), + StringType parent_property_name = fmt::format(STR("const FProperty* p_{}_Parent = GetClass()->FindPropertyByName(\"{}\");"), check_property->GetName(), check_property->GetName()); if (!implementation_file.parent_property_names.contains(parent_property_name)) @@ -1591,7 +1591,7 @@ namespace RC::UEGenerator implementation_file.parent_property_names.emplace(parent_property_name); implementation_file.append_line(parent_property_name); } - attach_string = std::format(STR("SetupAttachment(p_{}_Parent->ContainerPtrToValuePtr<{}>(this))"), + attach_string = fmt::format(STR("SetupAttachment(p_{}_Parent->ContainerPtrToValuePtr<{}>(this))"), check_property->GetName(), get_native_class_name(check_sub_object_value->GetClassPrivate())); implementation_file.add_dependency_object(check_sub_object_value->GetClassPrivate(), DependencyLevel::Include); @@ -1635,7 +1635,7 @@ namespace RC::UEGenerator implementation_file.add_dependency_object(sub_object_as_class, DependencyLevel::Include); const std::wstring object_class_name = get_native_class_name(sub_object_as_class); - const std::wstring initializer = std::format(STR("{}::StaticClass()"), object_class_name); + const std::wstring initializer = fmt::format(STR("{}::StaticClass()"), object_class_name); if (!super_and_no_access) { generate_simple_assignment_expression(property, initializer, implementation_file, property_scope); @@ -1664,7 +1664,7 @@ namespace RC::UEGenerator } void* StructDataPointer = StructProperty->container_ptr_to_value_ptr(Object); - const std::wstring NewPropertyScope = std::format(STR("{}{}."), PropertyScope, StructProperty->GetName()); + const std::wstring NewPropertyScope = fmt::format(STR("{}{}."), PropertyScope, StructProperty->GetName()); //Generate values for each struct property //TODO we do not really need to generate assignments for each struct member, we only really need members that are different from the constructor set @@ -1694,7 +1694,7 @@ namespace RC::UEGenerator { if (!super_and_no_access) { - implementation_file.append_line(std::format(STR("{}{}.AddDefaulted({});"), property_scope, property->GetName(), property_value->Num())); + implementation_file.append_line(fmt::format(STR("{}{}.AddDefaulted({});"), property_scope, property->GetName(), property_value->Num())); } else { @@ -1738,7 +1738,7 @@ namespace RC::UEGenerator else { double value = numeric_property->GetFloatingPointPropertyValue(numeric_property->ContainerPtrToValuePtr(object)); - number_constant_string = std::format(STR("{:.2f}f"), value); + number_constant_string = fmt::format(STR("{:.2f}f"), value); } if (!super_and_no_access) { @@ -1770,12 +1770,12 @@ namespace RC::UEGenerator if ((function_flags & FUNC_Net) != 0) { // Network functions always have the implementation inside the _Implementation function - function_implementation_name = std::format(STR("{}::{}_Implementation"), class_native_name, raw_function_name); + function_implementation_name = fmt::format(STR("{}::{}_Implementation"), class_native_name, raw_function_name); // Validated network functions by default have their validation function name set to _Validate if ((function_flags & FUNC_NetValidate) != 0) { - net_validate_function_name = std::format(STR("{}::{}_Validate"), class_native_name, raw_function_name); + net_validate_function_name = fmt::format(STR("{}::{}_Validate"), class_native_name, raw_function_name); } } else if ((function_flags & FUNC_BlueprintEvent) != 0) @@ -1784,13 +1784,13 @@ namespace RC::UEGenerator // BlueprintImplementableEvents do not have any native functions at all, they're just thunks if ((function_flags & FUNC_Native) != 0) { - function_implementation_name = std::format(STR("{}::{}_Implementation"), class_native_name, raw_function_name); + function_implementation_name = fmt::format(STR("{}::{}_Implementation"), class_native_name, raw_function_name); } } else { // Otherwise, normal UFunctions get a standard name matching the function in question - function_implementation_name = std::format(STR("{}::{}"), class_native_name, raw_function_name); + function_implementation_name = fmt::format(STR("{}::{}"), class_native_name, raw_function_name); } std::wstring function_parameter_list; @@ -1806,7 +1806,7 @@ namespace RC::UEGenerator const std::wstring return_value_type = return_value_property ? generate_property_type_declaration(return_value_property, context) : STR("void"); - implementation_file.append_line(std::format(STR("{} {}({}){} {{"), + implementation_file.append_line(fmt::format(STR("{} {}({}){} {{"), return_value_type, function_implementation_name, function_parameter_list, @@ -1816,7 +1816,7 @@ namespace RC::UEGenerator if (return_value_property != NULL) { const std::wstring default_value = generate_default_property_value(return_value_property, implementation_file, context.context_name); - implementation_file.append_line(std::format(STR("return {};"), default_value)); + implementation_file.append_line(fmt::format(STR("return {};"), default_value)); } implementation_file.end_indent_level(); @@ -1825,7 +1825,7 @@ namespace RC::UEGenerator if (!net_validate_function_name.empty()) { - implementation_file.append_line(std::format(STR("bool {}({}) {{"), net_validate_function_name, function_parameter_list)); + implementation_file.append_line(fmt::format(STR("bool {}({}) {{"), net_validate_function_name, function_parameter_list)); implementation_file.begin_indent_level(); implementation_file.append_line(STR("return true;")); @@ -1956,7 +1956,7 @@ namespace RC::UEGenerator default: { if (ch < 31 || ch >= 128) { - result.append(std::format(STR("\\x{:04X}"), ch)); + result.append(fmt::format(STR("\\x{:04X}"), ch)); previous_character_was_hex = true; } else @@ -2286,7 +2286,7 @@ namespace RC::UEGenerator } // Non-EnumClass enumerations should be wrapped into TEnumAsByte according to UHT, but implicit uint8s should not use TEnumAsByte - return std::format(STR("TEnumAsByte<{}>"), enum_type_name); + return fmt::format(STR("TEnumAsByte<{}>"), enum_type_name); } return STR("uint8"); } @@ -2388,7 +2388,7 @@ namespace RC::UEGenerator } const std::wstring meta_class_name = get_native_class_name(meta_class, false); - return std::format(STR("TSubclassOf<{}>"), meta_class_name); + return fmt::format(STR("TSubclassOf<{}>"), meta_class_name); } if (auto* class_property = CastField(property); class_property) @@ -2413,7 +2413,7 @@ namespace RC::UEGenerator } const std::wstring meta_class_name = get_native_class_name(meta_class, false); - return std::format(STR("TSoftClassPtr<{}>"), meta_class_name); + return fmt::format(STR("TSoftClassPtr<{}>"), meta_class_name); } // Object Properties @@ -2434,7 +2434,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("{}*"), property_class_name); + return fmt::format(STR("{}*"), property_class_name); } if (auto* object_property = CastField(property); object_property) @@ -2453,7 +2453,7 @@ namespace RC::UEGenerator } const auto property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TObjectPtr<{}>"), property_class_name); } } @@ -2473,7 +2473,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TWeakObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TWeakObjectPtr<{}>"), property_class_name); } if (property->IsA()) @@ -2492,7 +2492,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TLazyObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TLazyObjectPtr<{}>"), property_class_name); } if (property->IsA()) @@ -2511,7 +2511,7 @@ namespace RC::UEGenerator } const std::wstring property_class_name = get_native_class_name(property_class, false); - return std::format(STR("TSoftObjectPtr<{}>"), property_class_name); + return fmt::format(STR("TSoftObjectPtr<{}>"), property_class_name); } // Interface Property @@ -2531,7 +2531,7 @@ namespace RC::UEGenerator } const std::wstring interface_class_name = get_native_class_name(interface_class, true); - return std::format(STR("TScriptInterface<{}>"), interface_class_name); + return fmt::format(STR("TScriptInterface<{}>"), interface_class_name); } // Struct Property @@ -2563,7 +2563,7 @@ namespace RC::UEGenerator if (!delegate_signature_function) { throw std::runtime_error{ - std::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; + fmt::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; } if (context.source_file != NULL) @@ -2582,7 +2582,7 @@ namespace RC::UEGenerator if (!delegate_signature_function) { throw std::runtime_error{ - std::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; + fmt::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; } if (context.source_file != NULL) @@ -2599,7 +2599,7 @@ namespace RC::UEGenerator if (!delegate_signature_function) { throw std::runtime_error{ - std::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; + fmt::format("FunctionSignature is nullptr, cannot deduce function for '{}'\n", to_string(delegate_property->GetFullName()))}; } if (context.source_file != NULL) @@ -2614,7 +2614,7 @@ namespace RC::UEGenerator { FFieldPathProperty* field_path_property = static_cast(property); const std::wstring property_class_name = field_path_property->GetPropertyClass()->GetName(); - return std::format(STR("TFieldPath"), property_class_name); + return fmt::format(STR("TFieldPath"), property_class_name); } // Collection and Map Properties @@ -2625,7 +2625,7 @@ namespace RC::UEGenerator FProperty* inner_property = array_property->GetInner(); const std::wstring inner_property_type = generate_property_type_declaration(inner_property, context.inner_context()); - return std::format(STR("TArray<{}>"), inner_property_type); + return fmt::format(STR("TArray<{}>"), inner_property_type); } if (property->IsA()) @@ -2634,7 +2634,7 @@ namespace RC::UEGenerator FProperty* element_prop = set_property->GetElementProp(); const std::wstring element_property_type = generate_property_type_declaration(element_prop, context.inner_context()); - return std::format(STR("TSet<{}>"), element_property_type); + return fmt::format(STR("TSet<{}>"), element_property_type); } // TODO: This is missing support for freeze image map properties because XMapProperty is incomplete. (low priority) @@ -2647,7 +2647,7 @@ namespace RC::UEGenerator const std::wstring key_type = generate_property_type_declaration(key_property, context.inner_context()); const std::wstring value_type = generate_property_type_declaration(value_property, context.inner_context()); - return std::format(STR("TMap<{}, {}>"), key_type, value_type); + return fmt::format(STR("TMap<{}, {}>"), key_type, value_type); } // Standard properties that do not have any special attributes @@ -2966,7 +2966,7 @@ namespace RC::UEGenerator int64 highest_enum_value = 0; const StringType enum_prefix = uenum->GenerateEnumPrefix(); - const StringType expected_max_name = std::format(STR("{}_MAX"), enum_prefix); + const StringType expected_max_name = fmt::format(STR("{}_MAX"), enum_prefix); StringType expected_max_name_lower = expected_max_name; std::transform(expected_max_name_lower.begin(), expected_max_name_lower.end(), expected_max_name_lower.begin(), ::towlower); @@ -3125,7 +3125,7 @@ namespace RC::UEGenerator auto param_uc_name = string_to_uppercase(param_name); if (param_uc_name.find(STR("WORLDCONTEXT")) != param_uc_name.npos) { - flag_format_helper.get_meta()->add_parameter(STR("WorldContext"), std::format(STR("\"{}\""), param_name)); + flag_format_helper.get_meta()->add_parameter(STR("WorldContext"), fmt::format(STR("\"{}\""), param_name)); bWCFound = true; } if (auto as_struct_property = CastField(param); as_struct_property) @@ -3133,7 +3133,7 @@ namespace RC::UEGenerator // We now know this is a StructProperty. if (as_struct_property->GetStruct()->IsChildOf(latent_action_info)) { - flag_format_helper.get_meta()->add_parameter(STR("LatentInfo"), std::format(STR("\"{}\""), param_name)); + flag_format_helper.get_meta()->add_parameter(STR("LatentInfo"), fmt::format(STR("\"{}\""), param_name)); flag_format_helper.get_meta()->add_switch(STR("Latent")); bLAFound = true; } @@ -3309,7 +3309,7 @@ namespace RC::UEGenerator throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty %S", property->GetName().c_str())); } const std::wstring native_struct_name = get_native_struct_name(script_struct); - return std::format(STR("{}{{}}"), native_struct_name); + return fmt::format(STR("{}{{}}"), native_struct_name); } // Delegate Properties @@ -3317,7 +3317,7 @@ namespace RC::UEGenerator field_class_name == STR("MulticastSparseDelegateProperty")) { const std::wstring delegate_type_name = generate_delegate_name(property, context.context_name); - return std::format(STR("{}()"), delegate_type_name); + return fmt::format(STR("{}()"), delegate_type_name); } // Field path property @@ -3333,7 +3333,7 @@ namespace RC::UEGenerator FProperty* inner_property = array_property->GetInner(); const std::wstring inner_property_type = generate_property_type_declaration(inner_property, context); - return std::format(STR("TArray<{}>()"), inner_property_type); + return fmt::format(STR("TArray<{}>()"), inner_property_type); } if (field_class_name == STR("SetProperty")) @@ -3342,7 +3342,7 @@ namespace RC::UEGenerator FProperty* element_prop = set_property->GetElementProp(); const std::wstring element_property_type = generate_property_type_declaration(element_prop, context); - return std::format(STR("TSet<{}>()"), element_property_type); + return fmt::format(STR("TSet<{}>()"), element_property_type); } if (field_class_name == STR("MapProperty")) @@ -3354,7 +3354,7 @@ namespace RC::UEGenerator const std::wstring key_type = generate_property_type_declaration(key_property, context); const std::wstring value_type = generate_property_type_declaration(value_property, context); - return std::format(STR("TMap<{}, {}>()"), key_type, value_type); + return fmt::format(STR("TMap<{}, {}>()"), key_type, value_type); } // Various string, name and text properties @@ -3767,7 +3767,7 @@ namespace RC::UEGenerator { name = get_native_struct_name(std::bit_cast(object)); } - header_file.append_line(std::format(STR("FORCEINLINE uint32 GetTypeHash(const {}) {{ return 0; }}"), name)); + header_file.append_line(fmt::format(STR("FORCEINLINE uint32 GetTypeHash(const {}) {{ return 0; }}"), name)); } // Case for FTickFunction struct @@ -3783,7 +3783,7 @@ namespace RC::UEGenerator name = get_native_struct_name(struct_object); header_file.append_line(STR("")); header_file.append_line(STR("template<>")); - header_file.append_line(std::format(STR("struct TStructOpsTypeTraits<{}> : public TStructOpsTypeTraitsBase2<{}>"), name, name)); + header_file.append_line(fmt::format(STR("struct TStructOpsTypeTraits<{}> : public TStructOpsTypeTraitsBase2<{}>"), name, name)); header_file.append_line(STR("{")); header_file.append_line(STR(" enum")); header_file.append_line(STR(" {")); @@ -3970,14 +3970,14 @@ namespace RC::UEGenerator { if (auto it2 = m_dependency_object_to_unique_id.find(final_object); it2 != m_dependency_object_to_unique_id.end()) { - header_name.append(std::format(STR("{}"), it2->second)); + header_name.append(fmt::format(STR("{}"), it2->second)); } } else { if (auto it = m_used_file_names.find(header_name); it != m_used_file_names.end()) { - header_name.append(std::format(STR("{}"), ++it->second.usable_id)); + header_name.append(fmt::format(STR("{}"), ++it->second.usable_id)); m_dependency_object_to_unique_id.emplace(final_object, it->second.usable_id); } else @@ -4024,7 +4024,7 @@ namespace RC::UEGenerator } const std::wstring object_name = top_level_object->GetName(); - return std::format(STR("//CROSS-MODULE INCLUDE V2: -ModuleName={} -ObjectName={} -FallbackName={}\n"), module_name, object_name, fallback_name); + return fmt::format(STR("//CROSS-MODULE INCLUDE V2: -ModuleName={} -ObjectName={} -FallbackName={}\n"), module_name, object_name, fallback_name); } GeneratedFile::GeneratedFile(const FFilePath& full_file_path) @@ -4186,7 +4186,7 @@ namespace RC::UEGenerator if (m_header_file != NULL) { // Generate it if we have the correct header file set - result_include_string.append(std::format(STR("#include \"{}.h\"\n"), m_header_file->m_file_base_name)); + result_include_string.append(fmt::format(STR("#include \"{}.h\"\n"), m_header_file->m_file_base_name)); } else { @@ -4275,7 +4275,7 @@ namespace RC::UEGenerator // Last include of the header file should always be a generated one if (!m_is_implementation_file) { - result_include_string.append(std::format(STR("#include \"{}.generated.h\"\n"), m_file_base_name)); + result_include_string.append(fmt::format(STR("#include \"{}.generated.h\"\n"), m_file_base_name)); } return result_include_string; } diff --git a/UE4SS/src/UE4SSProgram.cpp b/UE4SS/src/UE4SSProgram.cpp index e753c31d..2f73e208 100644 --- a/UE4SS/src/UE4SSProgram.cpp +++ b/UE4SS/src/UE4SSProgram.cpp @@ -12,7 +12,7 @@ #include #include #include - +#include #include #include #include @@ -176,7 +176,7 @@ namespace RC } catch (std::exception& e) { - create_emergency_console_for_early_error(std::format(STR("The IniParser failed to parse: {}"), to_wstring(e.what()))); + create_emergency_console_for_early_error(fmt::format(STR("The IniParser failed to parse: {}"), to_wstring(e.what()))); return; } @@ -199,7 +199,7 @@ namespace RC { m_console_device = &Output::set_default_devices(); m_console_device->set_formatter([](File::StringViewType string) -> File::StringType { - return std::format(STR("[{}] {}"), std::format(STR("{:%X}"), std::chrono::system_clock::now()), string); + return fmt::format(STR("[{}] {}"), fmt::format(STR("{:%X}"), std::chrono::system_clock::now()), string); }); if (settings_manager.Debug.DebugConsoleVisible) { @@ -221,9 +221,9 @@ namespace RC UE4SS_LIB_VERSION_MAJOR, UE4SS_LIB_VERSION_MINOR, UE4SS_LIB_VERSION_HOTFIX, - std::format(L"{}", UE4SS_LIB_VERSION_PRERELEASE == 0 ? L"" : std::format(L" PreRelease #{}", UE4SS_LIB_VERSION_PRERELEASE)), - std::format(L"{}", - UE4SS_LIB_BETA_STARTED == 0 ? L"" : (UE4SS_LIB_IS_BETA == 0 ? L" Beta #?" : std::format(L" Beta #{}", UE4SS_LIB_VERSION_BETA))), + fmt::format(L"{}", UE4SS_LIB_VERSION_PRERELEASE == 0 ? L"" : fmt::format(L" PreRelease #{}", UE4SS_LIB_VERSION_PRERELEASE)), + fmt::format(L"{}", + UE4SS_LIB_BETA_STARTED == 0 ? L"" : (UE4SS_LIB_IS_BETA == 0 ? L" Beta #?" : fmt::format(L" Beta #{}", UE4SS_LIB_VERSION_BETA))), to_wstring(UE4SS_LIB_BUILD_GITSHA)); #ifdef __clang__ @@ -457,7 +457,7 @@ namespace RC m_debug_console_device = &Output::set_default_devices(); Output::set_default_log_level(); m_debug_console_device->set_formatter([](File::StringViewType string) -> File::StringType { - return std::format(STR("[{}] {}"), std::format(STR("{:%X}"), std::chrono::system_clock::now()), string); + return fmt::format(STR("[{}] {}"), fmt::format(STR("{:%X}"), std::chrono::system_clock::now()), string); }); if (AllocConsole()) @@ -1189,7 +1189,7 @@ namespace RC } if (ec.value() != 0) { - return std::format("is_directory ran into error {}", ec.value()); + return fmt::format("is_directory ran into error {}", ec.value()); } if (!std::filesystem::exists(mod_directory.path() / "enabled.txt", ec)) @@ -1198,7 +1198,7 @@ namespace RC } if (ec.value() != 0) { - return std::format("exists ran into error {}", ec.value()); + return fmt::format("exists ran into error {}", ec.value()); } auto mod = UE4SSProgram::find_mod_by_name(mod_directory.path().stem().c_str(), UE4SSProgram::IsInstalled::Yes); diff --git a/UE4SS/xmake.lua b/UE4SS/xmake.lua index 8ccee3fc..8d86350a 100644 --- a/UE4SS/xmake.lua +++ b/UE4SS/xmake.lua @@ -6,6 +6,7 @@ add_requires("IconFontCppHeaders v1.0", { debug = is_mode_debug(), configs = {ru add_requires("glfw 3.3.9", { debug = is_mode_debug() , configs = {runtimes = get_mode_runtimes()}}) add_requires("opengl", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} }) add_requires("glaze", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} }) +add_requires("fmt", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} }) option("ue4ssBetaIsStarted") set_default(true) @@ -62,6 +63,8 @@ target(projectName) "ScopedTimer", "Profiler", "patternsleuth_bind", "glad", { public = true } ) + + add_packages("fmt", { public = true }) add_packages("imgui", "ImGuiTextEdit", "IconFontCppHeaders", "glfw", "opengl", { public = true }) diff --git a/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp b/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp index ee2e0c08..5da40b8e 100644 --- a/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp +++ b/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp @@ -10,16 +10,17 @@ #include #include #include - +#include +#include #include #include #include #include #if RC_IS_ANSI == 1 -#define RC_STD_MAKE_FORMAT_ARGS std::make_format_args +#define RC_STD_MAKE_FORMAT_ARGS fmt::make_format_args #else -#define RC_STD_MAKE_FORMAT_ARGS std::make_wformat_args +#define RC_STD_MAKE_FORMAT_ARGS fmt::make_wformat_args #endif namespace RC::Output @@ -52,7 +53,7 @@ namespace RC::Output if (!ret) { THROW_INTERNAL_FILE_ERROR( - std::format("[Output::get_device_internal] tried to get_device but was unable to find device of type: {}", typeid(DeviceType).name())) + fmt::format("[Output::get_device_internal] tried to get_device but was unable to find device of type: {}", typeid(DeviceType).name())) } return *ret; } @@ -122,11 +123,11 @@ namespace RC::Output if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content), RC_STD_MAKE_FORMAT_ARGS(static_cast(optional_arg))); + device->receive_with_optional_arg(fmt::vformat(content), RC_STD_MAKE_FORMAT_ARGS(static_cast(optional_arg))); } else { - device->receive(std::vformat(content)); + device->receive(fmt::vformat(content)); } } } @@ -145,11 +146,11 @@ namespace RC::Output if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), 0); + device->receive_with_optional_arg(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), 0); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } @@ -167,11 +168,11 @@ namespace RC::Output ASSERT_OUTPUT_DEVICE_IS_VALID(device) if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, fmt_args...), RC_STD_MAKE_FORMAT_ARGS(static_cast(optional_arg))); + device->receive_with_optional_arg(fmt::vformat(content, fmt_args...), RC_STD_MAKE_FORMAT_ARGS(static_cast(optional_arg))); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } @@ -211,11 +212,11 @@ namespace RC::Output ASSERT_OUTPUT_DEVICE_IS_VALID(device) if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_arg, fmt_args...)), optional_arg); + device->receive_with_optional_arg(fmt::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_arg, fmt_args...)), optional_arg); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } @@ -287,11 +288,11 @@ namespace RC::Output if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), 0); + device->receive_with_optional_arg(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), 0); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } @@ -305,11 +306,11 @@ namespace RC::Output if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), static_cast(optional_arg)); + device->receive_with_optional_arg(fmt::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), static_cast(optional_arg)); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } @@ -343,11 +344,11 @@ namespace RC::Output if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), optional_arg); + device->receive_with_optional_arg(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), optional_arg); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(fmt::vformat(fmt::detail::to_string_view(content), RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); } } } diff --git a/deps/first/DynamicOutput/src/OutputDevice.cpp b/deps/first/DynamicOutput/src/OutputDevice.cpp index 7f20019d..4cf1f46f 100644 --- a/deps/first/DynamicOutput/src/OutputDevice.cpp +++ b/deps/first/DynamicOutput/src/OutputDevice.cpp @@ -1,6 +1,7 @@ #include #include - +#include +#include #include namespace RC::Output @@ -25,12 +26,12 @@ namespace RC::Output auto OutputDevice::get_now_as_string() -> const File::StringType { auto now = std::chrono::system_clock::now(); - const File::StringType when_as_string = std::format(STR("{:%Y-%m-%d %X}"), now); + const File::StringType when_as_string = fmt::format(STR("{:%Y-%m-%d %X}"), now); return when_as_string; } auto OutputDevice::default_format_string(File::StringViewType string_to_format) -> File::StringType { - return std::format(STR("[{}] {}"), get_now_as_string(), string_to_format); + return fmt::format(STR("[{}] {}"), get_now_as_string(), string_to_format); } } // namespace RC::Output diff --git a/deps/first/File/src/FileType/WinFile.cpp b/deps/first/File/src/FileType/WinFile.cpp index 0cbfd2f8..39e79fff 100644 --- a/deps/first/File/src/FileType/WinFile.cpp +++ b/deps/first/File/src/FileType/WinFile.cpp @@ -9,6 +9,7 @@ #ifdef TEXT #undef TEXT #endif +#include namespace RC::File { @@ -30,14 +31,14 @@ namespace RC::File { if (DeleteFileW(file_path_and_name.wstring().c_str()) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::delete_file] Was unable to delete file, error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::delete_file] Was unable to delete file, error: {}", GetLastError())) } } else { if (DeleteFileA(file_path_and_name.string().c_str()) != 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::delete_file] Was unable to delete file, error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::delete_file] Was unable to delete file, error: {}", GetLastError())) } } } @@ -98,7 +99,7 @@ namespace RC::File DWORD bytes_written{}; if (!WriteFile(file.get_file(), data, num_bytes_to_write, &bytes_written, nullptr)) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::write_to_file] Tried writing to file but was unable to complete operation. Error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::write_to_file] Tried writing to file but was unable to complete operation. Error: {}", GetLastError())) } } @@ -292,7 +293,7 @@ namespace RC::File if (res == 0) { THROW_INTERNAL_FILE_ERROR( - std::format("[WinFile::get_serialized_item] Tried deserializing file but was unable to complete operation. Error: {}", GetLastError())) + fmt::format("[WinFile::get_serialized_item] Tried deserializing file but was unable to complete operation. Error: {}", GetLastError())) } cache_file.close(); @@ -328,7 +329,7 @@ namespace RC::File } catch (const std::filesystem::filesystem_error& e) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::create_all_directories] Tried creating directories '{}' but encountered an error. Error: {}", + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::create_all_directories] Tried creating directories '{}' but encountered an error. Error: {}", file_name_and_path.string(), e.what())) } @@ -340,7 +341,7 @@ namespace RC::File { if (UnmapViewOfFile(m_memory_map) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::close_file] Was unable to unmap file, error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::close_file] Was unable to unmap file, error: {}", GetLastError())) } else { @@ -352,7 +353,7 @@ namespace RC::File { if (CloseHandle(m_map_handle) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::close_file] Was unable to close map handle, error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::close_file] Was unable to close map handle, error: {}", GetLastError())) } else { @@ -367,7 +368,7 @@ namespace RC::File if (CloseHandle(m_file) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::close_file] Was unable to close file, error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::close_file] Was unable to close file, error: {}", GetLastError())) } else { @@ -385,7 +386,7 @@ namespace RC::File int string_size = WideCharToMultiByte(CP_UTF8, 0, string_to_write.data(), static_cast(string_to_write.size()), NULL, 0, NULL, NULL); if (string_size == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::write_string_to_file] Tried writing string to file but string_size was 0. Error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::write_string_to_file] Tried writing string to file but string_size was 0. Error: {}", GetLastError())) } std::string string_converted_to_utf8(string_size, 0); @@ -393,7 +394,7 @@ namespace RC::File 0) { THROW_INTERNAL_FILE_ERROR( - std::format("[WinFile::write_string_to_file] Tried writing string to file but could not convert to utf-8. Error: {}", GetLastError())) + fmt::format("[WinFile::write_string_to_file] Tried writing string to file but could not convert to utf-8. Error: {}", GetLastError())) } write_to_file(*this, string_converted_to_utf8.c_str(), string_size); @@ -404,13 +405,13 @@ namespace RC::File BY_HANDLE_FILE_INFORMATION file_info{}; if (GetFileInformationByHandle(m_file, &file_info) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::is_same_as] Tried retrieving file information by handle. Error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::is_same_as] Tried retrieving file information by handle. Error: {}", GetLastError())) } BY_HANDLE_FILE_INFORMATION other_file_info{}; if (GetFileInformationByHandle(other_file.get_file(), &other_file_info) == 0) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::is_same_as] Tried retrieving file information by handle. Error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::is_same_as] Tried retrieving file information by handle. Error: {}", GetLastError())) } if (file_info.dwVolumeSerialNumber != other_file_info.dwVolumeSerialNumber) @@ -457,7 +458,7 @@ namespace RC::File StreamType stream{get_file_path(), std::ios::in | std::ios::binary}; if (!stream) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::read_all] Tried to read entire file but returned error {}", errno)) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::read_all] Tried to read entire file but returned error {}", errno)) } else { @@ -509,13 +510,13 @@ namespace RC::File m_map_handle = CreateFileMapping(get_raw_handle(), nullptr, handle_desired_access, 0, 0, nullptr); if (!m_map_handle) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::memory_map] Tried to memory map file but 'CreateFileMapping' returned error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::memory_map] Tried to memory map file but 'CreateFileMapping' returned error: {}", GetLastError())) } m_memory_map = static_cast(MapViewOfFile(m_map_handle, mapping_desired_access, 0, 0, 0)); if (!m_memory_map) { - THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::memory_map] Tried to memory map file but 'MapViewOfFile' returned error: {}", GetLastError())) + THROW_INTERNAL_FILE_ERROR(fmt::format("[WinFile::memory_map] Tried to memory map file but 'MapViewOfFile' returned error: {}", GetLastError())) } MEMORY_BASIC_INFORMATION buffer{}; @@ -600,16 +601,16 @@ namespace RC::File DWORD error = GetLastError(); if (error == 2) { - throw FileNotFoundException{std::format("File not found: {}", file_name_and_path.filename().string())}; + throw FileNotFoundException{fmt::format("File not found: {}", file_name_and_path.filename().string())}; } else if (error == 3) { - throw FileNotFoundException{std::format("Path not found: {}", file_name_and_path.filename().string())}; + throw FileNotFoundException{fmt::format("Path not found: {}", file_name_and_path.filename().string())}; } else { THROW_INTERNAL_FILE_ERROR( - std::format("[WinFile::open_file] Tried opening file for {} but encountered an error. Path & File: {} | GetLastError() = {}\n", + fmt::format("[WinFile::open_file] Tried opening file for {} but encountered an error. Path & File: {} | GetLastError() = {}\n", open_type, file_name_and_path.string(), error)) diff --git a/deps/first/File/xmake.lua b/deps/first/File/xmake.lua index 4d8b7707..c9f7c45a 100644 --- a/deps/first/File/xmake.lua +++ b/deps/first/File/xmake.lua @@ -9,4 +9,5 @@ target(projectName) add_includedirs("include", { public = true }) add_headerfiles("include/**.hpp") - add_files("src/**.cpp") \ No newline at end of file + add_files("src/**.cpp") + add_packages("fmt", { public = true }) \ No newline at end of file diff --git a/deps/first/IniParser/src/JSON.cpp b/deps/first/IniParser/src/JSON.cpp index a0a71f85..b7951e5f 100644 --- a/deps/first/IniParser/src/JSON.cpp +++ b/deps/first/IniParser/src/JSON.cpp @@ -41,16 +41,16 @@ namespace RC::Parser auto JSONInternal::StringItem::to_string() -> File::StringType { - return std::format(STR("String = \"{}\""), m_value); + return fmt::format(STR("String = \"{}\""), m_value); } auto JSONInternal::ObjectScope::to_string() -> File::StringType { - File::StringType str = std::format(STR("Object = \"{}\""), get_name()); + File::StringType str = fmt::format(STR("Object = \"{}\""), get_name()); for (const auto& member : m_members) { - str.append(std::format(STR("\n\"{}\" = {}"), member->get_name(), member->to_string())); + str.append(fmt::format(STR("\n\"{}\" = {}"), member->get_name(), member->to_string())); } return str; @@ -58,7 +58,7 @@ namespace RC::Parser auto JSONInternal::ArrayScope::to_string() -> File::StringType { - return std::format(STR("Array = \"{}\""), get_name()); + return fmt::format(STR("Array = \"{}\""), get_name()); } auto JSONInternal::TokenParser::token_to_string(const Token& token) -> File::StringType @@ -123,7 +123,7 @@ namespace RC::Parser if (static_cast(m_current_item)->m_previous_line_without_comma == 0) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Unexpected 'Comma' token, expected 'CloseCurlyBrace'.", token.get_line(), token.get_column())}; + fmt::format("Syntax error ({} : {}): Unexpected 'Comma' token, expected 'CloseCurlyBrace'.", token.get_line(), token.get_column())}; } } else if (m_current_item->get_type() == ItemType::Array) @@ -155,7 +155,7 @@ namespace RC::Parser // Enforce 'Comma' token, if this isn't the first item if (!typed_current_item.m_members.empty() && typed_current_item.m_previous_line_without_comma != 0) { - throw std::runtime_error{std::format("Syntax error ({} : {}): Expected 'Comma' token before new item.", + throw std::runtime_error{fmt::format("Syntax error ({} : {}): Expected 'Comma' token before new item.", typed_current_item.m_previous_line_without_comma, typed_current_item.m_previous_column_without_comma)}; } @@ -181,7 +181,7 @@ namespace RC::Parser // Consume the closing 'DoubleQuote' token if (peek().get_type() != TokenType::DoubleQuote) { - throw std::runtime_error{std::format("Syntax error ({} : {}): Expected 'DoubleQuote' token, got '{}'.", + throw std::runtime_error{fmt::format("Syntax error ({} : {}): Expected 'DoubleQuote' token, got '{}'.", token.get_line(), token.get_column(), to_string(token.to_string()))}; @@ -229,7 +229,7 @@ namespace RC::Parser } else { - throw std::runtime_error{std::format("Syntax error ({} : {}): Unexpected 'Comma' token.", token.get_line(), token.get_column())}; + throw std::runtime_error{fmt::format("Syntax error ({} : {}): Unexpected 'Comma' token.", token.get_line(), token.get_column())}; } m_processed_token_types += TokenType::Comma; @@ -256,7 +256,7 @@ namespace RC::Parser auto& peeked_token = peek(); if (peeked_token.get_type() != TokenType::Colon) { - throw std::runtime_error{std::format("Syntax error ({} : {}): Expected 'Colon' token, got '{}'.", + throw std::runtime_error{fmt::format("Syntax error ({} : {}): Expected 'Colon' token, got '{}'.", peeked_token.get_line(), peeked_token.get_column(), to_string(peeked_token.to_string()))}; @@ -308,7 +308,7 @@ namespace RC::Parser if (m_next_token_expected != TokenType::Default && token_type != TokenType::Characters && token_type != m_next_token_expected) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Expected 'Colon' token, got '{}'.", token.get_line(), token.get_column(), to_string(token.to_string()))}; + fmt::format("Syntax error ({} : {}): Expected 'Colon' token, got '{}'.", token.get_line(), token.get_column(), to_string(token.to_string()))}; } switch (token_type) diff --git a/deps/first/IniParser/src/TokenParser.cpp b/deps/first/IniParser/src/TokenParser.cpp index dd633366..d15bd72a 100644 --- a/deps/first/IniParser/src/TokenParser.cpp +++ b/deps/first/IniParser/src/TokenParser.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace RC::Ini @@ -252,7 +253,7 @@ namespace RC::Ini if (m_current_state != State::NewLineStarted && m_current_state != State::StartOfFile) { - throw std::runtime_error{std::format("Syntax error({} : {}): Expected state NewLineStarted or StartOfFile, got {}", + throw std::runtime_error{fmt::format("Syntax error({} : {}): Expected state NewLineStarted or StartOfFile, got {}", token.get_line(), token.get_column(), to_string(state_to_string(m_current_state)))}; @@ -273,7 +274,7 @@ namespace RC::Ini if (m_current_character_data.empty()) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Expected Characters, got {}", token.get_line(), token.get_column(), to_string(token.to_string()))}; + fmt::format("Syntax error ({} : {}): Expected Characters, got {}", token.get_line(), token.get_column(), to_string(token.to_string()))}; } if (auto section = m_output.find(m_current_character_data); section != m_output.end()) @@ -339,7 +340,7 @@ namespace RC::Ini else { throw std::runtime_error{ - std::format("Syntax error({} : {}): Invalid state {}", token.get_line(), token.get_column(), to_string(state_to_string(m_current_state)))}; + fmt::format("Syntax error({} : {}): Invalid state {}", token.get_line(), token.get_column(), to_string(state_to_string(m_current_state)))}; } } @@ -354,7 +355,7 @@ namespace RC::Ini if (m_current_state != State::CreateSectionKey) { - throw std::runtime_error{std::format("Syntax error({} : {}): Expected state CreateSectionKey, got {}", + throw std::runtime_error{fmt::format("Syntax error({} : {}): Expected state CreateSectionKey, got {}", token.get_line(), token.get_column(), to_string(state_to_string(m_current_state)))}; @@ -362,7 +363,7 @@ namespace RC::Ini if (!m_current_section) { - throw std::runtime_error{std::format("Syntax error ({} : {}): No section. Global variables not supported, please create a [Section]", + throw std::runtime_error{fmt::format("Syntax error ({} : {}): No section. Global variables not supported, please create a [Section]", token.get_line(), token.get_column())}; } @@ -370,13 +371,13 @@ namespace RC::Ini if (m_current_character_data.empty()) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Expected Characters, got {}", token.get_line(), token.get_column(), to_string(token.to_string()))}; + fmt::format("Syntax error ({} : {}): Expected Characters, got {}", token.get_line(), token.get_column(), to_string(token.to_string()))}; } if (m_current_section->is_ordered_list) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Previous item is in ordered-list mode, expected another list item, got key/value pair", + fmt::format("Syntax error ({} : {}): Previous item is in ordered-list mode, expected another list item, got key/value pair", token.get_line(), token.get_column(), to_string(token.to_string()))}; @@ -405,7 +406,7 @@ namespace RC::Ini if (!m_current_section->key_value_pairs.empty() && !m_current_section->is_ordered_list) { throw std::runtime_error{ - std::format("Syntax error ({} : {}): Previous item is in key/value mode, expected another key/value item, got ordered-list item", + fmt::format("Syntax error ({} : {}): Previous item is in key/value mode, expected another key/value item, got ordered-list item", token.get_line(), token.get_column(), to_string(token.to_string()))}; diff --git a/deps/first/LuaMadeSimple/include/LuaMadeSimple/LuaMadeSimple.hpp b/deps/first/LuaMadeSimple/include/LuaMadeSimple/LuaMadeSimple.hpp index a4ca10f2..c9f8f6bd 100644 --- a/deps/first/LuaMadeSimple/include/LuaMadeSimple/LuaMadeSimple.hpp +++ b/deps/first/LuaMadeSimple/include/LuaMadeSimple/LuaMadeSimple.hpp @@ -6,6 +6,7 @@ #include #include +#include namespace RC::LuaMadeSimple { @@ -409,7 +410,7 @@ namespace RC::LuaMadeSimple } else { - get_lua_instance().throw_error(std::format("[get_userdata_field] Attempted to get field: '{}' but the type was '{}'", + get_lua_instance().throw_error(fmt::format("[get_userdata_field] Attempted to get field: '{}' but the type was '{}'", field_name, lua_typename(get_lua_instance().get_lua_state(), pushed_type))); } diff --git a/deps/first/LuaMadeSimple/src/LuaMadeSimple.cpp b/deps/first/LuaMadeSimple/src/LuaMadeSimple.cpp index 411ddfe7..5106a244 100644 --- a/deps/first/LuaMadeSimple/src/LuaMadeSimple.cpp +++ b/deps/first/LuaMadeSimple/src/LuaMadeSimple.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -209,7 +208,7 @@ namespace RC::LuaMadeSimple } else { - get_lua_instance().throw_error(std::format("[get_string_field] Attempted to get field: '{}' but the type was '{}'", + get_lua_instance().throw_error(fmt::format("[get_string_field] Attempted to get field: '{}' but the type was '{}'", field_name, lua_typename(get_lua_instance().get_lua_state(), pushed_type))); } @@ -232,7 +231,7 @@ namespace RC::LuaMadeSimple } else { - get_lua_instance().throw_error(std::format("[get_int_field] Attempted to get field: '{}' but the type was '{}'", + get_lua_instance().throw_error(fmt::format("[get_int_field] Attempted to get field: '{}' but the type was '{}'", field_name, lua_typename(get_lua_instance().get_lua_state(), lua_type(get_lua_instance().get_lua_state(), -1)))); } @@ -255,7 +254,7 @@ namespace RC::LuaMadeSimple } else { - get_lua_instance().throw_error(std::format("[get_float_field] Attempted to get field: '{}' but the type was '{}'", + get_lua_instance().throw_error(fmt::format("[get_float_field] Attempted to get field: '{}' but the type was '{}'", field_name, lua_typename(get_lua_instance().get_lua_state(), lua_type(get_lua_instance().get_lua_state(), -1)))); } @@ -278,7 +277,7 @@ namespace RC::LuaMadeSimple } else { - get_lua_instance().throw_error(std::format("[get_table_field] Attempted to get field: '{}' but the type was '{}'", + get_lua_instance().throw_error(fmt::format("[get_table_field] Attempted to get field: '{}' but the type was '{}'", field_name, lua_typename(get_lua_instance().get_lua_state(), pushed_type))); } @@ -338,11 +337,11 @@ namespace RC::LuaMadeSimple { const char* status_message = lua_tostring(get_lua_state(), -1); lua_pop(get_lua_state(), 1); - return std::format("{} => {}", status_to_string(status), status_message); + return fmt::format("{} => {}", status_to_string(status), status_message); } else { - return std::format("{} => No message", status_to_string(status)); + return fmt::format("{} => No message", status_to_string(status)); } } @@ -425,12 +424,12 @@ namespace RC::LuaMadeSimple { if (int status = luaL_loadfile(get_lua_state(), file_name_and_path.data()); status != LUA_OK) { - throw std::runtime_error{std::format("[Lua::execute_file] luaL_loadfile returned {}", resolve_status_message(status))}; + throw std::runtime_error{fmt::format("[Lua::execute_file] luaL_loadfile returned {}", resolve_status_message(status))}; } if (int status = lua_pcall(get_lua_state(), 0, LUA_MULTRET, 0); status != LUA_OK) { - throw std::runtime_error{std::format("[Lua::execute_file] lua_pcall returned {}", resolve_status_message(status))}; + throw std::runtime_error{fmt::format("[Lua::execute_file] lua_pcall returned {}", resolve_status_message(status))}; } } @@ -446,12 +445,12 @@ namespace RC::LuaMadeSimple { if (int status = luaL_loadstring(get_lua_state(), code.data()); status != LUA_OK) { - throw_error(std::format("[Lua::execute_string] luaL_loadstring returned {}", resolve_status_message(status))); + throw_error(fmt::format("[Lua::execute_string] luaL_loadstring returned {}", resolve_status_message(status))); } if (int status = lua_pcall(get_lua_state(), 0, LUA_MULTRET, 0); status != LUA_OK) { - throw_error(std::format("[Lua::execute_string] lua_pcall returned {}", resolve_status_message(status))); + throw_error(fmt::format("[Lua::execute_string] lua_pcall returned {}", resolve_status_message(status))); } } @@ -716,7 +715,7 @@ namespace RC::LuaMadeSimple // Intentionally only cleaning the stack if the type wasn't TFUNCTION // This is because the TFUNCTION is needed on the stack later lua_pop(get_lua_state(), 1); - throw std::runtime_error{std::format("[Lua::prepare_function_call] lua_getglobal returned !LUA_TFUNCTION, type returned: {}", + throw std::runtime_error{fmt::format("[Lua::prepare_function_call] lua_getglobal returned !LUA_TFUNCTION, type returned: {}", lua_typename(get_lua_state(), status))}; } } @@ -725,7 +724,7 @@ namespace RC::LuaMadeSimple { if (int status = lua_pcall(get_lua_state(), num_params, num_return_values, 0); status != LUA_OK) { - throw std::runtime_error{std::format("[Lua::call_function] lua_pcall returned {}", resolve_status_message(status))}; + throw std::runtime_error{fmt::format("[Lua::call_function] lua_pcall returned {}", resolve_status_message(status))}; } } @@ -802,7 +801,7 @@ namespace RC::LuaMadeSimple if (final_message.empty() || final_message == error_message + "\nstack traceback:") { - final_message = std::format("{}\nNo traceback", error_message); + final_message = fmt::format("{}\nNo traceback", error_message); } // Clearing the Lua stack because we're treating errors as non-fatal, but we still need to clean everything up @@ -866,19 +865,19 @@ namespace RC::LuaMadeSimple if (func_type == Lua::LuaFunctionType::Local && !lua_isuserdata(lua_state, 1)) { - throw_error(lua_state, std::format("[process_lua_function] A function requiring userdata as param #1 was called without userdata at param #1")); + throw_error(lua_state, fmt::format("[process_lua_function] A function requiring userdata as param #1 was called without userdata at param #1")); } if (!lua_instances.contains(lua_state)) { - throw_error(lua_state, std::format("[process_lua_function] The lua state '{}' has no instance inside lua_instances unordered map", (void*)lua_state)); + throw_error(lua_state, fmt::format("[process_lua_function] The lua state '{}' has no instance inside lua_instances unordered map", (void*)lua_state)); } Lua& data_owner = *lua_instances.find(lua_state)->second; if (func_id > lua_functions.size()) { - throw_error(lua_state, std::format("[process_lua_function] There was no global function with the id '{}' inside the lua_functions vector", func_id)); + throw_error(lua_state, fmt::format("[process_lua_function] There was no global function with the id '{}' inside the lua_functions vector", func_id)); } if (!lua_functions[func_id].has_value()) diff --git a/deps/first/LuaMadeSimple/xmake.lua b/deps/first/LuaMadeSimple/xmake.lua index 60b4d303..441939d4 100644 --- a/deps/first/LuaMadeSimple/xmake.lua +++ b/deps/first/LuaMadeSimple/xmake.lua @@ -11,4 +11,5 @@ target(projectName) add_files("src/**.cpp") - add_deps("LuaRaw", { public = true }) \ No newline at end of file + add_deps("LuaRaw", { public = true }) + add_packages("fmt") \ No newline at end of file diff --git a/deps/first/SinglePassSigScanner/src/SinglePassSigScanner.cpp b/deps/first/SinglePassSigScanner/src/SinglePassSigScanner.cpp index ca8e7683..dc19d25a 100644 --- a/deps/first/SinglePassSigScanner/src/SinglePassSigScanner.cpp +++ b/deps/first/SinglePassSigScanner/src/SinglePassSigScanner.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -308,7 +309,7 @@ namespace RC return {"Max"}; } - throw std::runtime_error{std::format("Invalid param for ScanTargetToString, param: {}", static_cast(scan_target))}; + throw std::runtime_error{fmt::format("Invalid param for ScanTargetToString, param: {}", static_cast(scan_target))}; } auto ScanTargetToString(size_t scan_target) -> std::string @@ -441,7 +442,7 @@ namespace RC if (pattern.length() < 1 || pattern[0] == '?') { - throw std::runtime_error{std::format("[make_mask] A pattern cannot start with a wildcard.\nPattern: {}", pattern)}; + throw std::runtime_error{fmt::format("[make_mask] A pattern cannot start with a wildcard.\nPattern: {}", pattern)}; } for (size_t i = 0; i < pattern.length(); i++) @@ -545,7 +546,7 @@ namespace RC //{ // if (!std::regex_search(signature_data.signature, signature_validity_regex)) // { - // throw std::runtime_error{std::format("[SinglePassSigScanner::start_scan] A signature is improperly formatted. Signature: {}", signature_data.signature)}; + // throw std::runtime_error{fmt::format("[SinglePassSigScanner::start_scan] A signature is improperly formatted. Signature: {}", signature_data.signature)}; // } //} diff --git a/deps/first/SinglePassSigScanner/xmake.lua b/deps/first/SinglePassSigScanner/xmake.lua index 91b91390..6639bfdb 100644 --- a/deps/first/SinglePassSigScanner/xmake.lua +++ b/deps/first/SinglePassSigScanner/xmake.lua @@ -11,4 +11,5 @@ target(projectName) add_files("src/**.cpp") - add_deps("Profiler") \ No newline at end of file + add_deps("Profiler") + add_packages("fmt") \ No newline at end of file