mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 12:07:46 +08:00
refactor!: General changes (#1578)
- Removed try catch from main.cpp for better error logging - Added migration code to the YimMenu folder - Renamed globals to settings - refactor!: changed symlink
This commit is contained in:
parent
f1f5d4f6c0
commit
346960b012
BIN
BigBaseV2.lnk
BIN
BigBaseV2.lnk
Binary file not shown.
BIN
YimMenu.lnk
Normal file
BIN
YimMenu.lnk
Normal file
Binary file not shown.
@ -4,12 +4,12 @@ extern "C" std::uint64_t g_sound_overload_ret_addr;
|
||||
|
||||
namespace big
|
||||
{
|
||||
class byte_patch_manager
|
||||
{
|
||||
class byte_patch_manager
|
||||
{
|
||||
public:
|
||||
byte_patch_manager();
|
||||
~byte_patch_manager();
|
||||
};
|
||||
};
|
||||
|
||||
inline byte_patch_manager* g_byte_patch_manager;
|
||||
inline byte_patch_manager* g_byte_patch_manager;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
#include "logger/logger.hpp"
|
||||
|
||||
#include "core/globals.hpp"
|
||||
#include "core/settings.hpp"
|
||||
#include "gta/natives.hpp"
|
||||
#include "ped/CPed.hpp"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "globals.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "thread_pool.hpp"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "backend/player_command.hpp"
|
||||
#include "core/data/admin_rids.hpp"
|
||||
#include "core/globals.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta_util.hpp"
|
||||
#include "hooking.hpp"
|
||||
|
266
src/main.cpp
266
src/main.cpp
@ -1,7 +1,6 @@
|
||||
#include "backend/backend.hpp"
|
||||
#include "byte_patch_manager.hpp"
|
||||
#include "common.hpp"
|
||||
#include "core/globals.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "hooking.hpp"
|
||||
@ -33,6 +32,7 @@
|
||||
#include "services/vehicle/handling_service.hpp"
|
||||
#include "services/vehicle/vehicle_control_service.hpp"
|
||||
#include "thread_pool.hpp"
|
||||
#include "util/migrate.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||
@ -52,7 +52,8 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||
std::this_thread::sleep_for(100ms);
|
||||
|
||||
std::filesystem::path base_dir = std::getenv("appdata");
|
||||
base_dir /= "BigBaseV2";
|
||||
base_dir /= "YimMenu";
|
||||
do_migration(base_dir);
|
||||
auto file_manager_instance = std::make_unique<file_manager>(base_dir);
|
||||
|
||||
auto logger_instance = std::make_unique<logger>("YimMenu", file_manager_instance->get_project_file("./cout.log"));
|
||||
@ -61,171 +62,164 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||
|
||||
std::srand(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
|
||||
try
|
||||
{
|
||||
LOG(INFO) << "Yim's Menu Initializing";
|
||||
LOGF(INFO, "Git Info\n\tBranch:\t{}\n\tHash:\t{}\n\tDate:\t{}", version::GIT_BRANCH, version::GIT_SHA1, version::GIT_DATE);
|
||||
LOG(INFO) << "Yim's Menu Initializing";
|
||||
LOGF(INFO, "Git Info\n\tBranch:\t{}\n\tHash:\t{}\n\tDate:\t{}", version::GIT_BRANCH, version::GIT_SHA1, version::GIT_DATE);
|
||||
|
||||
auto thread_pool_instance = std::make_unique<thread_pool>();
|
||||
LOG(INFO) << "Thread pool initialized.";
|
||||
auto thread_pool_instance = std::make_unique<thread_pool>();
|
||||
LOG(INFO) << "Thread pool initialized.";
|
||||
|
||||
g.init(file_manager_instance->get_project_file("./settings.json"));
|
||||
LOG(INFO) << "Settings Loaded.";
|
||||
g.init(file_manager_instance->get_project_file("./settings.json"));
|
||||
LOG(INFO) << "Settings Loaded.";
|
||||
|
||||
auto pointers_instance = std::make_unique<pointers>();
|
||||
LOG(INFO) << "Pointers initialized.";
|
||||
auto pointers_instance = std::make_unique<pointers>();
|
||||
LOG(INFO) << "Pointers initialized.";
|
||||
|
||||
auto byte_patch_manager_instance = std::make_unique<byte_patch_manager>();
|
||||
LOG(INFO) << "Byte Patch Manager initialized.";
|
||||
auto byte_patch_manager_instance = std::make_unique<byte_patch_manager>();
|
||||
LOG(INFO) << "Byte Patch Manager initialized.";
|
||||
|
||||
auto renderer_instance = std::make_unique<renderer>();
|
||||
LOG(INFO) << "Renderer initialized.";
|
||||
auto gui_instance = std::make_unique<gui>();
|
||||
auto renderer_instance = std::make_unique<renderer>();
|
||||
LOG(INFO) << "Renderer initialized.";
|
||||
auto gui_instance = std::make_unique<gui>();
|
||||
|
||||
auto fiber_pool_instance = std::make_unique<fiber_pool>(11);
|
||||
LOG(INFO) << "Fiber pool initialized.";
|
||||
auto fiber_pool_instance = std::make_unique<fiber_pool>(11);
|
||||
LOG(INFO) << "Fiber pool initialized.";
|
||||
|
||||
g_translation_service.init();
|
||||
LOG(INFO) << "Translation Service initialized.";
|
||||
g_translation_service.init();
|
||||
LOG(INFO) << "Translation Service initialized.";
|
||||
|
||||
auto hooking_instance = std::make_unique<hooking>();
|
||||
LOG(INFO) << "Hooking initialized.";
|
||||
auto hooking_instance = std::make_unique<hooking>();
|
||||
LOG(INFO) << "Hooking initialized.";
|
||||
|
||||
auto context_menu_service_instance = std::make_unique<context_menu_service>();
|
||||
auto custom_text_service_instance = std::make_unique<custom_text_service>();
|
||||
auto globals_service_instace = std::make_unique<globals_service>();
|
||||
auto mobile_service_instance = std::make_unique<mobile_service>();
|
||||
auto notification_service_instance = std::make_unique<notification_service>();
|
||||
auto pickup_service_instance = std::make_unique<pickup_service>();
|
||||
auto player_service_instance = std::make_unique<player_service>();
|
||||
auto gta_data_service_instance = std::make_unique<gta_data_service>();
|
||||
auto model_preview_service_instance = std::make_unique<model_preview_service>();
|
||||
auto handling_service_instance = std::make_unique<handling_service>();
|
||||
auto gui_service_instance = std::make_unique<gui_service>();
|
||||
auto script_patcher_service_instance = std::make_unique<script_patcher_service>();
|
||||
auto player_database_service_instance = std::make_unique<player_database_service>();
|
||||
auto hotkey_service_instance = std::make_unique<hotkey_service>();
|
||||
auto matchmaking_service_instance = std::make_unique<matchmaking_service>();
|
||||
auto api_service_instance = std::make_unique<api_service>();
|
||||
auto tunables_service_instance = std::make_unique<tunables_service>();
|
||||
auto script_connection_service_instance = std::make_unique<script_connection_service>();
|
||||
LOG(INFO) << "Registered service instances...";
|
||||
auto context_menu_service_instance = std::make_unique<context_menu_service>();
|
||||
auto custom_text_service_instance = std::make_unique<custom_text_service>();
|
||||
auto globals_service_instace = std::make_unique<globals_service>();
|
||||
auto mobile_service_instance = std::make_unique<mobile_service>();
|
||||
auto notification_service_instance = std::make_unique<notification_service>();
|
||||
auto pickup_service_instance = std::make_unique<pickup_service>();
|
||||
auto player_service_instance = std::make_unique<player_service>();
|
||||
auto gta_data_service_instance = std::make_unique<gta_data_service>();
|
||||
auto model_preview_service_instance = std::make_unique<model_preview_service>();
|
||||
auto handling_service_instance = std::make_unique<handling_service>();
|
||||
auto gui_service_instance = std::make_unique<gui_service>();
|
||||
auto script_patcher_service_instance = std::make_unique<script_patcher_service>();
|
||||
auto player_database_service_instance = std::make_unique<player_database_service>();
|
||||
auto hotkey_service_instance = std::make_unique<hotkey_service>();
|
||||
auto matchmaking_service_instance = std::make_unique<matchmaking_service>();
|
||||
auto api_service_instance = std::make_unique<api_service>();
|
||||
auto tunables_service_instance = std::make_unique<tunables_service>();
|
||||
auto script_connection_service_instance = std::make_unique<script_connection_service>();
|
||||
LOG(INFO) << "Registered service instances...";
|
||||
|
||||
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func, "GUI", false));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func, "GUI", false));
|
||||
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::loop, "Backend Loop", false));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::self_loop, "Self"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::weapons_loop, "Weapon"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicles_loop, "Vehicle"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::misc_loop, "Miscellaneous"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop, "Remote"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop, "LS Customs"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::rainbowpaint_loop, "Rainbow Paint"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop, "Disable Controls"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::world_loop, "World"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::orbital_drone, "Orbital Drone"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicle_control, "Vehicle Control"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::tunables_script, "Tunables"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::squad_spawner, "Squad Spawner"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::loop, "Backend Loop", false));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::self_loop, "Self"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::weapons_loop, "Weapon"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicles_loop, "Vehicle"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::misc_loop, "Miscellaneous"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop, "Remote"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop, "LS Customs"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::rainbowpaint_loop, "Rainbow Paint"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop, "Disable Controls"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::world_loop, "World"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::orbital_drone, "Orbital Drone"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicle_control, "Vehicle Control"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::tunables_script, "Tunables"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::squad_spawner, "Squad Spawner"));
|
||||
|
||||
LOG(INFO) << "Scripts registered.";
|
||||
LOG(INFO) << "Scripts registered.";
|
||||
|
||||
g_hooking->enable();
|
||||
LOG(INFO) << "Hooking enabled.";
|
||||
g_hooking->enable();
|
||||
LOG(INFO) << "Hooking enabled.";
|
||||
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
|
||||
auto lua_manager_instance = std::make_unique<lua_manager>();
|
||||
LOG(INFO) << "Lua manager initialized.";
|
||||
auto lua_manager_instance = std::make_unique<lua_manager>();
|
||||
LOG(INFO) << "Lua manager initialized.";
|
||||
|
||||
g_running = true;
|
||||
g_running = true;
|
||||
|
||||
// start update loop after setting g_running to true to prevent it from exiting instantly
|
||||
g_player_database_service->start_update_loop();
|
||||
// start update loop after setting g_running to true to prevent it from exiting instantly
|
||||
g_player_database_service->start_update_loop();
|
||||
|
||||
while (g_running)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
while (g_running)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
|
||||
lua_manager_instance.reset();
|
||||
LOG(INFO) << "Lua manager uninitialized.";
|
||||
lua_manager_instance.reset();
|
||||
LOG(INFO) << "Lua manager uninitialized.";
|
||||
|
||||
g_hooking->disable();
|
||||
LOG(INFO) << "Hooking disabled.";
|
||||
g_hooking->disable();
|
||||
LOG(INFO) << "Hooking disabled.";
|
||||
|
||||
native_hooks_instance.reset();
|
||||
LOG(INFO) << "Dynamic native hooker uninitialized.";
|
||||
native_hooks_instance.reset();
|
||||
LOG(INFO) << "Dynamic native hooker uninitialized.";
|
||||
|
||||
g_script_mgr.remove_all_scripts();
|
||||
LOG(INFO) << "Scripts unregistered.";
|
||||
g_script_mgr.remove_all_scripts();
|
||||
LOG(INFO) << "Scripts unregistered.";
|
||||
|
||||
// cleans up the thread responsible for saving settings
|
||||
g.destroy();
|
||||
// cleans up the thread responsible for saving settings
|
||||
g.destroy();
|
||||
|
||||
// Make sure that all threads created don't have any blocking loops
|
||||
// otherwise make sure that they have stopped executing
|
||||
thread_pool_instance->destroy();
|
||||
LOG(INFO) << "Destroyed thread pool.";
|
||||
// Make sure that all threads created don't have any blocking loops
|
||||
// otherwise make sure that they have stopped executing
|
||||
thread_pool_instance->destroy();
|
||||
LOG(INFO) << "Destroyed thread pool.";
|
||||
|
||||
script_connection_service_instance.reset();
|
||||
LOG(INFO) << "Script Connection Service reset.";
|
||||
tunables_service_instance.reset();
|
||||
LOG(INFO) << "Tunables Service reset.";
|
||||
hotkey_service_instance.reset();
|
||||
LOG(INFO) << "Hotkey Service reset.";
|
||||
matchmaking_service_instance.reset();
|
||||
LOG(INFO) << "Matchmaking Service reset.";
|
||||
player_database_service_instance.reset();
|
||||
LOG(INFO) << "Player Database Service reset.";
|
||||
api_service_instance.reset();
|
||||
LOG(INFO) << "API Service reset.";
|
||||
script_patcher_service_instance.reset();
|
||||
LOG(INFO) << "Script Patcher Service reset.";
|
||||
gui_service_instance.reset();
|
||||
LOG(INFO) << "Gui Service reset.";
|
||||
gta_data_service_instance.reset();
|
||||
LOG(INFO) << "GTA Data Service reset.";
|
||||
handling_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Service reset.";
|
||||
model_preview_service_instance.reset();
|
||||
LOG(INFO) << "Model Preview Service reset.";
|
||||
mobile_service_instance.reset();
|
||||
LOG(INFO) << "Mobile Service reset.";
|
||||
player_service_instance.reset();
|
||||
LOG(INFO) << "Player Service reset.";
|
||||
pickup_service_instance.reset();
|
||||
LOG(INFO) << "Pickup Service reset.";
|
||||
globals_service_instace.reset();
|
||||
LOG(INFO) << "Globals Service reset.";
|
||||
custom_text_service_instance.reset();
|
||||
LOG(INFO) << "Custom Text Service reset.";
|
||||
context_menu_service_instance.reset();
|
||||
LOG(INFO) << "Context Service reset.";
|
||||
LOG(INFO) << "Services uninitialized.";
|
||||
script_connection_service_instance.reset();
|
||||
LOG(INFO) << "Script Connection Service reset.";
|
||||
tunables_service_instance.reset();
|
||||
LOG(INFO) << "Tunables Service reset.";
|
||||
hotkey_service_instance.reset();
|
||||
LOG(INFO) << "Hotkey Service reset.";
|
||||
matchmaking_service_instance.reset();
|
||||
LOG(INFO) << "Matchmaking Service reset.";
|
||||
player_database_service_instance.reset();
|
||||
LOG(INFO) << "Player Database Service reset.";
|
||||
api_service_instance.reset();
|
||||
LOG(INFO) << "API Service reset.";
|
||||
script_patcher_service_instance.reset();
|
||||
LOG(INFO) << "Script Patcher Service reset.";
|
||||
gui_service_instance.reset();
|
||||
LOG(INFO) << "Gui Service reset.";
|
||||
gta_data_service_instance.reset();
|
||||
LOG(INFO) << "GTA Data Service reset.";
|
||||
handling_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Service reset.";
|
||||
model_preview_service_instance.reset();
|
||||
LOG(INFO) << "Model Preview Service reset.";
|
||||
mobile_service_instance.reset();
|
||||
LOG(INFO) << "Mobile Service reset.";
|
||||
player_service_instance.reset();
|
||||
LOG(INFO) << "Player Service reset.";
|
||||
pickup_service_instance.reset();
|
||||
LOG(INFO) << "Pickup Service reset.";
|
||||
globals_service_instace.reset();
|
||||
LOG(INFO) << "Globals Service reset.";
|
||||
custom_text_service_instance.reset();
|
||||
LOG(INFO) << "Custom Text Service reset.";
|
||||
context_menu_service_instance.reset();
|
||||
LOG(INFO) << "Context Service reset.";
|
||||
LOG(INFO) << "Services uninitialized.";
|
||||
|
||||
hooking_instance.reset();
|
||||
LOG(INFO) << "Hooking uninitialized.";
|
||||
hooking_instance.reset();
|
||||
LOG(INFO) << "Hooking uninitialized.";
|
||||
|
||||
fiber_pool_instance.reset();
|
||||
LOG(INFO) << "Fiber pool uninitialized.";
|
||||
fiber_pool_instance.reset();
|
||||
LOG(INFO) << "Fiber pool uninitialized.";
|
||||
|
||||
renderer_instance.reset();
|
||||
LOG(INFO) << "Renderer uninitialized.";
|
||||
renderer_instance.reset();
|
||||
LOG(INFO) << "Renderer uninitialized.";
|
||||
|
||||
byte_patch_manager_instance.reset();
|
||||
LOG(INFO) << "Byte Patch Manager uninitialized.";
|
||||
byte_patch_manager_instance.reset();
|
||||
LOG(INFO) << "Byte Patch Manager uninitialized.";
|
||||
|
||||
pointers_instance.reset();
|
||||
LOG(INFO) << "Pointers uninitialized.";
|
||||
pointers_instance.reset();
|
||||
LOG(INFO) << "Pointers uninitialized.";
|
||||
|
||||
thread_pool_instance.reset();
|
||||
LOG(INFO) << "Thread pool uninitialized.";
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
LOG(WARNING) << ex.what();
|
||||
}
|
||||
thread_pool_instance.reset();
|
||||
LOG(INFO) << "Thread pool uninitialized.";
|
||||
|
||||
LOG(INFO) << "Farewell!";
|
||||
logger_instance->destroy();
|
||||
|
@ -116,7 +116,7 @@ namespace big
|
||||
call(thread, gta_util::find_script_program(m_script), args);
|
||||
|
||||
delete[] stack;
|
||||
delete[](uint8_t*) thread; // without the cast it ends up calling the destructor which leads to some pretty funny crashes
|
||||
delete[] (uint8_t*)thread; // without the cast it ends up calling the destructor which leads to some pretty funny crashes
|
||||
}
|
||||
|
||||
void script_function::operator()(std::initializer_list<std::uint64_t> args)
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "orbital_drone.hpp"
|
||||
|
||||
#include "backend/bool_command.hpp"
|
||||
#include "core/globals.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
17
src/util/migrate.hpp
Normal file
17
src/util/migrate.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
namespace big
|
||||
{
|
||||
void do_migration(const std::filesystem::path& current_dir)
|
||||
{
|
||||
std::filesystem::path old_dir = std::getenv("appdata");
|
||||
old_dir /= "BigBaseV2";
|
||||
|
||||
if (exists(old_dir) && !exists(current_dir))
|
||||
{
|
||||
LOG(INFO) << "YimMenu folder does not exist, migrating to new folder.";
|
||||
std::filesystem::copy(old_dir, current_dir, std::filesystem::copy_options::recursive);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user