Skip to content

Commit

Permalink
Merge branch 'master' of github.com:chocolate-doom/chocolate-doom
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath committed Sep 13, 2024
2 parents 3e7b32a + e346f88 commit 6e5c5b4
Show file tree
Hide file tree
Showing 25 changed files with 698 additions and 546 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
,clang-analyzer-*
,cppcoreguidelines-*
,-cppcoreguidelines-avoid-magic-numbers
,-cppcoreguidelines-init-variables
,-readability-identifier-length
,-readability-isolate-declaration
,-readability-magic-numbers
- name: Fail fast?!
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ jobs:
run: |
brew install \
automake \
dylibbundler \
sdl2 \
sdl2_mixer \
sdl2_net \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ CFLAGS="$CFLAGS $SDL_CFLAGS ${SAMPLERATE_CFLAGS:-} ${PNG_CFLAGS:-} ${FLUIDSYNTH_
LDFLAGS="$LDFLAGS $SDL_LIBS ${SAMPLERATE_LIBS:-} ${PNG_LIBS:-} ${FLUIDSYNTH_LIBS:-} ${LIBZ_LIBS:-}"
case "$host" in
*-*-mingw* | *-*-cygwin* | *-*-msvc* )
LDFLAGS="$LDFLAGS -lwinmm"
LDFLAGS="$LDFLAGS -lwinmm -lshlwapi"
;;
*)
esac
Expand Down
2 changes: 1 addition & 1 deletion opl/opl_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static void WriteRegister(unsigned int reg_num, unsigned int value)

if ((value & 0x20) == 0)
{
timer1.enabled = (value & 0x02) != 0;
timer2.enabled = (value & 0x02) != 0;
OPLTimer_CalculateEndTime(&timer2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ win32/GNUmakefile \
win32/cp-with-libs \
win32/README

EXTRA_DIST=$(OSX_FILES) $(WIN32_FILES)
EXTRA_DIST=style.html $(OSX_FILES) $(WIN32_FILES)

25 changes: 5 additions & 20 deletions pkg/osx/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ DMG=$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-$(POSTFIX).dmg
TOPLEVEL=../..
TOPLEVEL_DOCS=$(patsubst %,../../%,$(DOC_FILES))

ifeq (, $(shell which dylibbundler))
CP=./cp-with-libs
else
CP=cp
endif

# DMG file containing package:

$(DMG) : tmp.dmg
Expand Down Expand Up @@ -75,26 +69,17 @@ $(STAGING_DIR): launcher $(TOPLEVEL_DOCS) app.icns wadfile.icns
cp launcher "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/launcher"

$(CP) $(TOPLEVEL)/src/$(PROGRAM_PREFIX)doom "$(APP_BIN_DIR)"
./cp-with-libs $(TOPLEVEL)/src/$(PROGRAM_PREFIX)doom "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)doom"
$(CP) $(TOPLEVEL)/src/$(PROGRAM_PREFIX)heretic "$(APP_BIN_DIR)"
./cp-with-libs $(TOPLEVEL)/src/$(PROGRAM_PREFIX)heretic "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)heretic"
$(CP) $(TOPLEVEL)/src/$(PROGRAM_PREFIX)hexen "$(APP_BIN_DIR)"
./cp-with-libs $(TOPLEVEL)/src/$(PROGRAM_PREFIX)hexen "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)hexen"
$(CP) $(TOPLEVEL)/src/$(PROGRAM_PREFIX)strife "$(APP_BIN_DIR)"
./cp-with-libs $(TOPLEVEL)/src/$(PROGRAM_PREFIX)strife "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)strife"
$(CP) $(TOPLEVEL)/src/$(PROGRAM_PREFIX)setup "$(APP_BIN_DIR)"
./cp-with-libs $(TOPLEVEL)/src/$(PROGRAM_PREFIX)setup "$(APP_BIN_DIR)"
$(STRIP) "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)setup"

-dylibbundler --bundle-deps --overwrite-files \
--install-path "@executable_path/" \
--dest-dir "$(APP_BIN_DIR)" \
--fix-file "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)doom" \
--fix-file "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)heretic" \
--fix-file "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)hexen" \
--fix-file "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)strife" \
--fix-file "$(APP_BIN_DIR)/$(PROGRAM_PREFIX)setup"

$(TOPLEVEL)/man/simplecpp -DPRECOMPILED -D__MACOSX__ \
-DDOOM -DHERETIC -DHEXEN -DSTRIFE \
< $(TOPLEVEL)/man/INSTALL.template \
Expand Down
11 changes: 9 additions & 2 deletions pkg/osx/cp-with-libs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ is_sys_lib() {
/System/*)
true
;;
/usr/local/*) # homebrew/manual install
false
;;
/usr/*)
true
;;
Expand Down Expand Up @@ -54,7 +57,7 @@ install_with_deps() {

if [ -e "$dest_file" ]; then
return
fi
fi

echo "Installing $bin_name..."

Expand All @@ -65,7 +68,6 @@ install_with_deps() {
# Copy libraries that this file depends on:

otool -L "$src_file" | tail -n +2 | sed 's/^.//; s/ (.*//' | while read; do

# Don't copy system libraries

if is_sys_lib "$REPLY"; then
Expand All @@ -92,6 +94,11 @@ install_with_deps() {
if is_dylib "$dest_file"; then
install_name_tool -id "@executable_path/$bin_name" "$dest_file"
fi

# The install_name_tool calls above break signatures. Recent versions
# of macOS make signatures mandatory, even if just ad-hoc ones.
codesign --remove-signature "$dest_file"
codesign --force -s - "$dest_file" # ad-hoc signature
}

# Install the file, and recursively install any libraries:
Expand Down
48 changes: 48 additions & 0 deletions pkg/style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

<!-- Tweaks to the pandoc output style to make the resulting HTML
look much nicer. -->

<style>
body {
background-color: white;
margin-top: 1.5em;
margin-bottom: 4em;

max-width: 38em;
margin-left: auto;
margin-right: auto;
box-sizing: border-box;

padding: 0;
padding-left: 1.3em;
padding-right: 1.3em;

font-size: large;
color: #555;
line-height: 1.6;

text-align: justify;
overflow-wrap: break-word;
}

header {
font-family: serif;
margin-top: 0;
margin-bottom: 0.2em;
}

h1, h2, h3, h4, h5, h6 {
margin-top: 0.5em;
margin-bottom: 0.2em;
}

p {
margin-top: 0;
margin-bottom: 0.8em;
}

dl {
margin-block-start: 0.5em;
}
</style>

14 changes: 8 additions & 6 deletions pkg/win32/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ else
POSTFIX=win32
endif

PANDOC_FLAGS = -f gfm -s --template=default.html5 -H ../style.html

DOOM_ZIP=$(PROGRAM_PREFIX)doom-$(PACKAGE_VERSION)-$(POSTFIX).zip
HERETIC_ZIP=$(PROGRAM_PREFIX)heretic-$(PACKAGE_VERSION)-$(POSTFIX).zip
HEXEN_ZIP=$(PROGRAM_PREFIX)hexen-$(PACKAGE_VERSION)-$(POSTFIX).zip
Expand All @@ -32,12 +34,12 @@ $(STRIFE_ZIP): staging-strife hook-strife
# Special hooks to custom modify files for particular games.

hook-doom: staging-doom
-pandoc -f gfm -s -o $</NOT-BUGS.html $(TOPLEVEL)/NOT-BUGS.md
-pandoc $(PANDOC_FLAGS) -o $</NOT-BUGS.html $(TOPLEVEL)/NOT-BUGS.md

# Chocolate Strife has its own custom README file:

hook-strife: staging-strife
-pandoc -f gfm -s -o $</README.html $(TOPLEVEL)/README.Strife.md
-pandoc $(PANDOC_FLAGS) -o $</README.html $(TOPLEVEL)/README.Strife.md

# Build up a staging dir for a particular game.

Expand All @@ -54,11 +56,11 @@ staging-%:
$(STRIP) $@/*.exe $@/*.dll

-for f in $(DOC_FILES); do \
pandoc -f gfm -o $@/$$(basename $$f .md).html \
-s $(TOPLEVEL)/$$f; \
pandoc $(PANDOC_FLAGS) $@/$$(basename $$f .md).html \
$(TOPLEVEL)/$$f; \
done
-pandoc -f gfm -s -o $@/CMDLINE.html $(TOPLEVEL)/man/CMDLINE.$*.md
-pandoc -f gfm -s -o $@/INSTALL.html $(TOPLEVEL)/man/INSTALL.$*
-pandoc $(PANDOC_FLAGS) -o $@/CMDLINE.html $(TOPLEVEL)/man/CMDLINE.$*.md
-pandoc $(PANDOC_FLAGS) -o $@/INSTALL.html $(TOPLEVEL)/man/INSTALL.$*

clean:
rm -f $(ZIPS)
Expand Down
2 changes: 1 addition & 1 deletion quickcheck
Submodule quickcheck updated 3 files
+105 −40 GNUmakefile
+1 −0 extract/.gitignore
+15 −24 testrunner
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ set(GAME_SOURCE_FILES

set(GAME_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/../")

if(MSVC)
if(WIN32)
list(APPEND GAME_SOURCE_FILES
"../win32/win_opendir.c" "../win32/win_opendir.h")

Expand Down Expand Up @@ -146,7 +146,7 @@ if(FluidSynth_FOUND)
list(APPEND EXTRA_LIBS FluidSynth::libfluidsynth)
endif()
if(WIN32)
list(APPEND EXTRA_LIBS winmm)
list(APPEND EXTRA_LIBS winmm shlwapi)
endif()

if(WIN32)
Expand Down
5 changes: 4 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ execgames_SCRIPTS = $(SETUP_BINARIES)
AM_CFLAGS = -I$(top_srcdir)/textscreen \
-I$(top_srcdir)/opl \
-I$(top_srcdir)/pcsound \
-I$(top_srcdir)/win32 \
@SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@

# Common source files used by absolutely everything:
Expand Down Expand Up @@ -120,7 +121,9 @@ w_file.c w_file.h \
w_file_stdc.c \
w_file_posix.c \
w_file_win32.c \
w_merge.c w_merge.h
w_merge.c w_merge.h \
$(top_builddir)/win32/win_opendir.c \
$(top_builddir)/win32/win_opendir.h


MEMORY_NATIVE_SOURCE_FILES=\
Expand Down
1 change: 1 addition & 0 deletions src/d_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static struct {
GameVersion_t version;
} valid_versions[] = {
{ doom, exe_doom_1_2 },
{ doom, exe_doom_1_5 },
{ doom, exe_doom_1_666 },
{ doom, exe_doom_1_7 },
{ doom, exe_doom_1_8 },
Expand Down
1 change: 1 addition & 0 deletions src/d_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef enum
typedef enum
{
exe_doom_1_2, // Doom 1.2: shareware and registered
exe_doom_1_5, // Doom 1.5: "
exe_doom_1_666, // Doom 1.666: for shareware, registered and commercial
exe_doom_1_7, // Doom 1.7/1.7a: "
exe_doom_1_8, // Doom 1.8: "
Expand Down
7 changes: 4 additions & 3 deletions src/doom/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ static const struct
GameVersion_t version;
} gameversions[] = {
{"Doom 1.2", "1.2", exe_doom_1_2},
{"Doom 1.5", "1.5", exe_doom_1_5},
{"Doom 1.666", "1.666", exe_doom_1_666},
{"Doom 1.7/1.7a", "1.7", exe_doom_1_7},
{"Doom 1.8", "1.8", exe_doom_1_8},
Expand Down Expand Up @@ -1151,9 +1152,9 @@ static void InitGameVersion(void)
// @arg <version>
// @category compat
//
// Emulate a specific version of Doom. Valid values are "1.2",
// "1.666", "1.7", "1.8", "1.9", "ultimate", "final", "final2",
// "hacx" and "chex".
// Emulate a specific version of Doom. Valid values are "1.2",
// "1.5", "1.666", "1.7", "1.8", "1.9", "ultimate", "final",
// "final2", "hacx" and "chex".
//

p = M_CheckParmWithArgs("-gameversion", 1);
Expand Down
4 changes: 2 additions & 2 deletions src/doom/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ boolean P_CheckMeleeRange (mobj_t* actor)
pl = actor->target;
dist = P_AproxDistance (pl->x-actor->x, pl->y-actor->y);

if (gameversion <= exe_doom_1_2)
if (gameversion < exe_doom_1_5)
range = MELEERANGE;
else
range = MELEERANGE-20*FRACUNIT+pl->info->radius;
Expand Down Expand Up @@ -958,7 +958,7 @@ void A_SargAttack (mobj_t* actor)

A_FaceTarget (actor);

if (gameversion > exe_doom_1_2)
if (gameversion >= exe_doom_1_5)
{
if (!P_CheckMeleeRange (actor))
return;
Expand Down
2 changes: 1 addition & 1 deletion src/doom/p_inter.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ P_DamageMobj
target->reactiontime = 0; // we're awake now...

if ( (!target->threshold || target->type == MT_VILE)
&& source && (source != target || gameversion <= exe_doom_1_2)
&& source && (source != target || gameversion < exe_doom_1_5)
&& source->type != MT_VILE)
{
// if not intent on another player,
Expand Down
20 changes: 4 additions & 16 deletions src/i_glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "m_misc.h"
#include "config.h"

#if defined(_MSC_VER)
// For Visual C++, we need to include the win_opendir module.
#if defined(_WIN32)
#include <win_opendir.h>
#define S_ISDIR(m) (((m)& S_IFMT) == S_IFDIR)
#elif defined(HAVE_DIRENT_H)
Expand Down Expand Up @@ -102,7 +101,6 @@ glob_t *I_StartMultiGlob(const char *directory, int flags,
int num_globs;
glob_t *result;
va_list args;
char *directory_native;

globs = malloc(sizeof(char *));
if (globs == NULL)
Expand Down Expand Up @@ -141,18 +139,15 @@ glob_t *I_StartMultiGlob(const char *directory, int flags,
return NULL;
}

directory_native = M_ConvertUtf8ToSysNativeMB(directory);

result->dir = opendir(directory_native);
result->dir = opendir(directory);
if (result->dir == NULL)
{
FreeStringList(globs, num_globs);
free(result);
free(directory_native);
return NULL;
}

result->directory = directory_native;
result->directory = M_StringDuplicate(directory);
result->globs = globs;
result->num_globs = num_globs;
result->flags = flags;
Expand Down Expand Up @@ -246,7 +241,6 @@ static boolean MatchesAnyGlob(const char *name, glob_t *glob)
static char *NextGlob(glob_t *glob)
{
struct dirent *de;
char *temp, *ret;

do
{
Expand All @@ -259,13 +253,7 @@ static char *NextGlob(glob_t *glob)
|| !MatchesAnyGlob(de->d_name, glob));

// Return the fully-qualified path, not just the bare filename.
temp = M_StringJoin(glob->directory, DIR_SEPARATOR_S, de->d_name, NULL);

ret = M_ConvertSysNativeMBToUtf8(temp);

free(temp);

return ret;
return M_StringJoin(glob->directory, DIR_SEPARATOR_S, de->d_name, NULL);
}

static void ReadAllFilenames(glob_t *glob)
Expand Down
Loading

3 comments on commit 6e5c5b4

@JNechaevsky
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something goes wrong in TrueColor translucency. Translucent functions no longer working, matters no of their modes (additive or blending).

image

My first though was about using SDL_PIXELFORMAT_ARGB32, but looks likes this is not correct.

@JNechaevsky
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work:

crispy-doom/src/i_video.c
@@ -1631,6 +1631,9 @@
     if (argbbuffer == NULL)
     {
 #ifdef CRISPY_TRUECOLOR
+        int bpp;
+        SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp,
+                                   &rmask, &gmask, &bmask, &amask);
         argbbuffer = SDL_CreateRGBSurfaceWithFormat(
                      0, SCREENWIDTH, SCREENHEIGHT, 32, SDL_PIXELFORMAT_ARGB8888);

@JNechaevsky
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid there is one more problem, now with paletted-only build. Could you please:

  • Compile a non-TrueColor build.
  • Start a new game.
  • Toggle "High resolution rendering" between on and off in Crispness menu.

The program will crash on toggling from high resolution to normal. Backtrace:

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffe544d5bb6 in ntdll!RtlGetCurrentServiceSessionId () from C:\Windows\SYSTEM32\ntdll.dll
(gdb) bt
#0  0x00007ffe544d5bb6 in ntdll!RtlGetCurrentServiceSessionId () from C:\Windows\SYSTEM32\ntdll.dll
#1  0x00007ffe544d47b1 in ntdll!RtlFreeHeap () from C:\Windows\SYSTEM32\ntdll.dll
#2  0x00007ffe538b9c9c in msvcrt!free () from C:\Windows\System32\msvcrt.dll
#3  0x00007ffe0918a23f in ?? () from R:\MSYS\home\Julia\crispy-doom\debug\src\SDL2.dll
#4  0x00007ffe09215935 in ?? () from R:\MSYS\home\Julia\crispy-doom\debug\src\SDL2.dll
#5  0x00007ff717816e2f in I_ReInitGraphics (reinit=13)
    at R:/MSYS/home/Julia/crispy-doom/src/i_video.c:1914
#6  0x00007ff71788c993 in M_CrispyToggleHiresHook ()
    at R:/MSYS/home/Julia/crispy-doom/src/doom/m_crispy.c:420
#7  0x00007ff717837df3 in D_RunFrame () at R:/MSYS/home/Julia/crispy-doom/src/doom/d_main.c:575
#8  0x00007ff717837f07 in D_DoomLoop () at R:/MSYS/home/Julia/crispy-doom/src/doom/d_main.c:621
#9  0x00007ff71783aea1 in D_DoomMain () at R:/MSYS/home/Julia/crispy-doom/src/doom/d_main.c:2440
#10 0x00007ff717801635 in SDL_main (argc=1, argv=0x7aa880)
    at R:/MSYS/home/Julia/crispy-doom/src/i_main.c:91
#11 0x00007ff71789304e in main_getcmdline ()
#12 0x00007ff7178012e9 in __tmainCRTStartup ()
    at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:259
#13 0x00007ff7178013d6 in WinMainCRTStartup ()
    at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:149
(gdb)

The problem is with this line. Commenting out SDL_FreeSurface(argbbuffer) call helps, but it's a no-go and direct way to memory leak. But what else can be done - no idea. 😐

Please sign in to comment.