diff --git a/include/light/entities.hh b/include/light/entities.hh index a592cacc..4da6389c 100644 --- a/include/light/entities.hh +++ b/include/light/entities.hh @@ -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); diff --git a/light/entities.cc b/light/entities.cc index 038d5636..b674352f 100644 --- a/light/entities.cc +++ b/light/entities.cc @@ -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 diff --git a/light/light.cc b/light/light.cc index 4b6be2ba..7eff89f3 100644 --- a/light/light.cc +++ b/light/light.cc @@ -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)