mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
The function 'FireWeaponBolt' calls 'CreateWeaponBolt' to create a bolt entity, but it can return NULL. 'FireWeaponBolt' does NOT check for NULL and derefs the pointer regardless. This rarely happens though; in all cases, it was caused by a defect in scripts. Code has been hooked to throw an engine error instead of crashing.
32 lines
1.2 KiB
C++
32 lines
1.2 KiB
C++
#include "weapon_bolt.h"
|
|
#include "game/shared/util_shared.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: creates a weapon bolt
|
|
//-----------------------------------------------------------------------------
|
|
CBaseEntity* CreateWeaponBolt(Vector3D* origin, Vector3D* end, __int64 unused, float scale, CPlayer* player,
|
|
int a6, int modelIndex, int a8, unsigned __int8 a9, unsigned int a10, CBaseEntity* weapon)
|
|
{
|
|
CBaseEntity* weaponBolt = v_CreateWeaponBolt(origin, end, unused, scale, player, a6, modelIndex, a8, a9, a10, weapon);
|
|
if (!weaponBolt)
|
|
{
|
|
// Code does NOT check for null, and performing inline assembly is kind of a waste.
|
|
// This only happens when 'EntityFactoryDictionary' fails, which only happens when
|
|
// there are no edict slots available anymore (usually a bug in scripts).
|
|
Error(eDLL_T::SERVER, EXIT_FAILURE, "Unable to create bolt for %s", UTIL_GetEntityScriptInfo(player));
|
|
}
|
|
|
|
return weaponBolt;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void V_Weapon_Bolt::Attach() const
|
|
{
|
|
DetourAttach(&v_CreateWeaponBolt, &CreateWeaponBolt);
|
|
}
|
|
|
|
void V_Weapon_Bolt::Detach() const
|
|
{
|
|
DetourDetach(&v_CreateWeaponBolt, &CreateWeaponBolt);
|
|
}
|