Which would be a better trade-off?
Option #1:
Code:
#define MAX_ENTITY_INDEX 1600
new bool:g_special_entity[MAX_ENTITY_INDEX];
public plugin_init()
{
register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);
new ent = -1;
while( (ent = find_ent_by_class(ent, "_classname_"))
&& ent < MAX_ENTITY_INDEX )
{
g_special_entity[ent] = true;
}
}
public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset)
{
if( ent < MAX_ENTITY_INDEX
&& g_special_entity[ent] )
{
// code
}
}
Option #2:
Code:
#define SPECIAL_ENTITY 123456
public plugin_init()
{
register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);
new ent = -1;
while( (ent = find_ent_by_class(ent, "_classname_")) )
{
set_pev(ent, pev_iuser1, SPECIAL_ENTITY);
}
}
public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset)
{
if( pev(ent, pev_iuser1) == SPECIAL_ENTITY )
{
// code
}
}
Option #3:
(This wasn't originally included, but I'm curious)
Code:
#define MAX_ENTITY_INDEX 1600
new g_special_entity[(MAX_ENTITY_INDEX >> 5) + 1];
public plugin_init()
{
register_forward(FM_AddToFullPack, "FwdAddToFullPack", 1);
new ent = -1;
while( (ent = find_ent_by_class(ent, "_classname_"))
&& ent < MAX_ENTITY_INDEX )
{
g_special_entity[ent >> 5] |= (1 << (ent & 31));
}
}
public FwdAddToFullPack(es, e, ent, host, hostflags, player, pset)
{
if( ent < MAX_ENTITY_INDEX
&& (g_special_entity[ent >> 5] & (1 << (ent & 31))) )
{
// code
}
}
__________________