Engine: Add unregister_[touch|think|impulse]()
This commit is contained in:
parent
c531ad756d
commit
218fb9c794
|
@ -55,6 +55,27 @@ static cell AMX_NATIVE_CALL register_think(AMX *amx, cell *params)
|
||||||
return p->Forward;
|
return p->Forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL unregister_think(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int fwd = params[1];
|
||||||
|
for (size_t i = 0; i < Thinks.length(); ++i)
|
||||||
|
{
|
||||||
|
EntClass *p = Thinks.at(i);
|
||||||
|
if (p->Forward == fwd)
|
||||||
|
{
|
||||||
|
Thinks.remove(i);
|
||||||
|
delete p;
|
||||||
|
|
||||||
|
if (!Thinks.length())
|
||||||
|
g_pFunctionTable->pfnThink = NULL;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL register_impulse(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL register_impulse(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -72,6 +93,27 @@ static cell AMX_NATIVE_CALL register_impulse(AMX *amx, cell *params)
|
||||||
return p->Forward;
|
return p->Forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL unregister_impulse(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int fwd = params[1];
|
||||||
|
for (size_t i = 0; i < Impulses.length(); ++i)
|
||||||
|
{
|
||||||
|
Impulse *p = Impulses.at(i);
|
||||||
|
if (p->Forward == fwd)
|
||||||
|
{
|
||||||
|
Impulses.remove(i);
|
||||||
|
delete p;
|
||||||
|
|
||||||
|
if (!Impulses.length())
|
||||||
|
g_pFunctionTable->pfnCmdStart = NULL;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -102,6 +144,27 @@ static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
|
||||||
return p->Forward;
|
return p->Forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL unregister_touch(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int fwd = params[1];
|
||||||
|
for (size_t i = 0; i < Touches.length(); ++i)
|
||||||
|
{
|
||||||
|
Touch *p = Touches.at(i);
|
||||||
|
if (p->Forward == fwd)
|
||||||
|
{
|
||||||
|
Touches.remove(i);
|
||||||
|
delete p;
|
||||||
|
|
||||||
|
if (!Touches.length())
|
||||||
|
g_pFunctionTable->pfnTouch = NULL;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL halflife_time(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL halflife_time(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
REAL fVal = gpGlobals->time;
|
REAL fVal = gpGlobals->time;
|
||||||
|
@ -983,10 +1046,12 @@ AMX_NATIVE_INFO engine_Natives[] = {
|
||||||
{"get_usercmd", get_usercmd},
|
{"get_usercmd", get_usercmd},
|
||||||
{"set_usercmd", set_usercmd},
|
{"set_usercmd", set_usercmd},
|
||||||
|
|
||||||
|
|
||||||
{"register_impulse", register_impulse},
|
{"register_impulse", register_impulse},
|
||||||
{"register_think", register_think},
|
{"register_think", register_think},
|
||||||
{"register_touch", register_touch},
|
{"register_touch", register_touch},
|
||||||
|
{"unregister_impulse", unregister_impulse},
|
||||||
|
{"unregister_think", unregister_think},
|
||||||
|
{"unregister_touch", unregister_touch},
|
||||||
|
|
||||||
{"eng_get_string", get_string},
|
{"eng_get_string", get_string},
|
||||||
{"is_in_viewcone", in_view_cone},
|
{"is_in_viewcone", in_view_cone},
|
||||||
|
|
|
@ -70,7 +70,7 @@ native traceresult(type, any:...);
|
||||||
* @param impulse Impulse to hook
|
* @param impulse Impulse to hook
|
||||||
* @param function Name of callback function
|
* @param function Name of callback function
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @return Impulse forward id
|
||||||
*/
|
*/
|
||||||
native register_impulse(impulse, const function[]);
|
native register_impulse(impulse, const function[]);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ native register_impulse(impulse, const function[]);
|
||||||
* @param Toucher Entity classname touching, "*" or "" for any class
|
* @param Toucher Entity classname touching, "*" or "" for any class
|
||||||
* @param function Name of callback function
|
* @param function Name of callback function
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @return Touch forward id
|
||||||
*/
|
*/
|
||||||
native register_touch(const Touched[], const Toucher[], const function[]);
|
native register_touch(const Touched[], const Toucher[], const function[]);
|
||||||
|
|
||||||
|
@ -120,10 +120,37 @@ native register_touch(const Touched[], const Toucher[], const function[]);
|
||||||
* @param Touched Entity classname to hook
|
* @param Touched Entity classname to hook
|
||||||
* @param function Name of callback function
|
* @param function Name of callback function
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @return Think forward id
|
||||||
*/
|
*/
|
||||||
native register_think(const Classname[], const function[]);
|
native register_think(const Classname[], const function[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a previously registered impulse hook.
|
||||||
|
*
|
||||||
|
* @param registerid Impulse forward id
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 if nothing was removed
|
||||||
|
*/
|
||||||
|
native unregister_impulse(registerid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a previously registered touch hook.
|
||||||
|
*
|
||||||
|
* @param registerid Touch forward id
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 if nothing was removed
|
||||||
|
*/
|
||||||
|
native unregister_touch(registerid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a previously registered think hook.
|
||||||
|
*
|
||||||
|
* @param registerid Think forward id
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 if nothing was removed
|
||||||
|
*/
|
||||||
|
native unregister_think(registerid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Precaches an event file.
|
* Precaches an event file.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user