mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Cache the worldspawn entity.
It is an error (for now) if there is not exactly one worldspawn entity.
This commit is contained in:
parent
4f0a1df3c1
commit
f1a18742f1
2 changed files with 19 additions and 8 deletions
|
@ -87,6 +87,7 @@ typedef struct entity_s {
|
|||
|
||||
extern entity_t *entities;
|
||||
extern int num_entities;
|
||||
extern entity_t *world_entity;
|
||||
|
||||
const char *ValueForKey (entity_t *ent, const char *key);
|
||||
void SetKeyValue (entity_t *ent, const char *key, const char *value);
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
entity_t *entities;
|
||||
int num_entities;
|
||||
entity_t *world_entity;
|
||||
|
||||
/*
|
||||
ENTITY FILE PARSING
|
||||
|
@ -233,14 +234,21 @@ LoadEntities (void)
|
|||
entity->style);
|
||||
|
||||
// all fields have been parsed
|
||||
if (entity->classname && !strncmp (entity->classname, "light", 5)) {
|
||||
set_properties (entity, dict);
|
||||
if (!entity->light)
|
||||
entity->light = DEFAULTLIGHTLEVEL;
|
||||
if (!entity->noise)
|
||||
entity->noise = options.noise;
|
||||
if (!entity->persistence)
|
||||
entity->persistence = 1;
|
||||
if (entity->classname) {
|
||||
if (strcmp (entity->classname, "worldspawn")) {
|
||||
if (world_entity)
|
||||
Sys_Error ("More than one worldspawn entity");
|
||||
world_entity = entity;
|
||||
}
|
||||
if (!strncmp (entity->classname, "light", 5)) {
|
||||
set_properties (entity, dict);
|
||||
if (!entity->light)
|
||||
entity->light = DEFAULTLIGHTLEVEL;
|
||||
if (!entity->noise)
|
||||
entity->noise = options.noise;
|
||||
if (!entity->persistence)
|
||||
entity->persistence = 1;
|
||||
}
|
||||
}
|
||||
PL_Free (dict);
|
||||
|
||||
|
@ -311,6 +319,8 @@ LoadEntities (void)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!world_entity)
|
||||
Sys_Error ("no worldspawn entity");
|
||||
|
||||
if (options.verbosity >= 0)
|
||||
printf ("%d entities read\n", num_entities);
|
||||
|
|
Loading…
Reference in a new issue