Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quake2 Engine - Code Format

Started by quantum_red Aug 9, 2002 at 12:03 PM 13 replies 350+ views
Original Post
quantum_red
quantum_red
Is the Quake2 engine written in C as described in ''The C Programming Language'' by Kernighan and Ritchie or are there elements of C++ mixed in there? I have msvc6 and I''m trying to understand what language text books to use for reference.
shurcool
shurcool
yes, it seems that way (http://www.gamedev.net/community/forums/topic.asp?topic_id=108327).

---
shurcool
wwdev
quantum_red
quantum_red
That thread discusses doom3 and unreal.
barazor
barazor
yup, q2 is written completely in C with some ASM

check it out, its on the idsoftware ftp
Dean Harding
Dean Harding
Why does it matter what Quake 2 uses? Most people will tell you that the coding style of JC is rubbish anyway... I don''t know, I''ve never looked myself.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

zealouselixir
zealouselixir
quote:
Original post by quantum_red
Is the Quake2 engine written in C as described in ''The C Programming Language'' by Kernighan and Ritchie or are there elements of C++ mixed in there?


What do you mean by ''elements of C++''?

[twitter]warrenm[/twitter]
outRider
outRider
quote:

Why does it matter what Quake 2 uses? Most people will tell you that the coding style of JC is rubbish anyway...



And yet he seems to be getting stuff done... and driving a Ferrari.

As for the 'elements of C++', there are none, it's straight C, so pure and clean you could baptize your children with it.

------------
- outRider -

[edited by - outRider on August 9, 2002 11:23:02 PM]
shurcool
shurcool
quote:
Original post by quantum_red
That thread discusses doom3 and unreal.


yeah, but it also notes that doom3 is one of the first of JC''s projects that has any C++ code in it. that means that q2 does use C only. well, according to that thread, anyway.

---
shurcool
wwdev
quantum_red
quantum_red
quote:
What do you mean by 'elements of C++'?

I was a little unsure about how msvc determined whether code was C or C++ and I thought they might be mixed together. Now I realize the file extension .c or .cpp designates what 'format' the code is in.

And now that I realize it's straight C, I can keep the Kernighan and Ritchie book handy as I go through the code. Are there any other reference books I should look at for C? There are so many for C++ but the K+R is the only popular one I've found for C.

[edited by - quantum_red on August 9, 2002 11:27:30 PM]
zealouselixir
zealouselixir
I''m almost certain that file with a .c extension will be compiled as C++ files in VC. I''m still wondering what you consider these ''elements of C++'' that might be included in C code. Quake II was indeed written completely in C. It also somewhat emulated object-oriented design through the use of structs, but there is still no inheritance or polymorphism. This is because JC, until recently, believed that the overhead was unacceptable proportional to the gains.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
[twitter]warrenm[/twitter]
Dean Harding
Dean Harding
quote:
Original post by ZealousElixir
I''m almost certain that file with a .c extension will be compiled as C++ files in VC.


Nah, a .c file is compiled as straight C. I think there''s a compiler switch to force it one or the other as well, but I can''t remember what it is.

If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Xanth
Xanth
Well you could always try addign a cout << "" statment to your C sourcefile, and compiling it in MSVC.
"I thought Genius lived in bottles..." - Patrick Star
zealouselixir
zealouselixir
Dean''s right. My bad. The way it tells the difference is via the "__cplusplus" define, and I''m assuming it''s also the reason for "extern "C"" or whatever that is...

Later,
ZE.
[twitter]warrenm[/twitter]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.