qbism / cleancodequake2

Automatically exported from code.google.com/p/cleancodequake2
0 stars 0 forks source link

Entity pointer crash #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The method of storing pointers to the new entities causes problems at times
when a pointer to a deleted entity is not detected.

To explain; Quake 2 stores the server entity list in a dynamic array of
size 8192. This meant that in original Quake 2, entity pointers were never
invalid - they were always present.

CleanCode wraps this system around our IBaseEntity system; the entity
classes are maintained by CleanCode and simply store a pointer to and from
the different entity types. The server entity always has an IBaseEntity,
but IBaseEntity's (and derived types) memory is deleted once it is freed.
If the entities that are pointing to the freed entity is not informed and
does not NULL the pointer properly problems arise.

Several things can be done to rectify this, however no "fix" is a "good
fix" in that a lot will need to be re-designed. Ideas are open to discussion.

The first fix was to give entities about 3 frames for other entities to
realize that the entity has been freed - this has worked for several
entities, but the problem still remains.

Original issue reported on code.google.com by Jonno.5000 on 1 Jun 2010 at 8:05

GoogleCodeExporter commented 9 years ago
I am still coming to terms with radical restructuring of the code as compared 
to the original C code so I'm not really sure just by looking at the code at 
the moment, but is this still an issue?

Original comment by nephatr...@gmail.com on 11 Sep 2012 at 7:25

GoogleCodeExporter commented 9 years ago
I honestly haven't touched this code in ages; I did end up making an 
"entity_ptr" class, which is similar to the pointer types in Boost/C++0X and 
manages itself so that the pointer gets nulled when the entity is freed, but 
aside from that I haven't touched this in aaages.

Original comment by Jonno.5000 on 11 Sep 2012 at 7:29