Fix the tangled mess of entity connections.

What was the person who wrote valueForQKey thinking? Make the function
const-correct and bubble the changes through the code.
This commit is contained in:
Bill Currie 2010-09-28 00:29:16 +09:00
parent 3574668fe3
commit 62c73b300e
11 changed files with 31 additions and 33 deletions

View File

@ -28,11 +28,11 @@ typedef struct epair_s {
-(BOOL) modifiable; -(BOOL) modifiable;
-setModifiable:(BOOL) m; -setModifiable:(BOOL) m;
-(char *) targetname; -(const char *) targetname;
-writeToFILE:(FILE *)f region:(BOOL) reg; -writeToFILE:(FILE *)f region:(BOOL) reg;
-(char *) valueForQKey:(char *) k; -(const char *) valueForQKey:(const char *) k;
-getVector:(vec3_t)v forKey:(char *) k; -getVector:(vec3_t)v forKey:(char *) k;
-setKey:(const char *) -setKey:(const char *)

View File

@ -129,23 +129,20 @@ vec3_t bad_maxs = { 8, 8, 8 };
} }
-(char *) valueForQKey:(char *) k -(const char *) valueForQKey:(const char *) k
{ {
epair_t *e; epair_t *e;
static char ret[64];
for (e = epairs; e; e = e->next) for (e = epairs; e; e = e->next)
if (!strcmp (k, e->key)) { if (!strcmp (k, e->key))
strcpy (ret, e->value); return e->value;
return ret;
}
return ""; return "";
} }
-getVector:(vec3_t) -getVector:(vec3_t)
v forKey:(char *) k v forKey:(char *) k
{ {
char *c; const char *c;
c =[self valueForQKey:k]; c =[self valueForQKey:k];
@ -244,9 +241,9 @@ targetname
If the entity does not have a "targetname" key, a unique one is generated If the entity does not have a "targetname" key, a unique one is generated
============= =============
*/ */
-(char *) targetname -(const char *) targetname
{ {
char *t; const char *t;
int i, count; int i, count;
id ent; id ent;
int tval, maxt; int tval, maxt;
@ -291,7 +288,7 @@ int nument;
{ {
char *key; char *key;
id eclass, brush; id eclass, brush;
char *spawn; const char *spawn;
vec3_t emins, emaxs; vec3_t emins, emaxs;
vec3_t org; vec3_t org;
texturedef_t td; texturedef_t td;

View File

@ -39,7 +39,7 @@ typedef enum { esize_model, esize_fixed } esize_t;
} }
-initForSourceDirectory:(char *) path; -initForSourceDirectory:(char *) path;
-(id) classForName:(char *) name; -(id) classForName:(const char *) name;
-(void) scanDirectory; -(void) scanDirectory;
@end @end

View File

@ -260,7 +260,7 @@ id entity_classes_i;
return self; return self;
} }
-(id) classForName:(char *) name -(id) classForName:(const char *) name
{ {
int i; int i;
id o; id o;

View File

@ -224,7 +224,8 @@ readMapFile
*/ */
-readMapFile:(char *) fname -readMapFile:(char *) fname
{ {
char *dat, *cl; char *dat;
const char *wad, *cl;
id new; id new;
id ent; id ent;
int i, c; int i, c;
@ -264,13 +265,13 @@ readMapFile
[self addSelected]; [self addSelected];
// load the apropriate texture wad // load the apropriate texture wad
dat =[currentEntity valueForQKey:"wad"]; wad =[currentEntity valueForQKey:"wad"];
if (dat && dat[0]) { if (wad && wad[0]) {
if (dat[0] == '/') // remove old style fullpaths if (wad[0] == '/') // remove old style fullpaths
[currentEntity removeKeyPair:"wad"]; [currentEntity removeKeyPair:"wad"];
else { else {
if (strcmp ([texturepalette_i currentWad], dat)) if (strcmp ([texturepalette_i currentWad], wad))
[project_i setTextureWad:dat]; [project_i setTextureWad:wad];
} }
} }
// center the camera and XY view on the playerstart // center the camera and XY view on the playerstart

View File

@ -74,7 +74,7 @@ extern id project_i;
-(char *) currentProjectFile; -(char *) currentProjectFile;
-setTextureWad:(char *) wf; -setTextureWad:(const char *) wf;
-addToOutput:(char *) string; -addToOutput:(char *) string;
-clearBspOutput:sender; -clearBspOutput:sender;

View File

@ -261,7 +261,7 @@ t in:(id) obj
} }
-setTextureWad:(char *) wf -setTextureWad:(const char *) wf
{ {
int i, c; int i, c;
char *name; char *name;

View File

@ -990,9 +990,9 @@ BOOL fakebrush;
vec3_t dest, origin; vec3_t dest, origin;
vec3_t mid; vec3_t mid;
vec3_t forward, right; vec3_t forward, right;
char *targname; const char *targname;
vec3_t min, max, temp; vec3_t min, max, temp;
char *targ; const char *targ;
targ =[parent valueForQKey:"target"]; targ =[parent valueForQKey:"target"];
@ -1077,7 +1077,7 @@ XYDrawSelf
int i, j; int i, j;
winding_t *w; winding_t *w;
vec3_t mid, end, s1, s2; vec3_t mid, end, s1, s2;
char *val; const char *val;
float ang; float ang;
id worldent, currentent; id worldent, currentent;
BOOL keybrush; BOOL keybrush;
@ -1546,7 +1546,7 @@ Set the regioned flag based on if the object is containted in region_min/max
-newRegion -newRegion
{ {
int i; int i;
char *name; const char *name;
// filter away entities // filter away entities
if (parent !=[map_i objectAtIndex:0]) { if (parent !=[map_i objectAtIndex:0]) {

View File

@ -34,7 +34,7 @@ typedef struct {
extern int tex_count; extern int tex_count;
extern qtexture_t qtextures[MAX_TEXTURES]; extern qtexture_t qtextures[MAX_TEXTURES];
void TEX_InitFromWad (char *path); void TEX_InitFromWad (const char *path);
qtexture_t *TEX_ForName (char *name); qtexture_t *TEX_ForName (char *name);
@ -71,7 +71,7 @@ extern id texturepalette_i;
} }
-(char *) currentWad; -(char *) currentWad;
-initPaletteFromWadfile:(char *) wf; -initPaletteFromWadfile:(const char *) wf;
-computeTextureViewSize; -computeTextureViewSize;
-alphabetize; -alphabetize;
-getList; -getList;

View File

@ -174,7 +174,7 @@ TEX_InitFromWad
================= =================
*/ */
void void
TEX_InitFromWad (char *path) TEX_InitFromWad (const char *path)
{ {
int i; int i;
char newpath[1024]; char newpath[1024];
@ -268,7 +268,7 @@ TEX_ForName (char *name)
return currentwad; return currentwad;
} }
-initPaletteFromWadfile:(char *) wf -initPaletteFromWadfile:(const char *) wf
{ {
int i; int i;
texpal_t t; texpal_t t;

View File

@ -118,7 +118,7 @@ id things_i;
} }
-selectClass:(char *) class -selectClass:(const char *) class
{ {
id classent; id classent;
@ -141,9 +141,9 @@ id things_i;
-newCurrentEntity -newCurrentEntity
{ {
id ent, classent, cell; id ent, classent, cell;
char *classname; const char *classname;
int r, c; int r, c;
char *flagname; const char *flagname;
int flags; int flags;
ent =[map_i currentEntity]; ent =[map_i currentEntity];