From c5ea6b5efe8a83e3c5d32e1b17db05ef935e1484 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 10:22:17 -0400 Subject: [PATCH 01/80] MusicPlus Core (positioning and fading) 2.2 -> 2.1 backport --- src/android/i_sound.c | 72 ++++++ src/d_netcmd.c | 10 +- src/dehacked.c | 11 + src/djgppdos/i_sound.c | 72 ++++++ src/doomdef.h | 2 + src/doomstat.h | 4 + src/dummy/i_sound.c | 74 +++++- src/f_finale.c | 10 +- src/g_game.c | 12 +- src/i_sound.h | 23 ++ src/lua_baselib.c | 44 ++-- src/lua_hook.h | 1 + src/lua_hooklib.c | 1 + src/lua_maplib.c | 2 + src/p_setup.c | 2 + src/p_spec.c | 2 + src/p_user.c | 4 +- src/s_sound.c | 153 +++++++++-- src/s_sound.h | 41 ++- src/sdl/mixer_sound.c | 559 +++++++++++++++++++++++++++++++++++++++-- src/sdl/sdl_sound.c | 72 ++++++ src/win32/win_snd.c | 95 +++++++ 22 files changed, 1175 insertions(+), 91 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index 1d16e4df3..d7a7973d4 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -95,6 +95,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -139,3 +170,44 @@ void I_SetMusicVolume(INT32 volume) { (void)volume; } + +/// ------------------------ +// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a58aff3fe..5211b31e9 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3885,11 +3885,12 @@ static void Command_Tunes_f(void) { const char *tunearg; UINT16 tunenum, track = 0; + UINT32 position = 0; const size_t argc = COM_Argc(); if (argc < 2) //tunes slot ... { - CONS_Printf("tunes [track] [speed] / <-show> / <-default> / <-none>:\n"); + CONS_Printf("tunes [track] [speed] [position] / <-show> / <-default> / <-none>:\n"); CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n")); CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n")); CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n")); @@ -3936,10 +3937,15 @@ static void Command_Tunes_f(void) snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); else strncpy(mapmusname, tunearg, 7); + + if (argc > 4) + position = (UINT32)atoi(COM_Argv(4)); + mapmusname[6] = 0; mapmusflags = (track & MUSIC_TRACKMASK); + mapmusposition = position; - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); if (argc > 3) { diff --git a/src/dehacked.c b/src/dehacked.c index b7e874b16..e2df11142 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1192,6 +1192,8 @@ static void readlevelheader(MYFILE *f, INT32 num) #endif else if (fastcmp(word, "MUSICTRACK")) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); + else if (fastcmp(word, "MUSICPOS")) + mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2); else if (fastcmp(word, "FORCECHARACTER")) { strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); @@ -1483,6 +1485,11 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchflags), UNDO_NONE); cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; } + else if (fastcmp(word, "MUSICPOS")) + { + DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchposition), UNDO_NONE); + cutscenes[num]->scene[scenenum].musswitchposition = (UINT32)get_number(word2); + } else if (fastcmp(word, "MUSICLOOP")) { DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musicloop), UNDO_NONE); @@ -6977,6 +6984,7 @@ struct { // doomdef.h constants {"TICRATE",TICRATE}, + {"MUSICRATE",MUSICRATE}, {"RING_DIST",RING_DIST}, {"PUSHACCEL",PUSHACCEL}, {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. @@ -8264,6 +8272,9 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"mapmusflags")) { lua_pushinteger(L, mapmusflags); return 1; + } else if (fastcmp(word,"mapmusposition")) { + lua_pushinteger(L, mapmusposition); + return 1; } else if (fastcmp(word,"server")) { if ((!multiplayer || !netgame) && !playeringame[serverplayer]) return 0; diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 5403aef17..00e0f8c90 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -436,6 +436,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -543,3 +574,44 @@ int I_QrySongPlaying(int handle) return (midi_pos==-1); } #endif + +/// ------------------------ +// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/doomdef.h b/src/doomdef.h index 7f641558f..9cde20f9a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -288,6 +288,8 @@ typedef enum #define NEWTICRATERATIO 1 // try 4 for 140 fps :) #define NEWTICRATE (TICRATE*NEWTICRATERATIO) +#define MUSICRATE 1000 // sound timing is calculated by milliseconds + #define RING_DIST 512*FRACUNIT // how close you need to be to a ring to attract it #define PUSHACCEL (2*FRACUNIT) // Acceleration for MF2_SLIDEPUSH items. diff --git a/src/doomstat.h b/src/doomstat.h index 27bd3fa19..d6fd046b4 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -33,8 +33,10 @@ extern INT16 gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; +extern UINT32 mapmusposition; #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- +#define MUSIC_FORCERESET 0x4000 // -*-------------- // Use other bits if necessary. extern INT16 maptol; @@ -145,6 +147,7 @@ typedef struct char musswitch[7]; UINT16 musswitchflags; + UINT32 musswitchposition; UINT8 fadecolor; // Color number for fade, 0 means don't do the first fade UINT8 fadeinid; // ID of the first fade, to a color -- ignored if fadecolor is 0 @@ -215,6 +218,7 @@ typedef struct INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end. char musname[7]; ///< Music track to play. "" for no music. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. + UINT32 muspos; ///< Music position to jump to. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. INT16 skynum; ///< Sky number to use. diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 4bace7a41..89c400631 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -94,6 +94,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -141,4 +172,45 @@ boolean I_SetSongTrack(int track) { (void)track; return false; -} \ No newline at end of file +} + +/// ------------------------ +// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/f_finale.c b/src/f_finale.c index a8b27bb80..2499931ab 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1714,9 +1714,10 @@ static void F_AdvanceToNextScene(void) picypos = cutscenes[cutnum]->scene[scenenum].ycoord[picnum]; if (cutscenes[cutnum]->scene[scenenum].musswitch[0]) - S_ChangeMusic(cutscenes[cutnum]->scene[scenenum].musswitch, + S_ChangeMusicEx(cutscenes[cutnum]->scene[scenenum].musswitch, cutscenes[cutnum]->scene[scenenum].musswitchflags, - cutscenes[cutnum]->scene[scenenum].musicloop); + cutscenes[cutnum]->scene[scenenum].musicloop, + cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0); // Fade to the next dofadenow = true; @@ -1788,9 +1789,10 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset stoptimer = 0; if (cutscenes[cutnum]->scene[0].musswitch[0]) - S_ChangeMusic(cutscenes[cutnum]->scene[0].musswitch, + S_ChangeMusicEx(cutscenes[cutnum]->scene[0].musswitch, cutscenes[cutnum]->scene[0].musswitchflags, - cutscenes[cutnum]->scene[0].musicloop); + cutscenes[cutnum]->scene[0].musicloop, + cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0); else S_StopMusic(); } diff --git a/src/g_game.c b/src/g_game.c index 4f1c49b42..6be4cf96e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -71,6 +71,7 @@ static void G_DoWorldDone(void); char mapmusname[7]; // Music name UINT16 mapmusflags; // Track and reset bit +UINT32 mapmusposition; // Position to jump to INT16 gamemap = 1; INT16 maptol; @@ -2187,17 +2188,6 @@ void G_PlayerReborn(INT32 player) if ((netgame || multiplayer) && !p->spectator) p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent - if (p-players == consoleplayer) - { - if (mapmusflags & MUSIC_RELOADRESET) - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK; - } - S_ChangeMusic(mapmusname, mapmusflags, true); - } - if (gametype == GT_COOP) P_FindEmerald(); // scan for emeralds to hunt for diff --git a/src/i_sound.h b/src/i_sound.h index 1be970d2e..3c2608093 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -146,6 +146,18 @@ boolean I_SongPaused(void); boolean I_SetSongSpeed(float speed); +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void); + +boolean I_SetSongLoopPoint(UINT32 looppoint); +UINT32 I_GetSongLoopPoint(void); + +boolean I_SetSongPosition(UINT32 position); +UINT32 I_GetSongPosition(void); + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -216,6 +228,17 @@ void I_SetMusicVolume(UINT8 volume); boolean I_SetSongTrack(INT32 track); +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume); +void I_StopFadingSong(void); +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeOutStopSong(UINT32 ms); +boolean I_FadeInPlaySong(UINT32 ms, boolean looping); + /// ------------------------ // CD MUSIC I/O /// ------------------------ diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e8e8fd020..f7a0a5995 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -719,8 +719,14 @@ static int lib_pRestoreMusic(lua_State *L) NOHUD if (!player) return LUA_ErrInvalid(L, "player_t"); - P_RestoreMusic(player); - return 0; + else if (P_IsLocalPlayer(player)) + { + P_RestoreMusic(player); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; } static int lib_pSpawnShieldOrb(lua_State *L) @@ -1717,7 +1723,7 @@ static int lib_sChangeMusic(lua_State *L) { #ifdef MUSICSLOT_COMPATIBILITY const char *music_name; - UINT32 music_num; + UINT32 music_num, position, prefadems, fadeinms; char music_compat_name[7]; boolean looping; @@ -1745,7 +1751,6 @@ static int lib_sChangeMusic(lua_State *L) music_name = luaL_checkstring(L, 1); } - looping = (boolean)lua_opttrueboolean(L, 2); #else @@ -1770,9 +1775,18 @@ static int lib_sChangeMusic(lua_State *L) #endif music_flags = (UINT16)luaL_optinteger(L, 4, 0); + position = (UINT32)luaL_optinteger(L, 5, 0); + prefadems = (UINT32)luaL_optinteger(L, 6, 0); + fadeinms = (UINT32)luaL_optinteger(L, 7, 0); + if (!player || P_IsLocalPlayer(player)) - S_ChangeMusic(music_name, music_flags, looping); - return 0; + { + S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; } static int lib_sSpeedMusic(lua_State *L) @@ -1790,25 +1804,10 @@ static int lib_sSpeedMusic(lua_State *L) if (!player || P_IsLocalPlayer(player)) lua_pushboolean(L, S_SpeedMusic(speed)); else - lua_pushboolean(L, false); + lua_pushnil(L); return 1; } -static int lib_sStopMusic(lua_State *L) -{ - player_t *player = NULL; - NOHUD - if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) - { - player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - if (!player) - return LUA_ErrInvalid(L, "player_t"); - } - if (!player || P_IsLocalPlayer(player)) - S_StopMusic(); - return 0; -} - static int lib_sOriginPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -2131,7 +2130,6 @@ static luaL_Reg lib[] = { {"S_StopSound",lib_sStopSound}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, - {"S_StopMusic",lib_sStopMusic}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 53e0a7d8e..74a6b5e75 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -43,6 +43,7 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, + hook_MusicChange, hook_MAX // last hook }; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index eadd01537..dff2b8f46 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -54,6 +54,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", + "MusicChange", NULL }; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 208aebe37..a1d7994bf 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1192,6 +1192,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushstring(L, header->musname); else if (fastcmp(field,"mustrack")) lua_pushinteger(L, header->mustrack); + else if (fastcmp(field,"muspos")) + lua_pushinteger(L, header->muspos); else if (fastcmp(field,"forcecharacter")) lua_pushstring(L, header->forcecharacter); else if (fastcmp(field,"weather")) diff --git a/src/p_setup.c b/src/p_setup.c index 17a6797f4..6c6b9153d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -185,6 +185,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->musname[6] = 0; DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); mapheaderinfo[num]->mustrack = 0; + DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); + mapheaderinfo[num]->muspos = 0; DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); mapheaderinfo[num]->forcecharacter[0] = '\0'; DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE); diff --git a/src/p_spec.c b/src/p_spec.c index c62c3b209..afc3c0533 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2428,6 +2428,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!(line->flags & ML_BLOCKMONSTERS)) mapmusflags |= MUSIC_RELOADRESET; + mapmusposition = 0; + S_ChangeMusic(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4)); // Except, you can use the ML_BLOCKMONSTERS flag to change this behavior. diff --git a/src/p_user.c b/src/p_user.c index 7abf85347..03b037fed 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1124,13 +1124,13 @@ void P_RestoreMusic(player_t *player) if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) { S_SpeedMusic(1.4f); - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); } else S_ChangeMusicInternal("shoes", true); } else - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); } // diff --git a/src/s_sound.c b/src/s_sound.c index ea129a109..3da594fe1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -37,6 +37,10 @@ extern INT32 msg_id; #include "r_sky.h" // skyflatnum #include "p_local.h" // camera info +#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) +#include "lua_hook.h" // MusicChange hook +#endif + #ifdef HW3SOUND // 3D Sound Interface #include "hardware/hw3sound.h" @@ -1219,6 +1223,12 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; +static char queue_name[7]; +static UINT16 queue_flags; +static boolean queue_looping; +static UINT32 queue_position; +static UINT32 queue_fadeinms; + /// ------------------------ /// Music Status /// ------------------------ @@ -1253,6 +1263,11 @@ musictype_t S_MusicType(void) return I_SongType(); } +const char *S_MusicName(void) +{ + return music_name; +} + boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) { if (!I_SongPlaying()) @@ -1283,6 +1298,35 @@ boolean S_SpeedMusic(float speed) return I_SetSongSpeed(speed); } +/// ------------------------ +/// Music Seeking +/// ------------------------ + +UINT32 S_GetMusicLength(void) +{ + return I_GetSongLength(); +} + +boolean S_SetMusicLoopPoint(UINT32 looppoint) +{ + return I_SetSongLoopPoint(looppoint); +} + +UINT32 S_GetMusicLoopPoint(void) +{ + return I_GetSongLoopPoint(); +} + +boolean S_SetMusicPosition(UINT32 position) +{ + return I_SetSongPosition(position); +} + +UINT32 S_GetMusicPosition(void) +{ + return I_GetSongPosition(); +} + /// ------------------------ /// Music Playback /// ------------------------ @@ -1355,12 +1399,13 @@ static void S_UnloadMusic(void) music_looping = false; } -static boolean S_PlayMusic(boolean looping) +static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) { if (S_MusicDisabled()) return false; - if (!I_PlaySong(looping)) + if ((!fadeinms && !I_PlaySong(looping)) || + (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) { S_UnloadMusic(); return false; @@ -1370,7 +1415,27 @@ static boolean S_PlayMusic(boolean looping) return true; } -void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) +static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms) +{ + strncpy(queue_name, mmusic, 7); + queue_flags = mflags; + queue_looping = looping; + queue_position = position; + queue_fadeinms = fadeinms; +} + +static void S_ClearQueue(void) +{ + queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0; +} + +static void S_ChangeMusicToQueue(void) +{ + S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms); + S_ClearQueue(); +} + +void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { #if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X) S_ClearSfx(); @@ -1379,33 +1444,62 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) if (S_MusicDisabled()) return; - // No Music (empty string) - if (mmusic[0] == 0) - { - S_StopMusic(); + char newmusic[7]; + strncpy(newmusic, mmusic, 7); +#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) + if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + return; +#endif + newmusic[6] = 0; + + // No Music (empty string) + if (newmusic[0] == 0) + { + if (prefadems) + I_FadeSong(0, prefadems, &S_StopMusic); + else + S_StopMusic(); return; } - if (strnicmp(music_name, mmusic, 6)) + if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same { - S_StopMusic(); // shutdown old music + CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); + S_QueueMusic(newmusic, mflags, looping, position, fadeinms); + I_FadeSong(0, prefadems, S_ChangeMusicToQueue); + return; + } + else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) + { + CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); - if (!S_LoadMusic(mmusic)) + S_StopMusic(); + + if (!S_LoadMusic(newmusic)) { - CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", mmusic); + CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", newmusic); return; } music_flags = mflags; music_looping = looping; - if (!S_PlayMusic(looping)) - { - CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", mmusic); + if (!S_PlayMusic(looping, fadeinms)) + { + CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", newmusic); return; } + + if (position) + I_SetSongPosition(position); + + I_SetSongTrack(mflags & MUSIC_TRACKMASK); } - I_SetSongTrack(mflags & MUSIC_TRACKMASK); + else if (fadeinms) // let fades happen with same music + { + I_SetSongPosition(position); + I_FadeSong(100, fadeinms, NULL); + } } void S_StopMusic(void) @@ -1480,6 +1574,32 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } +/// ------------------------ +/// Music Fading +/// ------------------------ + +void S_SetInternalMusicVolume(INT32 volume) +{ + I_SetInternalMusicVolume(min(max(volume, 0), 100)); +} + +void S_StopFadingMusic(void) +{ + I_StopFadingSong(); +} + +boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms) +{ + if (source_volume < 0) + return I_FadeSong(target_volume, ms, NULL); + else + return I_FadeSongFromVolume(target_volume, source_volume, ms, false); +} + +boolean S_FadeOutStopMusic(UINT32 ms) +{ + return I_FadeSong(0, ms, &S_StopMusic); +} /// ------------------------ /// Init & Others @@ -1497,9 +1617,10 @@ void S_Start(void) strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; } if (cv_resetmusic.value) S_StopMusic(); - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); } diff --git a/src/s_sound.h b/src/s_sound.h index a2d51a59b..538707ffb 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -108,29 +108,49 @@ boolean S_MusicDisabled(void); boolean S_MusicPlaying(void); boolean S_MusicPaused(void); musictype_t S_MusicType(void); +const char *S_MusicName(void); boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); #define S_DigExists(a) S_MusicExists(a, false, true) #define S_MIDIExists(a) S_MusicExists(a, true, false) - // -// Music Properties +// Music Effects // // Set Speed of Music boolean S_SpeedMusic(float speed); // -// Music Routines +// Music Seeking +// + +// Get Length of Music +UINT32 S_GetMusicLength(void); + +// Set LoopPoint of Music +boolean S_SetMusicLoopPoint(UINT32 looppoint); + +// Get LoopPoint of Music +UINT32 S_GetMusicLoopPoint(void); + +// Set Position of Music +boolean S_SetMusicPosition(UINT32 position); + +// Get Position of Music +UINT32 S_GetMusicPosition(void); + +// +// Music Playback // // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet // and the last bit we ignore (internal game flag for resetting music on reload) -#define S_ChangeMusicInternal(a,b) S_ChangeMusic(a,0,b) -void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping); +void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms); +#define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) +#define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) // Stops the music. void S_StopMusic(void); @@ -139,6 +159,17 @@ void S_StopMusic(void); void S_PauseAudio(void); void S_ResumeAudio(void); +// +// Music Fading +// + +void S_SetInternalMusicVolume(INT32 volume); +void S_StopFadingMusic(void); +boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms); +#define S_FadeMusic(a, b) S_FadeMusicFromVolume(a, -1, b) +#define S_FadeInChangeMusic(a,b,c,d) S_ChangeMusicEx(a,b,c,0,0,d) +boolean S_FadeOutStopMusic(UINT32 ms); + // // Updates music & sounds // diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 87f8fd671..9b09ffe80 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -69,15 +69,41 @@ UINT8 sound_started = false; static Mix_Music *music; -static UINT8 music_volume, sfx_volume; +static UINT8 music_volume, sfx_volume, internal_volume; static float loop_point; +static float song_length; // length in seconds static boolean songpaused; +static UINT32 music_bytes; +static boolean is_looping; + +// fading +static boolean is_fading; +static UINT8 fading_source; +static UINT8 fading_target; +static UINT32 fading_timer; +static UINT32 fading_duration; +static INT32 fading_id; +static void (*fading_callback)(void); #ifdef HAVE_LIBGME static Music_Emu *gme; static INT32 current_track; #endif +static void var_cleanup(void) +{ + loop_point = song_length =\ + music_bytes = fading_source = fading_target =\ + fading_timer = fading_duration = 0; + + songpaused = is_looping =\ + is_fading = false; + + fading_callback = NULL; + + internal_volume = 100; +} + /// ------------------------ /// Audio System /// ------------------------ @@ -99,6 +125,8 @@ void I_StartupSound(void) return; } + var_cleanup(); + music = NULL; music_volume = sfx_volume = 0; @@ -323,6 +351,7 @@ void *I_GetSfx(sfxinfo_t *sfx) len = (info->play_length * 441 / 10) << 2; mem = malloc(len); gme_play(emu, len >> 1, mem); + gme_free_info(info); gme_delete(emu); return Mix_QuickLoad_RAW((Uint8 *)mem, len); @@ -395,6 +424,7 @@ void *I_GetSfx(sfxinfo_t *sfx) len = (info->play_length * 441 / 10) << 2; mem = malloc(len); gme_play(emu, len >> 1, mem); + gme_free_info(info); gme_delete(emu); return Mix_QuickLoad_RAW((Uint8 *)mem, len); @@ -447,14 +477,96 @@ void I_SetSfxVolume(UINT8 volume) sfx_volume = volume; } +/// ------------------------ +/// Music Utilities +/// ------------------------ + +static UINT32 get_real_volume(UINT8 volume) +{ +#ifdef _WIN32 + if (I_SongType() == MU_MID) + // HACK: Until we stop using native MIDI, + // disable volume changes + return ((UINT32)31*128/31); // volume = 31 + else +#endif + // convert volume to mixer's 128 scale + // then apply internal_volume as a percentage + return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100; +} + +static UINT32 get_adjusted_position(UINT32 position) +{ + // all in milliseconds + UINT32 length = I_GetSongLength(); + UINT32 looppoint = I_GetSongLoopPoint(); + if (length) + return position >= length ? (position % (length-looppoint)) : position; + else + return position; +} + +static void do_fading_callback() +{ + if (fading_callback) + (*fading_callback)(); + fading_callback = NULL; +} + /// ------------------------ /// Music Hooks /// ------------------------ +static void count_music_bytes(int chan, void *stream, int len, void *udata) +{ + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return; + music_bytes += len; +} + static void music_loop(void) { - Mix_PlayMusic(music, 0); - Mix_SetMusicPosition(loop_point); + if (is_looping) + { + Mix_PlayMusic(music, 0); + Mix_SetMusicPosition(loop_point); + music_bytes = loop_point*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition) + } + else + I_StopSong(); +} + +static UINT32 music_fade(UINT32 interval, void *param) +{ + if (!is_fading || + internal_volume == fading_target || + fading_duration == 0) + { + I_StopFadingSong(); + do_fading_callback(); + return 0; + } + else if (songpaused) // don't decrement timer + return interval; + else if ((fading_timer -= 10) <= 0) + { + internal_volume = fading_target; + Mix_VolumeMusic(get_real_volume(music_volume)); + I_StopFadingSong(); + do_fading_callback(); + return 0; + } + else + { + UINT8 delta = abs(fading_target - fading_source); + double factor = (double)(fading_duration - fading_timer) / (double)fading_duration; + if (fading_target < fading_source) + internal_volume = max(min(internal_volume, fading_source - (UINT8)round(delta * factor)), fading_target); + else if (fading_target > fading_source) + internal_volume = min(max(internal_volume, fading_source + (UINT8)round(delta * factor)), fading_target); + Mix_VolumeMusic(get_real_volume(music_volume)); + return interval; + } } #ifdef HAVE_LIBGME @@ -474,7 +586,7 @@ static void mix_gme(void *udata, Uint8 *stream, int len) // apply volume to stream for (i = 0, p = (short *)stream; i < len/2; i++, p++) - *p = ((INT32)*p) * music_volume*2 / 42; + *p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 42; } #endif @@ -552,6 +664,194 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +/// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + INT32 length; + +#ifdef HAVE_LIBGME + if (gme) + { + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + length = 0; + } + else + { + // reconstruct info->play_length, from GME source + // we only want intro + 1 loop, not 2 + length = info->length; + if (length <= 0) + { + length = info->intro_length + info->loop_length; // intro + 1 loop + if (length <= 0) + length = 150 * 1000; // 2.5 minutes + } + } + + gme_free_info(info); + return max(length, 0); + } + else +#endif + if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return 0; + else + { + // VERY IMPORTANT to set your LENGTHMS= in your song files, folks! + // SDL mixer can't read music length itself. + length = (UINT32)(song_length*1000); + if (!length) + CONS_Debug(DBG_DETAILED, "Getting music length: music is missing LENGTHMS= tag. Needed for seeking.\n"); + return length; + } +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID || !is_looping) + return false; + else + { + UINT32 length = I_GetSongLength(); + + if (length > 0) + looppoint %= length; + + loop_point = max((float)(looppoint / 1000.0L), 0); + return true; + } +} + +UINT32 I_GetSongLoopPoint(void) +{ +#ifdef HAVE_LIBGME + if (gme) + { + INT32 looppoint; + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + looppoint = 0; + } + else + looppoint = info->intro_length > 0 ? info->intro_length : 0; + + gme_free_info(info); + return max(looppoint, 0); + } + else +#endif + if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return 0; + else + return (UINT32)(loop_point * 1000); +} + +boolean I_SetSongPosition(UINT32 position) +{ + UINT32 length; +#ifdef HAVE_LIBGME + if (gme) + { + // this is unstable, so fail silently + return true; + // this isn't required technically, but GME thread-locks for a second + // if you seek too high from the counter + // length = I_GetSongLength(); + // if (length) + // position = get_adjusted_position(position); + + // SDL_LockAudio(); + // gme_err_t gme_e = gme_seek(gme, position); + // SDL_UnlockAudio(); + + // if (gme_e != NULL) + // { + // CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + // return false; + // } + // else + // return true; + } + else +#endif + if (!music || I_SongType() == MU_MID) + return false; + else if (I_SongType() == MU_MOD) + return Mix_SetMusicPosition(position); // Goes by channels + else + { + // Because SDL mixer can't identify song length, if you have + // a position input greater than the real length, then + // music_bytes becomes inaccurate. + + length = I_GetSongLength(); // get it in MS + if (length) + position = get_adjusted_position(position); + + Mix_RewindMusic(); // needed for mp3 + if(Mix_SetMusicPosition((float)(position/1000.0L)) == 0) + music_bytes = position/1000.0L*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition) + else + // NOTE: This block fires on incorrect song format, + // NOT if position input is greater than song length. + music_bytes = 0; + + return true; + } +} + +UINT32 I_GetSongPosition(void) +{ +#ifdef HAVE_LIBGME + if (gme) + { + INT32 position = gme_tell(gme); + + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + return position; + } + else + { + // adjust position, since GME's counter keeps going past loop + if (info->length > 0) + position %= info->length; + else if (info->intro_length + info->loop_length > 0) + position = position >= (info->intro_length + info->loop_length) ? (position % info->loop_length) : position; + else + position %= 150 * 1000; // 2.5 minutes + } + + gme_free_info(info); + return max(position, 0); + } + else +#endif + if (!music || I_SongType() == MU_MID) + return 0; + else + return music_bytes/44100.0L*1000.0L/4; //assume 44.1khz + // 4 = byte length for 16-bit samples (AUDIO_S16SYS), stereo (2-channel) + // This is hardcoded in I_StartupSound. Other formats for factor: + // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 +} + /// ------------------------ /// Music Playback /// ------------------------ @@ -561,9 +861,21 @@ boolean I_LoadSong(char *data, size_t len) const char *key1 = "LOOP"; const char *key2 = "POINT="; const char *key3 = "MS="; + const char *key4 = "LENGTHMS="; const size_t key1len = strlen(key1); const size_t key2len = strlen(key2); const size_t key3len = strlen(key3); + const size_t key4len = strlen(key4); + + // for mp3 wide chars + const char *key1w = "L\0O\0O\0P\0"; + const char *key2w = "P\0O\0I\0N\0T\0\0\0\xFF\xFE"; + const char *key3w = "M\0S\0\0\0\xFF\xFE"; + const char *key4w = "L\0E\0N\0G\0T\0H\0M\0S\0\0\0\xFF\xFE"; + const char *wterm = "\0\0"; + char wval[10]; + + size_t wstart, wp; char *p = data; if (music @@ -573,6 +885,8 @@ boolean I_LoadSong(char *data, size_t len) ) I_UnloadSong(); + var_cleanup(); + #ifdef HAVE_LIBGME if ((UINT8)data[0] == 0x1F && (UINT8)data[1] == 0x8B) @@ -675,32 +989,96 @@ boolean I_LoadSong(char *data, size_t len) return false; } + if (I_SongType() == MU_MP3) + { + CONS_Debug(DBG_BASIC, "MP3 songs are unsupported and may crash! Use OGG instead.\n"); + CONS_Debug(DBG_DETAILED, "MP3 songs are unsupported and may crash! Use OGG instead.\n"); + } + // Find the OGG loop point. loop_point = 0.0f; + song_length = 0.0f; while ((UINT32)(p - data) < len) { - if (strncmp(p++, key1, key1len)) - continue; - p += key1len-1; // skip OOP (the L was skipped in strncmp) - if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? + if (!loop_point && !strncmp(p, key1, key1len)) { - p += key2len; // skip POINT= - loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. - // because SDL_Mixer is USELESS and can't even tell us - // something simple like the frequency of the streaming music, - // we are unfortunately forced to assume that ALL MUSIC is 44100hz. - // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. + p += key1len; // skip LOOP + if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? + { + p += key2len; // skip POINT= + loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. + // because SDL_Mixer is USELESS and can't even tell us + // something simple like the frequency of the streaming music, + // we are unfortunately forced to assume that ALL MUSIC is 44100hz. + // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. + } + else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? + { + p += key3len; // skip MS= + loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. + // Everything that uses LOOPMS will work perfectly with SDL_Mixer. + } } - else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? + else if (!song_length && !strncmp(p, key4, key4len)) // is it LENGTHMS=? { - p += key3len; // skip MS= - loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. - // Everything that uses LOOPMS will work perfectly with SDL_Mixer. + p += key4len; // skip LENGTHMS + song_length = (float)(atoi(p) / 1000.0L); + } + // below: search MP3 or other tags that use wide char encoding + else if (!loop_point && !memcmp(p, key1w, key1len*2)) // LOOP wide char + { + p += key1len*2; + if (!memcmp(p, key2w, (key2len+1)*2)) // POINT= wide char + { + p += (key2len+1)*2; + wstart = (size_t)p; + wp = 0; + while (wp < 9 && memcmp(p, wterm, 2)) + { + wval[wp] = *p; + p += 2; + wp = ((size_t)(p-wstart))/2; + } + wval[min(wp, 9)] = 0; + loop_point = (float)((44.1L+atoi(wval) / 44100.0L)); + } + else if (!memcmp(p, key3w, (key3len+1)*2)) // MS= wide char + { + p += (key3len+1)*2; + wstart = (size_t)p; + wp = 0; + while (wp < 9 && memcmp(p, wterm, 2)) + { + wval[wp] = *p; + p += 2; + wp = ((size_t)(p-wstart))/2; + } + wval[min(wp, 9)] = 0; + loop_point = (float)(atoi(wval) / 1000.0L); + } + } + else if (!song_length && !memcmp(p, key4w, (key4len+1)*2)) // LENGTHMS= wide char + { + p += (key4len+1)*2; + wstart = (size_t)p; + wp = 0; + while (wp < 9 && memcmp(p, wterm, 2)) + { + wval[wp] = *p; + p += 2; + wp = ((size_t)(p-wstart))/2; + } + wval[min(wp, 9)] = 0; + song_length = (float)(atoi(wval) / 1000.0L); } - // Neither?! Continue searching. - } + if (loop_point && song_length && song_length > loop_point) // Got what we needed + // the last case is a sanity check, in case the wide char searches were false matches. + break; + else // continue searching + p++; + } return true; } @@ -737,15 +1115,30 @@ boolean I_PlaySong(boolean looping) if (!music) return false; - if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) + if (!song_length && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC)) + CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n"); + + if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1) + { + CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); + return false; + } + else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false; } - Mix_VolumeMusic((UINT32)music_volume*128/31); - if (loop_point != 0.0f) - Mix_HookMusicFinished(music_loop); + is_looping = looping; + + I_SetMusicVolume(music_volume); + + if (I_SongType() != MU_MOD && I_SongType() != MU_MID) + Mix_HookMusicFinished(music_loop); // don't bother counting if MOD + + if(I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL)) + CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError()); + return true; } @@ -760,19 +1153,40 @@ void I_StopSong(void) #endif if (music) { + var_cleanup(); + I_StopFadingSong(); + Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes); Mix_HookMusicFinished(NULL); Mix_HaltMusic(); } } -void I_PauseSong(void) +void I_PauseSong() { + if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI??? + return; + + if(I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID) + Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes); + Mix_PauseMusic(); songpaused = true; } -void I_ResumeSong(void) +void I_ResumeSong() { + if (I_SongType() == MU_MID) + return; + + if (I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID) + { + while(Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes) != 0) { } + // HACK: fixes issue of multiple effect callbacks being registered + + if(music && I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL)) + CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError()); + } + Mix_ResumeMusic(); songpaused = false; } @@ -791,7 +1205,7 @@ void I_SetMusicVolume(UINT8 volume) #endif music_volume = volume; - Mix_VolumeMusic((UINT32)music_volume*128/31); + Mix_VolumeMusic(get_real_volume(music_volume)); } boolean I_SetSongTrack(int track) @@ -820,9 +1234,100 @@ boolean I_SetSongTrack(int track) SDL_UnlockAudio(); return false; } + else #endif + if (I_SongType() == MU_MOD) + return !Mix_SetMusicPosition(track); (void)track; return false; } +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + internal_volume = volume; + if (!I_SongPlaying()) + return; + Mix_VolumeMusic(get_real_volume(music_volume)); +} + +void I_StopFadingSong(void) +{ + if (fading_id) + SDL_RemoveTimer(fading_id); + is_fading = false; + fading_source = fading_target = fading_timer = fading_duration = fading_id = 0; +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) +{ + INT16 volume_delta; + + source_volume = min(source_volume, 100); + volume_delta = (INT16)(target_volume - source_volume); + + I_StopFadingSong(); + + if (!ms && volume_delta) + { + I_SetInternalMusicVolume(target_volume); + if (callback) + (*callback)(); + return true; + + } + else if (!volume_delta) + { + if (callback) + (*callback)(); + return true; + } + + // Round MS to nearest 10 + // If n - lower > higher - n, then round up + ms = (ms - ((ms / 10) * 10) > (((ms / 10) * 10) + 10) - ms) ? + (((ms / 10) * 10) + 10) // higher + : ((ms / 10) * 10); // lower + + if (!ms) + I_SetInternalMusicVolume(target_volume); + else if (source_volume != target_volume) + { + fading_id = SDL_AddTimer(10, music_fade, NULL); + if (fading_id) + { + is_fading = true; + fading_timer = fading_duration = ms; + fading_source = source_volume; + fading_target = target_volume; + fading_callback = callback; + + if (internal_volume != source_volume) + I_SetInternalMusicVolume(source_volume); + } + } + + return is_fading; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) +{ + return I_FadeSongFromVolume(target_volume, internal_volume, ms, callback); +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + return I_FadeSongFromVolume(0, internal_volume, ms, &I_StopSong); +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + if (I_PlaySong(looping)) + return I_FadeSongFromVolume(100, 0, ms, NULL); + else + return false; +} #endif \ No newline at end of file diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index e29ac080b..25c21a07a 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1368,6 +1368,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -1436,6 +1467,47 @@ boolean I_SetSongTrack(int track) return false; } +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} + /// ------------------------ // MUSIC LOADING AND CLEANUP // \todo Split logic between loading and playing, diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 36a5904a5..85cae2ed1 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -810,6 +810,60 @@ void I_SetMusicVolume(UINT8 volume) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); } +UINT32 I_GetSongLength() +{ + if (midimode) + return 0; + UINT32 length; + e = FMOD_Sound_GetLength(music_stream, length, FMOD_TIMEUNIT_MS); + return length; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + if(midimode) + // Dummy out; this works for some MIDI, but not others. + // SDL does not support this for any MIDI. + return false; + FMOD_RESULT e; + e = FMOD_Channel_SetPosition(music_channel, position, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return true; + else if (e == FMOD_ERR_UNSUPPORTED // Only music modules, numbnuts! + || e == FMOD_ERR_INVALID_POSITION) // Out-of-bounds! + return false; + else // Congrats, you horribly broke it somehow + { + FMR_MUSIC(e); + return false; + } +} + +UINT32 I_GetSongPosition(void) +{ + if(midimode) + // Dummy out because unsupported, even though FMOD does this correctly. + return 0; + FMOD_RESULT e; + unsigned int fmposition = 0; + e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return (UINT32)fmposition; + else + return 0; +} + boolean I_SetSongTrack(INT32 track) { if (track != current_track) // If the track's already playing, then why bother? @@ -854,3 +908,44 @@ boolean I_SetSongTrack(INT32 track) } return false; } + +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} From 66283ce36a233c82135f3bfb204f231af189336f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 10:32:38 -0400 Subject: [PATCH 02/80] MusicPlus core: Lua separation fixes --- src/lua_baselib.c | 36 ++++++++++++++++++++---------------- src/lua_hook.h | 1 - src/lua_hooklib.c | 1 - 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f7a0a5995..6a8784259 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -720,13 +720,8 @@ static int lib_pRestoreMusic(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); else if (P_IsLocalPlayer(player)) - { P_RestoreMusic(player); - lua_pushboolean(L, true); - } - else - lua_pushnil(L); - return 1; + return 0; } static int lib_pSpawnShieldOrb(lua_State *L) @@ -1780,13 +1775,8 @@ static int lib_sChangeMusic(lua_State *L) fadeinms = (UINT32)luaL_optinteger(L, 7, 0); if (!player || P_IsLocalPlayer(player)) - { S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms); - lua_pushboolean(L, true); - } - else - lua_pushnil(L); - return 1; + return 0; } static int lib_sSpeedMusic(lua_State *L) @@ -1802,10 +1792,23 @@ static int lib_sSpeedMusic(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!player || P_IsLocalPlayer(player)) - lua_pushboolean(L, S_SpeedMusic(speed)); - else - lua_pushnil(L); - return 1; + S_SpeedMusic(speed); + return 0; +} + +static int lib_sStopMusic(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + S_StopMusic(); + return 0; } static int lib_sOriginPlaying(lua_State *L) @@ -2130,6 +2133,7 @@ static luaL_Reg lib[] = { {"S_StopSound",lib_sStopSound}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, + {"S_StopMusic",lib_sStopMusic}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 74a6b5e75..53e0a7d8e 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -43,7 +43,6 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, - hook_MusicChange, hook_MAX // last hook }; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index dff2b8f46..eadd01537 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -54,7 +54,6 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", - "MusicChange", NULL }; From 1a935eabd53ed4b1aceb64592cfb24811f4a4ec0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 12:51:42 -0400 Subject: [PATCH 03/80] Mixer I_StopSong: StopFadingSong and var_cleanup call fix --- src/sdl/mixer_sound.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 9b09ffe80..fbd587322 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1144,6 +1144,8 @@ boolean I_PlaySong(boolean looping) void I_StopSong(void) { + I_StopFadingSong(); + #ifdef HAVE_LIBGME if (gme) { @@ -1153,12 +1155,12 @@ void I_StopSong(void) #endif if (music) { - var_cleanup(); - I_StopFadingSong(); Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes); Mix_HookMusicFinished(NULL); Mix_HaltMusic(); } + + var_cleanup(); } void I_PauseSong() From b71996106be2bbefc085d0f8e4277ecd4dbc6ddf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 13:23:08 -0400 Subject: [PATCH 04/80] MusicPlus core: NOMIXER=1 compile fix --- src/sdl/sdl_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 25c21a07a..d3b51b15e 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1480,7 +1480,7 @@ void I_StopFadingSong(void) { } -boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) { (void)target_volume; (void)source_volume; @@ -1488,7 +1488,7 @@ boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms return false; } -boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) { (void)target_volume; (void)ms; From e4f48cfb71bbc24c173346e5290689765db30e6d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 14:08:31 -0400 Subject: [PATCH 05/80] MusicPlus core: Win32 DD compile fixes --- src/win32/win_snd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 85cae2ed1..543de3231 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -812,10 +812,10 @@ void I_SetMusicVolume(UINT8 volume) UINT32 I_GetSongLength() { - if (midimode) + if (I_SongType() == MU_MID) return 0; UINT32 length; - e = FMOD_Sound_GetLength(music_stream, length, FMOD_TIMEUNIT_MS); + FMR_MUSIC(FMOD_Sound_GetLength(music_stream, &length, FMOD_TIMEUNIT_MS)); return length; } @@ -832,7 +832,7 @@ UINT32 I_GetSongLoopPoint(void) boolean I_SetSongPosition(UINT32 position) { - if(midimode) + if(I_SongType() == MU_MID) // Dummy out; this works for some MIDI, but not others. // SDL does not support this for any MIDI. return false; @@ -852,7 +852,7 @@ boolean I_SetSongPosition(UINT32 position) UINT32 I_GetSongPosition(void) { - if(midimode) + if(I_SongType() == MU_MID) // Dummy out because unsupported, even though FMOD does this correctly. return 0; FMOD_RESULT e; @@ -922,7 +922,7 @@ void I_StopFadingSong(void) { } -boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) { (void)target_volume; (void)source_volume; @@ -930,7 +930,7 @@ boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms return false; } -boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) { (void)target_volume; (void)ms; From 0cfe0824b6c003afce5bca0d4495a09312ea155f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 15:10:42 -0400 Subject: [PATCH 06/80] Lua P_RestoreMusic else if fix --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6a8784259..093683660 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -719,7 +719,7 @@ static int lib_pRestoreMusic(lua_State *L) NOHUD if (!player) return LUA_ErrInvalid(L, "player_t"); - else if (P_IsLocalPlayer(player)) + if (P_IsLocalPlayer(player)) P_RestoreMusic(player); return 0; } From 2e0e0a3856cda84dd867ed3dc5ca30701e2233f8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 15:28:57 -0400 Subject: [PATCH 07/80] musicplus-le-changemusic 2.2 -> 2.1 backport --- src/p_setup.c | 36 ++++++++++++++++++++++---------- src/p_spec.c | 58 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 19 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6c6b9153d..f504ffb57 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1514,19 +1514,33 @@ static void P_LoadSideDefs2(lumpnum_t lumpnum) { M_Memcpy(process,msd->bottomtexture,8); process[8] = '\0'; - sd->bottomtexture = get_number(process)-1; + sd->bottomtexture = get_number(process); } - M_Memcpy(process,msd->toptexture,8); - process[8] = '\0'; - sd->text = Z_Malloc(7, PU_LEVEL, NULL); - // If they type in O_ or D_ and their music name, just shrug, - // then copy the rest instead. - if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); - else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); - sd->text[6] = 0; + if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') + { + M_Memcpy(process,msd->midtexture,8); + process[8] = '\0'; + sd->midtexture = get_number(process); + } + + // always process if back sidedef, because we need that - symbol + sd->text = Z_Malloc(7, PU_LEVEL, NULL); + if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') + { + M_Memcpy(process,msd->toptexture,8); + process[8] = '\0'; + + // If they type in O_ or D_ and their music name, just shrug, + // then copy the rest instead. + if ((process[0] == 'O' || process[0] == 'D') && process[7]) + M_Memcpy(sd->text, process+2, 6); + else // Assume it's a proper music name. + M_Memcpy(sd->text, process, 6); + sd->text[6] = 0; + } + else + sd->text[0] = 0; break; } case 414: // Play SFX diff --git a/src/p_spec.c b/src/p_spec.c index afc3c0533..7832ff038 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2419,18 +2419,60 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // console player only unless NOCLIMB is set if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) { - UINT16 tracknum = (UINT16)sides[line->sidenum[0]].bottomtexture; + boolean musicsame = (!sides[line->sidenum[0]].text[0] || !strnicmp(sides[line->sidenum[0]].text, S_MusicName(), 7)); + UINT16 tracknum = (UINT16)max(sides[line->sidenum[0]].bottomtexture, 0); + INT32 position = (INT32)max(sides[line->sidenum[0]].midtexture, 0); + UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0); + UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0); + UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); + INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : 0, -1); - strncpy(mapmusname, sides[line->sidenum[0]].text, 7); - mapmusname[6] = 0; + if (line->flags & ML_EFFECT1) + { + // adjust for loop point if subtracting + if (position < 0 && S_GetMusicLength() && + S_GetMusicPosition() > S_GetMusicLoopPoint() && + S_GetMusicPosition() + position < S_GetMusicLoopPoint()) + position = max(S_GetMusicLength() - (S_GetMusicLoopPoint() - (S_GetMusicPosition() + position)), 0); + else + position = max(S_GetMusicPosition() + position, 0); + } - mapmusflags = tracknum & MUSIC_TRACKMASK; - if (!(line->flags & ML_BLOCKMONSTERS)) - mapmusflags |= MUSIC_RELOADRESET; + if ((line->flags & ML_EFFECT2) && fadetarget && musicsame) + { + if (!postfadems) + S_SetInternalMusicVolume(fadetarget); + else + S_FadeMusicFromVolume(fadetarget, fadesource, postfadems); - mapmusposition = 0; + if (position) + S_SetMusicPosition(position); + } + else + { + strncpy(mapmusname, sides[line->sidenum[0]].text, 7); + mapmusname[6] = 0; - S_ChangeMusic(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4)); + mapmusflags = tracknum & MUSIC_TRACKMASK; + if (!(line->flags & ML_BLOCKMONSTERS)) + mapmusflags |= MUSIC_RELOADRESET; + if (line->flags & ML_BOUNCY) + mapmusflags |= MUSIC_FORCERESET; + + mapmusposition = position; + + S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, + !(line->flags & ML_EFFECT2) ? prefadems : 0, + !(line->flags & ML_EFFECT2) ? postfadems : 0); + + if ((line->flags & ML_EFFECT2) && fadetarget) + { + if (!postfadems) + S_SetInternalMusicVolume(fadetarget); + else + S_FadeMusicFromVolume(fadetarget, fadesource, postfadems); + } + } // Except, you can use the ML_BLOCKMONSTERS flag to change this behavior. // if (mapmusflags & MUSIC_RELOADRESET) then it will reset the music in G_PlayerReborn. From 00bbb60e69a4df5892b339cbbc985c9a337b2d5f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 22:15:53 -0400 Subject: [PATCH 08/80] Mixer: Add back var_cleanup in I_LoadSong Because musicplus-libopenmpt deleted it, I added a cautionary note to ALWAYS clean up your vars! --- src/sdl/mixer_sound.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index fbd587322..f966f531a 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -885,6 +885,7 @@ boolean I_LoadSong(char *data, size_t len) ) I_UnloadSong(); + // always do this whether or not a music already exists var_cleanup(); #ifdef HAVE_LIBGME From db9528f6e4b6a95b4b4ccb0ba730cba3e489c49a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 23:29:18 -0400 Subject: [PATCH 09/80] MP Core: 2.1 dehacked typo --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 6c6b9153d..4ca6c97c6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -185,7 +185,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->musname[6] = 0; DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); mapheaderinfo[num]->mustrack = 0; - DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); + DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->muspos), UNDO_NONE); mapheaderinfo[num]->muspos = 0; DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); mapheaderinfo[num]->forcecharacter[0] = '\0'; From 974b1d340aa81c4358b0cd8a138dea55db2d564e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 18:26:33 -0400 Subject: [PATCH 10/80] MP Core Mixer: Unused param fixes (buildbots) --- src/sdl/mixer_sound.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f966f531a..644a667b3 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -519,6 +519,10 @@ static void do_fading_callback() static void count_music_bytes(int chan, void *stream, int len, void *udata) { + (void)chan; + (void)stream; + (void)udata; + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) return; music_bytes += len; @@ -538,6 +542,8 @@ static void music_loop(void) static UINT32 music_fade(UINT32 interval, void *param) { + (void)param; + if (!is_fading || internal_volume == fading_target || fading_duration == 0) From ade637798b5458c59c8de7ad9c8490ed7efb4797 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 19:06:24 -0400 Subject: [PATCH 11/80] MP Core Mixer: Old-style function dec fixes (buildbots) --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 644a667b3..e5552b0a6 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -506,7 +506,7 @@ static UINT32 get_adjusted_position(UINT32 position) return position; } -static void do_fading_callback() +static void do_fading_callback(void) { if (fading_callback) (*fading_callback)(); @@ -1170,7 +1170,7 @@ void I_StopSong(void) var_cleanup(); } -void I_PauseSong() +void I_PauseSong(void) { if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI??? return; @@ -1182,7 +1182,7 @@ void I_PauseSong() songpaused = true; } -void I_ResumeSong() +void I_ResumeSong(void) { if (I_SongType() == MU_MID) return; From 96fa8996dbd174a9552b73fb37aa8387273357bb Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 19:18:35 -0400 Subject: [PATCH 12/80] MP Core Mixer fade: Use fixed instead of double calc (fixes buildbots) --- src/sdl/mixer_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index e5552b0a6..fc6ccf50c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -565,11 +565,11 @@ static UINT32 music_fade(UINT32 interval, void *param) else { UINT8 delta = abs(fading_target - fading_source); - double factor = (double)(fading_duration - fading_timer) / (double)fading_duration; + fixed_t factor = FixedDiv(fading_duration - fading_timer, fading_duration); if (fading_target < fading_source) - internal_volume = max(min(internal_volume, fading_source - (UINT8)round(delta * factor)), fading_target); + internal_volume = max(min(internal_volume, fading_source - FixedMul(delta, factor)), fading_target); else if (fading_target > fading_source) - internal_volume = min(max(internal_volume, fading_source + (UINT8)round(delta * factor)), fading_target); + internal_volume = min(max(internal_volume, fading_source + FixedMul(delta, factor)), fading_target); Mix_VolumeMusic(get_real_volume(music_volume)); return interval; } From 164be3056f96f33d3d32aab0324a0a7d50d0f0da Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 19:19:18 -0400 Subject: [PATCH 13/80] MP Core s_sound: Mixed D+C fix (buildbots) --- src/s_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 3da594fe1..4a9500e71 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1437,6 +1437,8 @@ static void S_ChangeMusicToQueue(void) void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { + char newmusic[7]; + #if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X) S_ClearSfx(); #endif @@ -1444,7 +1446,6 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 if (S_MusicDisabled()) return; - char newmusic[7]; strncpy(newmusic, mmusic, 7); #if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) From 2644180b7e5f2316cd64752b3424338efc03ede8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Sep 2018 19:46:57 -0400 Subject: [PATCH 14/80] MP Core s_sound: I_FadeSongFromVolume call fix (buildbots) --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 4a9500e71..4a52ead52 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1594,7 +1594,7 @@ boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 m if (source_volume < 0) return I_FadeSong(target_volume, ms, NULL); else - return I_FadeSongFromVolume(target_volume, source_volume, ms, false); + return I_FadeSongFromVolume(target_volume, source_volume, ms, NULL); } boolean S_FadeOutStopMusic(UINT32 ms) From 54f94b80db6b16908b29f6c9d131c39ac3b95d20 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 20 Sep 2018 08:41:40 -0400 Subject: [PATCH 15/80] MP Core Win32: Fix FadeSong unused callback param (buildbots) --- src/win32/win_snd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 543de3231..6fed59a93 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -927,6 +927,7 @@ boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms (void)target_volume; (void)source_volume; (void)ms; + (void)callback; return false; } @@ -934,6 +935,7 @@ boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) { (void)target_volume; (void)ms; + (void)callback; return false; } From 7916e020d2c21091209a23d3b37c262b39338d8c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 1 Jan 2019 10:47:16 -0500 Subject: [PATCH 16/80] Fix loop_point and song_length floating point comparisons --- src/sdl/mixer_sound.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 4a87712fa..04e82ea34 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1049,7 +1049,7 @@ boolean I_LoadSong(char *data, size_t len) while ((UINT32)(p - data) < len) { - if (!loop_point && !strncmp(p, key1, key1len)) + if (fpclassify(loop_point) == FP_ZERO && !strncmp(p, key1, key1len)) { p += key1len; // skip LOOP if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? @@ -1068,13 +1068,13 @@ boolean I_LoadSong(char *data, size_t len) // Everything that uses LOOPMS will work perfectly with SDL_Mixer. } } - else if (!song_length && !strncmp(p, key4, key4len)) // is it LENGTHMS=? + else if (fpclassify(song_length) == FP_ZERO && !strncmp(p, key4, key4len)) // is it LENGTHMS=? { p += key4len; // skip LENGTHMS song_length = (float)(atoi(p) / 1000.0L); } // below: search MP3 or other tags that use wide char encoding - else if (!loop_point && !memcmp(p, key1w, key1len*2)) // LOOP wide char + else if (fpclassify(loop_point) == FP_ZERO && !memcmp(p, key1w, key1len*2)) // LOOP wide char { p += key1len*2; if (!memcmp(p, key2w, (key2len+1)*2)) // POINT= wide char @@ -1106,7 +1106,7 @@ boolean I_LoadSong(char *data, size_t len) loop_point = (float)(atoi(wval) / 1000.0L); } } - else if (!song_length && !memcmp(p, key4w, (key4len+1)*2)) // LENGTHMS= wide char + else if (fpclassify(song_length) == FP_ZERO && !memcmp(p, key4w, (key4len+1)*2)) // LENGTHMS= wide char { p += (key4len+1)*2; wstart = (size_t)p; @@ -1121,7 +1121,7 @@ boolean I_LoadSong(char *data, size_t len) song_length = (float)(atoi(wval) / 1000.0L); } - if (loop_point && song_length && song_length > loop_point) // Got what we needed + if (fpclassify(loop_point) != FP_ZERO && fpclassify(song_length) != FP_ZERO && song_length > loop_point) // Got what we needed // the last case is a sanity check, in case the wide char searches were false matches. break; else // continue searching @@ -1150,7 +1150,6 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { - boolean lpz = fpclassify(loop_point) == FP_ZERO; #ifdef HAVE_LIBGME if (gme) { @@ -1164,7 +1163,7 @@ boolean I_PlaySong(boolean looping) if (!music) return false; - if (!song_length && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC)) + if (fpclassify(song_length) == FP_ZERO && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC)) CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n"); if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1) From e2e345988aa2567abb9ff6de11ad0e2b7f946278 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 04:58:03 -0500 Subject: [PATCH 17/80] Add safe lua music functions S_MusicExists S_SetInternalMusicVolume S_StopFadingMusic S_FadeMusic S_FadeOutStopMusic --- src/lua_baselib.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 00b309025..f5f3aeb76 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1899,6 +1899,42 @@ static int lib_sSpeedMusic(lua_State *L) return 0; } +static int lib_sMusicExists(lua_State *L) +{ + boolean checkMIDI = lua_opttrueboolean(L, 2); + boolean checkDigi = lua_opttrueboolean(L, 3); +#ifdef MUSICSLOT_COMPATIBILITY + const char *music_name; + UINT32 music_num; + char music_compat_name[7]; + UINT16 music_flags = 0; + NOHUD + if (lua_isnumber(L, 1)) + { + music_num = (UINT32)luaL_checkinteger(L, 1); + music_flags = (UINT16)(music_num & 0x0000FFFF); + if (music_flags && music_flags <= 1035) + snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags)); + else if (music_flags && music_flags <= 1050) + strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7); + else + music_compat_name[0] = 0; // becomes empty string + music_compat_name[6] = 0; + music_name = (const char *)&music_compat_name; + } + else + { + music_num = 0; + music_name = luaL_checkstring(L, 1); + } +#else + const char *music_name = luaL_checkstring(L, 1); +#endif + NOHUD + lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi)); + return 1; +} + static int lib_sStopMusic(lua_State *L) { player_t *player = NULL; @@ -1914,6 +1950,110 @@ static int lib_sStopMusic(lua_State *L) return 0; } +static int lib_sSetInternalMusicVolume(lua_State *L) +{ + UINT32 volume = (UINT32)luaL_checkinteger(L, 1); + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + { + player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_SetInternalMusicVolume(volume); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sStopFadingMusic(lua_State *L) +{ + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_StopFadingMusic(); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sFadeMusic(lua_State *L) +{ + UINT32 target_volume = (UINT32)luaL_checkinteger(L, 1); + UINT32 ms; + INT32 source_volume; + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) + { + player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + ms = (UINT32)luaL_checkinteger(L, 2); + source_volume = -1; + } + else if (!lua_isnone(L, 4) && lua_isuserdata(L, 4)) + { + player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + source_volume = (INT32)luaL_checkinteger(L, 2); + ms = (UINT32)luaL_checkinteger(L, 3); + } + else if (luaL_optinteger(L, 3, INT32_MAX) == INT32_MAX) + { + ms = (UINT32)luaL_checkinteger(L, 2); + source_volume = -1; + } + else + { + source_volume = (INT32)luaL_checkinteger(L, 2); + ms = (UINT32)luaL_checkinteger(L, 3); + } + + NOHUD + + if (!player || P_IsLocalPlayer(player)) + lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms)); + else + lua_pushnil(L); + return 1; +} + +static int lib_sFadeOutStopMusic(lua_State *L) +{ + UINT32 ms = (UINT32)luaL_checkinteger(L, 1); + player_t *player = NULL; + NOHUD + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + { + player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + lua_pushboolean(L, S_FadeOutStopMusic(ms)); + } + else + lua_pushnil(L); + return 1; +} + static int lib_sOriginPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -2265,7 +2405,12 @@ static luaL_Reg lib[] = { {"S_StopSound",lib_sStopSound}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, + {"S_MusicExists",lib_sMusicExists}, {"S_StopMusic",lib_sStopMusic}, + {"S_SetInternalMusicVolume", lib_sSetInternalMusicVolume}, + {"S_StopFadingMusic",lib_sStopFadingMusic}, + {"S_FadeMusic",lib_sFadeMusic}, + {"S_FadeOutStopMusic",lib_sFadeOutStopMusic}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, From 827461cc36e1d7aa73174c7f437ca2366e640935 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 21 Oct 2018 14:51:49 -0400 Subject: [PATCH 18/80] Support for per-map intermission music --- src/dehacked.c | 3 +++ src/doomstat.h | 3 +++ src/lua_maplib.c | 2 ++ src/p_setup.c | 2 ++ src/y_inter.c | 12 ++++++++++-- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 871fa0a44..011936688 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1198,6 +1198,9 @@ static void readlevelheader(MYFILE *f, INT32 num) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2); + else if (fastcmp(word, "MUSICINTER")) + deh_strlcpy(mapheaderinfo[num-1]->musintername, word2, + sizeof(mapheaderinfo[num-1]->musintername), va("Level header %d: intermission music", num)); else if (fastcmp(word, "FORCECHARACTER")) { strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); diff --git a/src/doomstat.h b/src/doomstat.h index ad989f365..716c4d654 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -247,6 +247,9 @@ typedef struct UINT8 numGradedMares; ///< Internal. For grade support. nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. + // Music stuff. + char musintername[7]; ///< Intermission screen music. + // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index e63ea34d8..d77e636b3 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1470,6 +1470,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->mustrack); else if (fastcmp(field,"muspos")) lua_pushinteger(L, header->muspos); + else if (fastcmp(field,"musintername")) + lua_pushstring(L, header->musintername); else if (fastcmp(field,"forcecharacter")) lua_pushstring(L, header->forcecharacter); else if (fastcmp(field,"weather")) diff --git a/src/p_setup.c b/src/p_setup.c index db7379fbb..4409ec356 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -189,6 +189,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->mustrack = 0; DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->muspos), UNDO_NONE); mapheaderinfo[num]->muspos = 0; + DEH_WriteUndoline("MUSICINTER", mapheaderinfo[num]->musintername, UNDO_NONE); + mapheaderinfo[num]->musintername[0] = '\0'; DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); mapheaderinfo[num]->forcecharacter[0] = '\0'; DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE); diff --git a/src/y_inter.c b/src/y_inter.c index 4b340cabd..e6e5a1d22 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -696,7 +696,12 @@ void Y_Ticker(void) boolean anybonuses = false; if (!intertic) // first time only - S_ChangeMusicInternal("lclear", false); // don't loop it + { + if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it + else + S_ChangeMusicInternal("lclear", false); // don't loop it + } if (intertic < TICRATE) // one second pause before tally begins return; @@ -757,7 +762,10 @@ void Y_Ticker(void) if (!intertic) // first time only { - S_ChangeMusicInternal("lclear", false); // don't loop it + if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it + else + S_ChangeMusicInternal("lclear", false); // don't loop it tallydonetic = 0; } From 2bd794c0069d8320c7978dd7bb4e95bc9cf76eef Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 06:26:18 -0500 Subject: [PATCH 19/80] Remove S_MusicExists lua --- src/lua_baselib.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f5f3aeb76..d3443312a 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1899,42 +1899,6 @@ static int lib_sSpeedMusic(lua_State *L) return 0; } -static int lib_sMusicExists(lua_State *L) -{ - boolean checkMIDI = lua_opttrueboolean(L, 2); - boolean checkDigi = lua_opttrueboolean(L, 3); -#ifdef MUSICSLOT_COMPATIBILITY - const char *music_name; - UINT32 music_num; - char music_compat_name[7]; - UINT16 music_flags = 0; - NOHUD - if (lua_isnumber(L, 1)) - { - music_num = (UINT32)luaL_checkinteger(L, 1); - music_flags = (UINT16)(music_num & 0x0000FFFF); - if (music_flags && music_flags <= 1035) - snprintf(music_compat_name, 7, "%sM", G_BuildMapName((INT32)music_flags)); - else if (music_flags && music_flags <= 1050) - strncpy(music_compat_name, compat_special_music_slots[music_flags - 1036], 7); - else - music_compat_name[0] = 0; // becomes empty string - music_compat_name[6] = 0; - music_name = (const char *)&music_compat_name; - } - else - { - music_num = 0; - music_name = luaL_checkstring(L, 1); - } -#else - const char *music_name = luaL_checkstring(L, 1); -#endif - NOHUD - lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi)); - return 1; -} - static int lib_sStopMusic(lua_State *L) { player_t *player = NULL; @@ -2405,7 +2369,6 @@ static luaL_Reg lib[] = { {"S_StopSound",lib_sStopSound}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, - {"S_MusicExists",lib_sMusicExists}, {"S_StopMusic",lib_sStopMusic}, {"S_SetInternalMusicVolume", lib_sSetInternalMusicVolume}, {"S_StopFadingMusic",lib_sStopFadingMusic}, From 2e4c1395511a0e6427742ef8d9c115e6cec55aa1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 06:48:06 -0500 Subject: [PATCH 20/80] DD Compile fixes --- src/win32/win_snd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 4507c27ff..f3e3bbed4 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -815,11 +815,11 @@ void I_SetMusicVolume(UINT8 volume) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); } -UINT32 I_GetSongLength() +UINT32 I_GetSongLength(void) { + UINT32 length; if (I_SongType() == MU_MID) return 0; - UINT32 length; FMR_MUSIC(FMOD_Sound_GetLength(music_stream, &length, FMOD_TIMEUNIT_MS)); return length; } @@ -837,11 +837,11 @@ UINT32 I_GetSongLoopPoint(void) boolean I_SetSongPosition(UINT32 position) { + FMOD_RESULT e; if(I_SongType() == MU_MID) // Dummy out; this works for some MIDI, but not others. // SDL does not support this for any MIDI. return false; - FMOD_RESULT e; e = FMOD_Channel_SetPosition(music_channel, position, FMOD_TIMEUNIT_MS); if (e == FMOD_OK) return true; @@ -857,11 +857,11 @@ boolean I_SetSongPosition(UINT32 position) UINT32 I_GetSongPosition(void) { + FMOD_RESULT e; + unsigned int fmposition = 0; if(I_SongType() == MU_MID) // Dummy out because unsupported, even though FMOD does this correctly. return 0; - FMOD_RESULT e; - unsigned int fmposition = 0; e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS); if (e == FMOD_OK) return (UINT32)fmposition; From 356249dade14c25a0404e75fd5eacd61acbed443 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 17 Jan 2019 16:47:01 -0800 Subject: [PATCH 21/80] Set modifiers in a non-reactive manner --- src/console.c | 10 ---------- src/d_main.c | 31 +------------------------------ src/hu_stuff.c | 10 ---------- src/sdl/i_video.c | 16 ++++++++++++++-- 4 files changed, 15 insertions(+), 52 deletions(-) diff --git a/src/console.c b/src/console.c index 5c173e459..50e185770 100644 --- a/src/console.c +++ b/src/console.c @@ -1051,16 +1051,6 @@ boolean CON_Responder(event_t *ev) else if (key == KEY_KPADSLASH) key = '/'; - // capslock - if (key == KEY_CAPSLOCK) // it's a toggle. - { - if (capslock) - capslock = false; - else - capslock = true; - return true; - } - if (key >= 'a' && key <= 'z') { if (capslock ^ shiftdown) diff --git a/src/d_main.c b/src/d_main.c index dd2cfe0e5..bc180f9bc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -176,37 +176,11 @@ void D_PostEvent_end(void) {}; #endif // modifier keys +// Now handled in I_OsPolling UINT8 shiftdown = 0; // 0x1 left, 0x2 right UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. -// -// D_ModifierKeyResponder -// Sets global shift/ctrl/alt variables, never actually eats events -// -static inline void D_ModifierKeyResponder(event_t *ev) -{ - if (ev->type == ev_keydown || ev->type == ev_console) switch (ev->data1) - { - case KEY_LSHIFT: shiftdown |= 0x1; return; - case KEY_RSHIFT: shiftdown |= 0x2; return; - case KEY_LCTRL: ctrldown |= 0x1; return; - case KEY_RCTRL: ctrldown |= 0x2; return; - case KEY_LALT: altdown |= 0x1; return; - case KEY_RALT: altdown |= 0x2; return; - default: return; - } - else if (ev->type == ev_keyup) switch (ev->data1) - { - case KEY_LSHIFT: shiftdown &= ~0x1; return; - case KEY_RSHIFT: shiftdown &= ~0x2; return; - case KEY_LCTRL: ctrldown &= ~0x1; return; - case KEY_RCTRL: ctrldown &= ~0x2; return; - case KEY_LALT: altdown &= ~0x1; return; - case KEY_RALT: altdown &= ~0x2; return; - default: return; - } -} // // D_ProcessEvents @@ -220,9 +194,6 @@ void D_ProcessEvents(void) { ev = &events[eventtail]; - // Set global shift/ctrl/alt down variables - D_ModifierKeyResponder(ev); // never eats events - // Screenshots over everything so that they can be taken anywhere. if (M_ScreenshotResponder(ev)) continue; // ate the event diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e34e5c35c..a416f0d26 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1101,16 +1101,6 @@ boolean HU_Responder(event_t *ev) c = (INT32)ev->data1; - // capslock (now handled outside of chat on so that it works everytime......) - if (c && c == KEY_CAPSLOCK) // it's a toggle. - { - if (capslock) - capslock = false; - else - capslock = true; - return true; - } - #ifndef NONET if (!chat_on) { diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index dbaa7037a..71d806050 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -580,8 +580,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) if (cv_usemouse.value) I_StartupMouse(); } //else firsttimeonmouse = SDL_FALSE; - - capslock = !!( SDL_GetModState() & KMOD_CAPS );// in case CL changes } else if (!mousefocus && !kbfocus) { @@ -939,6 +937,8 @@ void I_StartupMouse(void) // void I_OsPolling(void) { + SDL_Keymod mod; + if (consolevent) I_GetConsoleEvents(); if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) @@ -951,6 +951,18 @@ void I_OsPolling(void) I_GetMouseEvents(); I_GetEvent(); + + mod = SDL_GetModState(); + /* Handle here so that our state is always synched with the system. */ + shiftdown = ctrldown = altdown = 0; + capslock = false; + if (mod & KMOD_LSHIFT) shiftdown |= 1; + if (mod & KMOD_RSHIFT) shiftdown |= 2; + if (mod & KMOD_LCTRL) ctrldown |= 1; + if (mod & KMOD_RCTRL) ctrldown |= 2; + if (mod & KMOD_LALT) altdown |= 1; + if (mod & KMOD_RALT) altdown |= 2; + if (mod & KMOD_CAPS) capslock = true; } // From c9d90f7688aa7804316e99649bd85765cf7942df Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 21 Feb 2019 19:44:18 -0500 Subject: [PATCH 22/80] Add command to ban an IP address. --- src/d_clisrv.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2529b05d0..8ba356b68 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2627,6 +2627,42 @@ static void Command_Ban(void) } +static void Command_BanIP(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("banip : ban an ip address\n")); + return; + } + + if (server) // Only the server can use this, otherwise does nothing. + { + const char *address = (COM_Argv(1)); + const char *reason; + + if (COM_Argc() == 2) + reason = NULL; + else + reason = COM_Argv(2); + + + if (I_SetBanAddress && I_SetBanAddress(address, NULL)) + { + if (reason) + CONS_Printf("Banned IP address %s for: %s\n", address, reason); + else + CONS_Printf("Banned IP address %s\n", address); + + Ban_Add(reason); + D_SaveBan(); + } + else + { + return; + } + } +} + static void Command_Kick(void) { if (COM_Argc() < 2) @@ -2906,6 +2942,7 @@ void D_ClientServerInit(void) COM_AddCommand("getplayernum", Command_GetPlayerNum); COM_AddCommand("kick", Command_Kick); COM_AddCommand("ban", Command_Ban); + COM_AddCommand("banip", Command_BanIP); COM_AddCommand("clearbans", Command_ClearBans); COM_AddCommand("showbanlist", Command_ShowBan); COM_AddCommand("reloadbans", Command_ReloadBan); From bf2f6ebc098e4089b30b4e3fd65110890cbac64c Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 18 Feb 2019 01:03:39 -0500 Subject: [PATCH 23/80] Save ban list right after banning. --- src/d_clisrv.c | 3 +++ src/djgppdos/i_system.c | 3 --- src/sdl12/i_system.c | 3 --- src/win32/win_sys.c | 3 --- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8ba356b68..f3b1451a4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2596,7 +2596,10 @@ static void Command_Ban(void) else { if (server) // only the server is allowed to do this right now + { Ban_Add(COM_Argv(2)); + D_SaveBan(); // save the ban list + } if (COM_Argc() == 2) { diff --git a/src/djgppdos/i_system.c b/src/djgppdos/i_system.c index dae9ed16e..5413bfdb4 100644 --- a/src/djgppdos/i_system.c +++ b/src/djgppdos/i_system.c @@ -615,9 +615,6 @@ void I_Quit (void) //added:16-02-98: when recording a demo, should exit using 'q' key, // but sometimes we forget and use 'F10'.. so save here too. M_SaveConfig (NULL); //save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif G_SaveGameData(); // Tails 12-08-2002 if (demorecording) G_CheckDemoStatus(); diff --git a/src/sdl12/i_system.c b/src/sdl12/i_system.c index 10fbc50ee..e9b292449 100644 --- a/src/sdl12/i_system.c +++ b/src/sdl12/i_system.c @@ -2282,9 +2282,6 @@ void I_Quit(void) quiting = SDL_FALSE; I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif G_SaveGameData(); // Tails 12-08-2002 //added:16-02-98: when recording a demo, should exit using 'q' key, // but sometimes we forget and use 'F10'.. so save here too. diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index 77a21f7f3..8b7adf7c6 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -639,9 +639,6 @@ void I_Error(const char *error, ...) if (!errorcount) { M_SaveConfig(NULL); // save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif G_SaveGameData(); } From bfbb83df23323ff0a57e952e48721db8e417e26a Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 18 Feb 2019 02:04:58 -0500 Subject: [PATCH 24/80] Save when quitting the game. Also use default reason if not custom reason is given. --- src/djgppdos/i_system.c | 3 +++ src/sdl12/i_system.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/djgppdos/i_system.c b/src/djgppdos/i_system.c index 5413bfdb4..dae9ed16e 100644 --- a/src/djgppdos/i_system.c +++ b/src/djgppdos/i_system.c @@ -615,6 +615,9 @@ void I_Quit (void) //added:16-02-98: when recording a demo, should exit using 'q' key, // but sometimes we forget and use 'F10'.. so save here too. M_SaveConfig (NULL); //save game config, cvars.. +#ifndef NONET + D_SaveBan(); // save the ban list +#endif G_SaveGameData(); // Tails 12-08-2002 if (demorecording) G_CheckDemoStatus(); diff --git a/src/sdl12/i_system.c b/src/sdl12/i_system.c index e9b292449..10fbc50ee 100644 --- a/src/sdl12/i_system.c +++ b/src/sdl12/i_system.c @@ -2282,6 +2282,9 @@ void I_Quit(void) quiting = SDL_FALSE; I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. +#ifndef NONET + D_SaveBan(); // save the ban list +#endif G_SaveGameData(); // Tails 12-08-2002 //added:16-02-98: when recording a demo, should exit using 'q' key, // but sometimes we forget and use 'F10'.. so save here too. From 230faf15de9f3ab6f043b5711f32930adad4225d Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 19 Feb 2019 21:22:35 -0500 Subject: [PATCH 25/80] Some small changes. From 3d5d02fc15197eac5a663f5c79db21ff88cae5a4 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 19:58:01 -0500 Subject: [PATCH 26/80] Error if the lump is a PNG lump --- src/w_wad.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index 88e89974a..9ca4e0ff0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1175,6 +1175,29 @@ void zerr(int ret) } #endif +#define NO_PNG_LUMPS + +#ifdef NO_PNG_LUMPS +static void ErrorIfPNG(void *d, size_t s, char *f, char *l) +{ + if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ + return; +#define sigcheck ((UINT8 *)d) + if (sigcheck[0] == 0x89 + && sigcheck[1] == 0x50 + && sigcheck[2] == 0x4e + && sigcheck[3] == 0x47 + && sigcheck[4] == 0x0d + && sigcheck[5] == 0x0a + && sigcheck[6] == 0x1a + && sigcheck[7] == 0x0a) + { + I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); + } +#undef sigcheck +} +#endif + /** Reads bytes from the head of a lump. * Note: If the lump is compressed, the whole thing has to be read anyway. * @@ -1214,7 +1237,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si switch(wadfiles[wad]->lumpinfo[lump].compression) { case CM_NOCOMPRESSION: // If it's uncompressed, we directly write the data into our destination, and return the bytes read. +#ifdef NO_PNG_LUMPS + { + size_t bytesread = fread(dest, 1, size, handle); + ErrorIfPNG(dest, bytesread, wadfiles[wad]->filename, l->name2); + return bytesread; + } +#else return fread(dest, 1, size, handle); +#endif case CM_LZF: // Is it LZF compressed? Used by ZWADs. { #ifdef ZWAD @@ -1249,11 +1280,15 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si M_Memcpy(dest, decData + offset, size); Z_Free(rawData); Z_Free(decData); +#ifdef NO_PNG_LUMPS + ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); +#endif return size; #else //I_Error("ZWAD files not supported on this platform."); return 0; #endif + } #ifdef HAVE_ZLIB case CM_DEFLATE: // Is it compressed via DEFLATE? Very common in ZIPs/PK3s, also what most doom-related editors support. @@ -1307,6 +1342,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); Z_Free(decData); +#ifdef NO_PNG_LUMPS + ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); +#endif return size; } #endif From 15323328c5659ebee4c5b740c52b1968167e0f56 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 22:43:21 -0500 Subject: [PATCH 27/80] Check using memcmp() --- src/w_wad.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 9ca4e0ff0..b5aa95fac 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1183,14 +1183,10 @@ static void ErrorIfPNG(void *d, size_t s, char *f, char *l) if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ return; #define sigcheck ((UINT8 *)d) - if (sigcheck[0] == 0x89 - && sigcheck[1] == 0x50 - && sigcheck[2] == 0x4e - && sigcheck[3] == 0x47 - && sigcheck[4] == 0x0d - && sigcheck[5] == 0x0a - && sigcheck[6] == 0x1a - && sigcheck[7] == 0x0a) + // Check for PNG file signature using memcmp + // As it may be faster on CPUs with slow unaligned memory access + // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature + if (memcmp(&sigcheck[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) { I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); } From 9542a47f7fee56f6078b9973233b911370476ef3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 3 Mar 2019 22:57:09 -0500 Subject: [PATCH 28/80] New -noxinput and -nohidapi command line parameters. --- src/sdl/i_system.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index b5597784e..517c183ee 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1402,7 +1402,13 @@ static int joy_open2(const char *fname) void I_InitJoystick(void) { I_ShutdownJoystick(); - SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-noxinput")) + SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-nohidapi")) + SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); + if (!strcmp(cv_usejoystick.string, "0") || M_CheckParm("-nojoy")) return; if (joy_open(cv_usejoystick.string) != -1) @@ -1418,7 +1424,13 @@ void I_InitJoystick(void) void I_InitJoystick2(void) { I_ShutdownJoystick2(); - SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-noxinput")) + SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); + + if (M_CheckParm("-nohidapi")) + SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); + if (!strcmp(cv_usejoystick2.string, "0") || M_CheckParm("-nojoy")) return; if (joy_open2(cv_usejoystick2.string) != -1) From 60ca6ae06b3a58e24911e95030c1748581904552 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 9 Mar 2019 19:41:56 -0500 Subject: [PATCH 29/80] TravisCI: add option for GCC 8.1 --- .travis.yml | 8 ++++++-- src/Makefile.cfg | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1131bff3a..50dbab791 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ matrix: - p7zip-full - gcc-4.4 compiler: gcc-4.4 + env: GCC44=1 #gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7 - os: linux addons: @@ -27,6 +28,7 @@ matrix: - p7zip-full - gcc-4.6 compiler: gcc-4.6 + env: GCC46=1 #gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4 - os: linux addons: @@ -42,6 +44,7 @@ matrix: #gcc-4.7 - os: linux compiler: gcc + env: GCC48=1 #gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 - os: linux addons: @@ -56,6 +59,7 @@ matrix: - p7zip-full - gcc-4.8 compiler: gcc-4.8 + env: GCC48=1 #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: @@ -70,7 +74,7 @@ matrix: - p7zip-full - gcc-7 compiler: gcc-7 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1 #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 - os: linux addons: @@ -85,7 +89,7 @@ matrix: - p7zip-full - gcc-8 compiler: gcc-8 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" GCC81=1 #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 - os: linux compiler: clang diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 236d7ae2f..a0398154a 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -7,6 +7,10 @@ # and other things # +ifdef GCC81 +GCC80=1 +endif + ifdef GCC80 GCC72=1 endif From 8780800e8ee207c76f29591e0997cbd53d8ce0ce Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 9 Mar 2019 20:16:54 -0500 Subject: [PATCH 30/80] TravisCI: remove WFLAGS --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50dbab791..77fd82c80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,7 @@ matrix: - p7zip-full - gcc-4.7 compiler: gcc-4.7 + env: GCC47=1 #gcc-4.7 - os: linux compiler: gcc @@ -74,7 +75,7 @@ matrix: - p7zip-full - gcc-7 compiler: gcc-7 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1 + env: GCC72=1 #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 - os: linux addons: @@ -89,7 +90,7 @@ matrix: - p7zip-full - gcc-8 compiler: gcc-8 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" GCC81=1 + env: GCC81=1 #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 - os: linux compiler: clang From cd39b951bb8241fa1baef191571f0f9a64f31a66 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 9 Mar 2019 20:35:23 -0500 Subject: [PATCH 31/80] partly Revert "TravisCI: remove WFLAGS" This reverts commit 8780800e8ee207c76f29591e0997cbd53d8ce0ce. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77fd82c80..4bfc58860 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ matrix: - p7zip-full - gcc-7 compiler: gcc-7 - env: GCC72=1 + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1 #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 - os: linux addons: @@ -90,7 +90,7 @@ matrix: - p7zip-full - gcc-8 compiler: gcc-8 - env: GCC81=1 + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" GCC81=1 #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 - os: linux compiler: clang From aea18f36baea9d68f3252e5b7c2723f6f632afed Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 19:42:29 -0400 Subject: [PATCH 32/80] Remove MP3 warning --- src/sdl/mixer_sound.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 04e82ea34..dde62fc7a 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1037,12 +1037,6 @@ boolean I_LoadSong(char *data, size_t len) return false; } - if (I_SongType() == MU_MP3) - { - CONS_Debug(DBG_BASIC, "MP3 songs are unsupported and may crash! Use OGG instead.\n"); - CONS_Debug(DBG_DETAILED, "MP3 songs are unsupported and may crash! Use OGG instead.\n"); - } - // Find the OGG loop point. loop_point = 0.0f; song_length = 0.0f; From 2c75d4da696fd85567559215af14a602e376f93b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 19:44:24 -0400 Subject: [PATCH 33/80] Fix custom fade source bug for Change Music linedef --- src/p_spec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index e8dc80a75..f3be86ee1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2414,8 +2414,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0); UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0); UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); - INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : 0, -1); + INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); + // Seek offset from current song position if (line->flags & ML_EFFECT1) { // adjust for loop point if subtracting @@ -2427,8 +2428,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) position = max(S_GetMusicPosition() + position, 0); } + // Fade current music to target volume (if music won't be changed) if ((line->flags & ML_EFFECT2) && fadetarget && musicsame) { + // 0 fadesource means fade from current volume. + // meaning that we can't specify volume 0 as the source volume -- this starts at 1. + if (!fadesource) + fadesource = -1; + if (!postfadems) S_SetInternalMusicVolume(fadetarget); else @@ -2437,6 +2444,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (position) S_SetMusicPosition(position); } + // Change the music and apply position/fade operations else { strncpy(mapmusname, sides[line->sidenum[0]].text, 7); From c021e298357c2fd96d2992394c4bd53a49f8d6a0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 21:18:23 -0400 Subject: [PATCH 34/80] Restore MUSIC_RELOADRESET if block in g_game --- src/g_game.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 0992d55a7..c0cb469a1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2263,6 +2263,22 @@ void G_PlayerReborn(INT32 player) if ((netgame || multiplayer) && !p->spectator) p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent + if (p-players == consoleplayer) + { + if (mapmusflags & MUSIC_RELOADRESET) + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } + + // This is in S_Start, but this was not here previously. + // if (cv_resetmusic.value) + // S_StopMusic(); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + } + if (gametype == GT_COOP) P_FindEmerald(); // scan for emeralds to hunt for From 67e28573030210350f99f18a6e70fd0265eeb3cf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 23:17:35 -0400 Subject: [PATCH 35/80] When changing to same music, reset the internal volume --- src/s_sound.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index 89eb697cc..f3e330847 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1523,6 +1523,11 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 I_SetSongPosition(position); I_FadeSong(100, fadeinms, NULL); } + else // reset volume to 100 with same music + { + I_StopFadingSong(); + I_SetInternalMusicVolume(100); + } } void S_StopMusic(void) From fdde5f13c59e8a55278ab128ce6b295d5dd600c3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 23:55:30 -0400 Subject: [PATCH 36/80] When resetting volume on same music, make it fade instead of a hard change --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index f3e330847..acb7dcbbe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1526,7 +1526,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 else // reset volume to 100 with same music { I_StopFadingSong(); - I_SetInternalMusicVolume(100); + I_FadeSong(100, 500, NULL); } } From 6cf05a46132d642eaa3761a9c9a285822006f3b4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 15 Mar 2019 01:00:50 -0400 Subject: [PATCH 37/80] Implement MUSICINTERFADEOUT level header --- src/dehacked.c | 2 ++ src/doomstat.h | 1 + src/lua_maplib.c | 2 ++ src/p_setup.c | 2 ++ src/y_inter.c | 8 ++++++-- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6978dd16a..bda0c38f7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1198,6 +1198,8 @@ static void readlevelheader(MYFILE *f, INT32 num) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2); + else if (fastcmp(word, "MUSICINTERFADEOUT")) + mapheaderinfo[num-1]->musinterfadeout = (UINT32)get_number(word2); else if (fastcmp(word, "MUSICINTER")) deh_strlcpy(mapheaderinfo[num-1]->musintername, word2, sizeof(mapheaderinfo[num-1]->musintername), va("Level header %d: intermission music", num)); diff --git a/src/doomstat.h b/src/doomstat.h index 716c4d654..d9132798f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -248,6 +248,7 @@ typedef struct nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. // Music stuff. + UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds char musintername[7]; ///< Intermission screen music. // Lua stuff. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index d77e636b3..35542fdce 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1470,6 +1470,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->mustrack); else if (fastcmp(field,"muspos")) lua_pushinteger(L, header->muspos); + else if (fastcmp(field,"musinterfadeout")) + lua_pushinteger(L, header->musinterfadeout); else if (fastcmp(field,"musintername")) lua_pushstring(L, header->musintername); else if (fastcmp(field,"forcecharacter")) diff --git a/src/p_setup.c b/src/p_setup.c index 4409ec356..033e99f10 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -189,6 +189,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->mustrack = 0; DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->muspos), UNDO_NONE); mapheaderinfo[num]->muspos = 0; + DEH_WriteUndoline("MUSICINTERFADEOUT", va("%d", mapheaderinfo[num]->musinterfadeout), UNDO_NONE); + mapheaderinfo[num]->musinterfadeout = 0; DEH_WriteUndoline("MUSICINTER", mapheaderinfo[num]->musintername, UNDO_NONE); mapheaderinfo[num]->musintername[0] = '\0'; DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); diff --git a/src/y_inter.c b/src/y_inter.c index e6e5a1d22..1b7796efa 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -697,7 +697,9 @@ void Y_Ticker(void) if (!intertic) // first time only { - if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + if (mapheaderinfo[gamemap-1]->musinterfadeout) + S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); + else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it else S_ChangeMusicInternal("lclear", false); // don't loop it @@ -762,7 +764,9 @@ void Y_Ticker(void) if (!intertic) // first time only { - if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + if (mapheaderinfo[gamemap-1]->musinterfadeout) + S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); + else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it else S_ChangeMusicInternal("lclear", false); // don't loop it From 6b93ca92211024713fc12ca066e2d712b6088fb6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 15 Mar 2019 01:26:13 -0400 Subject: [PATCH 38/80] Intermission: Don't fade out level music when using win32 midi volume hack --- src/y_inter.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 1b7796efa..ed4972d2e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -697,7 +697,12 @@ void Y_Ticker(void) if (!intertic) // first time only { - if (mapheaderinfo[gamemap-1]->musinterfadeout) + if (mapheaderinfo[gamemap-1]->musinterfadeout +#ifdef _WIN32 + // can't fade midi due to win32 volume hack + && S_MusicType() != MU_MID +#endif + ) S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it @@ -764,7 +769,12 @@ void Y_Ticker(void) if (!intertic) // first time only { - if (mapheaderinfo[gamemap-1]->musinterfadeout) + if (mapheaderinfo[gamemap-1]->musinterfadeout +#ifdef _WIN32 + // can't fade midi due to win32 volume hack + && S_MusicType() != MU_MID +#endif + ) S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it From 6d751ff30257ce2f24b8f1aadb848438786b2949 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 15 Mar 2019 18:46:25 -0400 Subject: [PATCH 39/80] Remove the define. --- src/w_wad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4f0142081..c4f9ceca8 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1182,19 +1182,17 @@ void zerr(int ret) #define NO_PNG_LUMPS #ifdef NO_PNG_LUMPS -static void ErrorIfPNG(void *d, size_t s, char *f, char *l) +static void ErrorIfPNG(UINT8 *d, size_t s, char *f, char *l) { if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ return; -#define sigcheck ((UINT8 *)d) // Check for PNG file signature using memcmp // As it may be faster on CPUs with slow unaligned memory access // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature - if (memcmp(&sigcheck[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) + if (memcmp(&d[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) { I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); } -#undef sigcheck } #endif From d03c53930bfa9f0265ec27223a6a4baa20bb0a73 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 18 Mar 2019 16:50:17 -0400 Subject: [PATCH 40/80] Update CMakeLists.txt, remove CMAKE_SIZEOF_VOID_P check --- CMakeLists.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb065d04..11898db5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,14 +54,6 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() -# 64-bit check -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - message(STATUS "Target is 64-bit") - set(SRB2_SYSTEM_BITS 64) -else() - set(SRB2_SYSTEM_BITS 32) -endif() - # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) @@ -73,9 +65,6 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Linux") add_definitions(-DLINUX) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - add_definitions(-DLINUX64) - endif() endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") From 2fb569857a75571c27b02ffe0230da43cb456312 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 18 Mar 2019 22:00:23 +0000 Subject: [PATCH 41/80] Added the Gametype_Names array and G_GetGametypeByName for ease in converting gametype nums to strings and vice versa gametype_cons_t is now initialised using the Gametype_Names array, like how Color_cons_t is initialised using Color_Names # Conflicts: # src/doomstat.h # src/m_menu.c --- src/d_clisrv.c | 12 ++------ src/d_main.c | 10 ++----- src/d_netcmd.c | 76 +++++++++++++++++++++----------------------------- src/doomstat.h | 5 +++- src/g_game.c | 32 +++++++++++++++++++++ src/g_game.h | 1 + src/hu_stuff.c | 22 +++++++-------- src/m_menu.c | 27 ++++-------------- 8 files changed, 90 insertions(+), 95 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a0f9f40ab..31fec14fa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2056,17 +2056,11 @@ static void CL_ConnectToServer(boolean viams) if (i != -1) { - INT32 j; + UINT8 num = serverlist[i].info.gametype; const char *gametypestr = NULL; CONS_Printf(M_GetText("Connecting to: %s\n"), serverlist[i].info.servername); - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == serverlist[i].info.gametype) - { - gametypestr = gametype_cons_t[j].strvalue; - break; - } - } + if (num < NUMGAMETYPES) + gametypestr = Gametype_Names[num]; if (gametypestr) CONS_Printf(M_GetText("Gametype: %s\n"), gametypestr); CONS_Printf(M_GetText("Version: %d.%d.%u\n"), serverlist[i].info.version/100, diff --git a/src/d_main.c b/src/d_main.c index 1782e94f5..527031fa8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1362,13 +1362,9 @@ void D_SRB2Main(void) INT16 newgametype = -1; const char *sgametype = M_GetNextParm(); - for (j = 0; gametype_cons_t[j].strvalue; j++) - if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype)) - { - newgametype = (INT16)gametype_cons_t[j].value; - break; - } - if (!gametype_cons_t[j].strvalue) // reached end of the list with no match + newgametype = G_GetGametypeByName(sgametype); + + if (newgametype == -1) // reached end of the list with no match { j = atoi(sgametype); // assume they gave us a gametype number, which is okay too if (j >= 0 && j < NUMGAMETYPES) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 11b9413a8..71ec55de2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -409,6 +409,16 @@ const char *netxcmdnames[MAXNETXCMD - 1] = */ void D_RegisterServerCommands(void) { + INT32 i; + + for (i = 0; i < NUMGAMETYPES; i++) + { + gametype_cons_t[i].value = i; + gametype_cons_t[i].strvalue = Gametype_Names[i]; + } + gametype_cons_t[NUMGAMETYPES].value = 0; + gametype_cons_t[NUMGAMETYPES].strvalue = NULL; + RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); RegisterNetXCmd(XD_MAP, Got_Mapcmd); @@ -1639,7 +1649,7 @@ static void Command_Map_f(void) { const char *mapname; size_t i; - INT32 j, newmapnum; + INT32 newmapnum; boolean newresetplayers; INT32 newgametype = gametype; @@ -1707,27 +1717,13 @@ static void Command_Map_f(void) return; } - for (j = 0; gametype_cons_t[j].strvalue; j++) - if (!strcasecmp(gametype_cons_t[j].strvalue, COM_Argv(i+1))) - { - // Don't do any variable setting here. Wait until you get your - // map packet first to avoid sending the same info twice! - newgametype = gametype_cons_t[j].value; + newgametype = G_GetGametypeByName(COM_Argv(i+1)); - break; - } - - if (!gametype_cons_t[j].strvalue) // reached end of the list with no match + if (newgametype == -1) // reached end of the list with no match { - // assume they gave us a gametype number, which is okay too - for (j = 0; gametype_cons_t[j].strvalue != NULL; j++) - { - if (atoi(COM_Argv(i+1)) == gametype_cons_t[j].value) - { - newgametype = gametype_cons_t[j].value; - break; - } - } + INT32 j = atoi(COM_Argv(i+1)); // assume they gave us a gametype number, which is okay too + if (j >= 0 && j < NUMGAMETYPES) + newgametype = (INT16)j; } } @@ -1742,12 +1738,11 @@ static void Command_Map_f(void) char gametypestring[32] = "Single Player"; if (multiplayer) - for (i = 0; gametype_cons_t[i].strvalue != NULL; i++) - if (gametype_cons_t[i].value == newgametype) - { - strcpy(gametypestring, gametype_cons_t[i].strvalue); - break; - } + { + if (newgametype >= 0 && newgametype < NUMGAMETYPES + && Gametype_Names[newgametype]) + strcpy(gametypestring, Gametype_Names[newgametype]); + } CONS_Alert(CONS_WARNING, M_GetText("%s doesn't support %s mode!\n(Use -force to override)\n"), mapname, gametypestring); return; @@ -3486,7 +3481,6 @@ static void Command_ModDetails_f(void) // static void Command_ShowGametype_f(void) { - INT32 j; const char *gametypestr = NULL; if (!(netgame || multiplayer)) // print "Single player" instead of "Co-op" @@ -3494,15 +3488,11 @@ static void Command_ShowGametype_f(void) CONS_Printf(M_GetText("Current gametype is %s\n"), M_GetText("Single player")); return; } - // find name string for current gametype - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == gametype) - { - gametypestr = gametype_cons_t[j].strvalue; - break; - } - } + + // get name string for current gametype + if (gametype >= 0 && gametype < NUMGAMETYPES) + gametypestr = Gametype_Names[gametype]; + if (gametypestr) CONS_Printf(M_GetText("Current gametype is %s\n"), gametypestr); else // string for current gametype was not found above (should never happen) @@ -3644,15 +3634,13 @@ void D_GameTypeChanged(INT32 lastgametype) { if (netgame) { - INT32 j; const char *oldgt = NULL, *newgt = NULL; - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == lastgametype) - oldgt = gametype_cons_t[j].strvalue; - if (gametype_cons_t[j].value == gametype) - newgt = gametype_cons_t[j].strvalue; - } + + if (lastgametype >= 0 && lastgametype < NUMGAMETYPES) + oldgt = Gametype_Names[lastgametype]; + if (gametype >= 0 && lastgametype < NUMGAMETYPES) + newgt = Gametype_Names[gametype]; + if (oldgt && newgt) CONS_Printf(M_GetText("Gametype was changed from %s to %s\n"), oldgt, newgt); } diff --git a/src/doomstat.h b/src/doomstat.h index d9132798f..8050a1beb 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -318,7 +318,10 @@ enum GameType NUMGAMETYPES }; -// If you alter this list, update gametype_cons_t in m_menu.c +// If you alter this list, update dehacked.c, and Gametype_Names in g_game.c + +// String names for gametypes +extern const char *Gametype_Names[NUMGAMETYPES]; extern tic_t totalplaytime; diff --git a/src/g_game.c b/src/g_game.c index c0cb469a1..f9477f91e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2698,6 +2698,38 @@ void G_ExitLevel(void) } } +// See also the enum GameType in doomstat.h +const char *Gametype_Names[NUMGAMETYPES] = +{ + "Co-op", // GT_COOP + "Competition", // GT_COMPETITION + "Race", // GT_RACE + + "Match", // GT_MATCH + "Team Match", // GT_TEAMMATCH + + "Tag", // GT_TAG + "Hide and Seek", // GT_HIDEANDSEEK + + "CTF" // GT_CTF +}; + +// +// G_GetGametypeByName +// +// Returns the number for the given gametype name string, or -1 if not valid. +// +INT32 G_GetGametypeByName(const char *gametypestr) +{ + INT32 i; + + for (i = 0; i < NUMGAMETYPES; i++) + if (!stricmp(gametypestr, Gametype_Names[i])) + return i; + + return -1; // unknown gametype +} + // // G_IsSpecialStage // diff --git a/src/g_game.h b/src/g_game.h index 5259eacbb..87ddb3103 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -163,6 +163,7 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void); void G_StopDemo(void); boolean G_CheckDemoStatus(void); +INT32 G_GetGametypeByName(const char *gametypestr); boolean G_IsSpecialStage(INT32 mapnum); boolean G_GametypeUsesLives(void); boolean G_GametypeHasTeams(void); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e34e5c35c..f624e39de 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1952,19 +1952,17 @@ static void HU_DrawCEcho(void) static void HU_drawGametype(void) { - INT32 i = 0; + const char *strvalue = NULL; - for (i = 0; gametype_cons_t[i].strvalue; i++) - { - if (gametype_cons_t[i].value == gametype) - { - if (splitscreen) - V_DrawString(4, 184, 0, gametype_cons_t[i].strvalue); - else - V_DrawString(4, 192, 0, gametype_cons_t[i].strvalue); - return; - } - } + if (gametype < 0 || gametype >= NUMGAMETYPES) + return; // not a valid gametype??? + + strvalue = Gametype_Names[gametype]; + + if (splitscreen) + V_DrawString(4, 184, 0, strvalue); + else + V_DrawString(4, 192, 0, strvalue); } // diff --git a/src/m_menu.c b/src/m_menu.c index 65647d2a6..a833ace21 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -347,23 +347,9 @@ static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; // This gametype list is integral for many different reasons. -// When you add gametypes here, don't forget to update them in CV_AddValue! -CV_PossibleValue_t gametype_cons_t[] = -{ - {GT_COOP, "Co-op"}, +// When you add gametypes here, don't forget to update them in dehacked.c and doomstat.h! +CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; - {GT_COMPETITION, "Competition"}, - {GT_RACE, "Race"}, - - {GT_MATCH, "Match"}, - {GT_TEAMMATCH, "Team Match"}, - - {GT_TAG, "Tag"}, - {GT_HIDEANDSEEK, "Hide and Seek"}, - - {GT_CTF, "CTF"}, - {0, NULL} -}; consvar_t cv_newgametype = {"newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t serversort_cons_t[] = { @@ -6545,7 +6531,7 @@ static void M_DrawRoomMenu(void) static void M_DrawConnectMenu(void) { - UINT16 i, j; + UINT16 i; const char *gt = "Unknown"; INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; @@ -6591,11 +6577,8 @@ static void M_DrawConnectMenu(void) va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); gt = "Unknown"; - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == serverlist[slindex].info.gametype) - gt = gametype_cons_t[j].strvalue; - } + if (serverlist[slindex].info.gametype < NUMGAMETYPES) + gt = Gametype_Names[serverlist[slindex].info.gametype]; V_DrawSmallString(currentMenu->x+46,S_LINEY(i)+8, globalflags, va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer)); From 6142becb4d88e638326c136982e6191aaa6a137d Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 18 Mar 2019 23:58:31 -0400 Subject: [PATCH 42/80] Revert "Update CMakeLists.txt, remove CMAKE_SIZEOF_VOID_P check" This reverts commit d03c53930bfa9f0265ec27223a6a4baa20bb0a73. --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11898db5c..6eb065d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,14 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() +# 64-bit check +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + message(STATUS "Target is 64-bit") + set(SRB2_SYSTEM_BITS 64) +else() + set(SRB2_SYSTEM_BITS 32) +endif() + # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) @@ -65,6 +73,9 @@ endif() if(${CMAKE_SYSTEM} MATCHES "Linux") add_definitions(-DLINUX) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + add_definitions(-DLINUX64) + endif() endif() if(${CMAKE_SYSTEM} MATCHES "Darwin") From 49dddf54ab4ee6ad41dd5c3b00d2f4af33cd9fe8 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Tue, 19 Mar 2019 00:04:14 -0400 Subject: [PATCH 43/80] CMake: check if CMAKE_SIZEOF_VOID_P is defined on Mac? --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb065d04..75aa82f32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,8 @@ macro(copy_files_to_build_dir target dlllist_var) endmacro() # 64-bit check -if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) +message(STATUS "CMAKE_SIZEOF_VOID_P=" ${CMAKE_SIZEOF_VOID_P}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Target is 64-bit") set(SRB2_SYSTEM_BITS 64) else() From 1c55daef2a5612bca39d47d490f82987cface0a9 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Tue, 19 Mar 2019 09:10:25 -0400 Subject: [PATCH 44/80] CMake: have funny check for empty CMAKE_SIZEOF_VOID_P --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75aa82f32..0a5507b92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,14 +54,19 @@ macro(copy_files_to_build_dir target dlllist_var) endif() endmacro() -# 64-bit check -message(STATUS "CMAKE_SIZEOF_VOID_P=" ${CMAKE_SIZEOF_VOID_P}) +# bitness check +set(SRB2_SYSTEM_BITS 0) if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Target is 64-bit") set(SRB2_SYSTEM_BITS 64) -else() +endif() +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + message(STATUS "Target is 32-bit") set(SRB2_SYSTEM_BITS 32) endif() +if(${SRB2_SYSTEM_BITS} EQUAL 0) + message(STATUS "Target bitness is unknown") +endif() # OS macros if (UNIX) From f139ffd1dc6c757806c506f0925f2b5a612ab475 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 20 Mar 2019 19:20:34 -0700 Subject: [PATCH 45/80] Let localhost connections --- src/i_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index f8a65b754..37e355579 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -612,7 +612,7 @@ static boolean SOCK_Get(void) if (c != ERRSOCKET) { // find remote node number - for (j = 0; j <= MAXNETNODES; j++) //include LAN + for (j = 1; j <= MAXNETNODES; j++) //include LAN { if (SOCK_cmpaddr(&fromaddress, &clientaddress[j], 0)) { From ed0f8fd96765fec8ac9b6407db7118669b07ddde Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 20 Mar 2019 20:05:45 -0700 Subject: [PATCH 46/80] Actually allow connecting to "localhost" Because IPv6 doesn't seem to work anyway. --- src/i_tcp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index 37e355579..11a84ceba 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1340,8 +1340,12 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port) while (runp != NULL) { // find ip of the server - memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen); - runp = NULL; + if (sendto(mysockets[0], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0) + { + memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen); + break; + } + runp = runp->ai_next; } I_freeaddrinfo(ai); return newnode; From 147221cf6e67f8d0a4260a265127030efbd880b3 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Mar 2019 18:54:47 +0000 Subject: [PATCH 47/80] R_RenderThickSideRange: clamp lights that fail overflow test, rather than skipping them. --- src/r_segs.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 748365264..7495d7889 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -862,16 +862,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight -= viewz; rightheight -= viewz; -#define OVERFLOWTEST(height, scale) \ - overflow_test = (INT64)centeryfrac - (((INT64)height*scale)>>FRACBITS); \ - if (overflow_test < 0) overflow_test = -overflow_test; \ - if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; +#define CLAMPMAX INT32_MAX +#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. + // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->height = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->height = (fixed_t)overflow_test; + else rlight->height = CLAMPMIN; - OVERFLOWTEST(leftheight, ds->scale1) - OVERFLOWTEST(rightheight, ds->scale2) - - rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); - rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->heightstep = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->heightstep = (fixed_t)overflow_test; + else rlight->heightstep = CLAMPMIN; rlight->heightstep = (rlight->heightstep-rlight->height)/(range); #else if (light->height < *pfloor->bottomheight) @@ -893,12 +895,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight -= viewz; rightheight -= viewz; - OVERFLOWTEST(leftheight, ds->scale1) - OVERFLOWTEST(rightheight, ds->scale2) -#undef OVERFLOWTEST + // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave. + overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->botheight = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->botheight = (fixed_t)overflow_test; + else rlight->botheight = CLAMPMIN; - rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); - rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS); + if (overflow_test > (INT64)CLAMPMAX) rlight->botheightstep = CLAMPMAX; + else if (overflow_test > (INT64)CLAMPMIN) rlight->botheightstep = (fixed_t)overflow_test; + else rlight->botheightstep = CLAMPMIN; rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); #else lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; @@ -1071,9 +1077,6 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } #endif -#define CLAMPMAX INT32_MAX -#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. - // draw the columns for (dc_x = x1; dc_x <= x2; dc_x++) { From 9a8d36b822839252059701dd4824d3fbafe45e04 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:16:43 -0400 Subject: [PATCH 48/80] Travis-CI: use a new version of xcode and use homebrew add-on to install packages --- .travis.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bfc58860..07640f837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -222,7 +222,16 @@ matrix: # osx_image: xcode7.2 # #Apple LLVM version 7.0.2 (clang-700.1.81) - os: osx - osx_image: xcode7.3 + #osx_image: xcode7.3 + addons: + homebrew: + packages: + - sdl2 + - sdl2_mixer + - game-music-emu + - p7zip + - cmake + update: false #Apple LLVM version 7.3.0 (clang-703.0.31) allow_failures: - compiler: clang-3.5 @@ -258,9 +267,6 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2 sdl2_mixer game-music-emu p7zip; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install cmake||true; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From c4e8a601127d205ff9b36e26cf8b2b61a911700c Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:21:52 -0400 Subject: [PATCH 49/80] CircleCI: also test compiling without BLUA support --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3674a9e5..e5892b7c7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,8 +43,8 @@ jobs: - /var/cache/apt/archives - checkout - run: - name: Compile without network support - command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 + name: Compile without network support and BLUA + command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 - run: name: Clean build command: make -C src LINUX=1 clean From fe22fdc5a36fb2769ee83b880a873aa6375a6319 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:30:25 -0400 Subject: [PATCH 50/80] P_SuperDamage() is too big for inlining --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 009a2be1f..29450f6e1 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2643,7 +2643,7 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) } } -static inline void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) +static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) { fixed_t fallbackspeed; angle_t ang; From a8681a5b7262d013daea99250139e28d0884b4c6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:34:25 -0400 Subject: [PATCH 51/80] CircleCI: rebuild depend file with BLUA --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5892b7c7..1b0cf3407 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,7 +46,10 @@ jobs: name: Compile without network support and BLUA command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 - run: - name: Clean build + name: wipe build + command: make -C src LINUX=1 cleandep + - run: + name: rebuild depend command: make -C src LINUX=1 clean - restore_cache: keys: From 3ab0f675ecbe0d9a79ed4a0cb39c2f7903dba457 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:44:33 -0400 Subject: [PATCH 52/80] TravisCI: move homebrew packages for all mac builds --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07640f837..78a0a30dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -223,15 +223,6 @@ matrix: # #Apple LLVM version 7.0.2 (clang-700.1.81) - os: osx #osx_image: xcode7.3 - addons: - homebrew: - packages: - - sdl2 - - sdl2_mixer - - game-music-emu - - p7zip - - cmake - update: false #Apple LLVM version 7.3.0 (clang-703.0.31) allow_failures: - compiler: clang-3.5 @@ -256,6 +247,14 @@ addons: - libgl1-mesa-dev - libgme-dev - p7zip-full + homebrew: + packages: + - sdl2_mixer + - game-music-emu + - p7zip + - cmake + update: false + before_script: - wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2115-assets-2.7z -O $HOME/srb2_cache/SRB2-v2115-assets-2.7z From 594c906376293942a73ef43ef70b13f421420512 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:48:33 -0400 Subject: [PATCH 53/80] use default osx image --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78a0a30dc..f0ed0a8ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -221,9 +221,11 @@ matrix: # - os: osx # osx_image: xcode7.2 # #Apple LLVM version 7.0.2 (clang-700.1.81) +# - os: osx +# osx_image: xcode7.3 +# #Apple LLVM version 7.3.0 (clang-703.0.31) - os: osx - #osx_image: xcode7.3 - #Apple LLVM version 7.3.0 (clang-703.0.31) + #Default: macOS 10.13 and Xcode 9.4.1 allow_failures: - compiler: clang-3.5 - compiler: clang-3.6 From 3472bf857cab6238fcd9d77013ea97517df48967 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 15:51:13 -0400 Subject: [PATCH 54/80] TravisCI: build custom sdl2_mixer build --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0ed0a8ec..7ef0127b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -251,7 +251,7 @@ addons: - p7zip-full homebrew: packages: - - sdl2_mixer + - sdl2 - game-music-emu - p7zip - cmake @@ -268,6 +268,7 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From ec0afaf6c9706760428df566af790de9a9ebefe3 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:02:30 -0400 Subject: [PATCH 55/80] TravisCI: try updating homebew --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7ef0127b8..db81b9d91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -255,7 +255,7 @@ addons: - game-music-emu - p7zip - cmake - update: false + update: true before_script: From 9de5055d7fadebee347fd2af173c7e97e33b35ae Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:30:02 -0400 Subject: [PATCH 56/80] TravisCI: install deps on sdl2_mixer --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index db81b9d91..252abe0f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -251,6 +251,9 @@ addons: - p7zip-full homebrew: packages: + - libmodplug + - liboog + - libvorbis - sdl2 - game-music-emu - p7zip From fd284f232e09562505a110817481100fabf2aaf7 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:43:33 -0400 Subject: [PATCH 57/80] travisCI: add sdl2_mixer from mazmazz's srb2 tap --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 252abe0f1..b723f44e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -250,11 +250,10 @@ addons: - libgme-dev - p7zip-full homebrew: + taps: + - mazmazz/srb2 packages: - - libmodplug - - liboog - - libvorbis - - sdl2 + - mazmazz/srb2/sdl2_mixer - game-music-emu - p7zip - cmake @@ -271,7 +270,6 @@ before_script: - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2_mixer; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi - mkdir -p $HOME/srb2_cache From 73fa35baf0255a9b9fefbc8256206f8c6964e077 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 25 Mar 2019 16:59:47 -0400 Subject: [PATCH 58/80] TravisCI: use stock sdl2_mixer for prebuild bottle --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b723f44e3..15a3c844c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -253,7 +253,7 @@ addons: taps: - mazmazz/srb2 packages: - - mazmazz/srb2/sdl2_mixer + - sdl2_mixer - game-music-emu - p7zip - cmake From 8c1c0875a2f8dd545920cf7dc7c9bd59af2d43ae Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Mar 2019 21:35:04 +0000 Subject: [PATCH 59/80] Fix credits gamestate in dedicated mode, by properly separating the timer variable code from the drawing code in a semi-hacky way --- src/f_finale.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 64e371211..bcdac295a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1192,16 +1192,34 @@ void F_CreditDrawer(void) if (FixedMul(y,vid.dupy) > vid.height) break; } +} +void F_CreditTicker(void) +{ + // "Simulate" the drawing of the credits so that dedicated mode doesn't get stuck + UINT16 i; + fixed_t y = (80< vid.height) + break; + } + + // Do this here rather than in the drawer you doofus! (this is why dedicated mode broke at credits) if (!credits[i] && y <= 120< Date: Mon, 19 Mar 2018 23:15:16 -0700 Subject: [PATCH 60/80] Scroll console immediately upon pressing PageUp --- src/console.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 5c173e459..fbb9ac43e 100644 --- a/src/console.c +++ b/src/console.c @@ -1539,8 +1539,7 @@ static void CON_DrawConsole(void) i = con_cy - con_scrollup; // skip the last empty line due to the cursor being at the start of a new line - if (!con_scrollup && !con_cx) - i--; + i--; i -= (con_curlines - minheight) / charheight; From b9b36a44a8a4c13ac5702abf45260094370ec20c Mon Sep 17 00:00:00 2001 From: jameds Date: Wed, 21 Mar 2018 21:12:48 -0700 Subject: [PATCH 61/80] Keep color across wrapped lines And this works by inserting the same color code on each wrapped line. --- src/console.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/console.c b/src/console.c index fbb9ac43e..032615e1e 100644 --- a/src/console.c +++ b/src/console.c @@ -1106,6 +1106,7 @@ static void CON_Print(char *msg) { size_t l; INT32 controlchars = 0; // for color changing + char color = '\x80'; // keep color across lines if (msg == NULL) return; @@ -1131,7 +1132,7 @@ static void CON_Print(char *msg) { if (*msg & 0x80) { - con_line[con_cx++] = *(msg++); + color = con_line[con_cx++] = *(msg++); controlchars++; continue; } @@ -1139,12 +1140,14 @@ static void CON_Print(char *msg) { con_cy--; CON_Linefeed(); + color = '\x80'; controlchars = 0; } else if (*msg == '\n') // linefeed { CON_Linefeed(); - controlchars = 0; + con_line[con_cx++] = color; + controlchars = 1; } else if (*msg == ' ') // space { @@ -1152,7 +1155,8 @@ static void CON_Print(char *msg) if (con_cx - controlchars >= con_width-11) { CON_Linefeed(); - controlchars = 0; + con_line[con_cx++] = color; + controlchars = 1; } } else if (*msg == '\t') @@ -1167,7 +1171,8 @@ static void CON_Print(char *msg) if (con_cx - controlchars >= con_width-11) { CON_Linefeed(); - controlchars = 0; + con_line[con_cx++] = color; + controlchars = 1; } } msg++; @@ -1184,7 +1189,8 @@ static void CON_Print(char *msg) if ((con_cx - controlchars) + l > con_width-11) { CON_Linefeed(); - controlchars = 0; + con_line[con_cx++] = color; + controlchars = 1; } // a word at a time From e8071e66e49b383c2893b901e3a9a2ede5dab08a Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 26 Mar 2019 12:30:02 -0700 Subject: [PATCH 62/80] Resize console upon resolution change Basically, changing to a lower resolution won't cause your console to extend past the screen anymore. --- src/console.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/console.c b/src/console.c index 032615e1e..9718bb481 100644 --- a/src/console.c +++ b/src/console.c @@ -96,6 +96,7 @@ static size_t input_len; // length of current line, used to bound cursor and suc // protos. static void CON_InputInit(void); static void CON_RecalcSize(void); +static void CON_ChangeHeight(void); static void CONS_hudlines_Change(void); static void CONS_backcolor_Change(void); @@ -447,6 +448,12 @@ static void CON_RecalcSize(void) con_destlines = vid.height; } + if (con_destlines > 0) // Resize console if already open + { + CON_ChangeHeight(); + con_curlines = con_destlines; + } + // check for change of video width if (conw == con_width) return; // didn't change @@ -496,6 +503,20 @@ static void CON_RecalcSize(void) Z_Free(tmp_buffer); } +static void CON_ChangeHeight(void) +{ + INT32 minheight = 20 * con_scalefactor; // 20 = 8+8+4 + + // toggle console in + con_destlines = (cons_height.value*vid.height)/100; + if (con_destlines < minheight) + con_destlines = minheight; + else if (con_destlines > vid.height) + con_destlines = vid.height; + + con_destlines &= ~0x3; // multiple of text row height +} + // Handles Console moves in/out of screen (per frame) // static void CON_MoveConsole(void) @@ -584,16 +605,7 @@ void CON_Ticker(void) CON_ClearHUD(); } else - { - // toggle console in - con_destlines = (cons_height.value*vid.height)/100; - if (con_destlines < minheight) - con_destlines = minheight; - else if (con_destlines > vid.height) - con_destlines = vid.height; - - con_destlines &= ~0x3; // multiple of text row height - } + CON_ChangeHeight(); } // console movement From 69d7e98f34795c12639cdef991007278f5bb678d Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 26 Mar 2019 12:59:13 -0700 Subject: [PATCH 63/80] Remove redundant CON_ClearHUD calls --- src/d_main.c | 1 - src/d_netcmd.c | 1 - src/f_finale.c | 7 ------- 3 files changed, 9 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index dd2cfe0e5..6933ee1a1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1397,7 +1397,6 @@ void D_SRB2Main(void) else if (M_CheckParm("-skipintro")) { CON_ToggleOff(); - CON_ClearHUD(); F_StartTitleScreen(); } else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 11b9413a8..ed4be044b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1832,7 +1832,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) } CON_ToggleOff(); - CON_ClearHUD(); if (demoplayback && !timingdemo) precache = false; diff --git a/src/f_finale.c b/src/f_finale.c index bcdac295a..d4a468c57 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -444,7 +444,6 @@ void F_StartIntro(void) gameaction = ga_nothing; paused = false; CON_ToggleOff(); - CON_ClearHUD(); F_NewCutscene(introtext[0]); intro_scenenum = 0; @@ -1146,7 +1145,6 @@ void F_StartCredits(void) gameaction = ga_nothing; paused = false; CON_ToggleOff(); - CON_ClearHUD(); S_StopMusic(); S_ChangeMusicInternal("credit", false); @@ -1313,7 +1311,6 @@ void F_StartGameEvaluation(void) gameaction = ga_nothing; paused = false; CON_ToggleOff(); - CON_ClearHUD(); finalecount = 0; } @@ -1423,7 +1420,6 @@ void F_StartGameEnd(void) gameaction = ga_nothing; paused = false; CON_ToggleOff(); - CON_ClearHUD(); S_StopMusic(); // In case menus are still up?!! @@ -1626,7 +1622,6 @@ void F_StartContinue(void) keypressed = false; paused = false; CON_ToggleOff(); - CON_ClearHUD(); // In case menus are still up?!! M_ClearMenus(true); @@ -1797,8 +1792,6 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset F_NewCutscene(cutscenes[cutscenenum]->scene[0].text); - CON_ClearHUD(); - cutsceneover = false; runningprecutscene = precutscene; precutresetplayer = resetplayer; From 9a350eb8799de64efc3e50e37cc3d6b2da4b95a6 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 26 Mar 2019 13:04:11 -0700 Subject: [PATCH 64/80] Don't close console when changing map --- src/d_main.c | 4 ++-- src/d_netcmd.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index dd2cfe0e5..5b29cb415 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1396,13 +1396,13 @@ void D_SRB2Main(void) } else if (M_CheckParm("-skipintro")) { - CON_ToggleOff(); - CON_ClearHUD(); F_StartTitleScreen(); } else F_StartIntro(); // Tails 03-03-2002 + CON_ToggleOff(); + if (dedicated && server) { pagename = "TITLESKY"; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 11b9413a8..bee6b4091 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1831,9 +1831,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) CONS_Printf(M_GetText("Speeding off to level...\n")); } - CON_ToggleOff(); - CON_ClearHUD(); - if (demoplayback && !timingdemo) precache = false; From 917edf720d833917b76e032bbf0507d7483c354e Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 26 Mar 2019 13:05:19 -0700 Subject: [PATCH 65/80] Don't close console when starting title screen --- src/d_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 5b29cb415..1b2d73d7d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -726,7 +726,6 @@ void D_StartTitle(void) paused = false; advancedemo = false; F_StartTitleScreen(); - CON_ToggleOff(); // Reset the palette if (rendermode != render_none) From e6c6f048e4af94247d5a7c22fa8fde8ae2d34e9a Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Wed, 27 Mar 2019 18:23:03 -0400 Subject: [PATCH 66/80] CircleCI: Debian Jessie is dead, long live Debian Stretch --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b0cf3407..74e360255 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: working_directory: /root/SRB2 docker: - - image: debian:jessie + - image: debian:stretch environment: CC: ccache gcc -m32 PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig From 4d34841a532a974cbc33ab026ec7820bd7055162 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Wed, 27 Mar 2019 18:51:20 -0400 Subject: [PATCH 67/80] CircleCI: use libpng-dev --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 74e360255..1784ba1ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,7 +36,7 @@ jobs: - v1-SRB2-APT - run: name: Install SDK - command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng12-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client + command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client - save_cache: key: v1-SRB2-APT paths: From 797ca99f42a05e6f2b491983cd7f0222b9bfc519 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Apr 2019 16:39:14 +0100 Subject: [PATCH 68/80] Detect infinite alias self-recursion mixed with other commands, such as in the case of `alias a "echo test; a"; a`. (Unfortunately, this does not work if "wait" is used instead of "echo", but oh well) --- src/command.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/command.c b/src/command.c index ba0095e07..fda17847b 100644 --- a/src/command.c +++ b/src/command.c @@ -514,7 +514,6 @@ static void COM_ExecuteString(char *ptext) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { - recursion = 0; cmd->function(); return; } @@ -526,19 +525,17 @@ static void COM_ExecuteString(char *ptext) if (!stricmp(com_argv[0], a->name)) { if (recursion > MAX_ALIAS_RECURSION) - { CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); - recursion = 0; - return; + else + { // Monster Iestyn: keep track of how many levels of recursion we're in + recursion++; + COM_BufInsertText(a->value); + recursion--; } - recursion++; - COM_BufInsertText(a->value); return; } } - recursion = 0; - // check cvars // Hurdler: added at Ebola's request ;) // (don't flood the console in software mode with bad gr_xxx command) From 36e678b292a947393cdaa259aaac4d6eef3cefc1 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 14 Apr 2019 15:17:47 -0700 Subject: [PATCH 69/80] Don't count down wait timer when executing a command --- src/command.c | 20 ++++++++++++++------ src/command.h | 3 +++ src/d_clisrv.c | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index ba0095e07..edc04bed1 100644 --- a/src/command.c +++ b/src/command.c @@ -148,6 +148,20 @@ void COM_BufInsertText(const char *ptext) } } +/** Progress the wait timer and flush waiting console commands when ready. + */ +void +COM_BufTicker(void) +{ + if (com_wait) + { + com_wait--; + return; + } + + COM_BufExecute(); +} + /** Flushes (executes) console commands in the buffer. */ void COM_BufExecute(void) @@ -157,12 +171,6 @@ void COM_BufExecute(void) char line[1024] = ""; INT32 quotes; - if (com_wait) - { - com_wait--; - return; - } - while (com_text.cursize) { // find a '\n' or; line break diff --git a/src/command.h b/src/command.h index e6767825c..4682ba4a4 100644 --- a/src/command.h +++ b/src/command.h @@ -45,6 +45,9 @@ void COM_ImmedExecute(const char *ptext); // Execute commands in buffer, flush them void COM_BufExecute(void); +// As above; and progress the wait timer. +void COM_BufTicker(void); + // setup command buffer, at game tartup void COM_Init(void); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a0f9f40ab..1b0cb523f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4563,7 +4563,7 @@ void TryRunTics(tic_t realtics) if (realtics >= 1) { - COM_BufExecute(); + COM_BufTicker(); if (mapchangepending) D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change } From 26fdee82173b8a13d3cc62f967dea7d4c1ff8acc Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 16 Apr 2019 15:05:09 -0400 Subject: [PATCH 70/80] Don't enable UPnP support if NONET is defined. --- src/win32/Makefile.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index def2fe682..1880abf18 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -24,8 +24,10 @@ ifndef NOASM USEASM=1 endif +ifndef NONET ifndef MINGW64 #miniupnc is broken with MINGW64 HAVE_MINIUPNPC=1 +endif endif OPTS=-DSTDC_HEADERS From 4d77ed925e469ecf12b5c69f5144efc0f7d47f29 Mon Sep 17 00:00:00 2001 From: Sryder Date: Tue, 30 Apr 2019 23:08:01 +0100 Subject: [PATCH 71/80] OpenGL sprite billboarding Should work on both normal and precipitation sprites. Sprites that are split by lighting should work correctly. --- src/hardware/hw_main.c | 148 +++++++++++++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index efecac524..272da06d8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4246,10 +4246,43 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t } } +// This is expecting a pointer to an array containing 4 wallVerts for a sprite +static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts) +{ + if (spr && spr->mobj && wallVerts) + { + float basey = FIXED_TO_FLOAT(spr->mobj->z); + float lowy = wallVerts[0].y; + if (P_MobjFlip(spr->mobj) == -1) + { + basey = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); + } + // Rotate sprites to fully billboard with the camera + // X, Y, AND Z need to be manipulated for the polys to rotate around the + // origin, because of how the origin setting works I believe that should + // be mobj->z or mobj->z + mobj->height + wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gr_viewludsin + basey; + wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gr_viewludsin + basey; + // translate back to be around 0 before translating back + wallVerts[3].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[2].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; + + wallVerts[0].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[1].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; + + wallVerts[3].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[2].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; + + wallVerts[0].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[1].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; + } +} + static void HWR_SplitSprite(gr_vissprite_t *spr) { float this_scale = 1.0f; FOutVector wallVerts[4]; + FOutVector baseWallVerts[4]; // This is what the verts should end up as GLPatch_t *gpatch; FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); @@ -4262,11 +4295,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) float realtop, realbot, top, bot; float towtop, towbot, towmult; float bheight; + float realheight, heightmult; const sector_t *sector = spr->mobj->subsector->sector; const lightlist_t *list = sector->lightlist; #ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endbheight; + float endrealheight; fixed_t temp; fixed_t v1x, v1y, v2x, v2y; #endif @@ -4299,16 +4334,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) HWR_DrawSpriteShadow(spr, gpatch, this_scale); } - wallVerts[0].x = wallVerts[3].x = spr->x1; - wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[0].z = wallVerts[3].z = spr->z1; - wallVerts[1].z = wallVerts[2].z = spr->z2; + baseWallVerts[0].x = baseWallVerts[3].x = spr->x1; + baseWallVerts[2].x = baseWallVerts[1].x = spr->x2; + baseWallVerts[0].z = baseWallVerts[3].z = spr->z1; + baseWallVerts[1].z = baseWallVerts[2].z = spr->z2; - wallVerts[2].y = wallVerts[3].y = spr->ty; + baseWallVerts[2].y = baseWallVerts[3].y = spr->ty; if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; + baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height * this_scale; else - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; + baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height; v1x = FLOAT_TO_FIXED(spr->x1); v1y = FLOAT_TO_FIXED(spr->z1); @@ -4317,44 +4352,56 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (spr->flip) { - wallVerts[0].sow = wallVerts[3].sow = gpatch->max_s; - wallVerts[2].sow = wallVerts[1].sow = 0; - }else{ - wallVerts[0].sow = wallVerts[3].sow = 0; - wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; + baseWallVerts[0].sow = baseWallVerts[3].sow = gpatch->max_s; + baseWallVerts[2].sow = baseWallVerts[1].sow = 0; + } + else + { + baseWallVerts[0].sow = baseWallVerts[3].sow = 0; + baseWallVerts[2].sow = baseWallVerts[1].sow = gpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - wallVerts[3].tow = wallVerts[2].tow = gpatch->max_t; - wallVerts[0].tow = wallVerts[1].tow = 0; - }else{ - wallVerts[3].tow = wallVerts[2].tow = 0; - wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t; + baseWallVerts[3].tow = baseWallVerts[2].tow = gpatch->max_t; + baseWallVerts[0].tow = baseWallVerts[1].tow = 0; + } + else + { + baseWallVerts[3].tow = baseWallVerts[2].tow = 0; + baseWallVerts[0].tow = baseWallVerts[1].tow = gpatch->max_t; } // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { float co = -gr_viewcos*(0.05f*spr->dispoffset); float si = -gr_viewsin*(0.05f*spr->dispoffset); - wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; - wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; - wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; - wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; } - realtop = top = wallVerts[3].y; - realbot = bot = wallVerts[0].y; - towtop = wallVerts[3].tow; - towbot = wallVerts[0].tow; + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, baseWallVerts); + + realtop = top = baseWallVerts[3].y; + realbot = bot = baseWallVerts[0].y; + towtop = baseWallVerts[3].tow; + towbot = baseWallVerts[0].tow; towmult = (towbot - towtop) / (top - bot); #ifdef ESLOPE - endrealtop = endtop = wallVerts[2].y; - endrealbot = endbot = wallVerts[1].y; + endrealtop = endtop = baseWallVerts[2].y; + endrealbot = endbot = baseWallVerts[1].y; #endif + // copy the contents of baseWallVerts into the drawn wallVerts array + // baseWallVerts is used to know the final shape to easily get the vertex + // co-ordinates + memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + if (!cv_translucency.value) // translucency disabled { Surf.FlatColor.s.alpha = 0xFF; @@ -4481,12 +4528,53 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; + + // The x and y only need to be adjusted in the case that it's not a papersprite + if (spr->mobj) + { + // Get the x and z of the vertices so billboarding draws correctly + realheight = realbot - realtop; + endrealheight = endrealbot - endrealtop; + heightmult = (realtop - top) / realheight; + wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + + heightmult = (endrealtop - endtop) / endrealheight; + wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + + heightmult = (realtop - bot) / realheight; + wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + + heightmult = (endrealtop - endbot) / endrealheight; + wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + } #else wallVerts[3].tow = wallVerts[2].tow = towtop + ((realtop - top) * towmult); wallVerts[0].tow = wallVerts[1].tow = towtop + ((realtop - bot) * towmult); wallVerts[2].y = wallVerts[3].y = top; wallVerts[0].y = wallVerts[1].y = bot; + + // The x and y only need to be adjusted in the case that it's not a papersprite + if (spr->mobj) + { + // Get the x and z of the vertices so billboarding draws correctly + realheight = realbot - realtop; + heightmult = (realtop - top) / realheight; + wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + + heightmult = (realtop - bot) / realheight; + wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + } #endif if (colormap) @@ -4655,6 +4743,9 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; } + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, wallVerts); + // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured @@ -4736,6 +4827,9 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) wallVerts[0].z = wallVerts[3].z = spr->z1; wallVerts[1].z = wallVerts[2].z = spr->z2; + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, wallVerts); + wallVerts[0].sow = wallVerts[3].sow = 0; wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; From 3e5b0c45318d77f594d4ae71596c5d0fcc5752e8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 2 May 2019 18:31:51 -0400 Subject: [PATCH 72/80] Remove MP3 widechar tag searching 1. It's slow, 2. It's incorrect --- src/sdl/mixer_sound.c | 56 ------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index dde62fc7a..7b5a95a45 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -908,15 +908,6 @@ boolean I_LoadSong(char *data, size_t len) const size_t key3len = strlen(key3); const size_t key4len = strlen(key4); - // for mp3 wide chars - const char *key1w = "L\0O\0O\0P\0"; - const char *key2w = "P\0O\0I\0N\0T\0\0\0\xFF\xFE"; - const char *key3w = "M\0S\0\0\0\xFF\xFE"; - const char *key4w = "L\0E\0N\0G\0T\0H\0M\0S\0\0\0\xFF\xFE"; - const char *wterm = "\0\0"; - char wval[10]; - - size_t wstart, wp; char *p = data; SDL_RWops *rw; @@ -1067,53 +1058,6 @@ boolean I_LoadSong(char *data, size_t len) p += key4len; // skip LENGTHMS song_length = (float)(atoi(p) / 1000.0L); } - // below: search MP3 or other tags that use wide char encoding - else if (fpclassify(loop_point) == FP_ZERO && !memcmp(p, key1w, key1len*2)) // LOOP wide char - { - p += key1len*2; - if (!memcmp(p, key2w, (key2len+1)*2)) // POINT= wide char - { - p += (key2len+1)*2; - wstart = (size_t)p; - wp = 0; - while (wp < 9 && memcmp(p, wterm, 2)) - { - wval[wp] = *p; - p += 2; - wp = ((size_t)(p-wstart))/2; - } - wval[min(wp, 9)] = 0; - loop_point = (float)((44.1L+atoi(wval) / 44100.0L)); - } - else if (!memcmp(p, key3w, (key3len+1)*2)) // MS= wide char - { - p += (key3len+1)*2; - wstart = (size_t)p; - wp = 0; - while (wp < 9 && memcmp(p, wterm, 2)) - { - wval[wp] = *p; - p += 2; - wp = ((size_t)(p-wstart))/2; - } - wval[min(wp, 9)] = 0; - loop_point = (float)(atoi(wval) / 1000.0L); - } - } - else if (fpclassify(song_length) == FP_ZERO && !memcmp(p, key4w, (key4len+1)*2)) // LENGTHMS= wide char - { - p += (key4len+1)*2; - wstart = (size_t)p; - wp = 0; - while (wp < 9 && memcmp(p, wterm, 2)) - { - wval[wp] = *p; - p += 2; - wp = ((size_t)(p-wstart))/2; - } - wval[min(wp, 9)] = 0; - song_length = (float)(atoi(wval) / 1000.0L); - } if (fpclassify(loop_point) != FP_ZERO && fpclassify(song_length) != FP_ZERO && song_length > loop_point) // Got what we needed // the last case is a sanity check, in case the wide char searches were false matches. From 904b00e9211c310a5e191b8dc3f89b006abb0504 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 2 May 2019 19:14:23 -0400 Subject: [PATCH 73/80] Remove song_length tag search Because songs without this tag will skiplag when loading. --- src/sdl/mixer_sound.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 7b5a95a45..045e82b15 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -902,11 +902,9 @@ boolean I_LoadSong(char *data, size_t len) const char *key1 = "LOOP"; const char *key2 = "POINT="; const char *key3 = "MS="; - const char *key4 = "LENGTHMS="; const size_t key1len = strlen(key1); const size_t key2len = strlen(key2); const size_t key3len = strlen(key3); - const size_t key4len = strlen(key4); char *p = data; SDL_RWops *rw; @@ -1053,14 +1051,8 @@ boolean I_LoadSong(char *data, size_t len) // Everything that uses LOOPMS will work perfectly with SDL_Mixer. } } - else if (fpclassify(song_length) == FP_ZERO && !strncmp(p, key4, key4len)) // is it LENGTHMS=? - { - p += key4len; // skip LENGTHMS - song_length = (float)(atoi(p) / 1000.0L); - } - if (fpclassify(loop_point) != FP_ZERO && fpclassify(song_length) != FP_ZERO && song_length > loop_point) // Got what we needed - // the last case is a sanity check, in case the wide char searches were false matches. + if (fpclassify(loop_point) != FP_ZERO) // Got what we needed break; else // continue searching p++; From a5dfbe7eff806cf4efa03b9cb159907f38233214 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 3 May 2019 16:38:59 +0100 Subject: [PATCH 74/80] add parentheses around these conditions to fix sloped lights cutting out lights on FOF walls for apparently no reason not making a merge request because this is so laughably stupidly simple --- src/r_segs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 7495d7889..c82554ac8 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -854,8 +854,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) { lightlist_t *nextlight = &frontsector->lightlist[i+1]; - if (nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height > pfloorleft - && nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height > pfloorright) + if ((nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height) > pfloorleft + && (nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height) > pfloorright) continue; } From 8273534967272444d3fb79b1260ca14c05933ce1 Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 6 May 2019 16:57:32 +0100 Subject: [PATCH 75/80] Add a cvar for sprite billboarding, off by default. --- src/hardware/hw_main.c | 6 +++--- src/hardware/hw_main.h | 1 + src/r_main.c | 1 + src/v_video.c | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 272da06d8..7e0b369eb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4249,7 +4249,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t // This is expecting a pointer to an array containing 4 wallVerts for a sprite static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts) { - if (spr && spr->mobj && wallVerts) + if (cv_grspritebillboarding.value && spr && spr->mobj && wallVerts) { float basey = FIXED_TO_FLOAT(spr->mobj->z); float lowy = wallVerts[0].y; @@ -4530,7 +4530,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (spr->mobj) + if (cv_grspritebillboarding.value && spr->mobj) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; @@ -4559,7 +4559,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[0].y = wallVerts[1].y = bot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (spr->mobj) + if (cv_grspritebillboarding.value && spr->mobj) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 59042cf3b..f86b198a1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -95,6 +95,7 @@ extern consvar_t cv_grcorrecttricks; extern consvar_t cv_voodoocompatibility; extern consvar_t cv_grfovchange; extern consvar_t cv_grsolvetjoin; +extern consvar_t cv_grspritebillboarding; extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; diff --git a/src/r_main.c b/src/r_main.c index 94945af5b..08b1ab2f0 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1407,6 +1407,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_grcoronasize); #endif CV_RegisterVar(&cv_grmd2); + CV_RegisterVar(&cv_grspritebillboarding); #endif #ifdef HWRENDER diff --git a/src/v_video.c b/src/v_video.c index cfe7d0360..c3b29e157 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -81,6 +81,7 @@ consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE| CV_FLOAT, 0, NULL, 0 static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}}; // console variables in development consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif const UINT8 gammatable[5][256] = From 8f05d759263dfe3a57990f101f10cec6d1283936 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 8 May 2019 09:36:37 -0500 Subject: [PATCH 76/80] Don't skip frames when connecting or paused --- src/sdl/i_video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index dbaa7037a..f7afcf7de 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -984,6 +984,7 @@ void I_UpdateNoBlit(void) // from PrBoom's src/SDL/i_video.c static inline boolean I_SkipFrame(void) { +#if 0 static boolean skip = false; if (rendermode != render_soft) @@ -1003,6 +1004,8 @@ static inline boolean I_SkipFrame(void) default: return false; } +#endif + return false; } // From 7ac0a8b4d2cfd65a72dae30fd8824ea7d39b35ce Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 4 Mar 2019 22:13:22 -0800 Subject: [PATCH 77/80] Check that lumps are okay --- src/p_saveg.c | 149 +++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 12ee1345b..13117f07c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -649,84 +649,87 @@ static void P_NetArchiveWorld(void) mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); - // do lines - for (i = 0; i < numlines; i++, mld++, li++) + if (mld && msd) { - diff = diff2 = 0; - - if (li->special != SHORT(mld->special)) - diff |= LD_SPECIAL; - - if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved - diff |= LD_CLLCOUNT; - - if (li->sidenum[0] != 0xffff) + // do lines + for (i = 0; i < numlines; i++, mld++, li++) { - si = &sides[li->sidenum[0]]; - if (si->textureoffset != SHORT(msd[li->sidenum[0]].textureoffset)<sidenum[0]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[0]].toptexture)) - diff |= LD_S1TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[0]].bottomtexture)) - diff |= LD_S1BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[0]].midtexture)) - diff |= LD_S1MIDTEX; - } - if (li->sidenum[1] != 0xffff) - { - si = &sides[li->sidenum[1]]; - if (si->textureoffset != SHORT(msd[li->sidenum[1]].textureoffset)<sidenum[1]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[1]].toptexture)) - diff2 |= LD_S2TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[1]].bottomtexture)) - diff2 |= LD_S2BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[1]].midtexture)) - diff2 |= LD_S2MIDTEX; - if (diff2) - diff |= LD_DIFF2; - } + diff = diff2 = 0; - if (diff) - { - statline++; - WRITEINT16(put, i); - WRITEUINT8(put, diff); - if (diff & LD_DIFF2) - WRITEUINT8(put, diff2); - if (diff & LD_FLAG) - WRITEINT16(put, li->flags); - if (diff & LD_SPECIAL) - WRITEINT16(put, li->special); - if (diff & LD_CLLCOUNT) - WRITEINT16(put, li->callcount); + if (li->special != SHORT(mld->special)) + diff |= LD_SPECIAL; - si = &sides[li->sidenum[0]]; - if (diff & LD_S1TEXOFF) - WRITEFIXED(put, si->textureoffset); - if (diff & LD_S1TOPTEX) - WRITEINT32(put, si->toptexture); - if (diff & LD_S1BOTTEX) - WRITEINT32(put, si->bottomtexture); - if (diff & LD_S1MIDTEX) - WRITEINT32(put, si->midtexture); + if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved + diff |= LD_CLLCOUNT; - si = &sides[li->sidenum[1]]; - if (diff2 & LD_S2TEXOFF) - WRITEFIXED(put, si->textureoffset); - if (diff2 & LD_S2TOPTEX) - WRITEINT32(put, si->toptexture); - if (diff2 & LD_S2BOTTEX) - WRITEINT32(put, si->bottomtexture); - if (diff2 & LD_S2MIDTEX) - WRITEINT32(put, si->midtexture); + if (li->sidenum[0] != 0xffff) + { + si = &sides[li->sidenum[0]]; + if (si->textureoffset != SHORT(msd[li->sidenum[0]].textureoffset)<sidenum[0]].toptexture) != -1 + && si->toptexture != R_TextureNumForName(msd[li->sidenum[0]].toptexture)) + diff |= LD_S1TOPTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[0]].bottomtexture) != -1 + && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[0]].bottomtexture)) + diff |= LD_S1BOTTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[0]].midtexture) != -1 + && si->midtexture != R_TextureNumForName(msd[li->sidenum[0]].midtexture)) + diff |= LD_S1MIDTEX; + } + if (li->sidenum[1] != 0xffff) + { + si = &sides[li->sidenum[1]]; + if (si->textureoffset != SHORT(msd[li->sidenum[1]].textureoffset)<sidenum[1]].toptexture) != -1 + && si->toptexture != R_TextureNumForName(msd[li->sidenum[1]].toptexture)) + diff2 |= LD_S2TOPTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[1]].bottomtexture) != -1 + && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[1]].bottomtexture)) + diff2 |= LD_S2BOTTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[1]].midtexture) != -1 + && si->midtexture != R_TextureNumForName(msd[li->sidenum[1]].midtexture)) + diff2 |= LD_S2MIDTEX; + if (diff2) + diff |= LD_DIFF2; + } + + if (diff) + { + statline++; + WRITEINT16(put, i); + WRITEUINT8(put, diff); + if (diff & LD_DIFF2) + WRITEUINT8(put, diff2); + if (diff & LD_FLAG) + WRITEINT16(put, li->flags); + if (diff & LD_SPECIAL) + WRITEINT16(put, li->special); + if (diff & LD_CLLCOUNT) + WRITEINT16(put, li->callcount); + + si = &sides[li->sidenum[0]]; + if (diff & LD_S1TEXOFF) + WRITEFIXED(put, si->textureoffset); + if (diff & LD_S1TOPTEX) + WRITEINT32(put, si->toptexture); + if (diff & LD_S1BOTTEX) + WRITEINT32(put, si->bottomtexture); + if (diff & LD_S1MIDTEX) + WRITEINT32(put, si->midtexture); + + si = &sides[li->sidenum[1]]; + if (diff2 & LD_S2TEXOFF) + WRITEFIXED(put, si->textureoffset); + if (diff2 & LD_S2TOPTEX) + WRITEINT32(put, si->toptexture); + if (diff2 & LD_S2BOTTEX) + WRITEINT32(put, si->bottomtexture); + if (diff2 & LD_S2MIDTEX) + WRITEINT32(put, si->midtexture); + } } } WRITEUINT16(put, 0xffff); From 4e0cc2505a2d0a6fdab01545c55932cb70366f92 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 13 May 2019 00:20:39 -0400 Subject: [PATCH 78/80] Revert "Check that lumps are okay" This reverts commit 7ac0a8b4d2cfd65a72dae30fd8824ea7d39b35ce. --- src/p_saveg.c | 149 +++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 76 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 13117f07c..12ee1345b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -649,87 +649,84 @@ static void P_NetArchiveWorld(void) mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); - if (mld && msd) + // do lines + for (i = 0; i < numlines; i++, mld++, li++) { - // do lines - for (i = 0; i < numlines; i++, mld++, li++) + diff = diff2 = 0; + + if (li->special != SHORT(mld->special)) + diff |= LD_SPECIAL; + + if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved + diff |= LD_CLLCOUNT; + + if (li->sidenum[0] != 0xffff) { - diff = diff2 = 0; + si = &sides[li->sidenum[0]]; + if (si->textureoffset != SHORT(msd[li->sidenum[0]].textureoffset)<sidenum[0]].toptexture) != -1 + && si->toptexture != R_TextureNumForName(msd[li->sidenum[0]].toptexture)) + diff |= LD_S1TOPTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[0]].bottomtexture) != -1 + && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[0]].bottomtexture)) + diff |= LD_S1BOTTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[0]].midtexture) != -1 + && si->midtexture != R_TextureNumForName(msd[li->sidenum[0]].midtexture)) + diff |= LD_S1MIDTEX; + } + if (li->sidenum[1] != 0xffff) + { + si = &sides[li->sidenum[1]]; + if (si->textureoffset != SHORT(msd[li->sidenum[1]].textureoffset)<sidenum[1]].toptexture) != -1 + && si->toptexture != R_TextureNumForName(msd[li->sidenum[1]].toptexture)) + diff2 |= LD_S2TOPTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[1]].bottomtexture) != -1 + && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[1]].bottomtexture)) + diff2 |= LD_S2BOTTEX; + if (R_CheckTextureNumForName(msd[li->sidenum[1]].midtexture) != -1 + && si->midtexture != R_TextureNumForName(msd[li->sidenum[1]].midtexture)) + diff2 |= LD_S2MIDTEX; + if (diff2) + diff |= LD_DIFF2; + } - if (li->special != SHORT(mld->special)) - diff |= LD_SPECIAL; + if (diff) + { + statline++; + WRITEINT16(put, i); + WRITEUINT8(put, diff); + if (diff & LD_DIFF2) + WRITEUINT8(put, diff2); + if (diff & LD_FLAG) + WRITEINT16(put, li->flags); + if (diff & LD_SPECIAL) + WRITEINT16(put, li->special); + if (diff & LD_CLLCOUNT) + WRITEINT16(put, li->callcount); - if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved - diff |= LD_CLLCOUNT; + si = &sides[li->sidenum[0]]; + if (diff & LD_S1TEXOFF) + WRITEFIXED(put, si->textureoffset); + if (diff & LD_S1TOPTEX) + WRITEINT32(put, si->toptexture); + if (diff & LD_S1BOTTEX) + WRITEINT32(put, si->bottomtexture); + if (diff & LD_S1MIDTEX) + WRITEINT32(put, si->midtexture); - if (li->sidenum[0] != 0xffff) - { - si = &sides[li->sidenum[0]]; - if (si->textureoffset != SHORT(msd[li->sidenum[0]].textureoffset)<sidenum[0]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[0]].toptexture)) - diff |= LD_S1TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[0]].bottomtexture)) - diff |= LD_S1BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[0]].midtexture)) - diff |= LD_S1MIDTEX; - } - if (li->sidenum[1] != 0xffff) - { - si = &sides[li->sidenum[1]]; - if (si->textureoffset != SHORT(msd[li->sidenum[1]].textureoffset)<sidenum[1]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[1]].toptexture)) - diff2 |= LD_S2TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[1]].bottomtexture)) - diff2 |= LD_S2BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[1]].midtexture)) - diff2 |= LD_S2MIDTEX; - if (diff2) - diff |= LD_DIFF2; - } - - if (diff) - { - statline++; - WRITEINT16(put, i); - WRITEUINT8(put, diff); - if (diff & LD_DIFF2) - WRITEUINT8(put, diff2); - if (diff & LD_FLAG) - WRITEINT16(put, li->flags); - if (diff & LD_SPECIAL) - WRITEINT16(put, li->special); - if (diff & LD_CLLCOUNT) - WRITEINT16(put, li->callcount); - - si = &sides[li->sidenum[0]]; - if (diff & LD_S1TEXOFF) - WRITEFIXED(put, si->textureoffset); - if (diff & LD_S1TOPTEX) - WRITEINT32(put, si->toptexture); - if (diff & LD_S1BOTTEX) - WRITEINT32(put, si->bottomtexture); - if (diff & LD_S1MIDTEX) - WRITEINT32(put, si->midtexture); - - si = &sides[li->sidenum[1]]; - if (diff2 & LD_S2TEXOFF) - WRITEFIXED(put, si->textureoffset); - if (diff2 & LD_S2TOPTEX) - WRITEINT32(put, si->toptexture); - if (diff2 & LD_S2BOTTEX) - WRITEINT32(put, si->bottomtexture); - if (diff2 & LD_S2MIDTEX) - WRITEINT32(put, si->midtexture); - } + si = &sides[li->sidenum[1]]; + if (diff2 & LD_S2TEXOFF) + WRITEFIXED(put, si->textureoffset); + if (diff2 & LD_S2TOPTEX) + WRITEINT32(put, si->toptexture); + if (diff2 & LD_S2BOTTEX) + WRITEINT32(put, si->bottomtexture); + if (diff2 & LD_S2MIDTEX) + WRITEINT32(put, si->midtexture); } } WRITEUINT16(put, 0xffff); From cad65ad5e9d32fd74847929c1e1f4568461ac35b Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 13 May 2019 00:23:43 -0400 Subject: [PATCH 79/80] Properly fix crash due to duplicated lines. --- src/p_saveg.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 12ee1345b..fce72b927 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -647,8 +647,6 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, 0xffff); - mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); - msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); // do lines for (i = 0; i < numlines; i++, mld++, li++) { From addf2bb3c47551985641b380fbb8f8d9ddb822d7 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Mon, 13 May 2019 01:51:36 -0400 Subject: [PATCH 80/80] Fix NONET build --- src/hu_stuff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a416f0d26..fdaf36cb2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1072,7 +1072,9 @@ static INT16 typelines = 1; // number of drawfill lines we need when drawing the // boolean HU_Responder(event_t *ev) { +#ifndef NONET INT32 c=0; +#endif if (ev->type != ev_keydown) return false; @@ -1099,9 +1101,9 @@ boolean HU_Responder(event_t *ev) return false; }*/ //We don't actually care about that unless we get splitscreen netgames. :V +#ifndef NONET c = (INT32)ev->data1; -#ifndef NONET if (!chat_on) { // enter chat mode