Internal SUB_Null

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Internal SUB_Null

Post by Urre »

Would it break things if engines had an internal SUB_Null function for non-existent functions? Currently it results in a qc crash. It would just be nice if I didn't have to have SUB_Nulls on non-used function-fields for certain entities, which all share code which calls all the functions.
I was once a Quake modder
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

What do you actually mean by this? That if a function is set to null and the qc tries calling it, it is ignored?

Remember that there is a difference between SUB_Null and true null.
In fteqcc, you can use __NULL__ to specify a fully null function. Alternativly, world.touch typically works too. :)

If you do use true null, you can do if(ent.blah) ent.blah(); each time its required.

Typically code that does call null functions is a certain bug. Something wasn't throught through, or some such, so warning/erroring makes most sense. Admittedly in your code it may be more awkward, but in regular qc code, its probably a good thing that engines moan. At least using SUB_Null shows that you've thought about that field. Having some shared initialisation function (aka root constructor) on the entities which share the code might be a handy design choice.
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Post by Urre »

Spike wrote:Having some shared initialisation function (aka root constructor) on the entities which share the code might be a handy design choice.
I was hoping to be able to skip such things :(

But yes, your point makes sense, it's a bug for most people.
I was once a Quake modder
Post Reply