Re: [Quake-C] Tracebox / Traceline
Quake C mods and support - SSQC / CSQC
Brought to you by:
teknoskillz
|
From: Cobalt <co...@te...> - 2016-02-13 04:18:00
|
Regarding what you said on the think field missing, I'm encountering the
problem alot during my dev work and turns out that actually when remove
(blah)
is called, technically its not permanently removed from the environment,
rather its "freed".
It still has an edict number, and if you are for example still using another
active entity pointing to that now "free" edict,
its not edict 0, therefore any comparison to it == world, would not be true
for one thing.
Free ents don't have any fields yet, so I suppose they are all null fields,
and of course what I'm leading up to is, if your other active entities are
still pointing to this ent,
and are assuming its not been freed , and it use to have a .think field that
you want to use , then you get the crash you posted with think missing , if
other code spawns a dynamic entity and happens to pick that old edict
number. This is pretty dangerous, and I guess that why they have the built
in wasfreed (), to avert this. Apparently the spawn () function starts
looking at the top of the list for a good edict number, and if it encounters
a free edict, it will use that, versus going all the way to the last edict
and using a completely new number.
I suppose to eliminate this, you could use makestatic (blah), instead of
remove () however I believe it still retains all the field data including
the model etc, and during a single player game I believe it will appear to
vanish and not be drawn, but in multiplayer if another player joins, they
will see this edict as its part of the sign on packet.
If there was a true null entity we could use copyentity () on, maybe that
would work?
In defs.qc
entity STATIC_NULL;
Then someplace like endframe maybe:
void () EndFrame =
{
if (framecount == 1)
STATIC_NULL = spawn ();
};
So now at least we have a counterpart to world which does not have any
fields that we can essentially null the ent out, and its not a free ent, so
that means it wont be reused again.
|