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(
|
FetchContent_Declare(
|
||||||
gtav_classes
|
gtav_classes
|
||||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||||
GIT_TAG b9b832ab00c95a731f8472f696c5d026a29fd767
|
GIT_TAG aebd69542e58fab8975da76c3e555b122ddef5d6
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
|
@ -18,10 +18,13 @@ namespace big
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*g_pointers->m_gta.m_is_session_started)
|
||||||
|
{
|
||||||
if (!entity::take_control_of(veh, 0))
|
if (!entity::take_control_of(veh, 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (VEHICLE::GET_DOES_VEHICLE_HAVE_DAMAGE_DECALS(veh))
|
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
|
virtual void on_tick() override
|
||||||
{
|
{
|
||||||
if (g_local_player)
|
if (g_local_player)
|
||||||
{
|
{
|
||||||
const auto personal_vehicle = get_personal_vehicle();
|
const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle();
|
||||||
|
if (personal_vehicle)
|
||||||
|
{
|
||||||
apply_godmode_to_vehicle(personal_vehicle, true);
|
apply_godmode_to_vehicle(personal_vehicle, true);
|
||||||
|
}
|
||||||
apply_godmode_to_vehicle(g_local_player->m_vehicle, personal_vehicle == g_local_player->m_vehicle);
|
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)
|
if (g_local_player->m_vehicle)
|
||||||
restore_original_vehicle_data(g_local_player->m_vehicle);
|
restore_original_vehicle_data(g_local_player->m_vehicle);
|
||||||
|
|
||||||
const auto personal_vehicle = get_personal_vehicle();
|
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||||
if (personal_vehicle)
|
|
||||||
{
|
{
|
||||||
restore_original_vehicle_data(personal_vehicle);
|
restore_original_vehicle_data(personal_vehicle);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ namespace big
|
|||||||
{eGameLanguage::TRADITIONAL_CHINESE, "Chinese (Traditional)"},
|
{eGameLanguage::TRADITIONAL_CHINESE, "Chinese (Traditional)"},
|
||||||
{eGameLanguage::JAPANESE, "Japanese"},
|
{eGameLanguage::JAPANESE, "Japanese"},
|
||||||
{eGameLanguage::MEXICAN_SPANISH, "Spanish (Mexico)"},
|
{eGameLanguage::MEXICAN_SPANISH, "Spanish (Mexico)"},
|
||||||
{eGameLanguage::SIMPLIFIED_CHINESE, "Chinese (Simpified)"},
|
{eGameLanguage::SIMPLIFIED_CHINESE, "Chinese (Simplified)"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "hooking/hooking.hpp"
|
#include "hooking/hooking.hpp"
|
||||||
|
#include "util/mobile.hpp"
|
||||||
#include "util/notify.hpp"
|
#include "util/notify.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
@ -12,11 +13,15 @@ namespace big
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_local_player && g_local_player->m_vehicle && g_local_player->m_vehicle->m_net_object
|
if (const auto personal_vehicle = mobile::mechanic::get_personal_cvehicle())
|
||||||
&& object_id == g_local_player->m_vehicle->m_net_object->m_object_id) [[unlikely]]
|
|
||||||
{
|
{
|
||||||
if (!NETWORK::NETWORK_IS_ACTIVITY_SESSION()) //If we're in Freemode.
|
if (auto net_obj = personal_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 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))
|
if (auto plyr = g_player_service->get_by_id(src->m_player_id))
|
||||||
{
|
{
|
||||||
g.reactions.delete_vehicle.process(plyr);
|
g.reactions.delete_vehicle.process(plyr);
|
||||||
@ -24,6 +29,26 @@ namespace big
|
|||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto object = g_pointers->m_gta.m_get_net_object(*g_pointers->m_gta.m_network_object_mgr, object_id, true)) [[likely]]
|
if (auto object = g_pointers->m_gta.m_get_net_object(*g_pointers->m_gta.m_network_object_mgr, object_id, true)) [[likely]]
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ namespace big::entity
|
|||||||
|
|
||||||
bool network_has_control_of_entity(rage::netObject* net_object)
|
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)
|
bool take_control_of(Entity ent, int timeout)
|
||||||
|
@ -139,6 +139,17 @@ namespace big::mobile
|
|||||||
return *scr_globals::freemode_global.at(301).as<Vehicle*>();
|
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)
|
inline void summon_vehicle_by_index(int veh_idx)
|
||||||
{
|
{
|
||||||
if (*scr_globals::freemode_global.at(1000).as<int*>() != -1)
|
if (*scr_globals::freemode_global.at(1000).as<int*>() != -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user