feat: added rid joiner (#521)

This commit is contained in:
Quentin E. / iDeath 2022-10-26 14:12:29 +02:00 committed by GitHub
parent 8f63d1c65b
commit 839854a16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 13 deletions

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;

View File

@ -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";
}
}
}
}

View File

@ -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<BOOL>(TRUE);
}
else
{
src->set_return_value<BOOL>(NETWORK::NETWORK_SESSION_HOST(src->get_arg<int>(0), src->get_arg<int>(1), src->get_arg<BOOL>(2)));
}
}
}
}

View File

@ -398,6 +398,18 @@ namespace big
m_format_metric_for_sending = ptr.as<PVOID>();
});
// 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<functions::start_get_session_by_gamer_handle>();
});
// 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<functions::join_session_by_info>();
});
auto mem_region = memory::module(nullptr);
main_batch.run(mem_region);

View File

@ -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{};

View File

@ -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<bool*>() = g->session.local_weather == 13;
}
}
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?");
}
}

View File

@ -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();
}
}
}
}

2
vendor/GTAV-Classes vendored

@ -1 +1 @@
Subproject commit b37965211e80eb23be9a2bdb1bc58072defebcb0
Subproject commit 011018945d7a04ff818bd6961875309c2099709a