Understanding something in Quake 2 Source Code

This is a discussion on Understanding something in Quake 2 Source Code within the C Programming forums, part of the General Programming Boards category; Hi,
I recently downloaded the source code to Quake 2 (not including the rendering engine), and I'm trying to understand ...

Understanding something in Quake 2 Source Code

Hi,

I recently downloaded the source code to Quake 2 (not including the rendering engine), and I'm trying to understand how it works. In it, there's a source file called p_client.c, which includes a function declared thus:

Code:

void PutClientInServer (edict_t *ent)

Inside this function, a pointer is declared like this:

Code:

gclient_t *client;

Now here's what I don't get. Say if I make myself another source code file called "bot.c", and I include all the header files that were included in p_client.c:

Code:

#include "g_local.h"
#include "m_player.h"

And then, in a function in "bot.c" I try to declare a pointer like this:

Code:

gclient_t *client;

If I do this, I get an error. It says "error C2275: 'gclient_t' : illegal use of this type as an expression".

Could this be something to do with how gclient_t is declared in "game.h"? This file is included by "g_local.h" which is one of the ones I mentioned to be included earlier.

Well its seems you have this underwraps. Also glcient_t is fully defined in g_local.h, so within your preprocessor definitions, for game.h you may want to move your typedefs below your structure declaration, but that was noted in your previous forum I guess. Though this depends on how this gclient_s is to be populated as this is somewhat dynamic based on server response, kind of slick.

Well its seems you have this underwraps. Also glcient_t is fully defined in g_local.h, so within your preprocessor definitions, for game.h you may want to move your typedefs below your structure declaration, but that was noted in your previous forum I guess. Though this depends on how this gclient_s is to be populated as this is somewhat dynamic based on server response, kind of slick.

Actually that stuff I posted from game.h is part of the original code. There's more to it than I posted though, so presumably there's some other stuff in there that makes it work ok. Thanks for the reply though.