Forum

Global vars in QuakeC, not possible right?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Global vars in QuakeC, not possible right?

Postby Baker » Fri Aug 22, 2008 4:59 am

It is my understanding that global variables aren't possible in QuakeC, only global constants.

In particular, when the level changes all information is lost except player info (parm10, etc.)

Am I right about the above?

And if so, I should use extraneous cvars like scratch1, scratch2, saved1, saved2, etc.) to preserve information? (Unless I want to add extra fields to entities and I've read that uses a lot of memory because each edict used has that field?).

[add: btw, I'm not referring to storing player specific information. I just referring to general global variables not related to the player.)
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Urre » Fri Aug 22, 2008 8:40 am

Code: Select all
float myglobal;


There you go. Note the lack of assigning a value to it, which would make it a constant.
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby FrikaC » Fri Aug 22, 2008 4:15 pm

if you want persistence across level changes, a standard global won't work, all globals are reset (actually the progs are completely unloaded then reloaded) on level change. The only global variable kept across level changes is serverflags. If you want others, yes, then using cvars is not a bad solution.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby Baker » Sat Aug 23, 2008 3:36 am

FrikaC wrote:actually the progs are completely unloaded then reloaded) on level change. The only global variable kept across level changes is serverflags.


Thanks for making that clear. Had no idea the progs is actually unloaded/reloaded.
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest