diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 76ce9d2d..8bb7ec70 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -1,4 +1,5 @@ #pragma once +#include "rage/rlSessionInfo.hpp" #include "weapon/CAmmoInfo.hpp" #include "weapon/CWeaponInfo.hpp" #include "enums.hpp" @@ -172,6 +173,8 @@ namespace big { int hour{}, minute{}, second{}; } custom_time; + bool join_queued = false; + rage::rlSessionInfo info; }; struct settings { diff --git a/BigBaseV2/src/function_types.hpp b/BigBaseV2/src/function_types.hpp index 5d73886d..71f762b3 100644 --- a/BigBaseV2/src/function_types.hpp +++ b/BigBaseV2/src/function_types.hpp @@ -1,10 +1,4 @@ #pragma once -#include "common.hpp" -#include "gta/fwddec.hpp" -#include "gta/player.hpp" -#include "gta/natives.hpp" -#include "gta/replay.hpp" -#include "network/CNetComplaintMgr.hpp" namespace big::functions { @@ -59,4 +53,7 @@ namespace big::functions using fipackfile_open_archive = bool(*)(rage::fiPackfile* this_, const char* archive, bool b_true, int type, intptr_t very_false); using fipackfile_mount = bool(*)(rage::fiPackfile* this_, const char* mount_point); using fipackfile_unmount = bool(*)(const char* mount_point); + + using start_get_session_by_gamer_handle = bool(*)(int metric_manager, rage::rlGamerHandle* handles, int count, rage::rlSessionByGamerTaskResult* result, int unk, bool* success, int* state); + using join_session_by_info = bool(*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount); } diff --git a/BigBaseV2/src/gta/fwddec.hpp b/BigBaseV2/src/gta/fwddec.hpp index 44351877..ded77337 100644 --- a/BigBaseV2/src/gta/fwddec.hpp +++ b/BigBaseV2/src/gta/fwddec.hpp @@ -46,6 +46,9 @@ namespace rage class fiDevice; class fiPackfile; + + class rlSessionInfo; + class rlSessionByGamerTaskResult; } class GtaThread; @@ -65,7 +68,9 @@ class CPickup; class CPedFactory; class CVehicleFactory; +class Network; class CNetGamePlayer; class CNetworkPlayerMgr; class CPlayerInfo; class CNetworkObjectMgr; +class CNetComplaintMgr; diff --git a/BigBaseV2/src/native_hooks/native_hooks.cpp b/BigBaseV2/src/native_hooks/native_hooks.cpp index a81035b0..7bf369c9 100644 --- a/BigBaseV2/src/native_hooks/native_hooks.cpp +++ b/BigBaseV2/src/native_hooks/native_hooks.cpp @@ -4,6 +4,7 @@ #include "freemode.hpp" #include "gta_util.hpp" #include "shop_controller.hpp" +#include "network_session_host.hpp" namespace big { @@ -18,6 +19,7 @@ namespace big add_native_detour(RAGE_JOAAT("carmod_shop"), 0x767FBC2AC802EF3D, carmod_shop::STAT_GET_INT); add_native_detour(RAGE_JOAAT("freemode"), 0x95914459A87EBA28, freemode::NETWORK_BAIL); add_native_detour(RAGE_JOAAT("shop_controller"), 0xDC38CC1E35B6A5D7, shop_controller::SET_WARNING_MESSAGE_WITH_HEADER); + add_native_detour(RAGE_JOAAT("maintransition"), 0x6F3D4ED9BEE4E61D, network::NETWORK_SESSION_HOST); for (const auto& native_detours_for_script : m_native_registrations) if (const auto thread = gta_util::find_script_thread(native_detours_for_script.first); thread != nullptr && thread->m_context.m_state == rage::eThreadState::running) @@ -57,7 +59,7 @@ namespace big if (const auto& pair = m_native_registrations.find(ALL_SCRIPT_HASH); pair != m_native_registrations.end()) for (const auto& native_hook_reg : pair->second) native_replacements.insert(native_hook_reg); - + // Functions that only need to be detoured for a specific script if (const auto& pair = m_native_registrations.find(script_hash); pair != m_native_registrations.end()) for (const auto& native_hook_reg : pair->second) @@ -90,4 +92,4 @@ namespace big LOG_IF(G3LOG_DEBUG, g->debug.logs.script_hook_logs) << gta_thread->m_name << " script terminated, cleaning up native hooks"; } } -} \ No newline at end of file +} diff --git a/BigBaseV2/src/native_hooks/network_session_host.hpp b/BigBaseV2/src/native_hooks/network_session_host.hpp new file mode 100644 index 00000000..7bb14acd --- /dev/null +++ b/BigBaseV2/src/native_hooks/network_session_host.hpp @@ -0,0 +1,24 @@ +#pragma once +#include "native_hooks.hpp" +#include "natives.hpp" +#include "pointers.hpp" + +namespace big +{ + namespace network + { + inline void NETWORK_SESSION_HOST(rage::scrNativeCallContext* src) + { + if (g->session.join_queued) + { + g_pointers->m_join_session_by_info(*g_pointers->m_network, &g->session.info, 0, 0, nullptr, 0); + g->session.join_queued = false; + src->set_return_value(TRUE); + } + else + { + src->set_return_value(NETWORK::NETWORK_SESSION_HOST(src->get_arg(0), src->get_arg(1), src->get_arg(2))); + } + } + } +} diff --git a/BigBaseV2/src/pointers.cpp b/BigBaseV2/src/pointers.cpp index d612d9c6..f6569c50 100644 --- a/BigBaseV2/src/pointers.cpp +++ b/BigBaseV2/src/pointers.cpp @@ -398,6 +398,18 @@ namespace big m_format_metric_for_sending = ptr.as(); }); + // Get Session By Gamer Handle + main_batch.add("SGSBGH", "E8 ? ? ? ? 84 C0 0F 84 ? ? ? ? 8B 05 ? ? ? ? 48 8D 4C 24", [this](memory::handle ptr) + { + m_start_get_session_by_gamer_handle = ptr.add(1).rip().as(); + }); + + // Join Session By Info + main_batch.add("JSBI", "E8 ? ? ? ? 0F B6 CB 84 C0 41 0F 44 CD", [this](memory::handle ptr) + { + m_join_session_by_info = ptr.add(1).rip().as(); + }); + auto mem_region = memory::module(nullptr); main_batch.run(mem_region); diff --git a/BigBaseV2/src/pointers.hpp b/BigBaseV2/src/pointers.hpp index 873c01de..47798a96 100644 --- a/BigBaseV2/src/pointers.hpp +++ b/BigBaseV2/src/pointers.hpp @@ -106,6 +106,9 @@ namespace big Network** m_network; + functions::start_get_session_by_gamer_handle m_start_get_session_by_gamer_handle; + functions::join_session_by_info m_join_session_by_info; + functions::reset_network_complaints m_reset_network_complaints{}; functions::fidevice_get_device m_fidevice_get_device{}; diff --git a/BigBaseV2/src/util/session.hpp b/BigBaseV2/src/util/session.hpp index b7124205..417ae981 100644 --- a/BigBaseV2/src/util/session.hpp +++ b/BigBaseV2/src/util/session.hpp @@ -3,6 +3,9 @@ #include "script_global.hpp" #include "script.hpp" #include "natives.hpp" +#include "gta/joaat.hpp" +#include "rage/rlSessionByGamerTaskResult.hpp" +#include "pointers.hpp" namespace big::session { @@ -33,4 +36,39 @@ namespace big::session *script_global(262145).at(4723).as() = g->session.local_weather == 13; } -} \ No newline at end of file + + inline void join_by_rockstar_id(uint64_t rid) + { + if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) != 0 || + STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS()) + { + g_notification_service->push_error("RID Joiner", "Player switch in progress, wait a bit."); + return; + } + + rage::rlGamerHandle player_handle(rid); + rage::rlSessionByGamerTaskResult result; + bool success = false; + int state = 0; + if (g_pointers->m_start_get_session_by_gamer_handle(0, &player_handle, 1, &result, 1, &success, &state)) + { + while (state == 1) + script::get_current()->yield(); + + if (state == 3 && success) + { + g->session.join_queued = true; + g->session.info = result.m_session_info; + session::join_type({ eSessionType::NEW_PUBLIC }); + if (SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) + { + g->session.join_queued = false; + g_notification_service->push_error("RID Joiner", "Unable to launch maintransition"); + } + return; + } + } + + g_notification_service->push_error("RID Joiner", "Target Player is offline?"); + } +} diff --git a/BigBaseV2/src/views/network/view_session.cpp b/BigBaseV2/src/views/network/view_session.cpp index b9d737c2..986a2d0b 100644 --- a/BigBaseV2/src/views/network/view_session.cpp +++ b/BigBaseV2/src/views/network/view_session.cpp @@ -1,17 +1,24 @@ +#include "views/view.hpp" #include "fiber_pool.hpp" #include "util/session.hpp" -#include "views/view.hpp" namespace big { void view::session() { + static uint64_t rid = 0; + ImGui::InputScalar("Input RID", ImGuiDataType_U64, &rid); + components::button("Join RID", [] + { + session::join_by_rockstar_id(rid); + }); + components::sub_title("Session Switcher"); if (ImGui::ListBoxHeader("###session_switch")) { for (const auto& session_type : sessions) { - components::selectable(session_type.name, false, [&session_type] + components::selectable(session_type.name, false, [&session_type] { session::join_type(session_type.id); }); @@ -51,4 +58,4 @@ namespace big ImGui::TreePop(); } } -} \ No newline at end of file +} diff --git a/vendor/GTAV-Classes b/vendor/GTAV-Classes index b3796521..01101894 160000 --- a/vendor/GTAV-Classes +++ b/vendor/GTAV-Classes @@ -1 +1 @@ -Subproject commit b37965211e80eb23be9a2bdb1bc58072defebcb0 +Subproject commit 011018945d7a04ff818bd6961875309c2099709a