mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
proper fix for weapon info damage crash (#2740)
This commit is contained in:
parent
42d631882a
commit
26686402c3
@ -3,7 +3,7 @@ include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
gtav_classes
|
||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||
GIT_TAG e8d8bdd2b3152253f6e1fde48720e4caeab19f83
|
||||
GIT_TAG 09a586011a296cf8ce3ffb9c15db7ce474ea4363
|
||||
GIT_PROGRESS TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
|
9
src/gta/weapon_info_manager.hpp
Normal file
9
src/gta/weapon_info_manager.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// https://github.com/Parik27/V.Rainbomizer/blob/0c70868626411a1d30483339003b9985b0ff1c98/lib/CItemInfo.hh#L62
|
||||
class CWeaponInfoManager
|
||||
{
|
||||
public:
|
||||
char field_0x0[16][4];
|
||||
rage::atArray<CWeaponInfo*> m_item_infos;
|
||||
};
|
@ -16,6 +16,7 @@ class CVehicleDriveByMetadataMgr;
|
||||
class CBlipList;
|
||||
class TimecycleKeyframeData;
|
||||
class CTrainConfig;
|
||||
class CWeaponInfoManager;
|
||||
|
||||
namespace rage
|
||||
{
|
||||
@ -362,6 +363,8 @@ namespace big
|
||||
functions::get_ped_seat m_get_ped_seat;
|
||||
|
||||
functions::received_clone_remove m_received_clone_remove;
|
||||
|
||||
CWeaponInfoManager* m_weapon_info_manager;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "gta/net_game_event.hpp"
|
||||
#include "gta/weapon_info_manager.hpp"
|
||||
#include "hooking/hooking.hpp"
|
||||
#include "script/scriptIdBase.hpp"
|
||||
#include "util/math.hpp"
|
||||
@ -25,6 +26,19 @@ namespace big
|
||||
id.m_instance_id = buffer.Read<int32_t>(8);
|
||||
}
|
||||
|
||||
static bool is_valid_weapon(rage::joaat_t hash)
|
||||
{
|
||||
for (const auto& info : g_pointers->m_gta.m_weapon_info_manager->m_item_infos)
|
||||
{
|
||||
if (info && info->m_name == hash && info->GetClassId() == RAGE_JOAAT("cweaponinfo"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if bad event
|
||||
bool scan_weapon_damage_event(rage::netEventMgr* event_manager, CNetGamePlayer* player, CNetGamePlayer* target_player, int event_index, int event_handled_bitset, rage::datBitBuffer* buffer)
|
||||
{
|
||||
@ -72,9 +86,9 @@ namespace big
|
||||
damageType = buffer->Read<uint8_t>(2);
|
||||
weaponType = buffer->Read<uint32_t>(32);
|
||||
|
||||
const auto is_crash_weapon = weaponType == RAGE_JOAAT("AMMO_BALL");
|
||||
if (is_crash_weapon)
|
||||
if (!is_valid_weapon(weaponType))
|
||||
{
|
||||
notify::crash_blocked(player, "invalid weapon type");
|
||||
g_pointers->m_gta.m_send_event_ack(event_manager, player, target_player, event_index, event_handled_bitset);
|
||||
return true;
|
||||
}
|
||||
|
@ -1763,6 +1763,15 @@ namespace big
|
||||
{
|
||||
g_pointers->m_gta.m_received_clone_remove = ptr.as<functions::received_clone_remove>();
|
||||
}
|
||||
},
|
||||
// CWeaponInfoManager
|
||||
{
|
||||
"CWIM",
|
||||
"0F B7 15 ? ? ? ? ? 33 D2 2B D3 78 ? ? 8B 1D",
|
||||
[](memory::handle ptr)
|
||||
{
|
||||
g_pointers->m_gta.m_weapon_info_manager = ptr.add(3).rip().sub(72).as<CWeaponInfoManager*>();
|
||||
}
|
||||
}
|
||||
>(); // don't leave a trailing comma at the end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user