pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
doomlegacy-devel: Hook in new blockmap creation code
Module Name: pkgsrc-wip
Committed By: Michael Baeuerle <micha%NetBSD.org@localhost>
Pushed By: micha
Date: Wed May 13 18:15:29 2020 +0200
Changeset: fb20d790e4c48f4ce07b9873cd10bda9124ccddc
Modified Files:
doomlegacy-devel/Makefile
doomlegacy-devel/TODO
doomlegacy-devel/distinfo
doomlegacy-devel/files/p_blockmap.c
doomlegacy-devel/patches/patch-src_p__setup.c
Added Files:
doomlegacy-devel/files/p_blockmap.h
doomlegacy-devel/patches/patch-src_p__local.h
Log Message:
doomlegacy-devel: Hook in new blockmap creation code
Former behaviour is unchanged.
If the "-blockmap" option is specified, the BLOCKMAP lump is ignored
and the blockmap is created internally.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=fb20d790e4c48f4ce07b9873cd10bda9124ccddc
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
doomlegacy-devel/Makefile | 1 +
doomlegacy-devel/TODO | 11 ++--
doomlegacy-devel/distinfo | 3 +-
doomlegacy-devel/files/p_blockmap.c | 91 ++++++++++++++++++---------
doomlegacy-devel/files/p_blockmap.h | 32 ++++++++++
doomlegacy-devel/patches/patch-src_p__local.h | 18 ++++++
doomlegacy-devel/patches/patch-src_p__setup.c | 75 +++++++++++++++++-----
7 files changed, 178 insertions(+), 53 deletions(-)
diffs:
diff --git a/doomlegacy-devel/Makefile b/doomlegacy-devel/Makefile
index f9def4319b..83bbd50428 100644
--- a/doomlegacy-devel/Makefile
+++ b/doomlegacy-devel/Makefile
@@ -81,6 +81,7 @@ pre-configure:
${CP} ${FILESDIR}/doomlegacy.sh ${WRKDIR}
${CP} ${FILESDIR}/doomlegacy.6.in ${WRKDIR}
${CP} ${FILESDIR}/p_blockmap.c ${WRKSRC}/src
+ ${CP} ${FILESDIR}/p_blockmap.h ${WRKSRC}/src
${CP} ${FILESDIR}/p_extnodes.c ${WRKSRC}/src
${CP} ${FILESDIR}/p_extnodes.h ${WRKSRC}/src
cd ${WRKSRC} && ${CP} make_options_nix make_options
diff --git a/doomlegacy-devel/TODO b/doomlegacy-devel/TODO
index 93585bb933..45873d8db0 100644
--- a/doomlegacy-devel/TODO
+++ b/doomlegacy-devel/TODO
@@ -118,7 +118,6 @@ Part 6 finished.
Part 7: Import final release
============================
-
[ ] Import version 1.48.3
Not released yet
@@ -136,10 +135,12 @@ Part 9: Support for internal blockmap creation
==============================================
Make it possible to play maps with broken blockmaps (or no blockmaps at all).
-[X] Imported code based on Crispy Doom 5.8.0
-[ ] Fix for NOVA II (Bug #658)
-[ ] Fix for NOVA III (blockmaps missing completely)
-[ ] Command line option "-blockmap" like in PrBoom+
+[X] Import blockmap creation code based on Crispy Doom 5.8.0
+[X] Add command line option "-blockmap" like in PrBoom+
+[X] Usable as workaround for NOVA II (blockmap load error, Bug #658)
+[X] Usable as workaround for NOVA III (blockmaps missing completely)
+[ ] Usable as workaround for Lost Civilization
+ It's unclear whether the blockmaps are broken or not imported correctly
EOF
diff --git a/doomlegacy-devel/distinfo b/doomlegacy-devel/distinfo
index 9dd93052db..e8b5cfe426 100644
--- a/doomlegacy-devel/distinfo
+++ b/doomlegacy-devel/distinfo
@@ -7,5 +7,6 @@ Size (doomlegacy_1.47.2_common.zip) = 981654 bytes
SHA1 (patch-src_Makefile) = 40184838a23e00975a5380f18c8c53b3cc2eee47
SHA1 (patch-src_am__map.c) = 14b3c8b70c63778ad043827ab2f0b6f4fe07bcde
SHA1 (patch-src_doomdata.h) = 8c3186dafbf11a8a75262a06755dd9807cb58612
-SHA1 (patch-src_p__setup.c) = 526a5dcf97d4b2db3d05a8c655126fcd70deac21
+SHA1 (patch-src_p__local.h) = 0340c38a80ba4323e4fe7a8c314575a70a246708
+SHA1 (patch-src_p__setup.c) = 546f73bfbace85b762585a9c215f0c5d7d52d2f2
SHA1 (patch-src_r__defs.h) = 91e6543674e3474c9afdb0ba19d6869b658d0543
diff --git a/doomlegacy-devel/files/p_blockmap.c b/doomlegacy-devel/files/p_blockmap.c
index b56b92fe2b..1ac19bd388 100644
--- a/doomlegacy-devel/files/p_blockmap.c
+++ b/doomlegacy-devel/files/p_blockmap.c
@@ -4,6 +4,7 @@
// Rand Phares, Ty Halderman
// Copyright(C) 2005-2014 Simon Howard
// Copyright(C) 2017 Fabian Greffrath
+// Copyright(C) 2020 by DooM Legacy Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -16,32 +17,40 @@
// GNU General Public License for more details.
//
// DESCRIPTION:
-// [crispy] Create Blockmap
+// [crispy] Create Blockmap
+// [MB] 2020-05-13: Description of blockmap lump format:
+// https://doomwiki.org/wiki/Blockmap
//
-#include <inttypes.h>
+#include <stdint.h> // [MB] 2020-05-13: Added for C99 integer data types
#include <stdlib.h>
-#include <string.h>
+#include <string.h> // [MB] 2020-05-12: Added for memset()
-//#include "i_system.h"
-#include "doomincl.h" // [MB] 2020-05-12: Added for I_Error()
+//#include "i_system.h" // [MB] 2020-05-12: I_Realloc() is now here
+#include "doomincl.h" // [MB] 2020-05-12: Added for I_Error()
#include "p_local.h"
#include "r_state.h"
#include "z_zone.h"
-// [MB] 2020-05-12: Imported from Crispy Doom 5.8.0 (src/i_system.c)
// I_Realloc
+/*
+ * [MB] 2020-05-12: Ported from Crispy Doom 5.8.0 (src/i_system.c)
+ * - Reject zero new size (would be implementation defined behaviour)
+ * - Use (unsigned long) for I_Error() (size is not a pointer)
+ */
static void *I_Realloc(void *ptr, size_t size)
{
- void *new_ptr;
+ void *new_ptr = NULL;
- new_ptr = realloc(ptr, size);
-
- if (size != 0 && new_ptr == NULL)
+ if (0 == size)
+ I_Error("I_Realloc: Failed on zero new size");
+ else
{
- I_Error("I_Realloc: failed on reallocation of %" PRIuPTR " bytes",
- size);
+ new_ptr = realloc(ptr, size);
+ if (NULL == new_ptr)
+ I_Error("I_Realloc: Failed on reallocation of %lu bytes",
+ (unsigned long) size);
}
return new_ptr;
@@ -49,11 +58,15 @@ static void *I_Realloc(void *ptr, size_t size)
// [crispy] taken from mbfsrc/P_SETUP.C:547-707, slightly adapted
-// [MB] 2020-05-12: Change indentation to 4 SPs (matching Doom Legacy style)
-// [MB] 2020-05-12: Replace blockmap with blockmapindex (unsigned)
-// [MB] 2020-05-12: Replace blockmaplump with blockmaphead (unsigned)
-// [MB] 2020-05-12: Added typecasts for unsigned target types
-
+/*
+ * [MB] 2020-05-12: Ported from Crispy Doom 5.8.0 (src/doom/p_blockmap.c)
+ * - Change indentation to 4 SPs (matching DooM Legacy style)
+ * - Replace blockmap with blockmapindex (int32_t* => uint32_t*)
+ * Global pointer to header of the blockmap lump
+ * - Replace blockmaplump with blockmaphead (int32_t* => uint32_t*)
+ * Global pointer to beginning of the part containing the offsets
+ * - Added typecasts for unsigned target types
+ */
void P_CreateBlockMap(void)
{
register int i;
@@ -121,12 +134,12 @@ void P_CreateBlockMap(void)
// difference in preferring to move across y (>0) instead of x (<0)
diff = !adx ? 1 : !ady ? -1 :
- (((x >> MAPBTOFRAC) << MAPBTOFRAC) +
- (dx > 0 ? MAPBLOCKUNITS-1 : 0) - x) *
- (ady = abs(ady)) * dx -
- (((y >> MAPBTOFRAC) << MAPBTOFRAC) +
- (dy > 0 ? MAPBLOCKUNITS-1 : 0) - y) *
- (adx = abs(adx)) * dy;
+ ( ((x >> MAPBTOFRAC) << MAPBTOFRAC) +
+ (dx > 0 ? MAPBLOCKUNITS-1 : 0) - x ) *
+ (ady = abs(ady)) * dx -
+ ( ((y >> MAPBTOFRAC) << MAPBTOFRAC) +
+ (dy > 0 ? MAPBLOCKUNITS-1 : 0) - y ) *
+ (adx = abs(adx)) * dy;
// starting block, and pointer to its blocklist structure
b = (y >> MAPBTOFRAC)*bmapwidth + (x >> MAPBTOFRAC);
@@ -149,8 +162,9 @@ void P_CreateBlockMap(void)
// Increase size of allocated list if necessary
if (bmap[b].n >= bmap[b].nalloc)
bmap[b].list = I_Realloc(bmap[b].list,
- (bmap[b].nalloc = bmap[b].nalloc ?
- bmap[b].nalloc*2 : 8)*sizeof*bmap->list);
+ ( bmap[b].nalloc = bmap[b].nalloc ?
+ bmap[b].nalloc*2 : 8 ) *
+ sizeof*bmap->list);
// Add linedef to end of list
bmap[b].list[bmap[b].n++] = i;
@@ -211,20 +225,35 @@ void P_CreateBlockMap(void)
else // Empty blocklist: point to reserved empty blocklist
blockmaphead[i] = tot;
- free(bmap); // Free uncompressed blockmap
}
+
+ // [MB] 2020-05-13: Moved outside of last nested block to make it more
+ // obvious that the free() is always executed
+ free(bmap); // Free uncompressed blockmap
}
+#if 1
+ // [MB] 2020-05-13: Populate blockmap lump header
+ /*
+ * Currently DooM Legacy 1.48 does not use this header. Maybe useful for
+ * debugging.
+ */
+ {
+ blockmaphead[0] = bmaporgx>>FRACBITS; // x coordinate of grid origin
+ blockmaphead[1] = bmaporgy>>FRACBITS; // y coordinate of grid origin
+ blockmaphead[2] = bmapwidth; // Number of columns
+ blockmaphead[3] = bmapheight; // Number of rows
+ }
+#endif
+
// [crispy] copied over from P_LoadBlockMap()
+ // [MB] 2020-05-13: Modified to match "clear out mobj chains" of DooM Legacy
{
int count = sizeof(*blocklinks) * bmapwidth * bmapheight;
blocklinks = Z_Malloc(count, PU_LEVEL, 0);
memset(blocklinks, 0, count);
- blockmapindex = blockmaphead+4;
+ //blockmapindex = blockmaphead+4;
+ blockmapindex = & blockmaphead[4];
}
-
-#if 0
- fprintf(stderr, "+BLOCKMAP)\n");
-#endif
}
diff --git a/doomlegacy-devel/files/p_blockmap.h b/doomlegacy-devel/files/p_blockmap.h
new file mode 100644
index 0000000000..2c71bfc5ff
--- /dev/null
+++ b/doomlegacy-devel/files/p_blockmap.h
@@ -0,0 +1,32 @@
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 2020 by DooM Legacy Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+// DESCRIPTION:
+// Header file created for blockmap creation code from Crispy Doom.
+//
+//-----------------------------------------------------------------------------
+
+
+#ifndef __P_BLOCKMAP__
+#define __P_BLOCKMAP__
+
+void P_CreateBlockMap (void);
+
+#endif
diff --git a/doomlegacy-devel/patches/patch-src_p__local.h b/doomlegacy-devel/patches/patch-src_p__local.h
new file mode 100644
index 0000000000..aa1c70bfd2
--- /dev/null
+++ b/doomlegacy-devel/patches/patch-src_p__local.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+Add support to internally create blockmap.
+
+--- src/p_local.h.orig 2020-05-11 09:40:33.000000000 +0000
++++ src/p_local.h
+@@ -379,8 +379,9 @@ void P_ApplyTorque(mobj_t *mo);
+ extern byte* rejectmatrix; // for fast sight rejection
+ // Read wad blockmap using int16_t wadblockmaplump[].
+ // Expand from 16bit wad to internal 32bit blockmap.
+-extern uint32_t* blockmaphead; // offsets in blockmap are from here
+-extern uint32_t* blockmapindex; // Big blockmap, SSNTails
++// [MB] 2020-05-13: Fix comments (blockmapindex points to offset part of lump)
++extern uint32_t* blockmaphead; // Big blockmap, SSNTails
++extern uint32_t* blockmapindex; // offsets in blockmap are from here
+ extern int bmapwidth;
+ extern int bmapheight; // in mapblocks
+ extern fixed_t bmaporgx;
diff --git a/doomlegacy-devel/patches/patch-src_p__setup.c b/doomlegacy-devel/patches/patch-src_p__setup.c
index 54d3677261..b2e5ffa884 100644
--- a/doomlegacy-devel/patches/patch-src_p__setup.c
+++ b/doomlegacy-devel/patches/patch-src_p__setup.c
@@ -5,17 +5,38 @@ Add support for DeeP and ZDoom extended nodes.
Created upstream feature request:
https://sourceforge.net/p/doomlegacy/feature-requests/95/
---- src/p_setup.c.orig 2020-04-20 10:32:30.000000000 +0000
+--- src/p_setup.c.orig 2020-05-11 09:40:34.000000000 +0000
+++ src/p_setup.c
-@@ -150,6 +150,7 @@
+@@ -150,6 +150,9 @@
//-----------------------------------------------------------------------------
#include "doomincl.h"
++#include "m_argv.h" // [MB] 2020-05-13: To check for "-blockmap" option
++#include "p_blockmap.h" // [MB] 2020-05-13: For internal blockmap creation
+#include "p_extnodes.h" // [MB] 2020-04-21: For import of extended nodes
#include "p_local.h"
#include "p_tick.h"
// think
-@@ -282,6 +283,7 @@ mapthing_t * playerstarts[MAXPLAYERS]
+@@ -251,14 +254,15 @@ typedef struct mapdata_s {
+ // Created from axis aligned bounding box of the map, a rectangular array of
+ // blocks of size ...
+ // Used to speed up collision detection by spatial subdivision in 2D.
++// [MB] 2020-05-13: Fix comments (blockmapindex points to offset part of lump)
+ //
+ // Blockmap size.
+ int bmapwidth;
+ int bmapheight; // size in mapblocks
+
+-uint32_t * blockmapindex; // for large maps, wad is 16bit
+-// offsets in blockmap are from here
+-uint32_t * blockmaphead; // Big blockmap, SSNTails
++uint32_t * blockmaphead; // Big blockmap, SSNTails
++uint32_t * blockmapindex; // For large maps, wad is 16bit
++ // (offsets in blockmap are from here)
+
+ // origin of block map
+ fixed_t bmaporgx;
+@@ -282,6 +286,7 @@ mapthing_t * playerstarts[MAXPLAYERS]
#if 0
// [WDJ] Checks from PrBoom.
@@ -23,7 +44,7 @@ https://sourceforge.net/p/doomlegacy/feature-requests/95/
// figgi 08/21/00 -- constants and globals for glBsp support
#define gNd2 0x32644E67
-@@ -793,7 +795,22 @@ void P_LoadNodes (int lump)
+@@ -793,7 +798,22 @@ void P_LoadNodes (int lump)
no->dy = LE_SWAP16(mn->dy)<<FRACBITS;
for (j=0 ; j<2 ; j++)
{
@@ -47,7 +68,7 @@ https://sourceforge.net/p/doomlegacy/feature-requests/95/
for (k=0 ; k<4 ; k++)
no->bbox[j][k] = LE_SWAP16(mn->bbox[j][k])<<FRACBITS;
}
-@@ -1840,6 +1857,7 @@ boolean P_SetupLevel (int to_episod
+@@ -1840,6 +1860,7 @@ boolean P_SetupLevel (int to_episod
const char *errstr;
char *sl_mapname = NULL;
int i;
@@ -55,10 +76,22 @@ https://sourceforge.net/p/doomlegacy/feature-requests/95/
GenPrintf( (verbose? (EMSG_ver|EMSG_now) : (EMSG_console|EMSG_now)),
"Setup Level\n" );
-@@ -1985,6 +2003,29 @@ boolean P_SetupLevel (int to_episod
+@@ -1985,18 +2006,69 @@ boolean P_SetupLevel (int to_episod
goto load_reject;
}
+- // note: most of this ordering is important
+- P_LoadBlockMap (level_lumpnum+ML_BLOCKMAP);
+- P_LoadVertexes (level_lumpnum+ML_VERTEXES);
+- P_LoadSectors (level_lumpnum+ML_SECTORS);
+- P_LoadSideDefs (level_lumpnum+ML_SIDEDEFS);
+-
+- P_LoadLineDefs (level_lumpnum+ML_LINEDEFS);
+- P_LoadSideDefs2(level_lumpnum+ML_SIDEDEFS);
+- P_LoadLineDefs2();
+- P_LoadSubsectors (level_lumpnum+ML_SSECTORS);
+- P_LoadNodes (level_lumpnum+ML_NODES);
+- P_LoadSegs (level_lumpnum+ML_SEGS);
+ // [MB] 2020-04-21: Node format check from woof (p_extnodes.c)
+ mapformat = P_CheckMapFormat(level_lumpnum);
+ switch (mapformat)
@@ -82,16 +115,26 @@ https://sourceforge.net/p/doomlegacy/feature-requests/95/
+ break;
+ }
+
- // note: most of this ordering is important
- P_LoadBlockMap (level_lumpnum+ML_BLOCKMAP);
- P_LoadVertexes (level_lumpnum+ML_VERTEXES);
-@@ -1994,9 +2035,26 @@ boolean P_SetupLevel (int to_episod
- P_LoadLineDefs (level_lumpnum+ML_LINEDEFS);
- P_LoadSideDefs2(level_lumpnum+ML_SIDEDEFS);
- P_LoadLineDefs2();
-- P_LoadSubsectors (level_lumpnum+ML_SSECTORS);
-- P_LoadNodes (level_lumpnum+ML_NODES);
-- P_LoadSegs (level_lumpnum+ML_SEGS);
++ {
++ // [MB] 2020-05-13: Added option to internally create blockmap
++ boolean create_blockmap = M_CheckParm("-blockmap");
++
++ // note: most of this ordering is important
++ if (!create_blockmap)
++ P_LoadBlockMap (level_lumpnum+ML_BLOCKMAP);
++ P_LoadVertexes (level_lumpnum+ML_VERTEXES);
++ P_LoadSectors (level_lumpnum+ML_SECTORS);
++ P_LoadSideDefs (level_lumpnum+ML_SIDEDEFS);
++ P_LoadLineDefs (level_lumpnum+ML_LINEDEFS);
++ P_LoadSideDefs2(level_lumpnum+ML_SIDEDEFS);
++ P_LoadLineDefs2();
++ // [MB] 2020-05-13: Internally create blockmap on request
++ if (create_blockmap)
++ {
++ GenPrintf(EMSG_info, "Ignore BLOCKMAP lump, create blockmap\n" );
++ P_CreateBlockMap ();
++ }
++ }
+
+ // [MB] 2020-04-21: Hook in code imported from woof 1.2.0 (p_extnodes.c)
+ if (mapformat == MFMT_ZDBSPX || mapformat == MFMT_ZDBSPZ)
Home |
Main Index |
Thread Index |
Old Index