Internal SUB_Null
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
Internal SUB_Null
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
-

Urre - Posts: 1109
- Joined: Fri Nov 05, 2004 2:36 am
- Location: Moon
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.
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.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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
-

Urre - Posts: 1109
- Joined: Fri Nov 05, 2004 2:36 am
- Location: Moon
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest