![]() |
SWDS.dll Crashes.
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) 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. |
Re: SWDS.dll Crashes.
Im guessing that the engine is crashing because you are freeing the entities and the engines list of entities still has these dangling pointers to the entities that you freed.
Instead of "freeing" them, use pfnRemoveEntity in engine functions. (Thats same as REMOVE_ENTITY(edict_t*) ). That will allow the engine to do what it needs to ensure the edict you removed is not valid anymore. :P |
Re: SWDS.dll Crashes.
Auctually thats how I've been removing them, using remove_entity most of the time, I switched to flags |= FL_KILLME as I figured it might have been a problem with the remove_entity function (and the fact I rarely seen it used in HLSDK)
The data that I free for the entity is a pointer to its class instance, which is all me. (ie, delete pEntityData[index];) Once thats deleted the entity can still exist but will be nothing but an info_target. The thing is it doesnt seem to crash all the time, I went ahead and started making thousands of entities overnight and it wouldnt crash (50 ents a second with 2 second lifetime). |
Re: SWDS.dll Crashes.
Ok well I'm interested in solving your problem ;)
thing I don't get is... Code:
a = (T *)pEntityData[ENTINDEX(pEnt)]; I never exactly had a good look at the monster plugin to see how entities were spawned, I'm guessing as you say, you are using similar code to that of it? What exactly are you wanting to do (in the long run)? I'm sure there maybe an easier way to go about doing it. |
Re: SWDS.dll Crashes.
Hmm, thats right.
Duh... Thanks for spotting that. The purpose of this code is to make modifying entities & making new entities just like you would make an entity with the CBaseEntity class, only for server side mods as well. The nice thing about it is it makes fooling around with existing entities (ie, the phasegate in NS) really simple. That snippet I posted only creates an entity when creating a custom entity (ie, my nuke or fireworks ents). |
Re: SWDS.dll Crashes.
theory: ;)
If you are calling CBaseEntity methods through a pointer you got from your create function it could be accessing the wrong area of memory i.e. if you casted it wrong and called a method, the method locations will be in the wrong place and execution could wander through lines of code which manipulates the call stack and leaving it in an inconsistant state... (if by calling a method it took code into the middle of a function, it would not push the stack but would pop it at the end) in short: I'm guessing you are casting the values returned by your create function from edict_t* to CBaseEntity* The thing I believe is that to cast an edict_t* to a CBaseEntity* you must cast it by it's privateData and not the edict_t* memory location. i.e. by: CBaseEntity *pEnt = (CBaseEntity*)GET_PRIVATE(pEdict); To help you, here is code from my "marine build" function from my bot, which I am also guessing you are using natural-selection. My code works okay when spawning structures in Natural-selection, even resource towers but they don't give resources to the marines (at least that doesn't crash though, i found why it crashes in that case) have a look if you wish: Code:
// |
Re: SWDS.dll Crashes.
My code doesnt use anything relating to CBaseEntity, its totally independant.
Code:
CEBaseEntity *pEntityData[NSA_MAX_ENTS+1]; Code:
static CEBaseEntity *Instance( edict_t *pent ) pEntityData is basically the same as pvPrivateData. Example class: Code:
class CLight : public CEBaseEntity New entity: Code:
CEBaseEntity *pFireWork = NSAGetClassPtr( (CFireWork *)NULL); Code:
CEBaseEntity *pHive = NSAGetClassPtr( (CHive*)HiveEdict); |
Re: SWDS.dll Crashes.
IIRC, Monster makes monsters like this:
Code:
CBaseEntity *whatever = new CMonsterBarney So I am wondering, if you were to spawn, say a hive in NS, would you do it like this? Code:
CBaseEntity *thenewhive = new getClassPtr("info_hive") |
Re: SWDS.dll Crashes.
A dumb question (don't hurt me) but, when using CREATE_ENTITY() and making the entity solid, wouldn't you forget to set a bounding box ?
How do you manipulate your entity once it's created ? (setting position, angle and BB) |
Re: SWDS.dll Crashes.
CREATE_ENTITY() doesnt allocate a cbaseentity class for the entity, the mod then tries to access a cbaseentity pointer on solid ents if you look at it, without checking the pointer first.
All of the additional entity manipulation is performed in the spawn code, setting model, bbox, etc. |
All times are GMT +2. The time now is 14:31. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.