2010-09-09 11:46:38 +00:00
|
|
|
#include "QF/dstring.h"
|
|
|
|
#include "QF/script.h"
|
|
|
|
#include "QF/sys.h"
|
2010-09-28 12:40:11 +00:00
|
|
|
#include "QF/va.h"
|
2010-09-09 11:46:38 +00:00
|
|
|
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "EntityClass.h"
|
|
|
|
#include "TexturePalette.h"
|
|
|
|
#include "SetBrush.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "CameraView.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 07:25:25 +00:00
|
|
|
#define THING Entity
|
|
|
|
#include "THING+NSArray.m"
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
@implementation Entity
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t bad_mins = { -8, -8, -8 };
|
|
|
|
vec3_t bad_maxs = { 8, 8, 8 };
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-createFixedBrush:(vec3_t) org
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t emins, emaxs;
|
|
|
|
float *v, *v2, *color;
|
|
|
|
id new;
|
|
|
|
texturedef_t td;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// get class
|
2010-09-11 10:03:41 +00:00
|
|
|
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
2010-09-09 11:46:38 +00:00
|
|
|
if (new) {
|
2010-09-11 10:03:41 +00:00
|
|
|
v =[new mins];
|
|
|
|
v2 =[new maxs];
|
2010-09-09 11:46:38 +00:00
|
|
|
} else {
|
2003-03-18 19:48:24 +00:00
|
|
|
v = bad_mins;
|
|
|
|
v2 = bad_maxs;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
color =[new drawColor];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
modifiable = NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
memset (&td, 0, sizeof (td));
|
|
|
|
strcpy (td.texture, "entity");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
VectorAdd (org, v, emins);
|
|
|
|
VectorAdd (org, v2, emaxs);
|
2010-09-11 10:03:41 +00:00
|
|
|
new =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
|
|
|
[new setEntityColor:color];
|
|
|
|
|
|
|
|
[self addObject:new];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
-initClass:(const char *) classname
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id new;
|
|
|
|
esize_t esize;
|
|
|
|
vec3_t min, max;
|
2010-09-28 12:40:11 +00:00
|
|
|
int org[3];
|
2010-09-11 10:03:41 +00:00
|
|
|
float *v;
|
|
|
|
|
2010-09-12 07:25:25 +00:00
|
|
|
self = [super init];
|
|
|
|
array = [[NSMutableArray alloc] init];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
modifiable = YES;
|
|
|
|
|
|
|
|
[self setKey: "classname" toValue:classname];
|
|
|
|
|
|
|
|
// get class
|
2010-09-11 10:03:41 +00:00
|
|
|
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!new)
|
|
|
|
esize = esize_model;
|
|
|
|
else
|
2010-09-11 10:03:41 +00:00
|
|
|
esize =[new esize];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// create a brush if needed
|
2010-09-11 10:03:41 +00:00
|
|
|
if (esize == esize_fixed) {
|
|
|
|
v =[new mins];
|
|
|
|
[[map_i selectedBrush] getMins: min maxs:max];
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (min, v, min);
|
2010-09-28 12:40:11 +00:00
|
|
|
VectorCopy (min, org); // convert to integer
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-28 12:40:11 +00:00
|
|
|
[self setKey:"origin" toValue:va ("%i %i %i", org[0], org[1], org[2])];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[self createFixedBrush:min];
|
|
|
|
} else
|
2003-03-18 19:48:24 +00:00
|
|
|
modifiable = YES;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(void) dealloc
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e, *n;
|
|
|
|
|
|
|
|
for (e = epairs; e; e = n) {
|
2003-03-18 19:48:24 +00:00
|
|
|
n = e->next;
|
2010-09-09 11:46:38 +00:00
|
|
|
free (e->key);
|
|
|
|
free (e->value);
|
2003-03-18 19:48:24 +00:00
|
|
|
free (e);
|
|
|
|
}
|
2010-09-12 10:57:34 +00:00
|
|
|
[array release];
|
2010-09-09 11:46:38 +00:00
|
|
|
[super dealloc];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) modifiable
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return modifiable;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setModifiable:(BOOL) m
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
modifiable = m;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(void) removeObject:o
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[super removeObject:o];
|
2010-09-09 11:46:38 +00:00
|
|
|
if ([self count])
|
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
// the entity is empty, so remove the entire thing
|
2010-09-11 10:03:41 +00:00
|
|
|
if (self ==[map_i objectAtIndex:0])
|
|
|
|
return; // never remove the world
|
|
|
|
|
|
|
|
[map_i removeObject:self];
|
2010-09-09 11:46:38 +00:00
|
|
|
[self release];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-27 15:29:16 +00:00
|
|
|
-(const char *) valueForQKey:(const char *) k
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e;
|
|
|
|
|
|
|
|
for (e = epairs; e; e = e->next)
|
2010-09-27 15:29:16 +00:00
|
|
|
if (!strcmp (k, e->key))
|
|
|
|
return e->value;
|
2003-03-18 19:48:24 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
-getVector:(vec3_t) v forKey:(const char *) k
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-27 15:29:16 +00:00
|
|
|
const char *c;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
c =[self valueForQKey:k];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
v[0] = v[1] = v[2] = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-print
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e;
|
|
|
|
|
|
|
|
for (e = epairs; e; e = e->next)
|
|
|
|
printf ("%20s : %20s\n", e->key, e->value);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setKey:(const char *)
|
|
|
|
k toValue:(const char *) v
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
while (*k && *k <= ' ')
|
|
|
|
k++;
|
|
|
|
if (!*k)
|
2010-09-11 10:03:41 +00:00
|
|
|
return self; // don't set NULL values
|
|
|
|
|
|
|
|
for (e = epairs; e; e = e->next) {
|
2010-09-09 11:46:38 +00:00
|
|
|
if (!strcmp (k, e->key)) {
|
|
|
|
free (e->value);
|
|
|
|
e->value = strdup (v);
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-09 11:46:38 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
e = malloc (sizeof (epair_t));
|
2010-09-09 11:46:38 +00:00
|
|
|
|
|
|
|
e->key = strdup (k);
|
|
|
|
e->value = strdup (v);
|
2003-03-18 19:48:24 +00:00
|
|
|
e->next = epairs;
|
|
|
|
epairs = e;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(int) numPairs
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
epair_t *e;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
for (e = epairs; e; e = e->next)
|
2003-03-18 19:48:24 +00:00
|
|
|
i++;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(epair_t *) epairs
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return epairs;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-removeKeyPair:(char *) key
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e, *e2;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!epairs)
|
|
|
|
return self;
|
|
|
|
e = epairs;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (e->key, key)) {
|
2003-03-18 19:48:24 +00:00
|
|
|
epairs = e->next;
|
|
|
|
free (e);
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (; e; e = e->next) {
|
|
|
|
if (e->next && !strcmp (e->next->key, key)) {
|
2003-03-18 19:48:24 +00:00
|
|
|
e2 = e->next;
|
|
|
|
e->next = e2->next;
|
|
|
|
free (e2);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
printf ("WARNING: removeKeyPair: %s not found\n", key);
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
targetname
|
|
|
|
|
|
|
|
If the entity does not have a "targetname" key, a unique one is generated
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-27 15:29:16 +00:00
|
|
|
-(const char *) targetname
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-27 15:29:16 +00:00
|
|
|
const char *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, count;
|
|
|
|
id ent;
|
|
|
|
int tval, maxt;
|
|
|
|
|
|
|
|
t =[self valueForQKey:"targetname"];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (t && t[0])
|
|
|
|
return t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// make a unique name of the form t<number>
|
2010-09-11 10:03:41 +00:00
|
|
|
count =[map_i count];
|
2003-03-18 19:48:24 +00:00
|
|
|
maxt = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
ent =[map_i objectAtIndex:i];
|
|
|
|
t =[ent valueForQKey:"targetname"];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!t || t[0] != 't')
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
tval = atoi (t + 1);
|
2003-03-18 19:48:24 +00:00
|
|
|
if (tval > maxt)
|
|
|
|
maxt = tval;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 12:40:11 +00:00
|
|
|
[self setKey: "targetname" toValue:va ("t%i", maxt + 1)];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 12:40:11 +00:00
|
|
|
return [self valueForQKey:"targetname"];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
FILE METHODS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int nument;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-initFromScript:(script_t *) script
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char *key;
|
|
|
|
id eclass, brush;
|
2010-09-27 15:29:16 +00:00
|
|
|
const char *spawn;
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t emins, emaxs;
|
|
|
|
vec3_t org;
|
|
|
|
texturedef_t td;
|
|
|
|
esize_t esize;
|
|
|
|
int i, c;
|
|
|
|
float *color;
|
|
|
|
|
2010-09-12 10:57:34 +00:00
|
|
|
self = [super init];
|
|
|
|
array = [[NSMutableArray alloc] init];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!Script_GetToken (script, true)) {
|
2010-09-09 11:46:38 +00:00
|
|
|
[self dealloc];
|
2003-03-18 19:48:24 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (strcmp (Script_Token (script), "{"))
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("initFromFileP: { not found");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
do {
|
|
|
|
if (!Script_GetToken (script, true))
|
2003-03-18 19:48:24 +00:00
|
|
|
break;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (Script_Token (script), "}"))
|
2003-03-18 19:48:24 +00:00
|
|
|
break;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (Script_Token (script), "{")) {
|
2010-09-09 11:46:38 +00:00
|
|
|
// read a brush
|
2010-09-11 10:03:41 +00:00
|
|
|
brush =[[SetBrush alloc] initFromScript: script owner:self];
|
|
|
|
[self addObject:brush];
|
2010-09-09 11:46:38 +00:00
|
|
|
} else {
|
|
|
|
// read a key / value pair
|
|
|
|
key = strdup (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
[self setKey: key toValue:Script_Token (script)];
|
|
|
|
free (key);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
} while (1);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
nument++;
|
|
|
|
|
|
|
|
// get class
|
2010-09-11 10:03:41 +00:00
|
|
|
spawn =[self valueForQKey:"classname"];
|
|
|
|
eclass =[entity_classes_i classForName:spawn];
|
|
|
|
|
|
|
|
esize =[eclass esize];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self getVector: org forKey:"origin"];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([self count] && esize != esize_model) {
|
|
|
|
printf ("WARNING:Entity with brushes and wrong model type\n");
|
2010-09-09 11:46:38 +00:00
|
|
|
[self removeAllObjects];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (![self count] && esize == esize_model) {
|
2010-09-12 10:57:34 +00:00
|
|
|
printf ("WARNING:Entity with no brushes and esize_model: %s\n", [self valueForQKey:"classname"]);
|
2010-09-11 10:03:41 +00:00
|
|
|
[texturepalette_i getTextureDef:&td];
|
|
|
|
for (i = 0; i < 3; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
emins[i] = org[i] - 8;
|
|
|
|
emaxs[i] = org[i] + 8;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
brush =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
|
|
|
[self addObject:brush];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
// create a brush if needed
|
|
|
|
if (esize == esize_fixed)
|
2010-09-11 10:03:41 +00:00
|
|
|
[self createFixedBrush:org];
|
2003-03-18 19:48:24 +00:00
|
|
|
else
|
|
|
|
modifiable = YES;
|
|
|
|
|
|
|
|
// set all the brush colors
|
2010-09-11 10:03:41 +00:00
|
|
|
color =[eclass drawColor];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
c =[self count];
|
|
|
|
for (i = 0; i < c; i++) {
|
|
|
|
brush =[self objectAtIndex:i];
|
|
|
|
[brush setEntityColor:color];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-writeToFILE:(FILE *)
|
|
|
|
f region:(BOOL) reg;
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
epair_t *e;
|
2010-09-27 18:01:07 +00:00
|
|
|
int ang;
|
|
|
|
unsigned int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
id new;
|
2010-09-28 12:40:11 +00:00
|
|
|
vec3_t mins, maxs;
|
|
|
|
int org[3];
|
2010-09-09 11:46:38 +00:00
|
|
|
const vec_t *v;
|
2010-09-28 12:40:11 +00:00
|
|
|
char *oldang = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (reg) {
|
|
|
|
if (!strcmp ([self valueForQKey:"classname"], "info_player_start")) {
|
2010-09-28 12:40:11 +00:00
|
|
|
// move the playerstart temporarily to the camera position
|
|
|
|
oldang = strdup ([self valueForQKey:"angle"]);
|
|
|
|
ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
|
|
|
|
[self setKey: "angle" toValue: va ("%i", ang)];
|
|
|
|
} else if (self != [map_i objectAtIndex:0]
|
|
|
|
&& [[self objectAtIndex:0] regioned]) {
|
2010-09-11 10:03:41 +00:00
|
|
|
return self; // skip the entire entity definition
|
2010-09-28 12:40:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
fprintf (f, "{\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// set an origin epair
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!modifiable) {
|
|
|
|
[[self objectAtIndex: 0] getMins: mins maxs:maxs];
|
2010-09-28 12:40:11 +00:00
|
|
|
if (oldang) {
|
2010-09-11 10:03:41 +00:00
|
|
|
[cameraview_i getOrigin:mins];
|
2003-03-18 19:48:24 +00:00
|
|
|
mins[0] -= 16;
|
|
|
|
mins[1] -= 16;
|
|
|
|
mins[2] -= 48;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
new =[entity_classes_i classForName:
|
|
|
|
[self valueForQKey:"classname"]];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (new)
|
2010-09-11 10:03:41 +00:00
|
|
|
v =[new mins];
|
2003-03-18 19:48:24 +00:00
|
|
|
else
|
|
|
|
v = vec3_origin;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (mins, v, org);
|
2010-09-28 12:40:11 +00:00
|
|
|
[self setKey: "origin"
|
|
|
|
toValue: va ("%i %i %i", org[0], org[1], org[2])];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (e = epairs; e; e = e->next)
|
|
|
|
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// fixed size entities don't save out brushes
|
2010-09-11 10:03:41 +00:00
|
|
|
if (modifiable) {
|
|
|
|
for (i = 0; i <[self count]; i++)
|
|
|
|
[[self objectAtIndex: i] writeToFILE: f region:reg];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
fprintf (f, "}\n");
|
|
|
|
|
2010-09-28 12:40:11 +00:00
|
|
|
if (oldang) {
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setKey: "angle" toValue:oldang];
|
2010-09-28 12:40:11 +00:00
|
|
|
free (oldang);
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
INTERACTION
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
@end
|