a c t u a l i t y . l o g

Compiling and running Quake III on GNU/Linux

Tuesday, August the 23rd, 2005

This weekend was good for the pseudo-intellectual amongst the gaming community. The source code for [1] Quake III’s engine was released. Here are some steps and notes to getting it compiled on your friendly GNU/Linux box.

(Remember, this is just the engine, and [2] you do need to shell out the $10 or whatever and get your copy of the original game, for the game data.)

Steps:

0) cd /convenient/directory/
1) wget --passive-ftp ftp://ftp.idsoftware.com/idstuff/ source/quake3-1.32b-source.zip
2) unzip -qq quake3-1.32b-source.zip
3) cd quake3-1.32b
4) find -type f -exec dos2unix {} \;
5) cd code
6) chmod +x ./unix/cons
7) ./unix/cons -- release
8) cp -r /where/you/installed/the/game/you/bought/baseq3 ./install/
9) cd install
10) ./linuxq3

Corresponding Notes:

0) Pick a directory writable by you. Duh.
1) Make sure you get the latest code by first browsing the ftp site with your web browser.
2) -qq keeps things very quiet.
4) Make sure all the evil DOS carriage return characters are removed and the text files are UNIXified.
6) Make the install script executable.
7) -- release ensures you’re building the “final release” version of the code without -Werror turned on. Which means it will complain, but not balk, on warnings. You could also do ./unix/cons -- release gcc="/opt/intel_cc_80/bin/icc" g++="/opt/intel_cc_80/bin/icc" for, you know, Intel goodness.
8) Move the game data over from the original game’s install.
10) Start fragging!

Once you’re done and decide to actually learn something, you browse the code a bit. There are some absolutely intriguing (or horrendous, depending on how you look at it) bits in the code. For e.g., in code/game/q_math.c,


float Q_rsqrt( float number )
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;
            
	x2 = number * 0.5F;
	y  = number;
	i  = * ( long * ) &y;
       // evil floating point bit level hacking
	i  = 0x5f3759df - ( i >> 1 );  // what the fuck?
	y  = * ( float * ) &i;
	y  = y * ( threehalfs - ( x2 * y * y ) );
            
#ifndef Q3_VM
#ifdef __linux__
	assert( !isnan(y) ); // bk010122 - FPE?
#endif
#endif
	return y;
}

Seriously, what the fuck? I found [3] a paper [math.purdue.edu] online that made a little bit more sense.

pundit@emphaticallystatic.org