Hacker News new | comments | ask | show | jobs | submit login
Quake III Arena GPL Source Release (2012) (github.com)
265 points by tosh 9 months ago | hide | past | web | favorite | 79 comments

Heh, I still remember from the wolf3d release the self modifying code:


How to get this good? :D

Know your math (and floating point hacks, and ...)

I was bummed that there were no contributions in the 6 years this was open sourced, but it turns out that active development is actually happening in a fork: https://github.com/ioquake/ioq3

It's the same story for Doom 3 engine / id-tech4. The most active fork I think is still Dhewm3, which includes some modern useful changes for compiling.

* https://github.com/id-Software/DOOM-3

* https://github.com/dhewm/dhewm3

Also there's the Vulkan port by an id employee: https://github.com/DustinHLand/vkDOOM3

And Doom 1/2, which has which probably is the longest list of forks and ports of any software ever: https://doomwiki.org/wiki/Source_port#List_of_source_ports

Well, Doom and Quake 1 are kind of in the sweet spot where they are still small enough that one person has some hope of understanding the code base. As impressive as the later IdTech iterations are, and as awesome as it is that the code was released, they are daunting for a hobbyist.

Quake has more I would guess: https://en.wikipedia.org/wiki/Quake_engine#Derivative_engine... (old and incomplete)

Yes, and it was really open sourced in 2005. But apparently published on github in 2012.

I really like Quake 3's code. My favorite parts are:

- The client/server network protocol and syncing state

- The VM architecture (e.g. most of the game can be compiled by LCC into a custom byte code and interpreted. This was for safely (although I wouldn't be as sure these days) distributing mods iirc. I think the main game was shipped compiled to x86 though. The interface between the VM and the core stuff is via "syscalls" and its fun to see how that's wired up.)

- The player physics/controls (i.e. walk/jump/collisions/etc.) (it's neat how fake first-person player physics always is. This isn't unique to quake 3 but quake 3 had notably good controls.)

It's a bit fun to trace what happens on 'w' keydown/keyup (when bound to walk forward.) When I first saw how that actually worked I was surprised (hint: it types commands invisibly into the command console ;) lots of string copies to do that.)

A random thing I just remembered:


They implemented adaptive huffman coding but ironically only use it during static initialization, feeding it with static data (see the defn of msg_hData a few lines up.) Note that the only calls to Huff_addRef are in the init, and notice how it gets called - the loop over msg_hData[i]. I found that pretty funny. I'm guessing there was some plans to use it adaptively but it's not easy/obvious how to keep it in sync reliably...

Source review here: http://fabiensanglard.net/quake3/

This is one of my favourite games of all time! It has great atmosphere, attitude, awesome mods and is well balanced. Thanks for this link it will be a good read :)

Are you talking about Half-Life? ;)

This seems like a good time to mention the open-source Quake map editor TrenchBroom[0] which is actively developed and supports Quake, Quake 2 and Hexen 2 (with Quake 3 support on the way). It's very easy to work with and heavily used in the Quake mapping scene today. Yes, there is a "Quake mapping scene" still![1] :)

[0] http://kristianduske.com/trenchbroom/

[1] https://www.quaddicted.com/ & http://www.celephais.net/board/

Well, as far as I remember that doesn't include the assets, so to play the actual game you still need the asset files.

Nevertheless, I appreciated the open source release very much back in 2005, as it allowed you to learn C programming in a friendly way. Not just that testing is like playing a game, but they have build a lot of platform independent functions to provide cross platform support.

Yeah, but you ought to be able to use the assets from the demo.

looking at code like this in github always reminds me why I prefer spaces over tabs, look at all that broken alignment:


This is why you use tabs for indentation and spaces for alignment. Too bad most editors don't have good support for that.

> Too bad most editors don't have good support for that.

And this is why you use spaces for everything.

Or you just configure your editor to output spaces when you hit the tab key. Any serious text editor or IDE these days should have that option.

Yes. That's so common I didn't even think it necessary to mention.

I can't imagine anyone would manually press the spacebar N times to get the desired indentation level.

Oh, people do...

Use tabs for indentation and spaces for alignment and you will never have any problems using whatever tab width you want (except for potentially exceeding 80 char line length if you care about that. IMO that's secondary compared to the pros.)

... and get the worst possible experience? No thanks.

It can't be the worst experience if things actually line up.

I was being flippant but... things actually line up if you force everything to tabs too (or “smart tabs” if you really really want alignment for some reason).

Except with tabs everyone gets whatever width they want. Tab width is configurable system wide (and even in GitHub’s terrible web view).

Spaces are objectively worse in every possible way and require workarounds and editor hacks to make them behave like tabs. Skip a step & just use tabs: much better.

It's only objective if you're controlling the objectives. Here's my counter-example.

Go here in a browser: https://github.com/id-Software/Quake-III-Arena/blob/master/c...

Note that the use of tabs has caused un-alignment. You've claimed that tab width is configurable in git's web view, but I can't figure out how to do it.

And further, if it requires me to configure in a certain way, then it's not really true that "everyone can configure tabs how they want".

Spaces. Set it and forget it. Works everywhere, every time. Objectively better.

>Objectively better.

You can't really say that definitively without ignoring the laundry list of negatives that come with spaces. Spaces are not configurable at all. That, in itself, is reason enough that Tabs are "objectively better".

That’s due to the spaces tho, not the tabs. It’s the lines that used spaces that look awful.

You literally provided me with more proof spaces are bad. Good example.

Nope, it's the tabs. The only lines that are mis-aligned are mis-aligned because of tabs, not spaces. And it is a good example.

I see the exact opposite but.. k.

Interesting. Perhaps you've been using spaces all along, but somehow they appear to be tabs to you. What a twist that would be.

Or just don't bother with alignment and just use tabs for indentation. For example, instead of aligning function parameters after the opening parenthesis, move them to the next line and use a hanging indent:

    someType someFunctionName(
            param1, param2, ...)
I find that following a style like this will work equally well with tabs or spaces and that I have to spend less time formatting code I write (either manually or changing a setting in the editor I'm using).

This is a very good point, and I agree.

No matter how you do it[0], alignment is bad for maintainability. It happens that someType or someFunctionName changes, and if you use alignment, you'll have to re-align all those parameters. This is annoying to do even with editor help, and it generates noisy diffs which make patch review needlessly more difficult. Aligning the names of member variables is even worse.

Just Say No to alignment, perhaps? ;)

[0] Well, except if you use "elastic tabs", which don't have widespread support in the first place.

I recently found the answer for this. Sublime [0] with the Elastic Tabs[1] plugin[2].

[0] https://www.sublimetext.com/

[1] http://nickgravgaard.com/elastic-tabstops/

[2] https://github.com/SublimeText/ElasticTabstops

Also too bad both tabs and spaces are usually displaced as the same whitespace, which is a problem for humans.

This, too, can be fixed in most editors.

And the counter-argument remains that you can customize tabs to whatever length you want. Set "tab-size: 4;" in CSS.

Only works if people use tabs for indentation and spaces for alignment which I've never seen anybody maintain successfully on a big project. The code the parent linked is not indentation, it's alignment so it should be formatted using spaces regardless otherwise it breaks that way. If you have to impose tab width to have proper readability then what's the point? Try hacking the linux kernel with tabs != 8 spaces and see how long you last before all the broken alignment drives you crazy.

Furthermore if your coding style imposes some kind of width restriction you also have to commit to a certain tab width anyway.

Beyond that if you really value configurability it's a bit odd to limit yourself to "I want to configure tab width". How about bracket positions, spacing between operators, variable names etc... ? All these seems are arguably more important for readability and code understanding than indentation. Ideally programming languages would be stored as abstract syntax trees that you can display however you like but we're still using dumb all ASCII text files.

In theory tabs are mildly superior to spaces, pragmatically it's spaces all day every day as far as I'm concerned.

>Only works if people use tabs for indentation and spaces for alignment which I've never seen anybody maintain successfully on a big project.

It shouldn't be left to the devs.

All languages should have something like Go's gofmt -- or even better, mandatory whitespacing/tabs rules. If you don't respect them (which the auto format tool could help you automatically do), the program shouldn't compile.

> All languages should have something like Go's gofmt -- or even better, mandatory whitespacing/tabs rules. If you don't respect them (which the auto format tool could help you automatically do), the program shouldn't compile.

It exists `clang-format`

Formatters / indent do exist.

But they're not widely accepted by most languages devs (like gofmt is by Go programmers), nor is their use enforced by the compiler (even in Go).

That's the problem, though. People do that, and then to indent 12 spaces, your guy who uses 4-space tabs will put three tabs, your girl who uses 8-space tabs will put a tab and four spaces, and your ace who uses only spaces will put twelve spaces. And after a year of sharing code doing this, your formatting will be farked and you'll spend half your time fixing other peoples' "broken" indentation.

I have no issue whatsoever with using tabs in an editor, as long as it saves them as spaces on disk.

You do not "indent 12 spaces", you have levels of indentation. If you indent code only using tabs it doesn't matter whether you set your tab width to 4, 8 or 20, it will always display properly. Feel free to change your tab width hourly, still no problem.

The only valid argument is that mixing spaces and tabs for indentation messes things up, but that argument works both ways so doesn't support either side in this never ending argument.

It is trivial both to ban tabs and to bulk convert tabs to spaces in a codebase or presubmit hook. The other direction seems impossible.

That means that if you want to avoid a mixed codebase it is far easier to get to and stay at spaces only than tabs-for-indent, spaces-for-alignment.

Still messes with alignment if you want to do things like keep your comments aligned at the right of the page.

The solution is to have the repository refuse checkins with bad indentation. Anyone who can program can follow indentation rules, many people just can’t be bothered. But they can if there is no alternative.

Tabs for indentation, spaces for alignment.

You wouldn't need to customize anything, it would look good at all tab widths and people who prefer 2 space sized indents would be able to use that in their editors.

Actually, it could be even better, we could use tabs for aligning to tables too if editors supported elastic tabstops [0]. Unfortunately, the only ones that do don't support other essential features like saving when they lose focus.

Please note that i disagree with how the example aligns function params. The space/tab there looks bad and params should be aligned with spaces using a formatting tool (which every sane language should have).

Or, y'know, scratch that, why don't we commit the AST (enhanced to include comments and other hints like blank lines) to git and let everyone use their formatting.


[0]: http://nickgravgaard.com/elastic-tabstops/

I'm pretty sure its perfectly aligned if you have the correct tab size that was used for the whole project. Which is the stupidest thing about using tabs over spaces.

It looks fine to me at even 8, so I'm not sure what you mean.

Okay, I can see the issue there. Though it's worth keeping in mind that tabs are for indentation and not alignment. Even people that use tabs would agree that is a poor use.

Ah yes tab, the only ascii character where the rendering is user configurable.

Not at all. ASCII 0x07 ("BEL") can do anything as long as it notifies the user. Traditionally it makes a beep (volume, duration, and frequency unspecified, settable on X Windows with 'xset b') but implementations vary - OSX Terminal plays the system warning sound, while my Zipit Z2 frenetically blinks an LED.

Of course you can also configure all the alphanumeric characters by changing your terminal font. I'm only half joking - it's not supposed to be important what the letters look like, only what they mean. ASCII art is not guaranteed to look good, whether or not it uses tabs.

Not to mention monospace vs proportional fonts.

Cool example on BEL.

If it's so remarkable that you were reminded why you prefer spaces over tabs, presumably since the thing you're doing doesn't happen very often, maybe you shouldn't prefer spaces over tabs.

I edit code in an editor way, way more often than look at it on GitHub. Every day when I edit code indented with spaces and my various editors don't correctly handle every edge-case for backspacing, de-denting, etc. I am reminded why I prefer tabs over spaces. It's such a common event for me that I probably wouldn't remark on it without some prompting.

Except in a few cases that code is pretty well formatted I would say.

Anyway this is game engine code and very old. I doubt you would find perfect formatting if it were spaces either.

Or just have your tabs converted to equivalent spaces.

But then anyone else who doesn't also use that same number of spaces is SOL. With tabs, each user can set the display to whatever they want.

I shouldn’t be, but I am amazed that a tabs-vs-spaces war broke out on this particular story

To be honest, I really wanted to see that one day, id Tech 5 and id Tech 6(66) be open source as a contester and competitor for UE4, CE5 and Xenko Engine.


And 958 forks !

957 of them just empty meaningless forks as Github users like to do.

I wish there was a way to distinguish between real forks and forks that were created for the sake of creating a pull request.

Or just discard all of them without any edits whatsoever.

Every once in a while some random account forks one of my repos, and when I look at the account to see if they do anything interesting I see dozens of empty forks, many of which seem to be created within a timespan of a few hours or so.

My guess is that some people use them as bookmarks... but isn't that what stars are for?

Making a fork also lets you keep a copy of a repository if the original public GitHub repo is deleted or made private. So in that sense it's more useful than just starring a repo.

Ah, I never thought about it that way. Thanks for the explanation.

My biggest annoyance with github is that everytime you accidentally click the edit button on a file it instantly creates a permanent fork under your user. I must have dozens of them that i never bothered to clean up

Doesn't sound very permanent.

And if you need a tour guide to the Quake 3 source code (among others), Fabien Sangard's blog will walk you through his favourite bits.


On the subject of id engine open source releases, was tech 4(Doom 3) the last to get the GPL treatment?

The Doom 3: BFG sources have also been released, so technically no. Doom 3: BFG is essentially a hybrid of id Tech 4 and id Tech 5.

This is old news. Please add 2012 to the title.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact