From 5d97a9a63327bba17805bf228cafe3caf2338b2c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 9 Aug 2008 17:09:23 +0000 Subject: Don't modify level lumps when loading levels. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1178 --- src/p_setup.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 739a60b5..5cf7a628 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -302,12 +302,13 @@ void P_LoadNodes (int lump) // void P_LoadThings (int lump) { - byte* data; + byte *data; int i; - mapthing_t* mt; + mapthing_t *mt; + mapthing_t spawnthing; int numthings; boolean spawn; - + data = W_CacheLumpNum (lump,PU_STATIC); numthings = W_LumpLength (lump) / sizeof(mapthing_t); @@ -317,9 +318,9 @@ void P_LoadThings (int lump) spawn = true; // Do not spawn cool, new monsters if !commercial - if ( gamemode != commercial) + if (gamemode != commercial) { - switch(mt->type) + switch (SHORT(mt->type)) { case 68: // Arachnotron case 64: // Archvile @@ -339,15 +340,15 @@ void P_LoadThings (int lump) break; // Do spawn all other stuff. - mt->x = SHORT(mt->x); - mt->y = SHORT(mt->y); - mt->angle = SHORT(mt->angle); - mt->type = SHORT(mt->type); - mt->options = SHORT(mt->options); + spawnthing.x = SHORT(mt->x); + spawnthing.y = SHORT(mt->y); + spawnthing.angle = SHORT(mt->angle); + spawnthing.type = SHORT(mt->type); + spawnthing.options = SHORT(mt->options); - P_SpawnMapThing (mt); + P_SpawnMapThing(&spawnthing); } - + W_ReleaseLumpNum(lump); } @@ -470,25 +471,36 @@ void P_LoadSideDefs (int lump) // void P_LoadBlockMap (int lump) { - int i; - int count; + int i; + int count; + int lumplen; + + lumplen = W_LumpLength(lump); + count = lumplen / 2; - blockmaplump = W_CacheLumpNum (lump,PU_LEVEL); - blockmap = blockmaplump+4; - count = W_LumpLength (lump)/2; + blockmaplump = Z_Malloc(lumplen, PU_LEVEL, NULL); + W_ReadLump(lump, blockmaplump); + blockmap = blockmaplump + 4; - for (i=0 ; i