Fix crash with IgniteEntity on MCV (#1924)

* Fix crash with IgniteEntity on MCV.

* Formatting.
This commit is contained in:
Nicholas Hastings 2023-02-04 11:09:46 -05:00 committed by GitHub
parent 6e839a95c6
commit cd6886319c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -373,25 +373,39 @@ static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
{ {
return pContext->ThrowNativeError("\"Ignite\" not supported by this mod"); return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
} }
else if (!pCall) { else if (!pCall)
{
return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize"); return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
} }
} }
else else
#endif // SDK2013 #endif // SDK2013
{ {
#if SOURCE_ENGINE == SE_MCV
ValvePassInfo pass[6];
InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
InitPass(pass[4], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL);
InitPass(pass[5], Valve_POD, PassType_Basic, PASSFLAG_BYVAL);
if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 6, &pCall)) {
return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
} else if (!pCall) {
return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
}
#else
ValvePassInfo pass[4]; ValvePassInfo pass[4];
InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL); InitPass(pass[0], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); InitPass(pass[1], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL); InitPass(pass[2], Valve_Float, PassType_Float, PASSFLAG_BYVAL);
InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL);
if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 4, &pCall)) if (!CreateBaseCall("Ignite", ValveCall_Entity, NULL, pass, 4, &pCall)) {
{
return pContext->ThrowNativeError("\"Ignite\" not supported by this mod"); return pContext->ThrowNativeError("\"Ignite\" not supported by this mod");
} } else if (!pCall) {
else if (!pCall) {
return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize"); return pContext->ThrowNativeError("\"Ignite\" wrapper failed to initialize");
} }
#endif // MCV
} }
} }
@ -408,6 +422,9 @@ static cell_t IgniteEntity(IPluginContext *pContext, const cell_t *params)
*(int *) (vptr + pCall->vparams[4].offset) = 0; *(int *) (vptr + pCall->vparams[4].offset) = 0;
*(int *) (vptr + pCall->vparams[5].offset) = 0; *(int *) (vptr + pCall->vparams[5].offset) = 0;
} }
#elif SOURCE_ENGINE == SE_MCV
*(CBaseEntity **) (vptr + pCall->vparams[4].offset) = nullptr; // pAttacker
*(string_t *) (vptr + pCall->vparams[5].offset) = NULL_STRING; // sRootWeaponClassname
#endif // SDK2013 #endif // SDK2013
FINISH_CALL_SIMPLE(NULL); FINISH_CALL_SIMPLE(NULL);