diff options
author | Simon Howard | 2008-08-09 17:09:23 +0000 |
---|---|---|
committer | Simon Howard | 2008-08-09 17:09:23 +0000 |
commit | 5d97a9a63327bba17805bf228cafe3caf2338b2c (patch) | |
tree | 479c0e163a694ec676e6e6ae46adbecbca54df38 | |
parent | 4065884e2f06b7e24dd929db82f59219e34b4127 (diff) | |
download | chocolate-doom-5d97a9a63327bba17805bf228cafe3caf2338b2c.tar.gz chocolate-doom-5d97a9a63327bba17805bf228cafe3caf2338b2c.tar.bz2 chocolate-doom-5d97a9a63327bba17805bf228cafe3caf2338b2c.zip |
Don't modify level lumps when loading levels.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1178
-rw-r--r-- | src/p_setup.c | 56 |
1 files 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<count ; i++) + // Swap all short integers to native byte ordering. + + for (i=0; i<count; i++) + { blockmaplump[i] = SHORT(blockmaplump[i]); + } + // Read the header + bmaporgx = blockmaplump[0]<<FRACBITS; bmaporgy = blockmaplump[1]<<FRACBITS; bmapwidth = blockmaplump[2]; bmapheight = blockmaplump[3]; - // clear out mobj chains - count = sizeof(*blocklinks)* bmapwidth*bmapheight; - blocklinks = Z_Malloc (count,PU_LEVEL, 0); - memset (blocklinks, 0, count); + // Clear out mobj chains + + count = sizeof(*blocklinks) * bmapwidth * bmapheight; + blocklinks = Z_Malloc(count, PU_LEVEL, 0); + memset(blocklinks, 0, count); } |