3

Decided to check out some code other than my own, Quake I was the choice. The first file I click on is filled with nothing but raw data and the only comments are the GPL. I am guessing it is an array containing normal vectors? Regardless of what its purpose was, what confuses me is what it is doing in a header file anorms.h. I am wondering what could be the purpose of doing this?

The other source, actual code, feels fairly complicated to me. As a novice programmer I probably just need to spend more time at it.

Leonardo
  • 1,452
  • 3
  • 15
  • 26

1 Answers1

4

Guessing by the looks, it's indeed a normal array used somewhere in the game.

In older days, pretty much every game content was hardcoded; now you can simply open a file and load the data, because the HDDs (and more often SSDs) got so much faster.

Older games were also compiled as plain C executable; in modern IDEs such as Visual Studio (or pretty much anything, really), you can easily compile arbitrary data into the .exe in form of resources.

All that being said, it's simply legacy cruft and I shouldn't be very concerned with it.


Sample usage:

struct Vec { float x,y,z };
Vec arr[] = {
    #include "anorms.h"
};
Bartek Banachewicz
  • 38,596
  • 7
  • 91
  • 135
  • Thanks for the quick answer, I am just curious how it could possibly be used. Judging by the syntax it is being used in compiling, but the only way I figure it could be read is through file i/o. I must be wrong? – Leonardo Jul 21 '13 at 09:02
  • @Leonardo there you go. – Bartek Banachewicz Jul 21 '13 at 09:04
  • Wow I knew there was something crazy like that. Thanks I learned something, mission complete! – Leonardo Jul 21 '13 at 09:05
  • 3
    As a note, I would not have named the file `.h`, because this is a fixed convention for header files with related expectations, which obviously led to the question. Something like `.inc` for include may be better here. – Secure Jul 21 '13 at 09:22