Hello,
I've been using a system which spawns entities similar to the way they are done in botmans monster plug-in, but rather than using a func_wall, I'm using an info_target.
I've been using this code for a while and have noticed frequent crashes from swds.dll when its in a state where players can make entities (now, the ents are limited so players cant just go making 10 million of them).
Unfortunately, I know that its something with the entities causing the crash, but with no call stack or not even a clue on to what’s crashing it, I really don’t have an idea what’s doing it (Call stack just shows !SWDS 0xWhatever)
Code:
template <class T> T * NSAGetClassPtr( T *a)
{
edict_t *pEnt = (edict_t *)a;
// allocate entity if necessary
if (pEnt == NULL)
{
pEnt = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
if(!UTIL_IsValidEntity(pEnt))
return NULL;
DispatchSpawn( pEnt );
}
// get the private data
a = (T *)pEntityData[ENTINDEX(pEnt)];
if (a == NULL)
{
a = new T;
if(pEntityData[ ENTINDEX( pEnt ) ])
{
UTIL_LogPrintf("WARNING: Found pointer for entity that doesnt exist!\n");
FREE_MEM(pEntityData[ ENTINDEX( pEnt ) ]);
}
pEntityData[ ENTINDEX( pEnt ) ] = a;
a->pev = VARS(pEnt);
}
return a;
}
Entities are removed using the pev->flags |= FL_KILLME, theres a loop in start frame running thru all the possible indexes checking for the flag to free the memory allocated for the entity. pEntityData is an array of 1380 pointers. (max entities with 32 players).
The wierd part is, changing CREATE_NAMED_ENTITY to CREATE_ENTITY made all the nasty crashes from SWDS.dll go away, but the mod will crash if I make the entity solid (The mod does a trace line, if the entity it hits isnt null, it tries to access a cbaseentity instance without checking if its null first).
Preferably, I'd like to keep using the create_named_entity command if anyone has an idea of why swds would be crashing.
Fyi, SWDS.dll is the dedicated server engine dll as far as I know.
Anyone have any ideas? Botman?
Thanks.