Source code for Quake 2 rerelease
github.com
github.com
The code is clear, coherent, and straightforward. I’m not going to say it’s the best source code I’ve ever read, but it set a high bar. I’ve read source code to games since then, and I’ve seen all sorts of weird stuff… I’ve seen functions with nesting levels that go past the right side of the screen, I’ve seen functions a mile long that do a million things, you know. It was an early lesson that you could do cool things with simple code.
We used Quake and Quake II to teach a VR class to kids in the late 1990s and early 2000s. You got a VR headset, you got a half-dozen PCs with Q.E.D. or Qoole, and you taught a room of 12-14 or 14-18 year-old students how to make their own virtual reality game.
“Make your own virtual reality game” was, essentially, making your own Quake or Quake II level, without any monsters or guns in it. The story for the game could be told through on-screen messages triggered in the level. Students made all sorts of levels. One group made a level with slime you had to cross, and a button that turned on pumps to drain the slime (very much like what you would see in a standard Quake II level). Another group made a 3D maze out of water that you had to swim through, floating in space. I still have some of these student-made levels on my hard drive, after all these years, although I have trouble getting some of them to work.
For the class, I made a mod that gave the players a flaregun instead of the blaster. Basically, it was still the blaster, but with a different sound effect and no weapon model. I modified the blaster bolt to be affected by gravity, bounce off of things, and go out after a certain amount of time.
(If you were in that class—you may not have gotten the headset. We couldn’t always get it to work.)
This, of course, makes perfect sense as an output from an industry leader in the field (Carmack). However it definitely requires a lot of foreknowledge and, dare I say it, a mathematical bent to follow with confidence.
What's surprised me is that successful, fun to play, and stable enough games have been shipped with such absolute unmitigated disasters behind the curtain.
It makes me question sometimes all the effort(and time) I put into preventing the chaos, when such carelessly bodged together garbage can be perfectly profitable.
You can start with a great plan, but no plan survives gameplay- and balance-tweaking for very long.
Ideally the lower layers are much more structured though, usually those need to be maintained over a longer time and across games.
It's not just subtle floating-point errors either, but also outright wrong maths that appears to work (see [1] for an example), memory leaks [2], buffer overflows [3] etc.
[1] https://www.youtube.com/watch?v=4gNYTqn3qRc
[2] https://news.ycombinator.com/item?id=20410166
[3] https://arstechnica.com/gaming/2021/03/how-to-beat-paper-mar...
They weren't coding for some NASA space probe and they knew it.
Guilty as charged!
I used to chronically write macaroni code. So you would have like 25 lines of code that ended up being the back bone of like a dozen things that would have another dozen things stacked on top of each. Would execute super fast BUT would amount technical debt quickly and eventually said functions would become untouchable because you would risk breaking a lot of stuff build on top of stuff.
Comments would try to clear it up, but communication skills where not the best. Explain function but not workings. Things like - "Does SINE table". "Table Defrag". "Binary resolve" etc.
Get a lot of people going "What the F*K is this shit?! But... it does the job damn fast". If it was any field other that video games, I would not have lasted long and neither would the product...
i = ent->client->chase_target - g_edicts;
do {
i++;
if (i > maxclients->value)
i = 1;
e = g_edicts + i;
if (!e->inuse)
continue;
if (!e->client->resp.spectator)
break;
} while (e != ent->client->chase_target);
for instance, from the function ChaseNext in the file original/rogue/g_chase.c can be reduced to i = ent->client->chase_target - g_edicts;
do {
i = i % maxclients->value + 1;
e = g_edicts + i;
} while ((! e->inuse || e->client->resp.spectator) && (e != ent->client->chase_target));
which in my opinion is clearer since the exit condition for the loop is in one place.Also I doubt everyone would agree that the one exit condition is more clear. For example, if I know that if e->inuse is 0 it will continue with the next round. Arguably it's more difficult to understand that from the single combined expression—because it isn't so: if !e->inuse but e == ent->client->chase_target, the original will loop but yours will exit.
Though I'm guessing ent->client->chase_target->inuse is probably never 0.
No, the continue statement will jump to the test part also for `do' loops:
"The continue statement is related to break, but less often used; it causes the next iteration of the enclosing for, while, or do loop to begin. In the while and do, this means that the test part is executed immediately"
-- "The C programming language (Second Edition)"
I'd say I prefer the original.
do {
...
} while (p);
guarantees that p is false after the loop and this makes it easier to reason about the program. With breaks, however, the loop could be "lying" so to speak.This approach also works fine for c++ and c# code (probably also java too), which I like as it keeps my projects nice and consistent and I can jump between codebases and feel at home.
The only thing that I don't like about it is the if() statements not being contained in {}'ies. That always makes me nervous.
The best reason not to re-write for style reasons is you break it.
The first example makes it very clear that condition A means do it again and condition B means exit this loop while condition C establishes the boundaries of the loop.
----------------------------------------- John Carmack's .plan for Jan 31, 1997 -----------------------------------------
I went down to the ferrari dealership today with Ann and American with the intention of buying a new f355 as a "sensible" car (in contrast to my other twin turbo monstrosities).
There was an F40 sitting out front.
Umm. Sensible car. F40. Sensible car. F40. Hmmmm.
American played the evil conscience and Ann played the good conscience. For a while. Then Ann got infected by the Dark Side. :-) I bought the F40.
Ok, I now have too many ferraris. I have a plan to fix that. This hasn't gone through all the legal crap necessary yet, but it is my intention to give away my first ferrari as the grand prize of a Quake tournement.
Yes, I am serious.
DO NOT SEND ME ANY MAIL ABOUT THIS! When we have more to say about it, we will make a formal announcement. This would be a good time to start a heated debate in the newsgroups about what the fairest tourney rules would be, though.
The specs:
1987 328 GTS with turbocharged engine. Feature in the january, 1994 issue of Turbo magazine. Made 360 HP at the rear wheels on a chassis dyno. New engine (I melted the first one...), new paint. The interior could use a little work.
I plan to also include enough cash to cover tax and insurance.
After 2 or 3 purchases, the dealer habitually put the most expensive car in that spot.
When I started, I had only ever played the original DOOM, so I used those controls, and lo and behold they worked, and I thought nothing of it. At some point as I was playing along, my view suddenly became locked to the ceiling and I was thoroughly confused and stuck. Turns out I had bumped the mouse, and managed to figure out that mouse look was a thing after extended fiddling with the system to try to determine the cause and get back to killing badguys. Needless to say, the game got quite a bit easier after that.
There wasn't internet, neither I nor my friend knew what mouse-look was, we had never seen anyone play a true 3d fps. It is hard to imagine how obscure and alien the interfaces for games are because of how pervasive the knowledge has become.
Glad to see the source code released!
In case you were unaware, this is actually the source code of the rerelease of Quake II. The source code for the original Quake II has been released for many years[0], along with many of the id Software classics[1].
If it's anything like the Quake re-release, it's not actually using idTech 2 at all.
I was at a ComicCon in Rome, Italy, circa 1999, anyway Half Life just hit gold production and released multiplayer demos there were at least 20 people all playing on lan multiplayer half life, with mouses too! Crazy.
I went to many many lan parties since then up to 2005, then online match making killed quakenet and socializing.
Back in 1999, Quake II was the game I played (like, literally the only one). I sunk so much time in QII and I wrote my very first code building a Mod.
I think it's fair to say, Quake II turned me from a computer user into a computer programmer. And set the course for my entire adult life and career.
From my original mod, I learned how to calculate vectors, learn an existing code base, integrate autobuilds for rapid testing.
I also dabbeled in making maps, learning 3rd art, but, quickly realized I am no artist or designer.
Sadly, my version control and backup policies at the time were non-existant and I've lost all my original code.
The next game that really got my attention in the same way was Tribes 2, the scriptings and modding you could do there was truly amazing.
An homage: http://guake-project.org/
I find most DE's painful without that ability. The main exceptions are i3/sway or cwm, where I just launvh a terminal and then kill it.
So the real benefit IMO is that it then lets you keep your actual terminals more clean and focused, and not just interleave that kind of stuff with whatever you are doing.
https://xn0.co/Xeno-Mod_1.9_Setup.exe
Because I'm sure everyone on HN just downloads execs from a random internet source and runs them!
But if you have the OG QII, are curious, it is safe to run.
Adds 10 extra weapons
Changes the damage ratio of all weapons
Imports the "gravity mines" from one of the Q2 expansion packs
Adds togglable "moon boots" (low gravity, on a per-player basis)
Adds a grappling hook, with swing physics
Has "secret" command to turn invisible. (I can't remember what it is). Because back in 1999 I didn't realize people could unpack binaries and read them.
...should I not?
Then you could even do: npx run quake-2-xeno-mod@1.9
Not true, some of us have JavaScript disabled.
I assume this[1] is your website, please do not ever let the website go offline. It is such a perfect reminder of the time it is from.
Like you I was just tinkering, though I stuck with it for a long time. At that point I was 19 and literally living in my mom's basement.
It's all server side so there wasn't a huge amount you could do. The flame thrower was just the grenade launcher rotated upside down. The shotgun was my best invention, IIRC made up of two ELF guns rotated 90. Deadly up close with a delay before firing, only useful from afar to take off a sliver. Cloaking and hitting someone in the back with it was great -- click-click BANG dead. Good times!
Using one of my dad's ancient parallel cables and fooling Windows into thinking it was a LAN connection, which worked well enough, we played for days, until it got kind of tedious. So we then got into the whole modding scene - not creating anything, but downloading and testing the things which were out there. I will never, ever forget Girobot and KQP (Killer Quake Patch).
The Girobot bots were a force to be reckoned with when they didn't get stuck in the terrain. It was KQP which added all kinds of crazy mods/weapons/bot systems to the game that was the real gold. The Vampire Gun left us in stitches every time someone was hit by it, because it basically guaranteed a slow but not too slow death in which the hit player would crumble into little chunks of flesh. I miss the nineties very, very much.
Also, I believe KQP had ZeusBots included (for reference).
First few computers were too slow to run Quake effectively, but then I had a Duron 900 (they ran slow AND hot!), bought a 'PC Powerplay' magazine that came with a CD full of quake mods, and a map with 20-40 of ZeusBots worked just fine!
[1] https://github.com/Jason2Brownlee/HumanDebrisArchive/blob/ma...
With a null modem? I had same setup with my college roommate in our apartment. This was mid 90s, so it was Doom 2 and other FPS from that time.
Great memories.
I'm assuming they don't have legal requirements since they owned the old code anyway.
It could just be that they started using other proprietary components in their code though.
Would've loved to read the source code for Doom 2016!
I always found amusing that to replace him Zenimax built a whole new studio in Germany to hire the top programmers from Crytek and even then Doom 2016 used a litany of middleware :-P.
It was like the game didn't know if it wanted to be an FPS or some seamless open world ARPG so it tried to do a bit of both and the only reason the FPS side didn't felt bad was because id was masters at making FPSs by that time - but it was certainly dragged down.
It would have been way better if it was a regular FPS with a linear progression of levels like id's previous games.
https://www.gamedeveloper.com/design/patent-issue-forces-new...
With the newer engines there isn't a convenient branch that already has the proprietary parts substituted, and there's a lot more of them.
-----------------------------------------
John Carmack's .plan for Dec 11, 1997
-----------------------------------------
The Quake 2 public code release is up at:
ftp://ftp.idsoftware.com/idstuff/quake2/source/q2source_12_11.zip
This source code distribution is only for hard-core people that are
going to spend a lot of time pouring over it. This is NOT a
how-to-make-levels-for-q2 type dsitribution!
This should keep a bunch of you busy for a while. :)
https://github.com/ESWAT/john-carmack-plan-archive/blob/mast...I wish there were a law that if you don't release a patch for your software for 20 years to make it workable for newer platforms, you've to release it as open source from the perspective of cultural significance.
Why spend the energy trying to think up two names (one for the function you're writing and one for what you should call the type of its result)? It's also amenable to preprocessor macros, if you're so inclined.
That being said, I picked up the _s/_t habit from working on idtech codebases, and decided that I'm fine with my own C codebases forever having a "not POSIX compliant" stamp on it, whatever that means in practice. For C++ I just use InitialCamelCase.
I just used the preprocessor to #define key_t mykey_t (or something like that) after the Mac-specific headers in the couple of files where the conflict was and never thought about it again.
Cube instead of cube_t.
My map was The Edge and my weapon was either the rail gun or rocket launcher. I was on dial up back then so finding a server was good latency was critical. Most annoying of course were the folks using that gun that caused lag for everyone.
I know Q3 is the bigger game that perfected the genre but my favorite will always be Quake 2. Not only was there a solid single player + expansion packs, but the pace was just right for me. Everything got too fast when Q3 came around.
VQL is much closer to Q2, whereas PQL is more CPMA or Quakeworld.
Bonus, "The Edge" is also available in Quakelive.
EDIT: maybe it's getting sorted out, there's even a fricking vinyl release
https://www.lacedrecords.com/products/quake-2-limited-editio...
Unfortunately that CD cracked, so I no longer have access to the music nor the game.
The remaining side has audio code from the game etched into it.
“Corporations are so big, you don’t even know who you’re working for. That’s terror, terror built into the system”- Deus Ex, NSF.
Optus (telco in Australia), owned by Singtel, which is majority owned by Temasek, which is owned by the Government of Singapore. You can also substitute in India's 2nd largest telco (Bharti Airtel) for Optus in that example, by the way.
For what it’s worth, the first expansion (The Reckoning) was probably my favorite single player Quake 2 experience. Favorite multiplayer was Devastation Quake, where one player is in a mech and everyone else has to team up to knock them out.
They did a lot to open the idea that game mods could be more than cheats and cracks, too.
I still remember the grenade launchers and wild modded grenades fondly. the bouncing ones were so much fun in hallways.
For instance, Quake was the first FPS where the maps were truly 3D and could have one piece of floor on top of another. It would be considered insane for a game to not have that now. Quake(World) was the first truly massive online gaming FPS. Quake II was the first game I ever owned that used a 3D graphics card, I still remember the first time loading it up after I installed my card to set this wondrous coloured lighting that followed a rocket when I fired it.
Anyway, point is you’re right, you are too young to understand. I don’t mean that in a patronising way, it’s just that it’s not impressive today in any way. The enthusiasm you see here is nostalgia. It’s a museum piece.
And you could see both at the same time. The Build Engine used by Duke Nukem 3D could also have one piece of floor on top of another floor (or even going through another floor), but due to how it worked, if both were visible at the same time you would have a "hall of mirrors" effect instead of rendering properly. And also water: while the Build Engine faked it by teleporting the player to another room when entering or leaving a water area, Quake did not need that kind of trickery.
Other than Duke Nukem 3D, other popular FPS games from that era also used "2D map with varying height" (like the Doom family), or even simpler things like rectangular 90-degrees-only single-height maps (for instance, Wolfenstein 3D).
Also, "first true 3D FPS" depends on how you would classify Descent.
Bethesda's Terminator: Future Shock predated Quake by a year and also had truly 3D maps - which were often more expansive than Quake's (also you could drive vehicles, fly a helicopter or something like that IIRC, enter various places to find loot - though the loot variety was limited to basically ammo, weapons and grenades). I think Quake got more attention because Doom made way more of a noise than Bethesda's previous game (which AFAIK was a poor Wolf3D clone[0]) and unlike TFS Quake also had multiplayer support which was HUGE (TFS was criticized at the time for not having it).
Amusingly enough TFS controls pretty much like a modern FPS with its mouse look and the ability to configure WASD whereas Quake was still a hybrid of mouse being used to move forward/backward (unless you typed the "+mlook" command in the console) and again TFS was criticized for this.
[0] ok, they also made Arena but still id's previous game was way bigger and even at the time your last game was what people paid most attention to for the next one
2: Doom's impact was more huge than Quake. The MOD community still releases PWADs today. Doom basically boosted LAN multiplayer matches.
The most popular choice of accessory was the Sidewinder 3D Pro. That was my choice of input device and I was easily a top 5% player in my teens.
I never touched one, but many people swore by the SpaceOrb 360 as the pinnacle of controllers for Descent.
You can get into a rocket fight with your opposition, sustain a fair number of hits, heal in the next room, and repeat. Their goal was to make you feel like an amazing demon-killing machine.
Quake was one of the first PVP FPS games to bring that feel to the game. Death had minimal consequence, your goal was to find and kill the opposition, lethality was set low enough that you could shoot a rocket at your feet to "jump" higher.
At least, that's what made Quake (and ID games of that era) stand out to me.
Duke 3D had gameplay that was more fun, but it was a 2.5D game with a Doom-style engine (it was much more sophisticated with scripting and slanted ceiling/floors but still not true 3D like Quake).
Post-release, Quake had patches called GLQuake which added 3d accelerator support, and Quakeworld which added internet movement prediction so playing online didn't feel as jank. Quake 2 came out with these features integrated and more - colored lighting, transparent surfaces, etc.
Allow me to share the perspective of someone around 18 years old at the time.
First, Id Software created the FPS category with Wolfenstein. However, the company didn't gain widespread recognition until they released Doom. Doom was exceptionally unique, to the extent that it made headlines in mainstream news.
With the launch of Quake, although other FPS games existed, the expectations were high as everybody saw it as the successor of Doom. Also, Quake had a genuine 3D environment as opposed to Doom's 2.5D. 3D graphics cards were not common, making Quake a marvel of PC gaming. Moreover, Quake featured an advanced mod system and a level editor, which were rare in games of that time.
FPS games are now ubiquitous, and even budget smartphones have more 3D capabilities than high-end PCs of that era. So, the “wow” factor of Quake was extremely high.
However, Carmack was the most brilliant engine developer of his time and was heavily committed to open platforms, so that meant these games looked head and shoulders above their peers and played amazing online and had massive communities of modders and admins running the online games. Basically they created the modern FPS genre.
Until Unreal Tournament and Counterstrike came along, the Quake series was the king of online FPS gaming. And even after they appeared, Quake 3 held its own.
Both the resurgence of "boomer shooters" (at least in PC) and by extension the recent remastering of both Q1/Q2 indicates an existing target group for these kind of games.
Point taken that younger players may see no fun or meaning in games like this, but modern gamer <> young gamer.
Indeed, some years ago i'd wake up, take a shower, make some coffee, do a quick play of the first episode of Quake (i stopped at first death but i pretty much knew the game so well by that point that i rarely died before the last couple of maps) to wake up and then go to work :-P.
One can drift naturally to one or another extreme, but the more the variety the better imho. I just enjoy simpler games both in graphics and gameplay.
- First real 3D FPS game using OpenGL (GLQuake)
- First real multiplayer 3D game with 16 players
- First to introduce the idea of a "clan" or "guild" for a multiplayer game. It's where the term "clan" came from
- First esports game
- First instance of Capture the Flag mod later used in other games
- First instance of Team Fortress later used in other games (e.g. TF2)
- First game to have "demos" (aka VODs) where you can rewatch / replay a match
- First game with a multiplayer competition match mode (Clanring or CRCTF or CRDM)
- First web service allowing you to see what's going in in games from the internet [qstat](https://github.com/Unity-Technologies/qstat)
Aside from all of these firsts Quake 1 and Quake 2 were incredibly executed.
- Soundtracks made by Nine Inch Nails. Who at the time ever heard of a tier 1 famous band making entire videogame soundtracks?
- Creepy gothic lovecraftian demonic theme combined with space. The space parts were later ripped off by Half-Life. And you can see the influences even on modern cultural artifacts like the show Stranger Things (which itself seems to rip off Half Life's storyline).
Quake is basically the original online multiplayer game and had almost everything we have today but had it all the way back in 1996. The only things that game didn't really have was deep API integrations to websites the way games have now or complex matchmaking with elo and ranks.
Both are great OSTs, Q1 is a "ambient-horror-esque" styled album [1] while Q2 OST [2] is practically industrial metal made using synths.
[1] https://youtu.be/5n8iU7abqkQ [2] https://youtu.be/svRkAEoT5Hc
Quake II was at my first proper job, at DEC. I worked on the server/storage support team. At 5pm when the phone lines closed we'd fire up Quake II on a server and at least 20 people would hang around for an hour or two after work to smoke cigarettes and play Q2. The mods are terrific. One person used a perfectly crafted Homer Simpson mod, complete with sounds effects sampled from the show. Also remember a "Bananas in pyjamas" skin and a small floaty robot (which was a bit of a cheat because it was harder to see than Homer). And the maps! Christ, so many great maps. Some of them are in Xonotic, and I still play DM in them occasionally.
It's really too bad that the old ways of independent servers and mods went the way of the dodo. Just the other day for no reason at all I found myself repeating the old guttural "Welcome to GameSpy" voice intro to myself.
I watched some videos about MyHouse.wad (a Doom 2 level/mod that became popular with the indie horror crowd), and it's seriously impressive.
I wonder what happens in the context of Quake, after seeing the community take Doom to places Carmack could never have imagined.
I'm a lot more interested in how people mess with the rules of the game without necessarily breaking them, leading to some super subversive storytelling, rather than just porting the code onto a smart fridge or some shit.
Quaddicted is a great site to find mods; QuakeSpasm is a fantastic binary for enjoying them; and nQuake is where the multiplayer is at.
If you don't care about Doom (or even video games, honestly): I haven't even thought about Doom in 20 years. Just click the link and watch.
One of my favorite YouTube rides of all time.
Nightdive did a nice job giving new tools to make modern mods possible (effectively giving us much of the kit they used to remaster Q2). My read is that this isn't an accessibility to be able to make cool mods problem so much as an inertia one.
[0]https://www.doomworld.com/forum/topic/136771-every-gzdoom-ga... (Many of the links to games are various grades of NSFW)
I played the hell out of the LMCTF mod back in the old days. Great times.
Alliance for q3 was also great too, but it wasnt quite the same.
There is a Facebook community alive for LMCTF. Last time I checked they have a few servers online and organize pick up games.
I believe there were similar bits in the Quake 1 source, e.g. for Scourge of Armagon (Mission Pack No. 1) you would see things like '// HIPNOTIC'.
Quake 3’s source is pretty interesting from the perspective of id just transitioning from C to C++, and famously has an implementation of fast inverse square root. It’s also a pretty clean codebase overall with a reasonably modern engine architecture.
Quake 3 was designed to be used by 3rd parties and is more well put together, focuses on OpenGL and Carmack considers it his best C code.
I'd say one of these two.
I wonder if jungle1 and teamjungle are ported? Those were the first maps I made for any game (and I had no idea what I was doing).
I fondly remember a conversation with a random person in a bar, about a decade ago. Somehow, they brought AQ2 into the conversation, pointing to my creations as their favorite maps (without knowing I made them).
That was a good feeling :)