qbsp: pass entity pointer into key/value get/set functions
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
a06e60b5fa
commit
3bf10bef02
12
qbsp/brush.c
12
qbsp/brush.c
|
|
@ -296,7 +296,7 @@ FindTargetEntity(const char *szTarget)
|
|||
const char *szName;
|
||||
|
||||
for (iEntity = 0; iEntity < map.cEntities; iEntity++) {
|
||||
szName = ValueForKey(iEntity, "targetname");
|
||||
szName = ValueForKey(&map.rgEntities[iEntity], "targetname");
|
||||
if (szName && !strcasecmp(szTarget, szName))
|
||||
return iEntity;
|
||||
}
|
||||
|
|
@ -317,18 +317,18 @@ FixRotateOrigin(int iEntity, vec3_t offset)
|
|||
const char *szSearch;
|
||||
char szOrigin[20];
|
||||
|
||||
szSearch = ValueForKey(iEntity, "target");
|
||||
szSearch = ValueForKey(&map.rgEntities[iEntity], "target");
|
||||
if (!szSearch) {
|
||||
szSearch = ValueForKey(iEntity, "classname");
|
||||
szSearch = ValueForKey(&map.rgEntities[iEntity], "classname");
|
||||
Message(msgWarning, warnNoRotateTarget, szSearch);
|
||||
} else {
|
||||
iFoundEnt = FindTargetEntity(szSearch);
|
||||
if (iFoundEnt != -1)
|
||||
GetVectorForKey(iFoundEnt, "origin", offset);
|
||||
GetVectorForKey(&map.rgEntities[iFoundEnt], "origin", offset);
|
||||
}
|
||||
sprintf(szOrigin, "%d %d %d", (int)offset[0], (int)offset[1],
|
||||
(int)offset[2]);
|
||||
SetKeyValue(iEntity, "origin", szOrigin);
|
||||
SetKeyValue(&map.rgEntities[iEntity], "origin", szOrigin);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ CreateBrushFaces(void)
|
|||
max = brush_maxs[0] = brush_maxs[1] = brush_maxs[2] = -VECT_MAX;
|
||||
|
||||
// Hipnotic rotation
|
||||
szClassname = ValueForKey(map.iEntities, "classname");
|
||||
szClassname = ValueForKey(&map.rgEntities[map.iEntities], "classname");
|
||||
if (!strncmp(szClassname, "rotate_", 7))
|
||||
FixRotateOrigin(map.iEntities, offset);
|
||||
|
||||
|
|
|
|||
20
qbsp/map.c
20
qbsp/map.c
|
|
@ -116,7 +116,7 @@ ParseEpair(void)
|
|||
e->value = copystring(token);
|
||||
|
||||
if (!strcasecmp(e->key, "origin"))
|
||||
GetVectorForKey(map.iEntities, e->key,
|
||||
GetVectorForKey(&map.rgEntities[map.iEntities], e->key,
|
||||
map.rgEntities[map.iEntities].origin);
|
||||
else if (!strcasecmp(e->key, "classname")) {
|
||||
if (!strcasecmp(e->value, "info_player_start")) {
|
||||
|
|
@ -627,11 +627,11 @@ PrintEntity(int iEntity)
|
|||
|
||||
|
||||
const char *
|
||||
ValueForKey(int iEntity, const char *key)
|
||||
ValueForKey(const mapentity_t *ent, const char *key)
|
||||
{
|
||||
epair_t *ep;
|
||||
const epair_t *ep;
|
||||
|
||||
for (ep = map.rgEntities[iEntity].epairs; ep; ep = ep->next)
|
||||
for (ep = ent->epairs; ep; ep = ep->next)
|
||||
if (!strcmp(ep->key, key))
|
||||
return ep->value;
|
||||
|
||||
|
|
@ -640,31 +640,31 @@ ValueForKey(int iEntity, const char *key)
|
|||
|
||||
|
||||
void
|
||||
SetKeyValue(int iEntity, const char *key, const char *value)
|
||||
SetKeyValue(mapentity_t *ent, const char *key, const char *value)
|
||||
{
|
||||
epair_t *ep;
|
||||
|
||||
for (ep = map.rgEntities[iEntity].epairs; ep; ep = ep->next)
|
||||
for (ep = ent->epairs; ep; ep = ep->next)
|
||||
if (!strcmp(ep->key, key)) {
|
||||
free(ep->value); /* FIXME */
|
||||
ep->value = copystring(value);
|
||||
return;
|
||||
}
|
||||
ep = AllocMem(OTHER, sizeof(epair_t), true);
|
||||
ep->next = map.rgEntities[iEntity].epairs;
|
||||
map.rgEntities[iEntity].epairs = ep;
|
||||
ep->next = ent->epairs;
|
||||
ent->epairs = ep;
|
||||
ep->key = copystring(key);
|
||||
ep->value = copystring(value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GetVectorForKey(int iEntity, const char *szKey, vec3_t vec)
|
||||
GetVectorForKey(const mapentity_t *ent, const char *szKey, vec3_t vec)
|
||||
{
|
||||
const char *value;
|
||||
double v1, v2, v3;
|
||||
|
||||
value = ValueForKey(iEntity, szKey);
|
||||
value = ValueForKey(ent, szKey);
|
||||
v1 = v2 = v3 = 0;
|
||||
// scanf into doubles, then assign, so it is vec_t size independent
|
||||
sscanf(value, "%lf %lf %lf", &v1, &v2, &v3);
|
||||
|
|
|
|||
10
qbsp/qbsp.c
10
qbsp/qbsp.c
|
|
@ -55,7 +55,7 @@ ProcessEntity(mapentity_t *ent)
|
|||
|
||||
if (hullnum == 0)
|
||||
Message(msgStat, "MODEL: %s", mod);
|
||||
SetKeyValue(map.iEntities, "model", mod);
|
||||
SetKeyValue(&map.rgEntities[map.iEntities], "model", mod);
|
||||
}
|
||||
// take the brush_ts and clip off all overlapping and contained faces,
|
||||
// leaving a perfect skin of the model with no hidden faces
|
||||
|
|
@ -150,11 +150,11 @@ UpdateEntLump(void)
|
|||
map.rgEntities[iEntity].iBrushEnd)
|
||||
continue;
|
||||
sprintf(szMod, "*%i", m);
|
||||
SetKeyValue(iEntity, "model", szMod);
|
||||
SetKeyValue(&map.rgEntities[iEntity], "model", szMod);
|
||||
m++;
|
||||
|
||||
// Do extra work for rotating entities if necessary
|
||||
szClassname = ValueForKey(iEntity, "classname");
|
||||
szClassname = ValueForKey(&map.rgEntities[iEntity], "classname");
|
||||
if (!strncmp(szClassname, "rotate_", 7))
|
||||
FixRotateOrigin(iEntity, temp);
|
||||
}
|
||||
|
|
@ -247,9 +247,9 @@ ProcessFile(void)
|
|||
return;
|
||||
}
|
||||
|
||||
wadstring = ValueForKey(0, "_wad");
|
||||
wadstring = ValueForKey(pWorldEnt, "_wad");
|
||||
if (!wadstring)
|
||||
wadstring = ValueForKey(0, "wad");
|
||||
wadstring = ValueForKey(pWorldEnt, "wad");
|
||||
if (!wadstring)
|
||||
Message(msgWarning, warnNoWadKey);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -634,9 +634,9 @@ void LoadMapFile(void);
|
|||
int FindMiptex(char *name);
|
||||
|
||||
void PrintEntity(int iEntity);
|
||||
const char *ValueForKey(int iEntity, const char *key);
|
||||
void SetKeyValue(int iEntity, const char *key, const char *value);
|
||||
void GetVectorForKey(int iEntity, const char *szKey, vec3_t vec);
|
||||
const char *ValueForKey(const mapentity_t *ent, const char *key);
|
||||
void SetKeyValue(mapentity_t *ent, const char *key, const char *value);
|
||||
void GetVectorForKey(const mapentity_t *ent, const char *szKey, vec3_t vec);
|
||||
|
||||
void WriteEntitiesToString(void);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue