Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Global vars in QuakeC, not possible right?

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Fri Aug 22, 2008 4:59 am Post subject: Global vars in QuakeC, not possible right? |

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 |

Urre Joined: 05 Nov 2004 Posts: 1073 Location: Sweden |

Posted: Fri Aug 22, 2008 8:40 am Post subject: |

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 |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Fri Aug 22, 2008 4:15 pm Post subject: |

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 |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Sat Aug 23, 2008 3:36 am Post subject: |

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 |

Display posts from previous:

| 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