progs106.zip: 0 error(s), 0 warning(s)
by noctrun

Here is the resulting sample code:
Quake v1.06 [0 error(s), 0 warning(s), fteqcc 2191]
QuakeWorld v2.33 [0 error(s), 0 warning(s), fteqcc 2191]
Hipnotic MP [0 error(s), 0 warning(s), fteqcc 2191]
Rogue MP [0 error(s), 0 warning(s), fteqcc 2191]

Well if you compiled the released QuakeC source code with one of the newer QuakeC compilers (frikqcc, fteqcc, etc) you've noticed that the provided source code produces 15 warnings when it's compiled. This tutorial is meant to show you how to fix those warnings.

Let's take a look at the error.log file that frikqcc 2.6 created while compiling the QuakeC source id Software released:
warning: subs.qc:25:SetMovedir: not all control paths return a value
warning: fight.qc:299:enemy_yaw redeclared
warning: ai.qc:368:FindTarget must return a value
warning: ai.qc:588:CheckAnyAttack must return a value
warning: items.qc:47:droptofloor: Too few parameters. See definition defs.qc(602)
warning: weapons.qc:92:org redeclared
warning: client.qc:134:FindIntermission: not all control paths return a value
warning: monsters.qc:75:droptofloor: Too few parameters. See definition defs.qc(602)
warning: misc.qc:179:No operation performed
warning: misc.qc:249:droptofloor: Too few parameters. See definition defs.qc(602)
warning: misc.qc:281:droptofloor: Too few parameters. See definition defs.qc(602)
warning: misc.qc:536:makestatic: Too few parameters. See definition defs.qc(650)
warning: ogre.qc:249:ai_charge: Too few parameters. See definition fight.qc(157)
warning: wizard.qc:180:WizardAttackFinished: not all control paths return a value
warning: enforcer.qc:76:vec redeclared

subs.qc:25:SetMovedir: not all control paths return a value

Let's see what what's wrong with the SetMovedir function, open subs.qc and go to line 25 to find the end of the function. Hm, looks like SetMovedir doesn't return any vectors though it was declared as it would. The warning here is simple to fix: SetMovedir's type is wrong, it should be void(). Change the function definition form 'vector() SetMovedir =' to 'void() SetMovedir ='. 1 down, 14 to go.

fight.qc:299:enemy_yaw redeclared

The next warning is in line 299 of fight.qc so open that file and go there. Hm, a normal definition of a local variable, that's right, however it's unnecessary: 'float enemy_yaw;' was defined as a global variable in line 31 of fight.qc. To fix this warning all you have to do is to remove the 'local float enemy_yaw;' line form the ShamCheckAttack function. 2 down, 13 to go.

ai.qc:368:FindTarget must return a value

Well, id forgot to return a value here. FindTarget should return TRUE when the monster has a enemy in sight and for this return that is the case. So the empty return is suppost to return TRUE. 3 down, 12 to go.

ai.qc:588:CheckAnyAttack must return a value

Annother empty return, to fix this warning add a FALSE before the semicolon. Why a FALSE you ask? Well, basically when no enemy is visible to the monster it shouldn't attack. And besides, that's what the other *CheckAttack functions return in that case. (See wizard.qc, line 97 and 98). 4 down, 11 to go.

droptofloor: Too few parameters. See definition defs.qc(602)

droptofloor is never called with any parameters, so you have two choices here. First you could open up all the files with this warning and change the given line to droptofloor(0, 0);. Or you could simply open defs.qc go to line 602 and change the declaration form float(float yaw, float dist) droptofloor= #34; to float() droptofloor= #34;. 8 down, 7 to go.

weapons.qc:92:org redeclared

As you can see the vector org is declared as a local variable twice, once as the first parameter of the function and once alongside the other local variables. Since it would be a bad idea to remove the parameter declaration all you have to do to get rid of the warning is to remove the local vector org; line form the function. 9 down, 6 to go.

client.qc:134:FindIntermission: not all control paths return a value

The function does not return a entity when it doesn't find a intermission spot, to fix this warning add a new line at the end of the function with 'return world;'. 10 down, 5 to go.

misc.qc:179:No operation performed

There is a typo in line 179 of misc.qc: as you know, if you read any introduction to QuakeC, == is for comparisons only, remove one of the two =s form the line to get rid of this warning (the line should read 'self.speed = 1000;'). 11 down, 4 to go.

misc.qc:536:makestatic: Too few parameters. See definition defs.qc(650)

The missing parameter here is self, func_illusionary is a spawnfunction and makestatic should refer to the spawned entity (self). The fixed line should read 'makestatic (self);'. 12 down, 3 to go.

ogre.qc:249:ai_charge: Too few parameters. See definition fight.qc(157)

Annother missing parameter, this time a simple '0' since ai_charge is going to pass this parameter straight to the movetogoal builtin and the Ogre is not suppost to move during this frame. The fixed line should read 'void() ogre_smash12 =[$smash12, ogre_smash13] {ai_charge(0);};'. 13 down, 2 to go.

wizard.qc:180:WizardAttackFinished: not all control paths return a value

This warning is the same as the one with the SetMovedir function, WizardAttackFinished doesn't return any floats though it was declared as it would. It's type is wrong, it should be void(). Change the function definition form 'float() WizardAttackFinished =' to 'void() WizardAttackFinished ='. 14 down, 1 to go.

enforcer.qc:76:vec redeclared

Again, you can see that the vector vec is declared as a local variable twice, once as the second parameter of the function and once as a normal local variable. Remove the local vector vec; line form the function. 15 down, none to go. The QuakeC sourcecode should compile with 0 error(s), 0 warning(s) with frikqcc 2.6 now.

However if you use fteqcc you'll get about 61 more warnings about variables with no references:
knight.qc:32: warning: Duplicate macro defined (attackb1)
oldone.qc:29: warning: Duplicate macro defined (shake12)
defs.qc:401: warning: empty_float no references
defs.qc:417: warning: wad no references
defs.qc:428: warning: light_lev no references
defs.qc:501: warning: dest no references
defs.qc:548: warning: waitmax no references
defs.qc:549: warning: distance no references
defs.qc:550: warning: volume no references
fight.qc:298: warning: chance no references
fight.qc:299: warning: enemy_yaw no references
ai.qc:37: warning: current_yaw no references
ai.qc:476: warning: mtemp no references
ai.qc:679: warning: delta no references
ai.qc:680: warning: axis no references
ai.qc:681: warning: direct no references
ai.qc:681: warning: ang_rint no references
ai.qc:681: warning: ang_floor no references
ai.qc:681: warning: ang_ceil no references
items.qc:152: warning: amount no references
items.qc:871: warning: stemp no references
items.qc:872: warning: best no references
items.qc:1007: warning: stemp no references
items.qc:1008: warning: best no references
items.qc:1080: warning: stemp no references
items.qc:1081: warning: best no references
weapons.qc:91: warning: mpuff no references
weapons.qc:376: warning: mpuff no references
weapons.qc:551: warning: mpuff no references
weapons.qc:630: warning: old no references
weapons.qc:646: warning: old no references
weapons.qc:674: warning: hit_z no references
weapons.qc:677: warning: rand no references
weapons.qc:717: warning: rand no references
world.qc:362: warning: e no references
client.qc:292: warning: pos no references
client.qc:694: warning: old_self no references
client.qc:729: warning: start no references
client.qc:729: warning: end no references
client.qc:901: warning: mspeed no references
client.qc:901: warning: aspeed no references
client.qc:902: warning: r no references
client.qc:1113: warning: mspeed no references
client.qc:1113: warning: aspeed no references
client.qc:1114: warning: r no references
monsters.qc:51: warning: ent no references
monsters.qc:51: warning: otemp no references
monsters.qc:51: warning: stemp no references
monsters.qc:71: warning: stemp no references
monsters.qc:72: warning: etemp no references
buttons.qc:88: warning: gtemp no references
buttons.qc:88: warning: ftemp no references
triggers.qc:2: warning: stemp no references
triggers.qc:2: warning: otemp no references
triggers.qc:2: warning: old no references
triggers.qc:224: warning: junk no references
plats.qc:150: warning: t no references
misc.qc:447: warning: vtmp1 no references
misc.qc:447: warning: modi no references
ogre.qc:92: warning: mpuff no references
demon.qc:280: warning: vec no references
dog.qc:306: warning: vec no references
zombie.qc:164: warning: mpuff no references

Duplicate macro defined

this basically says that the a frame macro was given a name twice and is therefor ignored. In those two cases (shake12 in oldone.qc and attackb1) they are even in the same line right next to each other. To fix the warnings go to the given line and and remove one of the two entries of the frame macro.

no references

Well, this warning only tells you that there are variables defined that are not used at all, it's save to remove all definitions of the unused variables. Even in defs.qc, I know you might be told not to touch anything in that file, but you're save as long as you stay away form anything above line 220.