From c5ea6b5efe8a83e3c5d32e1b17db05ef935e1484 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 10:22:17 -0400 Subject: [PATCH 01/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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/72] 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 d7321fd8c44d82d9953f43bf2aff5dec024abf73 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Dec 2018 16:40:40 -0500 Subject: [PATCH 16/72] Pull expanded NMUSlist from 2.2 --- src/w_wad.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index e1cd16ae9..bc5473eab 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1667,15 +1667,26 @@ int W_VerifyNMUSlumps(const char *filename) // ENDOOM text and palette lumps lumpchecklist_t NMUSlist[] = { - {"D_", 2}, - {"O_", 2}, - {"DS", 2}, - {"ENDOOM", 6}, - {"PLAYPAL", 7}, - {"COLORMAP", 8}, - {"PAL", 3}, - {"CLM", 3}, - {"TRANS", 5}, + {"D_", 2}, // MIDI music + {"O_", 2}, // Digital music + {"DS", 2}, // Sound effects + + {"ENDOOM", 6}, // ENDOOM text lump + + {"PLAYPAL", 7}, // Palette changes + {"PAL", 3}, // Palette changes + {"COLORMAP", 8}, // Colormap changes + {"CLM", 3}, // Colormap changes + {"TRANS", 5}, // Translucency map changes + + {"LTFNT", 5}, // Level title font changes + {"TTL", 3}, // Act number changes + {"STCFN", 5}, // Console font changes + {"TNYFN", 5}, // Tiny console font changes + {"STT", 3}, // Acceptable HUD changes (Score Time Rings) + {"YB_", 3}, // Intermission graphics, goes with the above + {"M_", 2}, // As does menu stuff + {NULL, 0}, }; return W_VerifyFile(filename, NMUSlist, false); From 1b7a9aaa015e10196ccb6bad9cbe0cb4f62b9897 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Dec 2018 16:53:13 -0500 Subject: [PATCH 17/72] 2.1 Score/Time/Rings lump name --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index bc5473eab..b67974a10 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1683,7 +1683,8 @@ int W_VerifyNMUSlumps(const char *filename) {"TTL", 3}, // Act number changes {"STCFN", 5}, // Console font changes {"TNYFN", 5}, // Tiny console font changes - {"STT", 3}, // Acceptable HUD changes (Score Time Rings) + {"SBO", 3}, // Acceptable HUD changes (Score Time Rings) + {"RRINGS", 6}, // Rings HUD (not named as SBO) {"YB_", 3}, // Intermission graphics, goes with the above {"M_", 2}, // As does menu stuff From 78fa72514f03a881d559eb757708b2e7d0722841 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 30 Dec 2018 15:08:30 -0500 Subject: [PATCH 18/72] Implement deployer scripts for Travis -- OSX and Linux package building --- .gitignore | 2 + .travis.yml | 448 +++++++++++++++++- CMakeLists.txt | 10 +- assets/.gitignore | 11 +- assets/CMakeLists.txt | 74 ++- .../{debian => debian-template}/README.Debian | 52 +- .../{debian => debian-template}/README.source | 0 assets/debian-template/changelog | 5 + assets/{debian => debian-template}/compat | 0 assets/{debian => debian-template}/control | 8 +- {debian => assets/debian-template}/copyright | 10 +- assets/{debian => debian-template}/rules | 54 ++- .../{debian => debian-template}/source/format | 0 .../source/options | 0 assets/debian/changelog | 19 - {debian => debian-template}/README.Debian | 50 +- {debian => debian-template}/README.source | 0 debian-template/changelog | 5 + {debian => debian-template}/compat | 0 {debian => debian-template}/control | 24 +- {assets/debian => debian-template}/copyright | 10 +- {debian => debian-template}/docs | 0 {debian => debian-template}/rules | 26 +- {debian => debian-template}/source/format | 0 {debian => debian-template}/source/options | 2 +- debian-template/srb2.desktop | 10 + debian/changelog | 12 - debian/srb2.desktop | 10 - debian_template.sh | 166 +++++++ deployer/travis/deployer.sh | 157 ++++++ deployer/travis/deployer_build.sh | 190 ++++++++ deployer/travis/deployer_defaults.sh | 107 +++++ deployer/travis/deployer_dput.sh | 133 ++++++ deployer/travis/deployer_ftp.sh | 137 ++++++ src/sdl/CMakeLists.txt | 13 +- 35 files changed, 1594 insertions(+), 151 deletions(-) rename assets/{debian => debian-template}/README.Debian (59%) rename assets/{debian => debian-template}/README.source (100%) create mode 100644 assets/debian-template/changelog rename assets/{debian => debian-template}/compat (100%) rename assets/{debian => debian-template}/control (84%) rename {debian => assets/debian-template}/copyright (57%) rename assets/{debian => debian-template}/rules (58%) mode change 100755 => 100644 rename assets/{debian => debian-template}/source/format (100%) rename assets/{debian => debian-template}/source/options (100%) delete mode 100644 assets/debian/changelog rename {debian => debian-template}/README.Debian (62%) rename {debian => debian-template}/README.source (100%) create mode 100644 debian-template/changelog rename {debian => debian-template}/compat (100%) rename {debian => debian-template}/control (65%) rename {assets/debian => debian-template}/copyright (57%) rename {debian => debian-template}/docs (100%) rename {debian => debian-template}/rules (87%) mode change 100755 => 100644 rename {debian => debian-template}/source/format (100%) rename {debian => debian-template}/source/options (81%) create mode 100644 debian-template/srb2.desktop delete mode 100644 debian/changelog delete mode 100644 debian/srb2.desktop create mode 100644 debian_template.sh create mode 100644 deployer/travis/deployer.sh create mode 100644 deployer/travis/deployer_build.sh create mode 100644 deployer/travis/deployer_defaults.sh create mode 100644 deployer/travis/deployer_dput.sh create mode 100644 deployer/travis/deployer_ftp.sh diff --git a/.gitignore b/.gitignore index 922fac4aa..3090417dd 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ Win32_LIB_ASM_Release *.db *.opendb /.vs +/debian +/assets/debian diff --git a/.travis.yml b/.travis.yml index 1131bff3a..9d5774293 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,20 @@ +# Travis-CI Config +# +# You may use the Deployer to upload packages and builds to external servers. +# See deployer/travis/deployer_defaults.sh for environment variables to configure. + language: c sudo: required dist: trusty matrix: include: +################################ +# Test Buildbots +# Deployer does not operate on these. See Deployer Buildbots, below. +# These bots are disabled when a deployment is triggered by 'deployer' branch name AND DPL_TERMINATE_TESTS=1. +# These bots remain enabled when a deployment is triggered by release tag. +################################ - os: linux addons: apt: @@ -15,6 +26,7 @@ matrix: - p7zip-full - gcc-4.4 compiler: gcc-4.4 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7 - os: linux addons: @@ -27,6 +39,7 @@ matrix: - p7zip-full - gcc-4.6 compiler: gcc-4.6 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4 - os: linux addons: @@ -39,9 +52,11 @@ matrix: - p7zip-full - gcc-4.7 compiler: gcc-4.7 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.7 - os: linux compiler: gcc + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 - os: linux addons: @@ -56,6 +71,7 @@ matrix: - p7zip-full - gcc-4.8 compiler: gcc-4.8 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: @@ -71,6 +87,7 @@ matrix: - gcc-7 compiler: gcc-7 env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 - os: linux addons: @@ -86,9 +103,11 @@ matrix: - gcc-8 compiler: gcc-8 env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 - os: linux compiler: clang + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #clang version 3.5.0 (tags/RELEASE_350/final) - os: linux addons: @@ -103,6 +122,7 @@ matrix: - p7zip-full - clang-3.5 compiler: clang-3.5 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) - os: linux addons: @@ -118,6 +138,7 @@ matrix: - p7zip-full - clang-3.6 compiler: clang-3.6 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) - os: linux addons: @@ -133,6 +154,7 @@ matrix: - p7zip-full - clang-3.7 compiler: clang-3.7 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) - os: linux addons: @@ -148,6 +170,7 @@ matrix: - p7zip-full - clang-3.8 compiler: clang-3.8 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #clang version 3.8.1-svn271127-1~exp1 (branches/release_38) - os: linux addons: @@ -163,6 +186,7 @@ matrix: - p7zip-full - clang-3.9 compiler: clang-3.9 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #clang version 3.9.X # - os: linux # addons: @@ -178,6 +202,7 @@ matrix: # - p7zip-full # - clang-4.0 # compiler: clang-4.0 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #clang version 4.0.X # - os: linux # addons: @@ -193,32 +218,321 @@ matrix: # - p7zip-full # - clang-5.0 # compiler: clang-5.0 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #clang version 5.0.X # - os: osx # osx_image: beta-xcode6.1 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) # - os: osx # osx_image: beta-xcode6.2 # compiler: gcc +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) ## - os: osx ## osx_image: beta-xcode6.3 +## if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ ## #I think xcode.6.3 VM is broken, it does not boot # - os: osx # osx_image: xcode6.4 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) # - os: osx # osx_image: xcode7 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 7.0.0 (clang-700.0.72) # - os: osx # osx_image: xcode7.1 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 7.0.0 (clang-700.1.76) # - os: osx # osx_image: xcode7.2 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ # #Apple LLVM version 7.0.2 (clang-700.1.81) - os: osx osx_image: xcode7.3 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #Apple LLVM version 7.3.0 (clang-703.0.31) + + +################################ +# Deployer Buildbots - OSX +################################ + - os: osx + osx_image: xcode7.3 + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=osx + - _DPL_FTP_TARGET=1 + - _DPL_PACKAGE_BINARY=1 + #Apple LLVM version 7.3.0 (clang-703.0.31) + + +################################ +# Deployer Buildbots - Linux assets +# Set DPL_TERMINATE_ASSETS to disable all of these +# List Ubuntu LTS next, newest to oldest +# Then list non-LTS, newest to oldest +################################ + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_ASSETS) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=bionic-asset + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - _DPL_PACKAGE_MAIN=0 + - _DPL_PACKAGE_ASSET=1 + - PACKAGE_DISTRO=bionic + #- PACKAGE_SUBVERSION=~18.04bionic + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + + ################################ + # The below asset bots produce packages that occupy too much space. + # It would be nice if the asset files were not included in the source package itself, + # so these can deploy to each Ubuntu target without manual intervention. + # + # Currently, to get around Launchpad's space limitation, + # copy the packages from *one* bot and the space usage is not increased. + ################################ + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: trusty + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=trusty-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=trusty + # #- PACKAGE_SUBVERSION=~14.04trusty + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=disco-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=disco + # #- PACKAGE_SUBVERSION=~19.04disco + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=cosmic-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=cosmic + # #- PACKAGE_SUBVERSION=~18.10cosmic + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=xenial-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=xenial + # #- PACKAGE_SUBVERSION=~16.04xenial + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + + +################################ +# Deployer Buildbots - Linux binaries +# List Ubuntu LTS, newest to oldest +# Then list non-LTS, newest to oldest +################################ + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=bionic + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=bionic + - PACKAGE_SUBVERSION=~18.04bionic + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: trusty + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=trusty + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=trusty + - PACKAGE_SUBVERSION=~14.04trusty + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=disco + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=disco + - PACKAGE_SUBVERSION=~19.04disco + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=cosmic + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=cosmic + - PACKAGE_SUBVERSION=~18.10cosmic + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + - os: linux + addons: + apt: + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=xenial + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=xenial + - PACKAGE_SUBVERSION=~16.04xenial + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 allow_failures: - compiler: clang-3.5 - compiler: clang-3.6 @@ -228,12 +542,14 @@ matrix: - compiler: clang-4.0 - compiler: clang-5.0 + cache: apt: true ccache: true directories: - $HOME/srb2_cache + addons: apt: packages: @@ -241,23 +557,127 @@ addons: - libpng-dev - libgl1-mesa-dev - libgme-dev + - zlib1g-dev - p7zip-full -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 - - 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets - - mkdir build - - cd build - - export CFLAGS="-Wall -W -Werror $WFLAGS" - - export CCACHE_COMPRESS=true - - 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 + # Initialize Deployer defaults + - . ./deployer/travis/deployer_defaults.sh + # Initialize Deployer; check if Deployer is enabled + # This needs to be run in the current shell so that $__DPL_ACTIVE is set for this session + - . ./deployer/travis/deployer.sh + # Also check if we should now terminate + - if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]]; then + if [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Exiting early because this job is not deploying."; + exit; + fi; + fi + # If we're triggered by release tag, force ASSET_FILES_OPTIONAL_GET=1 + - if [[ "$__DPL_TAG_ELIGIBLE" = "1" ]]; then + ASSET_FILES_OPTIONAL_GET=1; + fi; + + +install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update; + brew install sdl2 game-music-emu zlib p7zip; + brew install sdl2_mixer --with-flac --with-mpg123; + brew install cmake||true; + fi - mkdir -p $HOME/srb2_cache -script: make -k + +before_script: + # OLDPWD is root repo folder + - OLDPWD=$PWD + - cd "$HOME/srb2_cache" + + # stat is different for OSX + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + STATCMD="stat -f %m"; + else + STATCMD="stat -c %y"; + fi + + # Get asset files (required for MD5) + - if [[ "$ASSET_ARCHIVE_PATH" != "" ]]; then + if [ -f "$(basename $ASSET_ARCHIVE_PATH)" ]; then + echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))"; + fi; + wget --verbose --server-response -N "$ASSET_ARCHIVE_PATH"; + 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$HOME/srb2_cache" -aos; + for f in $ASSET_FILES_REQUIRED; do + cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; + done; + fi; + + # Get individual required files + - for f in $ASSET_FILES_REQUIRED; do + if [ -f "$f" ]; then + echo "$f cache date -- $($STATCMD $f)"; + fi; + wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; + if [ ! -f "$HOME/srb2_cache/$f" ]; then + echo "Could not download \"$ASSET_BASE_PATH/$f\""; + return 1; + fi; + cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; + done; + + # Get the docs + - for f in $ASSET_FILES_DOCS; do + if [ -f "$f" ]; then + echo "$f cache date -- $($STATCMD $f)"; + fi; + wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; + cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; + done; + + # Get optional files too + - if [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]]; then + for f in $ASSET_FILES_OPTIONAL; do + if [ -f "$f" ]; then + echo "$f cache date -- $($STATCMD $f)"; + fi; + wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; + cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; + done; + fi; + + # Go back to root repo folder + - cd "$OLDPWD" + + # Prepare CMake asset lists + - SRB2_ASSET_REQUIRED=$(echo ${ASSET_FILES_REQUIRED// /\;}) + - SRB2_ASSET_OPTIONAL=$(echo ${ASSET_FILES_OPTIONAL// /\;}) + - SRB2_ASSET_DOCS=$(echo ${ASSET_FILES_DOCS// /\;}) + + # Prepare CMake + - mkdir build + - cd build + - mkdir package + - export CFLAGS="-Wall -W -Werror $WFLAGS" + - export CCACHE_COMPRESS=true + - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package + -DSRB2_ASSET_REQUIRED="${SRB2_ASSET_REQUIRED}" -DSRB2_ASSET_OPTIONAL="${SRB2_ASSET_OPTIONAL}" + -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}" + -DCPACK_PACKAGE_DESCRIPTION_SUMMARY="${PROGRAM_NAME}" + -DCPACK_PACKAGE_VENDOR="${PROGRAM_VENDOR}" + -DSRB2_SDL2_EXE_NAME="${PROGRAM_FILENAME}" + + +script: + # Build our Makefile from Cmake! + - if [[ "$__DPL_ACTIVE" == "1" ]]; then + . ../deployer/travis/deployer_build.sh; + else + make -k; + fi; + +after_success: + # Run the Deployer scripts + - . ../deployer/travis/deployer_ftp.sh + - . ../deployer/travis/deployer_dput.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb065d04..bc198e81b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 3.0) +# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. +# Version change is fine. project(SRB2 VERSION 2.1.23 LANGUAGES C) @@ -86,8 +88,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2) -set(SRB2_WIN_EXE_NAME srb2dd) +set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") +set(SRB2_WIN_EXE_NAME srb2dd CACHE STRING "Executable binary output name for DirectDraw build") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) @@ -116,8 +118,8 @@ if(${CMAKE_SYSTEM} MATCHES "Darwin") set(CPACK_GENERATOR "DragNDrop") endif() -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2") -set(CPACK_PACKAGE_VENDOR "Sonic Team Jr.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2" CACHE STRING "Program name for display purposes") +set(CPACK_PACKAGE_VENDOR "Sonic Team Jr." CACHE STRING "Vendor name for display purposes") #set(CPACK_PACKAGE_DESCRIPTION_FILE ) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) diff --git a/assets/.gitignore b/assets/.gitignore index 9ed61ca1a..d6e46a75b 100644 --- a/assets/.gitignore +++ b/assets/.gitignore @@ -1,5 +1,10 @@ -* -*.* +*.srb +*.pk3 +*.dta +*.wad +*.txt !README.txt !LICENSE.txt -!LICENSE-3RD-PARTY.txt \ No newline at end of file +!LICENSE-3RD-PARTY.txt +!CMakeLists.txt +!debian-template/* diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 6edb3df13..35e018d46 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,26 +1,44 @@ ## Assets Target Configuration ## -# MD5 generation -set(SRB2_ASSET_ALL - ${CMAKE_CURRENT_SOURCE_DIR}/srb2.srb - ${CMAKE_CURRENT_SOURCE_DIR}/player.dta - ${CMAKE_CURRENT_SOURCE_DIR}/rings.dta - ${CMAKE_CURRENT_SOURCE_DIR}/zones.dta - ${CMAKE_CURRENT_SOURCE_DIR}/patch.dta - ${CMAKE_CURRENT_SOURCE_DIR}/music.dta - ${CMAKE_CURRENT_SOURCE_DIR}/README.txt - ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt - ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE-3RD-PARTY.txt +# For prepending the current source path, later +FUNCTION(PREPEND var prefix) + SET(listVar "") + FOREACH(f ${ARGN}) + LIST(APPEND listVar "${prefix}/${f}") + ENDFOREACH(f) + SET(${var} "${listVar}" PARENT_SCOPE) +ENDFUNCTION(PREPEND) + +set(SRB2_ASSET_REQUIRED +"srb2.srb;\ +player.dta;\ +rings.dta;\ +zones.dta;\ +patch.dta" + CACHE STRING "Required asset files for packaging. No spaces between entries!" ) -set(SRB2_ASSET_HASHED - srb2.srb - player.dta - rings.dta - zones.dta - patch.dta +set(SRB2_ASSET_DOCS +"README.txt;\ +LICENSE.txt;\ +LICENSE-3RD-PARTY.txt" + CACHE STRING "Documentation files; will not fail if they do not exist. Packaged differently from optional assets. No spaces between entries!" ) +set(SRB2_ASSET_OPTIONAL +"music.dta" + CACHE STRING "Optional asset files. No spaces between entries!" +) + +# MD5 generation - Filename only, we don't append path to this +set(SRB2_ASSET_HASHED + ${SRB2_ASSET_REQUIRED} +) + +PREPEND(SRB2_ASSET_REQUIRED ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_REQUIRED}) +PREPEND(SRB2_ASSET_DOCS ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_DOCS}) +PREPEND(SRB2_ASSET_OPTIONAL ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_OPTIONAL}) + foreach(SRB2_ASSET ${SRB2_ASSET_HASHED}) file(MD5 ${CMAKE_CURRENT_SOURCE_DIR}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE) @@ -28,13 +46,29 @@ endforeach() # Installation -if(CLANG) +if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - install(FILES ${SRB2_ASSET_ALL} + install(FILES ${SRB2_ASSET_REQUIRED} DESTINATION "${outname}.app/Contents/Resources" ) + install(FILES ${SRB2_ASSET_OPTIONAL} + DESTINATION "${outname}.app/Contents/Resources" + OPTIONAL + ) + install(FILES ${SRB2_ASSET_DOCS} + DESTINATION . + OPTIONAL + ) else() - install(FILES ${SRB2_ASSET_ALL} + install(FILES ${SRB2_ASSET_REQUIRED} DESTINATION . ) + install(FILES ${SRB2_ASSET_OPTIONAL} + DESTINATION . + OPTIONAL + ) + install(FILES ${SRB2_ASSET_DOCS} + DESTINATION . + OPTIONAL + ) endif() diff --git a/assets/debian/README.Debian b/assets/debian-template/README.Debian similarity index 59% rename from assets/debian/README.Debian rename to assets/debian-template/README.Debian index 68c952a4e..f3fe90030 100644 --- a/assets/debian/README.Debian +++ b/assets/debian-template/README.Debian @@ -12,9 +12,39 @@ with apt-key add. Thanks! -- Callum Dickinson Fri, 26 Nov 2010 18:25:31 +1300 +--------------- + + +Templating + +Note that you MUST run [repo-root]/debian_template.sh before running debuild +on these scripts! debian_template.sh fills these template files with working values. + +You should also set PACKAGE_NAME_EMAIL="John Doe " to match +the identity of the key you will use to sign the package. + + +Building for Launchpad PPA + +Run this step first: + + 1. source [repo-root]/debian_template.sh + * Initializes defaults for the package variables and fills in templates. + +Use these steps to prepare building a source package for Launchpad: + + 1. cd [repo-root]/assets/ + 2. debuild -T clean-all (optional; if you already have asset files, this clears them) + +Build the source package: + + 1. debuild -T build (this downloads the asset files from srb2.org if necessary) + 2. debuild -S (builds the source package for Launchpad, including the asset files) + + Signing for Launchpad PPA -First, follow the above instructions to generate a GnuPG key with your identity. You will need +First, follow Callum's instructions to generate a GnuPG key with your identity. You will need to publish the fingerprint of that key to Ubuntu's key server. https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Uploading_the_key_to_Ubuntu_keyserver @@ -26,22 +56,18 @@ upload signed source packages and publish them onto your PPA. IF YOU UPLOAD A PACKAGE and Launchpad does NOT send you a confirmation or rejection email, that means your key is not set up correctly with your Launchpad account. +Finally, if your packages have not already been signed, follow these steps: -Building for Launchpad PPA + 1. cd .. + * Packages are located in the parent folder of where debuild was called + 2. debsign "srb2-data_[version]_source.changes" + * You may need to specify -k [key-fingerprint] -Use these steps to prepare building a source package for Launchpad: - 1. Highly recommend copying the assets/ folder to outside your repo folder, or else the asset - files may be included in the main source package, when you build that. - 2. cd [wherever-your-assets-folder-is]/assets/ - 3. debuild -T clean (optional, if you already have asset files) +Uploading for Launchpad PPA -Building the source package is a two-step process: - - 1. debuild -T build (this downloads the asset files from srb2.org if necessary) - 2. debuild -S (builds the source package for Launchpad, including the asset files) - -Then follow the instructions at to upload +Follow the instructions at to upload to your PPA and have Launchpad build your binary deb packages. + -- Marco Zafra Mon, 26 Nov 2018 21:13:00 -0500 diff --git a/assets/debian/README.source b/assets/debian-template/README.source similarity index 100% rename from assets/debian/README.source rename to assets/debian-template/README.source diff --git a/assets/debian-template/changelog b/assets/debian-template/changelog new file mode 100644 index 000000000..64562e2a3 --- /dev/null +++ b/assets/debian-template/changelog @@ -0,0 +1,5 @@ +${PACKAGE_NAME}-data (${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}) ${PACKAGE_DISTRO}; urgency=${PACKAGE_URGENCY} + + * ${PROGRAM_NAME} v${PROGRAM_VERSION} asset data + + -- ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} diff --git a/assets/debian/compat b/assets/debian-template/compat similarity index 100% rename from assets/debian/compat rename to assets/debian-template/compat diff --git a/assets/debian/control b/assets/debian-template/control similarity index 84% rename from assets/debian/control rename to assets/debian-template/control index 22d9643ee..ae5c0ce67 100644 --- a/assets/debian/control +++ b/assets/debian-template/control @@ -1,15 +1,15 @@ # SRB2-data Debian package control file. -Source: srb2-data +Source: ${PACKAGE_NAME}-data Section: games Priority: extra -Maintainer: Sonic Team Junior +Maintainer: ${PACKAGE_GROUP_NAME_EMAIL} Build-Depends: debhelper (>= 7.0.50~), wget Standards-Version: 3.8.4 -Homepage: http://www.srb2.org +Homepage: ${PACKAGE_WEBSITE} -Package: srb2-data +Package: ${PACKAGE_NAME}-data Architecture: all Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog diff --git a/debian/copyright b/assets/debian-template/copyright similarity index 57% rename from debian/copyright rename to assets/debian-template/copyright index 97d606b0f..cc47c453b 100644 --- a/debian/copyright +++ b/assets/debian-template/copyright @@ -1,18 +1,18 @@ This work was packaged for Debian by: - Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 + ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} It was downloaded from: - + ${PACKAGE_WEBSITE} Upstream Author(s): - Sonic Team Junior + ${PACKAGE_GROUP_NAME_EMAIL} Copyright: - Copyright (C) 1998-2018 Sonic Team Junior + Copyright (C) 1998-2018 by Sonic Team Junior License: @@ -21,7 +21,7 @@ License: The Debian packaging is: Copyright (C) 2010 Callum Dickinson - Copyright (C) 2010-2018 Sonic Team Junior + Copyright (C) 2010-2018 by Sonic Team Junior and is licensed under the GPL version 2, see "/usr/share/common-licenses/GPL-2". diff --git a/assets/debian/rules b/assets/debian-template/rules old mode 100755 new mode 100644 similarity index 58% rename from assets/debian/rules rename to assets/debian-template/rules index a34a3393f..99a4eaf3c --- a/assets/debian/rules +++ b/assets/debian-template/rules @@ -23,6 +23,16 @@ # ############################################################################# +############################################################################# +# +# !!!!!!!!!! DEPLOYER NOTE !!!!!!!!!! +# +# Variables to be templated are curly-braced ${PACKAGE_INSTALL_PATH} +# Variables used by the rules script are parenthese'd $(DATADIR) +# See [repo-root]/debian_template.sh +# +############################################################################# + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -37,9 +47,12 @@ RM := rm -rf DIR := $(shell pwd) PACKAGE := $(shell cat $(DIR)/debian/control | grep 'Package:' | sed -e 's/Package: //g') -DATAFILES := srb2.srb zones.dta player.dta rings.dta music.dta patch.dta README.txt LICENSE.txt LICENSE-3RD-PARTY.txt +DATAFILES := ${ASSET_FILES_REQUIRED} +DOCFILES := ${ASSET_FILES_DOCS} +OPTIONALFILES := ${ASSET_FILES_OPTIONAL} +GETOPTIONALFILES := ${ASSET_FILES_OPTIONAL_GET} -DATADIR := usr/games/SRB2 +DATADIR := $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///') RESOURCEDIR := . WGET := wget -P $(RESOURCEDIR) -c -nc @@ -49,18 +62,41 @@ build: # This will need to be updated every time SRB2 official version is # Copy data files to their install locations, and add data files to include-binaries for file in $(DATAFILES); do \ - if [ ! -f $(RESOURCEDIR)/$$file ]; then \ - $(WGET) http://alam.srb2.org/SRB2/2.1.21-Final/Resources/$$file; \ + if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ fi; \ - if [ -f $(RESOURCEDIR)/$$file ]; then \ - $(INSTALL) $(RESOURCEDIR)/$$file $(DIR)/debian/tmp/$(DATADIR)/$$file; \ - echo $(RESOURCEDIR)/$$file >> $(DIR)/debian/source/include-binaries; \ + if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ + echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ fi; \ - if [ ! -f $(DIR)/debian/tmp/$(DATADIR)/$$file ]; then \ - echo $(DIR)/debian/tmp/$(DATADIR)/$$file not found and could not be downloaded!; \ + if [ ! -f $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR} ]; then \ + echo $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR} not found and could not be downloaded!; \ return 1; \ fi; \ done + # Do the same for DOCFILES, but don't error out if not found + for file in $(DOCFILES); do \ + if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ + fi; \ + if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ + echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ + fi; \ + done + # Do the same for OPTIONALFILES if GETOPTIONALFILES == 1 + if [ "$(GETOPTIONALFILES)" = "1" ]; then \ + for file in $(OPTIONALFILES); do \ + if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ + fi; \ + if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ + $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ + echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ + fi; \ + done; \ + fi; + binary-indep: # Generate install folder file diff --git a/assets/debian/source/format b/assets/debian-template/source/format similarity index 100% rename from assets/debian/source/format rename to assets/debian-template/source/format diff --git a/assets/debian/source/options b/assets/debian-template/source/options similarity index 100% rename from assets/debian/source/options rename to assets/debian-template/source/options diff --git a/assets/debian/changelog b/assets/debian/changelog deleted file mode 100644 index f3a92e1cd..000000000 --- a/assets/debian/changelog +++ /dev/null @@ -1,19 +0,0 @@ -srb2-data (2.1.21~7) trusty; urgency=high - - * Updated for SRB2 v2.1.21 - - -- Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 - - -srb2-data (2.1.14~1) unstable; urgency=low - - * Updated for SRB2 v2.1.14 - - -- Alam Arias Sat, 6 Jan 2016 11:00:00 -0500 - - -srb2-data (2.0.6-2) maverick; urgency=high - - * Initial proper release.. - - -- Callum Dickinson Sat, 29 Jan 2011 01:18:42 +1300 diff --git a/debian/README.Debian b/debian-template/README.Debian similarity index 62% rename from debian/README.Debian rename to debian-template/README.Debian index 4b724816e..3aa52787e 100644 --- a/debian/README.Debian +++ b/debian-template/README.Debian @@ -10,10 +10,38 @@ and give them to your users to install with apt-key add. Thanks! -- Callum Dickinson Fri, 26 Nov 2010 18:25:31 +1300 +--------------- + + +Templating + +Note that you MUST run [repo-root]/debian_template.sh before running debuild +on these scripts! debian_template.sh fills these template files with working values. + +You should also set PACKAGE_NAME_EMAIL="John Doe " to match +the identity of the key you will use to sign the package. + + +Building for Launchpad PPA + +Use these steps to prepare building a source package for Launchpad: + + 1. cd [repo-root] + 2. git reset --hard; git clean -fd; git clean -fx; + * Resets your repo folder to a committed state and removes untracked files + * If you built srb2-data in the assets/ folder, MAKE SURE THAT FOLDER DOES NOT HAVE ASSETS, + OR THEY MAY BE INCLUDED IN THE MAIN SOURCE PACKAGE! + +Build the source package: + + 1. source [repo-root]/debian_template.sh + * Initializes defaults for the package variables and fills in templates. + 2. debuild -S (builds the source package for Launchpad) + Signing for Launchpad PPA -First, follow the above instructions to generate a GnuPG key with your identity. You will need +First, follow Callum's instructions to generate a GnuPG key with your identity. You will need to publish the fingerprint of that key to Ubuntu's key server. https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Uploading_the_key_to_Ubuntu_keyserver @@ -25,22 +53,18 @@ upload signed source packages and publish them onto your PPA. IF YOU UPLOAD A PACKAGE and Launchpad does NOT send you a confirmation or rejection email, that means your key is not set up correctly with your Launchpad account. +Finally, if your packages have not already been signed, follow these steps: -Building for Launchpad PPA + 1. cd .. + * Packages are located in the parent folder of where debuild was called + 2. debsign "srb2_[version]_source.changes" + * You may need to specify -k [key-fingerprint] -Use these steps to prepare building a source package for Launchpad: - 1. cd [srb2repo] - 2. git reset --hard; git clean -fd; git clean -fx; - * Resets your repo folder to a committed state and removes untracked files - * If you built srb2-data in the assets/ folder, MAKE SURE THAT FOLDER DOES NOT HAVE ASSETS, - OR THEY MAY BE INCLUDED IN THE MAIN SOURCE PACKAGE! +Uploading for Launchpad PPA -Building the source package takes just one step: - - 1. debuild -S (builds the source package for Launchpad) - -Then follow the instructions at to upload +Follow the instructions at to upload to your PPA and have Launchpad build your binary deb packages. + -- Marco Zafra Mon, 26 Nov 2018 21:13:00 -0500 diff --git a/debian/README.source b/debian-template/README.source similarity index 100% rename from debian/README.source rename to debian-template/README.source diff --git a/debian-template/changelog b/debian-template/changelog new file mode 100644 index 000000000..fb08908cd --- /dev/null +++ b/debian-template/changelog @@ -0,0 +1,5 @@ +${PACKAGE_NAME} (${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}) ${PACKAGE_DISTRO}; urgency=${PACKAGE_URGENCY} + + * ${PROGRAM_NAME} v${PROGRAM_VERSION} program build + + -- ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} diff --git a/debian/compat b/debian-template/compat similarity index 100% rename from debian/compat rename to debian-template/compat diff --git a/debian/control b/debian-template/control similarity index 65% rename from debian/control rename to debian-template/control index 0f2d8062b..e1348d704 100644 --- a/debian/control +++ b/debian-template/control @@ -1,24 +1,30 @@ # SRB2 Debian package control file. -Source: srb2 +Source: ${PACKAGE_NAME} Section: games Priority: extra -Maintainer: Sonic Team Junior +Maintainer: ${PACKAGE_GROUP_NAME_EMAIL} Build-Depends: debhelper (>= 7.0.50~), libsdl2-dev, libsdl2-mixer-dev, - libpng12-dev (>= 1.2.7) | libpng-dev, + libpng-dev | libpng16-dev | libpng12-dev (>= 1.2.7), zlib1g-dev, libgme-dev, libglu1-dev | libglu-dev, libosmesa6-dev | libgl-dev, nasm [i386] Standards-Version: 3.8.4 -Homepage: http://www.srb2.org +Homepage: ${PACKAGE_WEBSITE} -Package: srb2 +Package: ${PACKAGE_NAME} Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23) +Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS}, + ${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}), + libsdl2-2.0-0, + libsdl2-mixer-2.0-0, + zlib1g, + libgme0, + libpng | libpng16-16 | libpng12-0 Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy @@ -28,10 +34,10 @@ Description: A cross-platform 3D Sonic fangame and quite a lot of the fun that the original Sonic games provided. -Package: srb2-dbg +Package: ${PACKAGE_NAME}-dbg Architecture: any -# FIXME: should be Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat -Depends: libc6, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23), srb2 +# FIXME: should be Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat +Depends: libc6, ${MISC_DEPENDS}, ${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}), ${PACKAGE_NAME} Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy diff --git a/assets/debian/copyright b/debian-template/copyright similarity index 57% rename from assets/debian/copyright rename to debian-template/copyright index 97d606b0f..cc47c453b 100644 --- a/assets/debian/copyright +++ b/debian-template/copyright @@ -1,18 +1,18 @@ This work was packaged for Debian by: - Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 + ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} It was downloaded from: - + ${PACKAGE_WEBSITE} Upstream Author(s): - Sonic Team Junior + ${PACKAGE_GROUP_NAME_EMAIL} Copyright: - Copyright (C) 1998-2018 Sonic Team Junior + Copyright (C) 1998-2018 by Sonic Team Junior License: @@ -21,7 +21,7 @@ License: The Debian packaging is: Copyright (C) 2010 Callum Dickinson - Copyright (C) 2010-2018 Sonic Team Junior + Copyright (C) 2010-2018 by Sonic Team Junior and is licensed under the GPL version 2, see "/usr/share/common-licenses/GPL-2". diff --git a/debian/docs b/debian-template/docs similarity index 100% rename from debian/docs rename to debian-template/docs diff --git a/debian/rules b/debian-template/rules old mode 100755 new mode 100644 similarity index 87% rename from debian/rules rename to debian-template/rules index ff80d50bf..0a77624cb --- a/debian/rules +++ b/debian-template/rules @@ -23,6 +23,16 @@ # ############################################################################# +############################################################################# +# +# !!!!!!!!!! DEPLOYER NOTE !!!!!!!!!! +# +# Variables to be templated are curly-braced ${PACKAGE_INSTALL_PATH} +# Variables used by the rules script are parenthese'd $(PKGDIR) +# See [repo-root]/debian_template.sh +# +############################################################################# + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -50,16 +60,16 @@ DIR := $(shell pwd) # FIXME: hate hate hate head/tail hack :( CONTROLF = $(DIR)/debian/control -PACKAGE = srb2 -DBGPKG = $(PACKAGE)-dbg -TITLE = Sonic Robo Blast 2 +PACKAGE = ${PACKAGE_NAME} +DBGPKG = ${PACKAGE}-dbg +TITLE = ${PROGRAM_NAME} SECTION = Games/Action -EXENAME = srb2 +EXENAME = ${PROGRAM_FILENAME} DBGNAME = debug/$(EXENAME) -PKGDIR = usr/games/SRB2 +PKGDIR = $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///') DBGDIR = usr/lib/debug/$(PKGDIR) -LINKDIR = usr/games +LINKDIR = $(shell echo "${PACKAGE_LINK_PATH}" | sed -e 's/^\///') PIXMAPS_DIR = usr/share/pixmaps DESKTOP_DIR = usr/share/applications PREFIX = $(shell test "$(CROSS_COMPILE_BUILD)" != "$(CROSS_COMPILE_HOST)" && echo "PREFIX=$(CROSS_COMPILE_HOST)") @@ -102,8 +112,8 @@ binary-arch: $(INSTALL) $(BINDIR)/$(EXENAME) $(DIR)/debian/tmp/$(PKGDIR)/$(PACKAGE) $(INSTALL) $(BINDIR)/$(DBGNAME) $(DIR)/debian/tmp/$(DBGDIR)/$(PACKAGE) # Install desktop file and banner image - $(INSTALL) $(DIR)/srb2.png $(DIR)/debian/tmp/usr/share/pixmaps - $(INSTALL) $(DIR)/debian/srb2.desktop $(DIR)/debian/tmp/usr/share/applications + $(INSTALL) $(DIR)/srb2.png $(DIR)/debian/tmp/usr/share/pixmaps/${PROGRAM_FILENAME}.png + $(INSTALL) $(DIR)/debian/srb2.desktop $(DIR)/debian/tmp/usr/share/applications/${PROGRAM_FILENAME}.desktop # add compiled binaries to include-binaries echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries diff --git a/debian/source/format b/debian-template/source/format similarity index 100% rename from debian/source/format rename to debian-template/source/format diff --git a/debian/source/options b/debian-template/source/options similarity index 81% rename from debian/source/options rename to debian-template/source/options index 841c65a6f..1ef771ddf 100644 --- a/debian/source/options +++ b/debian-template/source/options @@ -2,7 +2,7 @@ tar-ignore = "assets/*.srb" tar-ignore = "assets/*.pk3" tar-ignore = "assets/*.dta" tar-ignore = "assets/*.wad" -tar-ignore = "assets/debian/srb2-data/*" +tar-ignore = "assets/debian/${PACKAGE_NAME}-data/*" tar-ignore = "assets/debian/tmp/*" tar-ignore = "*.obj" tar-ignore = "*.dep" diff --git a/debian-template/srb2.desktop b/debian-template/srb2.desktop new file mode 100644 index 000000000..07c7906e0 --- /dev/null +++ b/debian-template/srb2.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=${PROGRAM_NAME} +Comment=${PROGRAM_DESCRIPTION} +Encoding=UTF-8 +Exec=${PACKAGE_INSTALL_PATH}/${PROGRAM_FILENAME} +Icon=/usr/share/pixmaps/${PROGRAM_FILENAME}.png +Terminal=false +Type=Application +StartupNotify=false +Categories=Application;Game; diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index b06a78e2b..000000000 --- a/debian/changelog +++ /dev/null @@ -1,12 +0,0 @@ -srb2 (2.1.23~9) trusty; urgency=high - - * SRB2 v2.1.23 release - - -- Marco Zafra Mon, 27 Nov 2018 16:45:00 -0500 - - -srb2 (2.0.6-5) maverick; urgency=high - - * Initial proper release.. - - -- Callum Dickinson Sat, 29 Jan 2011 01:18:42 +1300 diff --git a/debian/srb2.desktop b/debian/srb2.desktop deleted file mode 100644 index 3a1cac9f6..000000000 --- a/debian/srb2.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=Sonic Robo Blast 2 -Comment=A free 3D Sonic the Hedgehog fangame closely inspired by the original Sonic games on the Sega Genesis. -Encoding=UTF-8 -Exec=/usr/games/SRB2/srb2 -Icon=/usr/share/pixmaps/srb2.png -Terminal=false -Type=Application -StartupNotify=false -Categories=Application;Game; diff --git a/debian_template.sh b/debian_template.sh new file mode 100644 index 000000000..c1af3c19f --- /dev/null +++ b/debian_template.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Debian package templating +# +# Call this script BEFORE running debuild! +# source ./debian_template.sh [clean] [main/asset] +# +# Before running this script, +# you should also set PACKAGE_NAME_EMAIL="John Doe " to match +# the identity of the key you will use to sign the package. +# + +# Get script's actual path +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +# Recursive function for directory crawling +# $1 = Directory root to crawl +# $2 = Code to eval on file +# $3 = Code to eval on directory +# Exposes $dirtails, $dirlevel, and $dirtailname +dirlevel=0 # initialize +dirtails=() + +# Utility function to make dira/dirb/dirc string +makedirtailname () { + dirtailname="" + for tail in $dirtails; do + if [[ "$dirtailname" == "" ]]; then + dirtailname="/$tail"; + else + dirtailname="$dirtailname/$tail"; + fi; + done; +} + +evaldirectory () { + if [ -d "$1" ]; then + # Set contextual variables + # dirtails is an array of directory basenames after the crawl root + if (( $dirlevel > 0 )); then + dirtails+=( "$(basename $1)" ); + else + dirtails=(); + fi; + dirlevel=$((dirlevel+1)); + + # Generate directory path after the crawl root + makedirtailname; + + # Eval our directory with the latest contextual info + # Don't eval on root + if (( $dirlevel > 1 )) && [[ "$3" != "" ]]; then + eval "$3"; + fi; + + # Iterate entries + for name in $1/*; do + if [ -d "$name" ]; then + # Name is a directory, but don't eval yet + # Recurse so our vars are updated + evaldirectory "$name" "$2" "$3"; + + # Decrement our directory level and remove a dirtail + unset 'dirtails[ ${#dirtails[@]}-1 ]'; + dirlevel=$((dirlevel-1)); + makedirtailname; + else + # Name is a file + if [ -f "$name" ] && [[ "$2" != "" ]]; then + eval "$2"; + fi; + fi; + done; + + # Reset our variables; we're done iterating + if (( $dirlevel == 1 )); then + dirlevel=0; + fi; + fi; +} + +# +# Initialize package parameter defaults +# +if [[ "$__DEBIAN_PARAMETERS_INITIALIZED" != "1" ]]; then + . ${DIR}/deployer/travis/deployer_defaults.sh; +fi; + +# Clean up after ourselves; we only expect to run this script once +# during buildboting +__DEBIAN_PARAMETERS_INITIALIZED=0 + +# for envsubst +export __PACKAGE_DATETIME="$(date '+%a, %d %b %Y %H:%M:%S %z')" +export __PACKAGE_DATETIME_DIGIT="$(date -u '+%Y%m%d%H%M%S')" + +if [[ "$PACKAGE_REVISION" == "" ]]; then + PACKAGE_REVISION="-$__PACKAGE_DATETIME_DIGIT"; + __PACKAGE_REVISION_BY_DATE=1; + export PACKAGE_REVISION=${PACKAGE_REVISION}; # for envsubst +fi; + +# +# Clean the old debian/ directories +# +if [[ "$1" == "clean" ]]; then + toclean=$2; +else + toclean=$1; +fi; + +if [[ "$toclean" == "" ]] || [[ "$toclean" == "main" ]]; then + echo "Cleaning main package scripts"; + if [[ ! -f ${DIR}/debian ]]; then + rm -rf ${DIR}/debian; + fi; +fi; +if [[ "$toclean" == "" ]] || [[ "$toclean" == "asset" ]]; then + echo "Cleaning asset package scripts"; + if [[ ! -f ${DIR}/assets/debian ]]; then + rm -rf ${DIR}/assets/debian; + fi; +fi; + +# +# Make new templates +# +if [[ "$1" != "clean" ]]; then + totemplate=$1; + + # HACK: ${shlibs:Depends} in the templates make the templating fail + # So just define replacemment variables + export SHLIBS_DEPENDS=${SHLIBS_DEPENDS}; + export MISC_DEPENDS=${MISC_DEPENDS}; + export DEBFILEVAR='$$file'; # used in assets/debian/rules + + # Package parameters are exported for envsubst in deployer_defaults.sh + + if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "main" ]]; then + echo "Generating main package scripts"; + fromroot=${DIR}/debian-template; + toroot=${DIR}/debian; + mkdir ${toroot}; + + evaldirectory ${fromroot} \ + "cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \ + "mkdir \"${toroot}\${dirtailname}\""; + fi; + + if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "asset" ]]; then + echo "Generating asset package scripts"; + fromroot=${DIR}/assets/debian-template; + toroot=${DIR}/assets/debian; + mkdir ${toroot}; + + # Root dir to crawl; file eval; directory eval + evaldirectory ${fromroot} \ + "cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \ + "mkdir \"${toroot}\${dirtailname}\""; + fi; +fi; + +if [[ "$__DPL_ACTIVE" != "1" ]] && [[ "$__PACKAGE_REVISION_BY_DATE" == "1" ]]; then + unset PACKAGE_REVISION; # so we can reset the date on subsequent runs +fi; diff --git a/deployer/travis/deployer.sh b/deployer/travis/deployer.sh new file mode 100644 index 000000000..c88155d21 --- /dev/null +++ b/deployer/travis/deployer.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Initialization +# +# Performs validity checks to ensure that Deployer is allowed to run +# e.g., is an FTP hostname specified? Are we whitelisted by OSNAMES and BRANCHES? +# +# Set these environment variables in your Travis-CI settings, where they are stored securely. +# See other shell scripts for more options. +# +# DPL_ENABLED = 1 (leave blank to disable) +# DPL_TAG_ENABLED = 1 (run Deployer on all tags) +# DPL_JOB_ENABLE_ALL = 1 (run Deployer on all jobs; leave blank to act on specific jobs, see below) +# DPL_JOBNAMES = name1,name2 (whitelist of job names to allow uploading; leave blank to upload from all jobs) +# DPL_OSNAMES = osx (whitelist of OS names to allow uploading; leave blank to upload from all OSes) +# DPL_BRANCHES = master,branch1,branch2 (whitelist of branches to upload; leave blank to upload all branches) +# +# To enable Deployer on specific jobs, set _DPL_JOB_ENABLED=1 for that job. Example: +# - matrix: +# - os: osx +# env: +# - _DPL_JOB_ENABLED=1 +# +# DO NOT set __DPL_ACTIVE, because that would bypass these validity checks. + +# Validate Deployer state +if [[ "$DPL_ENABLED" == "1" ]] && [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then + # Test for base eligibility: + # Are we in a deployer branch? Or + # Are we in a release tag AND DPL_TAG_ENABLED=1? + if [[ $TRAVIS_BRANCH == *"deployer"* ]]; then + __DPL_BASE_ELIGIBLE=1; + __DPL_TERMINATE_EARLY_ELIGIBLE=1; + fi; + + if [[ "$TRAVIS_TAG" != "" ]] && [[ "$DPL_TAG_ENABLED" == "1" ]]; then + __DPL_BASE_ELIGIBLE=1; + __DPL_TAG_ELIGIBLE=1; + __DPL_TERMINATE_EARLY_ELIGIBLE=1; + fi; + + # Logging message for trigger word + if [[ "$__DPL_TAG_ELIGIBLE" != "1" ]] && [[ "$DPL_TRIGGER" != "" ]]; then + echo "Testing for trigger $DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE"; + echo "[${DPL_TRIGGER}]"; + echo "[${DPL_TRIGGER}-${_DPL_JOB_NAME}]"; + echo "[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]"; + fi; + + # + # Search for the trigger word + # Force enable if release tags are eligible + # + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_TRIGGER" == "" ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER]"* ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${_DPL_JOB_NAME}]"* ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]"* ]]; then + # + # Whitelist by branch name + # Force enable if release tags are eligible + # + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then + # Set this so we only early-terminate builds when we are specifically deploying + # Trigger string and branch are encompassing conditions; the rest are job-specific + # This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1, + # because we're filtering non-deployer jobs. + # + # __DPL_TRY_TERMINATE_EARLY is invalidated in .travis.yml if __DPL_ACTIVE=1 + if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then + __DPL_TRY_TERMINATE_EARLY=1; + fi; + + # + # Is the job enabled for deployment? + # + if [[ "$DPL_JOB_ENABLE_ALL" == "1" ]] || [[ "$_DPL_JOB_ENABLED" == "1" ]]; then + # + # Whitelist by job names + # + if [[ "$DPL_JOBNAMES" == "" ]] || [[ "$_DPL_JOB_NAME" == "" ]] || [[ $DPL_JOBNAMES == *"$_DPL_JOB_NAME"* ]]; then + # + # Whitelist by OS names + # + if [[ "$DPL_OSNAMES" == "" ]] || [[ $DPL_OSNAMES == *"$TRAVIS_OS_NAME"* ]]; then + # Base Deployer is eligible for becoming active + + # Are we building for Linux? + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]] || [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + __DPL_DEBIAN_ACTIVE=1; + fi; + fi; + fi; + + # Now check for deployment targets + if [[ "$_DPL_FTP_TARGET" == "1" ]] && [[ "$DPL_FTP_HOSTNAME" != "" ]]; then + if [[ "$TRAVIS_OS_HOST" == "linux" ]] && [[ "$DPL_FTP_PROTOCOL" == "ftp" ]]; then + echo "Non-secure FTP will not work on Linux Travis-CI jobs!"; + echo "Try SFTP or another target. Details:"; + echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci"; + else + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] || [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_BINARY" == "1" ]]; then + echo "Deployer FTP target is enabled"; + __DPL_FTP_ACTIVE=1; + else + echo "Deployer FTP target cannot be enabled: You must specify _DPL_PACKAGE_BINARY=1,"; + echo "and/or _DPL_BINARY=1 in your job's environment variables."; + fi; + fi; + fi; + + if [[ "$_DPL_DPUT_TARGET" == "1" ]] && [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] \ + && [[ "$DPL_DPUT_INCOMING" != "" ]]; then + if [[ "$DPL_DPUT_METHOD" == "ftp" ]]; then + echo "DPUT will not work with non-secure FTP on Linux Travis-CI jobs!"; + echo "Try SFTP or another method for DPUT. Details:"; + echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci"; + else + echo "Deployer DPUT target is enabled"; + __DPL_DPUT_ACTIVE=1; + fi; + fi; + + # If any deployment targets are active, then so is the Deployer at large + if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + __DPL_ACTIVE=1; + fi; + fi; + fi; + fi; + fi; + else + if [[ "$DPL_TRIGGER" != "" ]]; then + echo "Testing for global trigger [$DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE"; + fi; + if [[ "$DPL_TRIGGER" != "" ]] && [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER"* ]]; then + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then + # This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1, + # because we're filtering non-deployer jobs. + if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then + # Assume that some job received the trigger, so mark this for early termination + __DPL_TRY_TERMINATE_EARLY=1; + fi; + fi; + fi; + fi; +fi; + +if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Deployer is active in another job"; +fi; + +if [[ "$__DPL_TRY_TERMINATE_EARLY" != "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Deployer is not active"; +fi; diff --git a/deployer/travis/deployer_build.sh b/deployer/travis/deployer_build.sh new file mode 100644 index 000000000..3817f025d --- /dev/null +++ b/deployer/travis/deployer_build.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Build Script +# +# Builds the required targets depending on which sub-modules are enabled + +if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then + echo "Building Debian package(s)" + + sudo apt-get install devscripts debhelper fakeroot secure-delete expect; + + # Build source packages first, since they zip up the entire source folder, + # binaries and all + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + . ../debian_template.sh main; + OLDPWD=$PWD; # [repo]/build + cd ..; # repo root + + if [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then + echo "Building main source Debian package"; + expect <(cat < key.asc; + echo "$DPL_PGP_KEY_PASSPHRASE" > phrase.txt; + gpg --import key.asc; + + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + echo "Signing main package(s)"; + + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; # parent of repo root + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*.changes; do + debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f"; + done; + done; + + cd $OLDPWD; + fi; + + if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + echo "Signing asset package(s)"; + + PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + ) + + # Asset packages are in root repo folder + OLDPWD=$PWD; # [repo]/build + cd ..; # repo root + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*.changes; do + debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f"; + done; + done; + + cd $OLDPWD; + fi; + + # Delete the keys :eyes: + srm key.asc; + srm phrase.txt; + fi; + fi; + + # all other OSes + if [[ "$TRAVIS_OS_NAME" != "linux" ]]; then + # + # Check for binary building + # + if [[ "$_DPL_BINARY" == "1" ]]; then + echo "Building a Binary"; + make -k; + fi; + + # + # Check for package building + # + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then + echo "Building a Package"; + + # Make an OSX package; superuser is required for library bundling + # + # HACK: OSX packaging can't write libraries to .app package unless we're superuser + # because the original library files don't have WRITE permission + # Bug may be sidestepped by using CHMOD_BUNDLE_ITEMS=TRUE + # But I don't know where this is set. Not `cmake -D...` because this var is ignored. + # https://cmake.org/Bug/view.php?id=9284 + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + sudo make -k package; + else + # Some day, when Windows is supported, we'll just make a standard package + make -k package; + fi; + fi; + fi; +fi; diff --git a/deployer/travis/deployer_defaults.sh b/deployer/travis/deployer_defaults.sh new file mode 100644 index 000000000..9716c31cb --- /dev/null +++ b/deployer/travis/deployer_defaults.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Default Variables +# +# Here are all of the user-set variables used by Deployer. +# See the "Cross-platform deployment" page on SRB2 Wiki for documentation. + +# Core Parameters +: ${DPL_ENABLED} # Enable Deployer behavior; must be set for any deployment activity +: ${DPL_TAG_ENABLED} # Trigger Deployer for all tag releases +: ${DPL_JOB_ENABLE_ALL} # Enable all jobs for deployment +: ${DPL_TERMINATE_TESTS} # Terminate all build test jobs (used in .travis.yml) +: ${DPL_TRIGGER} # Use a [word] in the commit message to trigger Deployer +: ${DPL_JOBNAMES} # Trigger Deployer by job name +: ${DPL_OSNAMES} # Trigger Deployer by OS name (osx,linux) +: ${DPL_BRANCHES} # Trigger Deployer by git branch name + +# Job Parameters +: ${_DPL_JOB_ENABLED} # Enable Deployer for this specific job. DPL_ENABLED must be set too. +: ${_DPL_JOB_NAME} # Identifier for the job, used for logging and trigger word matching +: ${_DPL_FTP_TARGET} # Deploy to FTP +: ${_DPL_DPUT_TARGET} # Deploy to DPUT +: ${_DPL_PACKAGE_SOURCE} # Build packages into a Source distribution. Linux only. +: ${_DPL_PACKAGE_BINARY} # Build packages into a Binary distribution. +: ${_DPL_PACKAGE_MAIN:=1} # Build main installation package. Linux only; OS X assumes this. +: ${_DPL_PACKAGE_ASSET} # Build asset installation package. Linux only. + +# Asset File Parameters +: ${ASSET_ARCHIVE_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-assets.7z} +: ${ASSET_BASE_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets} +: ${ASSET_FILES_REQUIRED:=srb2.srb zones.dta player.dta rings.dta patch.dta} +: ${ASSET_FILES_DOCS:=README.txt LICENSE.txt LICENSE-3RD-PARTY.txt} +: ${ASSET_FILES_OPTIONAL:=music.dta} +: ${ASSET_FILES_OPTIONAL_GET:=0} + +# FTP Parameters +: ${DPL_FTP_PROTOCOL} +: ${DPL_FTP_USER} +: ${DPL_FTP_PASS} +: ${DPL_FTP_HOSTNAME} +: ${DPL_FTP_PORT} +: ${DPL_FTP_PATH} + +# DPUT Parameters +: ${DPL_DPUT_DOMAIN:=ppa.launchpad.net} +: ${DPL_DPUT_METHOD:=sftp} +: ${DPL_DPUT_INCOMING} +: ${DPL_DPUT_LOGIN:=anonymous} +: ${DPL_SSH_KEY_PRIVATE} # Base64-encoded private key file. Used to sign repository uploads +: ${DPL_SSH_KEY_PASSPHRASE} # Decodes the private key file. + +# Package Parameters +: ${PACKAGE_NAME:=srb2} +: ${PACKAGE_VERSION:=2.1.23} +: ${PACKAGE_SUBVERSION} # Highly recommended to set this to reflect the distro series target (e.g., ~18.04bionic) +: ${PACKAGE_REVISION} # Defaults to UTC timestamp +: ${PACKAGE_INSTALL_PATH:=/usr/games/SRB2} +: ${PACKAGE_LINK_PATH:=/usr/games} +: ${PACKAGE_DISTRO:=trusty} +: ${PACKAGE_URGENCY:=high} +: ${PACKAGE_NAME_EMAIL:=Sonic Team Junior } +: ${PACKAGE_GROUP_NAME_EMAIL:=Sonic Team Junior } +: ${PACKAGE_WEBSITE:=} + +: ${PACKAGE_ASSET_MINVERSION:=2.1.21} # Number this the version BEFORE the actual required version, because we do a > check +: ${PACKAGE_ASSET_MAXVERSION:=2.1.24} # Number this the version AFTER the actual required version, because we do a < check + +: ${PROGRAM_NAME:=Sonic Robo Blast 2} +: ${PROGRAM_VENDOR:=Sonic Team Junior} +: ${PROGRAM_VERSION:=2.1.23} +: ${PROGRAM_DESCRIPTION:=A free 3D Sonic the Hedgehog fangame closely inspired by the original Sonic games on the Sega Genesis.} +: ${PROGRAM_FILENAME:=srb2} + +: ${DPL_PGP_KEY_PRIVATE} # Base64-encoded private key file. Used to sign Debian packages +: ${DPL_PGP_KEY_PASSPHRASE} # Decodes the private key file. + +# Export Asset and Package Parameters for envsubst templating + +export ASSET_ARCHIVE_PATH="${ASSET_ARCHIVE_PATH}" +export ASSET_BASE_PATH="${ASSET_BASE_PATH}" +export ASSET_FILES_REQUIRED="${ASSET_FILES_REQUIRED}" +export ASSET_FILES_DOCS="${ASSET_FILES_DOCS}" +export ASSET_FILES_OPTIONAL="${ASSET_FILES_OPTIONAL}" +export ASSET_FILES_OPTIONAL_GET="${ASSET_FILES_OPTIONAL_GET}" + +export PACKAGE_NAME="${PACKAGE_NAME}" +export PACKAGE_VERSION="${PACKAGE_VERSION}" +export PACKAGE_SUBVERSION="${PACKAGE_SUBVERSION}" # in case we have this +export PACKAGE_REVISION="${PACKAGE_REVISION}" +export PACKAGE_ASSET_MINVERSION="${PACKAGE_ASSET_MINVERSION}" +export PACKAGE_ASSET_MAXVERSION="${PACKAGE_ASSET_MAXVERSION}" +export PACKAGE_INSTALL_PATH="${PACKAGE_INSTALL_PATH}" +export PACKAGE_LINK_PATH="${PACKAGE_LINK_PATH}" +export PACKAGE_DISTRO="${PACKAGE_DISTRO}" +export PACKAGE_URGENCY="${PACKAGE_URGENCY}" +export PACKAGE_NAME_EMAIL="${PACKAGE_NAME_EMAIL}" +export PACKAGE_GROUP_NAME_EMAIL="${PACKAGE_GROUP_NAME_EMAIL}" +export PACKAGE_WEBSITE="${PACKAGE_WEBSITE}" + +export PROGRAM_NAME="${PROGRAM_NAME}" +export PROGRAM_VERSION="${PROGRAM_VERSION}" +export PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION}" +export PROGRAM_FILENAME="${PROGRAM_FILENAME}" + +# This file is called in debian_template.sh, so mark our completion so we don't run it again +__DEBIAN_PARAMETERS_INITIALIZED=1 diff --git a/deployer/travis/deployer_dput.sh b/deployer/travis/deployer_dput.sh new file mode 100644 index 000000000..863a928cd --- /dev/null +++ b/deployer/travis/deployer_dput.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +# Deployer for Travis-CI +# DPUT uploader (e.g., Launchpad PPA) +# + +if [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + # Install APT dependencies + # paramiko required for ssh + sudo apt-get install python-paramiko expect dput; # python-pip + #pip install paramiko; + + # Output the DPUT config + # Dput only works if you're using secure FTP, so that's what we default to. + cat > "./dput.cf" << EOM +[deployer] +fqdn = ${DPL_DPUT_DOMAIN} +method = ${DPL_DPUT_METHOD} +incoming = ${DPL_DPUT_INCOMING} +login = ${DPL_DPUT_LOGIN} +allow_unsigned_uploads = 0 +EOM + + # Output SSH config + # Don't let SSH prompt us for untrusted hosts + cat >> "./ssh_config" << EOM + +Host * + StrictHostKeyChecking no + UserKnownHostsFile=/dev/null + PubKeyAuthentication yes + IdentityFile ${PWD}/key.private + IdentitiesOnly yes +EOM + sudo sh -c "cat < ${PWD}/ssh_config >> /etc/ssh/ssh_config"; + + # Get the private key + echo "$DPL_SSH_KEY_PRIVATE" | base64 --decode > key.private; + chmod 700 ./key.private; + + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; + + # Enter passphrase if required + for n in ${PACKAGEFILENAMES}; do + for f in $n*.changes; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + + expect <(cat < "commit.txt"; + echo "Job ID $TRAVIS_JOB_ID" >> "commit.txt"; + echo "" >> "commit.txt"; + echo "Commit $TRAVIS_COMMIT" >> "commit.txt"; + echo "$TRAVIS_COMMIT_MESSAGE" >> "commit.txt"; + echo "" >> "commit.txt"; + + # Initialize FTP parameters + if [[ "$DPL_FTP_PORT" == "" ]]; then + DPL_FTP_PORT=21; + fi; + if [[ "$DPL_FTP_PROTOCOL" == "" ]]; then + DPL_FTP_PROTOCOL=ftp; + fi; + __DPL_FTP_LOCATION=$DPL_FTP_PROTOCOL://$DPL_FTP_HOSTNAME:$DPL_FTP_PORT/$DPL_FTP_PATH/$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/$TRAVIS_JOB_ID-$TRAVIS_JOB_NUMBER-$JOBNAME; + + # Upload to FTP! + echo "Uploading to FTP..."; + curl --ftp-create-dirs -T "commit.txt" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/commit.txt"; + + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/main/$f"; + done; + done; + + # Go back to [repo]/build folder + cd $OLDPWD; + fi; + + if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + ) + + # Asset packages are in root repo folder + OLDPWD=$PWD; # [repo]/build + cd ..; + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/asset/$f"; + done; + done; + + # Go back to [repo]/build folder + cd $OLDPWD; + fi; + else + if [[ "$_DPL_BINARY" == "1" ]]; then + find bin -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;; + fi; + + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then + sudo rm -r package/_CPack_Packages + find package -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;; + fi; + fi; +fi diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index f7b7c7ba4..ec5d63ac7 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -150,7 +150,7 @@ if(${SDL2_FOUND}) ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} ) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "Sonic Robo Blast 2") + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") else() target_link_libraries(SRB2SDL2 PRIVATE ${SDL2_LIBRARIES} @@ -334,10 +334,19 @@ if(${SDL2_FOUND}) # Mac bundle fixup + # HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This + # makes it so that var is evaluated LATER during cpack, not right now! + # This fixes the quirk where the bundled libraries don't land in the final package + # https://cmake.org/pipermail/cmake/2011-March/043532.html + # + # HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var + # is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at + # this current step points to the CMAKE build folder, NOT the folder that CPACK uses. + # Therefore, it makes sense to escape that var, but not the other. if(${CMAKE_SYSTEM} MATCHES Darwin) install(CODE " include(BundleUtilities) - fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\" + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\" \"\" /Library/Frameworks )" From 4d4b048eade5fc051100819b74dd714bb5054e5f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 31 Dec 2018 17:09:59 -0500 Subject: [PATCH 19/72] Don't download individual asset files; support only archives --- .travis.yml | 53 ++++++++-------------------- assets/CMakeLists.txt | 46 ++++++++---------------- assets/debian-template/rules | 52 ++++++++------------------- deployer/travis/deployer_defaults.sh | 10 +++--- 4 files changed, 47 insertions(+), 114 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d5774293..6e5c9fc0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -593,8 +593,10 @@ install: before_script: # OLDPWD is root repo folder - OLDPWD=$PWD + - mkdir -p "$OLDPWD/assets/installer" - cd "$HOME/srb2_cache" + # Get stat command so we know what the cached archive date is. # stat is different for OSX - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then STATCMD="stat -f %m"; @@ -608,52 +610,25 @@ before_script: echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))"; fi; wget --verbose --server-response -N "$ASSET_ARCHIVE_PATH"; - 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$HOME/srb2_cache" -aos; - for f in $ASSET_FILES_REQUIRED; do - cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; - done; + 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$OLDPWD/assets/installer" -aos; fi; - # Get individual required files - - for f in $ASSET_FILES_REQUIRED; do - if [ -f "$f" ]; then - echo "$f cache date -- $($STATCMD $f)"; - fi; - wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; - if [ ! -f "$HOME/srb2_cache/$f" ]; then - echo "Could not download \"$ASSET_BASE_PATH/$f\""; - return 1; - fi; - cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; - done; - - # Get the docs - - for f in $ASSET_FILES_DOCS; do - if [ -f "$f" ]; then - echo "$f cache date -- $($STATCMD $f)"; - fi; - wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; - cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; - done; - # Get optional files too - - if [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]]; then - for f in $ASSET_FILES_OPTIONAL; do - if [ -f "$f" ]; then - echo "$f cache date -- $($STATCMD $f)"; - fi; - wget --verbose --server-response -N "$ASSET_BASE_PATH/$f"; - cp "$HOME/srb2_cache/$f" "$OLDPWD/assets/$f"; - done; + - if [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]] && [[ "$ASSET_ARCHIVE_OPTIONAL_PATH" != "" ]]; then + if [ -f "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" ]; then + echo "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_OPTIONAL_PATH))"; + fi; + wget --verbose --server-response -N "$ASSET_ARCHIVE_OPTIONAL_PATH"; + 7z x "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" -o"$OLDPWD/assets/installer" -aos; fi; - # Go back to root repo folder + # Copy assets to repo staging folder, then go back to root repo folder - cd "$OLDPWD" # Prepare CMake asset lists - - SRB2_ASSET_REQUIRED=$(echo ${ASSET_FILES_REQUIRED// /\;}) - - SRB2_ASSET_OPTIONAL=$(echo ${ASSET_FILES_OPTIONAL// /\;}) + - SRB2_ASSET_HASHED=$(echo ${ASSET_FILES_HASHED// /\;}) - SRB2_ASSET_DOCS=$(echo ${ASSET_FILES_DOCS// /\;}) + - SRB2_ASSET_DIRECTORY="$OLDPWD/assets/installer" # Prepare CMake - mkdir build @@ -662,8 +637,8 @@ before_script: - export CFLAGS="-Wall -W -Werror $WFLAGS" - export CCACHE_COMPRESS=true - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package - -DSRB2_ASSET_REQUIRED="${SRB2_ASSET_REQUIRED}" -DSRB2_ASSET_OPTIONAL="${SRB2_ASSET_OPTIONAL}" - -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}" + -DSRB2_ASSET_HASHED="${SRB2_ASSET_HASHED}" -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}" + -DSRB2_ASSET_DIRECTORY="${SRB2_ASSET_DIRECTORY}" -DCPACK_PACKAGE_DESCRIPTION_SUMMARY="${PROGRAM_NAME}" -DCPACK_PACKAGE_VENDOR="${PROGRAM_VENDOR}" -DSRB2_SDL2_EXE_NAME="${PROGRAM_FILENAME}" diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 35e018d46..68ff0fdf9 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -9,38 +9,29 @@ FUNCTION(PREPEND var prefix) SET(${var} "${listVar}" PARENT_SCOPE) ENDFUNCTION(PREPEND) -set(SRB2_ASSET_REQUIRED +set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" + CACHE STRING "Path to directory that contains all asset files for the installer.") + +set(SRB2_ASSET_HASHED "srb2.srb;\ player.dta;\ rings.dta;\ zones.dta;\ patch.dta" - CACHE STRING "Required asset files for packaging. No spaces between entries!" + CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" ) set(SRB2_ASSET_DOCS "README.txt;\ LICENSE.txt;\ LICENSE-3RD-PARTY.txt" - CACHE STRING "Documentation files; will not fail if they do not exist. Packaged differently from optional assets. No spaces between entries!" + CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!" ) -set(SRB2_ASSET_OPTIONAL -"music.dta" - CACHE STRING "Optional asset files. No spaces between entries!" -) - -# MD5 generation - Filename only, we don't append path to this -set(SRB2_ASSET_HASHED - ${SRB2_ASSET_REQUIRED} -) - -PREPEND(SRB2_ASSET_REQUIRED ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_REQUIRED}) -PREPEND(SRB2_ASSET_DOCS ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_DOCS}) -PREPEND(SRB2_ASSET_OPTIONAL ${CMAKE_CURRENT_SOURCE_DIR} ${SRB2_ASSET_OPTIONAL}) +PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS}) foreach(SRB2_ASSET ${SRB2_ASSET_HASHED}) - file(MD5 ${CMAKE_CURRENT_SOURCE_DIR}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") + file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE) endforeach() @@ -48,27 +39,20 @@ endforeach() if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - install(FILES ${SRB2_ASSET_REQUIRED} + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" DESTINATION "${outname}.app/Contents/Resources" ) - install(FILES ${SRB2_ASSET_OPTIONAL} - DESTINATION "${outname}.app/Contents/Resources" - OPTIONAL - ) install(FILES ${SRB2_ASSET_DOCS} DESTINATION . OPTIONAL ) else() - install(FILES ${SRB2_ASSET_REQUIRED} + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" DESTINATION . ) - install(FILES ${SRB2_ASSET_OPTIONAL} - DESTINATION . - OPTIONAL - ) - install(FILES ${SRB2_ASSET_DOCS} - DESTINATION . - OPTIONAL - ) + # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again + #install(FILES ${SRB2_ASSET_DOCS} + # DESTINATION . + # OPTIONAL + #) endif() diff --git a/assets/debian-template/rules b/assets/debian-template/rules index 99a4eaf3c..c2d19922d 100644 --- a/assets/debian-template/rules +++ b/assets/debian-template/rules @@ -47,55 +47,31 @@ RM := rm -rf DIR := $(shell pwd) PACKAGE := $(shell cat $(DIR)/debian/control | grep 'Package:' | sed -e 's/Package: //g') -DATAFILES := ${ASSET_FILES_REQUIRED} -DOCFILES := ${ASSET_FILES_DOCS} -OPTIONALFILES := ${ASSET_FILES_OPTIONAL} +ARCHIVEPATH := ${ASSET_ARCHIVE_PATH} +ARCHIVEOPTIONALPATH := ${ASSET_ARCHIVE_OPTIONAL_PATH} GETOPTIONALFILES := ${ASSET_FILES_OPTIONAL_GET} DATADIR := $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///') RESOURCEDIR := . +STAGINGDIR := $(RESOURCEDIR)/installer WGET := wget -P $(RESOURCEDIR) -c -nc build: $(MKDIR) $(DIR)/debian/tmp/$(DATADIR) > $(DIR)/debian/source/include-binaries - # This will need to be updated every time SRB2 official version is # Copy data files to their install locations, and add data files to include-binaries - for file in $(DATAFILES); do \ - if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ + if [ ! -d $(STAGINGDIR) ]; then \ + mkdir -p "$(STAGINGDIR)"; \ + $(WGET) $(ARCHIVEPATH); \ + 7z x "$(RESOURCEDIR)/$(shell basename $(ARCHIVEPATH))" -aos; \ + if [ "$(GETOPTIONALFILES)" = "1" ]; then \ + $(WGET) $(ARCHIVEOPTIONALPATH); \ + 7z x "$(RESOURCEDIR)/$(shell basename $(ARCHIVEOPTIONALPATH))" -aos; \ fi; \ - if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ - echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ - fi; \ - if [ ! -f $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR} ]; then \ - echo $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR} not found and could not be downloaded!; \ - return 1; \ - fi; \ - done - # Do the same for DOCFILES, but don't error out if not found - for file in $(DOCFILES); do \ - if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ - fi; \ - if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ - echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ - fi; \ - done - # Do the same for OPTIONALFILES if GETOPTIONALFILES == 1 - if [ "$(GETOPTIONALFILES)" = "1" ]; then \ - for file in $(OPTIONALFILES); do \ - if [ ! -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(WGET) ${ASSET_BASE_PATH}/${DEBFILEVAR}; \ - fi; \ - if [ -f $(RESOURCEDIR)/${DEBFILEVAR} ]; then \ - $(INSTALL) $(RESOURCEDIR)/${DEBFILEVAR} $(DIR)/debian/tmp/$(DATADIR)/${DEBFILEVAR}; \ - echo $(RESOURCEDIR)/${DEBFILEVAR} >> $(DIR)/debian/source/include-binaries; \ - fi; \ - done; \ - fi; + fi + # Install asset directory and add asset file to include-binaries + cp -vr "$(STAGINGDIR)/." "$(DIR)/debian/tmp/$(DATADIR)" + find "$(STAGINGDIR)" >> $(DIR)/debian/source/include-binaries binary-indep: diff --git a/deployer/travis/deployer_defaults.sh b/deployer/travis/deployer_defaults.sh index 9716c31cb..bccb7409a 100644 --- a/deployer/travis/deployer_defaults.sh +++ b/deployer/travis/deployer_defaults.sh @@ -28,10 +28,9 @@ # Asset File Parameters : ${ASSET_ARCHIVE_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-assets.7z} -: ${ASSET_BASE_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets} -: ${ASSET_FILES_REQUIRED:=srb2.srb zones.dta player.dta rings.dta patch.dta} +: ${ASSET_ARCHIVE_OPTIONAL_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-optional-assets.7z} +: ${ASSET_FILES_HASHED:=srb2.srb zones.dta player.dta rings.dta patch.dta} : ${ASSET_FILES_DOCS:=README.txt LICENSE.txt LICENSE-3RD-PARTY.txt} -: ${ASSET_FILES_OPTIONAL:=music.dta} : ${ASSET_FILES_OPTIONAL_GET:=0} # FTP Parameters @@ -78,10 +77,9 @@ # Export Asset and Package Parameters for envsubst templating export ASSET_ARCHIVE_PATH="${ASSET_ARCHIVE_PATH}" -export ASSET_BASE_PATH="${ASSET_BASE_PATH}" -export ASSET_FILES_REQUIRED="${ASSET_FILES_REQUIRED}" +export ASSET_ARCHIVE_OPTIONAL_PATH="${ASSET_ARCHIVE_OPTIONAL_PATH}" +export ASSET_FILES_HASHED="${ASSET_FILES_HASHED}" export ASSET_FILES_DOCS="${ASSET_FILES_DOCS}" -export ASSET_FILES_OPTIONAL="${ASSET_FILES_OPTIONAL}" export ASSET_FILES_OPTIONAL_GET="${ASSET_FILES_OPTIONAL_GET}" export PACKAGE_NAME="${PACKAGE_NAME}" From 7916e020d2c21091209a23d3b37c262b39338d8c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 1 Jan 2019 10:47:16 -0500 Subject: [PATCH 20/72] 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 e765b9400cf741eb8aaa72768ef677769ee5c12b Mon Sep 17 00:00:00 2001 From: Jimita the Cat Date: Wed, 2 Jan 2019 00:41:52 -0300 Subject: [PATCH 21/72] Add support for flashpals in screenshots --- src/hardware/hw_draw.c | 9 +++-- src/hardware/hw_main.h | 5 +-- src/m_misc.c | 74 +++++++++++++++++++++++++----------------- src/m_misc.h | 2 +- src/st_stuff.c | 2 +- src/st_stuff.h | 1 + 6 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 55bbde459..bccb0ee82 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1082,21 +1082,24 @@ UINT8 *HWR_GetScreenshot(void) return buf; } -boolean HWR_Screenshot(const char *lbmname) +boolean HWR_Screenshot(const char *pathname, char **error) { boolean ret; UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf)); if (!buf) + { + *error = "Failed to allocate memory for HWR_Screenshot"; return false; + } // returns 24bit 888 RGB HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf); #ifdef USE_PNG - ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL); + ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL, &*error); // c_irl #else - ret = saveTGA(lbmname, buf, vid.width, vid.height); + ret = saveTGA(pathname, buf, vid.width, vid.height); #endif free(buf); return ret; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 59042cf3b..cf9f2232c 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -38,8 +38,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); -UINT8 *HWR_GetScreenshot(void); -boolean HWR_Screenshot(const char *lbmname); void HWR_InitTextureMapping(void); void HWR_SetViewSize(void); void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option); @@ -54,6 +52,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum); +UINT8 *HWR_GetScreenshot(void); +boolean HWR_Screenshot(const char *pathname, char **error); + void HWR_AddCommands(void); void HWR_CorrectSWTricks(void); void transform(float *cx, float *cy, float *cz); diff --git a/src/m_misc.c b/src/m_misc.c index 7dd0d822c..7b60caff1 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -30,6 +30,7 @@ #include "g_game.h" #include "m_misc.h" #include "hu_stuff.h" +#include "st_stuff.h" #include "v_video.h" #include "z_zone.h" #include "g_input.h" @@ -585,6 +586,21 @@ void M_SaveConfig(const char *filename) fclose(f); } +// ========================================================================== +// SCREENSHOTS +// ========================================================================== +static UINT8 screenshot_palette[768]; +static void M_CreateScreenShotPalette(void) +{ + size_t i, j; + for (i = 0, j = 0; i < 768; i += 3, j++) + { + RGBA_t locpal = pLocalPalette[(max(st_palette,0)*256)+j]; + screenshot_palette[i] = locpal.s.red; + screenshot_palette[i+1] = locpal.s.green; + screenshot_palette[i+2] = locpal.s.blue; + } +} #if NUMSCREENS > 2 static const char *Newsnapshotfile(const char *pathname, const char *ext) @@ -1047,6 +1063,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) static inline moviemode_t M_StartMovieAPNG(const char *pathname) { #ifdef USE_APNG + UINT8 *palette; const char *freename = NULL; boolean ret = false; @@ -1062,10 +1079,8 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname) return MM_OFF; } - if (rendermode == render_soft) - ret = M_SetupaPNG(va(pandf,pathname,freename), W_CacheLumpName(GetPalette(), PU_CACHE)); - else - ret = M_SetupaPNG(va(pandf,pathname,freename), NULL); + if (rendermode == render_soft) M_CreateScreenShotPalette(); + ret = M_SetupaPNG(va(pandf,pathname,freename), (palette = screenshot_palette)); if (!ret) { @@ -1268,10 +1283,11 @@ void M_StopMovie(void) * \param data The image data. * \param width Width of the picture. * \param height Height of the picture. - * \param palette Palette of image data + * \param palette Palette of image data. * \note if palette is NULL, BGR888 format + * \param error Error string to return, if screenshot failed. */ -boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette) +boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error) { png_structp png_ptr; png_infop png_info_ptr; @@ -1286,15 +1302,14 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_FILE = fopen(filename,"wb"); if (!png_FILE) { - CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for write\n", filename); + *error = "Failed to open file for write"; return false; } - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, - PNG_error, PNG_warn); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn); if (!png_ptr) { - CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n"); + *error = "Failed to initialize libpng"; fclose(png_FILE); remove(filename); return false; @@ -1303,7 +1318,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_info_ptr = png_create_info_struct(png_ptr); if (!png_info_ptr) { - CONS_Debug(DBG_RENDER, "M_SavePNG: Error on allocate for libpng\n"); + *error = "Failed to allocate memory for libpng"; png_destroy_write_struct(&png_ptr, NULL); fclose(png_FILE); remove(filename); @@ -1316,7 +1331,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const if (setjmp(png_jmpbuf(png_ptr))) #endif { - //CONS_Debug(DBG_RENDER, "libpng write error on %s\n", filename); + *error = "libpng write error"; png_destroy_write_struct(&png_ptr, &png_info_ptr); fclose(png_FILE); remove(filename); @@ -1445,9 +1460,8 @@ void M_ScreenShot(void) } /** Takes a screenshot. - * The screenshot is saved as "srb2xxxx.pcx" (or "srb2xxxx.tga" in hardware - * rendermode) where xxxx is the lowest four-digit number for which a file - * does not already exist. + * The screenshot is saved as "srb2xxxx.png" where xxxx is the lowest + * four-digit number for which a file does not already exist. * * \sa HWR_ScreenShot */ @@ -1456,11 +1470,16 @@ void M_DoScreenShot(void) #if NUMSCREENS > 2 const char *freename = NULL, *pathname = "."; boolean ret = false; + char *error = "Unknown error"; UINT8 *linear = NULL; // Don't take multiple screenshots, obviously takescreenshot = false; + // how does one take a screenshot without a render system? + if (rendermode == render_none) + return; + if (cv_screenshot_option.value == 0) pathname = usehome ? srb2home : srb2path; else if (cv_screenshot_option.value == 1) @@ -1471,16 +1490,13 @@ void M_DoScreenShot(void) pathname = cv_screenshot_folder.string; #ifdef USE_PNG - if (rendermode != render_none) - freename = Newsnapshotfile(pathname,"png"); + freename = Newsnapshotfile(pathname,"png"); #else if (rendermode == render_soft) freename = Newsnapshotfile(pathname,"pcx"); - else if (rendermode != render_none) + else if (rendermode == render_opengl) freename = Newsnapshotfile(pathname,"tga"); #endif - else - I_Error("Can't take a screenshot without a render system"); if (rendermode == render_soft) { @@ -1494,18 +1510,16 @@ void M_DoScreenShot(void) // save the pcx file #ifdef HWRENDER - if (rendermode != render_soft) - ret = HWR_Screenshot(va(pandf,pathname,freename)); + if (rendermode == render_opengl) + ret = HWR_Screenshot(va(pandf,pathname,freename), &error); else #endif - if (rendermode != render_none) { + M_CreateScreenShotPalette(); #ifdef USE_PNG - ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, - W_CacheLumpName(GetPalette(), PU_CACHE)); + ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette, &error); #else - ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, - W_CacheLumpName(GetPalette(), PU_CACHE)); + ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette); #endif } @@ -1513,14 +1527,14 @@ failure: if (ret) { if (moviemode != MM_SCREENSHOT) - CONS_Printf(M_GetText("screen shot %s saved in %s\n"), freename, pathname); + CONS_Printf(M_GetText("Screen shot %s saved in %s\n"), freename, pathname); } else { if (freename) - CONS_Printf(M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s (%s)\n"), freename, pathname, error); else - CONS_Printf(M_GetText("Couldn't create screen shot (all 10000 slots used!) in %s\n"), pathname); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname); if (moviemode == MM_SCREENSHOT) M_StopMovie(); diff --git a/src/m_misc.h b/src/m_misc.h index 7dd8baabf..cb4af3927 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -64,7 +64,7 @@ void FIL_ForceExtension(char *path, const char *extension); boolean FIL_CheckExtension(const char *in); #ifdef HAVE_PNG -boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette); +boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error); #endif extern boolean takescreenshot; diff --git a/src/st_stuff.c b/src/st_stuff.c index 1f8dbbf61..287aea134 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -197,7 +197,7 @@ void ST_Ticker(void) } // 0 is default, any others are special palettes. -static INT32 st_palette = 0; +INT32 st_palette = 0; void ST_doPaletteStuff(void) { diff --git a/src/st_stuff.h b/src/st_stuff.h index 6c4140ce3..6f05bbf3e 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -58,6 +58,7 @@ boolean ST_SameTeam(player_t *a, player_t *b); //-------------------- extern boolean st_overlay; // sb overlay on or off when fullscreen +extern INT32 st_palette; // 0 is default, any others are special palettes. extern lumpnum_t st_borderpatchnum; // patches, also used in intermission From 892e65071281e1aa2bd6158748120cf4b7cd81c2 Mon Sep 17 00:00:00 2001 From: Jimita the Cat Date: Wed, 2 Jan 2019 01:01:57 -0300 Subject: [PATCH 22/72] dumb --- src/hardware/hw_draw.c | 6 +++--- src/hardware/hw_main.h | 2 +- src/m_misc.c | 18 ++++++++---------- src/m_misc.h | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index bccb0ee82..cd2c95237 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -1082,14 +1082,14 @@ UINT8 *HWR_GetScreenshot(void) return buf; } -boolean HWR_Screenshot(const char *pathname, char **error) +boolean HWR_Screenshot(const char *pathname) { boolean ret; UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf)); if (!buf) { - *error = "Failed to allocate memory for HWR_Screenshot"; + CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n"); return false; } @@ -1097,7 +1097,7 @@ boolean HWR_Screenshot(const char *pathname, char **error) HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf); #ifdef USE_PNG - ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL, &*error); // c_irl + ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL); #else ret = saveTGA(pathname, buf, vid.width, vid.height); #endif diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index cf9f2232c..929544ec1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -53,7 +53,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum); UINT8 *HWR_GetScreenshot(void); -boolean HWR_Screenshot(const char *pathname, char **error); +boolean HWR_Screenshot(const char *pathname); void HWR_AddCommands(void); void HWR_CorrectSWTricks(void); diff --git a/src/m_misc.c b/src/m_misc.c index 7b60caff1..88ae3b86a 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1285,9 +1285,8 @@ void M_StopMovie(void) * \param height Height of the picture. * \param palette Palette of image data. * \note if palette is NULL, BGR888 format - * \param error Error string to return, if screenshot failed. */ -boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error) +boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette) { png_structp png_ptr; png_infop png_info_ptr; @@ -1302,14 +1301,14 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_FILE = fopen(filename,"wb"); if (!png_FILE) { - *error = "Failed to open file for write"; + CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for write\n", filename); return false; } png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn); if (!png_ptr) { - *error = "Failed to initialize libpng"; + CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n"); fclose(png_FILE); remove(filename); return false; @@ -1318,7 +1317,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const png_info_ptr = png_create_info_struct(png_ptr); if (!png_info_ptr) { - *error = "Failed to allocate memory for libpng"; + CONS_Debug(DBG_RENDER, "M_SavePNG: Error on allocate for libpng\n"); png_destroy_write_struct(&png_ptr, NULL); fclose(png_FILE); remove(filename); @@ -1331,7 +1330,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const if (setjmp(png_jmpbuf(png_ptr))) #endif { - *error = "libpng write error"; + //CONS_Debug(DBG_RENDER, "libpng write error on %s\n", filename); png_destroy_write_struct(&png_ptr, &png_info_ptr); fclose(png_FILE); remove(filename); @@ -1470,7 +1469,6 @@ void M_DoScreenShot(void) #if NUMSCREENS > 2 const char *freename = NULL, *pathname = "."; boolean ret = false; - char *error = "Unknown error"; UINT8 *linear = NULL; // Don't take multiple screenshots, obviously @@ -1511,13 +1509,13 @@ void M_DoScreenShot(void) // save the pcx file #ifdef HWRENDER if (rendermode == render_opengl) - ret = HWR_Screenshot(va(pandf,pathname,freename), &error); + ret = HWR_Screenshot(va(pandf,pathname,freename)); else #endif { M_CreateScreenShotPalette(); #ifdef USE_PNG - ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette, &error); + ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette); #else ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette); #endif @@ -1532,7 +1530,7 @@ failure: else { if (freename) - CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s (%s)\n"), freename, pathname, error); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname); else CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname); diff --git a/src/m_misc.h b/src/m_misc.h index cb4af3927..7dd8baabf 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -64,7 +64,7 @@ void FIL_ForceExtension(char *path, const char *extension); boolean FIL_CheckExtension(const char *in); #ifdef HAVE_PNG -boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error); +boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette); #endif extern boolean takescreenshot; From e2e345988aa2567abb9ff6de11ad0e2b7f946278 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 04:58:03 -0500 Subject: [PATCH 23/72] 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 24/72] 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 25/72] 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 26/72] 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 9b3174c4f43dc5ddb8969ba8ff11174545b8454b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 18:19:44 -0500 Subject: [PATCH 27/72] Correct asset directory for travis --- .travis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e5c9fc0d..d0bc064fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -593,7 +593,8 @@ install: before_script: # OLDPWD is root repo folder - OLDPWD=$PWD - - mkdir -p "$OLDPWD/assets/installer" + - __ASSET_DIRECTORY="$OLDPWD/assets/installer" + - mkdir -p "$__ASSET_DIRECTORY" - cd "$HOME/srb2_cache" # Get stat command so we know what the cached archive date is. @@ -610,7 +611,7 @@ before_script: echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))"; fi; wget --verbose --server-response -N "$ASSET_ARCHIVE_PATH"; - 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$OLDPWD/assets/installer" -aos; + 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$__ASSET_DIRECTORY" -aos; fi; # Get optional files too @@ -619,16 +620,16 @@ before_script: echo "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_OPTIONAL_PATH))"; fi; wget --verbose --server-response -N "$ASSET_ARCHIVE_OPTIONAL_PATH"; - 7z x "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" -o"$OLDPWD/assets/installer" -aos; + 7z x "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" -o"$__ASSET_DIRECTORY" -aos; fi; - # Copy assets to repo staging folder, then go back to root repo folder + # Go back to root repo folder - cd "$OLDPWD" # Prepare CMake asset lists - SRB2_ASSET_HASHED=$(echo ${ASSET_FILES_HASHED// /\;}) - SRB2_ASSET_DOCS=$(echo ${ASSET_FILES_DOCS// /\;}) - - SRB2_ASSET_DIRECTORY="$OLDPWD/assets/installer" + - SRB2_ASSET_DIRECTORY="$__ASSET_DIRECTORY" # Prepare CMake - mkdir build From ac7b29eb2db79bb2d0ab762e5123c75bf4ca0499 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 2 Jan 2019 20:48:00 -0500 Subject: [PATCH 28/72] Add __DPL_ACTIVE condition to optional asset download --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d0bc064fe..b87650f6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -615,7 +615,7 @@ before_script: fi; # Get optional files too - - if [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]] && [[ "$ASSET_ARCHIVE_OPTIONAL_PATH" != "" ]]; then + - if [[ "$__DPL_ACTIVE" == "1" ]] && [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]] && [[ "$ASSET_ARCHIVE_OPTIONAL_PATH" != "" ]]; then if [ -f "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" ]; then echo "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_OPTIONAL_PATH))"; fi; From 88c4a54cea71097e918593907477e2353c7efaaf Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 4 Jan 2019 20:25:41 -0500 Subject: [PATCH 29/72] Add GME to VC10 SRB2SDL project --- libs/libgme.props | 16 ++++++++++++++++ src/sdl/Srb2SDL-vc10.vcxproj | 1 + src/sdl/Srb2SDL.props | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 libs/libgme.props diff --git a/libs/libgme.props b/libs/libgme.props new file mode 100644 index 000000000..d530eac75 --- /dev/null +++ b/libs/libgme.props @@ -0,0 +1,16 @@ + + + + + + $(SolutionDir)libs\gme\include;$(IncludePath) + $(SolutionDir)libs\gme\win32;$(LibraryPath) + $(SolutionDir)libs\gme\win64;$(LibraryPath) + + + + libgme.dll.a;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 04af6a8e1..3b764996d 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -93,6 +93,7 @@ + diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props index 260f81eed..cba6d1642 100644 --- a/src/sdl/Srb2SDL.props +++ b/src/sdl/Srb2SDL.props @@ -5,7 +5,7 @@ - USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_LIBGME;HAVE_ZLIB;SDLMAIN;%(PreprocessorDefinitions) From 09ed8bd04621ec3e93fdaf9968676b0b01665120 Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 4 Jan 2019 20:38:03 -0500 Subject: [PATCH 30/72] Add LibGME to DD vc10 project --- src/win32/Srb2win-vc10.vcxproj | 1 + src/win32/Srb2win.props | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj index ca73b1293..f74cf3c16 100644 --- a/src/win32/Srb2win-vc10.vcxproj +++ b/src/win32/Srb2win-vc10.vcxproj @@ -91,6 +91,7 @@ + diff --git a/src/win32/Srb2win.props b/src/win32/Srb2win.props index 44a30d50d..ea12ffb28 100644 --- a/src/win32/Srb2win.props +++ b/src/win32/Srb2win.props @@ -5,7 +5,7 @@ - _WINDOWS;%(PreprocessorDefinitions) + _WINDOWS;HAVE_LIBGME;HAVE_ZLIB;%(PreprocessorDefinitions) From 882355d24b4b1c570480395043ac311fda77a848 Mon Sep 17 00:00:00 2001 From: Marco Z Date: Fri, 4 Jan 2019 21:18:55 -0500 Subject: [PATCH 31/72] Specify HAVE_LIBGME, paths, and depends only for Win32/x64 MSVC --- libs/libgme.props | 4 ++-- src/sdl/Srb2SDL.props | 5 ++++- src/win32/Srb2win.props | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/libgme.props b/libs/libgme.props index d530eac75..209f6b9a8 100644 --- a/libs/libgme.props +++ b/libs/libgme.props @@ -2,12 +2,12 @@ - + $(SolutionDir)libs\gme\include;$(IncludePath) $(SolutionDir)libs\gme\win32;$(LibraryPath) $(SolutionDir)libs\gme\win64;$(LibraryPath) - + libgme.dll.a;%(AdditionalDependencies) diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props index cba6d1642..75839a5b2 100644 --- a/src/sdl/Srb2SDL.props +++ b/src/sdl/Srb2SDL.props @@ -5,7 +5,10 @@ - USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_LIBGME;HAVE_ZLIB;SDLMAIN;%(PreprocessorDefinitions) + + HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + + USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) diff --git a/src/win32/Srb2win.props b/src/win32/Srb2win.props index ea12ffb28..fa152f0c9 100644 --- a/src/win32/Srb2win.props +++ b/src/win32/Srb2win.props @@ -5,7 +5,10 @@ - _WINDOWS;HAVE_LIBGME;HAVE_ZLIB;%(PreprocessorDefinitions) + + HAVE_ZLIB;HAVE_LIBGME;_WINDOWS;%(PreprocessorDefinitions) + + _WINDOWS;%(PreprocessorDefinitions) From abaa8730a5272a868c871ffb42f395866ae0c1b9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 09:54:45 -0500 Subject: [PATCH 32/72] Revised comments --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b87650f6a..1f80e3dfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -564,16 +564,20 @@ addons: before_install: # Initialize Deployer defaults - . ./deployer/travis/deployer_defaults.sh + # Initialize Deployer; check if Deployer is enabled # This needs to be run in the current shell so that $__DPL_ACTIVE is set for this session - . ./deployer/travis/deployer.sh - # Also check if we should now terminate + + # Also check if we should now terminate -- see `deployer.sh` for conditions. + # This should never happen on non-release buildbots when Deployer is not triggered. - if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]]; then if [[ "$__DPL_ACTIVE" != "1" ]]; then echo "Exiting early because this job is not deploying."; exit; fi; fi + # If we're triggered by release tag, force ASSET_FILES_OPTIONAL_GET=1 - if [[ "$__DPL_TAG_ELIGIBLE" = "1" ]]; then ASSET_FILES_OPTIONAL_GET=1; @@ -606,6 +610,7 @@ before_script: fi # Get asset files (required for MD5) + # See `deployer_defaults.sh` for asset download path - if [[ "$ASSET_ARCHIVE_PATH" != "" ]]; then if [ -f "$(basename $ASSET_ARCHIVE_PATH)" ]; then echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))"; @@ -655,5 +660,8 @@ script: after_success: # Run the Deployer scripts + - if [[ "$__DPL_ACTIVE" != "1" ]]; then + exit; + fi; - . ../deployer/travis/deployer_ftp.sh - . ../deployer/travis/deployer_dput.sh From 97f8448b72bd0563ed57f9c93c4fd96a96346072 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 10:17:33 -0500 Subject: [PATCH 33/72] Don't terminate in after_success because it halts the log abruptly --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f80e3dfc..3068b89bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -659,9 +659,7 @@ script: fi; after_success: - # Run the Deployer scripts - - if [[ "$__DPL_ACTIVE" != "1" ]]; then - exit; - fi; + # Run the upload scripts + # These do nothing if Deployer is not triggered - . ../deployer/travis/deployer_ftp.sh - . ../deployer/travis/deployer_dput.sh From 0834dbc194770ef4897558974a953239789ae704 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 19:20:58 -0500 Subject: [PATCH 34/72] * Add homebrew tap mazmazz/srb2 * Use sdl2_mixer from mazmazz/srb2 due to removed options from homebrew-core * Use `brew install --build-bottle` to build compatible libraries for old Macs --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3068b89bd..18e706476 100644 --- a/.travis.yml +++ b/.travis.yml @@ -585,10 +585,18 @@ before_install: install: + # Install OS X library dependencies via Homebrew + # `brew install --build-bottle` builds libraries for x86_64's lowest common denominator CPU, core2 + # `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2 + # `brew postinstall` runs post-install scripts after building a bottle - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; - brew install sdl2 game-music-emu zlib p7zip; - brew install sdl2_mixer --with-flac --with-mpg123; + brew tap mazmazz/srb2; + fi; + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew install --build-bottle sdl2 game-music-emu zlib p7zip; + brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; + brew postinstall sdl2 game-music-emu zlib p7zip mazmazz/srb2/sdl2_mixer; brew install cmake||true; fi - mkdir -p $HOME/srb2_cache From 9ef7d2e6ba46eb4fa9d015c3a998789c221de045 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 19:27:34 -0500 Subject: [PATCH 35/72] OS X set CFLAGS+="-march=core2" for compatible binaries with old Macs --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 18e706476..1103c4e89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -583,6 +583,9 @@ before_install: ASSET_FILES_OPTIONAL_GET=1; fi; + # Print version info + - gcc --version; + install: # Install OS X library dependencies via Homebrew @@ -650,6 +653,10 @@ before_script: - mkdir package - export CFLAGS="-Wall -W -Werror $WFLAGS" - export CCACHE_COMPRESS=true + # If OS X, set -march=core2 to build compatible binaries with old Macs + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export CFLAGS="${CFLAGS} -march=core2"; + fi; - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package -DSRB2_ASSET_HASHED="${SRB2_ASSET_HASHED}" -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}" -DSRB2_ASSET_DIRECTORY="${SRB2_ASSET_DIRECTORY}" From 17cde328c123edc45dd710e7a4cbb730e4ec2138 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 19:43:37 -0500 Subject: [PATCH 36/72] Use standard OSX brew bottles to speed up test buildbots --- .travis.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1103c4e89..301991ddf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -589,18 +589,24 @@ before_install: install: # Install OS X library dependencies via Homebrew - # `brew install --build-bottle` builds libraries for x86_64's lowest common denominator CPU, core2 - # `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2 - # `brew postinstall` runs post-install scripts after building a bottle + # Do this differently for release buildbots: + # * `brew install --build-bottle` builds libraries for x86_64's lowest common denominator CPU, core2 + # * `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2 + # * `brew postinstall` runs post-install scripts after building a bottle - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew tap mazmazz/srb2; fi; - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew install --build-bottle sdl2 game-music-emu zlib p7zip; - brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; - brew postinstall sdl2 game-music-emu zlib p7zip mazmazz/srb2/sdl2_mixer; - brew install cmake||true; + if [[ "$__DPL_ACTIVE" != "1" ]]; then + brew install sdl2 sdl2_mixer game-music-emu p7zip; + brew install cmake||true; + else + brew install --build-bottle sdl2 game-music-emu zlib p7zip; + brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; + brew postinstall sdl2 game-music-emu zlib p7zip mazmazz/srb2/sdl2_mixer; + brew install cmake||true; + fi; fi - mkdir -p $HOME/srb2_cache From 20879f1f40418ce05aed27bd7251da72285661e1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 19:49:25 -0500 Subject: [PATCH 37/72] Remove zlib from release brew packages (it was never in the original travis script) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 301991ddf..19a6d7a80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -602,9 +602,9 @@ install: brew install sdl2 sdl2_mixer game-music-emu p7zip; brew install cmake||true; else - brew install --build-bottle sdl2 game-music-emu zlib p7zip; + brew install --build-bottle sdl2 game-music-emu p7zip; brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; - brew postinstall sdl2 game-music-emu zlib p7zip mazmazz/srb2/sdl2_mixer; + brew postinstall sdl2 game-music-emu p7zip mazmazz/srb2/sdl2_mixer; brew install cmake||true; fi; fi From 2592f42a17325520c32882bf7b0d429f76aea3c1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 5 Jan 2019 19:56:27 -0500 Subject: [PATCH 38/72] Remove unnecessary version info call --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 19a6d7a80..e9c8d0d71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -583,9 +583,6 @@ before_install: ASSET_FILES_OPTIONAL_GET=1; fi; - # Print version info - - gcc --version; - install: # Install OS X library dependencies via Homebrew From 1c1331199d98a8de6cd0a6a3cb12114ce3723c4c Mon Sep 17 00:00:00 2001 From: Digiku Date: Mon, 7 Jan 2019 03:41:25 -0500 Subject: [PATCH 39/72] Update f_finale.c - Remove Torgo's real name by request --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index 64e371211..b177212c1 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1055,12 +1055,12 @@ static const char *credits[] = { "Dan \"Blitzzo\" Hagerstrand", "Kepa \"Nev3r\" Iceta", "Thomas \"Shadow Hog\" Igoe", - "Erik \"Torgo\" Nielsen", "\"Kaito Sinclaire\"", "Wessel \"sphere\" Smit", "\"Spazzo\"", "\"SSNTails\"", "Rob Tisdell", + "\"Torgo\"", "Jarrett \"JEV3\" Voight", "Johnny \"Sonikku\" Wallbank", "Marco \"mazmazz\" Zafra", From 4f0be1b064dfe14373b51e92b0dcf4cce243f21c Mon Sep 17 00:00:00 2001 From: Digiku Date: Mon, 7 Jan 2019 16:50:59 -0500 Subject: [PATCH 40/72] Update f_finale.c - Small credits update --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index b177212c1..7708642e8 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -996,6 +996,7 @@ static const char *credits[] = { "Andrew \"orospakr\" Clunis", "Gregor \"Oogaland\" Dick", "Louis-Antoine \"LJSonic\" de Moulins", // for fixing 2.1's netcode (de Rochefort doesn't quite fit on the screen sorry lol) + "Victor \"Steel Titanium\" Fuentes", "Julio \"Chaos Zero 64\" Guir", "\"Jimita\"", "\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog @@ -1006,7 +1007,6 @@ static const char *credits[] = { "Colin \"Sonict\" Pfaff", "Sean \"Sryder13\" Ryder", "Tasos \"tatokis\" Sahanidis", // Corrected C FixedMul, making 64-bit builds netplay compatible - "\"Steel Titanium\"", "Ben \"Cue\" Woodford", // Git contributors with 5+ approved merges of substantive quality, // or contributors with at least one groundbreaking merge, may be named. From fad341b0e9c3a315e870a62478f7b01128f804ee Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Tue, 15 Jan 2019 14:29:43 -0500 Subject: [PATCH 41/72] Fix skins overflow --- src/r_things.c | 4 ++-- src/r_things.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 67a45a76e..0382596f1 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2306,7 +2306,7 @@ void R_DrawMasked(void) // ========================================================================== INT32 numskins = 0; -skin_t skins[MAXSKINS+1]; +skin_t skins[MAXSKINS]; // FIXTHIS: don't work because it must be inistilised before the config load //#define SKINVALUES #ifdef SKINVALUES @@ -2559,7 +2559,7 @@ void R_AddSkins(UINT16 wadnum) // advance by default lastlump = lump + 1; - if (numskins > MAXSKINS) + if (numskins >= MAXSKINS) { CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); continue; // so we know how many skins couldn't be added diff --git a/src/r_things.h b/src/r_things.h index 6614e0aa4..2823c3894 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -180,7 +180,7 @@ typedef struct drawnode_s } drawnode_t; extern INT32 numskins; -extern skin_t skins[MAXSKINS + 1]; +extern skin_t skins[MAXSKINS]; void SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 From 0d1c5016641a3b18f9e05213c382fc6f1412afe7 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 15 Jan 2019 20:09:55 -0500 Subject: [PATCH 42/72] Update the SP menu stuff to use MAXSKINS Co-authoered-by: Steel Titanium (steeltitanium1@gmail.com> --- src/dehacked.c | 5 ++- src/m_menu.c | 119 ++++++++++++++++++++----------------------------- src/m_menu.h | 4 +- 3 files changed, 54 insertions(+), 74 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index a726ecbc1..5161bf242 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -435,11 +435,12 @@ static void readAnimTex(MYFILE *f, INT32 num) static boolean findFreeSlot(INT32 *num) { // Send the character select entry to a free slot. - while (*num < 32 && PlayerMenu[*num].status != IT_DISABLED) + while (*num < MAXSKINS && PlayerMenu[*num].status != IT_DISABLED) *num = *num+1; + CONS_Printf("%d\n", *num); // No more free slots. :( - if (*num >= 32) + if (*num >= MAXSKINS) return false; // Found one! ^_^ diff --git a/src/m_menu.c b/src/m_menu.c index 266bc2516..c27689506 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -112,41 +112,8 @@ typedef enum const char *quitmsg[NUM_QUITMESSAGES]; // Stuff for customizing the player select screen Tails 09-22-2003 -description_t description[32] = -{ - {"\x82Sonic\x80 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.\n\n\x82""Ability:\x80 Speed Thok\nDouble jump to zoom forward with a huge burst of speed.\n\n\x82Tip:\x80 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction.", "", "sonic"}, - {"\x82Tails\x80 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well-\nsuited to beginners.\n\n\x82""Ability:\x80 Fly\nDouble jump to start flying for a limited time. Repetitively hit the jump button to ascend.\n\n\x82Tip:\x80 To quickly descend while flying, hit the spin button.", "", "tails"}, - {"\x82Knuckles\x80 is well-\nrounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.\n\n\x82""Ability:\x80 Glide & Climb\nDouble jump to glide in the air as long as jump is held. Glide into a wall to climb it.\n\n\x82Tip:\x80 Press spin while climbing to jump off the wall; press jump instead to jump off\nand face away from\nthe wall.", "", "knuckles"}, - {"\x82Sonic & Tails\x80 team up to take on Dr. Eggman!\nControl Sonic while Tails desperately struggles to keep up.\n\nPlayer 2 can control Tails directly by setting the controls in the options menu.\nTails's directional controls are relative to Player 1's camera.\n\nTails can pick up Sonic while flying and carry him around.", "CHRS&T", "sonic&tails"}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""} -}; +description_t description[MAXSKINS]; + static char *char_notes = NULL; static fixed_t char_scroll = 0; @@ -842,41 +809,7 @@ static menuitem_t SP_LevelStatsMenu[] = // A rare case. // External files modify this menu, so we can't call it static. // And I'm too lazy to go through and rename it everywhere. ARRGH! -menuitem_t PlayerMenu[32] = -{ - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0} -}; +menuitem_t PlayerMenu[MAXSKINS]; // ----------------------------------- // Multiplayer and all of its submenus @@ -2809,6 +2742,8 @@ void M_Ticker(void) // void M_Init(void) { + UINT8 i; + CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); @@ -2850,6 +2785,50 @@ void M_Init(void) quitmsg[QUIT3MSG5] = M_GetText("You'll be back to play soon, though...\n......right?\n\n(Press 'Y' to quit)"); quitmsg[QUIT3MSG6] = M_GetText("Aww, is Egg Rock Zone too\ndifficult for you?\n\n(Press 'Y' to quit)"); + // Setup PlayerMenu table + for (i = 0; i < MAXSKINS; i++) + { + PlayerMenu[i].status = (i < 4 ? IT_CALL : IT_DISABLED); + PlayerMenu[i].patch = PlayerMenu[i].text = NULL; + PlayerMenu[i].itemaction = M_ChoosePlayer; + PlayerMenu[i].alphaKey = 0; + } + + // Setup description table + for (i = 0; i < MAXSKINS; i++) + { + if (i == 0) + { + strcpy(description[i].notes, "\x82Sonic\x80 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.\n\n\x82""Ability:\x80 Speed Thok\nDouble jump to zoom forward with a huge burst of speed.\n\n\x82Tip:\x80 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction."); + strcpy(description[i].picname, ""); + strcpy(description[i].skinname, "sonic"); + } + else if (i == 1) + { + strcpy(description[i].notes, "\x82Tails\x80 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well-\nsuited to beginners.\n\n\x82""Ability:\x80 Fly\nDouble jump to start flying for a limited time. Repetitively hit the jump button to ascend.\n\n\x82Tip:\x80 To quickly descend while flying, hit the spin button."); + strcpy(description[i].picname, ""); + strcpy(description[i].skinname, "tails"); + } + else if (i == 2) + { + strcpy(description[i].notes, "\x82Knuckles\x80 is well-\nrounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.\n\n\x82""Ability:\x80 Glide & Climb\nDouble jump to glide in the air as long as jump is held. Glide into a wall to climb it.\n\n\x82Tip:\x80 Press spin while climbing to jump off the wall; press jump instead to jump off\nand face away from\nthe wall."); + strcpy(description[i].picname, ""); + strcpy(description[i].skinname, "knuckles"); + } + else if (i == 3) + { + strcpy(description[i].notes, "\x82Sonic & Tails\x80 team up to take on Dr. Eggman!\nControl Sonic while Tails desperately struggles to keep up.\n\nPlayer 2 can control Tails directly by setting the controls in the options menu.\nTails's directional controls are relative to Player 1's camera.\n\nTails can pick up Sonic while flying and carry him around."); + strcpy(description[i].picname, "CHRS&T"); + strcpy(description[i].skinname, "sonic&tails"); + } + else + { + strcpy(description[i].notes, "???"); + strcpy(description[i].picname, ""); + strcpy(description[i].skinname, ""); + } + } + #ifdef HWRENDER // Permanently hide some options based on render mode if (rendermode == render_soft) diff --git a/src/m_menu.h b/src/m_menu.h index eb770c194..7e2cce20d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -151,7 +151,7 @@ typedef struct menuitem_s UINT8 alphaKey; } menuitem_t; -extern menuitem_t PlayerMenu[32]; +extern menuitem_t PlayerMenu[MAXSKINS]; typedef struct menu_s { @@ -206,7 +206,7 @@ typedef struct UINT8 netgame; } saveinfo_t; -extern description_t description[32]; +extern description_t description[MAXSKINS]; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; extern CV_PossibleValue_t gametype_cons_t[]; From bce093fd06b8b8441d897553ae1058a7df5e4cf2 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 26 Jan 2019 23:16:49 -0500 Subject: [PATCH 43/72] Setup the tables even eariler. I really hate that PlayerMenu status hack, but that's really the only way I could think off to show the entires for Tails, Knuckles and the Sonic&Tails pair. --- src/d_main.c | 4 ++++ src/m_menu.c | 33 ++++++++++++++++++--------------- src/m_menu.h | 3 +++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index dd2cfe0e5..1782e94f5 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1130,6 +1130,10 @@ void D_SRB2Main(void) // Setup default unlockable conditions M_SetupDefaultConditionSets(); + // Setup character tables + // Have to be done here before files are loaded + M_InitCharacterTables(); + // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); if (!W_InitMultipleFiles(startupwadfiles)) diff --git a/src/m_menu.c b/src/m_menu.c index c27689506..333cdaa70 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2742,8 +2742,6 @@ void M_Ticker(void) // void M_Init(void) { - UINT8 i; - CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); @@ -2785,6 +2783,24 @@ void M_Init(void) quitmsg[QUIT3MSG5] = M_GetText("You'll be back to play soon, though...\n......right?\n\n(Press 'Y' to quit)"); quitmsg[QUIT3MSG6] = M_GetText("Aww, is Egg Rock Zone too\ndifficult for you?\n\n(Press 'Y' to quit)"); +#ifdef HWRENDER + // Permanently hide some options based on render mode + if (rendermode == render_soft) + OP_VideoOptionsMenu[1].status = IT_DISABLED; +#endif + +#ifndef NONET + CV_RegisterVar(&cv_serversort); +#endif + + //todo put this somewhere better... + CV_RegisterVar(&cv_allcaps); +} + +void M_InitCharacterTables(void) +{ + UINT8 i; + // Setup PlayerMenu table for (i = 0; i < MAXSKINS; i++) { @@ -2828,19 +2844,6 @@ void M_Init(void) strcpy(description[i].skinname, ""); } } - -#ifdef HWRENDER - // Permanently hide some options based on render mode - if (rendermode == render_soft) - OP_VideoOptionsMenu[1].status = IT_DISABLED; -#endif - -#ifndef NONET - CV_RegisterVar(&cv_serversort); -#endif - - //todo put this somewhere better... - CV_RegisterVar(&cv_allcaps); } // ========================================================================== diff --git a/src/m_menu.h b/src/m_menu.h index 7e2cce20d..fcde5b7db 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -38,6 +38,9 @@ void M_Drawer(void); // Called by D_SRB2Main, loads the config file. void M_Init(void); +// Called by D_SRB2Main also, sets up the playermenu and description tables. +void M_InitCharacterTables(void); + // Called by intro code to force menu up upon a keypress, // does nothing if menu is already up. void M_StartControlPanel(void); From 0aa965c59f5fc4191d7d6402a3de567410729089 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 26 Jan 2019 23:22:30 -0500 Subject: [PATCH 44/72] How did I forget about this --- src/dehacked.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 5161bf242..82d630a55 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -437,7 +437,6 @@ static boolean findFreeSlot(INT32 *num) // Send the character select entry to a free slot. while (*num < MAXSKINS && PlayerMenu[*num].status != IT_DISABLED) *num = *num+1; - CONS_Printf("%d\n", *num); // No more free slots. :( if (*num >= MAXSKINS) From 76724c9c130f3e99506fd8ed9b475acccc021646 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 11 Feb 2019 16:39:58 -0500 Subject: [PATCH 45/72] Show line number on error, also hide under devmode --- src/p_slopes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 68767b50c..4e12b104f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -264,7 +264,7 @@ void P_SpawnSlope_Line(int linenum) if(!line->frontsector || !line->backsector) { - CONS_Printf("P_SpawnSlope_Line used on a line without two sides.\n"); + CONS_Debug(DBG_SETUP, "P_SpawnSlope_Line used on a line without two sides. (line number %i)\n", linenum); return; } From c9d90f7688aa7804316e99649bd85765cf7942df Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Thu, 21 Feb 2019 19:44:18 -0500 Subject: [PATCH 46/72] 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 47/72] 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 48/72] 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 49/72] Some small changes. From a25f4b81944230fe28e88c7d959923cc8339a5a1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 26 Feb 2019 21:14:22 +0000 Subject: [PATCH 50/72] Make sure that B_CheckRespawn can be called even if Tails is dead --- src/p_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e4cb01f63..285d36ca9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8688,8 +8688,11 @@ void P_PlayerThink(player_t *player) if (player->bot) { - if (player->playerstate == PST_LIVE && B_CheckRespawn(player)) - player->playerstate = PST_REBORN; + if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) + { + if (B_CheckRespawn(player)) + player->playerstate = PST_REBORN; + } if (player->playerstate == PST_REBORN) return; } From 15b27bb7d7fbeff916fc4142ba287e7a3508d8f7 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 27 Feb 2019 15:55:39 -0500 Subject: [PATCH 51/72] Upped MAXNETNODES --- src/d_net.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_net.h b/src/d_net.h index 61c669dbb..8e8afcffa 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -20,6 +20,7 @@ // Max computers in a game #define MAXNETNODES 32 +#define MAXNETNODES (MAXPLAYERS+4) #define BROADCASTADDR MAXNETNODES #define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer //#define NETSPLITSCREEN // Kart's splitscreen netgame feature From fa990e8603f45a551b7980ea7211fcdc7f87cc51 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 27 Feb 2019 16:05:43 -0500 Subject: [PATCH 52/72] Remove double define --- src/d_net.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_net.h b/src/d_net.h index 8e8afcffa..3d1058702 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -19,7 +19,6 @@ #define __D_NET__ // Max computers in a game -#define MAXNETNODES 32 #define MAXNETNODES (MAXPLAYERS+4) #define BROADCASTADDR MAXNETNODES #define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer From aea18f36baea9d68f3252e5b7c2723f6f632afed Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 13 Mar 2019 19:42:29 -0400 Subject: [PATCH 53/72] 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 54/72] 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 55/72] 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 56/72] 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 57/72] 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 58/72] 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 59/72] 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 2fb569857a75571c27b02ffe0230da43cb456312 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 18 Mar 2019 22:00:23 +0000 Subject: [PATCH 60/72] 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 3e5b0c45318d77f594d4ae71596c5d0fcc5752e8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 2 May 2019 18:31:51 -0400 Subject: [PATCH 61/72] 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 62/72] 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 8f05d759263dfe3a57990f101f10cec6d1283936 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Wed, 8 May 2019 09:36:37 -0500 Subject: [PATCH 63/72] 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 64/72] 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 65/72] 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 66/72] 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 d4dac52766e5841a3aa01373445a2f2a70448594 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 3 Jun 2019 15:23:48 -0400 Subject: [PATCH 67/72] Upped freeslots limit --- src/info.h | 2 +- src/sounds.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/info.h b/src/info.h index cba49667d..0700494f9 100644 --- a/src/info.h +++ b/src/info.h @@ -210,7 +210,7 @@ void A_NapalmScatter(); void A_SpawnFreshCopy(); // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 -#define NUMMOBJFREESLOTS 256 +#define NUMMOBJFREESLOTS 512 #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) diff --git a/src/sounds.h b/src/sounds.h index 495a55a1e..3c74d56e6 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -42,7 +42,7 @@ typedef enum } skinsound_t; // free sfx for S_AddSoundFx() -#define NUMSFXFREESLOTS 800 // Matches SOC Editor. +#define NUMSFXFREESLOTS 1600 // Matches SOC Editor. #define NUMSKINSFXSLOTS (MAXSKINS*NUMSKINSOUNDS) // From 6f6d912fa6f6e009502e7350bbea9f0420e1e222 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 7 Jun 2019 15:48:33 +0100 Subject: [PATCH 68/72] Update version to 2.1.24 --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- debian/changelog | 4 ++-- debian/control | 4 ++-- src/doomdef.h | 8 ++++---- src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a5507b92..2d7b34159 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(SRB2 - VERSION 2.1.23 + VERSION 2.1.24 LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) diff --git a/appveyor.yml b/appveyor.yml index f0f843fbb..98da61dbf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.1.23.{branch}-{build} +version: 2.1.24.{branch}-{build} os: MinGW environment: diff --git a/debian/changelog b/debian/changelog index b06a78e2b..ff59fdc47 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ -srb2 (2.1.23~9) trusty; urgency=high +srb2 (2.1.24~9) trusty; urgency=high - * SRB2 v2.1.23 release + * SRB2 v2.1.24 release -- Marco Zafra Mon, 27 Nov 2018 16:45:00 -0500 diff --git a/debian/control b/debian/control index 0f2d8062b..92bb147de 100644 --- a/debian/control +++ b/debian/control @@ -18,7 +18,7 @@ Homepage: http://www.srb2.org Package: srb2 Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23) +Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.24) Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy @@ -31,7 +31,7 @@ Description: A cross-platform 3D Sonic fangame Package: srb2-dbg Architecture: any # FIXME: should be Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat -Depends: libc6, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23), srb2 +Depends: libc6, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.24), srb2 Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy diff --git a/src/doomdef.h b/src/doomdef.h index 088d81d0a..6b6afbf1b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -150,9 +150,9 @@ extern FILE *logstream; // we use comprevision and compbranch instead. #else #define VERSION 201 // Game version -#define SUBVERSION 23 // more precise version number -#define VERSIONSTRING "v2.1.23" -#define VERSIONSTRINGW L"v2.1.23" +#define SUBVERSION 24 // more precise version number +#define VERSIONSTRING "v2.1.24" +#define VERSIONSTRINGW L"v2.1.24" // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -217,7 +217,7 @@ extern FILE *logstream; // it's only for detection of the version the player is using so the MS can alert them of an update. // Only set it higher, not lower, obviously. // Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1". -#define MODVERSION 28 +#define MODVERSION 29 // To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically. // Increment MINOREXECVERSION whenever a config change is needed that does not correspond diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index a8ecbf7f8..878db3d8d 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1219,7 +1219,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.1.24; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1231,7 +1231,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.1.24; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj index 69c544c56..6b3997b1f 100644 --- a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1219,7 +1219,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.1.24; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1231,7 +1231,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.1.24; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( From c59163373343e13c1fc14bc69aba39de468c1aee Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 14 Jun 2019 14:13:41 -0300 Subject: [PATCH 69/72] Update m_misc.c --- src/m_misc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index 232ccb477..0445136fe 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1032,7 +1032,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) static inline moviemode_t M_StartMovieAPNG(const char *pathname) { #ifdef USE_APNG - UINT8 *palette; + UINT8 *palette = NULL; const char *freename = NULL; boolean ret = false; @@ -1048,8 +1048,13 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname) return MM_OFF; } - if (rendermode == render_soft) M_CreateScreenShotPalette(); - ret = M_SetupaPNG(va(pandf,pathname,freename), (palette = screenshot_palette)); + if (rendermode == render_soft) + { + M_CreateScreenShotPalette(); + palette = screenshot_palette; + } + + ret = M_SetupaPNG(va(pandf,pathname,freename), palette); if (!ret) { From bc2804d383b95ccfcf400a04683fddd9105e6980 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 20 Jun 2019 13:24:54 +0100 Subject: [PATCH 70/72] Fix the clearly accidental duplication of lumpinfo's memory allocation in ResGetLumpsStandalone --- src/w_wad.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 5bf7a36d3..8641cf116 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -334,7 +334,6 @@ static restype_t ResourceFileDetect (const char* filename) static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const char* lumpname) { lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); - lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); lumpinfo->position = 0; fseek(handle, 0, SEEK_END); lumpinfo->size = ftell(handle); From dcd4995eb3ca9812a0ede191d4b55f48c8c37578 Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sat, 22 Jun 2019 00:19:34 +0100 Subject: [PATCH 71/72] Remember to end inflating --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 5bf7a36d3..4d7d930b6 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1327,8 +1327,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si { size = 0; zerr(zErr); - (void)inflateEnd(&strm); } + + (void)inflateEnd(&strm); } else { From 8444379d5357ebed6bb30aca0cb2e804128f399a Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sat, 22 Jun 2019 00:52:28 +0100 Subject: [PATCH 72/72] Free the zentries --- src/w_wad.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 6ed2d50c2..8d96449f1 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -565,14 +565,14 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) { CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", strerror(ferror(handle))); Z_Free(lumpinfo); - free(zentry); + free(zentries); return NULL; } if (memcmp(zentry->signature, pat_central, 4)) { CONS_Alert(CONS_ERROR, "Central directory is corrupt\n"); Z_Free(lumpinfo); - free(zentry); + free(zentries); return NULL; } @@ -585,7 +585,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) { CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", strerror(ferror(handle))); Z_Free(lumpinfo); - free(zentry); + free(zentries); free(fullname); return NULL; } @@ -627,6 +627,8 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) } } + free(zentries); + *nlmp = numlumps; return lumpinfo; }