Fixed memory leak in detach
This commit is contained in:
parent
91aacb1036
commit
b34179e997
|
@ -22,6 +22,27 @@ void EngineError(AMX *amx, char *fmt, ...)
|
|||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
}
|
||||
|
||||
void OnAmxxDetach()
|
||||
{
|
||||
register unsigned int i = 0;
|
||||
for (i=0; i<256; i++) {
|
||||
msgHooks[i].clear();
|
||||
msgBlocks[i] = 0;
|
||||
}
|
||||
for (i=0; i<Msg.size(); i++)
|
||||
delete Msg[i];
|
||||
for (i=0; i<Touches.size(); i++)
|
||||
delete Touches[i];
|
||||
for (i=0; i<Impulses.size(); i++)
|
||||
delete Impulses[i];
|
||||
for (i=0; i<Thinks.size(); i++)
|
||||
delete Thinks[i];
|
||||
Msg.clear();
|
||||
Touches.clear();
|
||||
Impulses.clear();
|
||||
Thinks.clear();
|
||||
}
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
pfnTouchForward = 0;
|
||||
|
@ -193,16 +214,6 @@ void ServerDeactivate()
|
|||
memset(glinfo.szRealLights, 0x0, 128);
|
||||
glinfo.bLights = false;
|
||||
glinfo.fNextLights = 0;
|
||||
Msg.clear();
|
||||
register int i = 0;
|
||||
for (i=0; i<256; i++) {
|
||||
msgHooks[i].clear();
|
||||
msgBlocks[i] = 0;
|
||||
}
|
||||
|
||||
Touches.clear();
|
||||
Impulses.clear();
|
||||
Thinks.clear();
|
||||
|
||||
// Reset all forwarding function tables (so that forwards won't be called before plugins are initialized)
|
||||
g_pFunctionTable->pfnAddToFullPack=NULL;
|
||||
|
|
|
@ -1351,167 +1351,6 @@ static cell AMX_NATIVE_CALL entity_set_size(AMX *amx, cell *params)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/***********************
|
||||
Offset control natives
|
||||
***********************/
|
||||
|
||||
static cell AMX_NATIVE_CALL get_offset_short(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
return *((short *)pEnt->pvPrivateData + off);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_offset_short(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
*((short *)pEnt->pvPrivateData + off) = (short)params[3];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_offset_char(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
char r = *((char *)pEnt->pvPrivateData + off);
|
||||
return r;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_offset_char(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
char data = params[3];
|
||||
*((char *)pEnt->pvPrivateData + off) = data;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_offset_int(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
return *((int *)pEnt->pvPrivateData + off);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_offset_int(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
*((int *)pEnt->pvPrivateData + off) = params[3];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_offset_float(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
REAL fRet = (REAL)(*((REAL*)pEnt->pvPrivateData + off));
|
||||
|
||||
return amx_ftoc(fRet);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_offset_float(AMX *amx, cell *params)
|
||||
{
|
||||
int idx = params[1];
|
||||
int off = params[2];
|
||||
|
||||
if (!is_ent_valid(idx)) {
|
||||
EngineError(amx, "Invalid Entity %d", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT2(idx);
|
||||
#ifdef __linux__
|
||||
off += params[3];
|
||||
#endif
|
||||
|
||||
REAL fVal = amx_ctof(params[3]);
|
||||
*((float *)pEnt->pvPrivateData + off) = fVal;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_entity_pointer(AMX *amx, cell *params) // get_entity_pointer(index, pointer[], len); = 3 params
|
||||
{
|
||||
return 0;
|
||||
|
@ -1780,16 +1619,6 @@ AMX_NATIVE_INFO ent_Natives[] = {
|
|||
{"fake_touch", fake_touch},
|
||||
{"force_use", force_use},
|
||||
|
||||
{"get_offset_short", get_offset_short},
|
||||
{"set_offset_short", set_offset_short},
|
||||
{"get_offset_char", get_offset_char},
|
||||
{"set_offset_char", set_offset_char},
|
||||
{"get_offset", get_offset_int},
|
||||
{"set_offset", set_offset_int},
|
||||
{"get_offset_int", get_offset_int},
|
||||
{"set_offset_int", set_offset_int},
|
||||
{"get_offset_float", get_offset_float},
|
||||
{"set_offset_float", set_offset_float},
|
||||
{"get_entity_pointer", get_entity_pointer},
|
||||
|
||||
{"find_ent_in_sphere", find_ent_in_sphere},
|
||||
|
|
|
@ -308,7 +308,6 @@ static cell AMX_NATIVE_CALL register_message(AMX *amx, cell *params)
|
|||
int len;
|
||||
if (params[1]>0 && params[1] < 256) {
|
||||
int id = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
// MF_Log("Registering message %d with result %d", params[1], id);
|
||||
if (id != -1)
|
||||
{
|
||||
msgHooks[params[1]].push_back(id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user