Author Topic: Understanding Use of gclient_t in Q2 Source Code  (Read 1971 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

July 04, 2025, 06:33:05 AM
 

RyU

June 29, 2025, 06:27:46 PM
Q2 must never die  :)
 

|iR|Focalor

May 26, 2025, 01:17:30 PM
 

-Unh0ly-

May 22, 2025, 05:45:28 PM
 

Yotematoi

May 17, 2025, 08:33:15 AM
Yo desde el año 2007 me enfermé de Q2, es incurable  
Morir y revivir es costumbre, lástima q el QT estaba bueno
 

ImperiusDamian

May 12, 2025, 01:45:35 AM
Quake II is not 27 years old. I refuse to accept THAT much time has gone by.
 

|iR|Focalor

May 11, 2025, 02:33:39 PM
 

-Unh0ly-

May 03, 2025, 08:02:46 AM
198.179.6.200:30634
 

Yotematoi

May 02, 2025, 10:27:47 AM
Note for Player-4109 "Remember, the Guinness Book of Records does not include cowards who shot at someone by treachery." :D

Show 50 latest
Welcome, Guest. Please login or register.
July 06, 2025, 11:05:18 PM

Login with username, password and session length