Compare commits

...
85 Commits
Author SHA1 Message Date
Gustaf Alhäll 89cecb88f5 Update license info 2025-12-06 19:45:35 +01:00
Gustaf Alhäll baf5c8d66b Fix music looping on digital 2025-12-06 19:45:32 +01:00
Gustaf Alhäll 72000c4546 Fix memory leak in AATree string trees 2025-12-06 19:45:29 +01:00
Gustaf Alhäll 82b774b2c3 Fix use-after-free when mobj is removed while still playing sounds 2025-12-06 19:45:27 +01:00
Gustaf Alhäll 3818b9ad1a Limit audio channels to 2 2025-12-05 00:22:09 +01:00
Alug ca8e811bd9 sdl_sound: attempt to fix sounds cutting off
i suck at explaining so just trust. :chonkbuncle:
Game sound handling has no idea which sound it is playing/checking, so a sound that ended frees its slot and it might get occupied again without the game knowing
so just encode the channel number into the sound so we can actually check
2025-12-04 17:52:38 +01:00
Alug 97ca034037 sdl_sound: handle explicit float conversions 2025-12-04 17:52:35 +01:00
Alug ac46f7ed00 add missing Fluidsynth ifdefs 2025-12-04 17:52:32 +01:00
Gustaf Alhäll 0afed59329 Fix MIDI music looping 2025-12-04 17:52:30 +01:00
Gustaf Alhäll ec3a1fee70 Tweak audio settings 2025-12-04 17:52:25 +01:00
Alug 5e8c0c3806 Add chorus and reverb settings to MIDI 2025-12-04 17:52:22 +01:00
Gustaf Alhäll 05ea898345 Fix Haiku build 2025-12-04 17:52:11 +01:00
Gustaf Alhäll 0c1fdc0be8 Fine-tune volume settings 2025-12-04 17:52:08 +01:00
Gustaf Alhäll 0e4c72e6f6 Implement MIDI seeking 2025-12-04 17:52:05 +01:00
Alug 29b83903ef delet the bird music resynching stuff
idk who even wants this, its pain, and even more pain to adapt
2025-12-04 17:52:03 +01:00
Alug 1cae09fa11 sdl_audio: use float M_PI for S_CURVE
meant for floats, prevents implicit double conversions
2025-12-04 17:51:59 +01:00
Alug 4a56819bc3 makefile: move openmpt stuff to before sdl stuff
seems to fix linking openmpt without mixer for some reason oh well
2025-12-01 16:49:11 +01:00
Alug 567a48aac3 sdl_sound: fix -Wmaybe-uninitialized warning 2025-12-01 16:49:08 +01:00
Alug d100401c5f this shouldnt be in sourcefile oops 2025-12-01 16:49:05 +01:00
Alug 6dee9fa561 add back "nearest" resampling from mixer
sdls own resampler uses linear interpolation, which sounds super muffled to me
some may like this, but i dont want to change how the game "sounds"
2025-12-01 16:49:01 +01:00
Alug 5bd7a09d9f force 44100khz sample rate
sounds better to me honestly
2025-12-01 16:48:56 +01:00
Alug 47477c2d03 make gme and tracker music slightly louder
prob needs some adjustment, but both were always quite quiet
2025-12-01 16:48:53 +01:00
Alug cd128a1084 lock audio stream in I_PlaySong
seems to fix weird crashes with gme
2025-12-01 16:48:49 +01:00
Alug 34f2afa3d9 add "audiobuffersize" handling
uses the SDL_AUDIO_DEVICE_SAMPLE_FRAMES hint
2025-12-01 16:48:46 +01:00
Alug 22f285edec disable sound precache for sdl sound 2025-12-01 16:48:43 +01:00
Alug 592abdef96 pitch is a float 2025-12-01 16:48:40 +01:00
Alug a27eee8e2f add few missing audiostream unlocks 2025-12-01 16:48:37 +01:00
Alug 904019d24b fix startup playing a super loud bit of music 2025-12-01 16:48:32 +01:00
Alug c6ca5a6f0f i_video: few type fixes for sdl3 2025-12-01 16:48:29 +01:00
Alug 2392f0484c remove hwr_shutdown call
honestly this didnt help with the issue i had, game should already release all the memory on quit anyways.
this just makes it take longer to quit
2025-12-01 16:48:26 +01:00
Alug 986a131a36 fix a few warnings 2025-12-01 16:48:23 +01:00
Alug e9685ef3e8 port srb2classics sdl audio system
still needs a little work reimplementing everything we got

from: https://codeberg.org/srb2classic/srb2classic/pulls/177
2025-12-01 16:48:18 +01:00
Alug 59f194cb9d fuckit SDL3 2025-12-01 16:48:15 +01:00
Alug 99d5590435 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-30 19:34:36 +01:00
Alug 9b2cfe51d6 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-28 18:24:07 +01:00
Alug 66619f42f9 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-28 18:07:35 +01:00
Alug 890677e2b5 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-27 23:33:28 +01:00
Alug 1105526eb1 fix perfstats freaking out 2025-11-26 10:10:14 +01:00
Alug d963df36f1 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-26 10:10:12 +01:00
Alug 846967cb91 fix compile with HAVE_DISCORDRPC 2025-11-25 20:21:15 +01:00
Alug 6c8862ee4b Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-25 20:16:18 +01:00
Alug a49ea4defd Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 22:43:26 +01:00
Alug 3c776b321d Optimize: move a few strlen calls out of loops
when applicable and the input does not get modified within the loop
needs some testing incase i oversaw something
2025-11-24 20:52:03 +01:00
Alug 1ed9bfc9b4 Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-24 20:50:04 +01:00
Alug a05413d925 fix erronous "Could not set custom resolution" warning on startup
the cvars may have not been initialised yet to anything
just return -2 and ignore
2025-11-24 20:49:45 +01:00
Alug fa9637fba4 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 18:29:05 +01:00
Alug 7f50a09bcd Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 00:35:31 +01:00
Alug e25191d7df Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-24 00:30:49 +01:00
Alug f4d8a903e8 Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-23 23:21:54 +01:00
Alug 8a8cbffd12 I_CheckDesktopRes: use SDL_GetCurrentDisplayMode
instead of SDL_GetDesktopDisplayMode, as the former only returns the display mode from when the window was created, which might not reflect the actual current desktop mode.
Maybe fixes some resolutions being incorrectly reported asa having visual issues
2025-11-23 23:21:47 +01:00
Alug 0adf356325 HACK: abuse batching system for sprites and drawnodes
use batching system without sorting for order sensitive things like sprites and transparent stuff
even despite not being "optimally" sorted, drawing them in one go, instead of directly still gives a nice speed increase in certain cases (on my ryzen 5600 i get around 120fps+ on teiai towers starting area!)
2025-11-23 23:08:09 +01:00
Alug 0fef290858 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-23 22:52:10 +01:00
Alug 2516873ba1 fix signed integer overflow in polygon hash calculation
also gives a speedup on some maps lul
2025-11-22 18:55:30 +01:00
Alug c650394c31 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-22 18:13:54 +01:00
Alug 1fb6c63097 fix dedi compile 2025-11-21 14:45:44 +01:00
Alug e95382075c Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-21 00:00:29 +01:00
Alug 2d9776d792 OpenGL: keep around our drawnodes memory
no need to constantly reallocate new memory
we dont have renderer switch, and the next level will render drawnodes anyways
those wont grow super big also, so theres no big worry about wasting tons of memory
yes i like ceepeepee vectors, how can you tell
2025-11-19 19:27:36 +01:00
Alug 7fa3d119e8 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-19 19:26:41 +01:00
Alug e65741acaa Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-18 16:33:38 +01:00
Alug b36ab31a56 Merge remote-tracking branch 'origin/vidmodestuff' into Saturn-Testing 2025-11-18 16:33:35 +01:00
Alug a335da3473 Merge branch 'Saturn-Next' into Saturn-Testing 2025-11-18 16:21:05 +01:00
Alug c312380944 check if our desired screen res already is in the videomode list
before deciding to rebuild the whole list when changing the resolution cvars
2025-11-18 05:22:50 +01:00
Alug b5bb2b42bf I_FillScreenResolutionsList: shrink list if it is too large
we check against MAXMODEDESCS, which is the maximum of modes the videomode can list
just in case we really get a display with a fuckton of resolutions, which most likely wont ever be the case though
this just removes the smallest modes from the list (accounting for the canonicals), to keep things simple
2025-11-18 04:55:50 +01:00
Alug d074f375ca M_VideoModeMenu: make sure red marked modes take precedence 2025-11-18 04:55:45 +01:00
Alug 6fd14f0a80 M_VideoModeMenu: remove old video mode dupe check 2025-11-18 04:55:41 +01:00
Alug d6bbb2c1b3 use static buffer for windowedModes names
no need to worry about memory management here :chaosleep:
2025-11-18 04:55:36 +01:00
Alug fa66b87965 cmp_resolutions: compare by numbers directly
instead by comparing it with strings
2025-11-18 04:55:30 +01:00
Alug c59d5db03e Merge remote-tracking branch 'origin/Saturn-Next' into vidmodestuff 2025-11-18 04:55:22 +01:00
Alug d2f3d5aa4d anew the testing branch
wiped it out completely
2025-11-17 20:26:49 +01:00
Alug 913b8878d8 Optimize: Use doomednum lookup also when (re)spawning mapthings
not just for loading savegame thinkers
Actually even provides slight runtime performance improvement, but mostly makes levelload faster
2025-11-17 20:26:07 +01:00
Alug f02b9f953e Merge branch 'vidmodestuff' into Saturn-Testing 2025-11-17 20:25:49 +01:00
Alug b6edc90553 mark resolutions listed above the current dektop resolution in red
as they lead to visual errors in openglmode without fbo support
2025-11-09 22:20:57 +01:00
Alug 23735121ff raise MAXWINMODES to 128
YES WINDOWS THANKS VERY MUCH SUPER COOL OF YOU
2025-11-09 20:40:03 +01:00
Alug 20950b698f make sure the default 320x200 mode exists 2025-11-09 20:39:58 +01:00
Alug 44df85d6a4 reduce the scope of this 2025-11-09 20:41:24 +01:00
Alug 42d53f1f6f Merge branch 'Saturn-Next' into vidmodestuff 2025-11-09 20:36:00 +01:00
Alug 48f2d0ff83 make sure our custom res fits within MAXVIDMODES
33 are alot so this probably will never be the case (i hope)
2025-11-09 20:21:30 +01:00
Alug 517723f9c1 handle custom res differently + make VID_NumModes return actual vidmodes
custom resolutions now will be put into the resolution list
which means they are selectable from the menu
2025-11-09 20:16:44 +01:00
Alug 6915077e0f refresh the video menu list if our resolution list changes
if you move the gamewindow to a different display, the video menu will now upadate to the new resolutions
2025-11-09 19:16:36 +01:00
Alug 406dbf333d use a video_mode_t thing for our custom resolution
perhaps we may merge it into windowedmodes? not sure
but this works for now
2025-11-09 19:13:38 +01:00
Alug a730dfd212 fix checking for if display changed 2025-11-09 19:13:35 +01:00
Alug 3058d365f3 no need to call I_FillScreenResolutionsList everywhere
its fine after startup, and when we move our window
2025-11-09 19:13:31 +01:00
Alug ccc453e0b0 fix windowmoved never resetting 2025-11-09 19:13:28 +01:00
Alug c3d02090e4 WIP: remove hardcoded resolutions
much thanks dsda-doom for most of the code for this
TODO:
- resolution menu needs to refresh if the list changes
- clean up
- handle custom resolutions more sane
- figure out the best maximum resolution list size the menu can display
2025-11-09 19:13:25 +01:00
Alug 20cd7621c3 delet numVidModes
wasnt doing anything
2025-11-09 19:13:22 +01:00
43 changed files with 2904 additions and 662 deletions

No files matched your search

+10 -6
View File
@@ -972,6 +972,14 @@ Public License instead of this License. But first, please read
Copyright (C) 1995-2018 Free Software Foundation, Inc.
https://www.gnu.org/software/gettext/
- FluidSynth
Copyright (C) 2000-2025 Peter Hanappe and others.
https://www.fluidsynth.org/
- libsndfile
Copyright (C) 1999-2016 Erik de Castro Lopo
https://libsndfile.github.io/libsndfile/
- mpg123
Copyright (c) 1995-2013 by Michael Hipp and others,
free software under the terms of the LGPL v2.1
@@ -1699,12 +1707,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zlib License
applies to:
- Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/hg.php
- SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/projects/SDL_mixer/
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
https://libsdl.org/
- zlib
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+41
View File
@@ -0,0 +1,41 @@
# Find FluidSynth
# Once done, this will define
#
# FLUIDSYNTH_FOUND - system has FluidSynth
# FLUIDSYNTH_INCLUDE_DIRS - FluidSynth include directories
# FLUIDSYNTH_LIBRARIES - link libraries
include(LibFindMacros)
libfind_pkg_check_modules(FLUIDSYNTH_PKGCONF FLUIDSYNTH)
# includes
find_path(FLUIDSYNTH_INCLUDE_DIR
NAMES fluidsynth.h
PATHS
${FLUIDSYNTH_PKGCONF_INCLUDE_DIRS}
)
# library
find_library(FLUIDSYNTH_LIBRARY
NAMES fluidsynth
PATHS
${FLUIDSYNTH_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
# set include dir variables
set(FLUIDSYNTH_PROCESS_INCLUDES FLUIDSYNTH_INCLUDE_DIR)
set(FLUIDSYNTH_PROCESS_LIBS FLUIDSYNTH_LIBRARY)
libfind_process(FLUIDSYNTH)
if(FLUIDSYNTH_FOUND AND NOT TARGET FluidSynth::libfluidsynth)
add_library(FluidSynth::libfluidsynth UNKNOWN IMPORTED)
set_target_properties(
FluidSynth::libfluidsynth
PROPERTIES
IMPORTED_LOCATION "${FLUIDSYNTH_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FLUIDSYNTH_INCLUDE_DIR}"
)
endif()
+1 -1
View File
@@ -8,6 +8,7 @@ passthru_opts+=\
HAVE_MINIUPNPC\
HAVE_DISCORDRPC DEVELOP\
NOHOLEPUNCH\
NOOPENMPT\
# build with debugging information
ifdef DEBUGMODE
@@ -91,7 +92,6 @@ endif
default_packages:=\
LIBGME/libgme/LIBGME\
OPENMPT/libopenmpt/LIBOPENMPT\
ZLIB/zlib\
$(foreach p,$(default_packages),\
+13 -9
View File
@@ -29,8 +29,19 @@ ifndef NOHW
sources+=sdl/ogl_sdl.c
endif
ifndef NOOPENMPT
LIBOPENMPT_PKGCONFIG?=libopenmpt
$(eval $(call Use_pkg_config,LIBOPENMPT))
opts+=-DHAVE_OPENMPT
endif
NOMIXER=1
ifdef NOMIXER
sources+=sdl/dummy_sound.c
#sources+=sdl/dummy_sound.c
sources+=sdl/sdl_sound.c
SNDFILE_PKGCONFIG?=sndfile
$(eval $(call Use_pkg_config,SNDFILE))
else
opts+=-DHAVE_MIXER
sources+=sdl/mixer_sound.c
@@ -45,15 +56,8 @@ opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c
endif
ifdef SDL_PKGCONFIG
SDL_PKGCONFIG?=sdl3
$(eval $(call Use_pkg_config,SDL))
else
SDL_CONFIG?=$(call Prefix,sdl2-config)
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
$(if $(STATIC),--static-libs,--libs))
$(eval $(call Propogate_flags,SDL))
endif
ifdef MINGW
ifndef NOSDLMAIN
+3 -3
View File
@@ -79,14 +79,14 @@ $(eval $(call _set,LIBOPENMPT))
lib:=../libs/SDL2_mixer/$(mingw)
ifdef SDL
mixer_opts:=-I$(lib)/include/SDL2
mixer_opts:=-I$(lib)/include/SDL3
mixer_libs:=-L$(lib)/lib
lib:=../libs/SDL2/$(mingw)
SDL_opts:=-I$(lib)/include/SDL2\
SDL_opts:=-I$(lib)/include/SDL3\
$(mixer_opts) -Dmain=SDL_main
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
-lmingw32 -lSDL2main -lSDL2 -mwindows
-lmingw32 -lSDL3main -lSDL3 -mwindows
$(eval $(call _set,SDL))
endif
+5 -2
View File
@@ -237,10 +237,13 @@ void COM_ImmedExecute(const char *ptext)
char line[1024] = "";
INT32 quotes;
while (i < strlen(ptext))
const size_t txtlength = strlen(ptext);
while (i < txtlength)
{
quotes = 0;
for (j = 0; i < strlen(ptext); i++,j++)
for (j = 0; i < txtlength; i++,j++)
{
if (ptext[i] == '\"' && !quotes && i > 0 && ptext[i-1] != ' ') // Malformed command
return;
+4 -2
View File
@@ -1457,12 +1457,14 @@ static inline void CL_DrawConnectionStatus(void)
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160);
memset(tempname, 0, sizeof(tempname));
// offset filename to just the name only part
filename += strlen(filename) - nameonlylength(filename);
const size_t filenamelength = strlen(filename);
if (strlen(filename) > sizeof(tempname)-1) // too long to display fully
if (filenamelength > sizeof(tempname)-1) // too long to display fully
{
size_t endhalfpos = strlen(filename)-10;
size_t endhalfpos = filenamelength-10;
// display as first 14 chars + ... + last 10 chars
// which should add up to 27 if our math(s) is correct
snprintf(tempname, sizeof(tempname), "%.14s...%.10s", filename, filename+endhalfpos);
+1 -1
View File
@@ -1264,7 +1264,7 @@ static void IdentifyVersion(void)
if (AddIWAD("extra3.kart", srb2waddir))
found_extra3_kart = true;
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
#if defined (HAVE_SDL)
#define MUSICTEST(str) \
musicpath = va(pandf, srb2waddir, str);\
handle = W_OpenWadFile(&musicpath, false); \
+6 -5
View File
@@ -1079,12 +1079,14 @@ void CloseNetFile(void)
// Receiving a file?
for (i = 0; i < MAX_WADFILES; i++)
{
if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file)
{
fclose(fileneeded[i].file);
// File is not complete delete it
remove(fileneeded[i].filename);
}
}
// Remove PT_FILEFRAGMENT from acknowledge list
Net_AbortPacketType(PT_FILEFRAGMENT);
@@ -1098,17 +1100,16 @@ void nameonly(char *s)
void *ns;
for (j = strlen(s); j != (size_t)-1; j--)
{
if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/'))
{
ns = &(s[j+1]);
len = strlen(ns);
#if 0
memcpy(s, ns, len+1);
#else
memmove(s, ns, len+1);
#endif
memmove(s, ns, len+1);
return;
}
}
}
// Returns the length in characters of the last element of a path.
+4
View File
@@ -115,6 +115,10 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h)
return -1;
}
void VID_RefreshModeList(void)
{
}
void VID_PrepareModeList(void)
{
}
+4 -3
View File
@@ -20,6 +20,7 @@
// but I can't stand that gibberish. D:
#define SOUND_DUMMY 0
#define SOUND_MIXER 1
#define SOUND_SDL 2
#ifndef SOUND
#ifdef HAVE_SDL
@@ -27,7 +28,7 @@
#ifdef HAVE_MIXER
#define SOUND SOUND_MIXER
#else
#define SOUND SOUND_DUMMY
#define SOUND SOUND_SDL
#endif
#else
#define SOUND SOUND_DUMMY
@@ -107,8 +108,8 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v9.1"
#define VERSIONSTRINGW L"Saturn v9.1"
#define VERSIONSTRING "Saturn v9.x - Testing"
#define VERSIONSTRINGW L"Saturn v9.x - Testing "
#define SATURN_TESTING // comment out for saturn release builds!
+13 -7
View File
@@ -237,7 +237,7 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
// This function organizes the geometry collected by HWR_ProcessPolygon calls into batches and uses
// the rendering backend to draw them.
void HWR_RenderBatches(void)
void HWR_RenderBatches(boolean sort)
{
int finalVertexWritePos = 0; // position in finalVertexArray
int finalIndexWritePos = 0; // position in finalVertexIndexArray
@@ -288,10 +288,13 @@ void HWR_RenderBatches(void)
polygonArraySorted[i] = &polygonArray[i];
}
// sort polygons
PS_START_TIMING(ps_hw_batchsorttime);
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (useshader ? comparePolygons : comparePolygonsNoShaders));
PS_STOP_TIMING(ps_hw_batchsorttime);
if (sort)
{
// sort polygons
PS_START_TIMING(ps_hw_batchsorttime);
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), (useshader ? comparePolygons : comparePolygonsNoShaders));
PS_STOP_TIMING(ps_hw_batchsorttime);
}
// sort order
// 1. shader
@@ -300,7 +303,9 @@ void HWR_RenderBatches(void)
// 4. colors + light level
// not sure about what order of the last 2 should be, or if it even matters
PS_START_TIMING(ps_hw_batchdrawtime);
// dont overwrite this on consecutive calls
if (!sort)
PS_START_TIMING(ps_hw_batchdrawtime);
currentShader = polygonArraySorted[0]->shader;
currentTexture = polygonArraySorted[0]->texture;
@@ -495,7 +500,8 @@ void HWR_RenderBatches(void)
polygonArraySize = 0;
unsortedVertexArraySize = 0;
PS_STOP_TIMING(ps_hw_batchdrawtime);
if (!sort)
PS_STOP_TIMING(ps_hw_batchdrawtime);
}
#endif // HWRENDER
+1 -1
View File
@@ -37,7 +37,7 @@ typedef struct
void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void);
void HWR_RenderBatches(boolean sort);
#ifdef __cplusplus
} // extern "C"
+35 -29
View File
@@ -14,6 +14,7 @@
#ifdef HWRENDER
#include <algorithm>
#include <vector>
#include "../doomstat.h"
#include "../doomdef.h"
@@ -4185,6 +4186,7 @@ static int CompareVisSprites(const void *p1, const void *p2)
static void HWR_SortVisSprites(void)
{
UINT32 i;
for (i = 0; i < gl_visspritecount; i++)
{
gl_vsprorder[i] = HWR_GetVisSprite(i);
@@ -4253,38 +4255,29 @@ typedef struct
// initial size of drawnode array
#define DRAWNODES_INIT_SIZE 64
gl_drawnode_t *drawnodes = NULL;
INT32 numdrawnodes = 0;
INT32 alloceddrawnodes = 0;
// no reason to waste all the allocations since every map will have atleast one translucent thing
static std::vector<gl_drawnode_t> drawnodes;
static void *HWR_CreateDrawNode(gl_drawnode_type_t type)
{
gl_drawnode_t *drawnode;
// if we didnt alloc anything yet, reserve atleast 64 nodes
// dont declare with it as we want our size to be 0!
drawnodes.reserve(DRAWNODES_INIT_SIZE);
if (!drawnodes)
{
alloceddrawnodes = DRAWNODES_INIT_SIZE;
drawnodes = static_cast<gl_drawnode_t*>(Z_Malloc(alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes));
}
else if (numdrawnodes >= alloceddrawnodes)
{
alloceddrawnodes *= 2;
Z_Realloc(drawnodes, alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes);
}
drawnode = &drawnodes[numdrawnodes++];
drawnode->type = type;
drawnodes.emplace_back();
drawnodes.back().type = type;
// not sure if returning different pointers to a union is necessary
switch (type)
{
case DRAWNODE_PLANE:
return &drawnode->u.plane;
return &drawnodes.back().u.plane;
case DRAWNODE_POLYOBJECT_PLANE:
return &drawnode->u.polyplane;
return &drawnodes.back().u.polyplane;
case DRAWNODE_WALL:
return &drawnode->u.wall;
return &drawnodes.back().u.wall;
}
return NULL;
}
@@ -4348,11 +4341,15 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2)
// Sorts and renders the list of drawnodes for the scene being rendered.
static void HWR_RenderDrawNodes(void)
{
INT32 i = 0, run_start = 0;
size_t i = 0, run_start = 0;
static std::vector<INT32> sortindex;
sortindex.reserve(DRAWNODES_INIT_SIZE);
// Array for storing the rendering order.
// A list of indices into the drawnodes array.
INT32 *sortindex;
const size_t numdrawnodes = drawnodes.size();
if (!numdrawnodes)
return;
@@ -4361,7 +4358,7 @@ static void HWR_RenderDrawNodes(void)
PS_START_TIMING(ps_hw_nodesorttime);
sortindex = static_cast<INT32*>(Z_Malloc(sizeof(INT32) * numdrawnodes, PU_STATIC, NULL));
sortindex.resize(numdrawnodes);
// Reversed order
for (i = 0; i < numdrawnodes; i++)
@@ -4377,7 +4374,7 @@ static void HWR_RenderDrawNodes(void)
if (drawnodes[sortindex[run_start]].type == DRAWNODE_PLANE)
{
// found it, now look for run end
INT32 run_end; // (inclusive)
size_t run_end; // (inclusive)
for (i = run_start+1; i < numdrawnodes; i++)
{
@@ -4390,7 +4387,7 @@ static void HWR_RenderDrawNodes(void)
if (run_end > run_start) // if there are multiple consecutive planes, not just one
{
// consecutive run of planes found, now sort it
qs22j(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes);
qs22j(sortindex.data() + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes);
}
run_start = run_end + 1; // continue looking for runs coming right after this one
@@ -4409,6 +4406,9 @@ static void HWR_RenderDrawNodes(void)
// Okay! Let's draw it all! Woo!
GL_SetTransform(&atransform);
if (LIKELY(cv_glbatching.value))
HWR_StartBatching();
for (i = 0; i < numdrawnodes; i++)
{
gl_drawnode_t *drawnode = &drawnodes[sortindex[i]];
@@ -4462,9 +4462,10 @@ static void HWR_RenderDrawNodes(void)
PS_STOP_TIMING(ps_hw_nodedrawtime);
numdrawnodes = 0;
if (LIKELY(cv_glbatching.value))
HWR_RenderBatches(false);
Z_Free(sortindex);
drawnodes.clear(); // clear so our size is 0 again!
}
@@ -5468,6 +5469,7 @@ void HWR_SetTransform(float fpov)
void HWR_ClearClipper(void)
{
const angle_t a1 = gld_FrustumAngle(gl_aimingangle);
gld_clipper_Clear();
gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1);
#ifdef HAVE_SPHEREFRUSTRUM
@@ -5552,7 +5554,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
{
if (allow_portals && rootportal)
{
HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search
HWR_PortalFrame(rootportal); // for portalclipsector, it could have gone null from search
HWR_PortalClipping(rootportal);
}
}
@@ -5602,7 +5604,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
PS_STOP_TIMING(ps_bsptime);
if (LIKELY(cv_glbatching.value))
HWR_RenderBatches();
HWR_RenderBatches(true);
// Check for new console commands.
NetUpdate();
@@ -5629,11 +5631,15 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool
HWR_SortVisSprites();
PS_STOP_TIMING(ps_hw_spritesorttime);
PS_START_TIMING(ps_hw_spritedrawtime);
if (LIKELY(cv_glbatching.value))
HWR_StartBatching();
if (UNLIKELY(cv_glmdls.value))
HWR_DrawSprites<DrawSpritesType::kModels>();
else
HWR_DrawSprites<DrawSpritesType::kSprites>();
PS_STOP_TIMING(ps_hw_spritedrawtime);
if (LIKELY(cv_glbatching.value))
HWR_RenderBatches(false);
ps_numdrawnodes.value.i = 0;
ps_hw_nodesorttime.value.p = 0;
+1 -1
View File
@@ -27,7 +27,7 @@ extern "C" {
#ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED
#include "SDL_opengl.h" //Alam_GBC: Simple, yes?
#include <SDL3/SDL_opengl.h> //Alam_GBC: Simple, yes?
#else
#include <GL/gl.h>
+24 -17
View File
@@ -596,12 +596,12 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
}
// Only servers/admins can CSAY.
if(!server && !(IsPlayerAdmin(consoleplayer)))
if (!server && !(IsPlayerAdmin(consoleplayer)))
flags &= ~HU_CSAY;
// We handle HU_SERVER_SAY, not the caller.
flags &= ~HU_SERVER_SAY;
if(dedicated && !(flags & HU_CSAY))
if (dedicated && !(flags & HU_CSAY))
flags |= HU_SERVER_SAY;
buf[0] = target;
@@ -615,17 +615,20 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
strlcat(msg, COM_Argv(ix + usedargs), msgspace);
}
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
const size_t msglength = strlen(msg);
if (msglength > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{
// what we're gonna do now is check if the node exists
// with that logic, characters 4 and 5 are our numbers:
const char *newmsg;
INT32 spc = 1; // used if nodenum[1] is a space.
char *nodenum = (char*) malloc(3);
CLEANUP(pfree) char *nodenum = (char*) malloc(3);
memcpy(nodenum, msg+3, 2);
nodenum[2] = '\0';
// check for undesirable characters in our "number"
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
{
// check if nodenum[1] is a space
if (nodenum[1] == ' ')
@@ -634,23 +637,21 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
else
{
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
free(nodenum);
return;
}
}
// I'm very bad at C, I swear I am, additional checks eww!
if (spc != 0)
{
if (msg[5] != ' ')
{
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
free(nodenum);
return;
}
}
target = atoi((const char*) nodenum); // turn that into a number
free(nodenum);
//CONS_Printf("%d\n", target);
// check for target player, if it doesn't exist then we can't send the message!
@@ -661,12 +662,13 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same
return;
}
buf[0] = target;
newmsg = msg+5+spc;
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
}
SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf);
SendNetXCmd(XD_SAY, buf, msglength + 1 + msg-buf);
}
/** Send a message to everyone.
@@ -917,10 +919,12 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
return;
}
const size_t msglength = strlen(msg);
//check for invalid characters (0x80 or above)
{
size_t i;
const size_t j = strlen(msg);
const size_t j = msglength;
for (i = 0; i < j; i++)
{
if (msg[i] & 0x80)
@@ -967,7 +971,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
}
// Handle "/me" actions, but only in messages to everyone.
if (target == 0 && strlen(msg) > 4 && strnicmp(msg, "/me ", 4) == 0)
if (target == 0 && msglength > 4 && strnicmp(msg, "/me ", 4) == 0)
{
msg += 4;
action = true;
@@ -1149,10 +1153,12 @@ static boolean HU_clearChatSpaces(void)
size_t i = 0; // Used to just check our message
char c; // current character we're iterating.
boolean nothingbutspaces = true;
const size_t chatlength = strlen(w_chat_buf);
for (; i < strlen(w_chat_buf); i++) // iterate through message and eradicate all spaces that don't belong.
for (; i < chatlength; i++) // iterate through message and eradicate all spaces that don't belong.
{
c = w_chat_buf[i];
if (!c)
break; // if there's nothing, it's safe to assume our message has ended, so let's not waste any more time here.
@@ -1161,6 +1167,7 @@ static boolean HU_clearChatSpaces(void)
nothingbutspaces = false;
}
}
return nothingbutspaces;
}
@@ -1207,11 +1214,11 @@ static void HU_SendChatMessage(void)
return;
}
size_t len = strlen(msg);
const size_t msglength = strlen(msg);
if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute
if (msglength >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute
{
if (len > 6)
if (msglength > 6)
DoMute(msg+6);
else
HU_AddChatText("\x82NOTICE: \x80Usage: /mute <name|node>", false);
@@ -1219,7 +1226,7 @@ static void HU_SendChatMessage(void)
return;
}
if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
if (msglength > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{
INT32 spc = 1; // used if nodenum[1] is a space.
const char *newmsg;
@@ -1991,7 +1998,7 @@ static void HU_DrawChat(void)
longest_name_length = max(longest_name_length, strlen(player_names[i]));
}
for(i = 0; i < MAXPLAYERS; i++)
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
-2
View File
@@ -158,8 +158,6 @@ UINT32 I_GetSongLoopPoint(void);
boolean I_SetSongPosition(UINT32 position);
UINT32 I_GetSongPosition(void);
void I_UpdateSongLagThreshold (void);
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
+2
View File
@@ -95,6 +95,7 @@ INT32 VID_SetMode(INT32 modenum);
*/
const char *VID_GetModeName(INT32 modenum);
void VID_RefreshModeList(void);
void VID_PrepareModeList(void);
/** \brief can video system do fullscreen
@@ -121,6 +122,7 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale);
UINT32 I_GetRefreshRate(void);
boolean I_CheckAboveDesktopRes(INT32 width, INT32 height);
boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void);
+3 -1
View File
@@ -4468,7 +4468,9 @@ static void K_drawLapStartAnim(void)
V_DrawFixedPatch(leftx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2, 6)], NULL);
char *lapnum = va("%02d", stplyr->laps + 1);
for (int i = 0; i < (int)strlen(lapnum); i++)
const size_t laplength = strlen(lapnum);
for (int i = 0; i < (int)laplength; i++)
{
int digit = lapnum[i] - '0';
int frame = min(2, progress/2 - 8 - (i*2));
+6 -4
View File
@@ -49,17 +49,19 @@ aatree_t *M_AATreeAlloc(UINT32 flags)
return aatree;
}
static void M_AATreeFree_Node(aatree_node_t *node)
static void M_AATreeFree_Node(aatree_node_t *node, bool is_string)
{
if (node->left) M_AATreeFree_Node(node->left);
if (node->right) M_AATreeFree_Node(node->right);
if (node->left) M_AATreeFree_Node(node->left, is_string);
if (node->right) M_AATreeFree_Node(node->right, is_string);
if (is_string)
Z_Free(node->value);
Z_Free(node);
}
void M_AATreeFree(aatree_t *aatree)
{
if (aatree->root)
M_AATreeFree_Node(aatree->root);
M_AATreeFree_Node(aatree->root, (aatree->flags & AATREE_STRING) == AATREE_STRING);
Z_Free(aatree);
}
+47 -55
View File
@@ -88,8 +88,8 @@
#include "z_zone.h"
#include "mserv.h"
#if defined(HAVE_SDL)
#include "SDL.h"
#if defined (HAVE_SDL)
#include <SDL3/SDL.h>
#if SDL_VERSION_ATLEAST(2,0,0)
#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG
#endif
@@ -282,7 +282,6 @@ static void M_SetupMultiHandler(INT32 choice);
// Options
// Split into multiple parts due to size
static void M_VideoModeMenu(INT32 choice);
static void M_Setup1PControlsMenu(void);
static void M_Setup2PControlsMenu(void);
static void M_Setup3PControlsMenu(void);
@@ -505,7 +504,6 @@ static INT32 M_ShiftChar(INT32 ch)
// Pretty and consistent ^u^
// See also G_GetGametypeColor.
//
static INT32 highlightflags, recommendedflags, warningflags;
inline static void M_GetGametypeColor(void)
@@ -2827,8 +2825,9 @@ static void M_DrawCenteredMenu(void)
static inline size_t M_StringHeight(const char *string)
{
size_t h = 8, i;
const size_t strlength = strlen(string);
for (i = 0; i < strlen(string); i++)
for (i = 0; i < strlength; i++)
if (string[i] == '\n')
h += 8;
@@ -9617,14 +9616,11 @@ static void M_ResetControls(INT32 choice)
// ===============
//added : 30-01-98:
#define MAXCOLUMNMODES 12 //max modes displayed in one column
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
static modedesc_t modedescs[MAXMODEDESCS];
static void M_VideoModeMenu(INT32 choice)
void M_VideoModeMenu(INT32 choice)
{
INT32 i, j, vdup, nummodes, width, height;
INT32 i, nummodes, width, height;
const char *desc;
(void)choice;
@@ -9638,54 +9634,30 @@ static void M_VideoModeMenu(INT32 choice)
nummodes = VID_NumModes();
// DOS does not skip mode 0, because mode 0 is ALWAYS present
i = 0;
for (; i < nummodes && vidm_nummodes < MAXMODEDESCS; i++)
for (i = 0; i < nummodes && vidm_nummodes < MAXMODEDESCS; i++)
{
desc = VID_GetModeName(i);
if (desc)
{
vdup = 0;
// when a resolution exists both under VGA and VESA, keep the
// VESA mode, which is always a higher modenum
for (j = 0; j < vidm_nummodes; j++)
{
if (fastcmp(modedescs[j].desc, desc))
{
// mode(0): 320x200 is always standard VGA, not vesa
if (modedescs[j].modenum)
{
modedescs[j].modenum = i;
vdup = 1;
if (!desc)
continue;
if (i == vid.modenum)
vidm_selected = j;
}
else
vdup = 1;
modedescs[vidm_nummodes].modenum = i;
modedescs[vidm_nummodes].desc = desc;
break;
}
}
if (i == vid.modenum)
vidm_selected = vidm_nummodes;
if (!vdup)
{
modedescs[vidm_nummodes].modenum = i;
modedescs[vidm_nummodes].desc = desc;
// Pull out the width and height
sscanf(desc, "%u%*c%u", &width, &height);
if (i == vid.modenum)
vidm_selected = vidm_nummodes;
// Show resolutions above desktop res as red.
if (I_CheckAboveDesktopRes(width, height))
modedescs[vidm_nummodes].goodratio = 2;
// Show multiples of 320x200 as green.
else if (SCR_IsAspectCorrect(width, height))
modedescs[vidm_nummodes].goodratio = 1;
// Pull out the width and height
sscanf(desc, "%u%*c%u", &width, &height);
// Show multiples of 320x200 as green.
if (SCR_IsAspectCorrect(width, height))
modedescs[vidm_nummodes].goodratio = 1;
vidm_nummodes++;
}
}
vidm_nummodes++;
}
vidm_column_size = (vidm_nummodes+2) / 3;
@@ -9874,7 +9846,11 @@ static void M_DrawVideoMode(void)
V_DrawString(row, col, highlightflags|MENUCAPS, modedescs[i].desc);
// Show multiples of 320x200 as green.
else
V_DrawString(row, col, ((modedescs[i].goodratio) ? recommendedflags : 0)|MENUCAPS, modedescs[i].desc);
{
const UINT8 goodratio = modedescs[i].goodratio;
const INT32 goodflag = ((goodratio == 2) ? warningflags : (goodratio == 1) ? recommendedflags : 0);
V_DrawString(row, col, goodflag|MENUCAPS, modedescs[i].desc);
}
col += 8;
if ((i % vidm_column_size) == (vidm_column_size-1))
@@ -9898,7 +9874,6 @@ static void M_DrawVideoMode(void)
va("Wait %d second%s", testtime, (testtime > 1) ? "s" : ""));
M_CentreText(OP_VideoModeDef.y + 158,
"or press ESC to return");
}
else
{
@@ -9914,9 +9889,26 @@ static void M_DrawVideoMode(void)
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 138,
recommendedflags|MENUCAPS, "Marked modes are recommended.");
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 146,
highlightflags|MENUCAPS, "Other modes may have visual errors.");
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 158,
highlightflags|MENUCAPS, "Larger modes may have performance issues.");
warningflags|MENUCAPS, "Marked modes are above Desktop resolution");
if (rendermode == render_opengl)
{
#ifdef USE_FBO_OGL
if (!cv_glframebuffer.value)
#endif
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 154,
warningflags|MENUCAPS, "and will have visual errors in OpenGL mode.");
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 166,
highlightflags|MENUCAPS, "Other modes may have visual errors.");
}
else
{
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 154,
highlightflags|MENUCAPS, "Other modes may have visual errors.");
V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 166,
highlightflags|MENUCAPS, "Larger modes may have performance issues.");
}
}
// Draw the cursor for the VidMode menu
+5
View File
@@ -223,6 +223,11 @@ extern menu_t *currentMenu;
extern menu_t MainDef;
extern menu_t SP_LoadDef;
#define MAXCOLUMNMODES 12 //max modes displayed in one column
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
extern menu_t OP_VideoModeDef;
void M_VideoModeMenu(INT32 choice);
// Call upon joystick hotplug
void M_SetupJoystickMenu(INT32 choice);
extern menu_t OP_JoystickSetDef;
+12 -7
View File
@@ -1153,6 +1153,13 @@ static menuitem_t OP_SoundAdvancedMenu[] =
{IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35},
#endif
#ifdef HAVE_FLUIDSYNTH
{IT_HEADER, NULL, "MIDI Settings", NULL, NULL, OPENMPT_MENUOFFSET},
{IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Sound Font File", NULL, &cv_midisoundfontpath, OPENMPT_MENUOFFSET+12},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chorus", NULL, &cv_midichorus, OPENMPT_MENUOFFSET+40},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Reverb", NULL, &cv_midireverb, OPENMPT_MENUOFFSET+50},
#endif
{IT_HEADER, NULL, "Misc", NULL, 45},
{IT_STRING | IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 55},
@@ -1180,6 +1187,11 @@ static const char* OP_SoundAdvancedTooltips[] =
"Which Amiga should be used for .mod playback?",
#endif
"How far should the four channels in .mod be panned?",
#endif
#ifdef HAVE_FLUIDSYNTH
"Which MIDI soundfont to use",
"Controls the chorus of MIDI playback\n setting this too high might cause some instruments to be overexposed",
"Controls the reverb of MIDI playback\n setting this too high might cause notes to be drawn out",
#endif
NULL,
"How many times is the same sound allowed to play at once?\nIf 0 theres no limit.",
@@ -2180,9 +2192,6 @@ static menuitem_t OP_AdvancedBirdMenu[] =
{IT_STRING | IT_CVAR, NULL, "Fade Back from Grow", &cv_growmusicfade, 20},
{IT_STRING | IT_CVAR, NULL, "Fade Out Before Respawning", &cv_respawnfademusicout, 30},
{IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40},
{IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60},
{IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70},
};
static const char* OP_AdvancedBirdTooltips[] =
@@ -2192,8 +2201,6 @@ static const char* OP_AdvancedBirdTooltips[] =
"Fade in music after Grow.",
"Fade out music before respawning.",
"Fade in music while respawning.",
"Threshold for syncing music.",
"Only sync special music.",
};
enum
@@ -2203,8 +2210,6 @@ enum
fadegrow,
respawnfadeout,
respawnfadein,
syncthreshold,
syncspecialonly,
};
menuitem_t OP_CustomCvarMenu[MAXMENUCCVARS];
+7 -6
View File
@@ -1693,22 +1693,23 @@ char *M_GetToken(const char *inputString)
}
const char * M_Ftrim (double f)
const char * M_Ftrim(double f)
{
static char dig[9];/* "0." + 6 digits (6 is printf's default) */
int i;
/* I know I said it's the default, but just in case... */
sprintf(dig, "%.6f", fabs(modf(f, &f)));
/* trim trailing zeroes */
for (i = strlen(dig)-1; dig[i] == '0'; --i)
;
if (dig[i] == '.')/* :NOTHING: */
return "";
else
{
dig[i + 1] = '\0';
return &dig[1];/* skip the 0 */
}
dig[i + 1] = '\0';
return &dig[1];/* skip the 0 */
}
/** Count bits in a number.
+3
View File
@@ -272,6 +272,9 @@ extern consvar_t cv_gravity;
void P_RespawnSpecials(void);
extern mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX];
void CalculateDoomednumToMobjtype(void);
mobj_t *P_AllocateMobj(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
+39 -32
View File
@@ -10448,6 +10448,21 @@ void P_PrecipitationEffects(void)
}
}
mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX];
void CalculateDoomednumToMobjtype(void)
{
memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype));
for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++)
{
if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX)
{
g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i;
}
}
}
//
// P_RespawnSpecials
//
@@ -10527,11 +10542,9 @@ void P_RespawnSpecials(void)
ss = R_PointInSubsector(x, y);
// find which type to spawn
for (i = 0; i < NUMMOBJTYPES; i++)
if (mthing->type == mobjinfo[i].doomednum)
break;
i = g_doomednum_to_mobjtype[mthing->type];
if (i == NUMMOBJTYPES) // prevent creation of objects with this type -- Monster Iestyn 17/12/17
if (i <= MT_NULL || i >= NUMMOBJTYPES) // prevent creation of objects with this type -- Monster Iestyn 17/12/17
{
// 3D Mode start Thing is unlikely to be added to the que,
// so don't bother checking for that specific type
@@ -10972,11 +10985,9 @@ void P_SpawnMapThing(mapthing_t *mthing)
if (objectplacing)
{
// find which type to spawn
for (i = 0; i < NUMMOBJTYPES; i++)
if (mthing->type == mobjinfo[i].doomednum)
break;
i = g_doomednum_to_mobjtype[mthing->type];
if (i == NUMMOBJTYPES)
if (i <= MT_NULL || i >= NUMMOBJTYPES)
{
if (mthing->type == 3328) // 3D Mode start Thing
return;
@@ -11044,13 +11055,9 @@ void P_SpawnMapThing(mapthing_t *mthing)
}
// find which type to spawn
for (i = 0; i < NUMMOBJTYPES; i++)
{
if (mthing->type == mobjinfo[i].doomednum)
break;
}
i = g_doomednum_to_mobjtype[mthing->type];
if (i == NUMMOBJTYPES)
if (i <= MT_NULL || i >= NUMMOBJTYPES)
{
if (mthing->type == 3328) // 3D Mode start Thing
return;
@@ -11743,32 +11750,32 @@ ML_NOCLIMB : Direction not controllable
if (mobj->flags & MF_MONITOR)
{
// flag for strong/weak random boxes
if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum ||
mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum ||
mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum ||
mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum ||
mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum ||
mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum)
if (i == MT_SUPERRINGBOX || i == MT_PRUP ||
i == MT_SNEAKERTV || i == MT_INV ||
i == MT_WHITETV || i == MT_GREENTV ||
i == MT_YELLOWTV || i == MT_BLUETV ||
i == MT_BLACKTV || i == MT_PITYTV ||
i == MT_RECYCLETV || i == MT_MIXUPBOX)
mobj->flags2 |= MF2_AMBUSH;
}
else if (mthing->type != mobjinfo[MT_AXIS].doomednum &&
mthing->type != mobjinfo[MT_AXISTRANSFER].doomednum &&
mthing->type != mobjinfo[MT_AXISTRANSFERLINE].doomednum &&
mthing->type != mobjinfo[MT_NIGHTSBUMPER].doomednum &&
mthing->type != mobjinfo[MT_STARPOST].doomednum)
else if (
i != MT_AXIS &&
i != MT_AXISTRANSFER &&
i != MT_AXISTRANSFERLINE &&
i != MT_NIGHTSBUMPER &&
i != MT_STARPOST)
mobj->flags2 |= MF2_AMBUSH;
}
if (mthing->options & MTF_OBJECTSPECIAL)
{
// flag for strong/weak random boxes
if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum ||
mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum ||
mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum ||
mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum ||
mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum ||
mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum)
if (i == MT_SUPERRINGBOX || i == MT_PRUP ||
i == MT_SNEAKERTV || i == MT_INV ||
i == MT_WHITETV || i == MT_GREENTV ||
i == MT_YELLOWTV || i == MT_BLUETV ||
i == MT_BLACKTV || i == MT_PITYTV ||
i == MT_RECYCLETV || i == MT_MIXUPBOX)
mobj->flags2 |= MF2_STRONGBOX;
// Requires you to be in bonus time to activate
-19
View File
@@ -1965,21 +1965,6 @@ FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player)
// Loads a mobj_t from a save game
//
static mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX];
static void CalculateDoomednumToMobjtype(void)
{
memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype));
for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++)
{
if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX)
{
g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i;
}
}
}
static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
{
mobj_t *mobj;
@@ -2879,10 +2864,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
if (READUINT32(save->p) != ARCHIVEBLOCK_THINKERS)
I_Error("Bad $$$.sav at archive block Thinkers");
// Pre-calculate this lookup, because it was wasting
// a shit ton of time loading mobj thinkers.
CalculateDoomednumToMobjtype();
// remove all the current thinkers
for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = next)
{
+6
View File
@@ -812,6 +812,8 @@ static void P_LoadSectors(UINT8 *data)
ss->tag = SHORT(ms->tag);
ss->flags |= SF_FLIPSPECIAL_FLOOR;
ss->soundorg.thinker.function = (actionf_p1)P_MobjThinker;
}
// set the sky flat num
@@ -2861,6 +2863,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
P_ResetDynamicSlopes();
// Pre-calculate this lookup, because it was wasting
// a shit ton of time loading mobj thinkers.
CalculateDoomednumToMobjtype();
P_SpawnMapThings();
P_SpawnEmblems(!fromnetsave);
+6 -1
View File
@@ -3986,7 +3986,12 @@ DoneSection2:
player->tossdelay = 3;
}
#if 0
// Event - Final Lap
// Still works for GME, but disabled for consistency
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1))
S_SpeedMusic(1.2f);
#endif
if (player->laps >= (unsigned)cv_numlaps.value)
{
if (P_IsLocalPlayer(player))
+19 -17
View File
@@ -58,7 +58,7 @@ static void AmigaType_OnChange(void);
#endif
static CV_PossibleValue_t audbuffersize_cons_t[] = {{128, "128"}, {256, "256"}, {512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}};
consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL|CV_NOINIT, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL};
// stereo reverse
consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -94,14 +94,6 @@ consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_
consvar_t cv_pausemusic = {"playmusicifpaused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
//bird music stuff
static CV_PossibleValue_t music_resync_threshold_cons_t[] = {
{0, "MIN"},
{1000, "MAX"},
{0}
};
consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -281,6 +273,12 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&cv_gamesounds);
CV_RegisterVar(&cv_gamedigimusic);
#ifdef HAVE_FLUIDSYNTH
CV_RegisterVar(&cv_midisoundfontpath);
CV_RegisterVar(&cv_midichorus);
CV_RegisterVar(&cv_midireverb);
#endif
CV_RegisterVar(&cv_samesoundlimit);
// bird music stuff
@@ -288,9 +286,6 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&cv_playsoundifunfocused);
CV_RegisterVar(&cv_pausemusic);
CV_RegisterVar(&cv_music_resync_threshold);
CV_RegisterVar(&cv_music_resync_powerups_only);
CV_RegisterVar(&cv_invincmusicfade);
CV_RegisterVar(&cv_growmusicfade);
@@ -362,6 +357,7 @@ boolean S_SoundDisabled(void)
int S_CacheSound(void)
{
#if SOUND == SOUND_MIXER
if (sound_disabled)
return SOUNDCACHE_OFF;
@@ -369,6 +365,9 @@ int S_CacheSound(void)
return SOUNDCACHE_PRECACHE;
return cv_cachesound.value;
#else
return SOUNDCACHE_OFF;
#endif
}
// Stop all sounds, load level info, THEN start sounds.
@@ -772,9 +771,14 @@ void S_UpdateSounds(void)
volume = c->volume; // 8 bits internal volume precision
sep = NORM_SEP;
if (P_MobjWasRemoved(c->origin))
{
// origin was removed, stop the music
S_StopChannel(cnum);
}
// check non-local sounds for distance clipping
// or modify their params
if (c->origin)
else
{
boolean itsUs = false;
@@ -1642,7 +1646,7 @@ UINT32 S_GetMusicPosition(void)
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
if (S_MusicExists(mname, false, true)) // check non midis first
return W_GetNumForName(va("o_%s", mname));
return W_GetNumForName(va("O_%s", mname));
if (S_MusicExists(mname, true, false))
{
@@ -1650,7 +1654,7 @@ static lumpnum_t S_GetMusicLumpNum(const char *mname)
CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname);
return LUMPERROR;
#else
return W_GetNumForName(va("d_%s", mname));
return W_GetNumForName(va("D_%s", mname));
#endif
}
@@ -1709,8 +1713,6 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
if (S_MusicDisabled())
return false;
I_UpdateSongLagThreshold();
if ((!fadeinms && !I_PlaySong(looping)) ||
(fadeinms && !I_FadeInPlaySong(fadeinms, looping)))
{
+6 -3
View File
@@ -54,10 +54,13 @@ extern consvar_t cv_amigatype;
#endif
#endif
//bird music stuff
extern consvar_t cv_music_resync_threshold;
extern consvar_t cv_music_resync_powerups_only;
#ifdef HAVE_FLUIDSYNTH
extern consvar_t cv_midisoundfontpath;
extern consvar_t cv_midichorus;
extern consvar_t cv_midireverb;
#endif
//bird music stuff
extern consvar_t cv_invincmusicfade;
extern consvar_t cv_growmusicfade;
+2 -2
View File
@@ -42,8 +42,8 @@ INT32 setmodeneeded = 0; // video mode change needed if > 0 (the mode number to
static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}};
//added : 03-02-98: default screen mode, as loaded/saved in config
consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE|CV_CALL, CV_Unsigned, VID_RefreshModeList, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE|CV_CALL, CV_Unsigned, VID_RefreshModeList, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_frameskip = {"frameskip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
+25 -24
View File
@@ -46,8 +46,8 @@
#include "SDL_image.h"
#else
// SDLCALL terms removed from original SDL_image declarations
int IMG_isXPM(SDL_RWops *src);
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src);
int IMG_isXPM(SDL_IOStream *src);
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src);
SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
#define IMG_SetError SDL_SetError
#define IMG_GetError SDL_GetError
@@ -56,7 +56,7 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
#ifdef LOAD_XPM
/* See if an image is contained in a data source */
int IMG_isXPM(SDL_RWops *src)
int IMG_isXPM(SDL_IOStream *src)
{
Sint64 start;
int is_XPM;
@@ -64,14 +64,14 @@ int IMG_isXPM(SDL_RWops *src)
if ( !src )
return 0;
start = SDL_RWtell(src);
start = SDL_TellIO(src);
is_XPM = 0;
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
if ( SDL_ReadIO(src, magic, sizeof(magic)) ) {
if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) {
is_XPM = 1;
}
}
SDL_RWseek(src, start, RW_SEEK_SET);
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
return(is_XPM);
}
@@ -933,7 +933,7 @@ static const char *error;
* If len > 0, it's assumed to be at least len chars (for efficiency).
* Return NULL and set error upon EOF or parse error.
*/
static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len)
{
char *linebufnew;
@@ -943,7 +943,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
char c;
int n;
do {
if (SDL_RWread(src, &c, 1, 1) <= 0) {
if (SDL_ReadIO(src, &c, 1) <= 0) {
error = "Premature end of data";
return NULL;
}
@@ -960,7 +960,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
}
linebuf = linebufnew;
}
if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) {
if (SDL_ReadIO(src, linebuf, len - 1) <= 0) {
error = "Premature end of data";
return NULL;
}
@@ -980,7 +980,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
}
linebuf = linebufnew;
}
if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) {
if (SDL_ReadIO(src, linebuf + n, 1) <= 0) {
error = "Premature end of data";
return NULL;
}
@@ -1005,7 +1005,7 @@ do { \
} while (0)
/* read XPM from either array or RWops */
static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
{
Sint64 start = 0;
SDL_Surface *image = NULL;
@@ -1027,7 +1027,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
buflen = 0;
if (src)
start = SDL_RWtell(src);
start = SDL_TellIO(src);
if (xpm)
xpmlines = &xpm;
@@ -1065,14 +1065,15 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
/* Create the new surface */
if (ncolors <= 256) {
indexed = 1;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
0, 0, 0, 0);
im_colors = image->format->palette->colors;
image->format->palette->ncolors = ncolors;
image = SDL_CreateSurface(w, h,
SDL_PIXELFORMAT_INDEX8);
SDL_Palette *palette = SDL_CreateSurfacePalette(image);
im_colors = palette->colors;
palette->ncolors = ncolors;
} else {
indexed = 0;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
0xff0000, 0x00ff00, 0x0000ff, 0);
image = SDL_CreateSurface(w, h,
SDL_GetPixelFormatForMasks(32, 0xff0000, 0x00ff00, 0x0000ff, 0));
}
if (!image) {
/* Hmm, some SDL error (out of memory?) */
@@ -1128,7 +1129,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
add_colorhash(colors, nextkey, cpp, pixel);
nextkey += cpp;
if (rgb == 0xffffffff)
SDL_SetColorKey(image, SDL_TRUE, pixel);
SDL_SetSurfaceColorKey(image, true, pixel);
break;
}
}
@@ -1164,9 +1165,9 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
done:
if (error) {
if ( src )
SDL_RWseek(src, start, RW_SEEK_SET);
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
if ( image ) {
SDL_FreeSurface(image);
SDL_DestroySurface(image);
image = NULL;
}
IMG_SetError("%s", error);
@@ -1180,7 +1181,7 @@ done:
}
/* Load a XPM type image from an RWops datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
{
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
@@ -1203,14 +1204,14 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
#else /* not LOAD_XPM */
/* See if an image is contained in a data source */
int IMG_isXPM(SDL_RWops *src)
int IMG_isXPM(SDL_IOStream *src)
{
return(0);
}
/* Load a XPM type image from an SDL datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
{
return(NULL);
}
+2 -2
View File
@@ -27,10 +27,10 @@
#ifdef HAVE_SDL
#include "SDL.h"
#include <SDL3/SDL.h>
#ifndef NOLOADSO
#include "SDL_loadso.h"
#include <SDL3/SDL_loadso.h>
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows
+1 -1
View File
@@ -36,7 +36,7 @@
#ifdef HAVE_SDL
#ifdef HAVE_TTF
#include "SDL.h"
#include <SDL3/SDL.h>
#include "i_ttf.h"
#endif
+59 -52
View File
@@ -67,13 +67,15 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED
#include "SDL.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL_joystick.h>
#include <SDL3/SDL_gamepad.h>
#ifdef HAVE_TTF
#include "i_ttf.h"
#endif
#include "SDL_cpuinfo.h"
#include <SDL3/SDL_cpuinfo.h>
#define HAVE_SDLCPUINFO
#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__))
@@ -213,13 +215,13 @@ static char returnWadPath[256];
#include "../byteptr.h"
#endif
SDL_bool consolevent = SDL_FALSE;
SDL_bool framebuffer = SDL_FALSE;
bool consolevent = false;
bool framebuffer = false;
UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you!
SDL_bool stdin_active = SDL_TRUE;
bool stdin_active = true;
typedef struct
{
@@ -282,7 +284,7 @@ static void I_ShutdownConsole(void)
if (consolevent)
{
I_OutputMsg("Shutdown tty console\n");
consolevent = SDL_FALSE;
consolevent = false;
tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc);
}
}
@@ -297,11 +299,11 @@ static void I_StartupConsole(void)
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
consolevent = static_cast<SDL_bool>(!M_CheckParm("-noconsole"));
framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer"));
consolevent = static_cast<bool>(!M_CheckParm("-noconsole"));
framebuffer = static_cast<bool>( M_CheckParm("-framebuffer"));
if (framebuffer)
consolevent = SDL_FALSE;
consolevent = false;
if (!consolevent)
return;
@@ -309,7 +311,7 @@ static void I_StartupConsole(void)
if (isatty(STDIN_FILENO)!=1)
{
I_OutputMsg("stdin is not a tty, tty console mode failed\n");
consolevent = SDL_FALSE;
consolevent = false;
return;
}
@@ -511,7 +513,7 @@ static void I_StartupConsole(void)
if (gotConsole)
{
SetConsoleTitleA("SRB2Kart Console");
consolevent = SDL_TRUE;
consolevent = true;
}
//Let get the real console HANDLE, because Mingw's Bash is bad!
@@ -544,7 +546,7 @@ static inline void I_StartupConsole(void)
framebuffer = M_CheckParm("-framebuffer");
if (framebuffer)
consolevent = SDL_FALSE;
consolevent = false;
}
static inline void I_ShutdownConsole(void){}
#endif
@@ -693,7 +695,7 @@ void I_OutputMsg(const char *fmt, ...)
//
// I_GetKey
//
INT32 I_GetKey (void)
INT32 I_GetKey(void)
{
// Warning: I_GetKey empties the event queue till next keypress
event_t *ev;
@@ -723,7 +725,7 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
{
if (JoySet->dev)
{
SDL_GameControllerClose(JoySet->dev);
SDL_CloseGamepad(JoySet->dev);
}
JoySet->dev = NULL;
@@ -765,15 +767,15 @@ void I_JoyScale4(void)
}
// Cheat to get the device index for a joystick handle
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev)
{
SDL_Joystick *joystick = NULL;
joystick = SDL_GameControllerGetJoystick(dev);
joystick = SDL_GetGamepadJoystick(dev);
if (joystick)
{
return SDL_JoystickInstanceID(joystick);
return SDL_GetJoystickID(joystick);
}
return -1;
@@ -883,7 +885,7 @@ void I_ShutdownJoystick(UINT8 index)
*/
static int joy_open(int playerIndex, int joyIndex)
{
SDL_GameController *newdev = NULL;
SDL_Gamepad *newdev = NULL;
int num_joy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
@@ -892,7 +894,7 @@ static int joy_open(int playerIndex, int joyIndex)
return -1;
}
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
{
CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
return -1;
@@ -901,7 +903,7 @@ static int joy_open(int playerIndex, int joyIndex)
if (joyIndex <= 0)
return -1;
num_joy = SDL_NumJoysticks();
SDL_GetJoysticks(&num_joy);
if (num_joy == 0)
{
@@ -909,7 +911,7 @@ static int joy_open(int playerIndex, int joyIndex)
return -1;
}
newdev = SDL_GameControllerOpen(joyIndex-1);
newdev = SDL_OpenGamepad(joyIndex-1);
// Handle the edge case where the device <-> joystick index assignment can change due to hotplugging
// This indexing is SDL's responsibility and there's not much we can do about it.
@@ -924,8 +926,8 @@ static int joy_open(int playerIndex, int joyIndex)
if (JoyInfo[playerIndex].dev)
{
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
return SDL_CONTROLLER_AXIS_MAX;
|| (newdev == NULL && SDL_GamepadConnected(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
return SDL_GAMEPAD_AXIS_COUNT;
// Else, we're changing devices, so send neutral joy events
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
@@ -942,13 +944,13 @@ static int joy_open(int playerIndex, int joyIndex)
}
else
{
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev));
JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX;
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GetGamepadName(JoyInfo[playerIndex].dev));
JoyInfo[playerIndex].axises = SDL_GAMEPAD_AXIS_COUNT;
if (JoyInfo[playerIndex].axises > JOYAXISSET*2)
JoyInfo[playerIndex].axises = JOYAXISSET*2;
JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons
JoyInfo[playerIndex].buttons = SDL_GAMEPAD_BUTTON_COUNT; // dpad is 4 buttons
if (JoyInfo[playerIndex].buttons > JOYBUTTONS)
JoyInfo[playerIndex].buttons = JOYBUTTONS;
@@ -968,7 +970,7 @@ static int joy_open(int playerIndex, int joyIndex)
void I_InitJoystick(UINT8 index)
{
UINT8 i;
SDL_GameController *newcontroller = NULL;
SDL_Gamepad *newcontroller = NULL;
// not sure if this is the best place to put this
SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0");
@@ -986,15 +988,16 @@ void I_InitJoystick(UINT8 index)
{
CONS_Printf("I_InitJoystick()...\n");
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)
if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK))
{
CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError());
return;
}
}
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
{
CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError());
return;
@@ -1007,7 +1010,7 @@ void I_InitJoystick(UINT8 index)
JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
if (cv_usejoystick[index].value)
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
newcontroller = SDL_OpenGamepad(cv_usejoystick[index].value-1);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
@@ -1047,7 +1050,7 @@ void I_InitJoystick(UINT8 index)
if (i == MAXSPLITSCREENPLAYERS)
{
// Joystick didn't end up being used
SDL_GameControllerClose(newcontroller);
SDL_CloseGamepad(newcontroller);
}
}
@@ -1082,10 +1085,10 @@ static void I_ShutdownInput(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
I_ShutdownJoystick(i);
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER)
if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
{
CONS_Printf("Shutting down gamecontroller system\n");
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
I_OutputMsg("I_Joystick: SDL's Game Controller system has been shutdown\n");
}
@@ -1102,7 +1105,9 @@ INT32 I_NumJoys(void)
INT32 numjoy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
numjoy = SDL_NumJoysticks();
{
SDL_GetJoysticks(&numjoy);
}
return numjoy;
}
@@ -1117,7 +1122,7 @@ const char *I_GetJoyName(INT32 joyindex)
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{
tempname = SDL_JoystickNameForIndex(joyindex);
tempname = SDL_GetJoystickNameForID(joyindex);
if (tempname)
{
@@ -1137,14 +1142,14 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength,
(void)high_strength;
(void)duration;
#else
SDL_GameController *controller = JoyInfo[playernum].dev;
SDL_Gamepad *controller = JoyInfo[playernum].dev;
if (controller == NULL)
{
return;
}
SDL_GameControllerRumble(controller, low_strength, high_strength, duration);
SDL_RumbleGamepad(controller, low_strength, high_strength, duration);
#endif
}
@@ -1156,14 +1161,14 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b
(void)green;
(void)blue;
#else
SDL_GameController *controller = JoyInfo[playernum].dev;
SDL_Gamepad *controller = JoyInfo[playernum].dev;
if (controller == NULL)
{
return;
}
SDL_GameControllerSetLED(controller, red, green, blue);
SDL_SetGamepadLED(controller, red, green, blue);
#endif
}
@@ -1816,10 +1821,7 @@ static void I_Fork(void)
INT32 I_StartupSystem(void)
{
SDL_version SDLcompiled;
SDL_version SDLlinked;
SDL_VERSION(&SDLcompiled)
SDL_GetVersion(&SDLlinked);
int SDLlinked = SDL_GetVersion();
I_StartupConsole();
#ifdef NEWSIGNALHANDLER
// This is useful when debugging. It lets GDB attach to
@@ -1835,15 +1837,15 @@ INT32 I_StartupSystem(void)
#endif
I_RegisterSignals();
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
SDLlinked.major, SDLlinked.minor, SDLlinked.patch);
SDL_VERSIONNUM_MAJOR(SDLlinked), SDL_VERSIONNUM_MINOR(SDLlinked), SDL_VERSIONNUM_MICRO(SDLlinked));
#if (SDL_VERSION_ATLEAST(2, 0, 18))
SDL_SetHint(SDL_HINT_APP_NAME, "SRB2Kart Saturn");
#endif
if (SDL_Init(0) < 0)
if (!SDL_Init(0))
I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no....
#ifndef NOMUMBLE
I_SetupMumble();
@@ -1856,12 +1858,12 @@ INT32 I_StartupSystem(void)
//
FUNCNORETURN void ATTRNORETURN I_Quit(void)
{
static SDL_bool quiting = SDL_FALSE;
static bool quiting = false;
/* prevent recursive I_Quit() */
if (quiting) goto death;
SDL_ShowCursor(SDL_TRUE);
quiting = SDL_FALSE;
SDL_ShowCursor();
quiting = false;
I_ShutdownConsole();
M_SaveConfig(NULL); //save game config, cvars..
D_SaveBan(); // save the ban list
@@ -2314,12 +2316,17 @@ static void pathonly(char *s)
size_t j;
for (j = strlen(s); j != (size_t)-1; j--)
{
if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/'))
{
if (s[j] == ':') s[j+1] = 0;
else s[j] = 0;
if (s[j] == ':')
s[j+1] = 0;
else
s[j] = 0;
return;
}
}
}
/** \brief search for srb2.srb in the given path
+25 -30
View File
@@ -12,7 +12,7 @@
#include "../doomdef.h"
#include "../i_threads.h"
#include <SDL.h>
#include <SDL3/SDL.h>
typedef void * (*Create_fn)(void);
@@ -45,7 +45,7 @@ static I_mutex i_thread_pool_mutex;
static I_mutex i_mutex_pool_mutex;
static I_mutex i_cond_pool_mutex;
static SDL_atomic_t i_threads_running = {1};
static SDL_AtomicInt i_threads_running = {1};
static Link
Insert_link (
@@ -103,13 +103,13 @@ Identity (
){
void * id;
id = SDL_AtomicGetPtr(anchor);
id = SDL_GetAtomicPointer(anchor);
if (! id)
{
I_lock_mutex(&pool_mutex);
{
id = SDL_AtomicGetPtr(anchor);
id = SDL_GetAtomicPointer(anchor);
if (! id)
{
@@ -120,7 +120,7 @@ Identity (
Insert_link(pool_anchor, New_link(id));
SDL_AtomicSetPtr(anchor, id);
SDL_SetAtomicPointer(anchor, id);
}
}
I_unlock_mutex(pool_mutex);
@@ -139,11 +139,11 @@ Worker (
(*th->entry)(th->userdata);
if (SDL_AtomicGet(&i_threads_running))
if (SDL_GetAtomicInt(&i_threads_running))
{
I_lock_mutex(&i_thread_pool_mutex);
{
if (SDL_AtomicGet(&i_threads_running))
if (SDL_GetAtomicInt(&i_threads_running))
{
SDL_DetachThread(th->thread);
Free_link(&i_thread_pool, link);
@@ -176,7 +176,7 @@ I_spawn_thread (
{
link = Insert_link(&i_thread_pool, New_link(th));
if (SDL_AtomicGet(&i_threads_running))
if (SDL_GetAtomicInt(&i_threads_running))
{
th->thread = SDL_CreateThread(
(SDL_ThreadFunction)Worker,
@@ -194,7 +194,7 @@ I_spawn_thread (
int
I_thread_is_stopped (void)
{
return ( ! SDL_AtomicGet(&i_threads_running) );
return ( ! SDL_GetAtomicInt(&i_threads_running) );
}
void
@@ -220,13 +220,13 @@ I_stop_threads (void)
Link next;
Thread th;
SDL_mutex * mutex;
SDL_cond * cond;
SDL_Mutex * mutex;
SDL_Condition * cond;
if (i_threads_running.value)
{
/* rely on the good will of thread-san */
SDL_AtomicSet(&i_threads_running, 0);
SDL_SetAtomicInt(&i_threads_running, 0);
I_lock_mutex(&i_thread_pool_mutex);
{
@@ -267,7 +267,7 @@ I_stop_threads (void)
next = link->next;
cond = link->data;
SDL_DestroyCond(cond);
SDL_DestroyCondition(cond);
free(link);
}
@@ -282,7 +282,7 @@ void
I_lock_mutex (
I_mutex * anchor
){
SDL_mutex * mutex;
SDL_Mutex * mutex;
mutex = Identity(
&i_mutex_pool,
@@ -291,16 +291,14 @@ I_lock_mutex (
(Create_fn)SDL_CreateMutex
);
if (SDL_LockMutex(mutex) == -1)
abort();
SDL_LockMutex(mutex);
}
void
I_unlock_mutex (
I_mutex id
){
if (SDL_UnlockMutex(id) == -1)
abort();
SDL_UnlockMutex(id);
}
void
@@ -308,49 +306,46 @@ I_hold_cond (
I_cond * cond_anchor,
I_mutex mutex_id
){
SDL_cond * cond;
SDL_Condition * cond;
cond = Identity(
&i_cond_pool,
i_cond_pool_mutex,
cond_anchor,
(Create_fn)SDL_CreateCond
(Create_fn)SDL_CreateCondition
);
if (SDL_CondWait(cond, mutex_id) == -1)
abort();
SDL_WaitCondition(cond, mutex_id);
}
void
I_wake_one_cond (
I_cond * anchor
){
SDL_cond * cond;
SDL_Condition * cond;
cond = Identity(
&i_cond_pool,
i_cond_pool_mutex,
anchor,
(Create_fn)SDL_CreateCond
(Create_fn)SDL_CreateCondition
);
if (SDL_CondSignal(cond) == -1)
abort();
SDL_SignalCondition(cond);
}
void
I_wake_all_cond (
I_cond * anchor
){
SDL_cond * cond;
SDL_Condition * cond;
cond = Identity(
&i_cond_pool,
i_cond_pool_mutex,
anchor,
(Create_fn)SDL_CreateCond
(Create_fn)SDL_CreateCondition
);
if (SDL_CondBroadcast(cond) == -1)
abort();
SDL_BroadcastCondition(cond);
}
+3 -3
View File
@@ -16,7 +16,7 @@
/// \file
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
#if defined(HAVE_SDL) && defined(HAVE_TTF)
#if defined (HAVE_SDL) && defined (HAVE_TTF)
#include "SDL.h"
#include "SDL_ttf.h"
#include "../doomdef.h"
@@ -236,14 +236,14 @@ void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags)
// what's the point of trying to display an error?
// SDL_ttf is not started, can't display anything to screen (presumably)...
if (SDL_InitSubSystem(initflags) < 0)
if (!SDL_InitSubSystem(initflags))
I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());
TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
if (!TTFSurface)
I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError());
if (TTF_Init() < 0)
if (!TTF_Init())
I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError());
// look for default font in many directories
+480 -304
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -20,7 +20,7 @@
#ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED
#include "SDL.h"
#include <SDL3/SDL.h>
#include "sdlmain.h"
@@ -96,7 +96,7 @@ boolean VID_LoadOGLAPI(void)
if (M_CheckParm("-OGLlib") && M_IsNextParm())
OGLLibname = M_GetNextParm();
if (SDL_GL_LoadLibrary(OGLLibname) != 0)
if (!SDL_GL_LoadLibrary(OGLLibname))
{
CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n", SDL_GetError());
if (!M_CheckParm("-OGLlib"))
+1962
View File
File diff suppressed because it is too large. Load diff
+7 -5
View File
@@ -23,14 +23,16 @@
extern "C" {
#endif
extern SDL_bool consolevent;
extern SDL_bool framebuffer;
extern bool consolevent;
extern bool framebuffer;
#include "../m_fixed.h"
// SDL2 stub macro
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
#include <SDL3/SDL_gamepad.h>
// So m_menu knows whether to store cv_usejoystick value or string
#define JOYSTICK_HOTPLUG
@@ -41,9 +43,9 @@ extern SDL_bool framebuffer;
typedef struct SDLJoyInfo_s
{
/// Controller handle
SDL_GameController *dev;
SDL_Gamepad *dev;
/// Controller index
INT32 id;
SDL_JoystickID id;
/// number of old joystick
int oldjoy;
/// number of axies
@@ -71,7 +73,7 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS
void I_ShutdownJoystick(UINT8 index);
// Cheat to get the device index for a game controller handle
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev);
INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player);
+9 -3
View File
@@ -2992,7 +2992,9 @@ INT32 V_CreditStringWidth(const char *string)
if (!string)
return 0;
for (i = 0; i < strlen(string); i++)
const size_t strlength = strlen(string);
for (i = 0; i < strlength; i++)
{
c = toupper(string[i]) - CRED_FONTSTART;
if (c < 0 || c >= CRED_FONTSIZE)
@@ -3070,7 +3072,9 @@ INT32 V_LevelNameWidth(const char *string)
INT32 c, w = 0;
size_t i;
for (i = 0; i < strlen(string); i++)
const size_t strlength = strlen(string);
for (i = 0; i < strlength; i++)
{
c = toupper(string[i]) - LT_FONTSTART;
if (c < 0 || c >= LT_FONTSIZE || !lt_font[c])
@@ -3089,7 +3093,9 @@ INT32 V_LevelNameHeight(const char *string)
INT32 c, w = 0;
size_t i;
for (i = 0; i < strlen(string); i++)
const size_t strlength = strlen(string);
for (i = 0; i < strlength; i++)
{
c = toupper(string[i]) - LT_FONTSTART;
if (c < 0 || c >= LT_FONTSIZE || !lt_font[c])