.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
cvar() issue (Groups : qc : Forum : hard_code() : cvar() issue) Locked
Thread Options
numbersix
numbersix quake-c coder++
Dec 4 2016 Anchor

Lately I saw this happening:

error notation

What is going on here?

Well, I've changed the base operation of my massive weapon expansion code, x_ents (extra entities)
and weapon system 6. System 6 adds a massive variety of weapons to any mod I work on.

The issue I ran into with the previous mark II code base is globals. All the extra entites add
a ton (or just a thousand+) of data. That data creates a lot of new globals. And code.

Every spawn function was adding a half dozen to a dozen new globals. There are 220 some items.
Plus new monsters.

The new method reads the data from cfg scripts via cvar_string().
This uses several inventive code loops and a new touch function set.

And it seems to work very well. This also fits into some of the crazier specs for the Chaos mod.
Insanity like shotguns firing grenades, rocket launchers shooting health boxes. etc.

On top of that it cleans up the extension code sections considerably.
I had whole qc files dedicated to random spawns, entity management, etc. that are gone.

Some teething issues do arise. Like this cvar() error.

item_reload is one of the new loops - when called it re-loads all entity data for designated entities.
cvar_fields is the read loop - it has a new method of parsing cvar data set via cfg files.

This crash shows what happens when you call cvar with "" - a null string.

In this case I fixed my data set.

Another possibility would be wrapping Moddb.com cvar:

float(string s) _cvar = #45;						// return cvar.value

float(string s) cvar =
{
// note - this returns a null value as well
	if (s == string_null) return;	// could add a developer bprint for notification
	_cvar(s);
};

I might have to put this fix in the maphack engine mod with the mentioned developer warning print.

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.