Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Quake 3 Source Code

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Quake 3 Source Code
Billybob
Member #3,136
January 2003

I hacked into their servers and got the source code, mwahahaha.
Download, Download, DOWNLOAD!

ReyBrujo
Moderator
January 2001
avatar

I read in Digg I think that is not the full source code, but only the mods support source code, is it true? I never liked Quake, though, been a Counter Strike man myself.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

juvinious
Member #5,145
October 2004
avatar

Carmack announced that the code will be published under the gpl very soon. He was actually going to do it last year, but ended up holding on it since ID, at the time, had just licensed it to another company.

[edit]
In fact here it is: Clicky
Announced during Quakecon 2005.

__________________________________________
Paintown

Billybob
Member #3,136
January 2003

It's the full Quake 3 Arena source code. You can compile it on Windows, Linux, and even Mac OS X. Though I hear it's buggy on OS X.

juvinious
Member #5,145
October 2004
avatar

Ok I just checked /. and it looks like it was released just recently. :D
Good sleuthing Heatly. :P
Urly

__________________________________________
Paintown

Billybob
Member #3,136
January 2003

For those that don't like reading all those /. comments (and since Alterslash doesn't archive good ones):

Quote:

Results of `grep -ri fuck *’:

1. //NOW close the fucking brush!!
2. i = 0x5f3759df - ( i >> 1 ); // what the fuck?
3. // fuck, don’t have a clean cut, we’ll overflow
4. // since the cmd formatting can fuckup (amount of spaces), using a dumb step by step parsing
5. // fuck, don’t have a clean cut, we’ll overflow
6. // vm fuckage
7. // vm fuckage
8. //FIXME: this is a fucking mess
9. Note: Unix CR/LF in *.dsw/*.dsp fucks up MSVC++.
10. How the fuck did this happen?
11. some files, and between their revisions and ours we fuck this up.
12. break; // dragged backwards or fucked up
13. // FIXME: this code is a TOTAL clusterfuck
14. {“rem”, “Less than half a fucking man.”},
15. {“rem”, “You’re fucking dumb! Suck it down.”},
16. // cleaning up after merging and thinks badly fucked up
17. this could fuck up if you have only part of a complex entity selected…
18. // FIXME: this bend painting code needs to be rolled up significantly as it is a cluster fuck right now

Quote:

Tested on a Debian Sarge:

  1. Get the code

wget ftp://ftp.idsoftware.com/idstuff/source/quake3-1.3 2b-source.zip
mkdir q3a
cd q3a
unzip quake3-1.32b-source.zip
cd quake3-1.32b

  1. Transformation for UNIX

find -type f -exec dos2unix {} \;

  1. Compiling

cd code ./unix/cons

  1. Result

cd install
find -ls

  1. Install the packs

  2. You needs to original files!

  3. I do not find them in the source.

cp -a usr/local/games/quake3/baseq3* ~/.q3a/baseq3/

  1. Playing ./linuxquake3

Quote:

First off, a big thanks to John Carmack for opening doors for developers… again.

The most exciting thing about this release is the GPL’d version of QeRadiant included with it. Radiant is a tool that many professional level designers swear by. For the first time ever, it is now available for independents to use when creating content for their own games. Prior to this, you needed a license from Id Software in order to use it for commercial purposes.

float InvSqrt (float x) 
{ 
     float xhalf = 0.5f*x; 
     int i = *(int*)&x; 
     i = 0x5f3759df - (i >> 1); 
     x = *(float*)&i; 
     x = x*(1.5f - xhalf*x*x); 
     return x; 
}

/// Note on the above code. It's under the GPL now, so be sure to follow the GPL when you implement that.

Brolin Empey
Member #6,132
August 2005

I found this in unix_main.c and macosx_sys.m:

int Sys_MonkeyShouldBeSpanked( void ) {

  return 0;

}

My grepping shows that this function is never actually called anywhere.

Evert
Member #794
November 2000
avatar

I just hope InvSqrt doesn't do what its name suggests it does (invert a square root)...

Dennis
Member #1,090
July 2003
avatar

...would not "inverting" a squareroot be the same as "abs"... maybe it gives the "reciprocal" so its 1/sqrt...but still "inv" is wrong...mumble mumble...

Kitty Cat
Member #2,815
October 2002
avatar

Somebody should run it, and compare the input and output. ;)

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Rick
Member #3,572
June 2003
avatar

Quote:

It's the full Quake 3 Arena source code.

It has an actual int main() (read OS specific main function)? Cool...Sorry, I've worked on HL code before. I hate not seeing int main(). It just makes me fuzzy inside to see the starting point.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Peter Wang
Member #23
April 2000

Dennis, you peeked at the answer didn't you? :)

Dennis
Member #1,090
July 2003
avatar

Peter??? I can't follow you: What answer? Answer to what? What did i say? Did i answer anything? (really i have no idea what you're talking about)

Peter Wang
Member #23
April 2000

The mystery of InvSqrt().

Avenger
Member #4,550
April 2004

More importantly, why is it there?8-)

Dennis
Member #1,090
July 2003
avatar

I don't know what it does, was just guessing. Looking at the function itself however, it is considered very bad programming style by me, because
a) No comments describe what it does
b) it uses a hardcoded constant
c) x as a parameter is abused as a local variable (legal but bad style, ok ok it's for speed reason for sure but still bad style)
d) if it really gives the reciprocal then the name is misleading and wrong

BAF
Member #2,981
December 2002
avatar

This is so old news :P

We've had the src code with a download mirror posted in #Allegro's topic since yesterday ;)

Evert
Member #794
November 2000
avatar

Well, you guessed correctly (of course).

Interestingly enough, I ran the following programme through the profiler:

1#include <stdio.h>
2#include <math.h>
3 
4float InvSqrt (float x)
5{
6 float xhalf = 0.5f*x;
7 int i = *(int*)&x;
8 i = 0x5f3759df - (i >> 1);
9 x = *(float*)&i;
10 x = x*(1.5f - xhalf*x*x);
11 return x;
12}
13 
14float InvSqrt2 (float x)
15{
16 return 1.0/sqrtf(x);
17}
18 
19int main(void)
20{
21 float x = 2;
22 float y, z;
23 int n;
24
25 for (n=0; n<10000000; n++) {
26 y+=InvSqrt(x);
27 z+=InvSqrt2(x);
28
29 x += 0.3;
30 }
31 printf("%g, %g, %g\n", x, InvSqrt(x), InvSqrt2(x));
32 printf("%g, %g, %g\n", x, y, z);
33}

Compiled with -O2 -pg on gcc 3.4.1 and running on an AMD 64 in native mode.
The resulting output:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ns/call  ns/call  name    
 52.52      1.53     1.53 10000001   153.37   153.37  InvSqrt
 31.79      2.46     0.93                             main
 13.48      2.86     0.39 10000001    39.35    39.35  InvSqrt2
  3.11      2.95     0.09                             frame_dummy

So it actually seems to be both less accurate and slower than using the libc function!
Of course, this may not be true on other hardware, but I'll just take it as another indication to not do obscure optimisation hacks like this one.

Mika Halttunen
Member #760
November 2000
avatar

On this old and slow K6-2, 400MHz I got following results with Evert's code: (Compiled with -O2 -pg on MinGW 3.3.1)

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ns/call  ns/call  name    
 46.38      2.37     2.37 10000001   237.00   237.00  InvSqrt2
 32.09      4.01     1.64                             main
 21.53      5.11     1.10 10000001   110.00   110.00  InvSqrt

It seems that on old machines like this the hacky version is faster. :)

---------------------------------------------
.:MHGames | @mhgames_ :.

Thomas Fjellstrom
Member #476
June 2000
avatar

Heres the results on my machine: (AMD Athlon XP 2400+ @ 2ghz w/768MB PC2700 ddr sdram) also, using gcc 3.4.4

moose@S0106000ea679c3f1 ~ $ gcc -pg -c invsqrt.c -O3 -march=athlon-xp -fno-fast-math
moose@S0106000ea679c3f1 ~ $ gcc -pg invsqrt.o -o invsqrt -lm
moose@S0106000ea679c3f1 ~ $ gprof ./invsqrt
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ns/call  ns/call  name
 63.79      2.96     2.96 10000001   296.00   296.00  InvSqrt2
 19.61      3.87     0.91                             main
 14.66      4.55     0.68                             InvSqrt
  1.94      4.64     0.09 10000001     9.00     9.00  frame_dummy

edit: heres the -02 version

moose@S0106000ea679c3f1 ~ $ gcc -pg -c invsqrt.c -O2
moose@S0106000ea679c3f1 ~ $ gcc -pg invsqrt.o -o invsqrt -lm
moose@S0106000ea679c3f1 ~ $ gprof ./invsqrt
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ns/call  ns/call  name
 63.79      2.96     2.96 10000001   296.00   296.00  InvSqrt2
 19.61      3.87     0.91                             main
 14.66      4.55     0.68                             InvSqrt
  1.94      4.64     0.09 10000001     9.00     9.00  frame_dummy

seems similar ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

HoHo
Member #4,534
April 2004
avatar

Just imagine what would be the speed difference if SSE sqrt function would be used. Sure, the accuaricy wouldn't be as good but I bet it would be quite a bit faster than libc sqrt.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Carrus85
Member #2,633
August 2002
avatar

Too bad they don't include a sane makefile for mingw32 (aka. Us poor windows users who can't afford MS's "Expensorama" Compiler)... :-/

EDIT:

I wonder, does this mean that with a bit of hacking we could soon get native versions of most Quake3 games on linux? (Like WolfET for example. Yes, I know it is native, but you can't really compile it to make your own platform-specific optimizations...)

True, it would require the GPL-ing of the source for those other Quake3 based games, so I'm guessing no... :-[

Niunio
Member #1,975
March 2002
avatar

But is it the Quake 3's sources or not? ???

-----------------
Current projects: Allegro.pas | MinGRo

HoHo
Member #4,534
April 2004
avatar

it is. Full sources of engine and some tools like radiant and some more

[edit]
Tihis would be the answer if you meant if the code that you can get is for q3a. If you meant something other please specify

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Niunio
Member #1,975
March 2002
avatar

I meant, if I have all Quake 3 data files and I compile this sources, can I play Quake 3 Arena?

-----------------
Current projects: Allegro.pas | MinGRo

 1   2 


Go to: