From a4149cfe37749db4dc150982510f7d011b336c24 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Jan 2020 18:49:22 -0800 Subject: [PATCH 01/28] Expose G_FindMap to Lua --- src/lua_baselib.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 2a82ec512..dfc5398cd 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2781,6 +2781,69 @@ static int lib_gBuildMapName(lua_State *L) return 1; } +static void +Lpushdim (lua_State *L, int c, struct searchdim *v) +{ + int i; + lua_createtable(L, c, 0);/* I guess narr is numeric indices??? */ + for (i = 0; i < c; ++i) + { + lua_createtable(L, 0, 2);/* and hashed indices (field)... */ + lua_pushnumber(L, v[i].pos); + lua_setfield(L, -2, "pos"); + + lua_pushnumber(L, v[i].siz); + lua_setfield(L, -2, "siz"); + lua_rawseti(L, -2, 1 + i); + } +} + +/* +I decided to make this return a table because userdata +is scary and tables let the user set their own fields. +*/ +static int lib_gFindMap(lua_State *L) +{ + const char *query = luaL_checkstring(L, 1); + + INT32 map; + char *realname; + INT32 frc; + mapsearchfreq_t *frv; + + INT32 i; + + map = G_FindMap(query, &realname, &frv, &frc); + + lua_settop(L, 0); + + lua_pushnumber(L, map); + lua_pushstring(L, realname); + + lua_createtable(L, frc, 0); + for (i = 0; i < frc; ++i) + { + lua_createtable(L, 0, 4); + lua_pushnumber(L, frv[i].mapnum); + lua_setfield(L, -2, "mapnum"); + + Lpushdim(L, frv[i].matchc, frv[i].matchd); + lua_setfield(L, -2, "matchd"); + + Lpushdim(L, frv[i].keywhc, frv[i].keywhd); + lua_setfield(L, -2, "keywhd"); + + lua_pushnumber(L, frv[i].total); + lua_setfield(L, -2, "total"); + lua_rawseti(L, -2, 1 + i); + } + + G_FreeMapSearch(frv, frc); + Z_Free(realname); + + return 3; +} + static int lib_gDoReborn(lua_State *L) { INT32 playernum = luaL_checkinteger(L, 1); @@ -3157,6 +3220,7 @@ static luaL_Reg lib[] = { // g_game {"G_AddGametype", lib_gAddGametype}, {"G_BuildMapName",lib_gBuildMapName}, + {"G_FindMap",lib_gFindMap}, {"G_DoReborn",lib_gDoReborn}, {"G_SetCustomExitVars",lib_gSetCustomExitVars}, {"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished}, From bcd90b96d4f5883dd9bff923d53b631190d9bd74 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Jan 2020 19:01:28 -0800 Subject: [PATCH 02/28] Add comment to lib_gFindMap so I know what the fuck I did --- src/lua_baselib.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index dfc5398cd..6964d5cc9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2802,6 +2802,31 @@ Lpushdim (lua_State *L, int c, struct searchdim *v) I decided to make this return a table because userdata is scary and tables let the user set their own fields. */ +/* +Returns: + +[1] => map number +[2] => map title +[3] => search frequency table + +The frequency table is unsorted. It has the following format: + +{ + ['mapnum'], + + ['matchd'] => matches in map title string + ['keywhd'] => matches in map keywords + + The above two tables have the following format: + + { + ['pos'] => offset from start of string + ['siz'] => length of match + }... + + ['total'] => the total matches +}... +*/ static int lib_gFindMap(lua_State *L) { const char *query = luaL_checkstring(L, 1); From 1e3fd7960148447e3233ef9c3f593199181962f8 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Jan 2020 20:32:40 -0800 Subject: [PATCH 03/28] Expose G_FindMapByNameOrCode to Lua --- src/lua_baselib.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6964d5cc9..c926db647 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2869,6 +2869,29 @@ static int lib_gFindMap(lua_State *L) return 3; } +/* +Returns: + +[1] => map number +[2] => map title +*/ +static int lib_gFindMapByNameOrCode(lua_State *L) +{ + const char *query = luaL_checkstring(L, 1); + INT32 map; + char *realname; + map = G_FindMapByNameOrCode(query, &realname); + lua_pushnumber(L, map); + if (map) + { + lua_pushstring(L, realname); + Z_Free(realname); + return 2; + } + else + return 1; +} + static int lib_gDoReborn(lua_State *L) { INT32 playernum = luaL_checkinteger(L, 1); @@ -3246,6 +3269,7 @@ static luaL_Reg lib[] = { {"G_AddGametype", lib_gAddGametype}, {"G_BuildMapName",lib_gBuildMapName}, {"G_FindMap",lib_gFindMap}, + {"G_FindMapByNameOrCode",lib_gFindMapByNameOrCode}, {"G_DoReborn",lib_gDoReborn}, {"G_SetCustomExitVars",lib_gSetCustomExitVars}, {"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished}, From 7f7ccc9911b058808bf5fdba892dee7643082bf3 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Wed, 13 May 2020 19:20:21 -0400 Subject: [PATCH 04/28] musicpref console variable Adds musicpref to console and sound options menu, which allows users to select whether to prioritize MIDI or Digital music. Functions GameMIDIMusic_OnChange and GameDigiMusic_OnChange updated to not assume digital music priority, and to have more consistent behavior between the two. Positive side effect of using P_RestoreMusic in these functions means that powerup music (speed shoes, invincibility) will restore in the correct position when reenabling the original MusicType they loaded in with. --- src/m_menu.c | 26 ++++++------ src/s_sound.c | 109 ++++++++++++++++++++++++++++++-------------------- src/s_sound.h | 10 ++++- 3 files changed, 88 insertions(+), 57 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2977b432f..bd0328b09 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1451,21 +1451,23 @@ static menuitem_t OP_OpenGLFogMenu[] = static menuitem_t OP_SoundOptionsMenu[] = { {IT_HEADER, NULL, "Game Audio", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 12}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 22}, + {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 6}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 11}, - {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 42}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 52}, + {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 21}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 26}, - {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 72}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 82}, + {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41}, + + {IT_STRING | IT_CVAR, NULL, "Music Preference", &cv_musicpref, 51}, - {IT_HEADER, NULL, "Miscellaneous", NULL, 102}, - {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 114}, - {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 124}, - {IT_STRING | IT_CVAR, NULL, "Default 1-Up sound", &cv_1upsound, 134}, + {IT_HEADER, NULL, "Miscellaneous", NULL, 61}, + {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 67}, + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 72}, + {IT_STRING | IT_CVAR, NULL, "Default 1-Up sound", &cv_1upsound, 77}, - {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 154}, + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 87}, }; #ifdef HAVE_OPENMPT @@ -2152,7 +2154,7 @@ menu_t OP_ColorOptionsDef = 0, NULL }; -menu_t OP_SoundOptionsDef = DEFAULTMENUSTYLE( +menu_t OP_SoundOptionsDef = DEFAULTSCROLLMENUSTYLE( MTREE2(MN_OP_MAIN, MN_OP_SOUND), "M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30); menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE( diff --git a/src/s_sound.c b/src/s_sound.c index 5ed9fd83a..1dde31349 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -60,6 +60,7 @@ static void Command_RestartAudio_f(void); static void GameMIDIMusic_OnChange(void); static void GameSounds_OnChange(void); static void GameDigiMusic_OnChange(void); +static void MusicPref_OnChange(void); #ifdef HAVE_OPENMPT static void ModFilter_OnChange(void); @@ -129,6 +130,14 @@ consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_O consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; +// Music preference +static CV_PossibleValue_t cons_musicpref_t[] = { + {0, "Digital"}, + {1, "MIDI"}, + {0, NULL} +}; +consvar_t cv_musicpref = {"musicpref", "Digital", CV_SAVE|CV_CALL|CV_NOINIT, cons_musicpref_t, MusicPref_OnChange, 0, NULL, NULL, 0, 0, NULL}; + // Window focus sound sytem toggles consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playsoundsifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -301,6 +310,7 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_gamesounds); CV_RegisterVar(&cv_gamedigimusic); CV_RegisterVar(&cv_gamemidimusic); + CV_RegisterVar(&cv_musicpref); #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); #endif @@ -1847,19 +1857,6 @@ const char *S_MusicName(void) return music_name; } -boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) -{ - if (!I_SongPlaying()) - return false; - - strncpy(mname, music_name, 7); - mname[6] = 0; - *mflags = music_flags; - *looping = music_looping; - - return (boolean)mname[0]; -} - boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) { return ( @@ -2201,10 +2198,12 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst) static lumpnum_t S_GetMusicLumpNum(const char *mname) { - if (!S_DigMusicDisabled() && S_DigExists(mname)) - return W_GetNumForName(va("o_%s", mname)); - else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) - return W_GetNumForName(va("d_%s", mname)); + boolean midipref = cv_musicpref.value; + + if (PREFAVAILABLE(midipref, mname)) + return W_GetNumForName(va(midipref ? "d_%s":"o_%s", mname)); + else if (ELSEAVAILABLE(midipref, mname)) + return W_GetNumForName(va(midipref ? "o_%s":"d_%s", mname)); else return LUMPERROR; } @@ -2660,11 +2659,17 @@ void GameDigiMusic_OnChange(void) else if (M_CheckParm("-nodigmusic")) return; + boolean midipref = cv_musicpref.value; + if (digital_disabled) { digital_disabled = false; I_StartupSound(); // will return early if initialised I_InitMusic(); + + if (midipref && (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)) + return; + S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); @@ -2674,27 +2679,20 @@ void GameDigiMusic_OnChange(void) else { digital_disabled = true; - if (S_MusicType() != MU_MID) + if (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX) { - if (midi_disabled) - S_StopMusic(); - else + S_StopMusic(); + if (!midi_disabled) { - char mmusic[7]; - UINT16 mflags; - boolean looping; - - if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic)) - { - S_StopMusic(); - S_ChangeMusic(mmusic, mflags, looping); - } + if (Playing()) + P_RestoreMusic(&players[consoleplayer]); else - S_StopMusic(); + S_ChangeMusicInternal("_clear", false); } } } } +} void GameMIDIMusic_OnChange(void) { @@ -2703,11 +2701,18 @@ void GameMIDIMusic_OnChange(void) else if (M_CheckParm("-nomidimusic")) return; + boolean midipref = cv_musicpref.value; + if (midi_disabled) { midi_disabled = false; I_StartupSound(); // will return early if initialised I_InitMusic(); + + if (!midipref && (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX && S_MusicType() != MU_NONE)) + return; + + S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); else @@ -2718,26 +2723,42 @@ void GameMIDIMusic_OnChange(void) midi_disabled = true; if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX) { - if (digital_disabled) - S_StopMusic(); - else + S_StopMusic(); + if (!digital_disabled) { - char mmusic[7]; - UINT16 mflags; - boolean looping; - - if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic)) - { - S_StopMusic(); - S_ChangeMusic(mmusic, mflags, looping); - } + if (Playing()) + P_RestoreMusic(&players[consoleplayer]); else - S_StopMusic(); + S_ChangeMusicInternal("_clear", false); } } } } +void MusicPref_OnChange(void) +{ + if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio") || + M_CheckParm("-nomidimusic") || M_CheckParm("-nodigmusic")) + return; + + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); + boolean midipref = cv_musicpref.value; + + if (midipref == currentmidi) + return; + + if (Playing() && PREFAVAILABLE(midipref, S_MusicName())) + { + S_StopMusic(); + P_RestoreMusic(&players[consoleplayer]); + } + else if (PREFAVAILABLE(midipref, "_clear")) + { + S_StopMusic(); + S_ChangeMusicInternal("_clear", false); + } +} + #ifdef HAVE_OPENMPT void ModFilter_OnChange(void) { diff --git a/src/s_sound.h b/src/s_sound.h index 3334fcb69..8b5c2aa1a 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -46,6 +46,15 @@ extern consvar_t cv_1upsound; extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; +extern consvar_t cv_musicpref; + +#define PREFAVAILABLE(pref, music) (pref ? \ + (!S_MIDIMusicDisabled() && S_MIDIExists(music)) : \ + (!S_DigMusicDisabled() && S_DigExists(music))) + +#define ELSEAVAILABLE(pref, music) (pref ? \ + (!S_DigMusicDisabled() && S_DigExists(music)) : \ + (!S_MIDIMusicDisabled() && S_MIDIExists(music))) extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundsifunfocused; @@ -178,7 +187,6 @@ boolean S_MusicPaused(void); boolean S_MusicNotInFocus(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) From fd31c5cd5eab28b2e16dc8983f8464cc9cd43628 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Thu, 14 May 2020 06:33:03 -0400 Subject: [PATCH 05/28] Update Worked out some edge cases that had resulted in tracks restarting in the same format when they shouldn't - or tracks not switching to the other format when they should. Removed stray } --- src/s_sound.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 1dde31349..2797ec252 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2151,7 +2151,11 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst) return false; } - if (strncmp(entry->musname, S_MusicName(), 7)) // don't restart music if we're already playing it + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); + boolean midipref = cv_musicpref.value; + + if (strncmp(entry->musname, S_MusicName(), 7) || // don't restart music if we're already playing it + (midipref != currentmidi && PREFAVAILABLE(midipref, entry->musname))) // but do if the user's preference has changed { if (music_stack_fadeout) S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, music_stack_fadeout, 0); @@ -2350,6 +2354,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); + boolean midipref = cv_musicpref.value; + if (prefadems) // queue music change for after fade // allow even if the music is the same // && S_MusicPlaying() // Let the delay happen even if we're not playing music { @@ -2358,7 +2365,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 I_FadeSong(0, prefadems, S_ChangeMusicToQueue); return; } - else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) + else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET) || + (midipref != currentmidi && PREFAVAILABLE(midipref, newmusic))) { CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); @@ -2659,21 +2667,15 @@ void GameDigiMusic_OnChange(void) else if (M_CheckParm("-nodigmusic")) return; - boolean midipref = cv_musicpref.value; - if (digital_disabled) { digital_disabled = false; I_StartupSound(); // will return early if initialised I_InitMusic(); - if (midipref && (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)) - return; - - S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); - else + else if ((!cv_musicpref.value || midi_disabled) && S_DigExists("_clear")) S_ChangeMusicInternal("_clear", false); } else @@ -2692,7 +2694,6 @@ void GameDigiMusic_OnChange(void) } } } -} void GameMIDIMusic_OnChange(void) { @@ -2701,21 +2702,15 @@ void GameMIDIMusic_OnChange(void) else if (M_CheckParm("-nomidimusic")) return; - boolean midipref = cv_musicpref.value; - if (midi_disabled) { midi_disabled = false; I_StartupSound(); // will return early if initialised I_InitMusic(); - if (!midipref && (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX && S_MusicType() != MU_NONE)) - return; - - S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); - else + else if ((cv_musicpref.value || digital_disabled) && S_MIDIExists("_clear")) S_ChangeMusicInternal("_clear", false); } else @@ -2741,22 +2736,10 @@ void MusicPref_OnChange(void) M_CheckParm("-nomidimusic") || M_CheckParm("-nodigmusic")) return; - boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); - boolean midipref = cv_musicpref.value; - - if (midipref == currentmidi) - return; - - if (Playing() && PREFAVAILABLE(midipref, S_MusicName())) - { - S_StopMusic(); + if (Playing()) P_RestoreMusic(&players[consoleplayer]); - } - else if (PREFAVAILABLE(midipref, "_clear")) - { - S_StopMusic(); + else if (PREFAVAILABLE(cv_musicpref.value, "_clear")) S_ChangeMusicInternal("_clear", false); - } } #ifdef HAVE_OPENMPT From c2a54acae3665362a8f6b0eafe359c965197381e Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Thu, 14 May 2020 07:17:58 -0400 Subject: [PATCH 06/28] Minor reorganization --- src/s_sound.c | 2 +- src/s_sound.h | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 2797ec252..32c4a2fbc 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2206,7 +2206,7 @@ static lumpnum_t S_GetMusicLumpNum(const char *mname) if (PREFAVAILABLE(midipref, mname)) return W_GetNumForName(va(midipref ? "d_%s":"o_%s", mname)); - else if (ELSEAVAILABLE(midipref, mname)) + else if (PREFAVAILABLE(!midipref, mname)) return W_GetNumForName(va(midipref ? "o_%s":"d_%s", mname)); else return LUMPERROR; diff --git a/src/s_sound.h b/src/s_sound.h index 8b5c2aa1a..f2c6f0e62 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -48,14 +48,6 @@ extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; extern consvar_t cv_musicpref; -#define PREFAVAILABLE(pref, music) (pref ? \ - (!S_MIDIMusicDisabled() && S_MIDIExists(music)) : \ - (!S_DigMusicDisabled() && S_DigExists(music))) - -#define ELSEAVAILABLE(pref, music) (pref ? \ - (!S_DigMusicDisabled() && S_DigExists(music)) : \ - (!S_MIDIMusicDisabled() && S_MIDIExists(music))) - extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundsifunfocused; @@ -191,6 +183,12 @@ 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) +// Returns whether the preferred format a (true = MIDI, false = Digital) +// exists and is enabled for musicname b +#define PREFAVAILABLE(a, b) (a ? \ + (!S_MIDIMusicDisabled() && S_MIDIExists(b)) : \ + (!S_DigMusicDisabled() && S_DigExists(b))) + // // Music Effects // From 70896f9095f289eb8192ff6e533a2084425ad8f2 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Thu, 14 May 2020 07:42:06 -0400 Subject: [PATCH 07/28] clean whitespace --- 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 32c4a2fbc..045e8409d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2366,7 +2366,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET) || - (midipref != currentmidi && PREFAVAILABLE(midipref, newmusic))) + (midipref != currentmidi && PREFAVAILABLE(midipref, newmusic))) { CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); From 864e7033552cbb966f378cfbaf56aa116c1f97e8 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Jun 2020 13:03:19 -0700 Subject: [PATCH 08/28] Only fill the intermission with blapck if we can't draw patches This fixes an issue where patches cease to be drawn due to Y_UnloadData, but the screen is still overwritten, causing the next wipe to start from void. --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index cd197c5cf..3c2308851 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -330,7 +330,7 @@ void Y_IntermissionDrawer(void) safetorender = false; } - if (!usebuffer || !safetorender) + if (!safetorender) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); if (!safetorender) From 78e6bcc8ff7525886aff8325bb973ac66e178ec5 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Jun 2020 13:08:00 -0700 Subject: [PATCH 09/28] Just stretch the fallback card to the screen resolution --- src/y_inter.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 3c2308851..9ccba2d5f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -359,12 +359,11 @@ void Y_IntermissionDrawer(void) else if (rendermode != render_soft && usebuffer) HWR_DrawIntermissionBG(); #endif - else + else if (bgpatch) { - if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx == 400) - V_DrawScaledPatch(0, 0, V_SNAPTOLEFT, widebgpatch); - else if (bgpatch) - V_DrawScaledPatch(0, 0, 0, bgpatch); + fixed_t hs = vid.width * FRACUNIT / BASEVIDWIDTH; + fixed_t vs = vid.height * FRACUNIT / BASEVIDHEIGHT; + V_DrawStretchyFixedPatch(0, 0, hs, vs, V_NOSCALEPATCH, bgpatch, NULL); } } else if (bgtile) From 607a4dbee7db7302dd229ce61441bec0c02fa01b Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Jun 2020 13:08:48 -0700 Subject: [PATCH 10/28] Remove caching of INTERSCW --- src/y_inter.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 9ccba2d5f..799578c34 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -141,7 +141,6 @@ static y_data data; // graphics static patch_t *bgpatch = NULL; // INTERSCR -static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK static patch_t *interpic = NULL; // custom picture defined in map header static boolean usetile; @@ -1265,7 +1264,6 @@ void Y_StartIntermission(void) data.coop.actnum = mapheaderinfo[gamemap-1]->actnum; // get background patches - widebgpatch = W_CachePatchName("INTERSCW", PU_PATCH); bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); // grab an interscreen if appropriate @@ -2083,7 +2081,6 @@ static void Y_UnloadData(void) // unload the background patches UNLOAD(bgpatch); - UNLOAD(widebgpatch); UNLOAD(bgtile); UNLOAD(interpic); @@ -2126,7 +2123,6 @@ static void Y_CleanupData(void) { // unload the background patches CLEANUP(bgpatch); - CLEANUP(widebgpatch); CLEANUP(bgtile); CLEANUP(interpic); From 5f85c722798d2154f8d823941ed1854dcae6cc4b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 20 Mar 2020 09:12:19 -0500 Subject: [PATCH 11/28] Fix the Master Server so it works Instructions: 1. In SQL, create an account called "srb2_ms" @ "localhost" (or your hostname). 2. Grant the account full priviledges to "srb2_ms" (the database). 3. Compile, and run using the sh script provided. That's all I'm telling you, I don't want this to become rampant. --- tools/masterserver/.gitignore | 4 +-- tools/masterserver/ipcs.h | 2 +- tools/masterserver/masterserver.sh | 21 ++++++++-------- tools/masterserver/server.cpp | 8 ++++-- tools/masterserver/structure.sql | 40 ++++++++++++++++-------------- 5 files changed, 41 insertions(+), 34 deletions(-) diff --git a/tools/masterserver/.gitignore b/tools/masterserver/.gitignore index 9f45745a3..8ae879eec 100644 --- a/tools/masterserver/.gitignore +++ b/tools/masterserver/.gitignore @@ -1,4 +1,4 @@ /client /server -/server.log -/*.o +/*.log +/*.o \ No newline at end of file diff --git a/tools/masterserver/ipcs.h b/tools/masterserver/ipcs.h index b9dc52fdf..4e144f4a5 100644 --- a/tools/masterserver/ipcs.h +++ b/tools/masterserver/ipcs.h @@ -140,8 +140,8 @@ typedef struct char port[8]; char name[32]; INT32 room; - char key[32]; // Secret key for linking dedicated servers to accounts char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31) + char key[32]; // Secret key for linking dedicated servers to accounts } ATTRPACK msg_server_t; typedef struct diff --git a/tools/masterserver/masterserver.sh b/tools/masterserver/masterserver.sh index 9b1adb128..fe4ba0071 100755 --- a/tools/masterserver/masterserver.sh +++ b/tools/masterserver/masterserver.sh @@ -5,9 +5,10 @@ # Get LSB functions . /lib/lsb/init-functions -. /etc/default/rcS +#. /etc/default/rcS -SRB2MS=/usr/local/bin/masterserver +#SRB2MS=/usr/local/bin/masterserver +SRB2MS=./server SRB2MS_PORT=28900 # Check that the package is still installed @@ -15,11 +16,9 @@ SRB2MS_PORT=28900 case "$1" in start) - log_begin_msg "Starting SRB2MS..." + log_begin_msg "Starting SRB2MS...\n" umask 002 - if start-stop-daemon --start \ - --exec $SRB2MS \ - -- $SRB2MS_PORT; then + if exec $SRB2MS $SRB2MS_PORT & then log_end_msg 0 else log_end_msg $? @@ -27,11 +26,11 @@ case "$1" in ;; stop) - log_begin_msg "Stopping SRB2MS..." - if start-stop-daemon --stop --exec $SRB2MS; then - log_end_msg 0 + log_begin_msg "Stopping SRB2MS...\n" + if killall $SRB2MS -q & then + log_end_msg 0 else - log_end_msg $? + log_end_msg $? fi ;; @@ -40,7 +39,7 @@ case "$1" in ;; *) - e cho "Usage: /etc/init.d/masterserver {start|stop|restart|force-reload}" + echo "Usage: $0 {start|stop|restart|force-reload}" exit 1 ;; esac diff --git a/tools/masterserver/server.cpp b/tools/masterserver/server.cpp index b7ed0d6b4..883ba5985 100644 --- a/tools/masterserver/server.cpp +++ b/tools/masterserver/server.cpp @@ -86,7 +86,7 @@ typedef struct //============================================================================= -#define HOSTNAME "loopback" +#define HOSTNAME "localhost" #define USER "srb2_ms" #define PASSWORD "gLRDRb7WgLRDRb7W" #define DATABASE "srb2_ms" @@ -841,6 +841,10 @@ static void addServer(int id, char *buffer, bool firstadd) info->port[sizeof (info->port)-1] = '\0'; info->name[sizeof (info->name)-1] = '\0'; info->version[sizeof (info->version)-1] = '\0'; + + logPrintf(logfile, "addServer(): Version = \"%s\"\n", info->version); + logPrintf(logfile, "addServer(): Key = \"%s\"\n", info->key); + // retrieve the true ip of the server strcpy(info->ip, server_socket.getClientIP(id)); //strcpy(info->port, server_socket.getClientPort(id)); @@ -995,7 +999,7 @@ int main(int argc, char *argv[]) if (server_socket.listen(argv[1]) < 0) { - fprintf(stderr, "Error while initializing the server\n"); + fprintf(stderr, "Error while initializing the server; port being used! Try killing the other Master Server.\n"); exit(2); } diff --git a/tools/masterserver/structure.sql b/tools/masterserver/structure.sql index 3cc2cb15b..013c22383 100644 --- a/tools/masterserver/structure.sql +++ b/tools/masterserver/structure.sql @@ -13,8 +13,8 @@ SET time_zone = "+00:00"; -- Database: `srb2ms` -- -CREATE DATABASE IF NOT EXISTS `srb2ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -USE `srb2ms`; +CREATE DATABASE IF NOT EXISTS `srb2_ms` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `srb2_ms`; -- -------------------------------------------------------- @@ -25,8 +25,8 @@ USE `srb2ms`; CREATE TABLE `ms_bans` ( `bid` int(11) DEFAULT NULL, - `ipstart` int(11) DEFAULT NULL, - `ipend` int(11) DEFAULT NULL, + `ipstart` int(10) unsigned DEFAULT NULL, + `ipend` int(10) unsigned DEFAULT NULL, `full_endtime` int(11) DEFAULT NULL, `permanent` tinyint(1) DEFAULT NULL, `hostonly` tinyint(1) DEFAULT NULL, @@ -63,19 +63,19 @@ INSERT INTO `ms_rooms` (`room_id`, `title`, `motd`, `visible`, `order`, `private -- CREATE TABLE `ms_servers` ( - `sid` int(11) NOT NULL, + `sid` int(11) primary key AUTO_INCREMENT, `name` text COLLATE utf8mb4_unicode_ci NOT NULL, `ip` text COLLATE utf8mb4_unicode_ci NOT NULL, - `port` int(11) NOT NULL, + `port` int(11) NOT NULL DEFAULT 5029, `version` text COLLATE utf8mb4_unicode_ci NOT NULL, - `timestamp` int(11) NOT NULL, - `room` int(11) NOT NULL, + `timestamp` int(11) NOT NULL DEFAULT 0, + `room` int(11) NOT NULL DEFAULT 0, `key` text COLLATE utf8mb4_unicode_ci NOT NULL, - `room_override` int(11) NOT NULL, - `upnow` tinyint(1) NOT NULL, - `permanent` tinyint(1) NOT NULL, - `delisted` tinyint(1) NOT NULL, - `sticky` int(11) NOT NULL + `room_override` int(11) NOT NULL DEFAULT 0, + `upnow` tinyint(1) NOT NULL DEFAULT 1, + `permanent` tinyint(1) NOT NULL DEFAULT 0, + `delisted` tinyint(1) NOT NULL DEFAULT 0, + `sticky` int(11) NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -85,16 +85,20 @@ CREATE TABLE `ms_servers` ( -- CREATE TABLE `ms_versions` ( - `mod_id` int(11) NOT NULL, - `mod_version` int(11) NOT NULL + `mod_id` int(10) unsigned primary key AUTO_INCREMENT, + `mod_version` int(10) unsigned NOT NULL DEFAULT 1, + `mod_vstring` varchar(45) NOT NULL DEFAULT 'v1.0', + `mod_codebase` int(10) unsigned NOT NULL DEFAULT 205, + `mod_name` varchar(255) NOT NULL DEFAULT 'Default MOD Name', + `mod_url` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Dumping data for table `ms_versions` -- -INSERT INTO `ms_versions` (`mod_id`, `mod_version`) VALUES -(12, 25); +INSERT INTO `ms_versions` (`mod_id`, `mod_version`, `mod_vstring`, `mod_codebase`, `mod_name`, `mod_url`) VALUES +(18, 42, 'v2.2.2', 205, 'SRB2 2.2', 'SRB2.org'); -- -------------------------------------------------------- @@ -114,4 +118,4 @@ COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; \ No newline at end of file From 66929c3c620e1e1ce386065e51992a9349a9c147 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 4 May 2020 01:38:38 -0500 Subject: [PATCH 12/28] Allow multiple ports to host under one IP address. --- tools/masterserver/server.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/masterserver/server.cpp b/tools/masterserver/server.cpp index 883ba5985..1f3f15a80 100644 --- a/tools/masterserver/server.cpp +++ b/tools/masterserver/server.cpp @@ -291,17 +291,17 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c char checkquery[500]; char updatequery[5000]; char queryp1[5000] = "INSERT INTO `ms_servers` (`name`,`ip`,`port`,`version`,`timestamp`,`room`,`key`) VALUES ('%s','%s','%s','%s','%ld','%d','%s')"; - char checkqueryp1[500] = "SELECT room_override FROM `ms_servers` WHERE `ip` = '%s'"; + char checkqueryp1[500] = "SELECT room_override FROM `ms_servers` WHERE `ip` = '%s' AND `port` = '%s'"; char updatequeryp1[5000]; if(firstadd) { logPrintf(logfile, "First add.\n"); - strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `delisted` = '0', `key` = '%s' WHERE `ip` = '%s'"); + strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `delisted` = '0', `key` = '%s' WHERE `ip` = '%s' AND `port` = '%s'"); } else { logPrintf(logfile, "Update ping.\n"); - strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `key` = '%s' WHERE `ip` = '%s' AND `delisted` = '0'"); + strcpy(updatequeryp1, "UPDATE `ms_servers` SET `name` = '%s', `port` = '%s', `version` = '%s', timestamp = '%ld', upnow = '1', `room` = '%d', `key` = '%s' WHERE `ip` = '%s' AND `port` = '%s' AND `delisted` = '0'"); } MySQL_Conn(false); mysql_real_escape_string(conn, escapedName, name, (unsigned long)strlen(name)); @@ -314,10 +314,10 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c logPrintf(errorfile, "IP %s tried to use the private room %d! THIS SHOULD NOT HAPPEN\n", ip, room); return; } - sprintf(checkquery, checkqueryp1, ip); + sprintf(checkquery, checkqueryp1, ip, port); time_t timestamp; timestamp = time (NULL); - logPrintf(logfile, "Checking for existing servers in table with the same IP...\n"); + logPrintf(logfile, "Checking for existing servers in table with the same IP and port...\n"); logPrintf(mysqlfile, "Executing MySQL Query: %s\n", checkquery); if(mysql_query(conn, checkquery)) { logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn)); @@ -343,7 +343,7 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c mysql_free_result(res); logPrintf(logfile, "Server's IP already exists, so let's just update it instead...\n"); logPrintf(logfile, "Updating Server Data for %s\n", ip); - sprintf(updatequery, updatequeryp1, escapedName, escapedPort, escapedVersion, timestamp, room, escapedKey, ip); + sprintf(updatequery, updatequeryp1, escapedName, escapedPort, escapedVersion, timestamp, room, escapedKey, ip, port); logPrintf(mysqlfile, "Executing MySQL Query: %s\n", updatequery); if(mysql_query(conn, updatequery)) { logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn)); @@ -619,10 +619,10 @@ void MySQL_ListServServers(UINT32 id, UINT32 type, const char *ip) { void MySQL_RemoveServer(char *ip, char *port, char *name, char *version) { char escapedName[255]; char updatequery[5000]; - char updatequeryp1[5000] = "UPDATE `ms_servers` SET upnow = '0' WHERE `ip` = '%s' AND `permanent` = '0'"; + char updatequeryp1[5000] = "UPDATE `ms_servers` SET upnow = '0' WHERE `ip` = '%s' AND `port` = '%s' AND `permanent` = '0'"; MySQL_Conn(false); mysql_real_escape_string(conn, escapedName, name, (unsigned long)strlen(name)); - sprintf(updatequery, updatequeryp1, ip); + sprintf(updatequery, updatequeryp1, ip, port); logPrintf(mysqlfile, "Executing MySQL Query: %s\n", updatequery); if(mysql_query(conn, updatequery)) { logPrintf(errorfile, "MYSQL ERROR: %s\n", mysql_error(conn)); From a02306b674af77bf154ff6e55c970074723b21d5 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Mon, 4 May 2020 01:44:49 -0500 Subject: [PATCH 13/28] Fix small inconsistency --- tools/masterserver/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/masterserver/server.cpp b/tools/masterserver/server.cpp index 1f3f15a80..d00205301 100644 --- a/tools/masterserver/server.cpp +++ b/tools/masterserver/server.cpp @@ -341,7 +341,7 @@ void MySQL_AddServer(const char *ip, const char *port, const char *name, const c if(atoi(row[0]) != 0) room = atoi(row[0]); mysql_free_result(res); - logPrintf(logfile, "Server's IP already exists, so let's just update it instead...\n"); + logPrintf(logfile, "Server's IP and port already exists, so let's just update it instead...\n"); logPrintf(logfile, "Updating Server Data for %s\n", ip); sprintf(updatequery, updatequeryp1, escapedName, escapedPort, escapedVersion, timestamp, room, escapedKey, ip, port); logPrintf(mysqlfile, "Executing MySQL Query: %s\n", updatequery); From f541c37ebc9068cf6a3526fb92d5bd655b5b444e Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Mon, 13 Jul 2020 15:16:49 -0400 Subject: [PATCH 14/28] Fix formatting PREFAVAILABLE -> S_PrefAvailable move declarations to top of blocks --- src/s_sound.c | 20 +++++++++----------- src/s_sound.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 045e8409d..072a69f6c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2097,6 +2097,8 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst) boolean mapmuschanged = false; musicstack_t *result; musicstack_t *entry = Z_Calloc(sizeof (*result), PU_MUSIC, NULL); + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); + boolean midipref = cv_musicpref.value; if (status) result = S_GetMusicStackEntry(status, fromfirst, -1); @@ -2151,11 +2153,8 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst) return false; } - boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); - boolean midipref = cv_musicpref.value; - if (strncmp(entry->musname, S_MusicName(), 7) || // don't restart music if we're already playing it - (midipref != currentmidi && PREFAVAILABLE(midipref, entry->musname))) // but do if the user's preference has changed + (midipref != currentmidi && S_PrefAvailable(midipref, entry->musname))) // but do if the user's preference has changed { if (music_stack_fadeout) S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, music_stack_fadeout, 0); @@ -2204,9 +2203,9 @@ static lumpnum_t S_GetMusicLumpNum(const char *mname) { boolean midipref = cv_musicpref.value; - if (PREFAVAILABLE(midipref, mname)) + if (S_PrefAvailable(midipref, mname)) return W_GetNumForName(va(midipref ? "d_%s":"o_%s", mname)); - else if (PREFAVAILABLE(!midipref, mname)) + else if (S_PrefAvailable(!midipref, mname)) return W_GetNumForName(va(midipref ? "o_%s":"d_%s", mname)); else return LUMPERROR; @@ -2333,6 +2332,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]; + boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); + boolean midipref = cv_musicpref.value; if (S_MusicDisabled()) return; @@ -2354,9 +2355,6 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } - boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX); - boolean midipref = cv_musicpref.value; - if (prefadems) // queue music change for after fade // allow even if the music is the same // && S_MusicPlaying() // Let the delay happen even if we're not playing music { @@ -2366,7 +2364,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET) || - (midipref != currentmidi && PREFAVAILABLE(midipref, newmusic))) + (midipref != currentmidi && S_PrefAvailable(midipref, newmusic))) { CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); @@ -2738,7 +2736,7 @@ void MusicPref_OnChange(void) if (Playing()) P_RestoreMusic(&players[consoleplayer]); - else if (PREFAVAILABLE(cv_musicpref.value, "_clear")) + else if (S_PrefAvailable(cv_musicpref.value, "_clear")) S_ChangeMusicInternal("_clear", false); } diff --git a/src/s_sound.h b/src/s_sound.h index f2c6f0e62..35d1c3dc5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -185,7 +185,7 @@ boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); // Returns whether the preferred format a (true = MIDI, false = Digital) // exists and is enabled for musicname b -#define PREFAVAILABLE(a, b) (a ? \ +#define S_PrefAvailable(a, b) (a ? \ (!S_MIDIMusicDisabled() && S_MIDIExists(b)) : \ (!S_DigMusicDisabled() && S_DigExists(b))) From 05ac0fc7ea7f232f804e9ca612be9ac437c4cc54 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 18 Jul 2020 16:36:41 -0400 Subject: [PATCH 15/28] Fix muspostbossname sometimes returning garbage. --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2fd7ba5b0..e032b7be2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -355,8 +355,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->muspos = 0; mapheaderinfo[num]->musinterfadeout = 0; - mapheaderinfo[num]->musintername[0] = '\0'; - mapheaderinfo[num]->muspostbossname[6] = 0; + mapheaderinfo[num]->musintername[0] = 0; + mapheaderinfo[num]->muspostbossname[0] = 0; mapheaderinfo[num]->muspostbosstrack = 0; mapheaderinfo[num]->muspostbosspos = 0; mapheaderinfo[num]->muspostbossfadein = 0; From e9a03401cb41af4a085586b7d326802533a0e7a0 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 19 Jul 2020 15:20:19 -0400 Subject: [PATCH 16/28] Port netticbuffer from Kart --- src/d_clisrv.c | 7 +++++++ src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 71e2e947e..d3cc0b0e2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3615,6 +3615,9 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) CL_RemovePlayer(pnum, kickreason); } +static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; +consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}}; @@ -5380,6 +5383,10 @@ void TryRunTics(tic_t realtics) ExtraDataTicker(); gametic++; consistancy[gametic%BACKUPTICS] = Consistancy(); + + // Leave a certain amount of tics present in the net buffer as long as we've ran at least one tic this frame. + if (client && gamestate == GS_LEVEL && leveltime > 3 && neededtic <= gametic + cv_netticbuffer.value) + break; } } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index cb23883a8..d537984df 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -540,7 +540,7 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; -extern consvar_t cv_allownewplayer, cv_joinnextround, cv_maxplayers, cv_joindelay, cv_rejointimeout; +extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_joinnextround, cv_maxplayers, cv_joindelay, cv_rejointimeout; extern consvar_t cv_resynchattempts, cv_blamecfail; extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 592734067..6aa168aa7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -701,6 +701,7 @@ void D_RegisterClientCommands(void) #endif CV_RegisterVar(&cv_rollingdemos); CV_RegisterVar(&cv_netstat); + CV_RegisterVar(&cv_netticbuffer); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); From ee9c146b5dd957b5a05196ee4e87cceaa6459a50 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Sun, 19 Jul 2020 17:23:08 -0500 Subject: [PATCH 17/28] Re-enable built-in color modification --- src/lua_infolib.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index b3e92f833..a7fee8b03 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1491,7 +1491,7 @@ static void setRamp(lua_State *L, skincolor_t* c) { UINT32 i; lua_pushnil(L); for (i=0; i= numskincolors) - return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", cnum, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); + if (!cnum || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", cnum, numskincolors-1); info = &skincolors[cnum]; // get the skincolor to assign to. } luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. @@ -1563,7 +1563,7 @@ static int lib_setSkinColor(lua_State *L) } else if (i == 3 || (str && fastcmp(str,"invcolor"))) { UINT16 v = (UINT16)luaL_checkinteger(L, 3); if (v >= numskincolors) - return luaL_error(L, "attempt to set skincolors[%d].invcolor to out of range value %d.", cnum, v); + return luaL_error(L, "skincolor_t field 'invcolor' out of range (1 - %d)", numskincolors-1); info->invcolor = v; } else if (i == 4 || (str && fastcmp(str,"invshade"))) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; @@ -1615,12 +1615,13 @@ static int skincolor_set(lua_State *L) UINT32 i; skincolor_t *info = *((skincolor_t **)luaL_checkudata(L, 1, META_SKINCOLOR)); const char *field = luaL_checkstring(L, 2); + UINT16 cnum = (UINT16)(info-skincolors); I_Assert(info != NULL); I_Assert(info >= skincolors); - if (info-skincolors < SKINCOLOR_FIRSTFREESLOT || info-skincolors >= numskincolors) - return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", info-skincolors, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); + if (!cnum || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", cnum, numskincolors-1); if (fastcmp(field,"name")) { const char* n = luaL_checkstring(L, 3); @@ -1633,7 +1634,7 @@ static int skincolor_set(lua_State *L) if (info->name[0] != '\0') // don't check empty string for dupe { UINT16 dupecheck = R_GetColorByName(info->name); - if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors))) + if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != cnum))) CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name); } } else if (fastcmp(field,"ramp")) { @@ -1644,11 +1645,11 @@ static int skincolor_set(lua_State *L) else for (i=0; iramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i]; - skincolor_modified[info-skincolors] = true; + skincolor_modified[cnum] = true; } else if (fastcmp(field,"invcolor")) { UINT16 v = (UINT16)luaL_checkinteger(L, 3); if (v >= numskincolors) - return luaL_error(L, "attempt to set skincolor_t field 'invcolor' to out of range value %d.", v); + return luaL_error(L, "skincolor_t field 'invcolor' out of range (1 - %d)", numskincolors-1); info->invcolor = v; } else if (fastcmp(field,"invshade")) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; @@ -1688,11 +1689,11 @@ static int colorramp_get(lua_State *L) static int colorramp_set(lua_State *L) { UINT8 *colorramp = *((UINT8 **)luaL_checkudata(L, 1, META_COLORRAMP)); - UINT16 cnum = (UINT16)(((uint8_t*)colorramp - (uint8_t*)(skincolors[0].ramp))/sizeof(skincolor_t)); + UINT16 cnum = (UINT16)(((UINT8*)colorramp - (UINT8*)(skincolors[0].ramp))/sizeof(skincolor_t)); UINT32 n = luaL_checkinteger(L, 2); UINT8 i = (UINT8)luaL_checkinteger(L, 3); - if (cnum < SKINCOLOR_FIRSTFREESLOT || cnum >= numskincolors) - return luaL_error(L, "skincolors[] index %d out of range (%d - %d)", cnum, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); + if (!cnum || cnum >= numskincolors) + return luaL_error(L, "skincolors[] index %d out of range (1 - %d)", cnum, numskincolors-1); if (n >= COLORRAMPSIZE) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' index %d out of range (0 - %d)", n, COLORRAMPSIZE-1); if (hud_running) From cea3f64c889655981705856f818f9678a5bd55f1 Mon Sep 17 00:00:00 2001 From: lachwright Date: Mon, 20 Jul 2020 22:24:16 +0800 Subject: [PATCH 18/28] Fix default NiGHTS skin brightness for non-super characters --- src/lua_baselib.c | 11 +++++++++++ src/p_local.h | 1 + src/p_mobj.c | 2 +- src/p_user.c | 28 +++++++++++++++------------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3f62ef890..e9596fa9c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1113,6 +1113,16 @@ static int lib_pPlayerCanDamage(lua_State *L) return 1; } +static int lib_pPlayerFullbright(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, P_PlayerFullbright(player)); + return 1; +} + static int lib_pIsObjectInGoop(lua_State *L) { @@ -3386,6 +3396,7 @@ static luaL_Reg lib[] = { {"P_DoPlayerPain",lib_pDoPlayerPain}, {"P_ResetPlayer",lib_pResetPlayer}, {"P_PlayerCanDamage",lib_pPlayerCanDamage}, + {"P_PlayerFullbright",lib_pPlayerFullbright}, {"P_IsObjectInGoop",lib_pIsObjectInGoop}, {"P_IsObjectOnGround",lib_pIsObjectOnGround}, {"P_InSpaceSector",lib_pInSpaceSector}, diff --git a/src/p_local.h b/src/p_local.h index b6c34f357..4077fecf6 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -142,6 +142,7 @@ void P_SetPlayerAngle(player_t *player, angle_t angle); angle_t P_GetLocalAngle(player_t *player); void P_SetLocalAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle); +boolean P_PlayerFullbright(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo); diff --git a/src/p_mobj.c b/src/p_mobj.c index 6f3f53559..9cd5667da 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -442,7 +442,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->sprite2 = spr2; mobj->frame = frame|(st->frame&~FF_FRAMEMASK); - if (player->powers[pw_super] || (player->powers[pw_carry] == CR_NIGHTSMODE && (player->charflags & (SF_SUPER|SF_NONIGHTSSUPER)) == SF_SUPER)) // Super colours? Super bright! + if (P_PlayerFullbright(player)) mobj->frame |= FF_FULLBRIGHT; } // Regular sprites diff --git a/src/p_user.c b/src/p_user.c index 679f4064b..8b8bf1714 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7975,20 +7975,13 @@ void P_MovePlayer(player_t *player) // Locate the capsule for this mare. else if (maptol & TOL_NIGHTS) { - if ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (player->exiting - || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] - && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6]))) // Note the < instead of <= + if (P_PlayerFullbright(player)) { - skin_t *skin = ((skin_t *)(player->mo->skin)); - if (( skin->flags & (SF_SUPER|SF_NONIGHTSSUPER) ) == SF_SUPER) - { - player->mo->color = skin->supercolor - + ((player->nightstime == player->startedtime) - ? 4 - : abs((((signed)leveltime >> 1) % 9) - 4)); // This is where super flashing is handled. - G_GhostAddColor(GHC_SUPER); - } + player->mo->color = ((skin_t *)player->mo->skin)->supercolor + + ((player->nightstime == player->startedtime) + ? 4 + : abs((((signed)leveltime >> 1) % 9) - 4)); // This is where super flashing is handled. + G_GhostAddColor(GHC_SUPER); } if (!player->capsule && !player->bonustime) @@ -12895,3 +12888,12 @@ void P_ForceLocalAngle(player_t *player, angle_t angle) else if (player == &players[secondarydisplayplayer]) localangle2 = angle; } + +boolean P_PlayerFullbright(player_t *player) +{ + return (player->powers[pw_super] + || ((player->powers[pw_carry] == CR_NIGHTSMODE && (((skin_t *)player->mo->skin)->flags & (SF_SUPER|SF_NONIGHTSSUPER)) == SF_SUPER) // Super colours? Super bright! + && (player->exiting + || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <= +} From 5332fff5403f9c02d378c1c74264225444e61771 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Mon, 20 Jul 2020 12:06:57 -0500 Subject: [PATCH 19/28] Deny standard color accessibility changes --- src/dehacked.c | 8 +++++--- src/lua_infolib.c | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 2e98a854c..cf891f438 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -808,9 +808,11 @@ static void readskincolor(MYFILE *f, INT32 num) { size_t namesize = sizeof(skincolors[num].name); char truncword[namesize]; + UINT16 dupecheck; deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes - if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword))) + dupecheck = R_GetColorByName(truncword); + if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || dupecheck && dupecheck != num)) { size_t lastchar = strlen(truncword); char oldword[lastchar+1]; @@ -4726,11 +4728,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_skincolor(word2); // find a skincolor by name - if (i < numskincolors && i >= (INT32)SKINCOLOR_FIRSTFREESLOT) + if (i && i < numskincolors) readskincolor(f, i); else { - deh_warning("Skincolor %d out of range (%d - %d)", i, SKINCOLOR_FIRSTFREESLOT, numskincolors-1); + deh_warning("Skincolor %d out of range (1 - %d)", i, numskincolors-1); ignorelines(f); } } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index a7fee8b03..830d97625 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1569,8 +1569,13 @@ static int lib_setSkinColor(lua_State *L) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (i == 5 || (str && fastcmp(str,"chatcolor"))) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); - else if (i == 6 || (str && fastcmp(str,"accessible"))) - info->accessible = lua_toboolean(L, 3); + else if (i == 6 || (str && fastcmp(str,"accessible"))) { + boolean v = lua_toboolean(L, 3); + if (cnum < FIRSTSUPERCOLOR && v != skincolors[cnum].accessible) + return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", cnum); + else + info->accessible = v; + } lua_pop(L, 1); } return 0; @@ -1655,9 +1660,13 @@ static int skincolor_set(lua_State *L) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"accessible")) - info->accessible = lua_toboolean(L, 3); - else + else if (fastcmp(field,"accessible")) { + boolean v = lua_toboolean(L, 3); + if (cnum < FIRSTSUPERCOLOR && v != skincolors[cnum].accessible) + return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", cnum); + else + info->accessible = v; + } else CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); return 1; } From 242e128aa0e8e68d9ef34684cdeb48ef2fb9e02d Mon Sep 17 00:00:00 2001 From: lachwright Date: Tue, 21 Jul 2020 03:50:26 +0800 Subject: [PATCH 20/28] Fix Super Sonic exploiting CA_FLOAT abilities --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 679f4064b..3d36521d8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5536,7 +5536,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) if ((!(gametyperules & GTR_TEAMFLAGS) || !player->gotflag) && !player->exiting) { - if (player->secondjump == 1 && player->charability != CA_DOUBLEJUMP) + if (player->secondjump == 1 && player->charability != CA_DOUBLEJUMP && player->charability != CA_THOK) { fixed_t potentialmomz; if (player->charability == CA_SLOWFALL) From 76702d6712c69f0efddc28d16c9b22a082aa03ce Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 20 Jul 2020 22:19:44 -0400 Subject: [PATCH 21/28] Fix crash if you start recording a replay and immediately close the game --- src/g_demo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 6c58f12fb..57a955cb1 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2382,9 +2382,12 @@ static void WriteDemoChecksum(void) static void G_StopDemoRecording(void) { boolean saved = false; - WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker - WriteDemoChecksum(); - saved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file. + if (demo_p) + { + WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker + WriteDemoChecksum(); + saved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file. + } free(demobuffer); demorecording = false; From 196beead7d3dc71203db5fd8e565db8d5c21244a Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 21 Jul 2020 16:16:03 -0700 Subject: [PATCH 22/28] Parenthesis --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 9a19833a9..a856ab352 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -812,7 +812,7 @@ static void readskincolor(MYFILE *f, INT32 num) deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes dupecheck = R_GetColorByName(truncword); - if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || dupecheck && dupecheck != num)) + if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || (dupecheck && dupecheck != num))) { size_t lastchar = strlen(truncword); char oldword[lastchar+1]; From 80172ee93214969cf446ceac5d66e1fb5f56b068 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 23 Jul 2020 18:24:41 +0300 Subject: [PATCH 23/28] Don't discard zero alpha fog block fragments. Fixes #198. --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 08d688e1d..2603abd46 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1535,7 +1535,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) // Sryder: Fog // multiplies input colour by input alpha, and destination colour by input colour, then adds them pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); + pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments break; default : // must be 0, otherwise it's an error // No blending From e4d6e92f37e9d9dcb6d21ea0ca5e57818dc1f2a8 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 23 Jul 2020 19:05:17 +0300 Subject: [PATCH 24/28] Clamp light level for shaders. Fixes #194. --- src/hardware/hw_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0d7404c77..127756a00 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -214,6 +214,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = min(max(light_level, 0), 255); + Surface->PolyColor.rgba = poly_color.rgba; Surface->TintColor.rgba = tint_color.rgba; Surface->FadeColor.rgba = fade_color.rgba; From e331c9d18e100b2b723918914ec8a97cfaeb6fa0 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Thu, 23 Jul 2020 20:51:05 +0300 Subject: [PATCH 25/28] Fix OpenGL polyobject texture distortion --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0d7404c77..0db7a2a4c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2757,8 +2757,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, HWR_SetCurrentTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)((polysector->origVerts[0].x & (~flatflag)) / fflatwidth); - flatyref = (float)((polysector->origVerts[0].y & (~flatflag)) / fflatheight); + flatxref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].x) & (~flatflag)) / fflatwidth); + flatyref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].y) & (~flatflag)) / fflatheight); // transform v3d = planeVerts; From 00943e9e82ff46a97a2bc1e3179ce47e53345cc3 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:32:10 -0700 Subject: [PATCH 26/28] Add missing GCC version flags to the Makefile --- src/Makefile.cfg | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 4a2c0687b..ef89a5b4b 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -12,11 +12,12 @@ # to avoid a false positive with the version detection... SUPPORTED_GCC_VERSIONS:=\ - 91\ - 81 82 83\ - 71 72\ + 101 102\ + 91 92 93\ + 81 82 83 84\ + 71 72 73 74 75\ 61 62 63 64\ - 51 52 53 54\ + 51 52 53 54 55\ 40 41 42 43 44 45 46 47 48 49 LATEST_GCC_VERSION=9.1 @@ -68,7 +69,27 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) endif endif +ifdef GCC102 +GCC101=1 +endif + +ifdef GCC101 +GCC93=1 +endif + +ifdef GCC93 +GCC92=1 +endif + +ifdef GCC92 +GCC91=1 +endif + ifdef GCC91 +GCC84=1 +endif + +ifdef GCC84 GCC83=1 endif @@ -81,6 +102,18 @@ GCC81=1 endif ifdef GCC81 +GCC75=1 +endif + +ifdef GCC75 +GCC74=1 +endif + +ifdef GCC74 +GCC73=1 +endif + +ifdef GCC73 GCC72=1 endif @@ -105,6 +138,10 @@ GCC61=1 endif ifdef GCC61 +GCC55=1 +endif + +ifdef GCC55 GCC54=1 endif From 4059c6a654a5785199cf0d6dd998bf113b57cd0f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:33:39 -0700 Subject: [PATCH 27/28] Update LATEST_GCC_VERSION too --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index ef89a5b4b..5c56978e7 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -20,7 +20,7 @@ SUPPORTED_GCC_VERSIONS:=\ 51 52 53 54 55\ 40 41 42 43 44 45 46 47 48 49 -LATEST_GCC_VERSION=9.1 +LATEST_GCC_VERSION=10.2 # gcc or g++ ifdef PREFIX From e47fbe7dd9c460b0ca8d88334f6a22e329cd10b3 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:58:05 -0700 Subject: [PATCH 28/28] Compiler error :V --- src/hardware/hw_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ac8eb213c..ab864f383 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2760,8 +2760,11 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, HWR_SetCurrentTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].x) & (~flatflag)) / fflatwidth); - flatyref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].y) & (~flatflag)) / fflatheight); + flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x); + flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y); + + flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatwidth); + flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatheight); // transform v3d = planeVerts;