Reconcile the concept of Edict & Networkable across the codebase (#1903)
* Reconcile the concept of Edict & Networkable across the codebase * There's no need to check this, it's done elsewhere. Also could be null (segfault) * This was never needed * Pseudo review changes Re-added removed null checks, and added new ones. Changed the error messages in Get/SetProp natives to better reflect reality. * Don't change the behaviour of GetEntityNetClass * Overload IGameHelpers::FindServerClass * Make error messages more accurate * Fix a dev comment * Rename FindServerClass --------- Co-authored-by: Kenzzer <[email protected]>
This commit is contained in:
@@ -60,15 +60,15 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params)
|
||||
break;
|
||||
case HookRet_BadEntForHookType:
|
||||
{
|
||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
|
||||
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
|
||||
if (!pClassname)
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
|
||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
|
||||
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
|
||||
if (!pClassname)
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -185,9 +185,9 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
if (!pCall)
|
||||
{
|
||||
int offset;
|
||||
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
|
||||
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
|
||||
}
|
||||
|
||||
PassInfo pass[2];
|
||||
@@ -230,10 +230,13 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
if (!pWeapon)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
|
||||
|
||||
IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
|
||||
IServerNetworkable *pNet = pUnk->GetNetworkable();
|
||||
|
||||
if (!UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, "DT_BaseCombatWeapon"))
|
||||
ServerClass *pClass = gamehelpers->FindEntityServerClass(pWeapon);
|
||||
if (pClass == nullptr)
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to retrieve entity %d server class!", params[2]);
|
||||
}
|
||||
|
||||
if (!UTIL_ContainsDataTable(pClass->m_pTable, "DT_BaseCombatWeapon"))
|
||||
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
|
||||
|
||||
sm_sendprop_info_t spi;
|
||||
@@ -291,9 +294,9 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
if (!pCall)
|
||||
{
|
||||
int offset;
|
||||
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
|
||||
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
|
||||
}
|
||||
|
||||
PassInfo pass[3];
|
||||
|
||||
Reference in New Issue
Block a user