foxygit / doom Log in
commit 80eacd13f9d4e7111893de511d0b5ecd5402ee74
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Fri Oct 24 17:28:37 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Fri Oct 24 17:28:37 2008 +0000

    Fix Heretic/Hexen implementations of P_LoadBlockmap to not modify the
    lump.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1362
---
 src/heretic/p_setup.c | 10 ++++++++--
 src/hexen/p_setup.c   | 15 ++++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/heretic/p_setup.c b/src/heretic/p_setup.c
index d27250c4..8e93fe04 100644
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -419,10 +419,16 @@ void P_LoadSideDefs(int lump)
 void P_LoadBlockMap(int lump)
 {
     int i, count;
+    int lumplen;

-    blockmaplump = W_CacheLumpNum(lump, PU_LEVEL);
+    lumplen = W_LumpLength(lump);
+
+    blockmaplump = Z_Malloc(lumplen, PU_LEVEL, NULL);
     blockmap = blockmaplump + 4;
-    count = W_LumpLength(lump) / 2;
+
+    // Swap all short integers to native byte ordering:
+
+    count = lumplen / 2;
     for (i = 0; i < count; i++)
         blockmaplump[i] = SHORT(blockmaplump[i]);

diff --git a/src/hexen/p_setup.c b/src/hexen/p_setup.c
index 695c262e..653080e2 100644
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -533,10 +533,18 @@ void P_LoadSideDefs(int lump)
 void P_LoadBlockMap(int lump)
 {
     int i, count;
+    int lumplen;

-    blockmaplump = W_CacheLumpNum(lump, PU_LEVEL);
+    lumplen = W_LumpLength(lump);
+
+    blockmaplump = Z_Malloc(lumplen, PU_LEVEL, NULL);
+    W_ReadLump(lump, blockmaplump);
     blockmap = blockmaplump + 4;
-    count = W_LumpLength(lump) / 2;
+
+    // Swap all short integers to native byte ordering:
+
+    count = lumplen / 2;
+
     for (i = 0; i < count; i++)
         blockmaplump[i] = SHORT(blockmaplump[i]);

@@ -545,7 +553,8 @@ void P_LoadBlockMap(int lump)
     bmapwidth = blockmaplump[2];
     bmapheight = blockmaplump[3];

-// clear out mobj chains
+    // clear out mobj chains
+
     count = sizeof(*blocklinks) * bmapwidth * bmapheight;
     blocklinks = Z_Malloc(count, PU_LEVEL, 0);
     memset(blocklinks, 0, count);