Hacker News new | past | comments | ask | show | jobs | submit login
Quake Engine source review (fabiensanglard.net)
123 points by jenningsjason on Aug 14, 2011 | hide | past | favorite | 15 comments



Interesting thought: the three most popular games on Steam[1] (Team Fortress 2, Counter-Strike, and Counter-Strike Source) and the two most popular games on Xbox Live[2] (Modern Warfare 2 and Black Ops) are all based on Quake's engine to some extent.

[1] http://store.steampowered.com/stats/ [2] http://majornelson.com/2011/08/10/live-activity-for-week-of-...


A lot of FPS games still use a lot of that code, or later versions.


Is it usual in games to perform prediction in single-player?

Also interesting note regarding readability of bitwise operations at the end of the Networking section.

Edit: Found more about this exact substitution on Wikipedia, of all places. :)

http://en.wikipedia.org/wiki/Modulo_operation#Performance_is...


Using bitwise and to implement modulo for a power of two is common as dirt in C; I'd object to it being considered a readability issue. Arguments about specific compilers in specific modes optimizing equivalent code to it using the % operator are beside the point. Often the whole point of using a power of two range is so that you can use a bitwise and at some point, and if it ultimately ends up in a library, it's likely that the argument to the and won't be constant (defeating the optimization). There are other considerations; at some point, the data type being wrapped around with the modulo may end up in a bitfield someplace (more likely in networking or tight storage situations). Being explicit about how many bits it uses doesn't hurt in that case.


Using &, rather than % is important, if someone used signed types for index for example, then % would've generate division, while & would still keep masking it - the example uses unsigned.

Also even if it was unsigned, but % was used then people might have the idea that any value could be used, while if & was used - it's more clear (at least to me) that power of 2 - 1 mask is needed - it just brings the right message.

The only case where % would've been used in similar fashion is in a hash-table, where the number of elements in the current bucket is prime number.


It reminds me also how clojure has recur, for tail-calls, rather than rely on the user to write code that would do so, which started as limitation of what the Java VM could do, but now it turns out that this design is better - as the intention is - make sure that the code is tail-call recursive, rather than relying on programmer or compiler to do it right.

In the same spirit - & rather than % for that example.


It is not very clear from the writing but he analysed the QuakeWorld source. QuakeWorld is the internet optimised version. So this is for server and client having latency between them.


How is it not clear? The first sentence in the first section is:

  "I happily dove into Quake World source code."


To someone who does not know what QuakeWorld is, that line does not explicitely say that it is about the online multiplayer engine instead of the "Quake engine" that was powering the singleplayer game.


Yes, it does explicitly say that.

> QW is "Quake World" project, where Server and Client are meant to run on different machine (notice the client staring point is WinMain (in sys_win.c), whereas the Server stating point is main (also in sys_win.c)).


In the middle of the index, in the "Opening the zip and compiling" section. Ok, it is explicit, but it is not too visible there... If someone jumped right into another section, how would they know.


After being called out twice, at this point I would have thought you would given up. Stop skimming and start reading if you are going to comment on articles.


Come on, please stop trolling.


I think he's saying it's not clear that games perform prediction in single-player mode, which is what the other person was asking.


Very cool. More code reading posts, please! :)




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

Search: