mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
remove some arbitrary limits and add some of the fields from hlight
This commit is contained in:
parent
50d83a7c56
commit
cabe8d6c02
2 changed files with 47 additions and 34 deletions
|
@ -34,23 +34,35 @@
|
||||||
|
|
||||||
typedef struct epair_s {
|
typedef struct epair_s {
|
||||||
struct epair_s *next;
|
struct epair_s *next;
|
||||||
char key[MAX_KEY];
|
const char *key;
|
||||||
char value[MAX_VALUE];
|
const char *value;
|
||||||
} epair_t;
|
} epair_t;
|
||||||
|
|
||||||
typedef struct entity_s {
|
typedef struct entity_s {
|
||||||
char classname[64];
|
const char *classname;
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
float angle;
|
float angle;
|
||||||
int light;
|
int light;
|
||||||
int style;
|
// LordHavoc: added falloff (smaller fractions = bigger light area),
|
||||||
char target[32];
|
// color, and lightradius (also subbrightness to implement lightradius)
|
||||||
char targetname[32];
|
vec_t falloff;
|
||||||
|
vec_t lightradius;
|
||||||
|
vec_t subbrightness;
|
||||||
|
vec_t lightoffset;
|
||||||
|
vec3_t color;
|
||||||
|
vec3_t spotdir;
|
||||||
|
vec_t spotcone;
|
||||||
|
unsigned short visbyte, visbit; // which byte and bit to look at in
|
||||||
|
// the visdata for the leaf this light
|
||||||
|
// is in
|
||||||
|
int style;
|
||||||
|
const char *target;
|
||||||
|
const char *targetname;
|
||||||
struct epair_s *epairs;
|
struct epair_s *epairs;
|
||||||
struct entity_s *targetent;
|
struct entity_s *targetent;
|
||||||
} entity_t;
|
} entity_t;
|
||||||
|
|
||||||
extern entity_t entities[MAX_MAP_ENTITIES];
|
extern entity_t *entities;
|
||||||
extern int num_entities;
|
extern int num_entities;
|
||||||
|
|
||||||
const char *ValueForKey (entity_t *ent, const char *key);
|
const char *ValueForKey (entity_t *ent, const char *key);
|
||||||
|
|
|
@ -60,8 +60,9 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
#include "entities.h"
|
#include "entities.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
entity_t entities[MAX_MAP_ENTITIES];
|
entity_t *entities;
|
||||||
int num_entities;
|
int num_entities;
|
||||||
|
static int max_entities;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ENTITY FILE PARSING
|
ENTITY FILE PARSING
|
||||||
|
@ -74,7 +75,7 @@ char lighttargets[32][64];
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
LightStyleForTargetname (char *targetname, qboolean alloc)
|
LightStyleForTargetname (const char *targetname, qboolean alloc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -125,17 +126,17 @@ MatchTargets (void)
|
||||||
void
|
void
|
||||||
LoadEntities (void)
|
LoadEntities (void)
|
||||||
{
|
{
|
||||||
const char *data;
|
const char *data;
|
||||||
char key[64];
|
const char *key;
|
||||||
double vec[3];
|
double vec[3];
|
||||||
entity_t *entity;
|
entity_t *entity;
|
||||||
epair_t *epair;
|
epair_t *epair;
|
||||||
int i;
|
|
||||||
|
|
||||||
data = bsp->entdata;
|
data = bsp->entdata;
|
||||||
|
|
||||||
// start parsing
|
// start parsing
|
||||||
num_entities = 0;
|
max_entities = num_entities = 0;
|
||||||
|
entities = 0;
|
||||||
|
|
||||||
// go through all the entities
|
// go through all the entities
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -147,8 +148,10 @@ LoadEntities (void)
|
||||||
fprintf (stderr, "LoadEntities: found %s when expecting {",
|
fprintf (stderr, "LoadEntities: found %s when expecting {",
|
||||||
com_token);
|
com_token);
|
||||||
|
|
||||||
if (num_entities == MAX_MAP_ENTITIES)
|
if (num_entities == max_entities) {
|
||||||
fprintf (stderr, "LoadEntities: MAX_MAP_ENTITIES");
|
max_entities += 128;
|
||||||
|
entities = realloc (entities, max_entities * sizeof (entity_t));
|
||||||
|
}
|
||||||
entity = &entities[num_entities];
|
entity = &entities[num_entities];
|
||||||
num_entities++;
|
num_entities++;
|
||||||
|
|
||||||
|
@ -162,7 +165,7 @@ LoadEntities (void)
|
||||||
fprintf (stderr, "LoadEntities: EOF without closing brace");
|
fprintf (stderr, "LoadEntities: EOF without closing brace");
|
||||||
if (!strcmp (com_token, "}"))
|
if (!strcmp (com_token, "}"))
|
||||||
break;
|
break;
|
||||||
strcpy (key, com_token);
|
key = strdup (com_token);
|
||||||
|
|
||||||
// parse value
|
// parse value
|
||||||
data = COM_Parse (data);
|
data = COM_Parse (data);
|
||||||
|
@ -172,27 +175,25 @@ LoadEntities (void)
|
||||||
if (c == '}')
|
if (c == '}')
|
||||||
fprintf (stderr, "LoadEntities: closing brace without data");
|
fprintf (stderr, "LoadEntities: closing brace without data");
|
||||||
|
|
||||||
epair = malloc (sizeof (epair_t));
|
epair = calloc (1, sizeof (epair_t));
|
||||||
memset (epair, 0, sizeof (epair));
|
epair->key = key;
|
||||||
strcpy (epair->key, key);
|
epair->value = strdup (com_token);
|
||||||
strcpy (epair->value, com_token);
|
|
||||||
epair->next = entity->epairs;
|
epair->next = entity->epairs;
|
||||||
entity->epairs = epair;
|
entity->epairs = epair;
|
||||||
|
|
||||||
if (!strcmp (key, "classname"))
|
if (!strcmp (key, "classname"))
|
||||||
strcpy (entity->classname, com_token);
|
entity->classname = epair->value;
|
||||||
else if (!strcmp (key, "target"))
|
else if (!strcmp (key, "target"))
|
||||||
strcpy (entity->target, com_token);
|
entity->target = epair->value;
|
||||||
else if (!strcmp (key, "targetname"))
|
else if (!strcmp (key, "targetname"))
|
||||||
strcpy (entity->targetname, com_token);
|
entity->targetname = epair->value;
|
||||||
else if (!strcmp (key, "origin")) {
|
else if (!strcmp (key, "origin")) {
|
||||||
// scan into doubles, then assign
|
// scan into doubles, then assign
|
||||||
// which makes it vec_t size independent
|
// which makes it vec_t size independent
|
||||||
if (sscanf (com_token, "%lf %lf %lf",
|
if (sscanf (com_token, "%lf %lf %lf",
|
||||||
&vec[0], &vec[1], &vec[2]) != 3)
|
&vec[0], &vec[1], &vec[2]) != 3)
|
||||||
fprintf (stderr, "LoadEntities: not 3 values for origin");
|
fprintf (stderr, "LoadEntities: not 3 values for origin");
|
||||||
for (i = 0; i < 3; i++)
|
VectorCopy (vec, entity->origin);
|
||||||
entity->origin[i] = vec[i];
|
|
||||||
} else if (!strncmp (key, "light", 5) || !strcmp (key, "_light")) {
|
} else if (!strncmp (key, "light", 5) || !strcmp (key, "_light")) {
|
||||||
entity->light = atof(com_token);
|
entity->light = atof(com_token);
|
||||||
} else if (!strcmp (key, "style")) {
|
} else if (!strcmp (key, "style")) {
|
||||||
|
@ -245,14 +246,14 @@ SetKeyValue (entity_t *ent, const char *key, const char *value)
|
||||||
|
|
||||||
for (ep = ent->epairs; ep; ep = ep->next)
|
for (ep = ent->epairs; ep; ep = ep->next)
|
||||||
if (!strcmp (ep->key, key)) {
|
if (!strcmp (ep->key, key)) {
|
||||||
strcpy (ep->value, value);
|
ep->value = strdup (value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ep = malloc (sizeof (*ep));
|
ep = malloc (sizeof (*ep));
|
||||||
ep->next = ent->epairs;
|
ep->next = ent->epairs;
|
||||||
ent->epairs = ep;
|
ent->epairs = ep;
|
||||||
strcpy (ep->key, key);
|
ep->key = strdup (key);
|
||||||
strcpy (ep->value, value);
|
ep->value = strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
|
|
Loading…
Reference in a new issue