diff --git a/scripts/gtav-classes.cmake b/scripts/gtav-classes.cmake index 3524390d..3ae487c3 100644 --- a/scripts/gtav-classes.cmake +++ b/scripts/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG 56aeddea31d677efa0e5c4f84b4f353d420a8502 + GIT_TAG cf7c1a71b413788371000b56d40c4e8b81c47a2c GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/gta/fidevice.cpp b/src/gta/fidevice.cpp index 30818c42..81ae91ca 100644 --- a/src/gta/fidevice.cpp +++ b/src/gta/fidevice.cpp @@ -1,6 +1,6 @@ #include "fidevice.hpp" - #include "pointers.hpp" +#include "hooking.hpp" namespace rage { @@ -262,6 +262,6 @@ namespace rage bool fiPackfile::Mount(const char* mount_point) { - return big::g_pointers->m_fipackfile_mount(this, mount_point); + return big::g_hooking->get_original()(this, mount_point); } } diff --git a/src/hooking.cpp b/src/hooking.cpp index a2d11182..860b934d 100644 --- a/src/hooking.cpp +++ b/src/hooking.cpp @@ -121,6 +121,8 @@ namespace big detour_hook_helper::add("WVPMDN", g_pointers->m_write_vehicle_proximity_migration_data_node); + detour_hook_helper::add("FPFM", g_pointers->m_fipackfile_mount); + g_hooking = this; } diff --git a/src/hooking.hpp b/src/hooking.hpp index 6eee9517..7f27fcdc 100644 --- a/src/hooking.hpp +++ b/src/hooking.hpp @@ -163,6 +163,8 @@ namespace big static HRESULT direct_sound_capture_create(GUID* guid, IDirectSoundCapture** sound, void* unknown); static void write_vehicle_proximity_migration_data_node(rage::netObject* veh, CVehicleProximityMigrationDataNode* node); + + static bool fipackfile_mount(rage::fiPackfile* this_, const char* mount_point); }; class minhook_keepalive diff --git a/src/hooks/misc/fipackfile_mount.cpp b/src/hooks/misc/fipackfile_mount.cpp new file mode 100644 index 00000000..734f6366 --- /dev/null +++ b/src/hooks/misc/fipackfile_mount.cpp @@ -0,0 +1,44 @@ +#include "hooking.hpp" +#include "gta/fidevice.hpp" +#include "services/gta_data/yim_fipackfile.hpp" +#include "services/gta_data/gta_data_service.hpp" + +namespace big +{ + bool hooks::fipackfile_mount(rage::fiPackfile* this_, const char* mount_point) + { + static bool init = ([] { + if(g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_WAITING) + g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_START); + }(),true); + + auto result = g_hooking->get_original()(this_, mount_point); + + if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_UPDATE_START) + { + yim_fipackfile rpf_wrapper = yim_fipackfile(this_, mount_point); + std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function cb) { + cb(rpf_wrapper); + }); + if (!stricmp(this_->GetName(), "BgScript.rpf")) + { + auto names = yim_fipackfile::get_non_dlc_mounted_devices_names(); + for (auto name : names) + { + auto device = rage::fiDevice::GetDevice(name.c_str(), true); + if (*(void**)this_ == *(void**)device) //make sure it's fipackfile + { + rpf_wrapper = yim_fipackfile((rage::fiPackfile*)device, name); + std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function cb) { + cb(rpf_wrapper); + }); + } + } + g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END); + } + + } + + return result; + } +} diff --git a/src/main.cpp b/src/main.cpp index 49d4c1f5..d67b3ac2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,7 +11,6 @@ #include "script_mgr.hpp" #include "services/api/api_service.hpp" #include "services/context_menu/context_menu_service.hpp" -#include "services/orbital_drone/orbital_drone.hpp" #include "services/custom_text/custom_text_service.hpp" #include "services/globals/globals_service.hpp" #include "services/gta_data/gta_data_service.hpp" @@ -21,6 +20,7 @@ #include "services/mobile/mobile_service.hpp" #include "services/model_preview/model_preview_service.hpp" #include "services/notifications/notification_service.hpp" +#include "services/orbital_drone/orbital_drone.hpp" #include "services/pickups/pickup_service.hpp" #include "services/player_database/player_database_service.hpp" #include "services/players/player_service.hpp" @@ -116,7 +116,7 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) g_script_mgr.add_script(std::make_unique