diff --git a/.gitignore b/.gitignore index 19b5cfb4..8a829f67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # IDE .vs/ -.vscode/ +.vscode/* +!.vscode/launch.json .cache/ # output directory diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..6db4aa9b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "GTA5.exe Attach", + "type": "cppvsdbg", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/src/core/settings.cpp b/src/core/settings.cpp index f39b5da3..10c67a53 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -12,7 +12,7 @@ namespace big void menu_settings::init(const file& save_file) { m_running = true; - m_save_file = std::make_unique(save_file.get_path()); + m_save_file = save_file; load(); g_thread_pool->push([this] { @@ -36,13 +36,13 @@ namespace big { m_default_options = *this; - std::ifstream file(m_save_file->get_path()); + std::ifstream file(m_save_file.get_path()); - if (!m_save_file->exists()) + if (!m_save_file.exists()) { write_default_config(); - file.open(m_save_file->get_path()); + file.open(m_save_file.get_path()); } try @@ -85,7 +85,7 @@ namespace big bool menu_settings::write_default_config() { - std::ofstream file(m_save_file->get_path(), std::ios::out | std::ios::trunc); + std::ofstream file(m_save_file.get_path(), std::ios::out | std::ios::trunc); file << m_default_options.dump(4); file.close(); @@ -124,7 +124,7 @@ namespace big bool menu_settings::save() { - std::ofstream file(m_save_file->get_path(), std::ios::out | std::ios::trunc); + std::ofstream file(m_save_file.get_path(), std::ios::out | std::ios::trunc); nlohmann::json j = *this; file << j.dump(4); file.close(); diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 184a1abf..951c7170 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -58,7 +58,7 @@ namespace big private: bool m_running; - std::unique_ptr m_save_file; + file m_save_file; nlohmann::json m_default_options; nlohmann::json m_options; diff --git a/src/file_manager.cpp b/src/file_manager.cpp new file mode 100644 index 00000000..e9e03cf0 --- /dev/null +++ b/src/file_manager.cpp @@ -0,0 +1,55 @@ +#include "file_manager.hpp" + +namespace big +{ + bool file_manager::init(const std::filesystem::path& base_dir) + { + m_base_dir = base_dir; + file_manager::ensure_folder_exists(m_base_dir); + + return true; + } + + const std::filesystem::path& file_manager::get_base_dir() + { + return m_base_dir; + } + + file file_manager::get_project_file(std::filesystem::path file_path) + { + if (file_path.is_absolute()) + throw std::exception("Project files are relative to the BaseDir, don't use absolute paths!"); + + return file_manager::ensure_file_can_be_created(m_base_dir / file_path); + } + + folder file_manager::get_project_folder(std::filesystem::path folder_path) + { + if (folder_path.is_absolute()) + throw std::exception("Project folders are relative to the BaseDir, don't use absolute paths!"); + + return file_manager::ensure_folder_exists(m_base_dir / folder_path); + } + + std::filesystem::path file_manager::ensure_file_can_be_created(const std::filesystem::path file_path) + { + file_manager::ensure_folder_exists(file_path.parent_path()); + + return file_path; + } + + std::filesystem::path file_manager::ensure_folder_exists(const std::filesystem::path folder_path) + { + bool create_path = !std::filesystem::exists(folder_path); + + if (!create_path && !std::filesystem::is_directory(folder_path)) + { + std::filesystem::remove(folder_path); + create_path = true; + } + if (create_path) + std::filesystem::create_directory(folder_path); + + return folder_path; + } +} diff --git a/src/file_manager.hpp b/src/file_manager.hpp index 7a44576e..6d1526fc 100644 --- a/src/file_manager.hpp +++ b/src/file_manager.hpp @@ -5,66 +5,30 @@ namespace big { - class file_manager; - inline file_manager* g_file_manager{}; - class file_manager final { public: - file_manager(std::filesystem::path base_dir) : - m_base_dir(base_dir) - { - file_manager::ensure_folder_exists(m_base_dir); + file_manager() = default; + virtual ~file_manager() = default; + file_manager(const file_manager&) = delete; + file_manager(file_manager&&) noexcept = delete; + file_manager& operator=(const file_manager&) = delete; + file_manager& operator=(file_manager&&) noexcept = delete; - g_file_manager = this; - } - ~file_manager() - { - g_file_manager = nullptr; - } + bool init(const std::filesystem::path& base_dir); - std::filesystem::path get_base_dir() - { - return m_base_dir; - } + const std::filesystem::path& get_base_dir(); - file get_project_file(std::filesystem::path file_path) - { - if (file_path.is_absolute()) - throw std::exception("Project files are relative to the BaseDir, don't use absolute paths!"); + file get_project_file(std::filesystem::path file_path); - return file(this, file_path); - } - folder get_project_folder(std::filesystem::path folder_path) - { - if (folder_path.is_absolute()) - throw std::exception("Project folders are relative to the BaseDir, don't use absolute paths!"); + folder get_project_folder(std::filesystem::path folder_path); - return folder(this, folder_path); - } - - static std::filesystem::path ensure_file_can_be_created(const std::filesystem::path file_path) - { - file_manager::ensure_folder_exists(file_path.parent_path()); - - return file_path; - } - static std::filesystem::path ensure_folder_exists(const std::filesystem::path folder_path) - { - bool create_path = !std::filesystem::exists(folder_path); - - if (!create_path && !std::filesystem::is_directory(folder_path)) - { - std::filesystem::remove(folder_path); - create_path = true; - } - if (create_path) - std::filesystem::create_directory(folder_path); - - return folder_path; - } + static std::filesystem::path ensure_file_can_be_created(const std::filesystem::path file_path); + static std::filesystem::path ensure_folder_exists(const std::filesystem::path folder_path); private: std::filesystem::path m_base_dir; + }; + inline auto g_file_manager = file_manager(); } \ No newline at end of file diff --git a/src/file_manager/file.cpp b/src/file_manager/file.cpp index 2496ded3..92507620 100644 --- a/src/file_manager/file.cpp +++ b/src/file_manager/file.cpp @@ -5,16 +5,24 @@ namespace big { - file::file(file_manager* file_manager, std::filesystem::path file_path) : - file(file_manager->get_base_dir() / file_path) + file::file(const std::filesystem::path& file_path) : + m_file_path(file_path) { - m_is_project_file = true; } - file::file(std::filesystem::path file_path) : - m_file_path(file_manager::ensure_file_can_be_created(file_path)), - m_is_project_file(false) + void file::operator=(const file& other) { + m_file_path = other.m_file_path; + } + + file::operator std::filesystem::path() + { + return m_file_path; + } + + file::operator std::filesystem::path&() + { + return m_file_path; } bool file::exists() const diff --git a/src/file_manager/file.hpp b/src/file_manager/file.hpp index 6c71b135..c62f51e3 100644 --- a/src/file_manager/file.hpp +++ b/src/file_manager/file.hpp @@ -7,16 +7,16 @@ namespace big class file { public: - file(std::filesystem::path file_path); + file(const std::filesystem::path& file_path = ""); + void operator=(const file& other); + operator std::filesystem::path(); + operator std::filesystem::path&(); - file copy(std::filesystem::path new_path); + file copy(const std::filesystem::path& new_path); bool exists() const; const std::filesystem::path get_path() const; file move(std::filesystem::path new_path); - protected: - file(file_manager* file_manager, std::filesystem::path file_path); - private: friend class file_manager; diff --git a/src/file_manager/folder.cpp b/src/file_manager/folder.cpp index a71c4727..e0adf19d 100644 --- a/src/file_manager/folder.cpp +++ b/src/file_manager/folder.cpp @@ -4,15 +4,8 @@ namespace big { - folder::folder(file_manager* file_manager, std::filesystem::path file_path) : - folder(file_manager->get_base_dir() / file_path) - { - m_file_manager = file_manager; - m_is_project_file = true; - } - - folder::folder(std::filesystem::path folder_path) : - m_folder_path(file_manager::ensure_folder_exists(folder_path)) + folder::folder(const std::filesystem::path& folder_path) : + m_folder_path(folder_path) { } diff --git a/src/file_manager/folder.hpp b/src/file_manager/folder.hpp index a0d24907..c836a07e 100644 --- a/src/file_manager/folder.hpp +++ b/src/file_manager/folder.hpp @@ -8,14 +8,11 @@ namespace big class folder { public: - folder(std::filesystem::path folder_path); + folder(const std::filesystem::path& folder_path = ""); file get_file(std::filesystem::path file_path) const; const std::filesystem::path get_path() const; - protected: - folder(file_manager* file_manager, std::filesystem::path file_path); - private: friend class file_manager; file_manager* m_file_manager; diff --git a/src/gta/sound.hpp b/src/gta/sound.hpp index ea6ada3f..ba592728 100644 --- a/src/gta/sound.hpp +++ b/src/gta/sound.hpp @@ -91,9 +91,9 @@ class IDirectSoundCaptureBuffer virtual HRESULT Start(int flags) { - if (big::g_file_manager->get_project_file("./audio.wav").exists()) + if (big::g_file_manager.get_project_file("./audio.wav").exists()) { - std::ifstream wave_stream(big::g_file_manager->get_project_file("./audio.wav").get_path(), std::ios::in | std::ios::binary); + std::ifstream wave_stream(big::g_file_manager.get_project_file("./audio.wav").get_path(), std::ios::in | std::ios::binary); // https://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html int header_size = 0; diff --git a/src/main.cpp b/src/main.cpp index a9bb11ea..72e73cff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,9 +55,9 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) std::filesystem::path base_dir = std::getenv("appdata"); base_dir /= "YimMenu"; do_migration(base_dir); - auto file_manager_instance = std::make_unique(base_dir); + g_file_manager.init(base_dir); - auto logger_instance = std::make_unique("YimMenu", file_manager_instance->get_project_file("./cout.log")); + auto logger_instance = std::make_unique("YimMenu", g_file_manager.get_project_file("./cout.log")); EnableMenuItem(GetSystemMenu(GetConsoleWindow(), 0), SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); @@ -69,7 +69,7 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) auto thread_pool_instance = std::make_unique(); LOG(INFO) << "Thread pool initialized."; - g.init(file_manager_instance->get_project_file("./settings.json")); + g.init(g_file_manager.get_project_file("./settings.json")); LOG(INFO) << "Settings Loaded."; auto pointers_instance = std::make_unique(); @@ -138,7 +138,7 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) auto native_hooks_instance = std::make_unique(); LOG(INFO) << "Dynamic native hooker initialized."; - auto lua_manager_instance = std::make_unique(g_file_manager->get_project_folder("scripts")); + auto lua_manager_instance = std::make_unique(g_file_manager.get_project_folder("scripts")); LOG(INFO) << "Lua manager initialized."; g_running = true; @@ -229,8 +229,6 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) logger_instance->destroy(); logger_instance.reset(); - file_manager_instance.reset(); - CloseHandle(g_main_thread); FreeLibraryAndExitThread(g_hmodule, 0); }, diff --git a/src/pointers.cpp b/src/pointers.cpp index 1c538310..aa454a6e 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1419,8 +1419,8 @@ namespace big } pointers::pointers() : - m_gta_pointers_cache(g_file_manager->get_project_file("./cache/gta_pointers.bin")), - m_sc_pointers_cache(g_file_manager->get_project_file("./cache/sc_pointers.bin")) + m_gta_pointers_cache(g_file_manager.get_project_file("./cache/gta_pointers.bin")), + m_sc_pointers_cache(g_file_manager.get_project_file("./cache/sc_pointers.bin")) { g_pointers = this; diff --git a/src/renderer.cpp b/src/renderer.cpp index dd0646cb..ef7b0788 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -24,7 +24,7 @@ namespace big } m_d3d_device->GetImmediateContext(&m_d3d_device_context); - auto file_path = g_file_manager->get_project_file("./imgui.ini").get_path(); + auto file_path = g_file_manager.get_project_file("./imgui.ini").get_path(); ImGuiContext* ctx = ImGui::CreateContext(); diff --git a/src/services/creator_storage/creator_storage_service.cpp b/src/services/creator_storage/creator_storage_service.cpp index abb3e28b..8e73d728 100644 --- a/src/services/creator_storage/creator_storage_service.cpp +++ b/src/services/creator_storage/creator_storage_service.cpp @@ -86,7 +86,7 @@ namespace big big::folder creator_storage_service::check_jobs_folder() { - const auto folder = g_file_manager->get_project_folder("./jobs"); + const auto folder = g_file_manager.get_project_folder("./jobs"); return folder; } diff --git a/src/services/globals/globals_service.cpp b/src/services/globals/globals_service.cpp index 2825dfcf..84cc59af 100644 --- a/src/services/globals/globals_service.cpp +++ b/src/services/globals/globals_service.cpp @@ -4,37 +4,30 @@ namespace big { - globals_service::globals_service() - { - g_globals_service = this; - } + globals_service::globals_service() : + m_globals_file(g_file_manager.get_project_file("./globals.json")) + { } globals_service::~globals_service() { - g_globals_service = nullptr; - m_running = false; - this->save(); + save(); } - void globals_service::build(nlohmann::json& data) + void globals_service::build() { m_globals.clear(); - for (auto& offset : data) - m_globals.push_back(global(offset)); - for (auto& global : m_globals) global.build_cache(); } bool globals_service::load() { - std::string path = std::getenv("appdata"); - path += this->file_location; + m_globals_file; - std::ifstream file(path); + std::ifstream file(m_globals_file.get_path(), std::ios::binary); if (!file.is_open()) return false; @@ -42,9 +35,10 @@ namespace big try { nlohmann::json j; - j << file; + file >> j; + m_globals = j.get(); - this->build(j); + build(); } catch (const std::exception&) { @@ -66,13 +60,9 @@ namespace big void globals_service::save() { - nlohmann::json j = nlohmann::json::array(); - for (auto& global : m_globals) - j.push_back(global.to_json()); + nlohmann::json j = m_globals; - std::string path = std::getenv("appdata"); - path += this->file_location; - std::ofstream file(path, std::ios::out | std::ios::trunc); + std::ofstream file(m_globals_file.get_path(), std::ios::binary | std::ios::out | std::ios::trunc); try { diff --git a/src/services/globals/globals_service.hpp b/src/services/globals/globals_service.hpp index cfe39ecc..ac8f92e6 100644 --- a/src/services/globals/globals_service.hpp +++ b/src/services/globals/globals_service.hpp @@ -5,14 +5,10 @@ namespace big { struct global_offset { - global_offset(nlohmann::json data) - { - m_offset = data["offset"]; - - if (data.contains("size")) - m_size = data["size"]; - } + int m_offset = 0; + int m_size = 0; + global_offset() = default; global_offset(int offset, int size = 0) { m_offset = offset; @@ -25,22 +21,8 @@ namespace big { return m_size ? internal_cache.at(m_offset, m_size) : internal_cache.at(m_offset); } - - nlohmann::json to_json() - { - nlohmann::json j; - - j["offset"] = m_offset; - if (m_size) - j["size"] = m_size; - - return j; - } - - private: - int m_offset = 0; - int m_size = 0; }; + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(global_offset, m_offset, m_size) struct global { @@ -50,30 +32,19 @@ namespace big std::vector m_offsets; int m_value; - global(nlohmann::json data) + global() = default; + global(const char* name, const int base_address, const bool freeze, const int (*offsets)[2], int offset_count) : + m_name(name), + m_base_address(base_address), + m_freeze(freeze) { m_internal_id = ++m_instance_count; - m_base_address = data["base_address"]; - m_freeze = data["freeze"]; - m_name = data["name"]; - m_value = data["value"]; - - for (auto& offset : data["offsets"]) - m_offsets.push_back(global_offset(offset)); - } - - global(const char* name, const int base_address, const bool freeze, const int (*offsets)[2], int offset_count) - { - m_internal_id = ++m_instance_count; - - m_base_address = base_address; - m_freeze = freeze; - m_name = std::string(name); - m_value = 0; - - for (int i = 0; i < offset_count; i++) - m_offsets.push_back(global_offset(offsets[i][0], offsets[i][1])); + for (int i = 0; i < offset_count; ++i) + { + const auto offset = offsets[i]; + m_offsets.push_back({ offset[0], offset[1] }); + } } void build_cache() @@ -105,22 +76,6 @@ namespace big this->write(); } - nlohmann::json to_json() - { - nlohmann::json j; - - j["base_address"] = m_base_address; - j["freeze"] = m_freeze; - j["name"] = m_name; - j["value"] = m_value; - - j["offsets"] = nlohmann::json::array(); - for (auto& offset : m_offsets) - j["offsets"].push_back(offset.to_json()); - - return j; - } - void write() { *m_internal_addr = m_value; @@ -132,10 +87,12 @@ namespace big int m_internal_id; int* m_internal_addr; }; + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(global, m_base_address, m_freeze, m_offsets, m_name, m_value) + using global_vec = std::vector; class globals_service { - const char* file_location = "\\BigBaseV2\\globals.json"; + file m_globals_file; public: globals_service(); @@ -145,13 +102,13 @@ namespace big void loop(); void save(); - std::vector m_globals; + global_vec m_globals; bool m_running = false; - ; private: - void build(nlohmann::json& data); + void build(); + }; - inline globals_service* g_globals_service{}; + inline auto g_globals_service = globals_service(); } \ No newline at end of file diff --git a/src/services/gta_data/gta_data_service.cpp b/src/services/gta_data/gta_data_service.cpp index 409473ff..e685d1d0 100644 --- a/src/services/gta_data/gta_data_service.cpp +++ b/src/services/gta_data/gta_data_service.cpp @@ -30,8 +30,8 @@ namespace big } gta_data_service::gta_data_service() : - m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 5), - m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 4), + m_peds_cache(g_file_manager.get_project_file("./cache/peds.bin"), 5), + m_vehicles_cache(g_file_manager.get_project_file("./cache/vehicles.bin"), 4), m_update_state(eGtaDataUpdateState::IDLE) { if (!is_cache_up_to_date()) @@ -161,7 +161,7 @@ namespace big m_peds_cache.load(); m_vehicles_cache.load(); - auto weapons_file = g_file_manager->get_project_file("./cache/weapons.json"); + auto weapons_file = g_file_manager.get_project_file("./cache/weapons.json"); if (weapons_file.exists()) { std::ifstream file(weapons_file.get_path()); @@ -593,7 +593,7 @@ namespace big m_weapons_cache.weapon_components.insert({weapon_component.m_name, weapon_component}); } - auto weapons_file = big::g_file_manager->get_project_file("./cache/weapons.json"); + auto weapons_file = g_file_manager.get_project_file("./cache/weapons.json"); std::ofstream file(weapons_file.get_path()); try { diff --git a/src/services/locals/locals_service.cpp b/src/services/locals/locals_service.cpp index d4a3b468..6942fa6c 100644 --- a/src/services/locals/locals_service.cpp +++ b/src/services/locals/locals_service.cpp @@ -24,7 +24,7 @@ namespace big std::filesystem::path locals_service::get_path() { - return g_file_manager->get_project_file("locals.json").get_path(); + return g_file_manager.get_project_file("locals.json").get_path(); } bool locals_service::load() diff --git a/src/services/player_database/player_database_service.cpp b/src/services/player_database/player_database_service.cpp index f40f7350..cd6ec923 100644 --- a/src/services/player_database/player_database_service.cpp +++ b/src/services/player_database/player_database_service.cpp @@ -11,7 +11,7 @@ namespace big g.player_db.update_player_online_states); player_database_service::player_database_service() : - m_file_path(g_file_manager->get_project_file("./players.json").get_path()) + m_file_path(g_file_manager.get_project_file("./players.json").get_path()) { load(); g_player_database_service = this; diff --git a/src/services/squad_spawner/squad_spawner_save_files.cpp b/src/services/squad_spawner/squad_spawner_save_files.cpp index 8582ff61..05fe087a 100644 --- a/src/services/squad_spawner/squad_spawner_save_files.cpp +++ b/src/services/squad_spawner/squad_spawner_save_files.cpp @@ -5,7 +5,7 @@ namespace big std::filesystem::path squad_spawner::get_file_path() { - return g_file_manager->get_project_folder("squad_spawner").get_path(); + return g_file_manager.get_project_folder("squad_spawner").get_path(); } bool squad_spawner::fetch_squads() diff --git a/src/services/translation_service/translation_service.cpp b/src/services/translation_service/translation_service.cpp index d75cc463..ecca6e4d 100644 --- a/src/services/translation_service/translation_service.cpp +++ b/src/services/translation_service/translation_service.cpp @@ -17,7 +17,7 @@ namespace big void translation_service::init() { - m_translation_directory = std::make_unique(g_file_manager->get_project_folder("./translations").get_path()); + m_translation_directory = std::make_unique(g_file_manager.get_project_folder("./translations").get_path()); bool loaded_remote_index = false; for (size_t i = 0; i < 5 && !loaded_remote_index; i++) diff --git a/src/services/tunables/tunables_service.cpp b/src/services/tunables/tunables_service.cpp index 5dfe829a..03b61366 100644 --- a/src/services/tunables/tunables_service.cpp +++ b/src/services/tunables/tunables_service.cpp @@ -12,7 +12,7 @@ namespace big { tunables_service::tunables_service() : - m_cache_file(g_file_manager->get_project_file("./cache/tunables.bin"), 1) + m_cache_file(g_file_manager.get_project_file("./cache/tunables.bin"), 1) { m_cache_file.load(); diff --git a/src/services/vehicle/handling_service.cpp b/src/services/vehicle/handling_service.cpp index 3b5ee6f2..e406f657 100644 --- a/src/services/vehicle/handling_service.cpp +++ b/src/services/vehicle/handling_service.cpp @@ -5,7 +5,7 @@ namespace big { handling_service::handling_service() : - m_profiles_folder(g_file_manager->get_project_folder("./handling_profiles")) + m_profiles_folder(g_file_manager.get_project_folder("./handling_profiles")) { g_handling_service = this; diff --git a/src/services/vehicle/persist_car_service.cpp b/src/services/vehicle/persist_car_service.cpp index e4910beb..c5ebe7ef 100644 --- a/src/services/vehicle/persist_car_service.cpp +++ b/src/services/vehicle/persist_car_service.cpp @@ -514,7 +514,7 @@ namespace big big::folder persist_car_service::check_vehicle_folder() { - const auto folder = g_file_manager->get_project_folder("./saved_json_vehicles"); + const auto folder = g_file_manager.get_project_folder("./saved_json_vehicles"); return folder; } diff --git a/src/services/vehicle/xml_vehicles_service.cpp b/src/services/vehicle/xml_vehicles_service.cpp index 576532d2..57476ec8 100644 --- a/src/services/vehicle/xml_vehicles_service.cpp +++ b/src/services/vehicle/xml_vehicles_service.cpp @@ -21,7 +21,7 @@ namespace big void xml_vehicles_service::fetch_xml_files() { - auto folder_path = g_file_manager->get_project_folder("xml_vehicles").get_path(); + auto folder_path = g_file_manager.get_project_folder("xml_vehicles").get_path(); try { diff --git a/src/util/animations.hpp b/src/util/animations.hpp index c6a9b7bb..f8ee7320 100644 --- a/src/util/animations.hpp +++ b/src/util/animations.hpp @@ -55,14 +55,14 @@ namespace big::animations all_anims.clear(); all_dicts.clear(); - if (!std::filesystem::exists(g_file_manager->get_project_file("animDictsCompact.json").get_path())) + if (!std::filesystem::exists(g_file_manager.get_project_file("animDictsCompact.json").get_path())) { LOG(INFO) << "Animations file is not in directory. https://raw.githubusercontent.com/DurtyFree/gta-v-data-dumps/master/animDictsCompact.json"; g_notification_service->push_warning("Animations", "Please download the appropriate animations json and put it in the mod directory."); return; } - auto path = g_file_manager->get_project_file("animDictsCompact.json").get_path(); + auto path = g_file_manager.get_project_file("animDictsCompact.json").get_path(); try { diff --git a/src/util/spam.hpp b/src/util/spam.hpp index 7d190e4e..68191020 100644 --- a/src/util/spam.hpp +++ b/src/util/spam.hpp @@ -70,7 +70,7 @@ namespace big::spam inline void log_chat(char* msg, player_ptr player, bool is_spam) { - std::ofstream spam_log(g_file_manager->get_project_file(is_spam ? "./spam.log" : "./chat.log").get_path(), std::ios::app); + std::ofstream spam_log(g_file_manager.get_project_file(is_spam ? "./spam.log" : "./chat.log").get_path(), std::ios::app); auto& plData = *player->get_net_data(); auto ip = player->get_ip_address(); diff --git a/src/util/system.hpp b/src/util/system.hpp index 38156efd..0d5d9459 100644 --- a/src/util/system.hpp +++ b/src/util/system.hpp @@ -10,7 +10,7 @@ namespace big::system { DWORD64 base_address = memory::module("GTA5.exe").begin().as(); - const auto file_path = g_file_manager->get_project_file("./entrypoints.txt"); + const auto file_path = g_file_manager.get_project_file("./entrypoints.txt"); auto file = std::ofstream(file_path.get_path(), std::ios::out | std::ios::trunc); for (auto& map : g_crossmap) diff --git a/src/util/teleport.hpp b/src/util/teleport.hpp index 58161892..54d04ba9 100644 --- a/src/util/teleport.hpp +++ b/src/util/teleport.hpp @@ -20,7 +20,7 @@ namespace big::teleport inline std::filesystem::path get_telelocations_file_path() { - return g_file_manager->get_project_file("telelocations.json").get_path(); + return g_file_manager.get_project_file("telelocations.json").get_path(); } inline bool fetch_saved_locations() diff --git a/src/views/debug/view_debug_globals.cpp b/src/views/debug/view_debug_globals.cpp index 9d0aee5b..34d2b715 100644 --- a/src/views/debug/view_debug_globals.cpp +++ b/src/views/debug/view_debug_globals.cpp @@ -9,17 +9,17 @@ namespace big { if (ImGui::BeginTabItem("DEBUG_TAB_GLOBALS"_T.data())) { - if (ImGui::Checkbox("DEBUG_GLOBALS_ENABLE_FREEZING"_T.data(), &g_globals_service->m_running) - && g_globals_service->m_running) + if (ImGui::Checkbox("DEBUG_GLOBALS_ENABLE_FREEZING"_T.data(), &g_globals_service.m_running) + && g_globals_service.m_running) g_thread_pool->push([&]() { - g_globals_service->loop(); + g_globals_service.loop(); }); if (components::button("LOAD"_T)) - g_globals_service->load(); + g_globals_service.load(); ImGui::SameLine(); if (components::button("SAVE"_T)) - g_globals_service->save(); + g_globals_service.save(); ImGui::SameLine(); @@ -81,7 +81,7 @@ namespace big auto new_global = global(name, base_address, freeze, offsets, offset_count); new_global.build_cache(); - g_globals_service->m_globals.push_back(new_global); + g_globals_service.m_globals.push_back(new_global); strcpy(name, ""); freeze = false; @@ -94,7 +94,7 @@ namespace big ImGui::EndPopup(); } - for (auto& global : g_globals_service->m_globals) + for (auto& global : g_globals_service.m_globals) { char label[64]; @@ -128,9 +128,9 @@ namespace big if (components::button("DELETE"_T)) { - for (int i = 0; i < g_globals_service->m_globals.size(); i++) - if (auto& it = g_globals_service->m_globals.at(i); it.get_id() == global.get_id()) - g_globals_service->m_globals.erase(g_globals_service->m_globals.begin() + i); + for (int i = 0; i < g_globals_service.m_globals.size(); i++) + if (auto& it = g_globals_service.m_globals.at(i); it.get_id() == global.get_id()) + g_globals_service.m_globals.erase(g_globals_service.m_globals.begin() + i); break; } diff --git a/src/views/self/view_outfit_editor.cpp b/src/views/self/view_outfit_editor.cpp index 89cead02..6189ea1f 100644 --- a/src/views/self/view_outfit_editor.cpp +++ b/src/views/self/view_outfit_editor.cpp @@ -161,7 +161,7 @@ namespace big ImGui::Separator(); static char outfit_name[MAX_PATH] = {}; - static folder saved_outfit_path = g_file_manager->get_project_folder("saved_outfits"); + static folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits"); std::vector saved_outfits; for (const auto& directory_entry : std::filesystem::directory_iterator(saved_outfit_path.get_path())) saved_outfits.push_back(directory_entry.path().filename().generic_string());