pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

prboom-plus: Version from pkgsrc with patches for big endian machines



Module Name:	pkgsrc-wip
Committed By:	Michael Baeuerle <michael.baeuerle%stz-e.de@localhost>
Pushed By:	micha
Date:		Mon Mar 2 13:42:22 2020 +0100
Changeset:	2b38ed1722f6806843fac7de8d599b6c69346d97

Modified Files:
	Makefile
Added Files:
	prboom-plus/DESCR
	prboom-plus/Makefile
	prboom-plus/PLIST
	prboom-plus/distinfo
	prboom-plus/patches/patch-src_m__swap.h
	prboom-plus/patches/patch-src_p__setup.c

Log Message:
prboom-plus: Version from pkgsrc with patches for big endian machines

Loading maps using ZDoom extended nodes crashes on big endian machines.
Example: Eviternity.wad Map15

This package contain patches to fix this problem.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=2b38ed1722f6806843fac7de8d599b6c69346d97

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                 |   1 +
 prboom-plus/DESCR                        |   3 +
 prboom-plus/Makefile                     |  24 ++++
 prboom-plus/PLIST                        |  19 +++
 prboom-plus/distinfo                     |   8 ++
 prboom-plus/patches/patch-src_m__swap.h  |  23 ++++
 prboom-plus/patches/patch-src_p__setup.c | 191 +++++++++++++++++++++++++++++++
 7 files changed, 269 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index f4b20655d1..6f254f53ac 100644
--- a/Makefile
+++ b/Makefile
@@ -3029,6 +3029,7 @@ SUBDIR+=	ppc-morphos-sdk
 SUBDIR+=	ppp
 SUBDIR+=	ppr
 SUBDIR+=	praat
+SUBDIR+=	prboom-plus
 SUBDIR+=	pre-commit
 SUBDIR+=	preftools
 SUBDIR+=	preload
diff --git a/prboom-plus/DESCR b/prboom-plus/DESCR
new file mode 100644
index 0000000000..41597a6d39
--- /dev/null
+++ b/prboom-plus/DESCR
@@ -0,0 +1,3 @@
+PrBoom+ is a modified version of id Software's classic game DOOM.  It
+runs on several platforms (including Win32 and Unixes) and features many
+additions to the original game.  It also supports multiplayer games.
diff --git a/prboom-plus/Makefile b/prboom-plus/Makefile
new file mode 100644
index 0000000000..d94e9dbc79
--- /dev/null
+++ b/prboom-plus/Makefile
@@ -0,0 +1,24 @@
+# $NetBSD: Makefile,v 1.7 2020/01/18 23:32:04 rillig Exp $
+
+DISTNAME=	prboom-plus-2.5.1.4
+CATEGORIES=	games
+MASTER_SITES=	${MASTER_SITE_SOURCEFORGE:=prboom-plus/}
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://prboom-plus.sourceforge.net/
+COMMENT=	Multiplayer-capable and modified version of DOOM
+LICENSE=	gnu-gpl-v2
+
+GNU_CONFIGURE=		YES
+CONFIGURE_ARGS+=	--with-waddir=${PREFIX}/share/doom
+
+SUBST_CLASSES+=		gamesdir
+SUBST_STAGE.gamesdir=	pre-configure
+SUBST_MESSAGE.gamesdir=	Fixing hard-coded gamesdir
+SUBST_FILES.gamesdir=	src/Makefile.in
+SUBST_SED.gamesdir+=	-e '/^gamesdir =/ s;/games;/bin;g'
+
+.include "../../audio/SDL_mixer/buildlink3.mk"
+.include "../../net/SDL_net/buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/prboom-plus/PLIST b/prboom-plus/PLIST
new file mode 100644
index 0000000000..4e91bbb744
--- /dev/null
+++ b/prboom-plus/PLIST
@@ -0,0 +1,19 @@
+@comment $NetBSD: PLIST,v 1.1 2014/09/13 12:55:06 shattered Exp $
+bin/prboom-plus
+bin/prboom-plus-game-server
+man/man5/prboom-plus.cfg.5
+man/man6/prboom-plus-game-server.6
+man/man6/prboom-plus.6
+share/doc/${PKGNAME}/AUTHORS
+share/doc/${PKGNAME}/COPYING
+share/doc/${PKGNAME}/MBF.txt
+share/doc/${PKGNAME}/MBFFAQ.txt
+share/doc/${PKGNAME}/NEWS
+share/doc/${PKGNAME}/README
+share/doc/${PKGNAME}/README.compat
+share/doc/${PKGNAME}/README.demos
+share/doc/${PKGNAME}/boom.txt
+share/doc/${PKGNAME}/prboom-plus-history.html
+share/doc/${PKGNAME}/prboom-plus-history.txt
+share/doc/${PKGNAME}/prboom-plus-usage.txt
+share/doom/prboom-plus.wad
diff --git a/prboom-plus/distinfo b/prboom-plus/distinfo
new file mode 100644
index 0000000000..bb9c5d6963
--- /dev/null
+++ b/prboom-plus/distinfo
@@ -0,0 +1,8 @@
+$NetBSD$
+
+SHA1 (prboom-plus-2.5.1.4.tar.gz) = 73b3b46c36aa693059f2762dcd807bfd0490f130
+RMD160 (prboom-plus-2.5.1.4.tar.gz) = ebb834844f6ca38aa55214ae8ee1d0cff5e2d5e8
+SHA512 (prboom-plus-2.5.1.4.tar.gz) = ca342bc2eac05458ed9c40aa781badc81416f25e51de23543f037df547d973dcca7522fb942160b7b797d24b6313a0e111afa11ad887199fbaab06240ffeb716
+Size (prboom-plus-2.5.1.4.tar.gz) = 1627558 bytes
+SHA1 (patch-src_m__swap.h) = 2a60e2dfe84496f46b89f2e28007b53c35157b00
+SHA1 (patch-src_p__setup.c) = 8596400c8d08b1d70bf7539306de920e2f894a61
diff --git a/prboom-plus/patches/patch-src_m__swap.h b/prboom-plus/patches/patch-src_m__swap.h
new file mode 100644
index 0000000000..23fc23c871
--- /dev/null
+++ b/prboom-plus/patches/patch-src_m__swap.h
@@ -0,0 +1,23 @@
+$NetBSD$
+
+Use doom_wtohs() for LittleShort() because these macros are used for
+importing data from WAD files. Add comments for returned data types.
+
+--- src/m_swap.h.orig	2014-05-20 04:47:44.000000000 +0000
++++ src/m_swap.h
+@@ -126,9 +126,12 @@
+ 
+ #endif
+ 
+-/* CPhipps - Boom's old LONG and SHORT endianness macros are for WAD stuff */
++/* CPhipps - Boom's old LONG and SHORT endianness macros are for WAD stuff
++ *
++ * MB 2020-03-01: Use doom_wtoYT() for all macros
++ */
+ 
+-#define LittleLong(x) doom_wtohl(x)
+-#define LittleShort(x) doom_htows(x)
++#define LittleLong(x) doom_wtohl(x)   /* Returns signed 32-bit value */
++#define LittleShort(x) doom_wtohs(x)  /* Returns signed 16-bit value */
+ 
+ #endif
diff --git a/prboom-plus/patches/patch-src_p__setup.c b/prboom-plus/patches/patch-src_p__setup.c
new file mode 100644
index 0000000000..6c334ad3e7
--- /dev/null
+++ b/prboom-plus/patches/patch-src_p__setup.c
@@ -0,0 +1,191 @@
+$NetBSD$
+
+Loading maps using ZDoom extended nodes crashes on big endian machines
+(because 32-bit values are imported with wrong byte order).
+
+Note that the endianess conversion macros return 16-bit or 32-bit
+signed values using data types short int and long int. Both data types
+are allowed to be larger (implementation defined) and in this case
+additional bits are sign extended. This patch mask such additional
+bits if the target data type is unsigned.
+
+If memory allocation returns NULL, do not continue (dereference the
+NULL pointer and crash).
+
+--- src/p_setup.c.orig	2016-01-10 18:01:30.000000000 +0000
++++ src/p_setup.c
+@@ -1024,6 +1024,7 @@ static void CheckZNodesOverflow(int *siz
+   }
+ }
+ 
++// MB 2020-03-01: Fix endianess for 32-bit ZDoom nodes
+ static void P_LoadZSegs (const byte *data)
+ {
+   int i;
+@@ -1037,12 +1038,12 @@ static void P_LoadZSegs (const byte *dat
+     seg_t *li = segs+i;
+     const mapseg_znod_t *ml = (const mapseg_znod_t *) data + i;
+ 
+-    v1 = ml->v1;
+-    v2 = ml->v2;
++    v1 = (unsigned int)LittleLong(ml->v1) & 0xFFFFFFFFU;
++    v2 = (unsigned int)LittleLong(ml->v2) & 0xFFFFFFFFU;
+ 
+     li->miniseg = false;
+ 
+-    linedef = (unsigned short)LittleShort(ml->linedef);
++    linedef = (unsigned short)LittleShort(ml->linedef) & 0xFFFFU;
+ 
+     //e6y: check for wrong indexes
+     if ((unsigned int)linedef >= (unsigned int)numlines)
+@@ -1098,6 +1099,8 @@ static void P_LoadZSegs (const byte *dat
+   }
+ }
+ 
++// MB 2020-03-01: Fix endianess for 32-bit ZDoom nodes
++// https://zdoom.org/wiki/Node#ZDoom_extended_nodes
+ static void P_LoadZNodes(int lump, int glnodes)
+ {
+   const byte *data;
+@@ -1112,18 +1115,18 @@ static void P_LoadZNodes(int lump, int g
+ 
+   data = W_CacheLumpNum(lump);
+   len =  W_LumpLength(lump);
+-  
++
+   // skip header
+   CheckZNodesOverflow(&len, 4);
+   data += 4;
+ 
+   // Read extra vertices added during node building
+   CheckZNodesOverflow(&len, sizeof(orgVerts));
+-  orgVerts = *((const unsigned int*)data);
++  orgVerts = (unsigned int)LittleLong(*((const unsigned int*)data)) & 0xFFFFFFFFU;
+   data += sizeof(orgVerts);
+ 
+   CheckZNodesOverflow(&len, sizeof(newVerts));
+-  newVerts = *((const unsigned int*)data);
++  newVerts = (unsigned int)LittleLong(*((const unsigned int*)data)) & 0xFFFFFFFFU;
+   data += sizeof(newVerts);
+ 
+   if (!samelevel)
+@@ -1135,16 +1138,21 @@ static void P_LoadZNodes(int lump, int g
+     else
+     {
+       newvertarray = calloc(orgVerts + newVerts, sizeof(vertex_t));
++      // MB 2020-03-01: Check whether memory allocation was successful
++      if (NULL == newvertarray)
++      {
++        I_Error("P_LoadZNodes: memory allocation failed");
++      }
+       memcpy (newvertarray, vertexes, orgVerts * sizeof(vertex_t));
+     }
+ 
+     CheckZNodesOverflow(&len, newVerts * (sizeof(newvertarray[0].x) + sizeof(newvertarray[0].y)));
+     for (i = 0; i < newVerts; i++)
+     {
+-      newvertarray[i + orgVerts].x = *((const unsigned int*)data);
++      newvertarray[i + orgVerts].x = (fixed_t)LittleLong(*((const unsigned int*)data));
+       data += sizeof(newvertarray[0].x);
+ 
+-      newvertarray[i + orgVerts].y = *((const unsigned int*)data);
++      newvertarray[i + orgVerts].y = (fixed_t)LittleLong(*((const unsigned int*)data));
+       data += sizeof(newvertarray[0].y);
+     }
+ 
+@@ -1172,28 +1180,37 @@ static void P_LoadZNodes(int lump, int g
+ 
+   // Read the subsectors
+   CheckZNodesOverflow(&len, sizeof(numSubs));
+-  numSubs = *((const unsigned int*)data);
++  numSubs = (unsigned int)LittleLong(*((const unsigned int*)data)) & 0xFFFFFFFFU;
+   data += sizeof(numSubs);
+ 
+   numsubsectors = numSubs;
+   if (numsubsectors <= 0)
+     I_Error("P_LoadZNodes: no subsectors in level");
+   subsectors = calloc_IfSameLevel(subsectors, numsubsectors, sizeof(subsector_t));
++  // MB 2020-03-01: Check whether memory allocation was successful
++  if (NULL == subsectors)
++  {
++    I_Error("P_LoadZNodes: memory allocation failed");
++  }
+ 
+   CheckZNodesOverflow(&len, numSubs * sizeof(mapsubsector_znod_t));
++  // MB 2020-03-01
++  // First segment number of each subsector is not stored
++  // First subsector starts at segment 0
++  // Subsequent subsectors starts with the next unused segment number (currSeg)
+   for (i = currSeg = 0; i < numSubs; i++)
+   {
+     const mapsubsector_znod_t *mseg = (const mapsubsector_znod_t *) data + i;
+ 
+     subsectors[i].firstline = currSeg;
+-    subsectors[i].numlines = mseg->numsegs;
+-    currSeg += mseg->numsegs;
++    subsectors[i].numlines = (int)LittleLong(mseg->numsegs);
++    currSeg += (unsigned int)LittleLong(mseg->numsegs) & 0xFFFFFFFFU;
+   }
+   data += numSubs * sizeof(mapsubsector_znod_t);
+ 
+   // Read the segs
+   CheckZNodesOverflow(&len, sizeof(numSegs));
+-  numSegs = *((const unsigned int*)data);
++  numSegs = (unsigned int)LittleLong(*((const unsigned int*)data)) & 0xFFFFFFFFU;
+   data += sizeof(numSegs);
+ 
+   // The number of segs stored should match the number of
+@@ -1205,6 +1222,11 @@ static void P_LoadZNodes(int lump, int g
+ 
+   numsegs = numSegs;
+   segs = calloc_IfSameLevel(segs, numsegs, sizeof(seg_t));
++  // MB 2020-03-01: Check whether memory allocation was successful
++  if (NULL == segs)
++  {
++    I_Error("P_LoadZNodes: memory allocation failed");
++  }
+ 
+   if (glnodes == 0)
+   {
+@@ -1220,11 +1242,16 @@ static void P_LoadZNodes(int lump, int g
+ 
+   // Read nodes
+   CheckZNodesOverflow(&len, sizeof(numNodes));
+-  numNodes = *((const unsigned int*)data);
++  numNodes = (unsigned int)LittleLong(*((const unsigned int*)data)) & 0xFFFFFFFFU;
+   data += sizeof(numNodes);
+ 
+   numnodes = numNodes;
+   nodes = calloc_IfSameLevel(nodes, numNodes, sizeof(node_t));
++  // MB 2020-03-01: Check whether memory allocation was successful
++  if (NULL == nodes)
++  {
++    I_Error("P_LoadZNodes: memory allocation failed");
++  }
+ 
+   CheckZNodesOverflow(&len, numNodes * sizeof(mapnode_znod_t));
+   for (i = 0; i < numNodes; i++)
+@@ -1233,17 +1260,17 @@ static void P_LoadZNodes(int lump, int g
+     node_t *no = nodes + i;
+     const mapnode_znod_t *mn = (const mapnode_znod_t *) data + i;
+ 
+-    no->x = LittleShort(mn->x)<<FRACBITS;
+-    no->y = LittleShort(mn->y)<<FRACBITS;
+-    no->dx = LittleShort(mn->dx)<<FRACBITS;
+-    no->dy = LittleShort(mn->dy)<<FRACBITS;
++    no->x = (fixed_t)LittleShort(mn->x)<<FRACBITS;
++    no->y = (fixed_t)LittleShort(mn->y)<<FRACBITS;
++    no->dx = (fixed_t)LittleShort(mn->dx)<<FRACBITS;
++    no->dy = (fixed_t)LittleShort(mn->dy)<<FRACBITS;
+ 
+     for (j = 0; j < 2; j++)
+     {
+-      no->children[j] = (unsigned int)(mn->children[j]);
++      no->children[j] = (int)LittleLong(mn->children[j]);
+ 
+       for (k = 0; k < 4; k++)
+-        no->bbox[j][k] = LittleShort(mn->bbox[j][k])<<FRACBITS;
++        no->bbox[j][k] = (fixed_t)LittleShort(mn->bbox[j][k])<<FRACBITS;
+     }
+   }
+ 


Home | Main Index | Thread Index | Old Index