Author Topic: Understanding Use of gclient_t in Q2 Source Code  (Read 1848 times)

Offline Greenwood

  • Newbie
  • *
  • Posts: 30
    • View Profile
  • Rated:
Understanding Use of gclient_t in Q2 Source Code
« on: August 05, 2009, 05:05:17 AM »
Hi,

I've been messing around with the source code for Quake 2, and I have a question about it, if anyone can help. In the file "p_client.c", inside the function "PutClientInServer", they declare a pointer like this: "gclient_t *client;".

So say I make another source code file, say "bot.c", and then include the same header files that "PutClientInServer" has. If I make a function in that, and try to declare a pointer in it like this: "gclient_t *client;", I get an error when I try to compile: "error C2275: 'gclient_t' : illegal use of this type as an expression".

Does anyone know why this happens? Ultimately, what I'm trying to do is figure out how to get a bot to have it's score displayed on the scoreboard. I'm messing around with the code to the Oakbot and the Famkebot from these sites:

http://www.quake2.com/dll/tutorials/bot/oak1.html
http://www.telefragged.com/thefatal/old/tut.htm

Thanks guys.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline quadz

  • Loquaciously Multiloquent Member
  • ****
  • Posts: 5352
    • View Profile
  • Rated:
Re: Understanding Use of gclient_t in Q2 Source Code
« Reply #1 on: August 05, 2009, 05:23:49 AM »
So say I make another source code file, say "bot.c", and then include the same header files that "PutClientInServer" has. If I make a function in that, and try to declare a pointer in it like this: "gclient_t *client;", I get an error when I try to compile: "error C2275: 'gclient_t' : illegal use of this type as an expression".

Prior to C99, C only allowed variable declarations at the beginning of a block.

So you could say:

if (foo) {
  gclient_t *client;
  bar();
  baz();
}

but not:

if (foo) {
  bar();
  gclient_t *client;  // pre-C99 compilers won't allow this declaration following the above statement
  baz();
}


More info: http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=215


Hope this helps,

quadz

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
"He knew all the tricks, dramatic irony, metaphor, bathos, puns, parody, litotes and... satire. He was vicious."

Offline Greenwood

  • Newbie
  • *
  • Posts: 30
    • View Profile
  • Rated:
Re: Understanding Use of gclient_t in Q2 Source Code
« Reply #2 on: August 05, 2009, 08:29:12 AM »
Yeah, that sorted it out. Thanks!
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

 

El Box de Shoutamente

Last 10 Shouts:

 

|iR|Focalor

November 06, 2024, 03:28:50 AM
 

RailWolf

November 05, 2024, 03:13:44 PM
Nice :)

Tom Servo

November 04, 2024, 05:05:24 PM
The Joe Rogan Experience episode 223 that dropped a couple hours ago with Musk, they're talking about Quake lol.
 

Costigan_Q2

November 04, 2024, 03:37:55 PM
Stay cozy folks.

Everything is gonna be fine.
 

|iR|Focalor

October 31, 2024, 08:56:37 PM
 

Costigan_Q2

October 17, 2024, 06:31:53 PM
Not activated your account yet?

Activate it now! join in the fun!

Tom Servo

October 11, 2024, 03:35:36 PM
HAHAHAHAHAHA
 

|iR|Focalor

October 10, 2024, 12:19:41 PM
I don't worship the devil. Jesus is Lord, friend. He died for your sins. He will forgive you if you just ask.
 

rikwad

October 09, 2024, 07:57:21 PM
Sorry, I couldn't resist my inner asshole.
 

Costigan_Q2

October 09, 2024, 01:35:05 PM
Et tu rikwad?

Please don't feed the degenerate lies of a sexually-perverted devil-worshipping barking dog like Focalor.

Show 50 latest
Welcome, Guest. Please login or register.
November 10, 2024, 09:41:17 AM

Login with username, password and session length