From 1741cebb1f7f10c0683ec2ef714efc19e6d05b8f Mon Sep 17 00:00:00 2001 From: Yangff Date: Mon, 19 Feb 2024 04:31:17 -0600 Subject: [PATCH] new string handling and ... maybe no need for fmt? --- UE4SS/CMakeLists.txt | 2 +- UE4SS/include/ExceptionHandling.hpp | 2 +- UE4SS/include/LuaType/LuaUObject.hpp | 16 +- UE4SS/include/UE4SSProgram.hpp | 4 +- UE4SS/src/EntryLinux.cpp | 4 +- UE4SS/src/GUI/BPMods.cpp | 2 +- UE4SS/src/GUI/GUI.cpp | 2 +- UE4SS/src/GUI/UFunctionCallerWidget.cpp | 4 +- UE4SS/src/LuaLibrary.cpp | 6 +- UE4SS/src/LuaType/LuaFName.cpp | 4 +- UE4SS/src/LuaType/LuaFOutputDevice.cpp | 2 +- UE4SS/src/LuaType/LuaFText.cpp | 4 +- UE4SS/src/LuaType/LuaTArray.cpp | 2 +- UE4SS/src/LuaType/LuaUEnum.cpp | 6 +- UE4SS/src/LuaType/LuaUObject.cpp | 4 +- UE4SS/src/LuaType/LuaUScriptStruct.cpp | 2 +- UE4SS/src/LuaType/LuaXProperty.cpp | 6 +- UE4SS/src/Mod/CppMod.cpp | 4 +- UE4SS/src/Mod/LuaMod.cpp | 102 ++++--- UE4SS/src/Mod/Mod.cpp | 1 - UE4SS/src/ObjectDumper/ObjectToString.cpp | 10 +- UE4SS/src/SDKGenerator/Common.cpp | 49 ++-- UE4SS/src/SDKGenerator/Generator.cpp | 38 +-- UE4SS/src/SDKGenerator/JSONDumper.cpp | 18 +- UE4SS/src/SDKGenerator/TMapOverrideGen.cpp | 8 +- UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp | 167 ++++++------ UE4SS/src/UE4SSProgram.cpp | 19 +- deps/first/DynamicOutput/CMakeLists.txt | 2 +- .../include/DynamicOutput/Output.hpp | 56 ++-- deps/first/File/include/File/Macros.hpp | 126 +++++---- deps/first/File/src/FileType/WinFile.cpp | 2 +- deps/first/Helpers/include/Helpers/Format.hpp | 87 +----- deps/first/Helpers/include/Helpers/String.hpp | 255 ++++++++++++++++-- .../SigScanner/SinglePassSigScannerWin32.hpp | 2 +- .../src/SinglePassSigScannerWin32.cpp | 4 +- deps/first/Unreal | 2 +- deps/third/CMakeLists.txt | 10 +- 37 files changed, 601 insertions(+), 433 deletions(-) diff --git a/UE4SS/CMakeLists.txt b/UE4SS/CMakeLists.txt index a522dd7cc..17f1d4ca0 100644 --- a/UE4SS/CMakeLists.txt +++ b/UE4SS/CMakeLists.txt @@ -178,7 +178,7 @@ target_link_libraries(${TARGET} PUBLIC Unreal SinglePassSigScanner LuaMadeSimple Function IniParser JSON Constructs Helpers - MProgram ScopedTimer Profiler fmt + MProgram ScopedTimer Profiler ) if (WIN32) target_link_libraries(${TARGET} PUBLIC diff --git a/UE4SS/include/ExceptionHandling.hpp b/UE4SS/include/ExceptionHandling.hpp index 6ab016086..5b9315866 100644 --- a/UE4SS/include/ExceptionHandling.hpp +++ b/UE4SS/include/ExceptionHandling.hpp @@ -8,7 +8,7 @@ #define UE4SS_ERROR_OUTPUTTER() \ if (!Output::has_internal_error()) \ { \ - Output::send(SYSSTR("Error: {}\n"), to_generic_string(e.what())); \ + Output::send(SYSSTR("Error: {}\n"), to_system(e.what())); \ } \ else \ { \ diff --git a/UE4SS/include/LuaType/LuaUObject.hpp b/UE4SS/include/LuaType/LuaUObject.hpp index e92605091..4fcc724c9 100644 --- a/UE4SS/include/LuaType/LuaUObject.hpp +++ b/UE4SS/include/LuaType/LuaUObject.hpp @@ -462,7 +462,7 @@ namespace RC::LuaType { lua.throw_error("Function 'GetProperty' requires a string as the first parameter"); } - SystemStringType property_name = to_generic_string(lua.get_string(2)); + auto property_name = to_system(lua.get_string(2)); auto reflection_table = lua.get_table(); const auto& reflected_object = reflection_table.get_userdata_field("ReflectedObject").get_remote_cpp_object(); @@ -478,7 +478,7 @@ namespace RC::LuaType { obj_as_struct = reflected_object->GetClassPrivate(); } - auto* property = obj_as_struct->FindProperty(Unreal::FName(SystemStringToUEString(property_name))); + auto* property = obj_as_struct->FindProperty(Unreal::FName(to_ue(property_name))); construct_xproperty(lua, property); return 1; @@ -586,7 +586,7 @@ No overload found for function 'UObject.ProcessConsoleExec'. { lua.throw_error(error_overload_not_found); } - auto cmd = to_generic_string(lua.get_string()); + auto cmd = to_system(lua.get_string()); if (lua.get_stack_size() < 2) { @@ -601,7 +601,7 @@ No overload found for function 'UObject.ProcessConsoleExec'. auto executor = lua.get_userdata(); auto ar = Unreal::FOutputDevice{}; - auto return_value = lua_object.get_remote_cpp_object()->ProcessConsoleExec(SystemStringToUEString(cmd).c_str(), ar, executor.get_remote_cpp_object()); + auto return_value = lua_object.get_remote_cpp_object()->ProcessConsoleExec(to_ue_string(cmd).c_str(), ar, executor.get_remote_cpp_object()); lua.set_bool(return_value); return 1; @@ -641,7 +641,7 @@ No overload found for function 'UObject.ProcessConsoleExec'. { auto& lua_object = lua.get_userdata(); - const SystemStringType& member_name = to_generic_string(lua.get_string()); + auto member_name = to_system_string(lua.get_string()); // If nullptr then we assume the UObject wasn't found so lets return an invalid UObject to Lua // This allows the safe chaining of "__index" as long as the Lua script checks ":IsValid()" before using the object @@ -666,7 +666,7 @@ No overload found for function 'UObject.ProcessConsoleExec'. return; } - Unreal::FName property_name = Unreal::FName(SystemStringToUEString(member_name)); + Unreal::FName property_name = Unreal::FName(to_ue(member_name)); Unreal::FField* field = LuaCustomProperty::StaticStorage::property_list.find_or_nullptr(lua_object.get_remote_cpp_object(), member_name); if (!field) @@ -777,10 +777,10 @@ No overload found for function 'UObject.ProcessConsoleExec'. { // We can either throw an error and kill the execution /**/ - SystemStringType property_type_name = UEStringToSystemString(property_type.ToString()); + auto property_type_name = to_string(property_type.ToString()); lua.throw_error(std::format( "[LocalUnrealParam::prepare_to_handle] Tried accessing unreal property without a registered handler. Property type '{}' not supported.", - to_string(property_type_name))); + property_type_name)); //*/ // Or we can treat unhandled property types as some sort of generic type diff --git a/UE4SS/include/UE4SSProgram.hpp b/UE4SS/include/UE4SSProgram.hpp index 903349104..4e5f6a8bb 100644 --- a/UE4SS/include/UE4SSProgram.hpp +++ b/UE4SS/include/UE4SSProgram.hpp @@ -277,10 +277,10 @@ namespace RC template static auto find_mod_by_name(SystemStringViewType mod_name, IsInstalled is_installed = IsInstalled::No, IsStarted is_started = IsStarted::No) -> T* { - return find_mod_by_name(to_generic_string(mod_name), is_installed, is_started); + return find_mod_by_name(to_system(mod_name), is_installed, is_started); }; - RC_UE4SS_API static auto find_lua_mod_by_name(UEViewType mod_name, IsInstalled = IsInstalled::No, IsStarted = IsStarted::No) -> LuaMod*; + RC_UE4SS_API static auto find_lua_mod_by_name(UEStringViewType mod_name, IsInstalled = IsInstalled::No, IsStarted = IsStarted::No) -> LuaMod*; RC_UE4SS_API static auto find_lua_mod_by_name(SystemStringViewType mod_name, IsInstalled = IsInstalled::No, IsStarted = IsStarted::No) -> LuaMod*; static auto static_cleanup() -> void; RC_UE4SS_API static auto get_program() -> UE4SSProgram& diff --git a/UE4SS/src/EntryLinux.cpp b/UE4SS/src/EntryLinux.cpp index 15cdce759..349affc86 100644 --- a/UE4SS/src/EntryLinux.cpp +++ b/UE4SS/src/EntryLinux.cpp @@ -36,7 +36,7 @@ void UE4SS_Start() fprintf(stderr, "%s\n", e.what()); } #endif - SystemStringType ue4sspath = to_generic_string(dl_info.dli_fname); + auto ue4sspath = to_system_string(dl_info.dli_fname); auto program = new UE4SSProgram(ue4sspath, {}); // use pthread here @@ -50,7 +50,7 @@ void UE4SS_Start() // Logging will only happen to the debug console but it's something at least if (!Output::has_internal_error()) { - Output::send(SYSSTR("Fatal Error: {}\n"), to_generic_string(e->get_message())); + Output::send(SYSSTR("Fatal Error: {}\n"), e->get_message()); } else { diff --git a/UE4SS/src/GUI/BPMods.cpp b/UE4SS/src/GUI/BPMods.cpp index 3ac0b87ec..1f1e48f1b 100644 --- a/UE4SS/src/GUI/BPMods.cpp +++ b/UE4SS/src/GUI/BPMods.cpp @@ -113,7 +113,7 @@ namespace RC::GUI::BPMods const auto& mod_button = mod_info.ModButtons[i2]; if (ImGui::Button(std::format("{}", mod_button).c_str())) { - Output::send(SYSSTR("Mod button {} hit.\n"), to_generic_string(mod_button)); + Output::send(SYSSTR("Mod button {} hit.\n"), to_system(mod_button)); mod_info.ModActor->ModMenuButtonPressed(static_cast(i2)); } } diff --git a/UE4SS/src/GUI/GUI.cpp b/UE4SS/src/GUI/GUI.cpp index 422aef27f..be8955367 100644 --- a/UE4SS/src/GUI/GUI.cpp +++ b/UE4SS/src/GUI/GUI.cpp @@ -328,7 +328,7 @@ namespace RC::GUI { if (!Output::has_internal_error()) { - Output::send(SYSSTR("Error: {}\n"), to_generic_string(e.what())); + Output::send(SYSSTR("Error: {}\n"), to_system(e.what())); } else { diff --git a/UE4SS/src/GUI/UFunctionCallerWidget.cpp b/UE4SS/src/GUI/UFunctionCallerWidget.cpp index a0528ea79..c2521cadd 100644 --- a/UE4SS/src/GUI/UFunctionCallerWidget.cpp +++ b/UE4SS/src/GUI/UFunctionCallerWidget.cpp @@ -164,7 +164,7 @@ namespace RC::GUI } auto function = m_currently_selected_function->function; - auto cmd = std::format(SYSSTR("{}"), UEStringToSystemString(function->GetName())); + auto cmd = std::format(SYSSTR("{}"), to_system(function->GetName())); for (const auto& param : m_params_for_selected_function) { cmd.append(std::format(SYSSTR(" {}"), to_wstring(param.value_from_ui))); @@ -245,7 +245,7 @@ namespace RC::GUI static auto get_typeless_object_name(UObject* object) -> std::string { - auto object_name = UEStringToSystemString(object->GetFullName()); + auto object_name = to_system(object->GetFullName()); auto object_name_type_space_location = object_name.find(" "); if (object_name_type_space_location == object_name.npos) { diff --git a/UE4SS/src/LuaLibrary.cpp b/UE4SS/src/LuaLibrary.cpp index 4ad9cd0d9..4b19cc9ef 100644 --- a/UE4SS/src/LuaLibrary.cpp +++ b/UE4SS/src/LuaLibrary.cpp @@ -50,7 +50,7 @@ namespace RC::LuaLibrary lua.get_type_string())); } - SystemStringType format = to_generic_string(lua.get_string()); + auto format = to_system_string(lua.get_string()); // The output device is at the top of the stack, therefore we must call this function after retrieving all of the params. auto* output_device = get_outputdevice_ref(lua); @@ -61,7 +61,7 @@ namespace RC::LuaLibrary Output::send(formatted_string); if (output_device) { - output_device->Log(SystemStringToUEString(formatted_string).c_str()); + output_device->Log(to_ue(formatted_string).c_str()); } } else if (stack_size >= 2) @@ -107,7 +107,7 @@ namespace RC::LuaLibrary // Logging will only happen to the debug console but it's something at least if (!Output::has_internal_error()) { - Output::send(SYSSTR("Error: {}\n"), to_generic_string(e)); + Output::send(SYSSTR("Error: {}\n"), to_system(e)); } else { diff --git a/UE4SS/src/LuaType/LuaFName.cpp b/UE4SS/src/LuaType/LuaFName.cpp index cc9db044d..9353a175c 100644 --- a/UE4SS/src/LuaType/LuaFName.cpp +++ b/UE4SS/src/LuaType/LuaFName.cpp @@ -64,7 +64,7 @@ No overload found for function 'FName'. Unreal::EFindName find_type{Unreal::EFindName::FNAME_Add}; if (lua.is_string()) { - name_string = to_generic_string(lua.get_string()); + name_string = to_system(lua.get_string()); } else if (lua.is_integer()) { @@ -94,7 +94,7 @@ No overload found for function 'FName'. } else { - LuaType::FName::construct(lua, Unreal::FName(SystemStringToUEString(name_string), find_type)); + LuaType::FName::construct(lua, Unreal::FName(to_ue(name_string), find_type)); } return 1; diff --git a/UE4SS/src/LuaType/LuaFOutputDevice.cpp b/UE4SS/src/LuaType/LuaFOutputDevice.cpp index 32f711ac3..7c8566c17 100644 --- a/UE4SS/src/LuaType/LuaFOutputDevice.cpp +++ b/UE4SS/src/LuaType/LuaFOutputDevice.cpp @@ -65,7 +65,7 @@ No overload found for function 'Log'. } auto message = lua.get_string(); - lua_object.get_remote_cpp_object()->Log(SystemStringToUEString(to_generic_string(message)).c_str()); + lua_object.get_remote_cpp_object()->Log(to_ue(to_system(message)).c_str()); return 0; }); diff --git a/UE4SS/src/LuaType/LuaFText.cpp b/UE4SS/src/LuaType/LuaFText.cpp index 9883b02fb..48a94bb07 100644 --- a/UE4SS/src/LuaType/LuaFText.cpp +++ b/UE4SS/src/LuaType/LuaFText.cpp @@ -61,14 +61,14 @@ No overload found for function 'FText'. SystemStringType text_string{}; if (lua.is_string()) { - text_string = to_generic_string(lua.get_string()); + text_string = to_system(lua.get_string()); } else { lua.throw_error(error_overload_not_found); } - LuaType::FText::construct(lua, Unreal::FText(SystemStringToUEString(text_string))); + LuaType::FText::construct(lua, Unreal::FText(to_ue(text_string))); return 1; }); diff --git a/UE4SS/src/LuaType/LuaTArray.cpp b/UE4SS/src/LuaType/LuaTArray.cpp index eb517dd36..9e1d69575 100644 --- a/UE4SS/src/LuaType/LuaTArray.cpp +++ b/UE4SS/src/LuaType/LuaTArray.cpp @@ -23,7 +23,7 @@ namespace RC::LuaType if (!lua_object.m_inner_property) { - Output::send(SYSSTR("TArray::construct: m_inner_property is nullptr for {}"), UEStringToSystemString(lua_object.m_property->GetFullName())); + Output::send(SYSSTR("TArray::construct: m_inner_property is nullptr for {}"), to_system(lua_object.m_property->GetFullName())); } auto metatable_name = ClassName::ToString(); diff --git a/UE4SS/src/LuaType/LuaUEnum.cpp b/UE4SS/src/LuaType/LuaUEnum.cpp index e02b10b65..ebe3480b6 100644 --- a/UE4SS/src/LuaType/LuaUEnum.cpp +++ b/UE4SS/src/LuaType/LuaUEnum.cpp @@ -162,7 +162,7 @@ No overload found for function 'UEnum.InsertIntoNames'. // P1 (Name), string if (lua.is_string()) { - param_name = to_generic_string(lua.get_string()); + param_name = to_system(lua.get_string()); } else { @@ -195,7 +195,7 @@ No overload found for function 'UEnum.InsertIntoNames'. param_shift = lua.get_bool(); } - const Unreal::FName key{SystemStringToUEString(param_name), Unreal::FNAME_Add}; + const Unreal::FName key{to_ue(param_name), Unreal::FNAME_Add}; const auto pair = Unreal::TPair{key, param_value}; lua_object.get_remote_cpp_object()->InsertIntoNames(pair, param_index, param_shift); @@ -243,7 +243,7 @@ No overload found for function 'UEnum.EditNameAt'. lua.throw_error("'UEnum.EditNameAt' could not load parameter for \"NewName\""); } - Unreal::FName new_key = Unreal::FName(SystemStringToUEString(to_generic_string(param_new_name)), Unreal::FNAME_Add); + Unreal::FName new_key = Unreal::FName(to_ue(to_system(param_new_name)), Unreal::FNAME_Add); lua_object.get_remote_cpp_object()->EditNameAt(param_index, new_key); return 0; diff --git a/UE4SS/src/LuaType/LuaUObject.cpp b/UE4SS/src/LuaType/LuaUObject.cpp index 18f4744fe..e92bbcebe 100644 --- a/UE4SS/src/LuaType/LuaUObject.cpp +++ b/UE4SS/src/LuaType/LuaUObject.cpp @@ -1106,7 +1106,7 @@ namespace RC::LuaType if (params.lua.is_string()) { auto lua_string = params.lua.get_string(); - auto fstring = Unreal::FString{ SystemStringToUEString(to_generic_string(lua_string)).c_str() }; + auto fstring = Unreal::FString{ to_ue(to_system(lua_string)).c_str() }; *string = fstring; } else if (params.lua.is_userdata()) @@ -1232,7 +1232,7 @@ No overload found for function 'IsA'. } else if (lua.is_string()) { - auto* object_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, SystemStringToUEString(to_generic_string(lua.get_string()))); + auto* object_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, to_ue(to_system(lua.get_string()))); lua.set_bool(is_a_internal(lua, object, object_class)); } else diff --git a/UE4SS/src/LuaType/LuaUScriptStruct.cpp b/UE4SS/src/LuaType/LuaUScriptStruct.cpp index 510a581ed..e731addbc 100644 --- a/UE4SS/src/LuaType/LuaUScriptStruct.cpp +++ b/UE4SS/src/LuaType/LuaUScriptStruct.cpp @@ -195,7 +195,7 @@ namespace RC::LuaType { auto& lua_object = lua.get_userdata(); - Unreal::FName property_name = Unreal::FName(SystemStringToUEString(to_generic_string(lua.get_string()))); + Unreal::FName property_name = Unreal::FName(to_ue(to_system(lua.get_string()))); // Check if property_name is 'NONE' if (property_name.GetComparisonIndex() == 0) diff --git a/UE4SS/src/LuaType/LuaXProperty.cpp b/UE4SS/src/LuaType/LuaXProperty.cpp index 9412b0a60..eb02eacf9 100644 --- a/UE4SS/src/LuaType/LuaXProperty.cpp +++ b/UE4SS/src/LuaType/LuaXProperty.cpp @@ -114,7 +114,7 @@ namespace RC::LuaType if (lua_object.get_remote_cpp_object()) { // Set the return value to the ansi version of the full name - lua.set_string(UEStringToSystemString(lua_object.get_remote_cpp_object()->GetFullName()).c_str()); + lua.set_string(to_system(lua_object.get_remote_cpp_object()->GetFullName()).c_str()); } else { @@ -227,7 +227,7 @@ No overload found for function 'ImportText'. SystemStringType buffer; if (lua.is_string()) { - buffer = to_generic_string(lua.get_string()); + buffer = to_system(lua.get_string()); } else { @@ -261,7 +261,7 @@ No overload found for function 'ImportText'. } auto* owner_object = lua.get_userdata().get_remote_cpp_object(); - lua_object.get_remote_cpp_object()->ImportText(SystemStringToUEString(buffer).c_str(), data, port_flags, owner_object, nullptr); + lua_object.get_remote_cpp_object()->ImportText(to_ue(buffer).c_str(), data, port_flags, owner_object, nullptr); return 0; }); diff --git a/UE4SS/src/Mod/CppMod.cpp b/UE4SS/src/Mod/CppMod.cpp index 92da147be..e360799b0 100644 --- a/UE4SS/src/Mod/CppMod.cpp +++ b/UE4SS/src/Mod/CppMod.cpp @@ -20,7 +20,7 @@ namespace RC if (!std::filesystem::exists(m_dlls_path)) { - Output::send(SYSSTR("Could not find the dlls folder for mod {}\n"), to_generic_string(m_mod_name)); + Output::send(SYSSTR("Could not find the dlls folder for mod {}\n"), to_system(m_mod_name)); set_installable(false); return; } @@ -69,7 +69,7 @@ namespace RC Output::send(SYSSTR("Failed to load dll <{}> for mod {}, because: {}\n"), (std::filesystem::path {m_dlls_path} / CONCATENATE_WIDE_STRING("main", DLLEXT)).generic_string() + "\n", m_mod_name, - to_generic_string(e.what())); + to_system(e.what())); } else { diff --git a/UE4SS/src/Mod/LuaMod.cpp b/UE4SS/src/Mod/LuaMod.cpp index 516997707..6fe566844 100644 --- a/UE4SS/src/Mod/LuaMod.cpp +++ b/UE4SS/src/Mod/LuaMod.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #ifdef HAS_INPUT @@ -265,8 +264,8 @@ namespace RC // If the type wasn't supported then we simply clean the Lua stack, output a warning and then do nothing lua_data.lua.discard_value(); - auto parameter_type_name = UEStringToSystemString(property_type_name.ToString()); - auto parameter_name = UEStringToSystemString(lua_data.return_property->GetName()); + auto parameter_type_name = to_system(property_type_name.ToString()); + auto parameter_name = to_system(lua_data.return_property->GetName()); Output::send( SYSSTR("Tried altering return value of a hooked UFunction without a registered handler for return type Return property '{}' of type " @@ -873,7 +872,7 @@ No overload found for function 'StaticFindObject'. // Ignores any params after P1 if (lua.is_string()) { - Unreal::UObject* object = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, SystemStringToUEString(to_generic_string(lua.get_string()))); + Unreal::UObject* object = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, to_ue(to_system(lua.get_string()))); // Construct a Lua object of type 'UObject' // Auto constructing is nullptr safe @@ -933,7 +932,7 @@ No overload found for function 'StaticFindObject'. // P3 (Name), string if (lua.is_string()) { - param_name = to_generic_string(lua.get_string()); + param_name = to_system(lua.get_string()); } else { @@ -947,7 +946,7 @@ No overload found for function 'StaticFindObject'. } // There's no error if P4 isn't a bool, simply ignore all parameters after P3 - Unreal::UObject* object = Unreal::UObjectGlobals::StaticFindObject(param_class, param_in_outer, SystemStringToUEString(param_name), param_exact_class); + Unreal::UObject* object = Unreal::UObjectGlobals::StaticFindObject(param_class, param_in_outer, to_ue(param_name), param_exact_class); // Construct a Lua object of type 'UObject' // Auto constructing is nullptr safe @@ -975,7 +974,7 @@ No overload found for function 'FindFirstOf'. // Ignores any params after P1 if (lua.is_string()) { - Unreal::UObject* object = Unreal::UObjectGlobals::FindFirstOf(SystemStringToUEString(to_generic_string(lua.get_string()))); + Unreal::UObject* object = Unreal::UObjectGlobals::FindFirstOf(to_ue(to_system(lua.get_string()))); // Construct a Lua object of type 'UObject' // Auto constructing is nullptr safe @@ -1152,7 +1151,7 @@ No overload found for function 'RegisterKeyBindAsync'. } catch (std::runtime_error& e) { - Output::send(SYSSTR("{}\n"), to_generic_string(lua.handle_error(e.what()))); + Output::send(SYSSTR("{}\n"), to_system(lua.handle_error(e.what()))); } }; @@ -1271,7 +1270,7 @@ No overload found for function 'RegisterKeyBind'. } catch (std::runtime_error& e) { - Output::send(SYSSTR("{}\n"), to_generic_string(lua.handle_error(e.what()))); + Output::send(SYSSTR("{}\n"), to_system(lua.handle_error(e.what()))); } }; @@ -1371,8 +1370,8 @@ No overload found for function 'UnregisterHook'. lua.throw_error(error_overload_not_found); } - UEStringType function_name = to_u16string(lua.get_string()); - UEStringType function_name_no_prefix = function_name.substr(function_name.find_first_of(STR(" ")) + 1, function_name.size()); + auto function_name = to_u16string(lua.get_string()); + auto function_name_no_prefix = function_name.substr(function_name.find_first_of(STR(" ")) + 1, function_name.size()); Unreal::UFunction* unreal_function = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, function_name_no_prefix); if (!unreal_function) @@ -1433,7 +1432,7 @@ No overload found for function 'UnregisterHook'. } else { - if (auto callback_data_it = LuaMod::m_script_hook_callbacks.find(UEStringToSystemString(unreal_function->GetFullName())); + if (auto callback_data_it = LuaMod::m_script_hook_callbacks.find(to_system(unreal_function->GetFullName())); callback_data_it != LuaMod::m_script_hook_callbacks.end()) { Output::send(SYSSTR("Unregistering script hook with id: {}\n"), post_id); @@ -1734,12 +1733,12 @@ No overload found for function 'RegisterCustomProperty'. }; // Always required, for all property types - property_info.name = to_generic_string(lua_table.get_string_field("Name")); + property_info.name = to_system(lua_table.get_string_field("Name")); property_info.type.name = lua_table.get_table_field("Type").get_string_field("Name"); property_info.type.size = verify_and_convert_int64_to_int32("Type", "Size"); property_info.type.ffieldclass_pointer = reinterpret_cast(lua_table.get_table_field("Type").get_int_field("FFieldClassPointer")); property_info.type.static_pointer = reinterpret_cast(lua_table.get_table_field("Type").get_int_field("StaticPointer")); - property_info.belongs_to_class = to_generic_string(lua_table.get_string_field("BelongsToClass")); + property_info.belongs_to_class = to_system(lua_table.get_string_field("BelongsToClass")); std::string oi_property_name; int32_t oi_relative_offset{}; @@ -1782,7 +1781,7 @@ No overload found for function 'RegisterCustomProperty'. lua.throw_error("Parameter #1 for function 'RegisterCustomProperty'. The table is missing required fields."); } - Unreal::UClass* belongs_to_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, SystemStringToUEString(property_info.belongs_to_class)); + Unreal::UClass* belongs_to_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, to_ue(property_info.belongs_to_class)); if (!belongs_to_class) { lua.throw_error("Tried to 'RegisterCustomProperty' but 'BelongsToClass' could not be found"); @@ -1790,7 +1789,7 @@ No overload found for function 'RegisterCustomProperty'. if (property_info.offset_internal_is_table) { - auto name = Unreal::FName(SystemStringToUEString(oi_property_name)); + auto name = Unreal::FName(to_ue(oi_property_name)); Unreal::FProperty* oi_property = belongs_to_class->FindProperty(name); if (!oi_property) { @@ -1886,7 +1885,7 @@ No overload found for function 'NotifyOnNewObject'. lua.throw_error(error_overload_not_found); } - SystemStringType class_name = to_generic_string(lua.get_string()); + auto class_name = to_system(lua.get_string()); if (!lua.is_function()) { @@ -1901,7 +1900,7 @@ No overload found for function 'NotifyOnNewObject'. // Take a reference to the Lua function (it also pops it of the stack) const int32_t lua_callback_registry_index = hook_lua->registry().make_ref(); - Unreal::UClass* instance_of_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, SystemStringToUEString(class_name)); + Unreal::UClass* instance_of_class = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, to_ue(class_name)); LuaMod::m_static_construct_object_lua_callbacks.emplace_back( LuaMod::LuaCallbackData{*hook_lua, @@ -1922,7 +1921,7 @@ No overload found for function 'RegisterCustomEvent'. lua.throw_error(error_overload_not_found); } - SystemStringType event_name = to_generic_string(lua.get_string()); + auto event_name = to_system(lua.get_string()); if (!lua.is_function()) { @@ -1958,7 +1957,7 @@ No overload found for function 'UnregisterCustomEvent'. { lua.throw_error(error_overload_not_found); } - auto custom_event_name = to_generic_string(lua.get_string()); + auto custom_event_name = to_system_string(lua.get_string()); LuaMod::m_custom_event_callbacks.erase(custom_event_name); @@ -2501,7 +2500,7 @@ No overload found for function 'RegisterConsoleCommandGlobalHandler'. { throw std::runtime_error{error_overload_not_found}; } - auto command_name = to_generic_string(lua.get_string()); + auto command_name = to_system_string(lua.get_string()); if (!lua.is_function()) { @@ -2536,7 +2535,7 @@ No overload found for function 'RegisterConsoleCommandHandler'. { throw std::runtime_error{error_overload_not_found}; } - auto command_name = to_generic_string(lua.get_string()); + auto command_name = to_system_string(lua.get_string()); if (!lua.is_function()) { @@ -2981,8 +2980,8 @@ No overload found for function 'RegisterHook'. lua.throw_error(error_overload_not_found); } - SystemStringType function_name = to_generic_string(lua.get_string()); - SystemStringType function_name_no_prefix = function_name.substr(function_name.find_first_of(SYSSTR("/")), function_name.size()); + auto function_name = to_system(lua.get_string()); + auto function_name_no_prefix = function_name.substr(function_name.find_first_of(SYSSTR("/")), function_name.size()); if (!lua.is_function()) { @@ -3012,7 +3011,7 @@ No overload found for function 'RegisterHook'. has_post_callback = true; } - Unreal::UFunction* unreal_function = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, SystemStringToUEString(function_name_no_prefix)); + Unreal::UFunction* unreal_function = Unreal::UObjectGlobals::StaticFindObject(nullptr, nullptr, to_ue(function_name_no_prefix)); if (!unreal_function) { lua.throw_error("Tried to register a hook with Lua function 'RegisterHook' but no UFunction with the specified name was found."); @@ -3038,13 +3037,13 @@ No overload found for function 'RegisterHook'. Output::send(SYSSTR("[RegisterHook] Registered native hook ({}, {}) for {}\n"), generic_pre_id, generic_post_id, - UEStringToSystemString(unreal_function->GetFullName())); + to_system(unreal_function->GetFullName())); } else if (func_ptr && func_ptr == Unreal::UObject::ProcessInternalInternal.get_function_address() && !unreal_function->HasAnyFunctionFlags(Unreal::EFunctionFlags::FUNC_Native)) { ++m_last_generic_hook_id; - auto [callback_data, _] = LuaMod::m_script_hook_callbacks.emplace(UEStringToSystemString(unreal_function->GetFullName()), LuaCallbackData{lua, nullptr, {}}); + auto [callback_data, _] = LuaMod::m_script_hook_callbacks.emplace(to_system(unreal_function->GetFullName()), LuaCallbackData{lua, nullptr, {}}); callback_data->second.registry_indexes.emplace_back(hook_lua, LuaMod::LuaCallbackData::RegistryIndex{lua_callback_registry_index, m_last_generic_hook_id}); generic_pre_id = m_last_generic_hook_id; @@ -3052,7 +3051,7 @@ No overload found for function 'RegisterHook'. Output::send(SYSSTR("[RegisterHook] Registered script hook ({}, {}) for {}\n"), generic_pre_id, generic_post_id, - UEStringToSystemString(unreal_function->GetFullName())); + to_system(unreal_function->GetFullName())); } else { @@ -3264,8 +3263,8 @@ No overload found for function 'FPackageName:IsShortPackageName'. { lua.throw_error(error_overload_not_found); } - auto local_str = SystemStringToUEString(to_generic_string(lua.get_string())); - UEViewType PossiblyLongName = local_str; + auto local_str = to_ue(lua.get_string()); + UEStringViewType PossiblyLongName = local_str; lua.set_bool(Unreal::FPackageName::IsShortPackageName(PossiblyLongName)); return 1; @@ -3281,8 +3280,8 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. { lua.throw_error(error_overload_not_found); } - auto local_str = SystemStringToUEString(to_generic_string(lua.get_string())); - UEViewType InLongPackageName = local_str; + auto local_str = to_ue(lua.get_string()); + UEStringViewType InLongPackageName = local_str; lua.set_bool(Unreal::FPackageName::IsValidLongPackageName(InLongPackageName)); return 1; @@ -3393,7 +3392,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } catch (std::runtime_error& e) { - Output::send(SYSSTR("{}\n"), to_generic_string(e.what())); + Output::send(SYSSTR("{}\n"), to_system(e.what())); } } @@ -3433,8 +3432,8 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. std::erase_if(g_hooked_script_function_data, [&](std::unique_ptr& item) -> bool { if (item->mod == this) { - Output::send(SYSSTR("\tUnregistering hook by id '{}#{}' for mod {}\n"), UEStringToSystemString(item->unreal_function->GetName()), item->pre_callback_id, item->mod->get_name()); - Output::send(SYSSTR("\tUnregistering hook by id '{}#{}' for mod {}\n"), UEStringToSystemString(item->unreal_function->GetName()), item->post_callback_id, item->mod->get_name()); + Output::send(SYSSTR("\tUnregistering hook by id '{}#{}' for mod {}\n"), to_system(item->unreal_function->GetName()), item->pre_callback_id, item->mod->get_name()); + Output::send(SYSSTR("\tUnregistering hook by id '{}#{}' for mod {}\n"), to_system(item->unreal_function->GetName()), item->post_callback_id, item->mod->get_name()); item->unreal_function->UnregisterHook(item->pre_callback_id); item->unreal_function->UnregisterHook(item->post_callback_id); return true; @@ -3495,7 +3494,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. { return; } - if (auto it = callback_container.find(precise_name_match ? UEStringToSystemString(Stack.Node()->GetFullName()) : UEStringToSystemString(Stack.Node()->GetName())); it != callback_container.end()) + if (auto it = callback_container.find(precise_name_match ? to_system(Stack.Node()->GetFullName()) : to_system(Stack.Node()->GetName())); it != callback_container.end()) { const auto& callback_data = it->second; for (const auto& [lua_ptr, registry_index] : callback_data.registry_indexes) @@ -3589,13 +3588,10 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } else { - SystemStringType return_property_type_name = UEStringToSystemString(return_property_type.ToString()); - SystemStringType return_property_name = UEStringToSystemString(return_property->GetName()); - Output::send(SYSSTR("Tried altering return value of a custom BP function without a registered handler for return type Return " "property '{}' of type '{}' not supported."), - return_property_name, - return_property_type_name); + return_property->GetName(), + return_property_type.ToString()); } } } @@ -3805,7 +3801,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } catch (std::runtime_error& e) { - Output::send(SYSSTR("{}\n"), to_generic_string(e.what())); + Output::send(SYSSTR("{}\n"), to_system(e.what())); } } } @@ -4039,26 +4035,26 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. ar.Log((const RC::Unreal::TCHAR*) log_message.c_str()); }; - if (!LuaStatics::console_executor_enabled && String::iequal(UEViewType{(UECharType*)cmd}, STR("luastart"))) + if (!LuaStatics::console_executor_enabled && String::iequal(UEStringViewType{(UECharType*)cmd}, STR("luastart"))) { start_console_lua_executor(); logln(SYSSTR("Console Lua executor started")); return true; } - else if (LuaStatics::console_executor_enabled && String::iequal(UEViewType{(UECharType*)cmd}, STR("luastop"))) + else if (LuaStatics::console_executor_enabled && String::iequal(UEStringViewType{(UECharType*)cmd}, STR("luastop"))) { stop_console_lua_executor(); logln(SYSSTR("Console Lua executor stopped")); return true; } - else if (LuaStatics::console_executor_enabled && String::iequal(UEViewType{(UECharType*)cmd}, STR("luarestart"))) + else if (LuaStatics::console_executor_enabled && String::iequal(UEStringViewType{(UECharType*)cmd}, STR("luarestart"))) { stop_console_lua_executor(); start_console_lua_executor(); logln(SYSSTR("Console Lua executor restarted")); return true; } - else if (String::iequal(UEViewType{(UECharType*)cmd}, STR("clear"))) + else if (String::iequal(UEStringViewType{(UECharType*)cmd}, STR("clear"))) { // TODO: Replace with proper implementation when we have UGameViewportClient and UConsole. // This should be fairly cross-game & cross-engine-version compatible even without the proper implementation. @@ -4100,7 +4096,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } catch (std::runtime_error& e) { - logln(to_generic_string(e.what())); + logln(to_system(e.what())); } // We always return true when the console Lua executor is enabled in order to suppress other handlers @@ -4116,7 +4112,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. Unreal::Hook::RegisterProcessConsoleExecGlobalPreCallback( [](Unreal::UObject* context, const RC::Unreal::TCHAR* cmd, Unreal::FOutputDevice& ar, Unreal::UObject* executor) -> std::pair { return TRY([&] { - auto command = UEViewType{(const UECharType*) cmd}; + auto command = UEStringViewType{(const UECharType*) cmd}; auto command_parts = explode_by_occurrence((const UECharType*) cmd, ' '); for (const auto& callback_data : m_process_console_exec_pre_callbacks) @@ -4172,7 +4168,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. Unreal::Hook::RegisterProcessConsoleExecGlobalPostCallback( [](Unreal::UObject* context, const RC::Unreal::TCHAR* cmd, Unreal::FOutputDevice& ar, Unreal::UObject* executor) -> std::pair { return TRY([&] { - auto command = UEViewType {(const UECharType*) cmd}; + auto command = UEStringViewType {(const UECharType*) cmd}; auto command_parts = explode_by_occurrence((const UECharType*)cmd, ' '); for (const auto& callback_data : m_process_console_exec_post_callbacks) @@ -4234,7 +4230,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. } return TRY([&] { - auto command = UEStringToSystemString(cmd); + auto command = to_system(cmd); auto command_parts = explode_by_occurrence(command, ' '); SystemStringType command_name; if (command_parts.size() > 1) @@ -4294,7 +4290,7 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. (void)executor; return TRY([&] { - auto command = UEStringToSystemString(cmd); + auto command = to_system(cmd); auto command_parts = explode_by_occurrence(command, ' '); SystemStringType command_name; if (command_parts.size() > 1) @@ -4414,8 +4410,8 @@ No overload found for function 'FPackageName:IsValidLongPackageName'. catch (std::runtime_error& e) { Output::send(SYSSTR("[{}] {}\n"), - to_generic_string(action.type == LuaMod::ActionType::Loop ? SYSSTR("LoopAsync") : SYSSTR("DelayedAction")), - to_generic_string(e.what())); + to_system(action.type == LuaMod::ActionType::Loop ? SYSSTR("LoopAsync") : SYSSTR("DelayedAction")), + to_system(e.what())); } return result; diff --git a/UE4SS/src/Mod/Mod.cpp b/UE4SS/src/Mod/Mod.cpp index b0cab8e7e..933c04107 100644 --- a/UE4SS/src/Mod/Mod.cpp +++ b/UE4SS/src/Mod/Mod.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/UE4SS/src/ObjectDumper/ObjectToString.cpp b/UE4SS/src/ObjectDumper/ObjectToString.cpp index 3d0ff774d..687e1da67 100644 --- a/UE4SS/src/ObjectDumper/ObjectToString.cpp +++ b/UE4SS/src/ObjectDumper/ObjectToString.cpp @@ -61,7 +61,7 @@ namespace RC::ObjectDumper UObject* p_typed_this = static_cast(p_this); out_line.append(std::format(SYSSTR("[{:016X}] "), reinterpret_cast(p_this))); - out_line.append(UEStringToSystemString(p_typed_this->GetFullName())); + out_line.append(to_system(p_typed_this->GetFullName())); out_line.append(std::format(SYSSTR(" [n: {:X}] [c: {:016X}] [or: {:016X}]"), p_typed_this->GetNamePrivate().GetComparisonIndex(), reinterpret_cast(p_typed_this->GetClassPrivate()), @@ -78,7 +78,7 @@ namespace RC::ObjectDumper FProperty* p_typed_this = static_cast(p_this); out_line.append(std::format(SYSSTR("[{:016X}] "), reinterpret_cast(p_this))); - out_line.append(UEStringToSystemString(p_typed_this->GetFullName())); + out_line.append(to_system(p_typed_this->GetFullName())); out_line.append(std::format(SYSSTR(" [o: {:X}] "), p_typed_this->GetOffset_Internal())); auto property_class = p_typed_this->GetClass(); @@ -127,7 +127,7 @@ namespace RC::ObjectDumper } else { - out_line.append(UEStringToSystemString(array_inner->GetFullName())); + out_line.append(to_system(array_inner->GetFullName())); callable(array_inner); } } @@ -168,7 +168,7 @@ namespace RC::ObjectDumper } else { - out_line.append(UEStringToSystemString(property->GetFullName())); + out_line.append(to_system(property->GetFullName())); callable(property); } }; @@ -261,7 +261,7 @@ namespace RC::ObjectDumper for (auto& Elem : typed_this->ForEachName()) { - out_line.append(std::format(SYSSTR("\n[{:016X}] {} [n: {:X}] [v: {}]"), 0, UEStringToSystemString(Elem.Key.ToString()), Elem.Key.GetComparisonIndex(), Elem.Value)); + out_line.append(std::format(SYSSTR("\n[{:016X}] {} [n: {:X}] [v: {}]"), 0, to_system(Elem.Key.ToString()), Elem.Key.GetComparisonIndex(), Elem.Value)); } } diff --git a/UE4SS/src/SDKGenerator/Common.cpp b/UE4SS/src/SDKGenerator/Common.cpp index 38c26affb..47321eb3c 100644 --- a/UE4SS/src/SDKGenerator/Common.cpp +++ b/UE4SS/src/SDKGenerator/Common.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #pragma warning(default : 4005) #define DELEGATE_SIGNATURE_POSTFIX STR("__DelegateSignature") @@ -57,7 +58,7 @@ namespace RC::UEGenerator result_string.append(SYSSTR("DEPRECATED_")); } - result_string.append(UEStringToSystemString(uclass->GetName())); + result_string.append(to_system(uclass->GetName())); return result_string; } @@ -79,7 +80,7 @@ namespace RC::UEGenerator // Seems to be not needed, because enum objects, unlike classes or structs, retain their normal E prefix // ResultString.append(SYSSTR("E")); - result_string.append(UEStringToSystemString(uenum->GetName())); + result_string.append(to_system(uenum->GetName())); // Namespaced enums need to have ::Type appended for the type if (uenum->GetCppForm() == UEnum::ECppForm::Namespaced && include_type) @@ -94,7 +95,7 @@ namespace RC::UEGenerator SystemStringType result_string; result_string.append(SYSSTR("F")); - result_string.append(UEStringToSystemString(script_struct->GetName())); + result_string.append(to_system(script_struct->GetName())); return result_string; } @@ -124,14 +125,14 @@ namespace RC::UEGenerator auto generate_delegate_name(FProperty* property, const File::StringType& context_name) -> File::StringType { - const SystemStringType property_name = sanitize_property_name(UEStringToSystemString(property->GetName())); + const auto property_name = sanitize_property_name(to_system_string(property->GetName())); return std::format(SYSSTR("F{}{}"), context_name, property_name); } auto generate_property_cxx_name(FProperty* property, bool is_top_level_declaration, UObject* class_context, EnableForwardDeclarations enable_forward_declarations) -> File::StringType { - const SystemStringType field_class_name = UEStringToSystemString(property->GetClass().GetName()); + const auto field_class_name = to_system(property->GetClass().GetName()); // Byte Property if (property->IsA()) @@ -156,7 +157,7 @@ namespace RC::UEGenerator if (uenum == NULL) { - throw std::runtime_error(RC::fmt("EnumProperty %S does not have a valid Enum value", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("EnumProperty {} does not have a valid Enum value", property->GetName())); } const SystemStringType enum_type_name = get_native_enum_name(uenum); @@ -368,7 +369,7 @@ namespace RC::UEGenerator if (script_struct == NULL) { - throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty %S", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty {}", property->GetName())); } const SystemStringType native_struct_name = get_native_struct_name(script_struct); @@ -380,7 +381,7 @@ namespace RC::UEGenerator { FDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -390,7 +391,7 @@ namespace RC::UEGenerator { FMulticastInlineDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -398,7 +399,7 @@ namespace RC::UEGenerator { FMulticastSparseDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -406,7 +407,7 @@ namespace RC::UEGenerator if (property->IsA()) { FFieldPathProperty* field_path_property = static_cast(property); - const SystemStringType property_class_name = UEStringToSystemString(field_path_property->GetPropertyClass()->GetName()); + const auto property_class_name = to_system(field_path_property->GetPropertyClass()->GetName()); return std::format(SYSSTR("TFieldPath"), property_class_name); } @@ -478,12 +479,12 @@ namespace RC::UEGenerator { return SYSSTR("FText"); } - throw std::runtime_error(RC::fmt("Unsupported property class " SystemStringPrint, field_class_name.c_str())); + throw std::runtime_error(RC::fmt("Unsupported property class " SystemStringPrint, field_class_name)); } auto generate_property_lua_name(FProperty* property, bool is_top_level_declaration, UObject* class_context) -> File::StringType { - const SystemStringType field_class_name = UEStringToSystemString(property->GetClass().GetName()); + const auto field_class_name = to_system(property->GetClass().GetName()); // Byte Property if (field_class_name == SYSSTR("ByteProperty")) @@ -508,7 +509,7 @@ namespace RC::UEGenerator if (uenum == NULL) { - throw std::runtime_error(RC::fmt("EnumProperty %S does not have a valid Enum value", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("EnumProperty {} does not have a valid Enum value", property->GetName())); } const SystemStringType enum_type_name = get_native_enum_name(uenum); @@ -695,7 +696,7 @@ namespace RC::UEGenerator if (script_struct == NULL) { - throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty %S", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty {}", property->GetName())); } const SystemStringType native_struct_name = get_native_struct_name(script_struct); @@ -707,7 +708,7 @@ namespace RC::UEGenerator { FDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -717,7 +718,7 @@ namespace RC::UEGenerator { FMulticastInlineDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -725,7 +726,7 @@ namespace RC::UEGenerator { FMulticastSparseDelegateProperty* delegate_property = static_cast(property); - const SystemStringType delegate_type_name = generate_delegate_name(delegate_property, UEStringToSystemString(class_context->GetName())); + const auto delegate_type_name = generate_delegate_name(delegate_property, to_system(class_context->GetName())); return delegate_type_name; } @@ -733,7 +734,7 @@ namespace RC::UEGenerator if (field_class_name == SYSSTR("FieldPathProperty")) { FFieldPathProperty* field_path_property = static_cast(property); - const SystemStringType property_class_name = UEStringToSystemString(field_path_property->GetPropertyClass()->GetName()); + const auto property_class_name = to_system(field_path_property->GetPropertyClass()->GetName()); return std::format(SYSSTR("TFieldPath"), property_class_name); } @@ -786,14 +787,14 @@ namespace RC::UEGenerator { return SYSSTR("FText"); } - throw std::runtime_error(RC::fmt("Unsupported property class %S", field_class_name.c_str())); + throw std::runtime_error(RC::fmt("Unsupported property class {}", field_class_name)); } auto get_native_delegate_type_name(Unreal::UFunction* signature_function, Unreal::UClass* current_class, bool strip_outer_name) -> File::StringType { if (!is_delegate_signature_function(signature_function)) { - throw std::runtime_error(RC::fmt("Function %S is not a delegate signature function", signature_function->GetName().c_str())); + throw std::runtime_error(RC::fmt("Function {} is not a delegate signature function", signature_function->GetName())); } // Delegate names always start with F and have __DelegateSignature postfix @@ -826,7 +827,7 @@ namespace RC::UEGenerator else if (!delegate_outer->IsA()) { // Delegate signature functions should never exist outside the UPackage or UClass - throw std::runtime_error(RC::fmt("Delegate signature function %S does not have class or package as outer", delegate_outer->GetName().c_str())); + throw std::runtime_error(RC::fmt("Delegate signature function {} does not have class or package as outer", delegate_outer->GetName())); } return delegate_type_name; } @@ -840,13 +841,13 @@ namespace RC::UEGenerator { if (!is_delegate_signature_function(signature_function)) { - throw std::runtime_error(RC::fmt("Function %S is not a delegate signature function", signature_function->GetName().c_str())); + throw std::runtime_error(RC::fmt("Function {} is not a delegate signature function", signature_function->GetName())); } // Delegate names always start with F and have __DelegateSignature postfix const SystemStringType delegate_signature_postfix = DELEGATE_SIGNATURE_POSTFIX_SYS; - SystemStringType delegate_name = UEStringToSystemString (signature_function->GetName()); + auto delegate_name = to_system(signature_function->GetName()); delegate_name.erase(delegate_name.length() - delegate_signature_postfix.length()); return delegate_name; } diff --git a/UE4SS/src/SDKGenerator/Generator.cpp b/UE4SS/src/SDKGenerator/Generator.cpp index b2ddff5c6..eb9f931dc 100644 --- a/UE4SS/src/SDKGenerator/Generator.cpp +++ b/UE4SS/src/SDKGenerator/Generator.cpp @@ -342,7 +342,7 @@ namespace RC::UEGenerator return return_property_info.has_value() ? return_property_info.value().property : nullptr; }(); - File::StringType function_name{UEStringToSystemString(function_info.function->GetName())}; + File::StringType function_name{to_system(function_info.function->GetName())}; if (is_delegate_function == IsDelegateFunction::Yes) { // Remove the last 19 characters, which is always '__DelegateSignature' for delegates @@ -488,7 +488,7 @@ namespace RC::UEGenerator size_t colon_pos = enum_value_full_name.rfind(STR(":")); auto enum_value_name = colon_pos == enum_value_full_name.npos ? enum_value_full_name : enum_value_full_name.substr(colon_pos + 1); - specification.generate_enum_member(content_buffer, uenum, UEStringToSystemString(enum_value_name), elem); + specification.generate_enum_member(content_buffer, uenum, to_system(enum_value_name), elem); } specification.generate_enum_end(content_buffer, uenum); @@ -538,7 +538,7 @@ namespace RC::UEGenerator else { // Get rid of everything before the last slash + the last slash, leaving only the actual name - File::StringType package_name = UEStringToSystemString(package->GetNamePrivate().ToString()); + File::StringType package_name = to_system(package->GetNamePrivate().ToString()); package_name = package_name.substr(package_name.rfind(SYSSTR("/")) + 1); File::StringType package_name_all_lower = package_name; std::transform(package_name_all_lower.begin(), package_name_all_lower.end(), package_name_all_lower.begin(), [](File::CharType c) { @@ -783,11 +783,11 @@ namespace RC::UEGenerator generate_tab(), property_info.should_forward_declare ? SYSSTR("class ") : SYSSTR(""), generate_property_cxx_name(property, true, native_class, EnableForwardDeclarations::Yes), - UEStringToSystemString(property->GetName())); + to_system(property->GetName())); } catch (std::exception& e) { - Output::send(SYSSTR("Could not generate property '{}' because: {}\n"),UEStringToSystemString(property->GetFullName()), to_generic_string(e.what())); + Output::send(SYSSTR("Could not generate property '{}' because: {}\n"),to_system(property->GetFullName()), to_system(e.what())); continue; } @@ -962,8 +962,8 @@ namespace RC::UEGenerator catch (std::exception& e) { Output::send(SYSSTR("Could not generate function '{}' because: {}\n"), - UEStringToSystemString(function_info.function->GetFullName()), - to_generic_string(e.what())); + to_system(function_info.function->GetFullName()), + to_system(e.what())); return; } @@ -992,13 +992,13 @@ namespace RC::UEGenerator param_info.should_forward_declare ? SYSSTR("class ") : SYSSTR(""), generate_property_cxx_name(param_info.property, true, function_info.function, EnableForwardDeclarations::Yes), param_info.property->HasAnyPropertyFlags(Unreal::CPF_ReferenceParm | Unreal::CPF_OutParm) ? SYSSTR("&") : SYSSTR(""), - UEStringToSystemString(param_info.property->GetName()))); + to_system(param_info.property->GetName()))); } catch (std::exception& e) { Output::send(SYSSTR("Could not generate function '{}' because: {}\n"), - UEStringToSystemString(function_info.function->GetFullName()), - to_generic_string(e.what())); + to_system(function_info.function->GetFullName()), + to_system(e.what())); return; } @@ -1094,7 +1094,7 @@ namespace RC::UEGenerator } auto generate_enum_declaration(File::StringType& content_buffer, UEnum* uenum) -> void { - auto enum_name = UEStringToSystemString(uenum->GetName()); + auto enum_name = to_system(uenum->GetName()); content_buffer.append(std::format(SYSSTR("---@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 @@ -1162,7 +1162,7 @@ namespace RC::UEGenerator try { - const auto& property_name = UEStringToSystemString(property->GetName()); + const auto& property_name = to_system(property->GetName()); if (is_valid_lua_symbol(property_name)) { content_buffer.append(std::format(SYSSTR("---@field {} {}\n"), property_name, generate_property_lua_name(property, true, native_class))); @@ -1175,7 +1175,7 @@ namespace RC::UEGenerator } catch (std::exception& e) { - Output::send(SYSSTR("Could not generate property '{}' because: {}\n"), UEStringToSystemString(property->GetFullName()), to_generic_string(e.what())); + Output::send(SYSSTR("Could not generate property '{}' because: {}\n"), to_system(property->GetFullName()), to_system(e.what())); continue; } @@ -1242,7 +1242,7 @@ namespace RC::UEGenerator { try { - auto param_name = UEStringToSystemString(param_info.property->GetName()); + auto param_name = to_system(param_info.property->GetName()); // TODO disambiguate param renames current_class_content.append(std::format(SYSSTR("---@param {} {}\n"), make_valid_symbol(param_name), @@ -1251,8 +1251,8 @@ namespace RC::UEGenerator catch (std::exception& e) { Output::send(SYSSTR("Could not generate function '{}' because: {}\n"), - UEStringToSystemString( function_info.function->GetFullName()), - to_generic_string(e.what())); + to_system( function_info.function->GetFullName()), + to_system(e.what())); return; } } @@ -1267,8 +1267,8 @@ namespace RC::UEGenerator catch (std::exception& e) { Output::send(SYSSTR("Could not generate function '{}' because: {}\n"), - UEStringToSystemString(function_info.function->GetFullName()), - to_generic_string(e.what())); + to_system(function_info.function->GetFullName()), + to_system(e.what())); return; } } @@ -1289,7 +1289,7 @@ namespace RC::UEGenerator const auto& param_info = function_info.params[i]; if (!param_info.property->HasAnyPropertyFlags(Unreal::CPF_ReturnParm)) { - auto param_name = UEStringToSystemString(param_info.property->GetName()); + auto param_name = to_system(param_info.property->GetName()); // TODO disambiguate param renames current_class_content.append(std::format(SYSSTR("{}"), make_valid_symbol(param_name))); diff --git a/UE4SS/src/SDKGenerator/JSONDumper.cpp b/UE4SS/src/SDKGenerator/JSONDumper.cpp index e2e58895b..5920f4f0c 100644 --- a/UE4SS/src/SDKGenerator/JSONDumper.cpp +++ b/UE4SS/src/SDKGenerator/JSONDumper.cpp @@ -201,7 +201,7 @@ namespace RC::UEGenerator::JSONDumper } UObject* object = static_cast(raw_object); - auto object_name = UEStringToSystemString(object->GetName()); + auto object_name = to_system(object->GetName()); if (!is_valid_class_to_dump(object_name, object)) { return LoopAction::Continue; @@ -214,7 +214,7 @@ namespace RC::UEGenerator::JSONDumper bp_class.new_string(SYSSTR("bp_class"), object_name); if (auto* super_struct = object_as_class->GetSuperStruct(); super_struct) { - bp_class.new_string(SYSSTR("inherits"), UEStringToSystemString(super_struct->GetName())); + bp_class.new_string(SYSSTR("inherits"), to_system(super_struct->GetName())); } else { @@ -233,7 +233,7 @@ namespace RC::UEGenerator::JSONDumper continue; } - auto event_name = UEStringToSystemString(event_function->GetName()); + auto event_name = to_system(event_function->GetName()); if (should_skip_event(event_name)) { continue; @@ -251,7 +251,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_event_arg = bp_event_args.new_object(); - bp_event_arg.new_string(SYSSTR("name"), UEStringToSystemString(param->GetName())); + bp_event_arg.new_string(SYSSTR("name"), to_system(param->GetName())); bp_event_arg.new_string(SYSSTR("type"), generate_property_cxx_name(param, true, event_function)); bool is_out = param->HasAnyPropertyFlags(EPropertyFlags::CPF_OutParm) && !param->HasAnyPropertyFlags(EPropertyFlags::CPF_ConstParm); bp_event_arg.new_bool(SYSSTR("is_out"), is_out); @@ -268,7 +268,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_function = functions.new_object(); - bp_function.new_string(SYSSTR("name"), UEStringToSystemString(function->GetName())); + bp_function.new_string(SYSSTR("name"), to_system(function->GetName())); auto& bp_function_args = bp_function.new_array(SYSSTR("args")); for (FProperty* param : function->ForEachProperty()) @@ -279,7 +279,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_function_arg = bp_function_args.new_object(); - bp_function_arg.new_string(SYSSTR("name"), UEStringToSystemString(param->GetName())); + bp_function_arg.new_string(SYSSTR("name"), to_system(param->GetName())); bp_function_arg.new_string(SYSSTR("type"), generate_property_cxx_name(param, true, function)); bool is_out = param->HasAnyPropertyFlags(EPropertyFlags::CPF_OutParm) && !param->HasAnyPropertyFlags(EPropertyFlags::CPF_ConstParm); bp_function_arg.new_bool(SYSSTR("is_out"), is_out); @@ -296,7 +296,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_property = properties.new_object(); - bp_property.new_string(SYSSTR("name"),UEStringToSystemString(property->GetName())); + bp_property.new_string(SYSSTR("name"),to_system(property->GetName())); bp_property.new_string(SYSSTR("type"), generate_property_cxx_name(property, true, object_as_class)); } @@ -313,7 +313,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_delegate = delegates.new_object(); - bp_delegate.new_string(SYSSTR("name"), UEStringToSystemString(delegate_function->GetName())); + bp_delegate.new_string(SYSSTR("name"), to_system(delegate_function->GetName())); auto& bp_delegate_args = bp_delegate.new_array(SYSSTR("args")); for (FProperty* param : delegate_function->ForEachProperty()) @@ -324,7 +324,7 @@ namespace RC::UEGenerator::JSONDumper } auto& bp_delegate_arg = bp_delegate_args.new_object(); - bp_delegate_arg.new_string(SYSSTR("name"), UEStringToSystemString(param->GetName())); + bp_delegate_arg.new_string(SYSSTR("name"), to_system(param->GetName())); bp_delegate_arg.new_string(SYSSTR("type"), generate_property_cxx_name(param, true, delegate_function)); bool is_out = param->HasAnyPropertyFlags(EPropertyFlags::CPF_OutParm) && !param->HasAnyPropertyFlags(EPropertyFlags::CPF_ConstParm); bp_delegate_arg.new_bool(SYSSTR("is_out"), is_out); diff --git a/UE4SS/src/SDKGenerator/TMapOverrideGen.cpp b/UE4SS/src/SDKGenerator/TMapOverrideGen.cpp index 0e8605001..68aca9a65 100644 --- a/UE4SS/src/SDKGenerator/TMapOverrideGen.cpp +++ b/UE4SS/src/SDKGenerator/TMapOverrideGen.cpp @@ -53,7 +53,7 @@ namespace RC::UEGenerator MapProperties.insert(property->GetFName()); - auto property_name = UEStringToSystemString(property->GetFName().ToString()); + auto property_name = to_system(property->GetFName().ToString()); auto key_as_struct_property = CastField(static_cast(property)->GetKeyProp()); auto key_struct_type = key_as_struct_property ? key_as_struct_property->GetStruct() : nullptr; @@ -67,14 +67,14 @@ namespace RC::UEGenerator { continue; } - Output::send(SYSSTR("Found Relevant TMap Property: {} in Class: {}\n"), property_name, UEStringToSystemString(object->GetName())); + Output::send(SYSSTR("Found Relevant TMap Property: {} in Class: {}\n"), property_name, to_system(object->GetName())); auto& fm_json_object = fm_object.new_object(property_name); auto& uaapi_array = uaapi_object.new_array(property_name); if (is_key_valid) { - auto key_name = UEStringToSystemString(key_as_struct_property->GetStruct()->GetName()); + auto key_name = to_system(key_as_struct_property->GetStruct()->GetName()); fm_json_object.new_string(SYSSTR("Key"), key_name); uaapi_array.new_string(key_name); } @@ -86,7 +86,7 @@ namespace RC::UEGenerator if (is_value_valid) { - auto value_name = UEStringToSystemString(value_as_struct_property->GetStruct()->GetName()); + auto value_name = to_system(value_as_struct_property->GetStruct()->GetName()); fm_json_object.new_string(SYSSTR("Value"), value_name); uaapi_array.new_string(value_name); } diff --git a/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp b/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp index d6e901df6..4e79d9dec 100644 --- a/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp +++ b/UE4SS/src/SDKGenerator/UEHeaderGenerator.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #pragma warning(default : 4005) namespace RC::UEGenerator @@ -632,8 +633,8 @@ namespace RC::UEGenerator for (auto [Name, Value] : uenum->ForEachName()) { UEStringType enum_name = Name.ToString(); - SystemStringType result_enumeration_line = sanitize_enumeration_name(UEStringToSystemString(enum_name)); - SystemStringType pre_append_result_line = result_enumeration_line; + auto result_enumeration_line = sanitize_enumeration_name(to_system(enum_name)); + auto pre_append_result_line = result_enumeration_line; // If an enum name is listed in the array twice, that likely means it is used as the value for another enum. Long story short, don't print it. if (enum_name_set.contains(enum_name)) @@ -647,15 +648,15 @@ namespace RC::UEGenerator // Taking advantage of GetNameByValue returning the first result for the value to determine if there are any enumerator names that // reference an already declared value/name. - UEStringType first_name_with_value = uenum->GetNameByValue(Value).ToString(); + auto first_name_with_value = uenum->GetNameByValue(Value).ToString(); if (first_name_with_value != Name.ToString()) { - result_enumeration_line.append(std::format(SYSSTR(" = {}"), sanitize_enumeration_name(UEStringToSystemString(first_name_with_value)))); + result_enumeration_line.append(std::format(SYSSTR(" = {}"), sanitize_enumeration_name(to_system(first_name_with_value)))); } else if (Value != expected_next_enum_value || last_value_was_negative_one) { - const SystemStringType CastString = (enum_is_uint8 && Value < 0) ? SYSSTR("(uint8)") : SYSSTR(""); - const SystemStringType MinusSign = Value < 0 ? SYSSTR("-") : SYSSTR(""); + const auto CastString = (enum_is_uint8 && Value < 0) ? SYSSTR("(uint8)") : SYSSTR(""); + const auto MinusSign = Value < 0 ? SYSSTR("-") : SYSSTR(""); result_enumeration_line.append(std::format(SYSSTR(" = {}{}{}"), CastString, MinusSign, Value < 0 ? -Value : Value)); } expected_next_enum_value = Value + 1; @@ -665,7 +666,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(SYSSTR("_max"))) { - const SystemStringType expected_full_constant_name = std::format(SYSSTR("{}_MAX"), UEStringToSystemString(enum_prefix)); + const auto expected_full_constant_name = std::format(SYSSTR("{}_MAX"), to_system(enum_prefix)); SystemStringType 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); @@ -704,13 +705,13 @@ namespace RC::UEGenerator } else { - owning_class = UEStringToSystemString(delegate_class->GetNamePrivate().ToString()); + owning_class = to_system(delegate_class->GetNamePrivate().ToString()); } auto function_flags = signature_function->GetFunctionFlags(); if ((function_flags & Unreal::FUNC_Delegate) == 0) { - throw std::runtime_error(RC::fmt("Delegate Signature function %S is missing FUNC_Delegate flag", signature_function->GetName().c_str())); + throw std::runtime_error(RC::fmt("Delegate Signature function {} is missing FUNC_Delegate flag", signature_function->GetName())); } // TODO not particularly nice or reliable, but will do for now @@ -872,7 +873,7 @@ namespace RC::UEGenerator { if ((property->GetPropertyFlags() & CPF_Net) != 0) { - implementation_file.append_line(std::format(SYSSTR("DOREPLIFETIME({}, {});"), class_native_name, UEStringToSystemString(property->GetName()))); + implementation_file.append_line(std::format(SYSSTR("DOREPLIFETIME({}, {});"), class_native_name, to_system(property->GetName()))); } } @@ -913,7 +914,7 @@ namespace RC::UEGenerator const SystemStringType property_flags_string = generate_property_flags(property); bool is_bitmask_bool = false; - PropertyTypeDeclarationContext Context(UEStringToSystemString(uclass->GetName()), &header_data, true, &is_bitmask_bool); + PropertyTypeDeclarationContext Context(to_system(uclass->GetName()), &header_data, true, &is_bitmask_bool); SystemStringType property_type_string{}; bool type_is_valid = true; @@ -925,14 +926,14 @@ namespace RC::UEGenerator catch (std::exception& e) { type_is_valid = false; - error_string = to_generic_string(std::string(e.what())); + error_string = to_system(std::string(e.what())); } if (!type_is_valid) { Output::send(SYSSTR("Warning: {}\n"), error_string); header_data.append_line(std::format(SYSSTR("// UPROPERTY({})"), property_flags_string)); - header_data.append_line(std::format(SYSSTR("// Missed Property: {}"), UEStringToSystemString(property->GetName()))); + header_data.append_line(std::format(SYSSTR("// Missed Property: {}"), to_system(property->GetName()))); header_data.append_line(std::format(SYSSTR("// {}"), error_string)); header_data.append_line(SYSSTR("")); return; @@ -942,7 +943,7 @@ namespace RC::UEGenerator if (property->GetArrayDim() != 1) { property_extra_declaration.append(SYSSTR("[")); - property_extra_declaration.append(to_generic_string(std::to_string(property->GetArrayDim()))); + property_extra_declaration.append(to_system(std::to_string(property->GetArrayDim()))); property_extra_declaration.append(SYSSTR("]")); } else if (is_bitmask_bool) @@ -951,7 +952,7 @@ namespace RC::UEGenerator } header_data.append_line(std::format(SYSSTR("UPROPERTY({})"), property_flags_string)); - header_data.append_line(std::format(SYSSTR("{} {}{};"), property_type_string, UEStringToSystemString(property->GetName()), property_extra_declaration)); + header_data.append_line(std::format(SYSSTR("{} {}{};"), property_type_string, to_system(property->GetName()), property_extra_declaration)); header_data.append_line(SYSSTR("")); } @@ -985,7 +986,7 @@ namespace RC::UEGenerator SystemStringType return_property_string; if (return_property != NULL) { - PropertyTypeDeclarationContext context(UEStringToSystemString(uclass->GetName()), &header_data); + PropertyTypeDeclarationContext context(to_system(uclass->GetName()), &header_data); return_property_string = generate_property_type_declaration(return_property, context); } else @@ -1003,7 +1004,7 @@ namespace RC::UEGenerator SystemStringType return_statement_string; if (return_property != NULL) { - const SystemStringType default_property_value = generate_default_property_value(return_property, header_data, UEStringToSystemString(context_name)); + const auto default_property_value = generate_default_property_value(return_property, header_data, to_system(context_name)); return_statement_string = std::format(SYSSTR(" return {};"), default_property_value); } @@ -1011,19 +1012,19 @@ namespace RC::UEGenerator { function_extra_postfix_string.append(SYSSTR(" override")); } - function_extra_postfix_string.append(std::format(SYSSTR(" PURE_VIRTUAL({},{})"), UEStringToSystemString(function->GetName()), return_statement_string)); + function_extra_postfix_string.append(std::format(SYSSTR(" PURE_VIRTUAL({},{})"), to_system(function->GetName()), return_statement_string)); } - SystemStringType function_argument_list = generate_function_parameter_list(uclass, function, header_data, false, UEStringToSystemString(context_name), blacklisted_property_names); + auto function_argument_list = generate_function_parameter_list(uclass, function, header_data, false, to_system(context_name), blacklisted_property_names); - const SystemStringType function_flags_string = generate_function_flags(function, is_function_pure_virtual); + const auto function_flags_string = generate_function_flags(function, is_function_pure_virtual); header_data.append_line(std::format(SYSSTR("UFUNCTION({})"), function_flags_string)); // Format for virtual functions // virtual () PURE_VIRTUAL(, ) header_data.append_line(std::format(SYSSTR("{}{} {}({}){};"), function_modifier_string, return_property_string, - UEStringToSystemString(function->GetName()), + to_system(function->GetName()), function_argument_list, function_extra_postfix_string)); header_data.append_line(SYSSTR("")); @@ -1039,7 +1040,7 @@ namespace RC::UEGenerator { if (Value == enum_value) { - enum_constant_name = sanitize_enumeration_name(UEStringToSystemString(Name.ToString())); + enum_constant_name = sanitize_enumeration_name(to_system(Name.ToString())); } } if (enum_constant_name.empty()) @@ -1066,7 +1067,7 @@ namespace RC::UEGenerator const SystemStringType& property_scope, const SystemStringType& operator_type) -> void { - const SystemStringType field_class_name = UEStringToSystemString(property->GetName()); + const auto field_class_name = to_system(property->GetName()); if (property->GetArrayDim() == 1) { implementation_file.append_line(std::format(SYSSTR("{}{}{}{};"), property_scope, field_class_name, operator_type, value)); @@ -1087,7 +1088,7 @@ namespace RC::UEGenerator const SystemStringType& property_type, const SystemStringType& operator_type) -> void { - const SystemStringType field_class_name = UEStringToSystemString(property->GetName()); + const auto field_class_name = to_system(property->GetName()); implementation_file.append_line(std::format(SYSSTR("const FProperty* p_{} = GetClass()->FindPropertyByName(\"{}\");"), field_class_name, field_class_name)); if (property->GetArrayDim() == 1) { @@ -1188,7 +1189,7 @@ namespace RC::UEGenerator UEnum* uenum = p_enum_property->GetEnum(); if (uenum == NULL) { - throw std::runtime_error(RC::fmt("EnumProperty %S does not have a valid Enum value", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("EnumProperty {} does not have a valid Enum value", property->GetName())); } FNumericProperty* underlying_property = p_enum_property->GetUnderlyingProperty(); @@ -1267,13 +1268,13 @@ namespace RC::UEGenerator if (property->IsA()) { FName* name_value = property->ContainerPtrToValuePtr(object); - const SystemStringType name_value_string = UEStringToSystemString(name_value->ToString()); + const auto name_value_string = to_system(name_value->ToString()); // Ensure property either does not exist in parent class or is overriden in the CDO for the child class if (super_property != nullptr) { FName* super_name_value = super_property->ContainerPtrToValuePtr(super_object); - const SystemStringType super_name_value_string = UEStringToSystemString(super_name_value->ToString()); + const auto super_name_value_string = to_system(super_name_value->ToString()); if (name_value_string == super_name_value_string) { return; @@ -1300,13 +1301,13 @@ namespace RC::UEGenerator if (property->IsA()) { FString* string_value = property->ContainerPtrToValuePtr(object); - const SystemStringType string_value_string = UEStringToSystemString(UEStringType (string_value->GetCharArray())); + const auto string_value_string = to_system(UEStringType (string_value->GetCharArray())); // Ensure property either does not exist in parent class or is overriden in the CDO for the child class if (super_property != nullptr) { FString* super_string_value = super_property->ContainerPtrToValuePtr(super_object); - const SystemStringType super_string_value_string = UEStringToSystemString(UEStringType (super_string_value->GetCharArray())); + const auto super_string_value_string = to_system(UEStringType (super_string_value->GetCharArray())); if (string_value_string == super_string_value_string) { return; @@ -1349,7 +1350,7 @@ namespace RC::UEGenerator if (text_value_string != STR("")) { - const SystemStringType result_property_value = std::format(SYSSTR("FText::FromString({})"), create_string_literal(UEStringToSystemString(text_value_string))); + const auto result_property_value = std::format(SYSSTR("FText::FromString({})"), create_string_literal(to_system(text_value_string))); if (!super_and_no_access) { generate_simple_assignment_expression(property, result_property_value, implementation_file, property_scope); @@ -1412,7 +1413,7 @@ namespace RC::UEGenerator else { // Unhandled case, reference to the non-native blueprint class potentially? - Output::send(SYSSTR("Unhandled default value of the FClassProperty {}: {}\n"), UEStringToSystemString(property->GetFullName()), UEStringToSystemString(class_value->GetFullName())); + Output::send(SYSSTR("Unhandled default value of the FClassProperty {}: {}\n"), to_system(property->GetFullName()), to_system(class_value->GetFullName())); } return; } @@ -1455,14 +1456,14 @@ namespace RC::UEGenerator if (sub_object_value->HasAnyFlags(EObjectFlags::RF_DefaultSubObject)) { UClass* object_class_type = sub_object_value->GetClassPrivate(); - const SystemStringType object_name = UEStringToSystemString(sub_object_value->GetName()); + const auto object_name = to_system(sub_object_value->GetName()); UClass* super_object_class_type{}; // Additional checks to ensure this property needs to be initialized in the current class if (super_sub_object_value) { super_object_class_type = super_sub_object_value->GetClassPrivate(); - const SystemStringType super_object_name = UEStringToSystemString(super_sub_object_value->GetName()); + const auto super_object_name = to_system(super_sub_object_value->GetName()); if ((object_class_type == super_object_class_type) && (object_name == super_object_name)) { return; @@ -1485,7 +1486,7 @@ namespace RC::UEGenerator UObject* check_super_sub_object_value = *check_super_object_property->ContainerPtrToValuePtr(super_object); if (check_super_sub_object_value) { - SystemStringType check_super_object_name = UEStringToSystemString(check_super_sub_object_value->GetName()); + auto check_super_object_name = to_system(check_super_sub_object_value->GetName()); if (check_super_object_name == object_name) { parent_component_found = true; @@ -1503,7 +1504,7 @@ namespace RC::UEGenerator { // Set property to equal previous property referencing the same object initializer = it->second; - FProperty* prior_property = ustruct->GetPropertyByNameInChain(SystemStringToUEString(initializer).c_str()); + FProperty* prior_property = ustruct->GetPropertyByNameInChain(to_ue(initializer).c_str()); bool prior_private = get_property_access_modifier(prior_property) == AccessModifier::Private; if (prior_private) { @@ -1534,7 +1535,7 @@ namespace RC::UEGenerator implementation_file.add_dependency_object(object_class_type, DependencyLevel::Include); implementation_file.m_implementation_constructor.append( std::format(SYSSTR(".SetDefaultSubobjectClass<{}>(TEXT(\"{}\"))"), get_native_class_name(object_class_type), object_name)); - m_class_subobjects.try_emplace(object_name, UEStringToSystemString(property->GetName())); + m_class_subobjects.try_emplace(object_name, to_system(property->GetName())); } else { @@ -1542,7 +1543,7 @@ namespace RC::UEGenerator implementation_file.add_dependency_object(object_class_type, DependencyLevel::Include); const SystemStringType object_class_name = get_native_class_name(object_class_type); initializer = std::format(SYSSTR("CreateDefaultSubobject<{}>(TEXT(\"{}\"))"), object_class_name, object_name); - m_class_subobjects.try_emplace(object_name, UEStringToSystemString(property->GetName())); + m_class_subobjects.try_emplace(object_name, to_system(property->GetName())); if (!super_and_no_access) { generate_simple_assignment_expression(property, initializer, implementation_file, property_scope); @@ -1561,7 +1562,7 @@ namespace RC::UEGenerator } if (attach_parent_object_value != NULL) { - const SystemStringType attach_parent_object_name = UEStringToSystemString (attach_parent_object_value->GetName()); + const auto attach_parent_object_name = to_system(attach_parent_object_value->GetName()); const SystemStringType operator_type = SYSSTR("->"); bool parent_found = false; SystemStringType attach_string; @@ -1581,25 +1582,25 @@ namespace RC::UEGenerator UObject* check_sub_object_value = *check_object_property->ContainerPtrToValuePtr(object); if (check_sub_object_value) { - SystemStringType check_object_name = UEStringToSystemString(check_sub_object_value->GetName()); + auto check_object_name = to_system(check_sub_object_value->GetName()); if (check_object_name == attach_parent_object_name) { if (get_property_access_modifier(check_object_property) != AccessModifier::Private) { - attach_string = std::format(SYSSTR("SetupAttachment({})"), UEStringToSystemString(check_property->GetName())); + attach_string = std::format(SYSSTR("SetupAttachment({})"), to_system(check_property->GetName())); } else { - SystemStringType parent_property_name = std::format(SYSSTR("const FProperty* p_{}_Parent = GetClass()->FindPropertyByName(\"{}\");"), - UEStringToSystemString(check_property->GetName()), - UEStringToSystemString(check_property->GetName())); + auto parent_property_name = std::format(SYSSTR("const FProperty* p_{}_Parent = GetClass()->FindPropertyByName(\"{}\");"), + to_system(check_property->GetName()), + to_system(check_property->GetName())); if (!implementation_file.parent_property_names.contains(parent_property_name)) { implementation_file.parent_property_names.emplace(parent_property_name); implementation_file.append_line(parent_property_name); } attach_string = std::format(SYSSTR("SetupAttachment(p_{}_Parent->ContainerPtrToValuePtr<{}>(this))"), - UEStringToSystemString(check_property->GetName()), + to_system(check_property->GetName()), get_native_class_name(check_sub_object_value->GetClassPrivate())); implementation_file.add_dependency_object(check_sub_object_value->GetClassPrivate(), DependencyLevel::Include); } @@ -1655,7 +1656,7 @@ namespace RC::UEGenerator } // Unhandled case, might be some external object reference - Output::send(SYSSTR("Unhandled default value of the FObjectProperty {}: {}\n"), UEStringToSystemString(property->GetFullName()), UEStringToSystemString(sub_object_value->GetFullName())); + Output::send(SYSSTR("Unhandled default value of the FObjectProperty {}: {}\n"), to_system(property->GetFullName()), to_system(sub_object_value->GetFullName())); return; } @@ -1701,7 +1702,7 @@ namespace RC::UEGenerator { if (!super_and_no_access) { - implementation_file.append_line(std::format(SYSSTR("{}{}.AddDefaulted({});"), property_scope, UEStringToSystemString(property->GetName()), (int32_t)property_value->Num())); + implementation_file.append_line(std::format(SYSSTR("{}{}.AddDefaulted({});"), property_scope, to_system(property->GetName()), (int32_t)property_value->Num())); } else { @@ -1740,7 +1741,7 @@ namespace RC::UEGenerator if (!numeric_property->IsFloatingPoint()) { int64 value = numeric_property->GetSignedIntPropertyValue(numeric_property->ContainerPtrToValuePtr(object)); - number_constant_string = to_generic_string( std::to_string(value)); + number_constant_string = to_system( std::to_string(value)); } else { @@ -1765,10 +1766,10 @@ namespace RC::UEGenerator bool is_generating_interface, const CaseInsensitiveSet& blacklisted_property_names) -> void { - const SystemStringType class_native_name = get_native_class_name(uclass, is_generating_interface); - const SystemStringType raw_function_name = UEStringToSystemString(function->GetName()); + const auto class_native_name = get_native_class_name(uclass, is_generating_interface); + const auto raw_function_name = to_system(function->GetName()); auto function_flags = function->GetFunctionFlags(); - PropertyTypeDeclarationContext context(UEStringToSystemString(uclass->GetName()), &implementation_file); + PropertyTypeDeclarationContext context(to_system(uclass->GetName()), &implementation_file); SystemStringType function_implementation_name; SystemStringType net_validate_function_name; @@ -2026,12 +2027,12 @@ namespace RC::UEGenerator for (FProperty* property : class_object->ForEachProperty()) { - result_set.insert(UEStringToSystemString(property->GetName())); + result_set.insert(to_system(property->GetName())); } for (UFunction* function : class_object->ForEachFunction()) { - result_set.insert(UEStringToSystemString(function->GetName())); + result_set.insert(to_system(function->GetName())); } } else if (uclass->GetClassPrivate()->IsChildOf(UScriptStruct::StaticClass())) @@ -2040,7 +2041,7 @@ namespace RC::UEGenerator for (FProperty* property : script_struct->ForEachProperty()) { - result_set.insert(UEStringToSystemString(property->GetName())); + result_set.insert(to_system(property->GetName())); } } return result_set; @@ -2163,7 +2164,7 @@ namespace RC::UEGenerator UClass* class_within = uclass->GetClassWithin(); if (class_within != NULL && class_within != UObject::StaticClass() && (super_class == NULL || class_within != super_class->GetClassWithin())) { - flag_format_helper.add_parameter(SYSSTR("Within"), UEStringToSystemString(class_within->GetName())); + flag_format_helper.add_parameter(SYSSTR("Within"), to_system(class_within->GetName())); } if ((class_own_flags & CLASS_Transient) != 0) @@ -2222,7 +2223,7 @@ namespace RC::UEGenerator const UEStringType class_config_name = uclass->GetClassConfigName().ToString(); if (super_class == NULL || class_config_name != super_class->GetClassConfigName().ToString()) { - flag_format_helper.add_parameter(SYSSTR("Config"), UEStringToSystemString(class_config_name)); + flag_format_helper.add_parameter(SYSSTR("Config"), to_system(class_config_name)); // Don't add our override config if we add the real one here add_config_name = false; } @@ -2306,7 +2307,7 @@ namespace RC::UEGenerator UEnum* uenum = enum_property->GetEnum(); if (uenum == NULL) { - throw std::runtime_error(RC::fmt("EnumProperty %S does not have a valid Enum value", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("EnumProperty {} does not have a valid Enum value", property->GetName())); } if (context.source_file != NULL) { @@ -2549,7 +2550,7 @@ namespace RC::UEGenerator if (script_struct == NULL) { - throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty %S", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty {}", property->GetName())); } const SystemStringType native_struct_name = get_native_struct_name(script_struct); @@ -2620,7 +2621,7 @@ namespace RC::UEGenerator if (property->IsA()) { FFieldPathProperty* field_path_property = static_cast(property); - const SystemStringType property_class_name = UEStringToSystemString(field_path_property->GetPropertyClass()->GetName()); + const auto property_class_name = to_system(field_path_property->GetPropertyClass()->GetName()); return std::format(SYSSTR("TFieldPath"), property_class_name); } @@ -2670,9 +2671,9 @@ namespace RC::UEGenerator { return SYSSTR("FText"); } - throw std::runtime_error(RC::fmt("[generate_property_type_declaration] Unsupported property class '%S', full name: '%S'", - field_class_name.c_str(), - property->GetFullName().c_str())); + throw std::runtime_error(RC::fmt("[generate_property_type_declaration] Unsupported property class '{}', full name: '{}'", + field_class_name, + property->GetFullName())); } //*/ @@ -2813,7 +2814,7 @@ namespace RC::UEGenerator { if ((property_flags & CPF_RepNotify) != 0) { - const SystemStringType rep_notify_func_name = UEStringToSystemString(property->GetRepNotifyFunc().ToString()); + const auto rep_notify_func_name = to_system(property->GetRepNotifyFunc().ToString()); flag_format_helper.add_parameter(SYSSTR("ReplicatedUsing"), rep_notify_func_name); } else @@ -2972,15 +2973,15 @@ namespace RC::UEGenerator } int64 highest_enum_value = 0; - const SystemStringType enum_prefix = UEStringToSystemString(uenum->GenerateEnumPrefix()); - const SystemStringType expected_max_name = std::format(SYSSTR("{}_MAX"), enum_prefix); - SystemStringType expected_max_name_lower = expected_max_name; + const auto enum_prefix = to_system(uenum->GenerateEnumPrefix()); + const auto expected_max_name = std::format(SYSSTR("{}_MAX"), enum_prefix); + auto 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); for (auto [Name, Value] : uenum->ForEachName()) { - SystemStringType enum_name = sanitize_enumeration_name(UEStringToSystemString(Name.ToString())); - SystemStringType enum_name_lower = enum_name; + auto enum_name = sanitize_enumeration_name(to_system(Name.ToString())); + auto enum_name_lower = enum_name; std::transform(enum_name_lower.begin(), enum_name_lower.end(), enum_name_lower.begin(), ::towlower); if ((enum_name_lower != expected_max_name_lower && enum_name_lower != sanitize_enumeration_name(expected_max_name_lower)) && Value > highest_enum_value) { @@ -3128,7 +3129,7 @@ namespace RC::UEGenerator bool bLAFound = false; for (FProperty* param : function->ForEachProperty()) { - auto param_name = UEStringToSystemString(param->GetName()); + auto param_name = to_system(param->GetName()); auto param_uc_name = string_to_uppercase(param_name); if (param_uc_name.find(SYSSTR("WORLDCONTEXT")) != param_uc_name.npos) { @@ -3210,7 +3211,7 @@ namespace RC::UEGenerator } param_declaration.append(SYSSTR(" ")); - SystemStringType property_name = UEStringToSystemString(property->GetName()); + auto property_name = to_system(property->GetName()); // If property name is blacklisted, capitalize first letter and prepend New if ((uclass && is_function_parameter_shadowing(uclass, property)) || blacklisted_property_names.contains(property_name)) @@ -3239,7 +3240,7 @@ namespace RC::UEGenerator auto UEHeaderGenerator::generate_default_property_value(FProperty* property, GeneratedSourceFile& header_data, const SystemStringType& ContextName) -> SystemStringType { - const SystemStringType field_class_name = UEStringToSystemString(property->GetClass().GetName()); + const auto field_class_name = to_system(property->GetClass().GetName()); PropertyTypeDeclarationContext context(ContextName, &header_data); // Byte Property @@ -3264,7 +3265,7 @@ namespace RC::UEGenerator if (uenum == NULL) { - throw std::runtime_error(RC::fmt("EnumProperty %S does not have a valid Enum value", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("EnumProperty {} does not have a valid Enum value", property->GetName())); } const int64_t first_enum_constant_value = uenum->GetEnumNameByIndex(0).Value; return generate_enum_value(uenum, first_enum_constant_value); @@ -3313,7 +3314,7 @@ namespace RC::UEGenerator if (script_struct == NULL) { - throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty %S", property->GetName().c_str())); + throw std::runtime_error(RC::fmt("Struct is NULL for StructProperty {}", property->GetName())); } const SystemStringType native_struct_name = get_native_struct_name(script_struct); return std::format(SYSSTR("{}{{}}"), native_struct_name); @@ -3377,9 +3378,9 @@ namespace RC::UEGenerator { return SYSSTR("FText::GetEmpty()"); } - throw std::runtime_error(RC::fmt("[generate_default_property_value] Unsupported property class '%S', full name: '%S'", - field_class_name.c_str(), - property->GetFullName().c_str())); + throw std::runtime_error(RC::fmt("[generate_default_property_value] Unsupported property class '{}', full name: '{}'", + field_class_name, + property->GetFullName())); } auto UEHeaderGenerator::get_class_blueprint_info(UClass* uclass) -> ClassBlueprintInfo @@ -3475,7 +3476,7 @@ namespace RC::UEGenerator { throw std::invalid_argument("Encountered a package with an outer object set"); } - SystemStringType package_name = UEStringToSystemString(package->GetName()); + auto package_name = to_system(package->GetName()); if (!package_name.starts_with(SYSSTR("/Script/"))) { return SYSSTR(""); @@ -3850,18 +3851,18 @@ namespace RC::UEGenerator { if (!is_delegate_signature_function(function)) { - throw std::runtime_error(RC::fmt("Function %S is not a delegate signature function", function->GetName().c_str())); + throw std::runtime_error(RC::fmt("Function {} is not a delegate signature function", function->GetName())); } if (!function->GetOuterPrivate()->IsA()) { - throw std::runtime_error(RC::fmt("Delegate Signature Function %S does not have a UPackage as it's owner", function->GetName().c_str())); + throw std::runtime_error(RC::fmt("Delegate Signature Function {} does not have a UPackage as it's owner", function->GetName())); } generate_global_delegate_declaration(function, NULL, header_file); } else { throw std::runtime_error( - RC::fmt("Provided object %S is not of a supported type: %S", object->GetName().c_str(), object->GetClassPrivate()->GetName().c_str())); + RC::fmt("Provided object {} is not of a supported type: {}", object->GetName(), object->GetClassPrivate()->GetName())); } auto iterator = this->m_module_dependencies.find(module_name); @@ -3932,14 +3933,14 @@ namespace RC::UEGenerator if (object->IsA() || object->IsA()) { // Class and struct headers follow the relevant object name - header_name = UEStringToSystemString(object->GetName()); + header_name = to_system(object->GetName()); final_object = object; } else if (object->IsA()) { // Enumeration usually have the E prefix which will be present in the header names // We do not strip it because there are some broken headers that do not follow that convention (e.g. funny Wwise) - header_name = UEStringToSystemString(object->GetName()); + header_name = to_system(object->GetName()); final_object = object; } else @@ -3970,7 +3971,7 @@ namespace RC::UEGenerator if (header_name.empty()) { // Unsupported dependency object type - throw std::runtime_error(RC::fmt("Unsupported dependency object type %S: %S", object->GetClassPrivate()->GetName().c_str(), object->GetName().c_str())); + throw std::runtime_error(RC::fmt("Unsupported dependency object type {}: {}", object->GetClassPrivate()->GetName(), object->GetName())); } if (get_existing_header) @@ -4033,7 +4034,7 @@ namespace RC::UEGenerator top_level_object = top_level_object->GetOuterPrivate(); } - const SystemStringType object_name = UEStringToSystemString(top_level_object->GetName()); + const auto object_name = to_system(top_level_object->GetName()); return std::format(SYSSTR("//CROSS-MODULE INCLUDE V2: -ModuleName={} -ObjectName={} -FallbackName={}\n"), module_name, object_name, fallback_name); } diff --git a/UE4SS/src/UE4SSProgram.cpp b/UE4SS/src/UE4SSProgram.cpp index 8820562de..f47871b03 100644 --- a/UE4SS/src/UE4SSProgram.cpp +++ b/UE4SS/src/UE4SSProgram.cpp @@ -23,7 +23,6 @@ #include #endif #include -#include #include #include #include @@ -99,7 +98,7 @@ namespace RC #define OUTPUT_MEMBER_OFFSETS_FOR_STRUCT(StructName) \ for (const auto& [name, offset] : Unreal::StructName::MemberOffsets) \ { \ - Output::send(SYSSTR(#StructName "::{} = 0x{:X}\n"), UEStringToSystemString(name), offset); \ + Output::send(SYSSTR(#StructName "::{} = 0x{:X}\n"), to_system(name), offset); \ } auto output_all_member_offsets() -> void @@ -139,7 +138,7 @@ namespace RC { UE4SSProgram& program = UE4SSProgram::get_program(); HMODULE lib = PLH::FnCast(program.m_hook_trampoline_load_library_a, &LoadLibraryA)(dll_name); - program.fire_dll_load_for_cpp_mods(to_generic_string(dll_name)); + program.fire_dll_load_for_cpp_mods(to_system(dll_name)); return lib; } @@ -147,7 +146,7 @@ namespace RC { UE4SSProgram& program = UE4SSProgram::get_program(); HMODULE lib = PLH::FnCast(program.m_hook_trampoline_load_library_ex_a, &LoadLibraryExA)(dll_name, file, flags); - program.fire_dll_load_for_cpp_mods(to_generic_string(dll_name)); + program.fire_dll_load_for_cpp_mods(to_system(dll_name)); return lib; } @@ -183,7 +182,7 @@ namespace RC } catch (std::exception& e) { - create_emergency_console_for_early_error(std::format(SYSSTR("The IniParser failed to parse: {}"), to_generic_string(e.what()))); + create_emergency_console_for_early_error(std::format(SYSSTR("The IniParser failed to parse: {}"), to_system(e.what()))); return; } @@ -342,7 +341,7 @@ namespace RC // only log modules with unique addresses (non-modular builds have everything in MainExe) if (i == static_cast(ScanTarget::MainExe) || main_exe_ptr != module.lpBaseOfDll) { - auto module_name = to_generic_string(ScanTargetToString(i)); + auto module_name = to_system(ScanTargetToString(i)); Output::send(SYSSTR("{} @ {} size={:#x}\n"), module_name.c_str(), module.lpBaseOfDll, module.SizeOfImage); } } @@ -354,7 +353,7 @@ namespace RC // only log modules with unique addresses (non-modular builds have everything in MainExe) if (i == static_cast(ScanTarget::MainExe) || main_exe_ptr != module.base_address) { - auto module_name = to_generic_string(ScanTargetToString(i)); + auto module_name = to_system(ScanTargetToString(i)); // FIXME: FIX Why this won't WORK? // Output::send(SYSSTR("{} @ {} size={:#x}\n"), module_name, module.base_address, module.size); } @@ -598,7 +597,7 @@ namespace RC auto list = parser.get_ordered_list(section_name); uint32_t vtable_size = list.size() - 1; list.for_each([&](uint32_t index, SystemStringType& item) { - auto ue_str = SystemStringToUEString(item); + auto ue_str = to_ue(item); callable(index, item, ue_str); }); return vtable_size; @@ -1576,9 +1575,9 @@ namespace RC return static_cast(find_mod_by_name(mod_name, installed_only, is_started)); } - auto UE4SSProgram::find_lua_mod_by_name(UEViewType mod_name, UE4SSProgram::IsInstalled installed_only, IsStarted is_started) -> LuaMod* + auto UE4SSProgram::find_lua_mod_by_name(UEStringViewType mod_name, UE4SSProgram::IsInstalled installed_only, IsStarted is_started) -> LuaMod* { - auto sysstr = UEStringToSystemString(UEStringType{mod_name}); + auto sysstr = to_system(UEStringType{mod_name}); return static_cast(find_mod_by_name(sysstr, installed_only, is_started)); } diff --git a/deps/first/DynamicOutput/CMakeLists.txt b/deps/first/DynamicOutput/CMakeLists.txt index 8bf4261d7..d4b328652 100644 --- a/deps/first/DynamicOutput/CMakeLists.txt +++ b/deps/first/DynamicOutput/CMakeLists.txt @@ -32,4 +32,4 @@ target_compile_definitions(${TARGET} PRIVATE target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(${TARGET} PUBLIC File) +target_link_libraries(${TARGET} PUBLIC File Helpers) diff --git a/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp b/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp index 0182d3f83..b3633fa30 100644 --- a/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp +++ b/deps/first/DynamicOutput/include/DynamicOutput/Output.hpp @@ -2,19 +2,23 @@ #define UE4SS_REWRITTEN_OUTPUT_HPP #include -#include #include #include #include #include #include #include +#include #include #include #include #include #include +#include + +// #include +// #include #if RC_IS_ANSI == 1 #define RC_STD_MAKE_FORMAT_ARGS std::make_format_args @@ -26,6 +30,7 @@ #endif #endif + namespace RC::Output { template @@ -119,14 +124,14 @@ namespace RC::Output { THROW_INTERNAL_FILE_ERROR("[Output::send] Attempted to send but there were no opened devices."); } - + for (const auto& device : m_opened_devices) { ASSERT_OUTPUT_DEVICE_IS_VALID(device) if (device->has_optional_arg()) { - device->receive_with_optional_arg(content, 0); + device->receive_with_optional_arg(content, static_cast(optional_arg)); } else { @@ -136,46 +141,50 @@ namespace RC::Output } template - auto send(File::StringViewType content, FmtArgs... fmt_args) -> void + auto send(File::StringViewType&& content, FmtArgs&&... fmt_args) -> void { if (m_opened_devices.empty()) { THROW_INTERNAL_FILE_ERROR("[Output::send] Attempted to send but there were no opened devices."); } + auto formated = std::vformat(std::forward(content), RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); + for (const auto& device : m_opened_devices) { 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_args...)), 0); + device->receive_with_optional_arg(formated, 0); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } template - auto send(File::StringViewType content, OptionalArg optional_arg, FmtArgs... fmt_args) -> void + auto send(File::StringViewType content, OptionalArg optional_arg, FmtArgs&&... fmt_args) -> void { if (m_opened_devices.empty()) { THROW_INTERNAL_FILE_ERROR("[Output::send] Attempted to send but there were no opened devices."); } + auto formated = std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); + for (const auto& device : m_opened_devices) { 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(formated, RC_STD_MAKE_FORMAT_ARGS(static_cast(optional_arg))); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } @@ -203,23 +212,25 @@ namespace RC::Output } template - auto send(File::StringViewType content, FmtArg fmt_arg, FmtArgs... fmt_args) -> void + auto send(File::StringViewType content, FmtArg&& fmt_arg, FmtArgs&&... fmt_args) -> void { if (m_opened_devices.empty()) { THROW_INTERNAL_FILE_ERROR("[Output::send] Attempted to send but there were no opened devices."); } + auto formated = std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_arg), std::forward(fmt_args))...)); + for (const auto& device : m_opened_devices) { 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(formated, optional_arg); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } @@ -283,37 +294,39 @@ namespace RC::Output } template - auto send(File::StringViewType content, FmtArgs... fmt_args) -> void + auto send(File::StringViewType content, FmtArgs&&... fmt_args) -> void { + auto formated = std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); for (const auto& device : DefaultTargets::get_default_devices_ref()) { ASSERT_DEFAULT_OUTPUT_DEVICE_IS_VALID(device) 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(formated, 0); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } template - auto send(File::StringViewType content, OptionalArg optional_arg, FmtArgs... fmt_args) -> void + auto send(File::StringViewType content, OptionalArg optional_arg, FmtArgs&&... fmt_args) -> void { + auto formated = std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); for (const auto& device : DefaultTargets::get_default_devices_ref()) { ASSERT_DEFAULT_OUTPUT_DEVICE_IS_VALID(device) 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(formated, static_cast(optional_arg)); } else { - device->receive(std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } @@ -339,19 +352,20 @@ namespace RC::Output } template - auto send(File::StringViewType content, FmtArgs... fmt_args) -> void + auto send(File::StringViewType content, FmtArgs&&... fmt_args) -> void { + auto formated = std::vformat(content, RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); for (const auto& device : DefaultTargets::get_default_devices_ref()) { ASSERT_DEFAULT_OUTPUT_DEVICE_IS_VALID(device) if (device->has_optional_arg()) { - device->receive_with_optional_arg(std::vformat((std::string)content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...)), optional_arg); + device->receive_with_optional_arg(formated, optional_arg); } else { - device->receive(std::vformat((std::string)content, RC_STD_MAKE_FORMAT_ARGS(fmt_args...))); + device->receive(formated); } } } diff --git a/deps/first/File/include/File/Macros.hpp b/deps/first/File/include/File/Macros.hpp index d35bfd989..fa0e4aca1 100644 --- a/deps/first/File/include/File/Macros.hpp +++ b/deps/first/File/include/File/Macros.hpp @@ -9,17 +9,20 @@ #define RC_IS_ANSI 0 #endif -#if RC_IS_ANSI == 1 +// always use u16string #define STR(str) u##str -#define SYSSTR(str) str -#else + #ifdef LINUX -#define STR(str) u##str -#define SYSSTR(str) str + #define SYSSTR(str) str + #define IOSTR(str) str #else -#define STR(str) L##str -#define SYSSTR(str) L##str -#endif + #if RC_IS_ANSI == 0 + #define SYSSTR(str) u##str + #define IOSTR(str) u##str + #else + #define SYSSTR(str) str + #define IOSTR(str) str + #endif #endif #ifdef S @@ -45,68 +48,79 @@ construct a Targets object and supply your own devices.") \ namespace RC::File { + typedef std::basic_ofstream u16ofstream; + typedef std::basic_ifstream u16ifstream; + #if RC_IS_ANSI == 1 using StringType = std::string; using StringViewType = std::string_view; using CharType = char; using StreamType = std::ifstream; - // using ToString = std::tostring; - - constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { - return std::to_string(std::forward(numeric_value)); - }; #else -#ifdef WIN32 - using StringType = std::wstring; - using StringViewType = std::wstring_view; - using CharType = wchar_t; - using StreamType = std::wifstream; - constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { - return std::to_wstring(std::forward(numeric_value)); - }; -#else -// on linux, use utf8 - using StringType = std::string; - using StringViewType = std::string_view; - using CharType = char; - using StreamType = std::ifstream; + // System String Types + #ifdef WIN32 + using StringType = std::u16string; + using StringViewType = std::u16string_view; + using CharType = std::u16string::value_type; + using StreamType = u16ifstream; + #else + // on linux, use utf8 + using StringType = std::string; + using StringViewType = std::string_view; + using CharType = char; + using StreamType = std::ifstream; + #endif // WIN32 +#endif // RC_IS_ANSI - constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { - return std::to_string(std::forward(numeric_value)); - }; -#endif -#endif } // namespace RC::File namespace RC { - using SystemStringType = File::StringType; - using SystemStringViewType = File::StringViewType; - using SystemCharType = File::CharType; - using SystemStreamType = File::StreamType; + // Should find a better place for these definitions + // System = C++ String Types +#if RC_IS_ANSI == 1 + using SystemStringType = std::string; + using SystemStringViewType = std::string_view; + using SystemCharType = char; + using SystemStreamType = std::ifstream; + constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { + return std::to_string(std::forward(numeric_value)); + }; + #define SystemStringPrint "%s" +#else + // System String Types + #ifdef WIN32 + using SystemStringType = std::u16string; + using SystemStringViewType = std::u16string_view; + using SystemCharType = std::u16string::value_type; + using SystemStreamType = u16ifstream; + constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { + return std::to_u16string(std::forward(numeric_value)); + }; + #define SystemStringPrint "%S" + #else + // on linux, use utf8 + using SystemStringType = std::string; + using SystemStringViewType = std::string_view; + using SystemCharType = char; + using SystemStreamType = std::ifstream; + constexpr auto ToString = [](auto&& numeric_value) constexpr -> decltype(auto) { + return std::to_string(std::forward(numeric_value)); + }; + #define SystemStringPrint "%s" + #endif // WIN32 +#endif -#ifdef WIN32 - using UEStringType = File::StringType; - using UEViewType = File::StringViewType; - using UECharType = File::CharType; - #define SystemStringPrint "%S" - #define UEStringPrint "%S" - static auto SystemStringToUEString = [](const SystemStringType& str) -> UEStringType { return str; }; - static auto UEStringToSystemString = [](const UEStringType& str) -> SystemStringType { return str; }; +#if RC_IS_ANSI == 1 + using UEStringType = std::string; + using UEStringViewType = std::string_view; + using UECharType = std::string::value_type; + #define UEStringPrint "%s" #else using UEStringType = std::u16string; - using UEViewType = std::u16string_view; - using UECharType = char16_t; - #define SystemStringPrint "%s" + using UEStringViewType = std::u16string_view; + using UECharType = std::u16string::value_type; #define UEStringPrint "%S" - static auto SystemStringToUEString = [](const SystemStringType& str) -> UEStringType { - static std::wstring_convert, char16_t> converter{}; - return converter.from_bytes((std::string)str); - }; - static auto UEStringToSystemString = [](const UEStringType& str) -> SystemStringType { - return std::wstring_convert, char16_t>{}.to_bytes((std::u16string)str); - }; -#endif +#endif // RC_IS_ANSI - constexpr auto ToString = File::ToString; } // namespace RC diff --git a/deps/first/File/src/FileType/WinFile.cpp b/deps/first/File/src/FileType/WinFile.cpp index 7508ee39a..9ae855b9a 100644 --- a/deps/first/File/src/FileType/WinFile.cpp +++ b/deps/first/File/src/FileType/WinFile.cpp @@ -26,7 +26,7 @@ namespace RC::File { if constexpr (sizeof(CharType) > 1) { - if (DeleteFileW(file_path_and_name.wstring().c_str()) == 0) + if (DeleteFileW(file_path_and_name.u16string().c_str()) == 0) { THROW_INTERNAL_FILE_ERROR(std::format("[WinFile::delete_file] Was unable to delete file, error: {}", GetLastError())) } diff --git a/deps/first/Helpers/include/Helpers/Format.hpp b/deps/first/Helpers/include/Helpers/Format.hpp index ea825c228..57ebaea46 100644 --- a/deps/first/Helpers/include/Helpers/Format.hpp +++ b/deps/first/Helpers/include/Helpers/Format.hpp @@ -1,90 +1,13 @@ #pragma once #include -#include -#include - -#ifdef LINUX -#define swprintf_s swprintf -#define sprintf_s snprintf -#endif +#include namespace RC { - template - auto static fmt(const char* fmt, Args... args) -> std::string - { - constexpr size_t out_string_length = 1000; - char out_string[out_string_length]; - - size_t msg_len = strlen(fmt); - - // Attempt to give a hint if the buffer is too small - if (msg_len > out_string_length) - { - fmt = "An error occurred but the message was too long for the buffer."; - msg_len = strlen(fmt); - } - - // If the buffer is too small for the hint message then I guess we do nothing - // The default message will be used which can't be too small since it's calculated at compile-time - if (msg_len < out_string_length) - { - sprintf_s(out_string, out_string_length, fmt, args...); - } - - return out_string; - } - - template - auto static fmt(const wchar_t* fmt, Args... args) -> std::wstring + template + auto static fmt(const std::string_view&& fmt, FmtArgs&&... fmt_args) -> std::string { - constexpr size_t out_string_length = 1000; - wchar_t out_string[out_string_length]; - - size_t msg_len = wcslen(fmt); - - // Attempt to give a hint if the buffer is too small - if (msg_len > out_string_length) - { - fmt = L"An error occurred but the message was too long for the buffer."; - msg_len = wcslen(fmt); - } - - // If the buffer is too small for the hint message then I guess we do nothing - // The default message will be used which can't be too small since it's calculated at compile-time - if (msg_len < out_string_length) - { - swprintf_s(out_string, out_string_length, fmt, args...); - } - - return out_string; - } - -/* - template - auto static fmt(const char16_t* fmt, Args... args) -> std::wstring - { - constexpr size_t out_string_length = 1000; - char16_t out_string[out_string_length]; - - size_t msg_len = wcslen(fmt); - - // Attempt to give a hint if the buffer is too small - if (msg_len > out_string_length) - { - fmt = L"An error occurred but the message was too long for the buffer."; - msg_len = wcslen(fmt); - } - - // If the buffer is too small for the hint message then I guess we do nothing - // The default message will be used which can't be too small since it's calculated at compile-time - if (msg_len < out_string_length) - { - swprintf_s(out_string, out_string_length, fmt, args...); - } - - return out_string; + return std::vformat(std::forward(fmt), RC_STD_MAKE_FORMAT_ARGS(to_file(std::forward(fmt_args))...)); } -*/ -} // namespace RC +} \ No newline at end of file diff --git a/deps/first/Helpers/include/Helpers/String.hpp b/deps/first/Helpers/include/Helpers/String.hpp index c681742a1..631c1e957 100644 --- a/deps/first/Helpers/include/Helpers/String.hpp +++ b/deps/first/Helpers/include/Helpers/String.hpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include @@ -212,10 +214,15 @@ namespace RC auto inline to_wstring(std::string& input) -> std::wstring { + #if WIN32 #pragma warning(disable : 4996) - static std::wstring_convert> converter{}; - return converter.from_bytes(input); + static std::wstring_convert> converter{}; + return converter.from_bytes(input); #pragma warning(default : 4996) + #else + static std::wstring_convert> converter{}; + return converter.from_bytes(input); + #endif } auto inline to_const_wstring(std::string_view input) -> const std::wstring& @@ -248,21 +255,39 @@ namespace RC auto inline to_wstring(std::u16string& input) -> std::wstring { +#ifdef WIN32 return {input.begin(), input.end()}; +#else + throw std::runtime_error{"There is no reason to use this function on non-Windows platforms"}; +#endif } auto inline to_wstring(std::u16string_view input) -> std::wstring { +#ifdef WIN32 auto temp_input = std::u16string{input}; return to_wstring(temp_input); +#else + return to_wstring(std::u16string{input}); +#endif + } + + auto inline to_wstring(std::filesystem::path& input) -> std::wstring + { + return input.wstring(); } auto inline to_string(std::wstring& input) -> std::string { +#ifdef WIN32 #pragma warning(disable : 4996) static std::wstring_convert> converter{}; return converter.to_bytes(input); #pragma warning(default : 4996) +#else + static std::wstring_convert> converter{}; + return converter.to_bytes(input); +#endif } auto inline to_string(std::u16string& input) -> std::string @@ -287,14 +312,23 @@ namespace RC return std::string{input}; } - auto inline to_string(std::string input) -> std::string + auto inline to_string(std::string& input) -> std::string { return std::string{input}; } + auto inline to_string(std::filesystem::path& input) -> std::string + { + return input.string(); + } + auto inline to_u16string(std::wstring& input) -> std::u16string { +#ifdef WIN32 return {input.begin(), input.end()}; +#else + throw std::runtime_error{"There is no reason to use this function on non-Windows platforms"}; +#endif } auto inline to_u16string(std::wstring_view input) -> std::u16string @@ -305,7 +339,10 @@ namespace RC auto inline to_u16string(std::string& input) -> std::u16string { - return {input.begin(), input.end()}; + // codecvt_utf8_utf16 + #pragma warning(disable : 4996) + return std::wstring_convert, char16_t>{}.from_bytes(input); + #pragma warning(default : 4996) } auto inline to_u16string(std::string_view input) -> std::u16string @@ -314,31 +351,215 @@ namespace RC return to_u16string(temp_input); } - auto inline to_generic_string(const auto& input) -> SystemStringType + auto inline to_u16string(std::u16string_view input) -> std::u16string + { + return std::u16string{input}; + } + + auto inline to_u16string(std::u16string& input) -> std::u16string + { + return std::u16string{input}; + } + + auto inline to_u16string(std::filesystem::path& input) -> std::u16string { - if constexpr (std::is_same_v>>, SystemStringViewType>) + return input.u16string(); + } + + // Type traits to check if T is a string type that needs conversion + template + struct is_string_like_t : std::false_type {}; + + // Specializations for the types that need conversion + template<> struct is_string_like_t : std::true_type {}; + template<> struct is_string_like_t : std::true_type {}; + template<> struct is_string_like_t : std::true_type {}; + template<> struct is_string_like_t : std::true_type {}; + template<> struct is_string_like_t : std::true_type {}; + template<> struct is_string_like_t : std::true_type {}; + + template + struct dependent_false : std::false_type {}; + + template + auto stringviewify(T&& tp) { + if constexpr (std::is_same_v, UECharType*> || std::is_same_v, const UECharType*>) { + return UEStringViewType{tp}; + } else if constexpr (std::is_same_v, SystemCharType*> || std::is_same_v, const SystemCharType*>) { + return SystemStringViewType{tp}; + } else if constexpr (std::is_same_v, File::CharType*> || std::is_same_v, const File::CharType*>) { + return File::StringViewType{tp}; + } else { + return std::forward(tp); + } + } + + template + struct _can_be_string_view_t : std::false_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + template<> struct _can_be_string_view_t : std::true_type {}; + + template + struct can_be_string_view_t : _can_be_string_view_t> {}; + + template + struct is_file_string_type : std::disjunction< + std::is_same, + std::is_same + > {}; + + template + struct not_file_string_like_t : std::conjunction>, std::negation>>> {}; + + template + auto inline to_file_string(T&& input) -> File::StringType { + if constexpr (std::is_same_v) + { + return to_string(input); + } + else if constexpr (std::is_same_v) { - return SystemStringType{input}; + return to_wstring(input); } - else if constexpr (std::is_same_v>>, SystemStringType> || - std::is_same_v>>, SystemCharType>) + else if constexpr (std::is_same_v) { - return input; + return to_u16string(input); + } else { + static_assert(dependent_false::value, "Unsupported SystemStringType."); } - else + } + + template + auto to_file(T&& arg) { + if constexpr (can_be_string_view_t::value) { + return to_file_string(stringviewify(std::forward(arg))); + } + else if constexpr (not_file_string_like_t>::value) + { + return to_file_string(std::forward(arg)); + } + else + { + return std::forward(arg); + } + } + + template + struct is_system_string_type : std::disjunction< + std::is_same, + std::is_same + > {}; + + template + struct not_system_string_like_t : std::conjunction>,std::negation>>> {}; + + template + auto inline to_system_string(T&& input) -> SystemStringType { + if constexpr (std::is_same_v) { -#if RC_IS_ANSI == 1 return to_string(input); -#else -#ifdef WIN32 + } + else if constexpr (std::is_same_v) + { return to_wstring(input); -#else + } + else if constexpr (std::is_same_v) + { + return to_u16string(input); + } + else + { + static_assert(dependent_false::value, "Unsupported SystemStringType."); + } + } + + template + auto to_system(T&& arg) { + if constexpr (can_be_string_view_t::value) { + return to_system_string(stringviewify(std::forward(arg))); + } + else if constexpr (not_system_string_like_t>::value) + { + return to_system_string(std::forward(arg)); + } + else + { + return std::forward(arg); + } + } + + template + struct is_ue_string_type : std::disjunction< + std::is_same, + std::is_same + > {}; + + template + struct not_ue_string_like_t : std::conjunction>, std::negation>>> {}; + + template + auto inline to_ue_string(T&& input) -> UEStringType { + if constexpr (std::is_same_v) + { return to_string(input); -#endif -#endif + } + else if constexpr (std::is_same_v) + { + return to_wstring(input); + } + else if constexpr (std::is_same_v) + { + return to_u16string(input); + } + else + { + static_assert(dependent_false::value, "Unsupported SystemStringType."); + } + } + + template + auto to_ue(T&& arg) { + if constexpr (can_be_string_view_t::value) + { + return to_ue_string(stringviewify(std::forward(arg))); + } + else if constexpr (not_ue_string_like_t>::value) + { + return to_ue_string(std::forward(arg)); + } + else + { + return std::forward(arg); } } + template + struct is_lua_string_type : std::disjunction< + std::is_same, + std::is_same + > {}; + + template + struct not_lua_string_like_t : std::negation>> {}; + + template + auto to_lua(T&& arg) { + if constexpr (can_be_string_view_t::value || not_lua_string_like_t>::value) + { + return to_string((arg)); + } + else + { + return std::forward(arg); + } + } + + #define csfor_lua(x) (to_lua((x)).c_str()) + namespace String { auto inline iequal(std::wstring_view a, std::wstring_view b) diff --git a/deps/first/SinglePassSigScanner/include/SigScanner/SinglePassSigScannerWin32.hpp b/deps/first/SinglePassSigScanner/include/SigScanner/SinglePassSigScannerWin32.hpp index a8afd086f..77ad45442 100644 --- a/deps/first/SinglePassSigScanner/include/SigScanner/SinglePassSigScannerWin32.hpp +++ b/deps/first/SinglePassSigScanner/include/SigScanner/SinglePassSigScannerWin32.hpp @@ -346,7 +346,7 @@ namespace RC using SignatureContainerMap = std::unordered_map>; RC_SPSS_API auto static start_scan(SignatureContainerMap& signature_containers) -> void; #ifdef WIN32 - RC_SPSS_API auto static string_scan(std::wstring_view string_to_scan_for, ScanTarget = ScanTarget::MainExe) -> void*; + RC_SPSS_API auto static string_scan(std::u16string_view string_to_scan_for, ScanTarget = ScanTarget::MainExe) -> void*; #endif }; } // namespace RC diff --git a/deps/first/SinglePassSigScanner/src/SinglePassSigScannerWin32.cpp b/deps/first/SinglePassSigScanner/src/SinglePassSigScannerWin32.cpp index 4d2c4ab8a..ea849dbd0 100644 --- a/deps/first/SinglePassSigScanner/src/SinglePassSigScannerWin32.cpp +++ b/deps/first/SinglePassSigScanner/src/SinglePassSigScannerWin32.cpp @@ -375,7 +375,7 @@ namespace RC return vector_of_signatures; } - auto SinglePassScanner::string_scan(std::wstring_view string_to_scan_for, ScanTarget scan_target) -> void* + auto SinglePassScanner::string_scan(std::u16string_view string_to_scan_for, ScanTarget scan_target) -> void* { auto module = SigScannerStaticData::m_modules_info[scan_target]; @@ -406,7 +406,7 @@ namespace RC break; } - std::wstring_view maybe_string = std::wstring_view((const wchar_t*)region_start, string_to_scan_for.size()); + std::u16string_view maybe_string = std::u16string_view((const wchar_t*)region_start, string_to_scan_for.size()); if (maybe_string == string_to_scan_for) { address_found = region_start; diff --git a/deps/first/Unreal b/deps/first/Unreal index e5ea049b8..3d8bd0d11 160000 --- a/deps/first/Unreal +++ b/deps/first/Unreal @@ -1 +1 @@ -Subproject commit e5ea049b854f118b8620c07133d7aa04acece941 +Subproject commit 3d8bd0d11833d2ea7baf5c52ccfb965af6796253 diff --git a/deps/third/CMakeLists.txt b/deps/third/CMakeLists.txt index 33b20f591..469d4ecf2 100644 --- a/deps/third/CMakeLists.txt +++ b/deps/third/CMakeLists.txt @@ -77,12 +77,12 @@ endif() # fmtlib start -FetchContent_Declare(fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG 10.2.1 - GIT_PROGRESS ON) +#FetchContent_Declare(fmt +# GIT_REPOSITORY https://github.com/fmtlib/fmt +# GIT_TAG 10.2.1 +# GIT_PROGRESS ON) -add_subdirectory("fmt") +#add_subdirectory("fmt") # fmtlib end # corrosion start