From 62c73b300e26ebab0fbddba728bdae3e2e24c6ab Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 28 Sep 2010 00:29:16 +0900 Subject: [PATCH] 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. --- tools/Forge/Bundles/MapEdit/Entity.h | 4 ++-- tools/Forge/Bundles/MapEdit/Entity.m | 17 +++++++---------- tools/Forge/Bundles/MapEdit/EntityClass.h | 2 +- tools/Forge/Bundles/MapEdit/EntityClass.m | 2 +- tools/Forge/Bundles/MapEdit/Map.m | 13 +++++++------ tools/Forge/Bundles/MapEdit/Project.h | 2 +- tools/Forge/Bundles/MapEdit/Project.m | 2 +- tools/Forge/Bundles/MapEdit/SetBrush.m | 8 ++++---- tools/Forge/Bundles/MapEdit/TexturePalette.h | 4 ++-- tools/Forge/Bundles/MapEdit/TexturePalette.m | 4 ++-- tools/Forge/Bundles/MapEdit/Things.m | 6 +++--- 11 files changed, 31 insertions(+), 33 deletions(-) diff --git a/tools/Forge/Bundles/MapEdit/Entity.h b/tools/Forge/Bundles/MapEdit/Entity.h index 27390e30a..e7655d24f 100644 --- a/tools/Forge/Bundles/MapEdit/Entity.h +++ b/tools/Forge/Bundles/MapEdit/Entity.h @@ -28,11 +28,11 @@ typedef struct epair_s { -(BOOL) modifiable; -setModifiable:(BOOL) m; --(char *) targetname; +-(const char *) targetname; -writeToFILE:(FILE *)f region:(BOOL) reg; --(char *) valueForQKey:(char *) k; +-(const char *) valueForQKey:(const char *) k; -getVector:(vec3_t)v forKey:(char *) k; -setKey:(const char *) diff --git a/tools/Forge/Bundles/MapEdit/Entity.m b/tools/Forge/Bundles/MapEdit/Entity.m index d82986359..3f77e3c22 100644 --- a/tools/Forge/Bundles/MapEdit/Entity.m +++ b/tools/Forge/Bundles/MapEdit/Entity.m @@ -129,23 +129,20 @@ vec3_t bad_maxs = { 8, 8, 8 }; } --(char *) valueForQKey:(char *) k +-(const char *) valueForQKey:(const char *) k { epair_t *e; - static char ret[64]; for (e = epairs; e; e = e->next) - if (!strcmp (k, e->key)) { - strcpy (ret, e->value); - return ret; - } + if (!strcmp (k, e->key)) + return e->value; return ""; } -getVector:(vec3_t) v forKey:(char *) k { - char *c; + const char *c; c =[self valueForQKey:k]; @@ -244,9 +241,9 @@ targetname 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; id ent; int tval, maxt; @@ -291,7 +288,7 @@ int nument; { char *key; id eclass, brush; - char *spawn; + const char *spawn; vec3_t emins, emaxs; vec3_t org; texturedef_t td; diff --git a/tools/Forge/Bundles/MapEdit/EntityClass.h b/tools/Forge/Bundles/MapEdit/EntityClass.h index 5a1a3e0d7..fde6f68b2 100644 --- a/tools/Forge/Bundles/MapEdit/EntityClass.h +++ b/tools/Forge/Bundles/MapEdit/EntityClass.h @@ -39,7 +39,7 @@ typedef enum { esize_model, esize_fixed } esize_t; } -initForSourceDirectory:(char *) path; --(id) classForName:(char *) name; +-(id) classForName:(const char *) name; -(void) scanDirectory; @end diff --git a/tools/Forge/Bundles/MapEdit/EntityClass.m b/tools/Forge/Bundles/MapEdit/EntityClass.m index 2db3d00f8..05a2c6b8c 100644 --- a/tools/Forge/Bundles/MapEdit/EntityClass.m +++ b/tools/Forge/Bundles/MapEdit/EntityClass.m @@ -260,7 +260,7 @@ id entity_classes_i; return self; } --(id) classForName:(char *) name +-(id) classForName:(const char *) name { int i; id o; diff --git a/tools/Forge/Bundles/MapEdit/Map.m b/tools/Forge/Bundles/MapEdit/Map.m index 46ad7341e..17ca59e73 100644 --- a/tools/Forge/Bundles/MapEdit/Map.m +++ b/tools/Forge/Bundles/MapEdit/Map.m @@ -224,7 +224,8 @@ readMapFile */ -readMapFile:(char *) fname { - char *dat, *cl; + char *dat; + const char *wad, *cl; id new; id ent; int i, c; @@ -264,13 +265,13 @@ readMapFile [self addSelected]; // load the apropriate texture wad - dat =[currentEntity valueForQKey:"wad"]; - if (dat && dat[0]) { - if (dat[0] == '/') // remove old style fullpaths + wad =[currentEntity valueForQKey:"wad"]; + if (wad && wad[0]) { + if (wad[0] == '/') // remove old style fullpaths [currentEntity removeKeyPair:"wad"]; else { - if (strcmp ([texturepalette_i currentWad], dat)) - [project_i setTextureWad:dat]; + if (strcmp ([texturepalette_i currentWad], wad)) + [project_i setTextureWad:wad]; } } // center the camera and XY view on the playerstart diff --git a/tools/Forge/Bundles/MapEdit/Project.h b/tools/Forge/Bundles/MapEdit/Project.h index 42bcb3aad..415247771 100644 --- a/tools/Forge/Bundles/MapEdit/Project.h +++ b/tools/Forge/Bundles/MapEdit/Project.h @@ -74,7 +74,7 @@ extern id project_i; -(char *) currentProjectFile; --setTextureWad:(char *) wf; +-setTextureWad:(const char *) wf; -addToOutput:(char *) string; -clearBspOutput:sender; diff --git a/tools/Forge/Bundles/MapEdit/Project.m b/tools/Forge/Bundles/MapEdit/Project.m index 8b4d4fd3f..98258626a 100644 --- a/tools/Forge/Bundles/MapEdit/Project.m +++ b/tools/Forge/Bundles/MapEdit/Project.m @@ -261,7 +261,7 @@ t in:(id) obj } --setTextureWad:(char *) wf +-setTextureWad:(const char *) wf { int i, c; char *name; diff --git a/tools/Forge/Bundles/MapEdit/SetBrush.m b/tools/Forge/Bundles/MapEdit/SetBrush.m index 975844758..ed50e9378 100644 --- a/tools/Forge/Bundles/MapEdit/SetBrush.m +++ b/tools/Forge/Bundles/MapEdit/SetBrush.m @@ -990,9 +990,9 @@ BOOL fakebrush; vec3_t dest, origin; vec3_t mid; vec3_t forward, right; - char *targname; + const char *targname; vec3_t min, max, temp; - char *targ; + const char *targ; targ =[parent valueForQKey:"target"]; @@ -1077,7 +1077,7 @@ XYDrawSelf int i, j; winding_t *w; vec3_t mid, end, s1, s2; - char *val; + const char *val; float ang; id worldent, currentent; BOOL keybrush; @@ -1546,7 +1546,7 @@ Set the regioned flag based on if the object is containted in region_min/max -newRegion { int i; - char *name; + const char *name; // filter away entities if (parent !=[map_i objectAtIndex:0]) { diff --git a/tools/Forge/Bundles/MapEdit/TexturePalette.h b/tools/Forge/Bundles/MapEdit/TexturePalette.h index 8f0aaf774..70cc1d0e7 100644 --- a/tools/Forge/Bundles/MapEdit/TexturePalette.h +++ b/tools/Forge/Bundles/MapEdit/TexturePalette.h @@ -34,7 +34,7 @@ typedef struct { extern int tex_count; extern qtexture_t qtextures[MAX_TEXTURES]; -void TEX_InitFromWad (char *path); +void TEX_InitFromWad (const char *path); qtexture_t *TEX_ForName (char *name); @@ -71,7 +71,7 @@ extern id texturepalette_i; } -(char *) currentWad; --initPaletteFromWadfile:(char *) wf; +-initPaletteFromWadfile:(const char *) wf; -computeTextureViewSize; -alphabetize; -getList; diff --git a/tools/Forge/Bundles/MapEdit/TexturePalette.m b/tools/Forge/Bundles/MapEdit/TexturePalette.m index bbe548ffc..ceaba8644 100644 --- a/tools/Forge/Bundles/MapEdit/TexturePalette.m +++ b/tools/Forge/Bundles/MapEdit/TexturePalette.m @@ -174,7 +174,7 @@ TEX_InitFromWad ================= */ void -TEX_InitFromWad (char *path) +TEX_InitFromWad (const char *path) { int i; char newpath[1024]; @@ -268,7 +268,7 @@ TEX_ForName (char *name) return currentwad; } --initPaletteFromWadfile:(char *) wf +-initPaletteFromWadfile:(const char *) wf { int i; texpal_t t; diff --git a/tools/Forge/Bundles/MapEdit/Things.m b/tools/Forge/Bundles/MapEdit/Things.m index 8ccb04ba7..e479cb354 100644 --- a/tools/Forge/Bundles/MapEdit/Things.m +++ b/tools/Forge/Bundles/MapEdit/Things.m @@ -118,7 +118,7 @@ id things_i; } --selectClass:(char *) class +-selectClass:(const char *) class { id classent; @@ -141,9 +141,9 @@ id things_i; -newCurrentEntity { id ent, classent, cell; - char *classname; + const char *classname; int r, c; - char *flagname; + const char *flagname; int flags; ent =[map_i currentEntity];