mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Added ownership checks to the delete_vehicle check. (#3552)
* Added ownership checks to the delete_vehicle check. * Redesigned delete_vehicle protections. * Cleaned up code. * Fixed vehicle repaired/vehicle godmode code not running if the player was offline/did not have a personal vehicle deployed. * Fixed Chinese being a simp. (Closes #3581) * GTAV-Classes: bump version
This commit is contained in:
parent
d1e4b0830c
commit
bdb307125f
@ -3,7 +3,7 @@ include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
gtav_classes
|
||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||
GIT_TAG b9b832ab00c95a731f8472f696c5d026a29fd767
|
||||
GIT_TAG aebd69542e58fab8975da76c3e555b122ddef5d6
|
||||
GIT_PROGRESS TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
|
@ -18,9 +18,12 @@ namespace big
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity::take_control_of(veh, 0))
|
||||
if (*g_pointers->m_gta.m_is_session_started)
|
||||
{
|
||||
return;
|
||||
if (!entity::take_control_of(veh, 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (VEHICLE::GET_DOES_VEHICLE_HAVE_DAMAGE_DECALS(veh))
|
||||
|
@ -91,23 +91,15 @@ namespace big
|
||||
}
|
||||
}
|
||||
|
||||
CVehicle* get_personal_vehicle()
|
||||
{
|
||||
Vehicle personal_vehicle = mobile::mechanic::get_personal_vehicle();
|
||||
if (ENTITY::DOES_ENTITY_EXIST(personal_vehicle))
|
||||
{
|
||||
return reinterpret_cast<CVehicle*>(g_pointers->m_gta.m_handle_to_ptr(personal_vehicle));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
if (g_local_player)
|
||||
{
|
||||
const auto personal_vehicle = get_personal_vehicle();
|
||||
apply_godmode_to_vehicle(personal_vehicle, true);
|
||||
const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle();
|
||||
if (personal_vehicle)
|
||||
{
|
||||
apply_godmode_to_vehicle(personal_vehicle, true);
|
||||
}
|
||||
apply_godmode_to_vehicle(g_local_player->m_vehicle, personal_vehicle == g_local_player->m_vehicle);
|
||||
}
|
||||
}
|
||||
@ -119,8 +111,7 @@ namespace big
|
||||
if (g_local_player->m_vehicle)
|
||||
restore_original_vehicle_data(g_local_player->m_vehicle);
|
||||
|
||||
const auto personal_vehicle = get_personal_vehicle();
|
||||
if (personal_vehicle)
|
||||
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||
{
|
||||
restore_original_vehicle_data(personal_vehicle);
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace big
|
||||
{eGameLanguage::TRADITIONAL_CHINESE, "Chinese (Traditional)"},
|
||||
{eGameLanguage::JAPANESE, "Japanese"},
|
||||
{eGameLanguage::MEXICAN_SPANISH, "Spanish (Mexico)"},
|
||||
{eGameLanguage::SIMPLIFIED_CHINESE, "Chinese (Simpified)"},
|
||||
{eGameLanguage::SIMPLIFIED_CHINESE, "Chinese (Simplified)"},
|
||||
};
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "hooking/hooking.hpp"
|
||||
#include "util/mobile.hpp"
|
||||
#include "util/notify.hpp"
|
||||
|
||||
namespace big
|
||||
@ -12,16 +13,40 @@ namespace big
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_local_player && g_local_player->m_vehicle && g_local_player->m_vehicle->m_net_object
|
||||
&& object_id == g_local_player->m_vehicle->m_net_object->m_object_id) [[unlikely]]
|
||||
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||
{
|
||||
if (!NETWORK::NETWORK_IS_ACTIVITY_SESSION()) //If we're in Freemode.
|
||||
if (auto net_obj = personal_vehicle->m_net_object)
|
||||
{
|
||||
if (auto plyr = g_player_service->get_by_id(src->m_player_id))
|
||||
if (object_id == net_obj->m_object_id && entity::network_has_control_of_entity(net_obj))
|
||||
{
|
||||
g.reactions.delete_vehicle.process(plyr);
|
||||
/*LOG(VERBOSE) << "DELETION ORDER FOR PERSONAL VEHICLE: " << net_obj->m_object_id << " m_is_remote: " << net_obj->m_is_remote
|
||||
<< " m_bubble: " << net_obj->m_bubble << " m_owner_id: " << net_obj->m_owner_id
|
||||
<< " m_wants_to_be_owner: " << net_obj->m_wants_to_be_owner;*/
|
||||
if (auto plyr = g_player_service->get_by_id(src->m_player_id))
|
||||
{
|
||||
g.reactions.delete_vehicle.process(plyr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self::veh != 0)
|
||||
{
|
||||
if (const auto current_vehicle = g_local_player->m_vehicle)
|
||||
{
|
||||
auto net_obj = current_vehicle->m_net_object;
|
||||
if (object_id == net_obj->m_object_id && entity::network_has_control_of_entity(net_obj))
|
||||
{
|
||||
/*LOG(VERBOSE) << "DELETION ORDER FOR CURRENT VEHICLE: " << net_obj->m_object_id
|
||||
<< " m_is_remote: " << net_obj->m_is_remote << " m_bubble: " << net_obj->m_bubble
|
||||
<< " m_owner_id: " << net_obj->m_owner_id << " m_wants_to_be_owner: " << net_obj->m_wants_to_be_owner;*/
|
||||
if (auto plyr = g_player_service->get_by_id(src->m_player_id))
|
||||
{
|
||||
g.reactions.delete_vehicle.process(plyr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace big::entity
|
||||
|
||||
bool network_has_control_of_entity(rage::netObject* net_object)
|
||||
{
|
||||
return !net_object || !net_object->m_next_owner_id && (net_object->m_control_id == -1);
|
||||
return !net_object || !net_object->m_is_remote && (net_object->m_wants_to_be_owner == -1);
|
||||
}
|
||||
|
||||
bool take_control_of(Entity ent, int timeout)
|
||||
|
@ -139,6 +139,17 @@ namespace big::mobile
|
||||
return *scr_globals::freemode_global.at(301).as<Vehicle*>();
|
||||
}
|
||||
|
||||
inline CVehicle* get_personal_cvehicle()
|
||||
{
|
||||
Vehicle personal_vehicle = get_personal_vehicle();
|
||||
if (personal_vehicle != -1 && ENTITY::DOES_ENTITY_EXIST(personal_vehicle))
|
||||
{
|
||||
return reinterpret_cast<CVehicle*>(g_pointers->m_gta.m_handle_to_ptr(personal_vehicle));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void summon_vehicle_by_index(int veh_idx)
|
||||
{
|
||||
if (*scr_globals::freemode_global.at(1000).as<int*>() != -1)
|
||||
|
Loading…
Reference in New Issue
Block a user