Optimize your code
So you know a bit about QC... now you want to optimize your code for better
One thing you may have noticed is Id left some things in their code that is,
well, not that great. The Quake
Info Pool has a section dedicated to FIXING Id's bugs here.
They have also released a source code with these improvements (and a few more)
already made (here)
As of this writing the newest version is 1.06a
Something to note is that this fixed source does not fix everything. Here we'll
list some things that need to me worked on. A somewhat new (as far as Quake
goes) but the skilled and respected QC coder called Electro is working on a
highly optimized Deathmatch Only source at the moment. He has taken into account
all the possible optimizations suggested by several people and hopes to include
a modified version of FrikbotX and a nice menu so QuakeDC coders will have a
complete ready to go source. Electro has mentioned the possibility of a highly
optimized Single Player source by him in the future.
Anyway, the main things I (TheDumbAss) told Electro that could be optimized
for QuakeDC is the precache system. As it stands Quake precaches tons of things
on every level regardless of if its used or not on that map or in that mod.
If you optimize the precache the levels will load faster and less ram will be
used... both are important on QuakeDC. (And low end PCs... which makes me wonder
why nobody thought of this years ago when EVERYONE had whats now considered
a low end PC)
The example of the poor stock precache I most commonly use is lavaball.mdl.
It is used on the start level in the 'Hard' hall and a few other maps... but
it is precached by Quake and most every mod on every level regardless of its
really needed or not. With the lavaball.mdl it is as simple as commenting out
the line "precache_model ("progs/lavaball.mdl");" in worldspawn();
in world.qc. Its only this simple because it is still automatically precached
when it is needed in a map. (see: misc_fireball in misc.qc)
Of course this isn't the only flaw... Several models and sounds are precached
unnecessarily. Until Electro releases his source publicly all I can say is to
pick through main(); and worldspawn(); in world.qc. If you see something that
isn't needed on every level for you mod remove it. You'll have to make sure
it is cached when it is needed though. Of course those are not the only two
places precaches are made so you may want to check other places too.
As far as any other optimizations go...
Check your warnings when you compile. If there are any (and there most likely
will be) try to find and fix the cause. Some of Id's AI code may seem impossible
to fix... but it can be done.
Use an advanced compiler. FrikQCC has a couple optimization options that will
reduce the processor load (which improves gameplay speed), decrease the progs.dat
size, or both. Other advanced QC compilers offer various features and may offer
better (or worse) results depending on the the mod and how its coded.
Keep your code clean... if you think to yourself "man that's a nasty hack"
then it probably is...