pkgsrc-WIP-changes archive

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

doomlegacy-devel: Initial work for UMAPINFO support



Module Name:	pkgsrc-wip
Committed By:	Michael Baeuerle <micha%NetBSD.org@localhost>
Pushed By:	micha
Date:		Fri Jan 13 18:02:00 2023 +0100
Changeset:	a606b01a52c77a7d5c9de621caf2041217f3643b

Modified Files:
	doomlegacy-devel/Makefile
	doomlegacy-devel/TODO
	doomlegacy-devel/distinfo
Added Files:
	doomlegacy-devel/files/umapinfo.c
	doomlegacy-devel/files/umapinfo.h
	doomlegacy-devel/patches/patch-make__options__nix
	doomlegacy-devel/patches/patch-src_Makefile
	doomlegacy-devel/patches/patch-src_w__wad.c

Log Message:
doomlegacy-devel: Initial work for UMAPINFO support

Does not work yet.

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

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

diffstat:
 doomlegacy-devel/Makefile                         |   2 +
 doomlegacy-devel/TODO                             |  12 +-
 doomlegacy-devel/distinfo                         |   3 +
 doomlegacy-devel/files/umapinfo.c                 | 171 ++++++++++++++++++++++
 doomlegacy-devel/files/umapinfo.h                 |  82 +++++++++++
 doomlegacy-devel/patches/patch-make__options__nix |  16 ++
 doomlegacy-devel/patches/patch-src_Makefile       |  31 ++++
 doomlegacy-devel/patches/patch-src_w__wad.c       |  49 +++++++
 8 files changed, 360 insertions(+), 6 deletions(-)

diffs:
diff --git a/doomlegacy-devel/Makefile b/doomlegacy-devel/Makefile
index 10839c0e84..ba205e916b 100644
--- a/doomlegacy-devel/Makefile
+++ b/doomlegacy-devel/Makefile
@@ -96,6 +96,8 @@ SUBST_FILES.install=	${WRKDIR}/INSTALL.pkgsrc
 SUBST_SED.install=	-e 's,DOOMWADDIR,${PREFIX}/${DOOMWADDIR},'
 
 pre-configure:
+	${CP} ${FILESDIR}/umapinfo.c ${WRKSRC}/src
+	${CP} ${FILESDIR}/umapinfo.h ${WRKSRC}/src
 	${CP} ${FILESDIR}/INSTALL.pkgsrc ${WRKDIR}
 	${CP} ${FILESDIR}/doomlegacy.sh ${WRKDIR}
 	${CP} ${FILESDIR}/doomlegacy.6.in ${WRKDIR}
diff --git a/doomlegacy-devel/TODO b/doomlegacy-devel/TODO
index 01083e1bb7..434fb263c0 100644
--- a/doomlegacy-devel/TODO
+++ b/doomlegacy-devel/TODO
@@ -1,13 +1,13 @@
 
-Part 23: Import final release
-=============================
-[X] Import version 1.48.10 to pkgsrc
-    Parts 8 to 22 are now available in games/doomlegacy
-
-
 Part 24: Mid-texture rendering
 ==============================
 [ ] Some mid-textures are rendered wrong in Pagodia
+    => Reported upstream in ticket #687
+
+
+Part 25: Add UMAPINFO support
+=============================
+[ ] Based on libdoom-umapinfo
 
 
 EOF
diff --git a/doomlegacy-devel/distinfo b/doomlegacy-devel/distinfo
index f8815f47f4..284b22dfe3 100644
--- a/doomlegacy-devel/distinfo
+++ b/doomlegacy-devel/distinfo
@@ -3,4 +3,7 @@ $NetBSD$
 BLAKE2s (doomlegacy_1.48.12_common.zip) = de8830301f433bc091804e8eaa0452fc574b99bc1d7e0021a71ba81aa6d90b76
 SHA512 (doomlegacy_1.48.12_common.zip) = 955dd60058a4676c5d16b8058754ed9a5e33fe36d7605ed09518ce7c8c675ca6345f793db40f0328e8c78bfbe707880970f442b3a0c355c507ae7cf8a5f908be
 Size (doomlegacy_1.48.12_common.zip) = 1055689 bytes
+SHA1 (patch-make__options__nix) = d8f7f3bd351e66e9cafe3b8e6093878d959fbc51
+SHA1 (patch-src_Makefile) = 7921393b6c4941fd02d9644836991c30b0fb3188
 SHA1 (patch-src_am__map.c) = 14b3c8b70c63778ad043827ab2f0b6f4fe07bcde
+SHA1 (patch-src_w__wad.c) = 237489b5d19e89e36dbf6720467d910cd7b72aa9
diff --git a/doomlegacy-devel/files/umapinfo.c b/doomlegacy-devel/files/umapinfo.c
new file mode 100644
index 0000000000..3809a67dee
--- /dev/null
+++ b/doomlegacy-devel/files/umapinfo.c
@@ -0,0 +1,171 @@
+//----------------------------------------------------------------------------
+//
+// Copyright(C) 2023 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.
+//
+// DESCRIPTION:
+//      Support maps with additional information in UMAPINFO format.
+//
+//----------------------------------------------------------------------------
+//
+// [MB] 2023-01-10: Description of UMAPINFO lump format:
+//      https://doomwiki.org/wiki/UMAPINFO
+
+
+#ifdef HAVE_LIBDOOM_UMAPINFO
+
+
+#include <assert.h>
+#include <stddef.h>
+
+#include "libdoom-umapinfo-0/doom_umi.h"  // libdoom-umapinfo
+
+#include "doomincl.h"
+#include "umapinfo.h"
+#include "w_wad.h"
+#include "z_zone.h"
+
+
+// UMAPINFO data in local format
+umapinfo_t umapinfo = { NULL, 0 };
+
+
+// Initialize map entry
+static void UMI_InitializeMapEntry(umapinfo_t *entry,
+                                   unsigned int episode, unsigned int map)
+{
+    entry->episode         = episode;
+    entry->map             = map;
+
+    entry->levelname       = NULL;
+    entry->label           = NULL;
+    entry->intertext       = NULL;
+    entry->intertextsecret = NULL;
+    entry->levelpic        = NULL;
+    entry->nextmap         = NULL;
+    entry->nextsecret      = NULL;
+    entry->music           = NULL;
+    entry->skytexture      = NULL;
+    entry->endpic          = NULL;
+    entry->exitpic         = NULL;
+    entry->enterpic        = NULL;
+    entry->interbackdrop   = NULL;
+    entry->intermusic      = NULL;
+    entry->bossactions     = NULL;
+    entry->numbossactions  = 0;
+    entry->partime         = 0;
+    entry->nointermission  = false;
+}
+
+
+// Populate map entry
+static int UMI_PopulateMapEntry(doom_umi0_ts_state state, size_t index)
+{
+    unsigned int episode, map;
+    int          res = doom_umi0_ts_map_read(state, &episode, &map);
+
+    if (0 == res)
+    {
+        UMI_InitializeMapEntry(&umapinfo.map[index], episode, map);
+
+        rets = doom_umi0_ts_key_first(state);
+        while (0 == retval)
+        {
+XXX Insert key data
+            res = doom_umi0_ts_key_next(state);
+        }
+    }
+
+    // Only count successfully populated maps
+    if (0 == res)
+    {
+        ++umapinfo.mapnum;
+    }
+}
+
+
+// Import UMAPINFO data
+static void UMI_ImportUMapInfo(umapinfo *umi, doom_umi0_handle data)
+{
+    doom_umi0_ts_state state  = NULL;
+    int                retval = doom_umi0_ts_state_create(&state, data);
+
+    if (0 > retval)
+        GenPrintf(EMSG_warn, "Importing UMAPINFO data failed\n");
+    else
+    {
+        size_t mapnum  = doom_umi0_ts_map_count(state);
+        size_t memsize = sizeof(umapinfo_t) * mapnum;
+        size_t i       = 0;
+
+        assert(memsize / mapnum == mapnum);
+        umapinfo.map    = Z_Malloc(memsize, PU_LEVEL, 0);
+        umapinfo.mapnum = 0;
+
+        retval = doom_umi0_ts_map_first(state);
+        while (0 == retval && mapnum)
+        {
+            retval = UMI_PopulateMapEntry(state, i++);
+            if (0 == retval)
+                retval = doom_umi0_ts_map_first(state);
+        }
+    }
+
+    doom_umi0_ts_state_destroy(&state);
+}
+
+
+// Load and parse UMAPINFO lump
+void UMI_LoadUMapInfoLump(lumpnum_t lumpnum)
+{
+    doom_umi0_handle  data = NULL; // libdoom-umapinfo UMAPINFO object handle
+    int               len  = W_LumpLength(lumpnum);
+
+    assert(0 <= len);
+
+    {
+        unsigned char *lump    = Z_Malloc(len, PU_IN_USE, 0);
+        size_t         length  = len;
+        int            verbose = 0;
+        int            retval  = doom_umi0_create(&data, lump, length, verbose);
+
+        W_ReadLump(lumpnum, lump);
+
+        if (0 > retval)
+            GenPrintf(EMSG_warn, "Parsing UMAPINFO data failed\n");
+        else if (0 < retval)
+            GenPrintf(EMSG_warn, "Error in UMAPINFO, data may be incomplete\n");
+
+        Z_Free(lump);
+
+        if (0 <= retval)
+            UMI_ImportUMapInfo(&umapinfo, data);
+
+        doom_umi0_destroy(&data);
+    }
+}
+
+
+#else  // HAVE_LIBDOOM_UMAPINFO
+
+
+#include "doomincl.h"
+
+
+// Stub if libdoom-umapinfo is not available
+void UMI_LoadUMapInfoLump(lumpnum_t lumpnum)
+{
+    GenPrintf(EMSG_warn, "UMAPINFO ignored (libdoom-umapinfo not available)\n");
+}
+
+
+#endif  // HAVE_LIBDOOM_UMAPINFO
diff --git a/doomlegacy-devel/files/umapinfo.h b/doomlegacy-devel/files/umapinfo.h
new file mode 100644
index 0000000000..8c723ba60b
--- /dev/null
+++ b/doomlegacy-devel/files/umapinfo.h
@@ -0,0 +1,82 @@
+//----------------------------------------------------------------------------
+//
+// Copyright(C) 2023 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.
+//
+// DESCRIPTION:
+//      Support maps with additional information in UMAPINFO format.
+//
+//----------------------------------------------------------------------------
+
+#ifndef UMAPINFO_H
+#define UMAPINFO_H
+
+#include "doomtype.h"
+
+
+typedef struct
+{
+    int thing;    // Thing type
+    int special;  // Line special type
+    int tag;      // Sector tag
+} bossaction_t;
+
+
+// UMAPINFO data for a single map
+typedef struct
+{
+    unsigned int  episode;
+    unsigned int  map;
+
+    char         *levelname;
+    char         *label;
+    char         *intertext;
+    char         *intertextsecret;
+    char         *levelpic;
+    char         *nextmap;
+    char         *nextsecret;
+    char         *music;
+    char         *skytexture;
+    char         *endpic;
+    char         *exitpic;
+    char         *enterpic;
+    char         *interbackdrop;
+    char         *intermusic;
+    bossaction_t *bossactions;
+    unsigned int  numbossactions;
+    unsigned int  partime;
+    boolean       nointermission;
+} mapentry_t;
+
+
+typedef struct
+{
+  mapentry_t   *map;
+  unsigned int  mapnum;
+} umapinfo_t;
+
+
+extern umapinfo_t umapinfo;
+
+
+void UMI_LoadUMapInfoLump(lumpnum_t lumpnum);
+
+
+#if 0
+extern boolean EpiCustom;
+mapentry_t *G_LookupMapinfo(int episode, int map);
+
+boolean UMI_CheckField(char *str);
+#endif
+
+
+#endif  // UMAPINFO_H
diff --git a/doomlegacy-devel/patches/patch-make__options__nix b/doomlegacy-devel/patches/patch-make__options__nix
new file mode 100644
index 0000000000..4aaf9840d6
--- /dev/null
+++ b/doomlegacy-devel/patches/patch-make__options__nix
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Add support for libdoom-umapinfo.
+
+--- make_options_nix.orig	2023-01-11 14:26:40.000000000 +0000
++++ make_options_nix
+@@ -79,6 +79,9 @@ HAVE_LIBZIP=1
+ # Optional, load with dlopen.
+ # HAVE_LIBZIP=3
+ 
++# Support for UMAPINFO lump needs libdoom-umapinfo.
++HAVE_LIBDOOM_UMAPINFO=0
++
+ # Extended nodes require zlib.
+ HAVE_ZLIB=1
+ # Optional, load with dlopen.
diff --git a/doomlegacy-devel/patches/patch-src_Makefile b/doomlegacy-devel/patches/patch-src_Makefile
new file mode 100644
index 0000000000..edbce0c972
--- /dev/null
+++ b/doomlegacy-devel/patches/patch-src_Makefile
@@ -0,0 +1,31 @@
+$NetBSD$
+
+Add support for UMAPINFO.
+
+--- src/Makefile.orig	2023-01-11 14:26:40.000000000 +0000
++++ src/Makefile
+@@ -1281,6 +1281,14 @@ ifdef HAVE_ZLIB
+   endif
+ endif
+ 
++# LIBDOOM_UMAPINFO
++ifdef HAVE_LIBDOOM_UMAPINFO
++  OPTS+=-DHAVE_LIBDOOM_UMAPINFO=$(HAVE_LIBDOOM_UMAPINFO)
++  ifeq ($(HAVE_LIBDOOM_UMAPINFO), 1)
++    LIBS+=-ldoom-umapinfo
++  endif
++endif
++
+ 
+ # compiler and linker flags
+ CFLAGS+=$(WFLAGS)
+@@ -1354,7 +1362,8 @@ console.o command.o \
+ p_saveg.o \
+ tables.o info.o dstrings.o dehacked.o w_wad.o w_zip.o\
+ d_netcmd.o d_clisrv.o d_net.o d_netfil.o i_tcp.o \
+-d_items.o d_main.o
++d_items.o d_main.o \
++umapinfo.o
+ 
+ # combine all objs ( main, INTERFACE specific, asm, CDMUS )
+ OBJS:=$(addprefix $(O)/, $(SMIFOBJS) $(OPTOBJS) $(MOBJS))
diff --git a/doomlegacy-devel/patches/patch-src_w__wad.c b/doomlegacy-devel/patches/patch-src_w__wad.c
new file mode 100644
index 0000000000..d82ff37aed
--- /dev/null
+++ b/doomlegacy-devel/patches/patch-src_w__wad.c
@@ -0,0 +1,49 @@
+$NetBSD$
+
+Add support for UMAPINFO.
+
+--- src/w_wad.c.orig	2023-01-10 10:38:38.711741654 +0000
++++ src/w_wad.c
+@@ -118,6 +118,7 @@
+ #include "d_netfil.h"
+ #include "dehacked.h"
+   // DEH_LoadDehackedLump
++#include "umapinfo.h"
+ #include "r_defs.h"
+ #include "i_system.h"
+ 
+@@ -589,6 +590,8 @@ int W_Load_WadFile ( const char * filena
+ 
+     GenPrintf(EMSG_info, "Added file %s (%i lumps)\n", filenamebuf, numlumps);
+     W_Load_DehackedLumps( filenum );
++    // [MB] 2023-01-10: Process UMAPINFO last for highest priority
++    W_Load_UMapInfoLumps( filenum );
+ 
+     return filenum;
+ 
+@@ -1378,6 +1381,25 @@ void W_Load_DehackedLumps( int wadnum )
+     }
+ }
+ 
++
++// [MB] 2023-01-10: Search for all UMAPINFO lumps in all wads and load them
++void W_Load_UMapInfoLumps( int wadnum )
++{
++    lumpnum_t  clump = 0;
++
++    while (1)
++    {
++        clump = W_CheckNumForNamePwad("UMAPINFO", wadnum, LUMPNUM(clump));
++        if( ! VALID_LUMP(clump) )
++            break;
++        GenPrintf(EMSG_info, "Loading UMAPINFO from %s\n",
++                  wadfiles[wadnum]->filename);
++        UMI_LoadUMapInfoLump(clump);
++        clump++;
++    }
++}
++
++
+ // [WDJ] Return a sum unique to a lump, to detect replacements.
+ // The lumpptr must be to a Z_Malloc lump.
+ uint64_t  W_lump_checksum( void* lumpptr )


Home | Main Index | Thread Index | Old Index