There are some things related to DObject class, that are unclear for me.
For example, why is the DArgs class (command line arguments parser) inherited from DObject? And why is FTexture (and other classes that could benefit from the embedded type information) not inherited from DObject? Is it because it would slow down things? If this is the case, would it be a problem to make DObject and FTexture and others inherit from a single base class, containing only the type information and maybe some additional basic stuff?
Thanks for clarification.
Source code related: Question about DObject
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Source code related: Question about DObject
Last edited by Grubber on Mon Jan 15, 2007 9:41 am, edited 1 time in total.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49234
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
DArgs: no idea. It probably served a purpose once but not anymore.
FTexture: Because it would create too much overhead. The pointer cleanup code has to scan each and every instance of DObject and there's a lot of textures in the game. But yes, it would definitely help if the textures had type information.
FTexture: Because it would create too much overhead. The pointer cleanup code has to scan each and every instance of DObject and there's a lot of textures in the game. But yes, it would definitely help if the textures had type information.
What about keeping the pointer substitution/cleanup code only inside the DObject class (if it's inherited from some other class)? Or, what about making some sort of class flag that will prevent instances of classes flagged with it to be added to the active object list (DObject::Objects) so that they'll be excluded from the pointer cleanup?
DArgs subclasses DObject because I've been planning on (eventually) doing scripting for a long time, and I wanted the class to be easily accessible by scripts.
FTexture does not subclass DObject because by the time I wrote it, every object was getting scanned when an object was destroyed, and I didn't want to add another few thousand objects to that scan.
I am considering limiting the scanning to just DThinker and its descendants, since it really only needs to be done for objects that can live on a level.
FTexture does not subclass DObject because by the time I wrote it, every object was getting scanned when an object was destroyed, and I didn't want to add another few thousand objects to that scan.
I am considering limiting the scanning to just DThinker and its descendants, since it really only needs to be done for objects that can live on a level.