r5sdk/r5dev/game/shared/r1/weapon_bolt.cpp
Kawe Mazidjatari 144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +02:00

34 lines
1.4 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));
// Amos: The engine code has been modified on assembly level, function
// 'FireWeaponBolt' now checks the pointer returned by this function,
// and returns null if null (script should be able to handle this error
// or cause a soft crash if the entity handle is being used).
Assert(0);
}
return weaponBolt;
}
//-----------------------------------------------------------------------------
void V_Weapon_Bolt::Detour(const bool bAttach) const
{
DetourSetup(&v_CreateWeaponBolt, &CreateWeaponBolt, bAttach);
}