Remove the leading _ from entity fields for properties.

Dealing with the _ in the properties code is a bit messy, and having to use
it in the properties list file is a pain.
This commit is contained in:
Bill Currie 2012-12-26 15:28:14 +09:00
parent 5fbe50a5e2
commit 9e6477fdf0
3 changed files with 25 additions and 23 deletions

View file

@ -126,19 +126,19 @@ int parse_noise (const char *arg);
will be ignored. will be ignored.
Supported properties: Supported properties:
\arg \c light/_light see \ref parse_light \arg \c light see \ref parse_light
\arg \c style light style: 0-254 \arg \c style light style: 0-254
\arg \c angle spotlight con angle in degress. defaults to 20 \arg \c angle spotlight con angle in degress. defaults to 20
\arg \c wait light "falloff". defaults to 1.0 \arg \c wait light "falloff". defaults to 1.0
\arg \c _lightradius size of light. interacts with falloff for \arg \c lightradius size of light. interacts with falloff for
distance clipping (?). defaults to 0 distance clipping (?). defaults to 0
\arg \c color/_color see \ref parse_color \arg \c color see \ref parse_color
\arg \c _attenuation see \ref parse_attenuation \arg \c attenuation see \ref parse_attenuation
\arg \c _radius the range of the light. \arg \c radius the range of the light.
\arg \c _noise noise intensity (?) \arg \c noise noise intensity (?)
\arg \c _noisetype see \ref parse_noise \arg \c noisetype see \ref parse_noise
\arg \c _persistence noise parameter \arg \c persistence noise parameter
\arg \c _resolution noise parameter \arg \c resolution noise parameter
\param ent The entity for which to set the lighting values. \param ent The entity for which to set the lighting values.
\param dict A dictionary property list item representing the fields \param dict A dictionary property list item representing the fields

View file

@ -226,8 +226,6 @@ LoadEntities (void)
epair->next = entity->epairs; epair->next = entity->epairs;
entity->epairs = epair; entity->epairs = epair;
PL_D_AddObject (dict, key, PL_NewString (script->token->str));
if (!strcmp (key, "classname")) if (!strcmp (key, "classname"))
entity->classname = epair->value; entity->classname = epair->value;
else if (!strcmp (key, "target")) else if (!strcmp (key, "target"))
@ -243,6 +241,12 @@ LoadEntities (void)
else else
VectorCopy (vec, entity->origin); VectorCopy (vec, entity->origin);
} }
// the leading _ is so the engine doesn't search for the field,
// but it's not wanted in the properties dictionary
if (*key == '_')
key++;
PL_D_AddObject (dict, key, PL_NewString (script->token->str));
} }
if (options.verbosity > 1 && entity->targetname) if (options.verbosity > 1 && entity->targetname)

View file

@ -173,7 +173,7 @@ set_properties (entity_t *ent, plitem_t *dict)
if (properties) { if (properties) {
prop = PL_ObjectForKey (properties, ent->classname); prop = PL_ObjectForKey (properties, ent->classname);
if ((p = get_item ("_light_name", dict, 0)) if ((p = get_item ("light_name", dict, 0))
&& (str = PL_String (p))) && (str = PL_String (p)))
prop = PL_ObjectForKey (properties, str); prop = PL_ObjectForKey (properties, str);
if (!prop) if (!prop)
@ -183,8 +183,7 @@ set_properties (entity_t *ent, plitem_t *dict)
if (!prop) if (!prop)
prop = PL_ObjectForKey (properties, "default"); prop = PL_ObjectForKey (properties, "default");
} }
if ((p = get_item ("light", dict, prop)) if ((p = get_item ("light", dict, prop))) {
|| (p = get_item ("_light", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->light = parse_light (str, ent->color); ent->light = parse_light (str, ent->color);
} }
@ -208,18 +207,17 @@ set_properties (entity_t *ent, plitem_t *dict)
ent->falloff *= ent->falloff; // presquared ent->falloff *= ent->falloff; // presquared
} }
} }
if ((p = get_item ("_lightradius", dict, prop))) { if ((p = get_item ("lightradius", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->lightradius = parse_float (str); ent->lightradius = parse_float (str);
} }
} }
if ((p = get_item ("color", dict, prop)) if ((p = get_item ("color", dict, prop))) {
|| (p = get_item ("_color", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
parse_color (str, ent->color2); parse_color (str, ent->color2);
} }
} }
if ((p = get_item ("_attenuation", dict, prop))) { if ((p = get_item ("attenuation", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->attenuation = parse_attenuation (str); ent->attenuation = parse_attenuation (str);
if (ent->attenuation == -1) { if (ent->attenuation == -1) {
@ -229,27 +227,27 @@ set_properties (entity_t *ent, plitem_t *dict)
} }
} }
} }
if ((p = get_item ("_radius", dict, prop))) { if ((p = get_item ("radius", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->radius = parse_float (str); ent->radius = parse_float (str);
} }
} }
if ((p = get_item ("_noise", dict, prop))) { if ((p = get_item ("noise", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->noise = parse_float (str); ent->noise = parse_float (str);
} }
} }
if ((p = get_item ("_noisetype", dict, prop))) { if ((p = get_item ("noisetype", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->noisetype = parse_noise (str); ent->noisetype = parse_noise (str);
} }
} }
if ((p = get_item ("_persistence", dict, prop))) { if ((p = get_item ("persistence", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->persistence = parse_float (str); ent->persistence = parse_float (str);
} }
} }
if ((p = get_item ("_resolution", dict, prop))) { if ((p = get_item ("resolution", dict, prop))) {
if ((str = PL_String (p))) { if ((str = PL_String (p))) {
ent->resolution = parse_float (str); ent->resolution = parse_float (str);
} }