light: clean WorldValueForKey/SetWorldKeyValue

This commit is contained in:
Eric Wasylishen 2016-07-24 16:56:40 -06:00
parent ca507336ca
commit 0501f07673
3 changed files with 11 additions and 10 deletions

View File

@ -155,8 +155,8 @@ void GetVectorForKey(const entity_t *ent, const char *key, vec3_t vec);
std::string EntDict_StringForKey(const entdict_t &dict, const std::string key);
float EntDict_FloatForKey(const entdict_t &dict, const std::string key);
void SetWorldKeyValue(const char *key, const char *value);
const char *WorldValueForKey(const char *key);
void SetWorldKeyValue(const std::string &key, const std::string &value);
std::string WorldValueForKey(const std::string &key);
void LoadEntities(const bsp2_t *bsp);
void SetupLights(const bsp2_t *bsp);

View File

@ -79,21 +79,22 @@ SetKeyValue(entity_t *ent, const char *key, const char *value)
ent->epairs[key] = value;
}
static entity_t *WorldEnt()
static entdict_t &WorldEnt()
{
if (0 != strcmp("worldspawn", ValueForKey(entities, "classname"))) {
if (entdicts.size() == 0
|| entdicts.at(0)["classname"] != "worldspawn") {
Error("WorldEnt() failed to get worldspawn");
}
return entities;
return entdicts.at(0);
}
void SetWorldKeyValue(const char *key, const char *value)
void SetWorldKeyValue(const std::string &key, const std::string &value)
{
SetKeyValue(WorldEnt(), key, value);
WorldEnt()[key] = value;
}
const char *WorldValueForKey(const char *key)
std::string WorldValueForKey(const std::string &key)
{
return ValueForKey(WorldEnt(), key);
return EntDict_StringForKey(WorldEnt(), key);
}
static int

View File

@ -351,7 +351,7 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
if (lmscaleoverride)
SetWorldKeyValue("_lightmap_scale", lmscaleoverride);
lightmapscale = atoi(WorldValueForKey("_lightmap_scale"));
lightmapscale = atoi(WorldValueForKey("_lightmap_scale").c_str());
if (!lightmapscale)
lightmapscale = 16; /* the default */
if (lightmapscale <= 0)