Finger info for marco@icculus.org...


FTEQC Tricks: __fullspawndata

__fullspawndata is what we call an undocumented global.
They're not documented by default in the fteextensions.qc file that FTEQW
outputs, because you aren't really meant to be confronted with it.

As you know, in QuakeC all map entity "keys" are mapped into fields that have to
be declared in the progs.dat source.

However, when using classes they don't map to member attributes automatically.
Also, you might not want to create thousands of global ent-fields in the code.
You might also want to create an entity like Half-Life's multi_manager, where
you don't know what the entity keys are called in advance.

__fullspawndata is a global that is set to be the entire ent lump when the
respective entity's spawn function is called.
That way you can tokenize it and handle the keys, interpret them yourself:

for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
switch (argv(i)) {
case "health":
m_flHealth = stof(argv(i + 1));
break;
case "amplitude":
m_flAmplitude = stof(argv(i + 1));
break;
default:
break;
}
}

But before this will work, just put this into your defs.qc/h or whatever:

string __fullspawndata;

I've been using it ever since I started FreeCS back in 2016 because I had to
support multi_manager entities. I know not a lot of people might know about it
as it's not documented publically. Happy hacking

-- Marco

When this .plan was written: 2019-01-25 05:38:02
.plan archives for this user are here (RSS here).
Powered by IcculusFinger v2.1.27
Stick it in the camel and go.