Inside3D!
     

Global vars in QuakeC, not possible right?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Fri Aug 22, 2008 4:59 am    Post subject: Global vars in QuakeC, not possible right? Reply with quote

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.)
Back to top
View user's profile Send private message
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Fri Aug 22, 2008 8:40 am    Post subject: Reply with quote

Code:
float myglobal;


There you go. Note the lack of assigning a value to it, which would make it a constant.
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Fri Aug 22, 2008 4:15 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Sat Aug 23, 2008 3:36 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group