From a4149cfe37749db4dc150982510f7d011b336c24 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Jan 2020 18:49:22 -0800 Subject: [PATCH 01/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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 288d7166bc5b1e708d26eb96e5fa1fe1a83248b2 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 15 May 2020 16:41:39 -0300 Subject: [PATCH 08/75] Fix ASTBlendPixel outputting empty pixels if the background pixel was empty, BUT if the foreground pixel had no alpha at all --- src/r_data.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 831e75bef..21f382845 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -244,7 +244,13 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph // if the background pixel is empty, match software and don't blend anything if (!background.s.alpha) - output.rgba = 0; + { + // ...unless the foreground pixel ISN'T actually translucent. + if (alpha == 0xFF) + output.rgba = foreground.rgba; + else + output.rgba = 0; + } else { UINT8 beta = (0xFF - alpha); From c64e231b2b196da7cb6ae67511365f4ade3a4bdb Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 16 May 2020 13:51:10 -0300 Subject: [PATCH 09/75] Attempt to properly match Software texture blending without messing with the original ASTBlendPixel function --- src/hardware/hw_cache.c | 16 ++++++++-------- src/r_data.c | 40 +++++++++++++++++++++++++++++++++++----- src/r_data.h | 5 ++++- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 059556f15..9109a6e53 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -135,7 +135,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm { case 2 : // uhhhhhhhh.......... if ((originPatch != NULL) && (originPatch->style != AST_COPY)) - texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha); + texel = ASTBlendPaletteIndexes(*(dest+1), texel, originPatch->style, originPatch->alpha); texelu16 = (UINT16)((alpha<<8) | texel); memcpy(dest, &texelu16, sizeof(UINT16)); break; @@ -144,7 +144,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm { RGBA_t rgbatexel; rgbatexel.rgba = *(UINT32 *)dest; - colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); } memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8)); break; @@ -154,14 +154,14 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm { RGBA_t rgbatexel; rgbatexel.rgba = *(UINT32 *)dest; - colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); } memcpy(dest, &colortemp, sizeof(RGBA_t)); break; // default is 1 default: if ((originPatch != NULL) && (originPatch->style != AST_COPY)) - *dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha); + *dest = ASTBlendPaletteIndexes(*dest, texel, originPatch->style, originPatch->alpha); else *dest = texel; break; @@ -247,7 +247,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, { case 2 : // uhhhhhhhh.......... if ((originPatch != NULL) && (originPatch->style != AST_COPY)) - texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha); + texel = ASTBlendPaletteIndexes(*(dest+1), texel, originPatch->style, originPatch->alpha); texelu16 = (UINT16)((alpha<<8) | texel); memcpy(dest, &texelu16, sizeof(UINT16)); break; @@ -256,7 +256,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, { RGBA_t rgbatexel; rgbatexel.rgba = *(UINT32 *)dest; - colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); } memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8)); break; @@ -266,14 +266,14 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, { RGBA_t rgbatexel; rgbatexel.rgba = *(UINT32 *)dest; - colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + colortemp.rgba = ASTBlendTexturePixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); } memcpy(dest, &colortemp, sizeof(RGBA_t)); break; // default is 1 default: if ((originPatch != NULL) && (originPatch->style != AST_COPY)) - *dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha); + *dest = ASTBlendPaletteIndexes(*dest, texel, originPatch->style, originPatch->alpha); else *dest = texel; break; diff --git a/src/r_data.c b/src/r_data.c index 21f382845..fc783ad17 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -227,6 +227,8 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex } } +// Blends two pixels together, using the equation +// that matches the specified alpha style. UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) { RGBA_t output; @@ -307,18 +309,46 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph return 0; } -UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha) +INT32 ASTTextureBlendingThreshold[2] = {255/11, (10*255/11)}; + +// Blends a pixel for a texture patch. +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) { // Alpha style set to translucent? if (style == AST_TRANSLUCENT) { // Is the alpha small enough for translucency? - if (alpha <= (10*255/11)) + if (alpha <= ASTTextureBlendingThreshold[1]) + { + // Is the patch way too translucent? Don't blend then. + if (alpha < ASTTextureBlendingThreshold[0]) + return background; + + return foreground; + } + else // just copy the pixel + return foreground; + } + else + return ASTBlendPixel(background, foreground, style, alpha); +} + +// Blends two palette indexes for a texture patch, then +// finds the nearest palette index from the blended output. +UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT8 alpha) +{ + // Alpha style set to translucent? + if (style == AST_TRANSLUCENT) + { + // Is the alpha small enough for translucency? + if (alpha <= ASTTextureBlendingThreshold[1]) { UINT8 *mytransmap; + // Is the patch way too translucent? Don't blend then. - if (alpha < 255/11) + if (alpha < ASTTextureBlendingThreshold[0]) return background; + // The equation's not exact but it works as intended. I'll call it a day for now. mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); if (background != 0xFF) @@ -383,7 +413,7 @@ static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpa { for (; dest < cache + position + count; source++, dest++) if (*source != 0xFF) - *dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha); + *dest = ASTBlendPaletteIndexes(*dest, *source, originPatch->style, originPatch->alpha); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); @@ -427,7 +457,7 @@ static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache { for (; dest < cache + position + count; --source, dest++) if (*source != 0xFF) - *dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha); + *dest = ASTBlendPaletteIndexes(*dest, *source, originPatch->style, originPatch->alpha); } patch = (column_t *)((UINT8 *)patch + patch->length + 4); diff --git a/src/r_data.h b/src/r_data.h index 78ce35a41..8b8d08c52 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -26,7 +26,10 @@ enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); -UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha); +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); +UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT8 alpha); + +extern INT32 ASTTextureBlendingThreshold[2]; UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b); From 423494381e9366d86b819e5a7c75c0a962444c1a Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sat, 16 May 2020 14:01:42 -0300 Subject: [PATCH 10/75] Fix mistake --- src/r_data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index fc783ad17..302d2ea57 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -322,12 +322,12 @@ UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UIN { // Is the patch way too translucent? Don't blend then. if (alpha < ASTTextureBlendingThreshold[0]) - return background; + return background.rgba; - return foreground; + return ASTBlendPixel(background, foreground, style, alpha); } else // just copy the pixel - return foreground; + return foreground.rgba; } else return ASTBlendPixel(background, foreground, style, alpha); From a449fa4a1d1337057e1ae4c305c623997301ddd8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 6 Jun 2020 22:05:25 -0400 Subject: [PATCH 11/75] Added SDL Mixer X to CMAKE (Windows only) --- src/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ src/sdl/CMakeLists.txt | 23 +++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a593bb1..840feb3fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -226,6 +226,12 @@ set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL "Enable GME support.") set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL "Enable OpenMPT support.") +if(${CMAKE_SYSTEM} MATCHES Windows) + set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL + "Enable SDL Mixer X support.") +else() + set(SRB2_CONFIG_HAVE_MIXERX OFF) +endif() set(SRB2_CONFIG_HWRENDER ON CACHE BOOL "Enable hardware rendering through OpenGL.") set(SRB2_CONFIG_USEASM OFF CACHE BOOL @@ -366,6 +372,30 @@ if(${SRB2_CONFIG_HAVE_OPENMPT}) endif() endif() +if(${SRB2_CONFIG_HAVE_MIXERX}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + set(MIXERX_FOUND ON) + set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext") + else() # 32-bit + set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext") + endif() + else() + # No support for non-Windows (yet?) + #find_package(MIXERX) + message(WARNING "SDL Mixer X is not supported as an external library.") + set(MIXERX_FOUND OFF) + endif() + if(${MIXERX_FOUND}) + set(SRB2_HAVE_MIXERX ON) + set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + add_definitions(-DHAVE_MIXERX) + else() + message(WARNING "You have specified that SDL Mixer X is available but it was not found.") + endif() +endif() + if(${SRB2_CONFIG_HAVE_ZLIB}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) set(ZLIB_FOUND ON) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 38d557a3f..d5a5fc950 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -1,6 +1,10 @@ # Declare SDL2 interface sources -set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") +if(NOT ${SRB2_CONFIG_HAVE_MIXERX}) + set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") +else() + set(SRB2_CONFIG_SDL2_USEMIXER OFF) +endif() if(${SRB2_CONFIG_SDL2_USEMIXER}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) @@ -22,6 +26,8 @@ if(${SRB2_CONFIG_SDL2_USEMIXER}) message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.") set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) endif() +elseif(${MIXERX_FOUND}) + set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) else() set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) endif() @@ -156,6 +162,7 @@ if(${SDL2_FOUND}) SDL2_mixer ${GME_LIBRARIES} ${OPENMPT_LIBRARIES} + ${MIXERX_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} @@ -167,6 +174,7 @@ if(${SDL2_FOUND}) ${SDL2_MIXER_LIBRARIES} ${GME_LIBRARIES} ${OPENMPT_LIBRARIES} + ${MIXERX_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} @@ -247,12 +255,13 @@ if(${SDL2_FOUND}) ${SDL2_MIXER_INCLUDE_DIRS} ${GME_INCLUDE_DIRS} ${OPENMPT_INCLUDE_DIRS} + ${MIXERX_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} ) - if(${SRB2_HAVE_MIXER}) + if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX})) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) endif() @@ -294,6 +303,7 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw + HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" @@ -301,6 +311,7 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw + HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin ) endif() else() @@ -310,6 +321,7 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw + HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" @@ -317,6 +329,7 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw + HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin ) endif() endif() @@ -340,6 +353,12 @@ if(${SDL2_FOUND}) if(${SRB2_CONFIG_HAVE_OPENMPT}) getwinlib(libopenmpt "libopenmpt.dll") endif() + if(${SRB2_CONFIG_HAVE_MIXERX}) + getwinlib(SDL2_mixer_ext "SDL2_mixer_ext.dll") + getwinlib(libfluidsynth-2 "libfluidsynth-2.dll") + getwinlib(libgcc_s_sjlj-1 "libgcc_s_sjlj-1.dll") + getwinlib(libstdc++-6 "libstdc++-6.dll") + endif() install(PROGRAMS ${win_extra_dll_list} From ded6285249bd994ee88a9b77cd88ec5f649525f9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 7 Jun 2020 18:35:33 -0400 Subject: [PATCH 12/75] CMAKE improvements: optional asset install; exe.debug for RelWithDebInfo --- CMakeLists.txt | 1 + assets/CMakeLists.txt | 32 +++++++++++++++++++++----------- src/sdl/CMakeLists.txt | 20 +++++++++++++++----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e46f5dc3..480baa7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,4 +131,5 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") +SET(CPACK_OUTPUT_FILE_PREFIX package) include(CPack) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 095349418..3ea7c28df 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -12,6 +12,9 @@ ENDFUNCTION(PREPEND) 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_INSTALL ON + CACHE BOOL "Insert asset files into the install directory or package.") + #################### # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list! #################### @@ -43,20 +46,27 @@ endforeach() if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION "${outname}.app/Contents/Resources" - ) + if(${SRB2_ASSET_INSTALL}) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" + DESTINATION "${outname}.app/Contents/Resources" + ) + endif() + # Always install the doc files, even in non-asset packages. install(FILES ${SRB2_ASSET_DOCS} DESTINATION . OPTIONAL ) else() - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION . - ) - # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again - #install(FILES ${SRB2_ASSET_DOCS} - # DESTINATION . - # OPTIONAL - #) + if(${SRB2_ASSET_INSTALL}) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" + DESTINATION . + ) + # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call. + else() + # Always install the doc files, even in non-asset packages. + install(FILES ${SRB2_ASSET_DOCS} + DESTINATION . + OPTIONAL + ) + endif() endif() diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index d5a5fc950..1e3d0f7a6 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -269,14 +269,18 @@ if(${SDL2_FOUND}) -DHAVE_SDL ) - ## strip debug symbols into separate file when using gcc - if(CMAKE_COMPILER_IS_GNUCC) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) + ## strip debug symbols into separate file when using gcc. + ## to be consistent with Makefile, don't generate for OS X. + if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin)) + if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) + if(${CMAKE_BUILD_TYPE} MATCHES Debug) + set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug") + endif() message(STATUS "Will make separate debug symbols in *.debug") add_custom_command(TARGET SRB2SDL2 POST_BUILD - COMMAND ${OBJCOPY} --only-keep-debug $ $.debug + COMMAND ${OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $ $.debug COMMAND ${OBJCOPY} --strip-debug $ - COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ + COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ ) endif() endif() @@ -290,6 +294,12 @@ if(${SDL2_FOUND}) install(TARGETS SRB2SDL2 SRB2SDL2 RUNTIME DESTINATION . ) + if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) + install(FILES $.debug + DESTINATION . + OPTIONAL + ) + endif() endif() if(${CMAKE_SYSTEM} MATCHES Windows) From c63ead5abb4afd9b55edf18c75a78757404c30d9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 7 Jun 2020 20:27:18 -0400 Subject: [PATCH 13/75] CMAKE: Configurable CPACK generator --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 480baa7ef..dc92de90c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,16 +113,19 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINAR ##### PACKAGE CONFIGURATION ##### -if(${CMAKE_SYSTEM} MATCHES "Windows") - set(CPACK_GENERATOR "ZIP") -endif() -if(${CMAKE_SYSTEM} MATCHES "Linux") - set(CPACK_GENERATOR "TGZ") -endif() -if(${CMAKE_SYSTEM} MATCHES "Darwin") - set(CPACK_GENERATOR "DragNDrop") +set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.") + +if("${SRB2_CPACK_GENERATOR}" STREQUAL "") + if(${CMAKE_SYSTEM} MATCHES "Windows") + set(SRB2_CPACK_GENERATOR "ZIP") + elseif(${CMAKE_SYSTEM} MATCHES "Linux") + set(SRB2_CPACK_GENERATOR "TGZ") + elseif(${CMAKE_SYSTEM} MATCHES "Darwin") + set(SRB2_CPACK_GENERATOR "TGZ") + endif() endif() +set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR}) 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 ) From aef9a1b522ebdad2a2c1b977389091e136c60e05 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 7 Jun 2020 20:41:43 -0400 Subject: [PATCH 14/75] CMAKE: Add CCACHE support --- CMakeLists.txt | 17 +++++++++++++++++ launch-c.in | 3 +++ launch-cxx.in | 3 +++ src/CMakeLists.txt | 21 +++++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 launch-c.in create mode 100644 launch-cxx.in diff --git a/CMakeLists.txt b/CMakeLists.txt index dc92de90c..495da101e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,17 @@ cmake_minimum_required(VERSION 3.0) + +# Enable CCache early +set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache") +if (${SRB2_USE_CCACHE}) + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + message(STATUS "Found CCache: ${CCACHE_PROGRAM}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") + else() + message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.") + endif() +endif() + # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 @@ -9,6 +22,10 @@ if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") endif() +if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang")) + message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.") +endif() + # Set up CMAKE path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") diff --git a/launch-c.in b/launch-c.in new file mode 100644 index 000000000..c60558232 --- /dev/null +++ b/launch-c.in @@ -0,0 +1,3 @@ +#!/bin/sh +export CCACHE_CPP2=true +exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@" diff --git a/launch-cxx.in b/launch-cxx.in new file mode 100644 index 000000000..c60558232 --- /dev/null +++ b/launch-cxx.in @@ -0,0 +1,3 @@ +#!/bin/sh +export CCACHE_CPP2=true +exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 840feb3fa..fda3f2e7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -523,6 +523,27 @@ endif() # Targets +# If using CCACHE, then force it. +# https://github.com/Cockatrice/Cockatrice/pull/3052/files +if (${CMAKE_SYSTEM} MATCHES "Darwin") + get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + if(RULE_LAUNCH_COMPILE) + MESSAGE(STATUS "Force enabling CCache usage under macOS") + # Set up wrapper scripts + configure_file(${CMAKE_MODULE_PATH}/launch-c.in launch-c) + configure_file(${CMAKE_MODULE_PATH}/launch-cxx.in launch-cxx) + execute_process(COMMAND chmod a+rx + "${CMAKE_BINARY_DIR}/launch-c" + "${CMAKE_BINARY_DIR}/launch-cxx") + + # Set Xcode project attributes to route compilation through our scripts + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") + set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") + set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") + endif() +endif() + # Compatibility flag with later versions of GCC # We should really fix our code to not need this if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") From efba50c83c73ac770851c2c12b1a26e0df6f8511 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 7 Jun 2020 23:57:15 -0400 Subject: [PATCH 15/75] CMAKE: Add SRB2_DEBUG_INSTALL to toggle *.debug in install/package --- src/sdl/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 1e3d0f7a6..481f1a426 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -295,10 +295,13 @@ if(${SDL2_FOUND}) RUNTIME DESTINATION . ) if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo)) - install(FILES $.debug - DESTINATION . - OPTIONAL - ) + set(SRB2_DEBUG_INSTALL OFF CACHE BOOL "Insert *.debug file into the install directory or package.") + if (${SRB2_DEBUG_INSTALL}) + install(FILES $.debug + DESTINATION . + OPTIONAL + ) + endif() endif() endif() From f3c1db06509323aa212fbc36fe0449f27fed16ab Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 8 Jun 2020 03:08:58 -0400 Subject: [PATCH 16/75] CMAKE: Fix OSX CCache error --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fda3f2e7e..86adcb5e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -530,8 +530,8 @@ if (${CMAKE_SYSTEM} MATCHES "Darwin") if(RULE_LAUNCH_COMPILE) MESSAGE(STATUS "Force enabling CCache usage under macOS") # Set up wrapper scripts - configure_file(${CMAKE_MODULE_PATH}/launch-c.in launch-c) - configure_file(${CMAKE_MODULE_PATH}/launch-cxx.in launch-cxx) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-c.in launch-c) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-cxx.in launch-cxx) execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") From 36e17006b7bf769d6b3a23015e13b34ead1fa386 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 9 Jun 2020 11:11:40 -0400 Subject: [PATCH 17/75] CMAKE: Fix OS X ccache scripts --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86adcb5e5..1da86d0ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -530,8 +530,8 @@ if (${CMAKE_SYSTEM} MATCHES "Darwin") if(RULE_LAUNCH_COMPILE) MESSAGE(STATUS "Force enabling CCache usage under macOS") # Set up wrapper scripts - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-c.in launch-c) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-cxx.in launch-cxx) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-c.in ${CMAKE_BINARY_DIR}/launch-c) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx) execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") From 46b383acda4e4e5b04afb8f1315800b837a5bc9f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 9 Jun 2020 17:31:49 -0400 Subject: [PATCH 18/75] CMAKE: Fix toggle fullscreen breakage due to missing define This is lazy. The correct solution is to eliminate the define in the program code --- src/sdl/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 481f1a426..744b242fa 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -266,7 +266,7 @@ if(${SDL2_FOUND}) endif() target_compile_definitions(SRB2SDL2 PRIVATE - -DHAVE_SDL + -DDDIRECTFULLSCREEN -DHAVE_SDL ) ## strip debug symbols into separate file when using gcc. From 8fc414536f5923e9f7f36cb2ab3e485fee0307d0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 10 Jun 2020 15:07:41 -0400 Subject: [PATCH 19/75] CMAKE: Move launch-c into more sensible location --- launch-c.in => cmake/launch-c.in | 0 launch-cxx.in => cmake/launch-cxx.in | 0 src/CMakeLists.txt | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename launch-c.in => cmake/launch-c.in (100%) rename launch-cxx.in => cmake/launch-cxx.in (100%) diff --git a/launch-c.in b/cmake/launch-c.in similarity index 100% rename from launch-c.in rename to cmake/launch-c.in diff --git a/launch-cxx.in b/cmake/launch-cxx.in similarity index 100% rename from launch-cxx.in rename to cmake/launch-cxx.in diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1da86d0ae..16063fe2e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -530,8 +530,8 @@ if (${CMAKE_SYSTEM} MATCHES "Darwin") if(RULE_LAUNCH_COMPILE) MESSAGE(STATUS "Force enabling CCache usage under macOS") # Set up wrapper scripts - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-c.in ${CMAKE_BINARY_DIR}/launch-c) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx) execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") From 864e7033552cbb966f378cfbaf56aa116c1f97e8 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Jun 2020 13:03:19 -0700 Subject: [PATCH 20/75] 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 21/75] 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 22/75] 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 b29873ce1c6c6b492da530ec0184243f9a8afa16 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 27 Jun 2020 17:22:00 +0300 Subject: [PATCH 23/75] Better MF2_LINKDRAW support for OpenGL --- src/hardware/hw_glob.h | 1 + src/hardware/hw_main.c | 197 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 188 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index d8ea7c7a3..8efa5a1f8 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -63,6 +63,7 @@ typedef struct gr_vissprite_s { float x1, x2; float tz, ty; + float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting //lumpnum_t patchlumpnum; GLPatch_t *gpatch; boolean flip; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 455985ddf..c24af0043 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3501,6 +3501,54 @@ static gr_vissprite_t *HWR_NewVisSprite(void) return HWR_GetVisSprite(gr_visspritecount++); } +// A hack solution for transparent surfaces appearing on top of linkdraw sprites. +// Keep a list of linkdraw sprites and draw their shapes to the z-buffer after all other +// sprite drawing is done. (effectively the z-buffer drawing of linkdraw sprites is delayed) +// NOTE: This will no longer be necessary once full translucent sorting is implemented, where +// translucent sprites and surfaces are sorted together. + +typedef struct +{ + FOutVector verts[4]; + gr_vissprite_t *spr; +} zbuffersprite_t; + +// this list is used to store data about linkdraw sprites +zbuffersprite_t linkdrawlist[MAXVISSPRITES]; +UINT32 linkdrawcount = 0; + +// add the necessary data to the list for delayed z-buffer drawing +static void HWR_LinkDrawHackAdd(FOutVector *verts, gr_vissprite_t *spr) +{ + if (linkdrawcount < MAXVISSPRITES) + { + memcpy(linkdrawlist[linkdrawcount].verts, verts, sizeof(FOutVector) * 4); + linkdrawlist[linkdrawcount].spr = spr; + linkdrawcount++; + } +} + +// process and clear the list of sprites for delayed z-buffer drawing +static void HWR_LinkDrawHackFinish(void) +{ + UINT32 i; + FSurfaceInfo surf; + surf.PolyColor.rgba = 0xFFFFFFFF; + surf.TintColor.rgba = 0xFFFFFFFF; + surf.FadeColor.rgba = 0xFFFFFFFF; + surf.LightInfo.light_level = 0; + surf.LightInfo.fade_start = 0; + surf.LightInfo.fade_end = 31; + for (i = 0; i < linkdrawcount; i++) + { + // draw sprite shape, only to z-buffer + HWR_GetPatch(linkdrawlist[i].spr->gpatch); + HWR_ProcessPolygon(&surf, linkdrawlist[i].verts, 4, PF_Translucent|PF_Occlude|PF_Invisible|PF_Clip, 0, false); + } + // reset list + linkdrawcount = 0; +} + // // HWR_DoCulling // Hardware version of R_DoCulling @@ -3687,6 +3735,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) extracolormap_t *colormap; FUINT lightlevel; FBITFIELD blend = 0; + FBITFIELD occlusion; + boolean use_linkdraw_hack = false; UINT8 alpha; INT32 i; @@ -3780,10 +3830,18 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // co-ordinates memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) + // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. + if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + occlusion = 0; + else + occlusion = PF_Occlude; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = PF_Translucent|occlusion; + if (!occlusion) use_linkdraw_hack = true; } else if (spr->mobj->flags2 & MF2_SHADOW) { @@ -3799,7 +3857,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = PF_Translucent|occlusion; + if (!occlusion) use_linkdraw_hack = true; } alpha = Surf.PolyColor.s.alpha; @@ -3904,6 +3963,9 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + if (use_linkdraw_hack) + HWR_LinkDrawHackAdd(wallVerts, spr); + top = bot; endtop = endbot; } @@ -3929,6 +3991,9 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) Surf.PolyColor.s.alpha = alpha; HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + + if (use_linkdraw_hack) + HWR_LinkDrawHackAdd(wallVerts, spr); } // -----------------+ @@ -4051,10 +4116,21 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) { FBITFIELD blend = 0; + FBITFIELD occlusion; + boolean use_linkdraw_hack = false; + + // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) + // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. + if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + occlusion = 0; + else + occlusion = PF_Occlude; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = PF_Translucent|occlusion; + if (!occlusion) use_linkdraw_hack = true; } else if (spr->mobj->flags2 & MF2_SHADOW) { @@ -4070,10 +4146,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = PF_Translucent|occlusion; + if (!occlusion) use_linkdraw_hack = true; } HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, 3, false); // sprite shader + + if (use_linkdraw_hack) + HWR_LinkDrawHackAdd(wallVerts, spr); } } @@ -4189,6 +4269,7 @@ static int CompareVisSprites(const void *p1, const void *p2) gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2; int idiff; float fdiff; + float tz1, tz2; // Make transparent sprites last. Comment from the previous sort implementation: // Sryder: Oh boy, while it's nice having ALL the sprites sorted properly, it fails when we bring MD2's into the @@ -4196,12 +4277,52 @@ static int CompareVisSprites(const void *p1, const void *p2) // everything else, but still ordered of course, the depth buffer can handle the opaque ones plenty fine. // We just need to move all translucent ones to the end in order // TODO: Fully sort all sprites and MD2s with walls and floors, this part will be unnecessary after that - int transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); - int transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + int transparency1; + int transparency2; + + int linkdraw1 = (spr1->mobj->flags2 & MF2_LINKDRAW) && spr1->mobj->tracer; + int linkdraw2 = (spr2->mobj->flags2 & MF2_LINKDRAW) && spr2->mobj->tracer; + + // ^ is the XOR operation + // if comparing a linkdraw and non-linkdraw sprite or 2 linkdraw sprites with different tracers, then use + // the tracer's properties instead of the main sprite's. + if ((linkdraw1 && linkdraw2 && spr1->mobj->tracer != spr2->mobj->tracer) || (linkdraw1 ^ linkdraw2)) + { + if (linkdraw1) + { + tz1 = spr1->tracertz; + transparency1 = (spr1->mobj->tracer->flags2 & MF2_SHADOW) || (spr1->mobj->tracer->frame & FF_TRANSMASK); + } + else + { + tz1 = spr1->tz; + transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); + } + if (linkdraw2) + { + tz2 = spr2->tracertz; + transparency2 = (spr2->mobj->tracer->flags2 & MF2_SHADOW) || (spr2->mobj->tracer->frame & FF_TRANSMASK); + } + else + { + tz2 = spr2->tz; + transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + } + } + else + { + tz1 = spr1->tz; + transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); + tz2 = spr2->tz; + transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + } + + // first compare transparency flags, then compare tz, then compare dispoffset + idiff = transparency1 - transparency2; if (idiff != 0) return idiff; - fdiff = spr2->tz - spr1->tz; // this order seems correct when checking with apitrace. Back to front. + fdiff = tz2 - tz1; // this order seems correct when checking with apitrace. Back to front. if (fabsf(fdiff) < 1.0E-36f) return spr1->dispoffset - spr2->dispoffset; // smallest dispoffset first if sprites are at (almost) same location. else if (fdiff > 0) @@ -4525,6 +4646,7 @@ static void HWR_CreateDrawNodes(void) static void HWR_DrawSprites(void) { UINT32 i; + boolean skipshadow = false; // skip shadow if it was drawn already for a linkdraw sprite encountered earlier in the list HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value); for (i = 0; i < gr_visspritecount; i++) { @@ -4535,11 +4657,32 @@ static void HWR_DrawSprites(void) else #endif { - if (spr->mobj && spr->mobj->shadowscale && cv_shadow.value) + if (spr->mobj && spr->mobj->shadowscale && cv_shadow.value && !skipshadow) { HWR_DrawDropShadow(spr->mobj, spr->mobj->shadowscale); } + if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + { + // If this linkdraw sprite is behind a sprite that has a shadow, + // then that shadow has to be drawn first, otherwise the shadow ends up on top of + // the linkdraw sprite because the linkdraw sprite does not modify the z-buffer. + // The !skipshadow check is there in case there are multiple linkdraw sprites connected + // to the same tracer, so the tracer's shadow only gets drawn once. + if (cv_shadow.value && !skipshadow && spr->dispoffset < 0 && spr->mobj->tracer->shadowscale) + { + HWR_DrawDropShadow(spr->mobj->tracer, spr->mobj->tracer->shadowscale); + skipshadow = true; + // The next sprite in this loop should be either another linkdraw sprite or the tracer. + // When the tracer is inevitably encountered, skipshadow will cause it's shadow + // to get skipped and skipshadow will get set to false by the 'else' clause below. + } + } + else + { + skipshadow = false; + } + if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { if (!cv_grmodels.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) @@ -4563,6 +4706,16 @@ static void HWR_DrawSprites(void) } } HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, 0); + + // At the end of sprite drawing, draw shapes of linkdraw sprites to z-buffer, so they + // don't get drawn over by transparent surfaces. + HWR_LinkDrawHackFinish(); + // Work around a r_opengl.c bug with PF_Invisible by making this SetBlend call + // where PF_Invisible is off and PF_Masked is on. + // (Other states probably don't matter. Here I left them same as in LinkDrawHackFinish) + // Without this workaround the rest of the draw calls in this frame (including UI, screen texture) + // can get drawn using an incorrect glBlendFunc, resulting in a occasional black screen. + HWD.pfnSetBlend(PF_Translucent|PF_Occlude|PF_Clip|PF_Masked); } // -------------------------------------------------------------------------- @@ -4624,6 +4777,7 @@ static void HWR_ProjectSprite(mobj_t *thing) gr_vissprite_t *vis; float tr_x, tr_y; float tz; + float tracertz = 0.0f; float x1, x2; float rightsin, rightcos; float this_scale; @@ -4636,6 +4790,7 @@ static void HWR_ProjectSprite(mobj_t *thing) unsigned rot; UINT16 flip; boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); + INT32 dispoffset; angle_t ang; INT32 heightsec, phs; @@ -4653,6 +4808,8 @@ static void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; + dispoffset = thing->info->dispoffset; + this_scale = FIXED_TO_FLOAT(thing->scale); // transform the origin point @@ -4861,9 +5018,28 @@ static void HWR_ProjectSprite(mobj_t *thing) if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) { - // bodge support - not nearly as comprehensive as r_things.c, but better than nothing if (! R_ThingVisible(thing->tracer)) return; + + // calculate tz for tracer, same way it is calculated for this sprite + // transform the origin point + tr_x = FIXED_TO_FLOAT(thing->tracer->x) - gr_viewx; + tr_y = FIXED_TO_FLOAT(thing->tracer->y) - gr_viewy; + + // rotation around vertical axis + tracertz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); + + // Software does not render the linkdraw sprite if the tracer is behind the view plane, + // so do the same check here. + // NOTE: This check has the same flaw as the view plane check at the beginning of HWR_ProjectSprite: + // the view aiming angle is not taken into account, leading to sprites disappearing too early when they + // can still be seen when looking down/up at steep angles. + if (tracertz < ZCLIP_PLANE) + return; + + // if the sprite is behind the tracer, invert dispoffset, putting the sprite behind the tracer + if (tz > tracertz) + dispoffset *= -1; } // store information in a vissprite @@ -4871,7 +5047,8 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->x1 = x1; vis->x2 = x2; vis->tz = tz; // Keep tz for the simple sprite sorting that happens - vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST + vis->tracertz = tracertz; + vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST //vis->patchlumpnum = sprframe->lumppat[rot]; #ifdef ROTSPRITE if (rotsprite) From abeedc4b651546bbc245e2430df4664210354d97 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 00:27:34 -0300 Subject: [PATCH 24/75] Delete hw_glide.h --- src/CMakeLists.txt | 1 - src/Makefile | 8 ++-- src/hardware/hw_data.h | 23 ++++++++++- src/hardware/hw_glide.h | 41 ------------------- src/sdl/Srb2SDL-vc10.vcxproj | 1 - src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 -- src/sdl/Srb2SDL-vc9.vcproj | 4 -- src/sdl/Srb2SDL.dsp | 26 +++++------- src/sdl/macosx/Srb2mac.pbproj/project.pbxproj | 7 ---- .../macosx/Srb2mac.xcodeproj/project.pbxproj | 2 - src/win32/Srb2win-vc10.vcxproj | 1 - src/win32/Srb2win-vc10.vcxproj.filters | 3 -- src/win32/Srb2win-vc9.vcproj | 4 -- src/win32/Srb2win.dsp | 26 +++++------- 14 files changed, 47 insertions(+), 103 deletions(-) delete mode 100644 src/hardware/hw_glide.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a3f0564d..fa7f235a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -440,7 +440,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glide.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h diff --git a/src/Makefile b/src/Makefile index e00c84bc9..4bf158d78 100644 --- a/src/Makefile +++ b/src/Makefile @@ -645,7 +645,7 @@ ifdef SDL ifdef MINGW $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ + command.h hardware/hw_data.h hardware/hw_defs.h \ hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ @@ -654,7 +654,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h else $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ + command.h hardware/hw_data.h hardware/hw_defs.h \ hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ @@ -732,7 +732,7 @@ ifndef SDL ifndef NOHW $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ + command.h hardware/hw_data.h hardware/hw_defs.h \ hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ @@ -741,7 +741,7 @@ $(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h $(OBJDIR)/ogl_win.o: hardware/r_opengl/ogl_win.c hardware/r_opengl/r_opengl.h \ doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_glide.h hardware/hw_defs.h \ + command.h hardware/hw_data.h hardware/hw_defs.h \ hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 686d522a0..6dc26948f 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -20,8 +20,6 @@ #endif #include "../doomdef.h" -//THIS MUST DISAPPEAR!!! -#include "hw_glide.h" #include "../screen.h" @@ -29,6 +27,27 @@ // TEXTURE INFO // ========================================================================== +typedef unsigned long FxU32; +typedef long FxI32; + +typedef FxI32 GrTextureFormat_t; +#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */ +#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */ +#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 +#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */ +#define GR_TEXFMT_RGB_565 0xa +#define GR_TEXFMT_ARGB_1555 0xb +#define GR_TEXFMT_ARGB_4444 0xc +#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd +#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ +#define GR_RGBA 0x6 // 32 bit RGBA ! + +typedef struct +{ + GrTextureFormat_t format; + void *data; +} GrTexInfo; + // grInfo.data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s diff --git a/src/hardware/hw_glide.h b/src/hardware/hw_glide.h deleted file mode 100644 index d0eeebaeb..000000000 --- a/src/hardware/hw_glide.h +++ /dev/null @@ -1,41 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file hw_glide.h -/// \brief Declaration needed by Glide renderer -/// !!! To be replaced by our own def in the future !!! - -#ifndef _GLIDE_H_ -#define _GLIDE_H_ - -#ifndef __GLIDE_H__ - -typedef unsigned long FxU32; -typedef long FxI32; - -typedef FxI32 GrTextureFormat_t; -#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */ -#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */ -#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 -#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */ -#define GR_TEXFMT_RGB_565 0xa -#define GR_TEXFMT_ARGB_1555 0xb -#define GR_TEXFMT_ARGB_4444 0xc -#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd -#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ -#define GR_RGBA 0x6 // 32 bit RGBA ! - -typedef struct -{ - GrTextureFormat_t format; - void *data; -} GrTexInfo; - -#endif // __GLIDE_H__ (defined in ) - -#endif // _GLIDE_H_ diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index c24104b92..beaed6a3b 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -226,7 +226,6 @@ - diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 2f0aec7ca..80af94b65 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -237,9 +237,6 @@ Hw_Hardware - - Hw_Hardware - Hw_Hardware diff --git a/src/sdl/Srb2SDL-vc9.vcproj b/src/sdl/Srb2SDL-vc9.vcproj index 9ef4301cc..d407b2884 100644 --- a/src/sdl/Srb2SDL-vc9.vcproj +++ b/src/sdl/Srb2SDL-vc9.vcproj @@ -2410,10 +2410,6 @@ RelativePath="..\hardware\hw_drv.h" > - - diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index 879113ca2..ce35e2e23 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -7,19 +7,19 @@ CFG=Srb2SDL - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "Srb2SDL.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "Srb2SDL.mak" CFG="Srb2SDL - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "Srb2SDL - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "Srb2SDL - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -85,7 +85,7 @@ LINK32=link.exe # ADD LINK32 SDL.lib SDL_mixer.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /pdb:"C:\srb2demo2\srb2sdldebug.pdb" /debug /machine:I386 /out:"C:\srb2demo2\srb2sdldebug.exe" /pdbtype:sept # SUBTRACT LINK32 /pdb:none -!ENDIF +!ENDIF # Begin Target @@ -213,7 +213,7 @@ SOURCE=.\SDL_main\SDL_win32_main.c # PROP Exclude_From_Build 1 -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -274,7 +274,7 @@ InputName=tmap # End Custom Build -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -308,7 +308,7 @@ InputName=tmap_mmx # End Custom Build -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -339,7 +339,7 @@ InputName=tmap_vc # End Custom Build -!ENDIF +!ENDIF # End Source File # End Group @@ -576,10 +576,6 @@ SOURCE=..\hardware\hw_drv.h # End Source File # Begin Source File -SOURCE=..\hardware\hw_glide.h -# End Source File -# Begin Source File - SOURCE=..\hardware\hw_glob.h # End Source File # Begin Source File diff --git a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj index de12201f5..ee0bf4697 100644 --- a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj @@ -1064,13 +1064,6 @@ path = ../../hardware/hw_drv.h; refType = 2; }; - 8417773B085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_glide.h; - path = ../../hardware/hw_glide.h; - refType = 2; - }; 8417773C085A106C000C01D8 = { fileEncoding = 30; isa = PBXFileReference; diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index 745513eeb..f4d7fdd86 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -181,7 +181,6 @@ 1E44AE640B67CC2B00BAD059 /* hw_cache.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_cache.c; path = ../../hardware/hw_cache.c; sourceTree = SOURCE_ROOT; }; 1E44AE650B67CC2B00BAD059 /* hw_dll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_dll.h; path = ../../hardware/hw_dll.h; sourceTree = SOURCE_ROOT; }; 1E44AE660B67CC2B00BAD059 /* hw_drv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_drv.h; path = ../../hardware/hw_drv.h; sourceTree = SOURCE_ROOT; }; - 1E44AE670B67CC2B00BAD059 /* hw_glide.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_glide.h; path = ../../hardware/hw_glide.h; sourceTree = SOURCE_ROOT; }; 1E44AE680B67CC2B00BAD059 /* hw_light.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_light.c; path = ../../hardware/hw_light.c; sourceTree = SOURCE_ROOT; }; 1E44AE690B67CC2B00BAD059 /* hw_light.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_light.h; path = ../../hardware/hw_light.h; sourceTree = SOURCE_ROOT; }; 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3sound.h; path = ../../hardware/hw3sound.h; sourceTree = SOURCE_ROOT; }; @@ -535,7 +534,6 @@ 1E44AE640B67CC2B00BAD059 /* hw_cache.c */, 1E44AE650B67CC2B00BAD059 /* hw_dll.h */, 1E44AE660B67CC2B00BAD059 /* hw_drv.h */, - 1E44AE670B67CC2B00BAD059 /* hw_glide.h */, 1E44AE680B67CC2B00BAD059 /* hw_light.c */, 1E44AE690B67CC2B00BAD059 /* hw_light.h */, 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */, diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj index 387d65da9..72636d60d 100644 --- a/src/win32/Srb2win-vc10.vcxproj +++ b/src/win32/Srb2win-vc10.vcxproj @@ -399,7 +399,6 @@ - diff --git a/src/win32/Srb2win-vc10.vcxproj.filters b/src/win32/Srb2win-vc10.vcxproj.filters index 2f380c473..a46eb1e2e 100644 --- a/src/win32/Srb2win-vc10.vcxproj.filters +++ b/src/win32/Srb2win-vc10.vcxproj.filters @@ -516,9 +516,6 @@ Hw_Hardware - - Hw_Hardware - Hw_Hardware diff --git a/src/win32/Srb2win-vc9.vcproj b/src/win32/Srb2win-vc9.vcproj index 4c17bb6f7..e216212f8 100644 --- a/src/win32/Srb2win-vc9.vcproj +++ b/src/win32/Srb2win-vc9.vcproj @@ -2151,10 +2151,6 @@ RelativePath="..\hardware\hw_drv.h" > - - diff --git a/src/win32/Srb2win.dsp b/src/win32/Srb2win.dsp index 501bd26b8..c52873f7b 100644 --- a/src/win32/Srb2win.dsp +++ b/src/win32/Srb2win.dsp @@ -7,19 +7,19 @@ CFG=Srb2win - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "Srb2win.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "Srb2win.mak" CFG="Srb2win - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "Srb2win - Win32 Release" (based on "Win32 (x86) Application") !MESSAGE "Srb2win - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -84,7 +84,7 @@ LINK32=link.exe # ADD LINK32 dxguid.lib user32.lib gdi32.lib winmm.lib advapi32.lib ws2_32.lib dinput.lib /nologo /subsystem:windows /profile /debug /machine:I386 /out:"C:\srb2demo2\srb2debug.exe" # SUBTRACT LINK32 /nodefaultlib -!ENDIF +!ENDIF # Begin Target @@ -148,7 +148,7 @@ SOURCE=.\Srb2win.rc !ELSEIF "$(CFG)" == "Srb2win - Win32 Debug" -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -233,7 +233,7 @@ InputName=tmap # End Custom Build -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -266,7 +266,7 @@ InputName=tmap_mmx # End Custom Build -!ENDIF +!ENDIF # End Source File # Begin Source File @@ -298,7 +298,7 @@ InputName=tmap_vc # End Custom Build -!ENDIF +!ENDIF # End Source File # End Group @@ -535,10 +535,6 @@ SOURCE=..\hardware\hw_drv.h # End Source File # Begin Source File -SOURCE=..\hardware\hw_glide.h -# End Source File -# Begin Source File - SOURCE=..\hardware\hw_glob.h # End Source File # Begin Source File From ac04853f8c1aedde657885cfa9c8f6fb495c6c7e Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 00:35:48 -0300 Subject: [PATCH 25/75] Remove GrTexInfo --- src/hardware/hw_cache.c | 92 ++++++++++++++++---------------- src/hardware/hw_data.h | 13 ++--- src/hardware/hw_light.c | 8 +-- src/hardware/hw_main.c | 16 +++--- src/hardware/hw_md2.c | 62 ++++++++++----------- src/hardware/r_opengl/r_opengl.c | 30 +++++------ src/r_patch.c | 6 +-- src/w_wad.c | 4 +- 8 files changed, 114 insertions(+), 117 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index ab9a50dd5..1e63acf78 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -292,7 +292,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, fixed_t xfrac, xfracstep; fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = mipmap->grInfo.data; + UINT8 *block = mipmap->data; INT32 bpp; INT32 blockmodulo; @@ -307,7 +307,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, yfracstep = FRACUNIT; scale_y = FRACUNIT; - bpp = format2bpp[mipmap->grInfo.format]; + bpp = format2bpp[mipmap->format]; if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); @@ -339,7 +339,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, fixed_t xfrac, xfracstep; fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = mipmap->grInfo.data; + UINT8 *block = mipmap->data; INT32 bpp; INT32 blockmodulo; INT32 width, height; @@ -400,7 +400,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, yfracstep = (texture->height<< FRACBITS) / pblockheight; scale_y = (pblockheight << FRACBITS) / texture->height; - bpp = format2bpp[mipmap->grInfo.format]; + bpp = format2bpp[mipmap->format]; if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); @@ -431,8 +431,8 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX); INT32 blocksize = (grMipmap->width * grMipmap->height); - bpp = format2bpp[grMipmap->grInfo.format]; - block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data)); + bpp = format2bpp[grMipmap->format]; + block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data)); switch (bpp) { @@ -483,7 +483,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.width = (UINT16)texture->width; grtex->mipmap.height = (UINT16)texture->height; - grtex->mipmap.grInfo.format = textureformat; + grtex->mipmap.format = textureformat; blockwidth = texture->width; blockheight = texture->height; @@ -537,7 +537,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) Z_Unlock(realpatch); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( - if (format2bpp[grtex->mipmap.grInfo.format]==4) + if (format2bpp[grtex->mipmap.format]==4) { for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp { @@ -581,15 +581,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // no wrap around, no chroma key grMipmap->flags = 0; // setup the texture info - grMipmap->grInfo.format = patchformat; + grMipmap->format = patchformat; //grPatch->max_s = grPatch->max_t = 1.0f; grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; } - Z_Free(grMipmap->grInfo.data); - grMipmap->grInfo.data = NULL; + Z_Free(grMipmap->data); + grMipmap->data = NULL; if (makebitmap) { @@ -648,9 +648,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. - if (next->grInfo.data) - Z_Free(next->grInfo.data); - next->grInfo.data = NULL; + if (next->data) + Z_Free(next->data); + next->data = NULL; // Free the old colormap mipmap from memory. free(next); @@ -736,17 +736,17 @@ GLTexture_t *HWR_GetTexture(INT32 tex) grtex = &gr_textures[tex]; // Generate texture if missing from the cache - if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) + if (!grtex->mipmap.data && !grtex->mipmap.downloaded) HWR_GenerateTexture(tex, grtex); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. - Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED); return grtex; } @@ -756,7 +756,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) size_t size, pflatsize; // setup the texture info - grMipmap->grInfo.format = GR_TEXFMT_P_8; + grMipmap->format = GR_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; size = W_LumpLength(flatlumpnum); @@ -791,7 +791,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) // the flat raw data needn't be converted with palettized textures W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), - PU_HWRCACHE, &grMipmap->grInfo.data)); + PU_HWRCACHE, &grMipmap->data)); } static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) @@ -799,13 +799,13 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) UINT8 *flat; // setup the texture info - grMipmap->grInfo.format = GR_TEXFMT_P_8; + grMipmap->format = GR_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; grMipmap->width = (UINT16)textures[texturenum]->width; grMipmap->height = (UINT16)textures[texturenum]->height; - flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data); + flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->data); memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height); R_TextureToFlat(texturenum, flat); @@ -819,17 +819,17 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) return; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; - if (!grmip->downloaded && !grmip->grInfo.data) + if (!grmip->downloaded && !grmip->data) HWR_CacheFlat(grmip, flatlumpnum); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - + HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. - Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED); } void HWR_GetLevelFlat(levelflat_t *levelflat) @@ -857,17 +857,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) grtex = &gr_flats[texturenum]; // Generate flat if missing from the cache - if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) + if (!grtex->mipmap.data && !grtex->mipmap.downloaded) HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. - Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED); } else // set no texture HWR_SetCurrentTexture(NULL); @@ -879,7 +879,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) // static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) { - if (!grmip->downloaded && !grmip->grInfo.data) + if (!grmip->downloaded && !grmip->data) { patch_t *patch = gpatch->rawpatch; if (!patch) @@ -895,11 +895,11 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - + HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. - Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED); } // -----------------+ @@ -908,7 +908,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) void HWR_GetPatch(GLPatch_t *gpatch) { // is it in hardware cache - if (!gpatch->mipmap->downloaded && !gpatch->mipmap->grInfo.data) + if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data) { // load the software patch, PU_STATIC or the Z_Malloc for hardware patch will // flush the software patch before the conversion! oh yeah I suffered @@ -930,7 +930,7 @@ void HWR_GetPatch(GLPatch_t *gpatch) HWR_SetCurrentTexture(gpatch->mipmap); // The system-memory patch data can be purged now. - Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED); } @@ -980,7 +980,7 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch) if (!gpatch) return; - Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED); } @@ -1065,7 +1065,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) { GLPatch_t *grpatch = HWR_GetCachedGLPatch(lumpnum); - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) { pic_t *pic; UINT8 *block; @@ -1083,27 +1083,27 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) grpatch->mipmap->height = (UINT16)grpatch->height; if (pic->mode == PALETTE) - grpatch->mipmap->grInfo.format = textureformat; // can be set by driver + grpatch->mipmap->format = textureformat; // can be set by driver else - grpatch->mipmap->grInfo.format = picmode2GR[pic->mode]; + grpatch->mipmap->format = picmode2GR[pic->mode]; - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); // allocate block block = MakeBlock(grpatch->mipmap); if (grpatch->width == SHORT(pic->width) && grpatch->height == SHORT(pic->height) && - format2bpp[grpatch->mipmap->grInfo.format] == format2bpp[picmode2GR[pic->mode]]) + format2bpp[grpatch->mipmap->format] == format2bpp[picmode2GR[pic->mode]]) { // no conversion needed - M_Memcpy(grpatch->mipmap->grInfo.data, pic->data,len); + M_Memcpy(grpatch->mipmap->data, pic->data,len); } else HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height), - SHORT(pic->width)*format2bpp[grpatch->mipmap->grInfo.format], + SHORT(pic->width)*format2bpp[grpatch->mipmap->format], pic, - format2bpp[grpatch->mipmap->grInfo.format]); + format2bpp[grpatch->mipmap->format]); Z_Unlock(pic); Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED); @@ -1112,7 +1112,7 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) grpatch->max_s = grpatch->max_t = 1.0f; } HWD.pfnSetTexture(grpatch->mipmap); - //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.grInfo.data, grpatch->mipmap.downloaded); + //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.data, grpatch->mipmap.downloaded); return grpatch; } @@ -1145,7 +1145,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 { INT32 i,j; fixed_t posx, posy, stepx, stepy; - UINT8 *block = mipmap->grInfo.data; // places the data directly into here + UINT8 *block = mipmap->data; // places the data directly into here UINT8 *flat; UINT8 *dest, *src, texel; RGBA_t col; @@ -1184,7 +1184,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) UINT16 fmheight = 0, fmwidth = 0; // setup the texture info - grMipmap->grInfo.format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later + grMipmap->format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later grMipmap->flags = 0; size = W_LumpLength(fademasklumpnum); @@ -1228,13 +1228,13 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { GLMipmap_t *grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; - if (!grmip->downloaded && !grmip->grInfo.data) + if (!grmip->downloaded && !grmip->data) HWR_CacheFadeMask(grmip, fademasklumpnum); HWD.pfnSetTexture(grmip); // The system-memory data can be purged now. - Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED); } #endif //HWRENDER diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 6dc26948f..9cd929e1e 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -42,17 +42,14 @@ typedef FxI32 GrTextureFormat_t; #define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ #define GR_RGBA 0x6 // 32 bit RGBA ! -typedef struct -{ - GrTextureFormat_t format; - void *data; -} GrTexInfo; - -// grInfo.data holds the address of the graphics data cached in heap memory +// data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s { - GrTexInfo grInfo; //for TexDownloadMipMap + //for TexDownloadMipMap + GrTextureFormat_t format; + void *data; + FxU32 flags; UINT16 height; UINT16 width; diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index a685994cc..a7e815730 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -1229,10 +1229,10 @@ static void HWR_SetLight(void) { int i, j; - if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->grInfo.data) + if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data) { - UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->grInfo.data); + UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data); for (i = 0; i < 128; i++) { @@ -1245,7 +1245,7 @@ static void HWR_SetLight(void) Data[i*128+j] = 0; } } - lightmappatch.mipmap->grInfo.format = GR_TEXFMT_ALPHA_INTENSITY_88; + lightmappatch.mipmap->format = GR_TEXFMT_ALPHA_INTENSITY_88; lightmappatch.width = 128; lightmappatch.height = 128; @@ -1256,7 +1256,7 @@ static void HWR_SetLight(void) HWD.pfnSetTexture(lightmappatch.mipmap); // The system-memory data can be purged now. - Z_ChangeTag(lightmappatch.mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(lightmappatch.mipmap->data, PU_HWRCACHE_UNLOCKED); } //********************************************************** diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f07cb24d8..98a92768c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3327,7 +3327,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on INT32 side; - + rs_numbspcalls++; // Found a subsector? @@ -3570,7 +3570,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) alpha = 255 - alpha; gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE); - if (!(gpatch && gpatch->mipmap->grInfo.format)) return; + if (!(gpatch && gpatch->mipmap->format)) return; HWR_GetPatch(gpatch); scalemul = FixedMul(FRACUNIT - floordiff/640, scale); @@ -4189,7 +4189,7 @@ static int CompareVisSprites(const void *p1, const void *p2) gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2; int idiff; float fdiff; - + // Make transparent sprites last. Comment from the previous sort implementation: // Sryder: Oh boy, while it's nice having ALL the sprites sorted properly, it fails when we bring MD2's into the // mix and they want to be translucent. So let's place all the translucent sprites and MD2's AFTER @@ -4411,7 +4411,7 @@ static void HWR_CreateDrawNodes(void) // However, in reality we shouldn't be re-copying and shifting all this information // that is already lying around. This should all be in some sort of linked list or lists. sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL); - + rs_hw_nodesorttime = I_GetTimeMicros(); for (i = 0; i < numplanes; i++, p++) @@ -4431,7 +4431,7 @@ static void HWR_CreateDrawNodes(void) sortnode[p].wall = &wallinfo[i]; sortindex[p] = p; } - + rs_numdrawnodes = p; // p is the number of stuff to sort @@ -4468,7 +4468,7 @@ static void HWR_CreateDrawNodes(void) } rs_hw_nodesorttime = I_GetTimeMicros() - rs_hw_nodesorttime; - + rs_hw_nodedrawtime = I_GetTimeMicros(); // Okay! Let's draw it all! Woo! @@ -4505,7 +4505,7 @@ static void HWR_CreateDrawNodes(void) sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap); } } - + rs_hw_nodedrawtime = I_GetTimeMicros() - rs_hw_nodedrawtime; numwalls = 0; @@ -5763,7 +5763,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grsolvetjoin); - + CV_RegisterVar(&cv_renderstats); CV_RegisterVar(&cv_grbatching); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f5df49bcd..b5a00a785 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -191,7 +191,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename); png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); fclose(png_FILE); - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); return 0; } #ifdef USE_FAR_KEYWORD @@ -232,7 +232,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ { png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr); - png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); + png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data); png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep)); for (i = 0; i < height; i++) row_pointers[i] = PNG_image + i*pitch; @@ -306,7 +306,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, pw = *w = header.xmax - header.xmin + 1; ph = *h = header.ymax - header.ymin + 1; - image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); + image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data); if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE) { @@ -354,7 +354,7 @@ static void md2_loadTexture(md2_t *model) if (model->grpatch) { grpatch = model->grpatch; - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); } else { @@ -363,18 +363,18 @@ static void md2_loadTexture(md2_t *model) grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); } - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) { int w = 0, h = 0; UINT32 size; RGBA_t *image; #ifdef HAVE_PNG - grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) #endif - grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) { model->notexturefile = true; // mark it so its not searched for again repeatedly return; @@ -389,7 +389,7 @@ static void md2_loadTexture(md2_t *model) grpatch->mipmap->height = (UINT16)h; // Lactozilla: Apply colour cube - image = grpatch->mipmap->grInfo.data; + image = grpatch->mipmap->data; size = w*h; while (size--) { @@ -414,7 +414,7 @@ static void md2_loadBlendTexture(md2_t *model) if (model->blendgrpatch) { grpatch = model->blendgrpatch; - Z_Free(grpatch->mipmap->grInfo.data); + Z_Free(grpatch->mipmap->data); } else { @@ -423,15 +423,15 @@ static void md2_loadBlendTexture(md2_t *model) grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); } - if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data) { int w = 0, h = 0; #ifdef HAVE_PNG - grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) #endif - grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap->grInfo.format == 0) + grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->format == 0) { model->noblendfile = true; // mark it so its not searched for again repeatedly Z_Free(filename); @@ -686,20 +686,20 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // no wrap around, no chroma key grmip->flags = 0; // setup the texture info - grmip->grInfo.format = GR_RGBA; + grmip->format = GR_RGBA; } - if (grmip->grInfo.data) + if (grmip->data) { - Z_Free(grmip->grInfo.data); - grmip->grInfo.data = NULL; + Z_Free(grmip->data); + grmip->data = NULL; } - cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->grInfo.data); + cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->data); memset(cur, 0x00, size*4); - image = gpatch->mipmap->grInfo.data; - blendimage = blendgpatch->mipmap->grInfo.data; + image = gpatch->mipmap->data; + blendimage = blendgpatch->mipmap->data; // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. if (skinnum == TC_METALSONIC) @@ -1050,7 +1050,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT return; } - if ((blendgpatch && blendgpatch->mipmap->grInfo.format) + if ((blendgpatch && blendgpatch->mipmap->format) && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) { // Blend image exists, but it's bad. @@ -1065,10 +1065,10 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT grmip = grmip->nextcolormap; if (grmip->colormap == colormap) { - if (grmip->downloaded && grmip->grInfo.data) + if (grmip->downloaded && grmip->data) { HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture - Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); + Z_ChangeTag(grmip->data, PU_HWRMODELTEXTURE_UNLOCKED); return; } } @@ -1090,7 +1090,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color); HWD.pfnSetTexture(newmip); - Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); + Z_ChangeTag(newmip->data, PU_HWRMODELTEXTURE_UNLOCKED); } #define NORMALFOG 0x00000000 @@ -1307,17 +1307,17 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) finalscale = md2->scale; //Hurdler: arf, I don't like that implementation at all... too much crappy gpatch = md2->grpatch; - if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) + if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) md2_loadTexture(md2); gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... - if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available + if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available && (!md2->blendgrpatch - || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) + || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); - if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture + if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { INT32 skinnum = TC_DEFAULT; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e5f6ff3cf..7abd98fba 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1657,15 +1657,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) else texnum = pTexInfo->downloaded; - //GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data); + //GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->data); w = pTexInfo->width; h = pTexInfo->height; - if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || - (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)) + if ((pTexInfo->format == GR_TEXFMT_P_8) || + (pTexInfo->format == GR_TEXFMT_AP_88)) { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; + const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; for (j = 0; j < h; j++) @@ -1691,7 +1691,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pImgData++; - if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88) + if (pTexInfo->format == GR_TEXFMT_AP_88) { if (!(pTexInfo->flags & TF_CHROMAKEYED)) tex[w*j+i].s.alpha = *pImgData; @@ -1701,15 +1701,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } } - else if (pTexInfo->grInfo.format == GR_RGBA) + else if (pTexInfo->format == GR_RGBA) { // corona test : passed as ARGB 8888, which is not in glide formats // Hurdler: not used for coronas anymore, just for dynamic lighting - ptex = pTexInfo->grInfo.data; + ptex = pTexInfo->data; } - else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) + else if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88) { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; + const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; for (j = 0; j < h; j++) @@ -1725,9 +1725,9 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } } - else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks + else if (pTexInfo->format == GR_TEXFMT_ALPHA_8) // Used for fade masks { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; + const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; for (j = 0; j < h; j++) @@ -1743,7 +1743,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } else - GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format); + GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->format); // the texture number was already generated by pglGenTextures pglBindTexture(GL_TEXTURE_2D, texnum); @@ -1761,7 +1761,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); } - if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) + if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88) { //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); if (MipMap) @@ -1782,7 +1782,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); } } - else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) + else if (pTexInfo->format == GR_TEXFMT_ALPHA_8) { //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); if (MipMap) @@ -2968,7 +2968,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) // I don't know which one the game actually _uses_ but this // follows format2bpp in hw_cache.c int bpp = 1; - int format = tmp->grInfo.format; + int format = tmp->format; if (format == GR_RGBA) bpp = 4; else if (format == GR_TEXFMT_RGB_565 diff --git a/src/r_patch.c b/src/r_patch.c index ad4b3329a..8980eda58 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1426,10 +1426,10 @@ void R_FreeSingleRotSprite(spritedef_t *spritedef) } if (grPatch->mipmap) { - if (grPatch->mipmap->grInfo.data) + if (grPatch->mipmap->data) { - Z_Free(grPatch->mipmap->grInfo.data); - grPatch->mipmap->grInfo.data = NULL; + Z_Free(grPatch->mipmap->data); + grPatch->mipmap->data = NULL; } Z_Free(grPatch->mipmap); grPatch->mipmap = NULL; diff --git a/src/w_wad.c b/src/w_wad.c index 9af661b57..e6dedba22 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1732,11 +1732,11 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) grPatch = HWR_GetCachedGLPatchPwad(wad, lump); - if (grPatch->mipmap->grInfo.data) + if (grPatch->mipmap->data) { if (tag == PU_CACHE) tag = PU_HWRCACHE; - Z_ChangeTag(grPatch->mipmap->grInfo.data, tag); + Z_ChangeTag(grPatch->mipmap->data, tag); } else { From 3d50bef0e50408b5700c5d96ed3d4f40d54d67d5 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 00:52:10 -0300 Subject: [PATCH 26/75] Rename structs, turn GrTextureFormat_t into an enum --- src/hardware/hw_cache.c | 75 +++++++++++++++----------------- src/hardware/hw_data.h | 35 ++++++++------- src/hardware/hw_glob.h | 2 +- src/hardware/hw_light.c | 2 +- src/hardware/hw_main.c | 4 +- src/hardware/hw_md2.c | 10 ++--- src/hardware/r_opengl/r_opengl.c | 28 ++++++------ 7 files changed, 75 insertions(+), 81 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 1e63acf78..a284b8ed0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -27,27 +27,22 @@ #include "../r_patch.h" #include "../p_setup.h" -INT32 patchformat = GR_TEXFMT_AP_88; // use alpha for holes -INT32 textureformat = GR_TEXFMT_P_8; // use chromakey for hole +INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes +INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole -static const INT32 format2bpp[16] = +static INT32 format2bpp(GLTextureFormat_t format) { - 0, //0 - 0, //1 - 1, //2 GR_TEXFMT_ALPHA_8 - 1, //3 GR_TEXFMT_INTENSITY_8 - 1, //4 GR_TEXFMT_ALPHA_INTENSITY_44 - 1, //5 GR_TEXFMT_P_8 - 4, //6 GR_RGBA - 0, //7 - 0, //8 - 0, //9 - 2, //10 GR_TEXFMT_RGB_565 - 2, //11 GR_TEXFMT_ARGB_1555 - 2, //12 GR_TEXFMT_ARGB_4444 - 2, //13 GR_TEXFMT_ALPHA_INTENSITY_88 - 2, //14 GR_TEXFMT_AP_88 -}; + if (format == GL_TEXFMT_RGBA) + return 4; + else if (format == GL_TEXFMT_RGB_565 + || format == GL_TEXFMT_ARGB_1555 + || format == GL_TEXFMT_ARGB_4444 + || format == GL_TEXFMT_ALPHA_INTENSITY_88 + || format == GL_TEXFMT_AP_88) + return 2; + else + return 1; +} // This code was originally placed directly in HWR_DrawPatchInCache. // It is now split from it for my sanity! (and the sanity of others) @@ -307,7 +302,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, yfracstep = FRACUNIT; scale_y = FRACUNIT; - bpp = format2bpp[mipmap->format]; + bpp = format2bpp(mipmap->format); if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); @@ -400,7 +395,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, yfracstep = (texture->height<< FRACBITS) / pblockheight; scale_y = (pblockheight << FRACBITS) / texture->height; - bpp = format2bpp[mipmap->format]; + bpp = format2bpp(mipmap->format); if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); @@ -431,7 +426,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX); INT32 blocksize = (grMipmap->width * grMipmap->height); - bpp = format2bpp[grMipmap->format]; + bpp = format2bpp(grMipmap->format); block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data)); switch (bpp) @@ -453,7 +448,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) // Create a composite texture from patches, adapt the texture size to a power of 2 // height and width for the hardware texture cache. // -static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) +static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) { UINT8 *block; texture_t *texture; @@ -537,7 +532,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) Z_Unlock(realpatch); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( - if (format2bpp[grtex->mipmap.format]==4) + if (format2bpp(grtex->mipmap.format)==4) { for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp { @@ -608,8 +603,8 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // ================================================= static size_t gr_numtextures = 0; // Texture count -static GLTexture_t *gr_textures; // For all textures -static GLTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached +static GLMapTexture_t *gr_textures; // For all textures +static GLMapTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached void HWR_InitTextureCache(void) { @@ -713,7 +708,7 @@ void HWR_SetPalette(RGBA_t *palette) // hardware driver will flush there own cache if cache is non paletized // now flush data texture cache so 32 bit texture are recomputed - if (patchformat == GR_RGBA || textureformat == GR_RGBA) + if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA) { Z_FreeTag(PU_HWRCACHE); Z_FreeTag(PU_HWRCACHE_UNLOCKED); @@ -723,9 +718,9 @@ void HWR_SetPalette(RGBA_t *palette) // -------------------------------------------------------------------------- // Make sure texture is downloaded and set it as the source // -------------------------------------------------------------------------- -GLTexture_t *HWR_GetTexture(INT32 tex) +GLMapTexture_t *HWR_GetTexture(INT32 tex) { - GLTexture_t *grtex; + GLMapTexture_t *grtex; #ifdef PARANOIA if ((unsigned)tex >= gr_numtextures) I_Error("HWR_GetTexture: tex >= numtextures\n"); @@ -756,7 +751,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) size_t size, pflatsize; // setup the texture info - grMipmap->format = GR_TEXFMT_P_8; + grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; size = W_LumpLength(flatlumpnum); @@ -799,7 +794,7 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) UINT8 *flat; // setup the texture info - grMipmap->format = GR_TEXFMT_P_8; + grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; grMipmap->width = (UINT16)textures[texturenum]->width; @@ -842,7 +837,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum); else if (levelflat->type == LEVELFLAT_TEXTURE) { - GLTexture_t *grtex; + GLMapTexture_t *grtex; INT32 texturenum = levelflat->u.texture.num; #ifdef PARANOIA if ((unsigned)texturenum >= gr_numtextures) @@ -986,11 +981,11 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch) static const INT32 picmode2GR[] = { - GR_TEXFMT_P_8, // PALETTE + GL_TEXFMT_P_8, // PALETTE 0, // INTENSITY (unsupported yet) - GR_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this) + GL_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this) 0, // RGB24 (unsupported yet) - GR_RGBA, // RGBA32 (opengl only) + GL_TEXFMT_RGBA, // RGBA32 (opengl only) }; static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheight, @@ -1005,7 +1000,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig stepy = ((INT32)SHORT(pic->height)<width)<mode]]; + picbpp = format2bpp(picmode2GR[pic->mode]); posy = 0; for (j = 0; j < pblockheight; j++) { @@ -1094,16 +1089,16 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) if (grpatch->width == SHORT(pic->width) && grpatch->height == SHORT(pic->height) && - format2bpp[grpatch->mipmap->format] == format2bpp[picmode2GR[pic->mode]]) + format2bpp(grpatch->mipmap->format) == format2bpp(picmode2GR[pic->mode])) { // no conversion needed M_Memcpy(grpatch->mipmap->data, pic->data,len); } else HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height), - SHORT(pic->width)*format2bpp[grpatch->mipmap->format], + SHORT(pic->width)*format2bpp(grpatch->mipmap->format), pic, - format2bpp[grpatch->mipmap->format]); + format2bpp(grpatch->mipmap->format)); Z_Unlock(pic); Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED); @@ -1184,7 +1179,7 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) UINT16 fmheight = 0, fmwidth = 0; // setup the texture info - grMipmap->format = GR_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later + grMipmap->format = GL_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later grMipmap->flags = 0; size = W_LumpLength(fademasklumpnum); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 9cd929e1e..1e1381d7c 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -27,30 +27,29 @@ // TEXTURE INFO // ========================================================================== -typedef unsigned long FxU32; -typedef long FxI32; - -typedef FxI32 GrTextureFormat_t; -#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */ -#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */ -#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 -#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */ -#define GR_TEXFMT_RGB_565 0xa -#define GR_TEXFMT_ARGB_1555 0xb -#define GR_TEXFMT_ARGB_4444 0xc -#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd -#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */ -#define GR_RGBA 0x6 // 32 bit RGBA ! +typedef enum GLTextureFormat_e +{ + GL_TEXFMT_ALPHA_8 = 0x2, /* (0..0xFF) alpha */ + GL_TEXFMT_INTENSITY_8 = 0x3, /* (0..0xFF) intensity */ + GL_TEXFMT_ALPHA_INTENSITY_44 = 0x4, + GL_TEXFMT_P_8 = 0x5, /* 8-bit palette */ + GL_TEXFMT_RGBA = 0x6, /* 32 bit RGBA! */ + GL_TEXFMT_RGB_565 = 0xa, + GL_TEXFMT_ARGB_1555 = 0xb, + GL_TEXFMT_ARGB_4444 = 0xc, + GL_TEXFMT_ALPHA_INTENSITY_88 = 0xd, + GL_TEXFMT_AP_88 = 0xe, /* 8-bit alpha 8-bit palette */ +} GLTextureFormat_t; // data holds the address of the graphics data cached in heap memory // NULL if the texture is not in Doom heap cache. struct GLMipmap_s { //for TexDownloadMipMap - GrTextureFormat_t format; + GLTextureFormat_t format; void *data; - FxU32 flags; + UINT32 flags; UINT16 height; UINT16 width; UINT32 downloaded; // the dll driver have it in there cache ? @@ -67,13 +66,13 @@ typedef struct GLMipmap_s GLMipmap_t; // // Doom texture info, as cached for hardware rendering // -struct GLTexture_s +struct GLMapTexture_s { GLMipmap_t mipmap; float scaleX; //used for scaling textures on walls float scaleY; }; -typedef struct GLTexture_s GLTexture_t; +typedef struct GLMapTexture_s GLMapTexture_t; // a cached patch as converted to hardware format, holding the original patch_t diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index d8ea7c7a3..8e3760fd1 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -95,7 +95,7 @@ void HWR_FreeExtraSubsectors(void); void HWR_GetLevelFlat(levelflat_t *levelflat); void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); -GLTexture_t *HWR_GetTexture(INT32 tex); +GLMapTexture_t *HWR_GetTexture(INT32 tex); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_UnlockCachedPatch(GLPatch_t *gpatch); diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index a7e815730..400551016 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -1245,7 +1245,7 @@ static void HWR_SetLight(void) Data[i*128+j] = 0; } } - lightmappatch.mipmap->format = GR_TEXFMT_ALPHA_INTENSITY_88; + lightmappatch.mipmap->format = GL_TEXFMT_ALPHA_INTENSITY_88; lightmappatch.width = 128; lightmappatch.height = 128; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 98a92768c..ab6d48736 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1055,7 +1055,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t v1x, v1y, v2x, v2y; - GLTexture_t *grTex = NULL; + GLMapTexture_t *grTex = NULL; float cliplow = 0.0f, cliphigh = 0.0f; INT32 gr_midtexture; fixed_t h, l; // 3D sides and 2s middle textures @@ -5812,7 +5812,7 @@ void HWR_Startup(void) } if (rendermode == render_opengl) - textureformat = patchformat = GR_RGBA; + textureformat = patchformat = GL_TEXFMT_RGBA; startupdone = true; } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index b5a00a785..a09fdc926 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -141,7 +141,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext) CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext); } -static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch) +static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch) { png_structp png_ptr; png_infop png_info_ptr; @@ -245,7 +245,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ fclose(png_FILE); *w = (int)width; *h = (int)height; - return GR_RGBA; + return GL_TEXFMT_RGBA; } #endif @@ -271,7 +271,7 @@ typedef struct UINT8 filler[54]; } PcxHeader; -static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, +static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch) { PcxHeader header; @@ -340,7 +340,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, } } fclose(file); - return GR_RGBA; + return GL_TEXFMT_RGBA; } // -----------------+ @@ -686,7 +686,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // no wrap around, no chroma key grmip->flags = 0; // setup the texture info - grmip->format = GR_RGBA; + grmip->format = GL_TEXFMT_RGBA; } if (grmip->data) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 7abd98fba..04bbd916d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1662,8 +1662,8 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) w = pTexInfo->width; h = pTexInfo->height; - if ((pTexInfo->format == GR_TEXFMT_P_8) || - (pTexInfo->format == GR_TEXFMT_AP_88)) + if ((pTexInfo->format == GL_TEXFMT_P_8) || + (pTexInfo->format == GL_TEXFMT_AP_88)) { const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; @@ -1691,7 +1691,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pImgData++; - if (pTexInfo->format == GR_TEXFMT_AP_88) + if (pTexInfo->format == GL_TEXFMT_AP_88) { if (!(pTexInfo->flags & TF_CHROMAKEYED)) tex[w*j+i].s.alpha = *pImgData; @@ -1701,13 +1701,13 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } } - else if (pTexInfo->format == GR_RGBA) + else if (pTexInfo->format == GL_TEXFMT_RGBA) { // corona test : passed as ARGB 8888, which is not in glide formats // Hurdler: not used for coronas anymore, just for dynamic lighting ptex = pTexInfo->data; } - else if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88) + else if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88) { const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; @@ -1725,7 +1725,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) } } } - else if (pTexInfo->format == GR_TEXFMT_ALPHA_8) // Used for fade masks + else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) // Used for fade masks { const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; INT32 i, j; @@ -1761,7 +1761,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); } - if (pTexInfo->format == GR_TEXFMT_ALPHA_INTENSITY_88) + if (pTexInfo->format == GL_TEXFMT_ALPHA_INTENSITY_88) { //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); if (MipMap) @@ -1782,7 +1782,7 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo) pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); } } - else if (pTexInfo->format == GR_TEXFMT_ALPHA_8) + else if (pTexInfo->format == GL_TEXFMT_ALPHA_8) { //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); if (MipMap) @@ -2969,13 +2969,13 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) // follows format2bpp in hw_cache.c int bpp = 1; int format = tmp->format; - if (format == GR_RGBA) + if (format == GL_TEXFMT_RGBA) bpp = 4; - else if (format == GR_TEXFMT_RGB_565 - || format == GR_TEXFMT_ARGB_1555 - || format == GR_TEXFMT_ARGB_4444 - || format == GR_TEXFMT_ALPHA_INTENSITY_88 - || format == GR_TEXFMT_AP_88) + else if (format == GL_TEXFMT_RGB_565 + || format == GL_TEXFMT_ARGB_1555 + || format == GL_TEXFMT_ARGB_4444 + || format == GL_TEXFMT_ALPHA_INTENSITY_88 + || format == GL_TEXFMT_AP_88) bpp = 2; // Add it up! From a739cb0da9e7d87cb857048295420ba2f642e48d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 00:58:09 -0300 Subject: [PATCH 27/75] Remove unused texture formats --- src/hardware/hw_cache.c | 6 +----- src/hardware/hw_data.h | 18 ++++++++---------- src/hardware/r_opengl/r_opengl.c | 6 +----- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index a284b8ed0..0b3169147 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -34,11 +34,7 @@ static INT32 format2bpp(GLTextureFormat_t format) { if (format == GL_TEXFMT_RGBA) return 4; - else if (format == GL_TEXFMT_RGB_565 - || format == GL_TEXFMT_ARGB_1555 - || format == GL_TEXFMT_ARGB_4444 - || format == GL_TEXFMT_ALPHA_INTENSITY_88 - || format == GL_TEXFMT_AP_88) + else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88) return 2; else return 1; diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 1e1381d7c..e5477d729 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -29,16 +29,14 @@ typedef enum GLTextureFormat_e { - GL_TEXFMT_ALPHA_8 = 0x2, /* (0..0xFF) alpha */ - GL_TEXFMT_INTENSITY_8 = 0x3, /* (0..0xFF) intensity */ - GL_TEXFMT_ALPHA_INTENSITY_44 = 0x4, - GL_TEXFMT_P_8 = 0x5, /* 8-bit palette */ - GL_TEXFMT_RGBA = 0x6, /* 32 bit RGBA! */ - GL_TEXFMT_RGB_565 = 0xa, - GL_TEXFMT_ARGB_1555 = 0xb, - GL_TEXFMT_ARGB_4444 = 0xc, - GL_TEXFMT_ALPHA_INTENSITY_88 = 0xd, - GL_TEXFMT_AP_88 = 0xe, /* 8-bit alpha 8-bit palette */ + GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */ + GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */ + + GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */ + + GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */ + GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */ + GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, } GLTextureFormat_t; // data holds the address of the graphics data cached in heap memory diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 04bbd916d..49dbcd08f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2971,11 +2971,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) int format = tmp->format; if (format == GL_TEXFMT_RGBA) bpp = 4; - else if (format == GL_TEXFMT_RGB_565 - || format == GL_TEXFMT_ARGB_1555 - || format == GL_TEXFMT_ARGB_4444 - || format == GL_TEXFMT_ALPHA_INTENSITY_88 - || format == GL_TEXFMT_AP_88) + else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88) bpp = 2; // Add it up! From 5c5d907251a052548ad5dd86d72e9c5413f89c0f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jul 2020 01:15:08 -0300 Subject: [PATCH 28/75] gr_ -> gl_ --- src/command.c | 2 +- src/d_main.c | 6 +- src/hardware/hw_batching.c | 10 +- src/hardware/hw_bsp.c | 56 +- src/hardware/hw_cache.c | 40 +- src/hardware/hw_draw.c | 10 +- src/hardware/hw_glob.h | 4 +- src/hardware/hw_light.c | 42 +- src/hardware/hw_light.h | 4 +- src/hardware/hw_main.c | 1238 +++++++++++++++--------------- src/hardware/hw_main.h | 42 +- src/hardware/hw_md2.c | 10 +- src/hardware/hw_md2.h | 2 +- src/hardware/hw_trick.c | 2 +- src/hardware/r_opengl/r_opengl.c | 28 +- src/hu_stuff.c | 6 +- src/m_menu.c | 28 +- src/p_user.c | 2 +- src/r_main.c | 2 +- 19 files changed, 767 insertions(+), 767 deletions(-) diff --git a/src/command.c b/src/command.c index f5c02d877..fdfc95c6d 100644 --- a/src/command.c +++ b/src/command.c @@ -620,7 +620,7 @@ static void COM_ExecuteString(char *ptext) // check cvars // Hurdler: added at Ebola's request ;) - // (don't flood the console in software mode with bad gr_xxx command) + // (don't flood the console in software mode with bad gl_xxx command) if (!CV_Command() && con_destlines) CONS_Printf(M_GetText("Unknown command '%s'\n"), COM_Argv(0)); } diff --git a/src/d_main.c b/src/d_main.c index 28570b909..5ad46de31 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -599,7 +599,7 @@ static void D_Display(void) snprintf(s, sizeof s - 1, "SysMiss %.2f%%", lostpercent); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s); } - + if (cv_renderstats.value) { char s[50]; @@ -608,7 +608,7 @@ static void D_Display(void) rs_prevframetime = I_GetTimeMicros(); if (rs_rendercalltime > 10000) divisor = 1000; - + snprintf(s, sizeof s - 1, "ft %d", frametime / divisor); V_DrawThinString(30, 10, V_MONOSPACE | V_YELLOWMAP, s); snprintf(s, sizeof s - 1, "rtot %d", rs_rendercalltime / divisor); @@ -635,7 +635,7 @@ static void D_Display(void) V_DrawThinString(30, 70, V_MONOSPACE | V_YELLOWMAP, s); snprintf(s, sizeof s - 1, "fin %d", rs_swaptime / divisor); V_DrawThinString(30, 80, V_MONOSPACE | V_YELLOWMAP, s); - if (cv_grbatching.value) + if (cv_glbatching.value) { snprintf(s, sizeof s - 1, "bsrt %d", rs_hw_batchsorttime / divisor); V_DrawThinString(80, 55, V_MONOSPACE | V_REDMAP, s); diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 5c5379f6d..492cea5fa 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -250,7 +250,7 @@ void HWR_RenderBatches(void) // sort polygons rs_hw_batchsorttime = I_GetTimeMicros(); - if (cv_grshaders.value && gr_shadersavailable) + if (cv_glshaders.value && gl_shadersavailable) qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); @@ -272,8 +272,8 @@ void HWR_RenderBatches(void) // and a color array could replace the color calls. // set state for first batch - - if (cv_grshaders.value && gr_shadersavailable) + + if (cv_glshaders.value && gl_shadersavailable) { HWD.pfnSetShader(currentShader); } @@ -355,7 +355,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = polygonArray[nextIndex].surf; if (nextPolyFlags & PF_NoTexture) nextTexture = 0; - if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable) + if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable) { changeState = true; changeShader = true; @@ -370,7 +370,7 @@ void HWR_RenderBatches(void) changeState = true; changePolyFlags = true; } - if (cv_grshaders.value && gr_shadersavailable) + if (cv_glshaders.value && gl_shadersavailable) { if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 6987e9d01..4db69ff8b 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -61,17 +61,17 @@ static INT32 totalsubsecpolys = 0; /// \todo check out how much is used static size_t POLYPOOLSIZE = 1024000; -static UINT8 *gr_polypool = NULL; -static UINT8 *gr_ppcurrent; -static size_t gr_ppfree; +static UINT8 *gl_polypool = NULL; +static UINT8 *gl_ppcurrent; +static size_t gl_ppfree; #endif // only between levels, clear poly pool static void HWR_ClearPolys(void) { #ifndef ZPLANALLOC - gr_ppcurrent = gr_polypool; - gr_ppfree = POLYPOOLSIZE; + gl_ppcurrent = gl_polypool; + gl_ppfree = POLYPOOLSIZE; #endif } @@ -86,8 +86,8 @@ void HWR_InitPolyPool(void) POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb) CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE); - gr_polypool = malloc(POLYPOOLSIZE); - if (!gr_polypool) + gl_polypool = malloc(POLYPOOLSIZE); + if (!gl_polypool) I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n"); HWR_ClearPolys(); #endif @@ -96,9 +96,9 @@ void HWR_InitPolyPool(void) void HWR_FreePolyPool(void) { #ifndef ZPLANALLOC - if (gr_polypool) - free(gr_polypool); - gr_polypool = NULL; + if (gl_polypool) + free(gl_polypool); + gl_polypool = NULL; #endif } @@ -110,19 +110,19 @@ static poly_t *HWR_AllocPoly(INT32 numpts) p = Z_Malloc(size, PU_HWRPLANE, NULL); #else #ifdef PARANOIA - if (!gr_polypool) - I_Error("Used gr_polypool without init!\n"); - if (!gr_ppcurrent) - I_Error("gr_ppcurrent == NULL!\n"); + if (!gl_polypool) + I_Error("Used gl_polypool without init!\n"); + if (!gl_ppcurrent) + I_Error("gl_ppcurrent == NULL!\n"); #endif - if (gr_ppfree < size) + if (gl_ppfree < size) I_Error("HWR_AllocPoly(): no more memory %u bytes left, %u bytes needed\n\n%s\n", - gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)"); + gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)"); - p = (poly_t *)gr_ppcurrent; - gr_ppcurrent += size; - gr_ppfree -= size; + p = (poly_t *)gl_ppcurrent; + gl_ppcurrent += size; + gl_ppfree -= size; #endif p->numpts = numpts; return p; @@ -135,13 +135,13 @@ static polyvertex_t *HWR_AllocVertex(void) #ifdef ZPLANALLOC p = Z_Malloc(size, PU_HWRPLANE, NULL); #else - if (gr_ppfree < size) + if (gl_ppfree < size) I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n", - gr_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)"); + gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)"); - p = (polyvertex_t *)gr_ppcurrent; - gr_ppcurrent += size; - gr_ppfree -= size; + p = (polyvertex_t *)gl_ppcurrent; + gl_ppcurrent += size; + gl_ppfree -= size; #endif return p; } @@ -829,7 +829,7 @@ static INT32 SolveTProblem(void) INT32 i; size_t l; - if (cv_grsolvetjoin.value == 0) + if (cv_glsolvetjoin.value == 0) return 0; CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n"); @@ -983,9 +983,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum) I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors)); // allocate table for back to front drawing of subsectors - /*gr_drawsubsectors = (INT16 *)malloc(sizeof (*gr_drawsubsectors) * totsubsectors); - if (!gr_drawsubsectors) - I_Error("couldn't malloc gr_drawsubsectors\n");*/ + /*gl_drawsubsectors = (INT16 *)malloc(sizeof (*gl_drawsubsectors) * totsubsectors); + if (!gl_drawsubsectors) + I_Error("couldn't malloc gl_drawsubsectors\n");*/ // number of the first new subsector that might be added addsubsector = numsubsectors; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 0b3169147..79610cbd0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -598,14 +598,14 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // CACHING HANDLING // ================================================= -static size_t gr_numtextures = 0; // Texture count -static GLMapTexture_t *gr_textures; // For all textures -static GLMapTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached +static size_t gl_numtextures = 0; // Texture count +static GLMapTexture_t *gl_textures; // For all textures +static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached void HWR_InitTextureCache(void) { - gr_textures = NULL; - gr_flats = NULL; + gl_textures = NULL; + gl_flats = NULL; } // Callback function for HWR_FreeTextureCache. @@ -673,13 +673,13 @@ void HWR_FreeTextureCache(void) // now the heap don't have any 'user' pointing to our // texturecache info, we can free it - if (gr_textures) - free(gr_textures); - if (gr_flats) - free(gr_flats); - gr_textures = NULL; - gr_flats = NULL; - gr_numtextures = 0; + if (gl_textures) + free(gl_textures); + if (gl_flats) + free(gl_flats); + gl_textures = NULL; + gl_flats = NULL; + gl_numtextures = 0; } void HWR_LoadTextures(size_t pnumtextures) @@ -688,13 +688,13 @@ void HWR_LoadTextures(size_t pnumtextures) HWR_FreeTextureCache(); // Why not Z_Malloc? - gr_numtextures = pnumtextures; - gr_textures = calloc(gr_numtextures, sizeof(*gr_textures)); - gr_flats = calloc(gr_numtextures, sizeof(*gr_flats)); + gl_numtextures = pnumtextures; + gl_textures = calloc(gl_numtextures, sizeof(*gl_textures)); + gl_flats = calloc(gl_numtextures, sizeof(*gl_flats)); // Doesn't tell you which it _is_, but hopefully // should never ever happen (right?!) - if ((gr_textures == NULL) || (gr_flats == NULL)) + if ((gl_textures == NULL) || (gl_flats == NULL)) I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!"); } @@ -718,13 +718,13 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) { GLMapTexture_t *grtex; #ifdef PARANOIA - if ((unsigned)tex >= gr_numtextures) + if ((unsigned)tex >= gl_numtextures) I_Error("HWR_GetTexture: tex >= numtextures\n"); #endif // Every texture in memory, stored in the // hardware renderer's bit depth format. Wow! - grtex = &gr_textures[tex]; + grtex = &gl_textures[tex]; // Generate texture if missing from the cache if (!grtex->mipmap.data && !grtex->mipmap.downloaded) @@ -836,7 +836,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) GLMapTexture_t *grtex; INT32 texturenum = levelflat->u.texture.num; #ifdef PARANOIA - if ((unsigned)texturenum >= gr_numtextures) + if ((unsigned)texturenum >= gl_numtextures) I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n"); #endif @@ -845,7 +845,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat) return; // Every texture in memory, stored as a 8-bit flat. Wow! - grtex = &gr_flats[texturenum]; + grtex = &gl_flats[texturenum]; // Generate flat if missing from the cache if (!grtex->mipmap.data && !grtex->mipmap.downloaded) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 3d20cd9b0..f5a984d5d 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -936,17 +936,17 @@ void HWR_DrawViewBorder(INT32 clearlines) INT32 basewindowx, basewindowy; GLPatch_t *patch; -// if (gr_viewwidth == vid.width) +// if (gl_viewwidth == vid.width) // return; if (!clearlines) clearlines = BASEVIDHEIGHT; // refresh all // calc view size based on original game resolution - baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7; - baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewheight), vid.fdupy)); - top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_baseviewwindowy), vid.fdupy)); - side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewwindowx), vid.fdupx)); + baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7; + baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdupy)); + top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdupy)); + side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwindowx), vid.fdupx)); // top HWR_DrawFlatFill(0, 0, diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 8e3760fd1..57f3c54d9 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -59,7 +59,7 @@ typedef struct // needed for sprite rendering // equivalent of the software renderer's vissprites -typedef struct gr_vissprite_s +typedef struct gl_vissprite_s { float x1, x2; float tz, ty; @@ -74,7 +74,7 @@ typedef struct gr_vissprite_s UINT8 *colormap; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing float z1, z2; -} gr_vissprite_t; +} gl_vissprite_t; // -------- // hw_bsp.c diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index 400551016..32c2d550d 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -821,7 +821,7 @@ void HWR_WallLighting(FOutVector *wlVerts) { int i, j; - // dynlights->nb == 0 if cv_grdynamiclighting.value is not set + // dynlights->nb == 0 if cv_gldynamiclighting.value is not set for (j = 0; j < dynlights->nb; j++) { FVector inter; @@ -970,7 +970,7 @@ static lumpnum_t coronalumpnum = LUMPERROR; // -------------------------------------------------------------------------- // coronas lighting // -------------------------------------------------------------------------- -void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr) +void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr) { light_t *p_lspr; @@ -985,7 +985,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr) p_lspr = &lspr[ROCKETEXP_L]; } - if (cv_grcoronas.value && (p_lspr->type & CORONA_SPR)) + if (cv_glcoronas.value && (p_lspr->type & CORONA_SPR)) { // it's an object which emits light FOutVector light[4]; FSurfaceInfo Surf; @@ -1010,7 +1010,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr) } if (size > p_lspr->corona_radius) size = p_lspr->corona_radius; - size *= FIXED_TO_FLOAT(cv_grcoronasize.value<<1); + size *= FIXED_TO_FLOAT(cv_glcoronasize.value<<1); // compute position doing average for (i = 0; i < 4; i++) @@ -1067,7 +1067,7 @@ void HWR_DrawCoronas(void) { int j; - if (!cv_grcoronas.value || dynlights->nb <= 0 || coronalumpnum == LUMPERROR) + if (!cv_glcoronas.value || dynlights->nb <= 0 || coronalumpnum == LUMPERROR) return; HWR_GetPic(coronalumpnum); /// \todo use different coronas @@ -1121,7 +1121,7 @@ void HWR_DrawCoronas(void) } if (size > p_lspr->corona_radius) size = p_lspr->corona_radius; - size = (float)(FIXED_TO_FLOAT(cv_grcoronasize.value<<1)*size); + size = (float)(FIXED_TO_FLOAT(cv_glcoronasize.value<<1)*size); // put light little forward the sprite so there is no // z-buffer problem (coplanar polygons) @@ -1170,13 +1170,13 @@ void HWR_SetLights(int viewnumber) // Add a light for dynamic lighting // The light position is already transformed execpt for mlook // -------------------------------------------------------------------------- -void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch) +void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch) { light_t *p_lspr; //Hurdler: moved here because it's better;-) (void)patch; - if (!cv_grdynamiclighting.value) + if (!cv_gldynamiclighting.value) return; if (!spr->mobj) @@ -1193,7 +1193,7 @@ void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch) p_lspr = t_lspr[spr->mobj->sprite]; if (!(p_lspr->type & DYNLIGHT_SPR)) return; - if ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value) + if ((p_lspr->type != LIGHT_SPR) || cv_glstaticlighting.value) return; LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x); @@ -1265,8 +1265,8 @@ static void HWR_SetLight(void) #ifdef STATICLIGHT // is this really necessary? -static sector_t *lgr_backsector; -static seg_t *lgr_curline; +static sector_t *lgl_backsector; +static seg_t *lgl_curline; #endif // p1 et p2 c'est le deux bou du seg en float @@ -1304,27 +1304,27 @@ static void HWR_AddLightMapForLine(int lightnum, seg_t *line) */ FVector p1,p2; - lgr_curline = line; - lgr_backsector = line->backsector; + lgl_curline = line; + lgl_backsector = line->backsector; // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, // and no middle texture. /* - if ( lgr_backsector->ceilingpic == gr_frontsector->ceilingpic - && lgr_backsector->floorpic == gr_frontsector->floorpic - && lgr_backsector->lightlevel == gr_frontsector->lightlevel - && lgr_curline->sidedef->midtexture == 0) + if ( lgl_backsector->ceilingpic == gl_frontsector->ceilingpic + && lgl_backsector->floorpic == gl_frontsector->floorpic + && lgl_backsector->lightlevel == gl_frontsector->lightlevel + && lgl_curline->sidedef->midtexture == 0) { return; } */ - p1.y = FIXED_TO_FLOAT(lgr_curline->v1->y); - p1.x = FIXED_TO_FLOAT(lgr_curline->v1->x); - p2.y = FIXED_TO_FLOAT(lgr_curline->v2->y); - p2.x = FIXED_TO_FLOAT(lgr_curline->v2->x); + p1.y = FIXED_TO_FLOAT(lgl_curline->v1->y); + p1.x = FIXED_TO_FLOAT(lgl_curline->v1->x); + p2.y = FIXED_TO_FLOAT(lgl_curline->v2->y); + p2.x = FIXED_TO_FLOAT(lgl_curline->v2->x); // check bbox of the seg // if (CircleTouchBBox(&p1, &p2, &LIGHT_POS(lightnum), DL_RADIUS(lightnum))==false) diff --git a/src/hardware/hw_light.h b/src/hardware/hw_light.h index 3b12f9c87..fed7db47f 100644 --- a/src/hardware/hw_light.h +++ b/src/hardware/hw_light.h @@ -24,7 +24,7 @@ #define DL_MAX_LIGHT 256 // maximum number of lights (extra lights are ignored) void HWR_InitLight(void); -void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch); +void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch); void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts); void HWR_WallLighting(FOutVector *wlVerts); void HWR_ResetLights(void); @@ -33,7 +33,7 @@ void HWR_SetLights(int viewnumber); #ifdef NEWCORONAS void HWR_DrawCoronas(void); #else -void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr); +void HWR_DoCoronasLighting(FOutVector *outVerts, gl_vissprite_t *spr); #endif typedef struct diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ab6d48736..db9dfdda7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -77,18 +77,18 @@ boolean drawsky = true; #define FIELDOFVIEW ANGLE_90 #define ABS(x) ((x) < 0 ? -(x) : (x)) -static angle_t gr_clipangle; +static angle_t gl_clipangle; // The viewangletox[viewangle + FINEANGLES/4] lookup // maps the visible view angles to screen X coordinates, // flattening the arc to a flat projection plane. // There will be many angles mapped to the same X. -static INT32 gr_viewangletox[FINEANGLES/2]; +static INT32 gl_viewangletox[FINEANGLES/2]; // The xtoviewangleangle[] table maps a screen pixel // to the lowest viewangle that maps back to x ranges // from clipangle to -clipangle. -static angle_t gr_xtoviewangle[MAXVIDWIDTH+1]; +static angle_t gl_xtoviewangle[MAXVIDWIDTH+1]; // ========================================================================== // GLOBALS @@ -106,24 +106,24 @@ static angle_t gr_xtoviewangle[MAXVIDWIDTH+1]; //#define NOCRAPPYMLOOK // base values set at SetViewSize -static float gr_basecentery; +static float gl_basecentery; -float gr_baseviewwindowy, gr_basewindowcentery; -float gr_viewwidth, gr_viewheight; // viewport clipping boundaries (screen coords) -float gr_viewwindowx; +float gl_baseviewwindowy, gl_basewindowcentery; +float gl_viewwidth, gl_viewheight; // viewport clipping boundaries (screen coords) +float gl_viewwindowx; -static float gr_centerx, gr_centery; -static float gr_viewwindowy; // top left corner of view window -static float gr_windowcenterx; // center of view window, for projection -static float gr_windowcentery; +static float gl_centerx, gl_centery; +static float gl_viewwindowy; // top left corner of view window +static float gl_windowcenterx; // center of view window, for projection +static float gl_windowcentery; -static float gr_pspritexscale, gr_pspriteyscale; +static float gl_pspritexscale, gl_pspriteyscale; -static seg_t *gr_curline; -static side_t *gr_sidedef; -static line_t *gr_linedef; -static sector_t *gr_frontsector; -static sector_t *gr_backsector; +static seg_t *gl_curline; +static side_t *gl_sidedef; +static line_t *gl_linedef; +static sector_t *gl_frontsector; +static sector_t *gl_backsector; // -------------------------------------------------------------------------- // STUFF FOR THE PROJECTION CODE @@ -135,14 +135,14 @@ FTransform atransform; static fixed_t dup_viewx, dup_viewy, dup_viewz; static angle_t dup_viewangle; -static float gr_viewx, gr_viewy, gr_viewz; -static float gr_viewsin, gr_viewcos; +static float gl_viewx, gl_viewy, gl_viewz; +static float gl_viewsin, gl_viewcos; // Maybe not necessary with the new T&L code (needs to be checked!) -static float gr_viewludsin, gr_viewludcos; // look up down kik test -static float gr_fovlud; +static float gl_viewludsin, gl_viewludcos; // look up down kik test +static float gl_fovlud; -static angle_t gr_aimingangle; +static angle_t gl_aimingangle; static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean skybox); // Render stats @@ -162,7 +162,7 @@ int rs_hw_numcolors = 0; int rs_hw_batchsorttime = 0; int rs_hw_batchdrawtime = 0; -boolean gr_shadersavailable = true; +boolean gl_shadersavailable = true; // ========================================================================== @@ -178,7 +178,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; // Crappy backup coloring if you can't do shaders - if (!cv_grshaders.value || !gr_shadersavailable) + if (!cv_glshaders.value || !gl_shadersavailable) { // be careful, this may get negative for high lightlevel values. float tint_alpha, fade_alpha; @@ -229,7 +229,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if realcolor.rgba = (colormap != NULL) ? colormap->rgba : GL_DEFAULTMIX; - if (cv_grshaders.value && gr_shadersavailable) + if (cv_glshaders.value && gl_shadersavailable) { surfcolor.s.alpha = (255 - light); } @@ -256,12 +256,12 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t { INT16 finallight = lightnum; - if (cv_grfakecontrast.value != 0) + if (cv_glfakecontrast.value != 0) { const UINT8 contrast = 8; fixed_t extralight = 0; - if (cv_grfakecontrast.value == 2) // Smooth setting + if (cv_glfakecontrast.value == 2) // Smooth setting { extralight = (-(contrast<f_slope && !isceiling) - slope = gr_frontsector->f_slope; - else if (gr_frontsector->c_slope && isceiling) - slope = gr_frontsector->c_slope; + if (gl_frontsector->f_slope && !isceiling) + slope = gl_frontsector->f_slope; + else if (gl_frontsector->c_slope && isceiling) + slope = gl_frontsector->c_slope; } // Set fixedheight to the slope's height from our viewpoint, if we have a slope @@ -471,19 +471,19 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool angle = FOFsector->ceilingpic_angle; } } - else if (gr_frontsector) + else if (gl_frontsector) { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth; - scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight; - angle = gr_frontsector->floorpic_angle; + scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatheight; + angle = gl_frontsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth; - scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight; - angle = gr_frontsector->ceilingpic_angle; + scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatheight; + angle = gl_frontsector->ceilingpic_angle; } } @@ -607,9 +607,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool vy = y1 + yd * j / numplanes; SETUP3DVERT((&horizonpts[1]), vx, vy); - dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); - vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; - vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; + dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2)); + vx = (vx - gl_viewx) * renderdist / dist + gl_viewx; + vy = (vy - gl_viewy) * renderdist / dist + gl_viewy; SETUP3DVERT((&horizonpts[0]), vx, vy); // Right side @@ -617,21 +617,21 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool vy = y1 + yd * (j+1) / numplanes; SETUP3DVERT((&horizonpts[2]), vx, vy); - dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); - vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; - vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; + dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2)); + vx = (vx - gl_viewx) * renderdist / dist + gl_viewx; + vy = (vy - gl_viewy) * renderdist / dist + gl_viewy; SETUP3DVERT((&horizonpts[3]), vx, vy); // Horizon fills - vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; - vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; + vx = (horizonpts[0].x - gl_viewx) * farrenderdist / renderdist + gl_viewx; + vy = (horizonpts[0].z - gl_viewy) * farrenderdist / renderdist + gl_viewy; SETUP3DVERT((&horizonpts[5]), vx, vy); - horizonpts[5].y = gr_viewz; + horizonpts[5].y = gl_viewz; - vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; - vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; + vx = (horizonpts[3].x - gl_viewx) * farrenderdist / renderdist + gl_viewx; + vy = (horizonpts[3].z - gl_viewy) * farrenderdist / renderdist + gl_viewy; SETUP3DVERT((&horizonpts[4]), vx, vy); - horizonpts[4].y = gr_viewz; + horizonpts[4].y = gl_viewz; // Draw HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true); @@ -712,13 +712,13 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) M_ClearBox(segbbox); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y)); + FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y)); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y)); + FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x), + FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y)); - splat = (wallsplat_t *)gr_curline->linedef->splats; + splat = (wallsplat_t *)gl_curline->linedef->splats; for (; splat; splat = splat->next) { //BP: don't draw splat extern to this seg @@ -799,7 +799,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, 2, false); // wall shader #ifdef WALLSPLATS - if (gr_curline->linedef->splats && cv_splats.value) + if (gl_curline->linedef->splats && cv_splats.value) HWR_DrawSegsSplats(pSurf); #endif } @@ -817,7 +817,7 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) { float num, den; float v1x, v1y, v1dx, v1dy, v2dx, v2dy; - angle_t pclipangle = gr_xtoviewangle[x]; + angle_t pclipangle = gl_xtoviewangle[x]; // a segment of a polygon v1x = v1->x; @@ -837,7 +837,7 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) // calc the frac along the polygon segment, //num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; //num = -v1x * v2dy + v1y * v2dx; - num = (gr_viewx - v1x)*v2dy + (v1y - gr_viewy)*v2dx; + num = (gl_viewx - v1x)*v2dy + (v1y - gl_viewy)*v2dx; return num / den; } @@ -1057,7 +1057,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom GLMapTexture_t *grTex = NULL; float cliplow = 0.0f, cliphigh = 0.0f; - INT32 gr_midtexture; + INT32 gl_midtexture; fixed_t h, l; // 3D sides and 2s middle textures fixed_t hS, lS; @@ -1065,13 +1065,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom extracolormap_t *colormap; FSurfaceInfo Surf; - gr_sidedef = gr_curline->sidedef; - gr_linedef = gr_curline->linedef; + gl_sidedef = gl_curline->sidedef; + gl_linedef = gl_curline->linedef; - vs.x = ((polyvertex_t *)gr_curline->pv1)->x; - vs.y = ((polyvertex_t *)gr_curline->pv1)->y; - ve.x = ((polyvertex_t *)gr_curline->pv2)->x; - ve.y = ((polyvertex_t *)gr_curline->pv2)->y; + vs.x = ((polyvertex_t *)gl_curline->pv1)->x; + vs.y = ((polyvertex_t *)gl_curline->pv1)->y; + ve.x = ((polyvertex_t *)gl_curline->pv2)->x; + ve.y = ((polyvertex_t *)gl_curline->pv2)->y; v1x = FLOAT_TO_FIXED(vs.x); v1y = FLOAT_TO_FIXED(vs.y); @@ -1082,8 +1082,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end2 = P_GetZAt(slope, v2x, v2y, normalheight); - SLOPEPARAMS(gr_frontsector->c_slope, worldtop, worldtopslope, gr_frontsector->ceilingheight) - SLOPEPARAMS(gr_frontsector->f_slope, worldbottom, worldbottomslope, gr_frontsector->floorheight) + SLOPEPARAMS(gl_frontsector->c_slope, worldtop, worldtopslope, gl_frontsector->ceilingheight) + SLOPEPARAMS(gl_frontsector->f_slope, worldbottom, worldbottomslope, gl_frontsector->floorheight) // remember vertices ordering // 3--2 @@ -1099,84 +1099,84 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // x offset the texture { - fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; + fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset; cliplow = (float)texturehpeg; - cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); + cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT)); } - lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); - colormap = gr_frontsector->extra_colormap; + lightnum = HWR_CalcWallLight(gl_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); + colormap = gl_frontsector->extra_colormap; - if (gr_frontsector) + if (gl_frontsector) Surf.PolyColor.s.alpha = 255; - if (gr_backsector) + if (gl_backsector) { - INT32 gr_toptexture = 0, gr_bottomtexture = 0; + INT32 gl_toptexture = 0, gl_bottomtexture = 0; // two sided line boolean bothceilingssky = false; // turned on if both back and front ceilings are sky boolean bothfloorssky = false; // likewise, but for floors - SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) - SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) + SLOPEPARAMS(gl_backsector->c_slope, worldhigh, worldhighslope, gl_backsector->ceilingheight) + SLOPEPARAMS(gl_backsector->f_slope, worldlow, worldlowslope, gl_backsector->floorheight) #undef SLOPEPARAMS // hack to allow height changes in outdoor areas // This is what gets rid of the upper textures if there should be sky - if (gr_frontsector->ceilingpic == skyflatnum - && gr_backsector->ceilingpic == skyflatnum) + if (gl_frontsector->ceilingpic == skyflatnum + && gl_backsector->ceilingpic == skyflatnum) { bothceilingssky = true; } // likewise, but for floors and upper textures - if (gr_frontsector->floorpic == skyflatnum - && gr_backsector->floorpic == skyflatnum) + if (gl_frontsector->floorpic == skyflatnum + && gl_backsector->floorpic == skyflatnum) { bothfloorssky = true; } if (!bothceilingssky) - gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); + gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); if (!bothfloorssky) - gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); + gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); // check TOP TEXTURE - if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture) + if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture) { { fixed_t texturevpegtop; // top - grTex = HWR_GetTexture(gr_toptexture); + grTex = HWR_GetTexture(gl_toptexture); // PEGGING - if (gr_linedef->flags & ML_DONTPEGTOP) + if (gl_linedef->flags & ML_DONTPEGTOP) texturevpegtop = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; + else if (gl_linedef->flags & ML_EFFECT1) + texturevpegtop = worldhigh + textureheight[gl_sidedef->toptexture] - worldtop; else - texturevpegtop = gr_backsector->ceilingheight + textureheight[gr_sidedef->toptexture] - gr_frontsector->ceilingheight; + texturevpegtop = gl_backsector->ceilingheight + textureheight[gl_sidedef->toptexture] - gl_frontsector->ceilingheight; - texturevpegtop += gr_sidedef->rowoffset; + texturevpegtop += gl_sidedef->rowoffset; // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegtop %= SHORT(textures[gr_toptexture]->height)<height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * grTex->scaleY; wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) + if (!(gl_linedef->flags & ML_EFFECT1)) { // Unskewed - wallVerts[3].t -= (worldtop - gr_frontsector->ceilingheight) * grTex->scaleY; - wallVerts[2].t -= (worldtopslope - gr_frontsector->ceilingheight) * grTex->scaleY; - wallVerts[0].t -= (worldhigh - gr_backsector->ceilingheight) * grTex->scaleY; - wallVerts[1].t -= (worldhighslope - gr_backsector->ceilingheight) * grTex->scaleY; + wallVerts[3].t -= (worldtop - gl_frontsector->ceilingheight) * grTex->scaleY; + wallVerts[2].t -= (worldtopslope - gl_frontsector->ceilingheight) * grTex->scaleY; + wallVerts[0].t -= (worldhigh - gl_backsector->ceilingheight) * grTex->scaleY; + wallVerts[1].t -= (worldhighslope - gl_backsector->ceilingheight) * grTex->scaleY; } - else if (gr_linedef->flags & ML_DONTPEGTOP) + else if (gl_linedef->flags & ML_DONTPEGTOP) { // Skewed by top wallVerts[0].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY; @@ -1197,10 +1197,10 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); - if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, &Surf, FF_CUTLEVEL, NULL); + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL); else if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1208,41 +1208,41 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check BOTTOM TEXTURE if (( worldlowslope > worldbottomslope || - worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! + worldlow > worldbottom) && gl_bottomtexture) //only if VISIBLE!!! { { fixed_t texturevpegbottom = 0; // bottom - grTex = HWR_GetTexture(gr_bottomtexture); + grTex = HWR_GetTexture(gl_bottomtexture); // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + if (!(gl_linedef->flags & ML_DONTPEGBOTTOM)) texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) + else if (gl_linedef->flags & ML_EFFECT1) texturevpegbottom = worldbottom - worldlow; else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; + texturevpegbottom = gl_frontsector->floorheight - gl_backsector->floorheight; - texturevpegbottom += gr_sidedef->rowoffset; + texturevpegbottom += gl_sidedef->rowoffset; // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gl_backsector->floorheight - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) + if (!(gl_linedef->flags & ML_EFFECT1)) { // Unskewed - wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; - wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; + wallVerts[0].t -= (worldbottom - gl_frontsector->floorheight) * grTex->scaleY; + wallVerts[1].t -= (worldbottomslope - gl_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t -= (worldlow - gl_backsector->floorheight) * grTex->scaleY; + wallVerts[2].t -= (worldlowslope - gl_backsector->floorheight) * grTex->scaleY; } - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + else if (gl_linedef->flags & ML_DONTPEGBOTTOM) { // Skewed by bottom wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; @@ -1263,15 +1263,15 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); - if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, &Surf, FF_CUTLEVEL, NULL); + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL); else if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); - if (gr_midtexture) + gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); + if (gl_midtexture) { FBITFIELD blendmode; sector_t *front, *back; @@ -1279,19 +1279,19 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t texturevpeg = 0; INT32 repeats; - if (gr_linedef->frontsector->heightsec != -1) - front = §ors[gr_linedef->frontsector->heightsec]; + if (gl_linedef->frontsector->heightsec != -1) + front = §ors[gl_linedef->frontsector->heightsec]; else - front = gr_linedef->frontsector; + front = gl_linedef->frontsector; - if (gr_linedef->backsector->heightsec != -1) - back = §ors[gr_linedef->backsector->heightsec]; + if (gl_linedef->backsector->heightsec != -1) + back = §ors[gl_linedef->backsector->heightsec]; else - back = gr_linedef->backsector; + back = gl_linedef->backsector; - if (gr_sidedef->repeatcnt) - repeats = 1 + gr_sidedef->repeatcnt; - else if (gr_linedef->flags & ML_EFFECT5) + if (gl_sidedef->repeatcnt) + repeats = 1 + gl_sidedef->repeatcnt; + else if (gl_linedef->flags & ML_EFFECT5) { fixed_t high, low; @@ -1305,8 +1305,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else low = back->floorheight; - repeats = (high - low)/textureheight[gr_sidedef->midtexture]; - if ((high-low)%textureheight[gr_sidedef->midtexture]) + repeats = (high - low)/textureheight[gl_sidedef->midtexture]; + if ((high-low)%textureheight[gl_sidedef->midtexture]) repeats++; // tile an extra time to fill the gap -- Monster Iestyn } else @@ -1322,7 +1322,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct // From CB - if (gr_curline->polyseg) + if (gl_curline->polyseg) { popentop = back->ceilingheight; popenbottom = back->floorheight; @@ -1333,33 +1333,33 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom popenbottom = max(worldbottom, worldlow); } - if (gr_linedef->flags & ML_EFFECT2) + if (gl_linedef->flags & ML_EFFECT2) { - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) { - polybottom = max(front->floorheight, back->floorheight) + gr_sidedef->rowoffset; - polytop = polybottom + textureheight[gr_midtexture]*repeats; + polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset; + polytop = polybottom + textureheight[gl_midtexture]*repeats; } else { - polytop = min(front->ceilingheight, back->ceilingheight) + gr_sidedef->rowoffset; - polybottom = polytop - textureheight[gr_midtexture]*repeats; + polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset; + polybottom = polytop - textureheight[gl_midtexture]*repeats; } } - else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + else if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) { - polybottom = popenbottom + gr_sidedef->rowoffset; - polytop = polybottom + textureheight[gr_midtexture]*repeats; + polybottom = popenbottom + gl_sidedef->rowoffset; + polytop = polybottom + textureheight[gl_midtexture]*repeats; } else { - polytop = popentop + gr_sidedef->rowoffset; - polybottom = polytop - textureheight[gr_midtexture]*repeats; + polytop = popentop + gl_sidedef->rowoffset; + polybottom = polytop - textureheight[gl_midtexture]*repeats; } // CB // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct - if (gr_curline->polyseg) + if (gl_curline->polyseg) { lowcut = polybottom; highcut = polytop; @@ -1376,12 +1376,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { // PEGGING - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; + if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) + texturevpeg = textureheight[gl_sidedef->midtexture]*repeats - h + polybottom; else texturevpeg = polytop - h; - grTex = HWR_GetTexture(gr_midtexture); + grTex = HWR_GetTexture(gl_midtexture); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; @@ -1399,9 +1399,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t midtextureslant; - if (gr_linedef->flags & ML_EFFECT2) + if (gl_linedef->flags & ML_EFFECT2) midtextureslant = 0; - else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + else if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) midtextureslant = worldlow < worldbottom ? worldbottomslope-worldbottom : worldlowslope-worldlow; @@ -1426,8 +1426,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { // PEGGING - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; + if (!!(gl_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gl_linedef->flags & ML_EFFECT3)) + texturevpeg = textureheight[gl_sidedef->midtexture]*repeats - h + polybottom; else texturevpeg = polytop - h; wallVerts[2].t = texturevpeg * grTex->scaleY; @@ -1440,7 +1440,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // set alpha for transparent walls (new boom and legacy linedef types) // ooops ! this do not work at all because render order we should render it in backtofront order - switch (gr_linedef->special) + switch (gl_linedef->special) { case 900: blendmode = HWR_TranstableToAlpha(tr_trans10, &Surf); @@ -1493,39 +1493,39 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom break; } - if (gr_curline->polyseg && gr_curline->polyseg->translucency > 0) + if (gl_curline->polyseg && gl_curline->polyseg->translucency > 0) { - if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn + if (gl_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn { Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode blendmode = PF_Masked; } else - blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, &Surf); + blendmode = HWR_TranstableToAlpha(gl_curline->polyseg->translucency, &Surf); } - if (gr_frontsector->numlights) + if (gl_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_TRANSLUCENT, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_TRANSLUCENT, NULL); else { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); } } else if (!(blendmode & PF_Masked)) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } // Sky culling // No longer so much a mess as before! - if (!gr_curline->polyseg) // Don't do it for polyobjects + if (!gl_curline->polyseg) // Don't do it for polyobjects { - if (gr_frontsector->ceilingpic == skyflatnum) + if (gl_frontsector->ceilingpic == skyflatnum) { - if (gr_backsector->ceilingpic != skyflatnum) // don't cull if back sector is also sky + if (gl_backsector->ceilingpic != skyflatnum) // don't cull if back sector is also sky { wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space wallVerts[0].y = FIXED_TO_FLOAT(worldtop); @@ -1534,9 +1534,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - if (gr_frontsector->floorpic == skyflatnum) + if (gl_frontsector->floorpic == skyflatnum) { - if (gr_backsector->floorpic != skyflatnum) // don't cull if back sector is also sky + if (gl_backsector->floorpic != skyflatnum) // don't cull if back sector is also sky { wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); @@ -1549,34 +1549,34 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); - if (gr_midtexture && gr_linedef->special != 41) // (Ignore horizon line for OGL) + gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); + if (gl_midtexture && gl_linedef->special != 41) // (Ignore horizon line for OGL) { { fixed_t texturevpeg; // PEGGING - if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) - texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; + if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) + texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset; + else if (gl_linedef->flags & ML_DONTPEGBOTTOM) + texturevpeg = worldbottom + textureheight[gl_sidedef->midtexture] - worldtop + gl_sidedef->rowoffset; else // top of texture at top - texturevpeg = gr_sidedef->rowoffset; + texturevpeg = gl_sidedef->rowoffset; - grTex = HWR_GetTexture(gr_midtexture); + grTex = HWR_GetTexture(gl_midtexture); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY; wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; // Texture correction for slopes - if (gr_linedef->flags & ML_EFFECT2) { - wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; - wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; - wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; - wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; - } else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { + if (gl_linedef->flags & ML_EFFECT2) { + wallVerts[3].t += (gl_frontsector->ceilingheight - worldtop) * grTex->scaleY; + wallVerts[2].t += (gl_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; + wallVerts[0].t += (gl_frontsector->floorheight - worldbottom) * grTex->scaleY; + wallVerts[1].t += (gl_frontsector->floorheight - worldbottomslope) * grTex->scaleY; + } else if (gl_linedef->flags & ML_DONTPEGBOTTOM) { wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; } else { @@ -1592,27 +1592,27 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); // I don't think that solid walls can use translucent linedef types... - if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL); + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL); else { if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } } - if (!gr_curline->polyseg) + if (!gl_curline->polyseg) { - if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector + if (gl_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } - if (gr_frontsector->floorpic == skyflatnum) + if (gl_frontsector->floorpic == skyflatnum) { wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); @@ -1624,7 +1624,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //Hurdler: 3d-floors test - if (gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) + if (gl_frontsector && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) { ffloor_t * rover; fixed_t highcut = 0, lowcut = 0; @@ -1634,12 +1634,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom ///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope /// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C - highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; - lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight; + highcut = gl_frontsector->ceilingheight < gl_backsector->ceilingheight ? gl_frontsector->ceilingheight : gl_backsector->ceilingheight; + lowcut = gl_frontsector->floorheight > gl_backsector->floorheight ? gl_frontsector->floorheight : gl_backsector->floorheight; - if (gr_backsector->ffloors) + if (gl_backsector->ffloors) { - for (rover = gr_backsector->ffloors; rover; rover = rover->next) + for (rover = gl_backsector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; @@ -1652,7 +1652,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = gr_curline->linedef-gr_backsector->lines[0]; + size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -1661,9 +1661,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom hS = P_GetFFloorTopZAt (rover, v2x, v2y); l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) + if (!(*rover->t_slope) && !gl_frontsector->c_slope && !gl_backsector->c_slope && h > highcut) h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) + if (!(*rover->b_slope) && !gl_frontsector->f_slope && !gl_backsector->f_slope && l < lowcut) l = lS = lowcut; //Hurdler: HW code starts here //FIXME: check if peging is correct @@ -1698,7 +1698,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { texturevpeg = sides[rover->master->sidenum[0]].rowoffset; - attachtobottom = !!(gr_linedef->flags & ML_DONTPEGBOTTOM); + attachtobottom = !!(gl_linedef->flags & ML_DONTPEGBOTTOM); slopeskew = !!(rover->master->flags & ML_DONTPEGTOP); } @@ -1743,8 +1743,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); - if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, 0, &Surf, rover->flags, rover); + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->flags, rover); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1758,8 +1758,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } - if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, texnum, &Surf, rover->flags, rover); + if (gl_frontsector->numlights) + HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->flags, rover); else { if (blendmode != PF_Masked) @@ -1771,9 +1771,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - if (gr_frontsector->ffloors) // Putting this seperate should allow 2 FOF sectors to be connected without too many errors? I think? + if (gl_frontsector->ffloors) // Putting this seperate should allow 2 FOF sectors to be connected without too many errors? I think? { - for (rover = gr_frontsector->ffloors; rover; rover = rover->next) + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES)) continue; @@ -1786,7 +1786,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->master->flags & ML_TFERLINE) { - size_t linenum = gr_curline->linedef-gr_backsector->lines[0]; + size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } @@ -1794,9 +1794,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom hS = P_GetFFloorTopZAt (rover, v2x, v2y); l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) + if (!(*rover->t_slope) && !gl_frontsector->c_slope && !gl_backsector->c_slope && h > highcut) h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) + if (!(*rover->b_slope) && !gl_frontsector->f_slope && !gl_backsector->f_slope && l < lowcut) l = lS = lowcut; //Hurdler: HW code starts here //FIXME: check if peging is correct @@ -1843,8 +1843,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); - if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, 0, &Surf, rover->flags, rover); + if (gl_backsector->numlights) + HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->flags, rover); else HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); } @@ -1858,8 +1858,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; } - if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, texnum, &Surf, rover->flags, rover); + if (gl_backsector->numlights) + HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->flags, rover); else { if (blendmode != PF_Masked) @@ -1898,10 +1898,10 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y); + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); #define SLOPEPARAMS(slope, end1, end2, normalheight) \ end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end2 = P_GetZAt(slope, v2x, v2y, normalheight); @@ -1972,17 +1972,17 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks // hw_newend is one past the last valid seg static cliprange_t * hw_newend; -static cliprange_t gr_solidsegs[MAXSEGS]; +static cliprange_t gl_solidsegs[MAXSEGS]; // needs fix: walls are incorrectly clipped one column less -static consvar_t cv_grclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_glclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void printsolidsegs(void) { cliprange_t * start; if (!hw_newend) return; - for (start = gr_solidsegs;start != hw_newend;start++) + for (start = gl_solidsegs;start != hw_newend;start++) { CONS_Debug(DBG_RENDER, "%d-%d|",start->first,start->last); } @@ -2000,7 +2000,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) // Find the first range that touches the range // (adjacent pixels are touching). - start = gr_solidsegs; + start = gl_solidsegs; while (start->last < first-1) start++; @@ -2028,14 +2028,14 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) } // There is a fragment above *start. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(first, last); poorhack = true; } else { - highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(0, highfrac); } // Now adjust the clip size. @@ -2052,15 +2052,15 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) while (last >= (next+1)->first-1) { // There is a fragment between two posts. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(first,last); poorhack = true; } else { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); - highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); + highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(lowfrac, highfrac); } next++; @@ -2076,7 +2076,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) if (first == next->first+1) // 1 line texture { - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(first,last); poorhack = true; @@ -2087,14 +2087,14 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) else { // There is a fragment after *next. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(first,last); poorhack = true; } else { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(lowfrac, 1); } } @@ -2135,7 +2135,7 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) // Find the first range that touches the range // (adjacent pixels are touching). - start = gr_solidsegs; + start = gl_solidsegs; while (start->last < first - 1) start++; @@ -2149,7 +2149,7 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) } // There is a fragment above *start. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { //20/08/99: Changed by Hurdler (taken from faB's code) if (!poorhack) HWR_StoreWallRange(0, 1); poorhack = true; @@ -2157,8 +2157,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) else { highfrac = HWR_ClipViewSegment(min(start->first + 1, - start->last), (polyvertex_t *)gr_curline->pv1, - (polyvertex_t *)gr_curline->pv2); + start->last), (polyvertex_t *)gl_curline->pv1, + (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(0, highfrac); } } @@ -2170,15 +2170,15 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) while (last >= (start+1)->first-1) { // There is a fragment between two posts. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(0, 1); poorhack = true; } else { - lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); - highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2); + lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); + highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(lowfrac, highfrac); } start++; @@ -2189,7 +2189,7 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) if (first == start->first+1) // 1 line texture { - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(0, 1); poorhack = true; @@ -2200,7 +2200,7 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) else { // There is a fragment after *next. - if (!cv_grclipwalls.value) + if (!cv_glclipwalls.value) { if (!poorhack) HWR_StoreWallRange(0,1); poorhack = true; @@ -2208,8 +2208,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last) else { lowfrac = HWR_ClipViewSegment(max(start->last - 1, - start->first), (polyvertex_t *)gr_curline->pv1, - (polyvertex_t *)gr_curline->pv2); + start->first), (polyvertex_t *)gl_curline->pv1, + (polyvertex_t *)gl_curline->pv2); HWR_StoreWallRange(lowfrac, 1); } } @@ -2224,7 +2224,7 @@ static boolean HWR_ClipToSolidSegs(INT32 first, INT32 last) // Find the first range that touches the range // (adjacent pixels are touching). - start = gr_solidsegs; + start = gl_solidsegs; while (start->last < first-1) start++; @@ -2243,17 +2243,17 @@ static boolean HWR_ClipToSolidSegs(INT32 first, INT32 last) // static void HWR_ClearClipSegs(void) { - gr_solidsegs[0].first = -0x7fffffff; - gr_solidsegs[0].last = -1; - gr_solidsegs[1].first = vid.width; //viewwidth; - gr_solidsegs[1].last = 0x7fffffff; - hw_newend = gr_solidsegs+2; + gl_solidsegs[0].first = -0x7fffffff; + gl_solidsegs[0].last = -1; + gl_solidsegs[1].first = vid.width; //viewwidth; + gl_solidsegs[1].last = 0x7fffffff; + hw_newend = gl_solidsegs+2; } #endif // NEWCLIP // -----------------+ // HWR_AddLine : Clips the given segment and adds any visible pieces to the line list. -// Notes : gr_cursectorlight is set to the current subsector -> sector -> light value +// Notes : gl_cursectorlight is set to the current subsector -> sector -> light value // : (it may be mixed with the wall's own flat colour in the future ...) // -----------------+ static void HWR_AddLine(seg_t * line) @@ -2272,12 +2272,12 @@ static void HWR_AddLine(seg_t * line) if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; - gr_curline = line; + gl_curline = line; - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y); - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y); + v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); // OPTIMIZE: quickly reject orthogonal back sides. angle1 = R_PointToAngle(v1x, v1y); @@ -2309,27 +2309,27 @@ static void HWR_AddLine(seg_t * line) angle1 -= dup_viewangle; angle2 -= dup_viewangle; - tspan = angle1 + gr_clipangle; - if (tspan > 2*gr_clipangle) + tspan = angle1 + gl_clipangle; + if (tspan > 2*gl_clipangle) { - tspan -= 2*gr_clipangle; + tspan -= 2*gl_clipangle; // Totally off the left edge? if (tspan >= span) return; - angle1 = gr_clipangle; + angle1 = gl_clipangle; } - tspan = gr_clipangle - angle2; - if (tspan > 2*gr_clipangle) + tspan = gl_clipangle - angle2; + if (tspan > 2*gl_clipangle) { - tspan -= 2*gr_clipangle; + tspan -= 2*gl_clipangle; // Totally off the left edge? if (tspan >= span) return; - angle2 = (angle_t)-(signed)gr_clipangle; + angle2 = (angle_t)-(signed)gl_clipangle; } #if 0 @@ -2337,23 +2337,23 @@ static void HWR_AddLine(seg_t * line) float fx1,fx2,fy1,fy2; //BP: test with a better projection than viewangletox[R_PointToAngle(angle)] // do not enable this at release 4 mul and 2 div - fx1 = ((polyvertex_t *)(line->pv1))->x-gr_viewx; - fy1 = ((polyvertex_t *)(line->pv1))->y-gr_viewy; - fy2 = (fx1 * gr_viewcos + fy1 * gr_viewsin); + fx1 = ((polyvertex_t *)(line->pv1))->x-gl_viewx; + fy1 = ((polyvertex_t *)(line->pv1))->y-gl_viewy; + fy2 = (fx1 * gl_viewcos + fy1 * gl_viewsin); if (fy2 < 0) // the point is back fx1 = 0; else - fx1 = gr_windowcenterx + (fx1 * gr_viewsin - fy1 * gr_viewcos) * gr_centerx / fy2; + fx1 = gl_windowcenterx + (fx1 * gl_viewsin - fy1 * gl_viewcos) * gl_centerx / fy2; - fx2 = ((polyvertex_t *)(line->pv2))->x-gr_viewx; - fy2 = ((polyvertex_t *)(line->pv2))->y-gr_viewy; - fy1 = (fx2 * gr_viewcos + fy2 * gr_viewsin); + fx2 = ((polyvertex_t *)(line->pv2))->x-gl_viewx; + fy2 = ((polyvertex_t *)(line->pv2))->y-gl_viewy; + fy1 = (fx2 * gl_viewcos + fy2 * gl_viewsin); if (fy1 < 0) // the point is back fx2 = vid.width; else - fx2 = gr_windowcenterx + (fx2 * gr_viewsin - fy2 * gr_viewcos) * gr_centerx / fy1; + fx2 = gl_windowcenterx + (fx2 * gl_viewsin - fy2 * gl_viewcos) * gl_centerx / fy1; x1 = fx1+0.5f; x2 = fx2+0.5f; @@ -2364,8 +2364,8 @@ static void HWR_AddLine(seg_t * line) angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT; - x1 = gr_viewangletox[angle1]; - x2 = gr_viewangletox[angle2]; + x1 = gl_viewangletox[angle1]; + x2 = gl_viewangletox[angle2]; #endif // Does not cross a pixel? // if (x1 == x2) @@ -2377,7 +2377,7 @@ static void HWR_AddLine(seg_t * line) */ #endif - gr_backsector = line->backsector; + gl_backsector = line->backsector; #ifdef NEWCLIP if (!line->backsector) @@ -2388,26 +2388,26 @@ static void HWR_AddLine(seg_t * line) { boolean bothceilingssky = false, bothfloorssky = false; - gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) + if (gl_backsector->ceilingpic == skyflatnum && gl_frontsector->ceilingpic == skyflatnum) bothceilingssky = true; - if (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) + if (gl_backsector->floorpic == skyflatnum && gl_frontsector->floorpic == skyflatnum) bothfloorssky = true; if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then { if (!line->polyseg && !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) + && ((!gl_frontsector->ffloors && !gl_backsector->ffloors) + || (gl_frontsector->tag == gl_backsector->tag))) return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; } - if (CheckClip(line, gr_frontsector, gr_backsector)) + if (CheckClip(line, gl_frontsector, gl_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); checkforemptylines = false; @@ -2416,7 +2416,7 @@ static void HWR_AddLine(seg_t * line) // Identical floor and ceiling on both sides, // identical light levels on both sides, // and no middle texture. - if (checkforemptylines && R_IsEmptyLine(line, gr_frontsector, gr_backsector)) + if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) return; } @@ -2424,28 +2424,28 @@ static void HWR_AddLine(seg_t * line) return; #else // Single sided line? - if (!gr_backsector) + if (!gl_backsector) goto clipsolid; - gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) + if (gl_backsector->ceilingpic == skyflatnum && gl_frontsector->ceilingpic == skyflatnum) bothceilingssky = true; - if (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) + if (gl_backsector->floorpic == skyflatnum && gl_frontsector->floorpic == skyflatnum) bothfloorssky = true; if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then { if (!line->polyseg && !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) + && ((!gl_frontsector->ffloors && !gl_backsector->ffloors) + || (gl_frontsector->tag == gl_backsector->tag))) return; // line is empty, don't even bother goto clippass; // treat like wide open window instead } - if (gr_frontsector->f_slope || gr_frontsector->c_slope || gr_backsector->f_slope || gr_backsector->c_slope) + if (gl_frontsector->f_slope || gl_frontsector->c_slope || gl_backsector->f_slope || gl_backsector->c_slope) { fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends @@ -2454,10 +2454,10 @@ static void HWR_AddLine(seg_t * line) end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end2 = P_GetZAt(slope, v2x, v2y, normalheight); - SLOPEPARAMS(gr_frontsector->f_slope, frontf1, frontf2, gr_frontsector-> floorheight) - SLOPEPARAMS(gr_frontsector->c_slope, frontc1, frontc2, gr_frontsector->ceilingheight) - SLOPEPARAMS( gr_backsector->f_slope, backf1, backf2, gr_backsector-> floorheight) - SLOPEPARAMS( gr_backsector->c_slope, backc1, backc2, gr_backsector->ceilingheight) + SLOPEPARAMS(gl_frontsector->f_slope, frontf1, frontf2, gl_frontsector-> floorheight) + SLOPEPARAMS(gl_frontsector->c_slope, frontc1, frontc2, gl_frontsector->ceilingheight) + SLOPEPARAMS( gl_backsector->f_slope, backf1, backf2, gl_backsector-> floorheight) + SLOPEPARAMS( gl_backsector->c_slope, backc1, backc2, gl_backsector->ceilingheight) #undef SLOPEPARAMS // if both ceilings are skies, consider it always "open" // same for floors @@ -2472,8 +2472,8 @@ static void HWR_AddLine(seg_t * line) // Check for automap fix. if (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture)) + && ((backc1 >= frontc1 && backc2 >= frontc2) || gl_curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || gl_curline->sidedef->bottomtexture)) goto clipsolid; } @@ -2492,23 +2492,23 @@ static void HWR_AddLine(seg_t * line) if (!bothceilingssky && !bothfloorssky) { // Closed door. - if (gr_backsector->ceilingheight <= gr_frontsector->floorheight || - gr_backsector->floorheight >= gr_frontsector->ceilingheight) + if (gl_backsector->ceilingheight <= gl_frontsector->floorheight || + gl_backsector->floorheight >= gl_frontsector->ceilingheight) goto clipsolid; // Check for automap fix. - if (gr_backsector->ceilingheight <= gr_backsector->floorheight - && ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture) - && ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture)) + if (gl_backsector->ceilingheight <= gl_backsector->floorheight + && ((gl_backsector->ceilingheight >= gl_frontsector->ceilingheight) || gl_curline->sidedef->toptexture) + && ((gl_backsector->floorheight <= gl_backsector->floorheight) || gl_curline->sidedef->bottomtexture)) goto clipsolid; } // Window. if (!bothceilingssky) // ceilings are always the "same" when sky - if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight) + if (gl_backsector->ceilingheight != gl_frontsector->ceilingheight) goto clippass; if (!bothfloorssky) // floors are always the "same" when sky - if (gr_backsector->floorheight != gr_frontsector->floorheight) + if (gl_backsector->floorheight != gl_frontsector->floorheight) goto clippass; } @@ -2516,7 +2516,7 @@ static void HWR_AddLine(seg_t * line) // Identical floor and ceiling on both sides, // identical light levels on both sides, // and no middle texture. - if (R_IsEmptyLine(gr_curline, gr_frontsector, gr_backsector)) + if (R_IsEmptyLine(gl_curline, gl_frontsector, gl_backsector)) return; clippass: @@ -2588,28 +2588,28 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) if (span >= ANGLE_180) return true; - tspan = angle1 + gr_clipangle; + tspan = angle1 + gl_clipangle; - if (tspan > 2*gr_clipangle) + if (tspan > 2*gl_clipangle) { - tspan -= 2*gr_clipangle; + tspan -= 2*gl_clipangle; // Totally off the left edge? if (tspan >= span) return false; - angle1 = gr_clipangle; + angle1 = gl_clipangle; } - tspan = gr_clipangle - angle2; - if (tspan > 2*gr_clipangle) + tspan = gl_clipangle - angle2; + if (tspan > 2*gl_clipangle) { - tspan -= 2*gr_clipangle; + tspan -= 2*gl_clipangle; // Totally off the left edge? if (tspan >= span) return false; - angle2 = (angle_t)-(signed)gr_clipangle; + angle2 = (angle_t)-(signed)gl_clipangle; } // Find the first clippost @@ -2617,8 +2617,8 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) // (adjacent pixels are touching). angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT; - sx1 = gr_viewangletox[angle1]; - sx2 = gr_viewangletox[angle2]; + sx1 = gl_viewangletox[angle1]; + sx2 = gl_viewangletox[angle2]; // Does not cross a pixel. if (sx1 == sx2) @@ -2638,7 +2638,7 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) static inline void HWR_AddPolyObjectSegs(void) { size_t i, j; - seg_t *gr_fakeline = Z_Calloc(sizeof(seg_t), PU_STATIC, NULL); + seg_t *gl_fakeline = Z_Calloc(sizeof(seg_t), PU_STATIC, NULL); polyvertex_t *pv1 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL); polyvertex_t *pv2 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL); @@ -2649,25 +2649,25 @@ static inline void HWR_AddPolyObjectSegs(void) for (j = 0; j < po_ptrs[i]->segCount; ++j) { // Copy the info of a polyobject's seg, then convert it to OpenGL floating point - M_Memcpy(gr_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t)); + M_Memcpy(gl_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t)); // Now convert the line to float and add it to be rendered - pv1->x = FIXED_TO_FLOAT(gr_fakeline->v1->x); - pv1->y = FIXED_TO_FLOAT(gr_fakeline->v1->y); - pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x); - pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y); + pv1->x = FIXED_TO_FLOAT(gl_fakeline->v1->x); + pv1->y = FIXED_TO_FLOAT(gl_fakeline->v1->y); + pv2->x = FIXED_TO_FLOAT(gl_fakeline->v2->x); + pv2->y = FIXED_TO_FLOAT(gl_fakeline->v2->y); - gr_fakeline->pv1 = pv1; - gr_fakeline->pv2 = pv2; + gl_fakeline->pv1 = pv1; + gl_fakeline->pv2 = pv2; - HWR_AddLine(gr_fakeline); + HWR_AddLine(gl_fakeline); } } // Free temporary data no longer needed Z_Free(pv2); Z_Free(pv1); - Z_Free(gr_fakeline); + Z_Free(gl_fakeline); } static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, @@ -2778,19 +2778,19 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } - else if (gr_frontsector) + else if (gl_frontsector) { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth; - scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight; - angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatheight; + angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth; - scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight; - angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatheight; + angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -2874,11 +2874,11 @@ static void HWR_AddPolyObjectPlanes(void) if (po_ptrs[i]->translucency >= NUMTRANSMAPS) continue; - if (polyobjsector->floorheight <= gr_frontsector->ceilingheight - && polyobjsector->floorheight >= gr_frontsector->floorheight + if (polyobjsector->floorheight <= gl_frontsector->ceilingheight + && polyobjsector->floorheight >= gl_frontsector->floorheight && (viewz < polyobjsector->floorheight)) { - light = R_GetPlaneLight(gr_frontsector, polyobjsector->floorheight, true); + light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; @@ -2886,22 +2886,22 @@ static void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->floorpic], po_ptrs[i], false, polyobjsector->floorheight, - (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); + (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : *gl_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetLevelFlat(&levelflats[polyobjsector->floorpic]); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->floorpic], - polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); + (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->floorpic], + polyobjsector, 255, (light == -1 ? gl_frontsector->extra_colormap : *gl_frontsector->lightlist[light].extra_colormap)); } } - if (polyobjsector->ceilingheight >= gr_frontsector->floorheight - && polyobjsector->ceilingheight <= gr_frontsector->ceilingheight + if (polyobjsector->ceilingheight >= gl_frontsector->floorheight + && polyobjsector->ceilingheight <= gl_frontsector->ceilingheight && (viewz > polyobjsector->ceilingheight)) { - light = R_GetPlaneLight(gr_frontsector, polyobjsector->ceilingheight, true); + light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; @@ -2909,14 +2909,14 @@ static void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->ceilingpic], po_ptrs[i], true, polyobjsector->ceilingheight, - (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); + (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : *gl_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetLevelFlat(&levelflats[polyobjsector->ceilingpic]); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->ceilingpic], - polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); + (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->ceilingpic], + polyobjsector, 255, (light == -1 ? gl_frontsector->extra_colormap : *gl_frontsector->lightlist[light].extra_colormap)); } } } @@ -2926,7 +2926,7 @@ static void HWR_AddPolyObjectPlanes(void) // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. // : Draw one or more line segments. -// Notes : Sets gr_cursectorlight to the light of the parent sector, to modulate wall textures +// Notes : Sets gl_cursectorlight to the light of the parent sector, to modulate wall textures // -----------------+ static void HWR_Subsector(size_t num) { @@ -2958,7 +2958,7 @@ static void HWR_Subsector(size_t num) // subsector sub = &subsectors[num]; // sector - gr_frontsector = sub->sector; + gl_frontsector = sub->sector; // how many linedefs count = sub->numlines; // first line seg @@ -2968,96 +2968,96 @@ static void HWR_Subsector(size_t num) { // there are no segs but only planes sub = &subsectors[0]; - gr_frontsector = sub->sector; + gl_frontsector = sub->sector; count = 0; line = NULL; } //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. - gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel, + gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. - floorcolormap = ceilingcolormap = gr_frontsector->extra_colormap; + floorcolormap = ceilingcolormap = gl_frontsector->extra_colormap; // ------------------------------------------------------------------------ // sector lighting, DISABLED because it's done in HWR_StoreWallRange // ------------------------------------------------------------------------ /// \todo store a RGBA instead of just intensity, allow coloured sector lighting //light = (FUBYTE)(sub->sector->lightlevel & 0xFF) / 255.0f; - //gr_cursectorlight.red = light; - //gr_cursectorlight.green = light; - //gr_cursectorlight.blue = light; - //gr_cursectorlight.alpha = light; + //gl_cursectorlight.red = light; + //gl_cursectorlight.green = light; + //gl_cursectorlight.blue = light; + //gl_cursectorlight.alpha = light; // ----- for special tricks with HW renderer ----- - if (gr_frontsector->pseudoSector) + if (gl_frontsector->pseudoSector) { - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; + cullFloorHeight = locFloorHeight = gl_frontsector->virtualFloorheight; + cullCeilingHeight = locCeilingHeight = gl_frontsector->virtualCeilingheight; } - else if (gr_frontsector->virtualFloor) + else if (gl_frontsector->virtualFloor) { ///@TODO Is this whole virtualFloor mess even useful? I don't think it even triggers ever. - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - if (gr_frontsector->virtualCeiling) - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; + cullFloorHeight = locFloorHeight = gl_frontsector->virtualFloorheight; + if (gl_frontsector->virtualCeiling) + cullCeilingHeight = locCeilingHeight = gl_frontsector->virtualCeilingheight; else - cullCeilingHeight = locCeilingHeight = gr_frontsector->ceilingheight; + cullCeilingHeight = locCeilingHeight = gl_frontsector->ceilingheight; } - else if (gr_frontsector->virtualCeiling) + else if (gl_frontsector->virtualCeiling) { - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - cullFloorHeight = locFloorHeight = gr_frontsector->floorheight; + cullCeilingHeight = locCeilingHeight = gl_frontsector->virtualCeilingheight; + cullFloorHeight = locFloorHeight = gl_frontsector->floorheight; } else { - cullFloorHeight = P_GetSectorFloorZAt (gr_frontsector, viewx, viewy); - cullCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, viewx, viewy); - locFloorHeight = P_GetSectorFloorZAt (gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - locCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); + cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); + locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); } // ----- end special tricks ----- - if (gr_frontsector->ffloors) + if (gl_frontsector->ffloors) { - if (gr_frontsector->moved) + if (gl_frontsector->moved) { - gr_frontsector->numlights = sub->sector->numlights = 0; - R_Prep3DFloors(gr_frontsector); - sub->sector->lightlist = gr_frontsector->lightlist; - sub->sector->numlights = gr_frontsector->numlights; - sub->sector->moved = gr_frontsector->moved = false; + gl_frontsector->numlights = sub->sector->numlights = 0; + R_Prep3DFloors(gl_frontsector); + sub->sector->lightlist = gl_frontsector->lightlist; + sub->sector->numlights = gl_frontsector->numlights; + sub->sector->moved = gl_frontsector->moved = false; } - light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); - if (gr_frontsector->floorlightsec == -1) - floorlightlevel = *gr_frontsector->lightlist[light].lightlevel; - floorcolormap = *gr_frontsector->lightlist[light].extra_colormap; + light = R_GetPlaneLight(gl_frontsector, locFloorHeight, false); + if (gl_frontsector->floorlightsec == -1) + floorlightlevel = *gl_frontsector->lightlist[light].lightlevel; + floorcolormap = *gl_frontsector->lightlist[light].extra_colormap; - light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); - if (gr_frontsector->ceilinglightsec == -1) - ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel; - ceilingcolormap = *gr_frontsector->lightlist[light].extra_colormap; + light = R_GetPlaneLight(gl_frontsector, locCeilingHeight, false); + if (gl_frontsector->ceilinglightsec == -1) + ceilinglightlevel = *gl_frontsector->lightlist[light].lightlevel; + ceilingcolormap = *gl_frontsector->lightlist[light].extra_colormap; } - sub->sector->extra_colormap = gr_frontsector->extra_colormap; + sub->sector->extra_colormap = gl_frontsector->extra_colormap; // render floor ? #ifdef DOPLANES // yeah, easy backface cull! :) if (cullFloorHeight < dup_viewz) { - if (gr_frontsector->floorpic != skyflatnum) + if (gl_frontsector->floorpic != skyflatnum) { if (sub->validcount != validcount) { - HWR_GetLevelFlat(&levelflats[gr_frontsector->floorpic]); + HWR_GetLevelFlat(&levelflats[gl_frontsector->floorpic]); HWR_RenderPlane(sub, &extrasubsectors[num], false, // Hack to make things continue to work around slopes. - locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, + locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, floorlightlevel, &levelflats[gr_frontsector->floorpic], NULL, 255, floorcolormap); + PF_Occlude, floorlightlevel, &levelflats[gl_frontsector->floorpic], NULL, 255, floorcolormap); } } else @@ -3070,16 +3070,16 @@ static void HWR_Subsector(size_t num) if (cullCeilingHeight > dup_viewz) { - if (gr_frontsector->ceilingpic != skyflatnum) + if (gl_frontsector->ceilingpic != skyflatnum) { if (sub->validcount != validcount) { - HWR_GetLevelFlat(&levelflats[gr_frontsector->ceilingpic]); + HWR_GetLevelFlat(&levelflats[gl_frontsector->ceilingpic]); HWR_RenderPlane(sub, &extrasubsectors[num], true, // Hack to make things continue to work around slopes. - locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, + locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, &levelflats[gr_frontsector->ceilingpic], NULL, 255, ceilingcolormap); + PF_Occlude, ceilinglightlevel, &levelflats[gl_frontsector->ceilingpic], NULL, 255, ceilingcolormap); } } else @@ -3092,23 +3092,23 @@ static void HWR_Subsector(size_t num) #ifndef POLYSKY // Moved here because before, when above the ceiling and the floor does not have the sky flat, it doesn't draw the sky - if (gr_frontsector->ceilingpic == skyflatnum || gr_frontsector->floorpic == skyflatnum) + if (gl_frontsector->ceilingpic == skyflatnum || gl_frontsector->floorpic == skyflatnum) drawsky = true; #endif #ifdef R_FAKEFLOORS - if (gr_frontsector->ffloors) + if (gl_frontsector->ffloors) { /// \todo fix light, xoffs, yoffs, extracolormap ? ffloor_t * rover; - for (rover = gr_frontsector->ffloors; + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { fixed_t cullHeight, centerHeight; // bottom plane cullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; @@ -3124,41 +3124,41 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], false, *rover->bottomheight, - *gr_frontsector->lightlist[light].lightlevel, + *gl_frontsector->lightlist[light].lightlevel, alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&levelflats[*rover->bottompic], &extrasubsectors[num], false, *rover->bottomheight, - *gr_frontsector->lightlist[light].lightlevel, + *gl_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, - false, *gr_frontsector->lightlist[light].extra_colormap); + false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->bottompic]); - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], - rover->master->frontsector, 255, *gr_frontsector->lightlist[light].extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], + rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } // top plane cullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - centerHeight = P_GetFFloorTopZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && @@ -3169,35 +3169,35 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], true, *rover->topheight, - *gr_frontsector->lightlist[light].lightlevel, + *gl_frontsector->lightlist[light].lightlevel, alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&levelflats[*rover->toppic], &extrasubsectors[num], true, *rover->topheight, - *gr_frontsector->lightlist[light].lightlevel, + *gl_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, - false, *gr_frontsector->lightlist[light].extra_colormap); + false, *gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetLevelFlat(&levelflats[*rover->toppic]); - light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], - rover->master->frontsector, 255, *gr_frontsector->lightlist[light].extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], + rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } } @@ -3243,11 +3243,11 @@ static void HWR_Subsector(size_t num) { // draw sprites first, coz they are clipped to the solidsegs of // subsectors more 'in front' - HWR_AddSprites(gr_frontsector); + HWR_AddSprites(gl_frontsector); //Hurdler: at this point validcount must be the same, but is not because - // gr_frontsector doesn't point anymore to sub->sector due to - // the call gr_frontsector = R_FakeFlat(...) + // gl_frontsector doesn't point anymore to sub->sector due to + // the call gl_frontsector = R_FakeFlat(...) // if it's not done, the sprite is drawn more than once, // what looks really bad with translucency or dynamic light, // without talking about the overdraw of course. @@ -3335,12 +3335,12 @@ static void HWR_RenderBSPNode(INT32 bspnum) { if (bspnum == -1) { - //*(gr_drawsubsector_p++) = 0; + //*(gl_drawsubsector_p++) = 0; HWR_Subsector(0); } else { - //*(gr_drawsubsector_p++) = bspnum&(~NF_SUBSECTOR); + //*(gl_drawsubsector_p++) = bspnum&(~NF_SUBSECTOR); HWR_Subsector(bspnum&(~NF_SUBSECTOR)); } return; @@ -3370,7 +3370,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) // static void HWR_ClearDrawSubsectors(void) { - gr_drawsubsector_p = gr_drawsubsectors; + gl_drawsubsector_p = gl_drawsubsectors; } // @@ -3378,7 +3378,7 @@ static void HWR_ClearDrawSubsectors(void) // static void HWR_RenderSubsectors(void) { - while (gr_drawsubsector_p > gr_drawsubsectors) + while (gl_drawsubsector_p > gl_drawsubsectors) { HWR_RenderBSPNode( lastsubsec->nextsubsec = bspnum & (~NF_SUBSECTOR); @@ -3432,7 +3432,7 @@ void HWR_InitTextureMapping(void) else if (t > grviewwidth+1) t = grviewwidth+1; } - gr_viewangletox[i] = t; + gl_viewangletox[i] = t; } // Scan viewangletox[] to generate xtoviewangle[]: @@ -3441,32 +3441,32 @@ void HWR_InitTextureMapping(void) for (x = 0; x <= grviewwidth; x++) { i = 0; - while (gr_viewangletox[i]>x) + while (gl_viewangletox[i]>x) i++; - gr_xtoviewangle[x] = (i<> VISSPRITECHUNKBITS] = {NULL}; +static UINT32 gl_visspritecount; +static gl_vissprite_t *gl_visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL}; // -------------------------------------------------------------------------- // HWR_ClearSprites @@ -3474,31 +3474,31 @@ static gr_vissprite_t *gr_visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = // -------------------------------------------------------------------------- static void HWR_ClearSprites(void) { - gr_visspritecount = 0; + gl_visspritecount = 0; } // -------------------------------------------------------------------------- // HWR_NewVisSprite // -------------------------------------------------------------------------- -static gr_vissprite_t gr_overflowsprite; +static gl_vissprite_t gl_overflowsprite; -static gr_vissprite_t *HWR_GetVisSprite(UINT32 num) +static gl_vissprite_t *HWR_GetVisSprite(UINT32 num) { UINT32 chunk = num >> VISSPRITECHUNKBITS; // Allocate chunk if necessary - if (!gr_visspritechunks[chunk]) - Z_Malloc(sizeof(gr_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gr_visspritechunks[chunk]); + if (!gl_visspritechunks[chunk]) + Z_Malloc(sizeof(gl_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gl_visspritechunks[chunk]); - return gr_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); + return gl_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK); } -static gr_vissprite_t *HWR_NewVisSprite(void) +static gl_vissprite_t *HWR_NewVisSprite(void) { - if (gr_visspritecount == MAXVISSPRITES) - return &gr_overflowsprite; + if (gl_visspritecount == MAXVISSPRITES) + return &gl_overflowsprite; - return HWR_GetVisSprite(gr_visspritecount++); + return HWR_GetVisSprite(gl_visspritecount++); } // @@ -3561,7 +3561,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) groundz = R_GetShadowZ(thing, &groundslope); - //if (abs(groundz - gr_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes + //if (abs(groundz - gl_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes floordiff = abs((flip < 0 ? thing->height : 0) + thing->z - groundz); @@ -3599,8 +3599,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) { float oldx = shadowVerts[i].x; float oldy = shadowVerts[i].z; - shadowVerts[i].x = fx + ((oldx - fx) * gr_viewcos) - ((oldy - fy) * gr_viewsin); - shadowVerts[i].z = fy + ((oldx - fx) * gr_viewsin) + ((oldy - fy) * gr_viewcos); + shadowVerts[i].x = fx + ((oldx - fx) * gl_viewcos) - ((oldy - fy) * gl_viewsin); + shadowVerts[i].z = fy + ((oldx - fx) * gl_viewsin) + ((oldy - fy) * gl_viewcos); } if (groundslope) @@ -3643,9 +3643,9 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) } // This is expecting a pointer to an array containing 4 wallVerts for a sprite -static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts, const boolean precip) +static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip) { - if (cv_grspritebillboarding.value + if (cv_glspritebillboarding.value && spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) && wallVerts) { @@ -3659,24 +3659,24 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts // X, Y, AND Z need to be manipulated for the polys to rotate around the // origin, because of how the origin setting works I believe that should // be mobj->z or mobj->z + mobj->height - wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gr_viewludsin + basey; - wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gr_viewludsin + basey; + wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gl_viewludsin + basey; + wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gl_viewludsin + basey; // translate back to be around 0 before translating back - wallVerts[3].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; - wallVerts[2].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[3].x += ((spr->ty - basey) * gl_viewludcos) * gl_viewcos; + wallVerts[2].x += ((spr->ty - basey) * gl_viewludcos) * gl_viewcos; - wallVerts[0].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; - wallVerts[1].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[0].x += ((lowy - basey) * gl_viewludcos) * gl_viewcos; + wallVerts[1].x += ((lowy - basey) * gl_viewludcos) * gl_viewcos; - wallVerts[3].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; - wallVerts[2].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[3].z += ((spr->ty - basey) * gl_viewludcos) * gl_viewsin; + wallVerts[2].z += ((spr->ty - basey) * gl_viewludcos) * gl_viewsin; - wallVerts[0].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; - wallVerts[1].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[0].z += ((lowy - basey) * gl_viewludcos) * gl_viewsin; + wallVerts[1].z += ((lowy - basey) * gl_viewludcos) * gl_viewsin; } } -static void HWR_SplitSprite(gr_vissprite_t *spr) +static void HWR_SplitSprite(gl_vissprite_t *spr) { float this_scale = 1.0f; FOutVector wallVerts[4]; @@ -3755,8 +3755,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { - float co = -gr_viewcos*(0.05f*spr->dispoffset); - float si = -gr_viewsin*(0.05f*spr->dispoffset); + float co = -gl_viewcos*(0.05f*spr->dispoffset); + float si = -gl_viewsin*(0.05f*spr->dispoffset); baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; @@ -3875,7 +3875,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_grspritebillboarding.value + if (cv_glspritebillboarding.value && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) { // Get the x and z of the vertices so billboarding draws correctly @@ -3936,7 +3936,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // : (monsters, bonuses, weapons, lights, ...) // Returns : // -----------------+ -static void HWR_DrawSprite(gr_vissprite_t *spr) +static void HWR_DrawSprite(gl_vissprite_t *spr) { float this_scale = 1.0f; FOutVector wallVerts[4]; @@ -4022,8 +4022,8 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { - float co = -gr_viewcos*(0.05f*spr->dispoffset); - float si = -gr_viewsin*(0.05f*spr->dispoffset); + float co = -gl_viewcos*(0.05f*spr->dispoffset); + float si = -gl_viewsin*(0.05f*spr->dispoffset); wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; @@ -4079,7 +4079,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) #ifdef HWPRECIP // Sprite drawer for precipitation -static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) +static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { FBITFIELD blend = 0; FOutVector wallVerts[4]; @@ -4179,14 +4179,14 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) // -------------------------------------------------------------------------- // Sort vissprites by distance // -------------------------------------------------------------------------- -gr_vissprite_t* gr_vsprorder[MAXVISSPRITES]; +gl_vissprite_t* gl_vsprorder[MAXVISSPRITES]; // Note: For more correct transparency the transparent sprites would need to be // sorted and drawn together with transparent surfaces. static int CompareVisSprites(const void *p1, const void *p2) { - gr_vissprite_t* spr1 = *(gr_vissprite_t*const*)p1; - gr_vissprite_t* spr2 = *(gr_vissprite_t*const*)p2; + gl_vissprite_t* spr1 = *(gl_vissprite_t*const*)p1; + gl_vissprite_t* spr2 = *(gl_vissprite_t*const*)p2; int idiff; float fdiff; @@ -4213,11 +4213,11 @@ static int CompareVisSprites(const void *p1, const void *p2) static void HWR_SortVisSprites(void) { UINT32 i; - for (i = 0; i < gr_visspritecount; i++) + for (i = 0; i < gl_visspritecount; i++) { - gr_vsprorder[i] = HWR_GetVisSprite(i); + gl_vsprorder[i] = HWR_GetVisSprite(i); } - qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); + qsort(gl_vsprorder, gl_visspritecount, sizeof(gl_vissprite_t*), CompareVisSprites); } // A drawnode is something that points to a 3D floor, 3D side, or masked @@ -4277,16 +4277,16 @@ static size_t numpolyplanes = 0; // a list of transparent poyobject floors to be static polyplaneinfo_t *polyplaneinfo = NULL; //Hurdler: 3D water sutffs -typedef struct gr_drawnode_s +typedef struct gl_drawnode_s { planeinfo_t *plane; polyplaneinfo_t *polyplane; wallinfo_t *wall; - gr_vissprite_t *sprite; + gl_vissprite_t *sprite; -// struct gr_drawnode_s *next; -// struct gr_drawnode_s *prev; -} gr_drawnode_t; +// struct gl_drawnode_s *next; +// struct gl_drawnode_s *prev; +} gl_drawnode_t; static INT32 drawcount = 0; @@ -4352,7 +4352,7 @@ void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polyse } // putting sortindex and sortnode here so the comparator function can see them -gr_drawnode_t *sortnode; +gl_drawnode_t *sortnode; size_t *sortindex; static int CompareDrawNodes(const void *p1, const void *p2) @@ -4479,8 +4479,8 @@ static void HWR_CreateDrawNodes(void) { if (sortnode[sortindex[i]].plane) { - // We aren't traversing the BSP tree, so make gr_frontsector null to avoid crashes. - gr_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) HWR_GetLevelFlat(sortnode[sortindex[i]].plane->levelflat); @@ -4489,8 +4489,8 @@ static void HWR_CreateDrawNodes(void) } else if (sortnode[sortindex[i]].polyplane) { - // We aren't traversing the BSP tree, so make gr_frontsector null to avoid crashes. - gr_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture)) HWR_GetLevelFlat(sortnode[sortindex[i]].polyplane->levelflat); @@ -4525,10 +4525,10 @@ static void HWR_CreateDrawNodes(void) static void HWR_DrawSprites(void) { UINT32 i; - HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value); - for (i = 0; i < gr_visspritecount; i++) + HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_glmodellighting.value); + for (i = 0; i < gl_visspritecount; i++) { - gr_vissprite_t *spr = gr_vsprorder[i]; + gl_vissprite_t *spr = gl_vsprorder[i]; #ifdef HWPRECIP if (spr->precip) HWR_DrawPrecipitationSprite(spr); @@ -4542,7 +4542,7 @@ static void HWR_DrawSprites(void) if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { - if (!cv_grmodels.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) + if (!cv_glmodels.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) HWR_DrawSprite(spr); else { @@ -4552,7 +4552,7 @@ static void HWR_DrawSprites(void) } else { - if (!cv_grmodels.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + if (!cv_glmodels.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) HWR_DrawSprite(spr); else { @@ -4621,7 +4621,7 @@ static void HWR_AddSprites(sector_t *sec) // BP why not use xtoviexangle/viewangletox like in bsp ?.... static void HWR_ProjectSprite(mobj_t *thing) { - gr_vissprite_t *vis; + gl_vissprite_t *vis; float tr_x, tr_y; float tz; float x1, x2; @@ -4658,16 +4658,16 @@ static void HWR_ProjectSprite(mobj_t *thing) this_scale = FIXED_TO_FLOAT(thing->scale); // transform the origin point - tr_x = FIXED_TO_FLOAT(thing->x) - gr_viewx; - tr_y = FIXED_TO_FLOAT(thing->y) - gr_viewy; + tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; + tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy; // rotation around vertical axis - tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); + tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); // thing is behind view plane? if (tz < ZCLIP_PLANE && !papersprite) { - if (cv_grmodels.value) //Yellow: Only MD2's dont disappear + if (cv_glmodels.value) //Yellow: Only MD2's dont disappear { if (thing->skin && thing->sprite == SPR_PLAY) md2 = &md2_playermodels[( (skin_t *)thing->skin - skins )]; @@ -4843,7 +4843,7 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->cullheight) { - if (HWR_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, gr_viewz, gz, gzt)) + if (HWR_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, gl_viewz, gz, gzt)) return; } @@ -4855,12 +4855,12 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (gr_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? + if (gl_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? FIXED_TO_FLOAT(thing->z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) return; - if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? - gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : + if (gl_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? + gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gl_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : FIXED_TO_FLOAT(thing->z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) return; } @@ -4940,7 +4940,7 @@ static void HWR_ProjectSprite(mobj_t *thing) // Precipitation projector for hardware mode static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) { - gr_vissprite_t *vis; + gl_vissprite_t *vis; float tr_x, tr_y; float tz; float x1, x2; @@ -4953,11 +4953,11 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) UINT8 flip; // transform the origin point - tr_x = FIXED_TO_FLOAT(thing->x) - gr_viewx; - tr_y = FIXED_TO_FLOAT(thing->y) - gr_viewy; + tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; + tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy; // rotation around vertical axis - tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); + tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); // thing is behind view plane? if (tz < ZCLIP_PLANE) @@ -5048,7 +5048,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // ========================================================================== static void HWR_DrawSkyBackground(player_t *player) { - if (cv_grskydome.value) + if (cv_glskydome.value) { FTransform dometransform; const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); @@ -5062,7 +5062,7 @@ static void HWR_DrawSkyBackground(player_t *player) memset(&dometransform, 0x00, sizeof(FTransform)); //04/01/2000: Hurdler: added for T&L - // It should replace all other gr_viewxxx when finished + // It should replace all other gl_viewxxx when finished HWR_SetTransformAiming(&dometransform, player, false); dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); @@ -5120,7 +5120,7 @@ static void HWR_DrawSkyBackground(player_t *player) // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture - angle = (dup_viewangle + gr_xtoviewangle[0]); + angle = (dup_viewangle + gl_xtoviewangle[0]); dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); @@ -5185,10 +5185,10 @@ static inline void HWR_ClearView(void) /// \bug faB - enable depth mask, disable color mask - HWD.pfnGClipRect((INT32)gr_viewwindowx, - (INT32)gr_viewwindowy, - (INT32)(gr_viewwindowx + gr_viewwidth), - (INT32)(gr_viewwindowy + gr_viewheight), + HWD.pfnGClipRect((INT32)gl_viewwindowx, + (INT32)gl_viewwindowy, + (INT32)(gl_viewwindowx + gl_viewwidth), + (INT32)(gl_viewwindowy + gl_viewheight), ZCLIP_PLANE); HWD.pfnClearBuffer(false, true, 0); @@ -5204,30 +5204,30 @@ static inline void HWR_ClearView(void) void HWR_SetViewSize(void) { // setup view size - gr_viewwidth = (float)vid.width; - gr_viewheight = (float)vid.height; + gl_viewwidth = (float)vid.width; + gl_viewheight = (float)vid.height; if (splitscreen) - gr_viewheight /= 2; + gl_viewheight /= 2; - gr_centerx = gr_viewwidth / 2; - gr_basecentery = gr_viewheight / 2; //note: this is (gr_centerx * gr_viewheight / gr_viewwidth) + gl_centerx = gl_viewwidth / 2; + gl_basecentery = gl_viewheight / 2; //note: this is (gl_centerx * gl_viewheight / gl_viewwidth) - gr_viewwindowx = (vid.width - gr_viewwidth) / 2; - gr_windowcenterx = (float)(vid.width / 2); - if (fabsf(gr_viewwidth - vid.width) < 1.0E-36f) + gl_viewwindowx = (vid.width - gl_viewwidth) / 2; + gl_windowcenterx = (float)(vid.width / 2); + if (fabsf(gl_viewwidth - vid.width) < 1.0E-36f) { - gr_baseviewwindowy = 0; - gr_basewindowcentery = gr_viewheight / 2; // window top left corner at 0,0 + gl_baseviewwindowy = 0; + gl_basewindowcentery = gl_viewheight / 2; // window top left corner at 0,0 } else { - gr_baseviewwindowy = (vid.height-gr_viewheight) / 2; - gr_basewindowcentery = (float)(vid.height / 2); + gl_baseviewwindowy = (vid.height-gl_viewheight) / 2; + gl_basewindowcentery = (float)(vid.height / 2); } - gr_pspritexscale = gr_viewwidth / BASEVIDWIDTH; - gr_pspriteyscale = ((vid.height*gr_pspritexscale*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width; + gl_pspritexscale = gl_viewwidth / BASEVIDWIDTH; + gl_pspriteyscale = ((vid.height*gl_pspritexscale*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width; HWD.pfnFlushScreenTextures(); } @@ -5238,20 +5238,20 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean { // 1 = always on // 2 = chasecam only - if (cv_grshearing.value == 1 || (cv_grshearing.value == 2 && R_IsViewpointThirdPerson(player, skybox))) + if (cv_glshearing.value == 1 || (cv_glshearing.value == 2 && R_IsViewpointThirdPerson(player, skybox))) { fixed_t fixedaiming = AIMINGTODY(aimingangle); trans->viewaiming = FIXED_TO_FLOAT(fixedaiming); trans->shearing = true; - gr_aimingangle = 0; + gl_aimingangle = 0; } else { trans->shearing = false; - gr_aimingangle = aimingangle; + gl_aimingangle = aimingangle; } - trans->anglex = (float)(gr_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); } // ========================================================================== @@ -5288,42 +5288,42 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) dup_viewangle = viewangle; // set window position - gr_centery = gr_basecentery; - gr_viewwindowy = gr_baseviewwindowy; - gr_windowcentery = gr_basewindowcentery; + gl_centery = gl_basecentery; + gl_viewwindowy = gl_baseviewwindowy; + gl_windowcentery = gl_basewindowcentery; if (splitscreen && viewnumber == 1) { - gr_viewwindowy += (vid.height/2); - gr_windowcentery += (vid.height/2); + gl_viewwindowy += (vid.height/2); + gl_windowcentery += (vid.height/2); } // check for new console commands. NetUpdate(); - gr_viewx = FIXED_TO_FLOAT(dup_viewx); - gr_viewy = FIXED_TO_FLOAT(dup_viewy); - gr_viewz = FIXED_TO_FLOAT(dup_viewz); - gr_viewsin = FIXED_TO_FLOAT(viewsin); - gr_viewcos = FIXED_TO_FLOAT(viewcos); + gl_viewx = FIXED_TO_FLOAT(dup_viewx); + gl_viewy = FIXED_TO_FLOAT(dup_viewy); + gl_viewz = FIXED_TO_FLOAT(dup_viewz); + gl_viewsin = FIXED_TO_FLOAT(viewsin); + gl_viewcos = FIXED_TO_FLOAT(viewcos); //04/01/2000: Hurdler: added for T&L - // It should replace all other gr_viewxxx when finished + // It should replace all other gl_viewxxx when finished memset(&atransform, 0x00, sizeof(FTransform)); HWR_SetTransformAiming(&atransform, player, true); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - gr_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gr_aimingangle>>ANGLETOFINESHIFT)); - gr_viewludcos = FIXED_TO_FLOAT(-FINESINE(gr_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); if (*type == postimg_flip) atransform.flip = true; else atransform.flip = false; - atransform.x = gr_viewx; // FIXED_TO_FLOAT(viewx) - atransform.y = gr_viewy; // FIXED_TO_FLOAT(viewy) - atransform.z = gr_viewz; // FIXED_TO_FLOAT(viewz) + atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx) + atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy) + atransform.z = gl_viewz; // FIXED_TO_FLOAT(viewz) atransform.scalex = 1; atransform.scaley = (float)vid.width/vid.height; atransform.scalez = 1; @@ -5338,7 +5338,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) } atransform.splitscreen = splitscreen; - gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); + gl_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); //------------------------------------------------------------------------ HWR_ClearView(); @@ -5356,7 +5356,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) #ifdef NEWCLIP if (rendermode == render_opengl) { - angle_t a1 = gld_FrustumAngle(gr_aimingangle); + angle_t a1 = gld_FrustumAngle(gl_aimingangle); gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM @@ -5372,12 +5372,12 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) HWD.pfnSetTransform(&atransform); // Reset the shader state. - HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_grshaders.value); + HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value); HWD.pfnSetShader(0); validcount++; - if (cv_grbatching.value) + if (cv_glbatching.value) HWR_StartBatching(); HWR_RenderBSPNode((INT32)numnodes-1); @@ -5390,14 +5390,14 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) viewangle = localaiming2; // Handle stuff when you are looking farther up or down. - if ((gr_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) + if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) { dup_viewangle += ANGLE_90; HWR_ClearClipSegs(); HWR_RenderBSPNode((INT32)numnodes-1); //left dup_viewangle += ANGLE_90; - if (((INT32)gr_aimingangle > ANGLE_45 || (INT32)gr_aimingangle<-ANGLE_45)) + if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45)) { HWR_ClearClipSegs(); HWR_RenderBSPNode((INT32)numnodes-1); //back @@ -5411,7 +5411,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) } #endif - if (cv_grbatching.value) + if (cv_glbatching.value) HWR_RenderBatches(); // Check for new console commands. @@ -5470,7 +5470,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) ClearColor.blue = 0.0f; ClearColor.alpha = 1.0f; - if (cv_grshaders.value) + if (cv_glshaders.value) HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. if (viewnumber == 0) // Only do it if it's the first screen being rendered @@ -5501,42 +5501,42 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) dup_viewangle = viewangle; // set window position - gr_centery = gr_basecentery; - gr_viewwindowy = gr_baseviewwindowy; - gr_windowcentery = gr_basewindowcentery; + gl_centery = gl_basecentery; + gl_viewwindowy = gl_baseviewwindowy; + gl_windowcentery = gl_basewindowcentery; if (splitscreen && viewnumber == 1) { - gr_viewwindowy += (vid.height/2); - gr_windowcentery += (vid.height/2); + gl_viewwindowy += (vid.height/2); + gl_windowcentery += (vid.height/2); } // check for new console commands. NetUpdate(); - gr_viewx = FIXED_TO_FLOAT(dup_viewx); - gr_viewy = FIXED_TO_FLOAT(dup_viewy); - gr_viewz = FIXED_TO_FLOAT(dup_viewz); - gr_viewsin = FIXED_TO_FLOAT(viewsin); - gr_viewcos = FIXED_TO_FLOAT(viewcos); + gl_viewx = FIXED_TO_FLOAT(dup_viewx); + gl_viewy = FIXED_TO_FLOAT(dup_viewy); + gl_viewz = FIXED_TO_FLOAT(dup_viewz); + gl_viewsin = FIXED_TO_FLOAT(viewsin); + gl_viewcos = FIXED_TO_FLOAT(viewcos); //04/01/2000: Hurdler: added for T&L - // It should replace all other gr_viewxxx when finished + // It should replace all other gl_viewxxx when finished memset(&atransform, 0x00, sizeof(FTransform)); HWR_SetTransformAiming(&atransform, player, false); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - gr_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gr_aimingangle>>ANGLETOFINESHIFT)); - gr_viewludcos = FIXED_TO_FLOAT(-FINESINE(gr_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); if (*type == postimg_flip) atransform.flip = true; else atransform.flip = false; - atransform.x = gr_viewx; // FIXED_TO_FLOAT(viewx) - atransform.y = gr_viewy; // FIXED_TO_FLOAT(viewy) - atransform.z = gr_viewz; // FIXED_TO_FLOAT(viewz) + atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx) + atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy) + atransform.z = gl_viewz; // FIXED_TO_FLOAT(viewz) atransform.scalex = 1; atransform.scaley = (float)vid.width/vid.height; atransform.scalez = 1; @@ -5551,7 +5551,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } atransform.splitscreen = splitscreen; - gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); + gl_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); //------------------------------------------------------------------------ HWR_ClearView(); // Clears the depth buffer and resets the view I believe @@ -5569,7 +5569,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) #ifdef NEWCLIP if (rendermode == render_opengl) { - angle_t a1 = gld_FrustumAngle(gr_aimingangle); + angle_t a1 = gld_FrustumAngle(gl_aimingangle); gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM @@ -5585,7 +5585,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWD.pfnSetTransform(&atransform); // Reset the shader state. - HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_grshaders.value); + HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_glshaders.value); HWD.pfnSetShader(0); rs_numbspcalls = 0; @@ -5594,7 +5594,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) validcount++; - if (cv_grbatching.value) + if (cv_glbatching.value) HWR_StartBatching(); HWR_RenderBSPNode((INT32)numnodes-1); @@ -5607,14 +5607,14 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) viewangle = localaiming2; // Handle stuff when you are looking farther up or down. - if ((gr_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) + if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) { dup_viewangle += ANGLE_90; HWR_ClearClipSegs(); HWR_RenderBSPNode((INT32)numnodes-1); //left dup_viewangle += ANGLE_90; - if (((INT32)gr_aimingangle > ANGLE_45 || (INT32)gr_aimingangle<-ANGLE_45)) + if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45)) { HWR_ClearClipSegs(); HWR_RenderBSPNode((INT32)numnodes-1); //back @@ -5630,7 +5630,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) rs_bsptime = I_GetTimeMicros() - rs_bsptime; - if (cv_grbatching.value) + if (cv_glbatching.value) HWR_RenderBatches(); // Check for new console commands. @@ -5643,7 +5643,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) #endif // Draw MD2 and sprites - rs_numsprites = gr_visspritecount; + rs_numsprites = gl_visspritecount; rs_hw_spritesorttime = I_GetTimeMicros(); HWR_SortVisSprites(); rs_hw_spritesorttime = I_GetTimeMicros() - rs_hw_spritesorttime; @@ -5685,8 +5685,8 @@ static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Some static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; static CV_PossibleValue_t grshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Third-person"}, {0, NULL}}; -static void CV_grfiltermode_OnChange(void); -static void CV_granisotropic_OnChange(void); +static void CV_glfiltermode_OnChange(void); +static void CV_glanisotropic_OnChange(void); static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, @@ -5696,46 +5696,46 @@ static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA {0, NULL}}; CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; -consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef ALAM_LIGHTING -consvar_t cv_grdynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gldynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif -consvar_t cv_grmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glmodellighting = {"gr_modellighting", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glshearing = {"gr_shearing", "Off", CV_SAVE, grshearing_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, grfiltermode_cons_t, - CV_grfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, - CV_granisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, grfiltermode_cons_t, + CV_glfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glanisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, + CV_glanisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static void CV_grfiltermode_OnChange(void) +static void CV_glfiltermode_OnChange(void) { if (rendermode == render_opengl) - HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); } -static void CV_granisotropic_OnChange(void) +static void CV_glanisotropic_OnChange(void) { if (rendermode == render_opengl) - HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); } //added by Hurdler: console varibale that are saved @@ -5744,31 +5744,31 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_fovchange); #ifdef ALAM_LIGHTING - CV_RegisterVar(&cv_grstaticlighting); - CV_RegisterVar(&cv_grdynamiclighting); - CV_RegisterVar(&cv_grcoronasize); - CV_RegisterVar(&cv_grcoronas); + CV_RegisterVar(&cv_glstaticlighting); + CV_RegisterVar(&cv_gldynamiclighting); + CV_RegisterVar(&cv_glcoronasize); + CV_RegisterVar(&cv_glcoronas); #endif - CV_RegisterVar(&cv_grmodellighting); - CV_RegisterVar(&cv_grmodelinterpolation); - CV_RegisterVar(&cv_grmodels); + CV_RegisterVar(&cv_glmodellighting); + CV_RegisterVar(&cv_glmodelinterpolation); + CV_RegisterVar(&cv_glmodels); - CV_RegisterVar(&cv_grskydome); - CV_RegisterVar(&cv_grspritebillboarding); - CV_RegisterVar(&cv_grfakecontrast); - CV_RegisterVar(&cv_grshearing); - CV_RegisterVar(&cv_grshaders); + CV_RegisterVar(&cv_glskydome); + CV_RegisterVar(&cv_glspritebillboarding); + CV_RegisterVar(&cv_glfakecontrast); + CV_RegisterVar(&cv_glshearing); + CV_RegisterVar(&cv_glshaders); - CV_RegisterVar(&cv_grfiltermode); - CV_RegisterVar(&cv_grcorrecttricks); - CV_RegisterVar(&cv_grsolvetjoin); + CV_RegisterVar(&cv_glfiltermode); + CV_RegisterVar(&cv_glcorrecttricks); + CV_RegisterVar(&cv_glsolvetjoin); CV_RegisterVar(&cv_renderstats); - CV_RegisterVar(&cv_grbatching); + CV_RegisterVar(&cv_glbatching); #ifndef NEWCLIP - CV_RegisterVar(&cv_grclipwalls); + CV_RegisterVar(&cv_glclipwalls); #endif } @@ -5778,7 +5778,7 @@ void HWR_AddSessionCommands(void) if (alreadycalled) return; - CV_RegisterVar(&cv_granisotropicmode); + CV_RegisterVar(&cv_glanisotropicmode); alreadycalled = true; } @@ -5808,7 +5808,7 @@ void HWR_Startup(void) for (i = 0; i < numwadfiles; i++) HWR_ReadShaders(i, (wadfiles[i]->type == RET_PK3)); if (!HWR_LoadShaders()) - gr_shadersavailable = false; + gl_shadersavailable = false; } if (rendermode == render_opengl) @@ -5823,8 +5823,8 @@ void HWR_Startup(void) void HWR_Switch(void) { // Set special states from CVARs - HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); - HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); } // -------------------------------------------------------------------------- @@ -5843,23 +5843,23 @@ void transform(float *cx, float *cy, float *cz) { float tr_x,tr_y; // translation - tr_x = *cx - gr_viewx; - tr_y = *cz - gr_viewy; + tr_x = *cx - gl_viewx; + tr_y = *cz - gl_viewy; // *cy = *cy; // rotation around vertical y axis - *cx = (tr_x * gr_viewsin) - (tr_y * gr_viewcos); - tr_x = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); + *cx = (tr_x * gl_viewsin) - (tr_y * gl_viewcos); + tr_x = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); //look up/down ----TOTAL SUCKS!!!--- do the 2 in one!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - tr_y = *cy - gr_viewz; + tr_y = *cy - gl_viewz; - *cy = (tr_x * gr_viewludcos) + (tr_y * gr_viewludsin); - *cz = (tr_x * gr_viewludsin) - (tr_y * gr_viewludcos); + *cy = (tr_x * gl_viewludcos) + (tr_y * gl_viewludsin); + *cz = (tr_x * gl_viewludsin) - (tr_y * gl_viewludcos); //scale y before frustum so that frustum can be scaled to screen height - *cy *= ORIGINAL_ASPECT * gr_fovlud; - *cx *= gr_fovlud; + *cy *= ORIGINAL_ASPECT * gl_fovlud; + *cx *= gl_fovlud; } void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) @@ -5915,7 +5915,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode, shader, false); #ifdef WALLSPLATS - if (gr_curline->linedef->splats && cv_splats.value) + if (gl_curline->linedef->splats && cv_splats.value) HWR_DrawSegsSplats(pSurf); #endif } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 21bd7ddb3..f404d8c5e 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -75,32 +75,32 @@ boolean HWR_LoadShaders(void); extern CV_PossibleValue_t granisotropicmode_cons_t[]; #ifdef ALAM_LIGHTING -extern consvar_t cv_grdynamiclighting; -extern consvar_t cv_grstaticlighting; -extern consvar_t cv_grcoronas; -extern consvar_t cv_grcoronasize; +extern consvar_t cv_gldynamiclighting; +extern consvar_t cv_glstaticlighting; +extern consvar_t cv_glcoronas; +extern consvar_t cv_glcoronasize; #endif -extern consvar_t cv_grshaders; -extern consvar_t cv_grmodels; -extern consvar_t cv_grmodelinterpolation; -extern consvar_t cv_grmodellighting; -extern consvar_t cv_grfiltermode; -extern consvar_t cv_granisotropicmode; -extern consvar_t cv_grcorrecttricks; +extern consvar_t cv_glshaders; +extern consvar_t cv_glmodels; +extern consvar_t cv_glmodelinterpolation; +extern consvar_t cv_glmodellighting; +extern consvar_t cv_glfiltermode; +extern consvar_t cv_glanisotropicmode; +extern consvar_t cv_glcorrecttricks; extern consvar_t cv_fovchange; -extern consvar_t cv_grsolvetjoin; -extern consvar_t cv_grshearing; -extern consvar_t cv_grspritebillboarding; -extern consvar_t cv_grskydome; -extern consvar_t cv_grfakecontrast; -extern consvar_t cv_grslopecontrast; +extern consvar_t cv_glsolvetjoin; +extern consvar_t cv_glshearing; +extern consvar_t cv_glspritebillboarding; +extern consvar_t cv_glskydome; +extern consvar_t cv_glfakecontrast; +extern consvar_t cv_glslopecontrast; -extern consvar_t cv_grbatching; +extern consvar_t cv_glbatching; -extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; +extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowy; -extern float gr_viewwindowx, gr_basewindowcentery; +extern float gl_viewwindowx, gl_basewindowcentery; // BP: big hack for a test in lighting ref : 1249753487AB extern fixed_t *hwbbox; @@ -124,6 +124,6 @@ extern int rs_hw_numcolors; extern int rs_hw_batchsorttime; extern int rs_hw_batchdrawtime; -extern boolean gr_shadersavailable; +extern boolean gl_shadersavailable; #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index a09fdc926..c311d6462 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1108,14 +1108,14 @@ static boolean HWR_AllowModel(mobj_t *mobj) static boolean HWR_CanInterpolateModel(mobj_t *mobj, model_t *model) { - if (cv_grmodelinterpolation.value == 2) // Always interpolate + if (cv_glmodelinterpolation.value == 2) // Always interpolate return true; return model->interpolate[(mobj->frame & FF_FRAMEMASK)]; } static boolean HWR_CanInterpolateSprite2(modelspr2frames_t *spr2frame) { - if (cv_grmodelinterpolation.value == 2) // Always interpolate + if (cv_glmodelinterpolation.value == 2) // Always interpolate return true; return spr2frame->interpolate; } @@ -1181,7 +1181,7 @@ static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t // HWR_DrawModel // -boolean HWR_DrawModel(gr_vissprite_t *spr) +boolean HWR_DrawModel(gl_vissprite_t *spr) { md2_t *md2; @@ -1192,7 +1192,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) FTransform p; FSurfaceInfo Surf; - if (!cv_grmodels.value) + if (!cv_glmodels.value) return false; if (spr->precip) @@ -1388,7 +1388,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) #ifdef USE_MODEL_NEXTFRAME #define INTERPOLERATION_LIMIT TICRATE/4 - if (cv_grmodelinterpolation.value && tics <= durs && tics <= INTERPOLERATION_LIMIT) + if (cv_glmodelinterpolation.value && tics <= durs && tics <= INTERPOLERATION_LIMIT) { if (durs > INTERPOLERATION_LIMIT) durs = INTERPOLERATION_LIMIT; diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 42a9d7c63..0f4d2c7bc 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -42,7 +42,7 @@ extern md2_t md2_playermodels[MAXSKINS]; void HWR_InitModels(void); void HWR_AddPlayerModel(INT32 skin); void HWR_AddSpriteModel(size_t spritenum); -boolean HWR_DrawModel(gr_vissprite_t *spr); +boolean HWR_DrawModel(gl_vissprite_t *spr); #define PLAYERMODELPREFIX "PLAYER" diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c index 82d81b5b2..312be66d4 100644 --- a/src/hardware/hw_trick.c +++ b/src/hardware/hw_trick.c @@ -739,7 +739,7 @@ void HWR_CorrectSWTricks(void) sector_t **sectorList; sector_t *outSector; - if ((0 == cv_grcorrecttricks.value)) + if ((0 == cv_glcorrecttricks.value)) return; // determine lines for sectors diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 49dbcd08f..8b48a0438 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -58,8 +58,8 @@ static GLuint tex_downloaded = 0; static GLfloat fov = 90.0f; static FBITFIELD CurrentPolyFlags; -static FTextureInfo *gr_cachetail = NULL; -static FTextureInfo *gr_cachehead = NULL; +static FTextureInfo *gl_cachetail = NULL; +static FTextureInfo *gl_cachehead = NULL; RGBA_t myPaletteData[256]; GLint screen_width = 0; // used by Draw2DLine() @@ -1200,7 +1200,7 @@ void SetModelView(GLint w, GLint h) pglLoadIdentity(); GLPerspective(fov, ASPECT_RATIO); - //pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gr_scalefrustum (ORIGINAL_ASPECT) + //pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gl_scalefrustum (ORIGINAL_ASPECT) // added for new coronas' code (without depth buffer) pglGetIntegerv(GL_VIEWPORT, viewport); @@ -1277,14 +1277,14 @@ void Flush(void) { //GL_DBG_Printf ("HWR_Flush()\n"); - while (gr_cachehead) + while (gl_cachehead) { - if (gr_cachehead->downloaded) - pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded); - gr_cachehead->downloaded = 0; - gr_cachehead = gr_cachehead->nextmipmap; + if (gl_cachehead->downloaded) + pglDeleteTextures(1, (GLuint *)&gl_cachehead->downloaded); + gl_cachehead->downloaded = 0; + gl_cachehead = gl_cachehead->nextmipmap; } - gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL + gl_cachetail = gl_cachehead = NULL; //Hurdler: well, gl_cachehead is already NULL tex_downloaded = 0; } @@ -1860,13 +1860,13 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) { UpdateTexture(pTexInfo); pTexInfo->nextmipmap = NULL; - if (gr_cachetail) + if (gl_cachetail) { // insertion at the tail - gr_cachetail->nextmipmap = pTexInfo; - gr_cachetail = pTexInfo; + gl_cachetail->nextmipmap = pTexInfo; + gl_cachetail = pTexInfo; } else // initialization of the linked list - gr_cachetail = gr_cachehead = pTexInfo; + gl_cachetail = gl_cachehead = pTexInfo; } } @@ -2959,7 +2959,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT INT32 HWRAPI(GetTextureUsed) (void) { - FTextureInfo *tmp = gr_cachehead; + FTextureInfo *tmp = gl_cachehead; INT32 res = 0; while (tmp) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7b84784e5..b61192533 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1880,7 +1880,7 @@ static inline void HU_DrawCrosshair(void) #ifdef HWRENDER if (rendermode != render_soft) - y = (INT32)gr_basewindowcentery; + y = (INT32)gl_basewindowcentery; else #endif y = viewwindowy + (viewheight>>1); @@ -1901,7 +1901,7 @@ static inline void HU_DrawCrosshair2(void) #ifdef HWRENDER if (rendermode != render_soft) - y = (INT32)gr_basewindowcentery; + y = (INT32)gl_basewindowcentery; else #endif y = viewwindowy + (viewheight>>1); @@ -1910,7 +1910,7 @@ static inline void HU_DrawCrosshair2(void) { #ifdef HWRENDER if (rendermode != render_soft) - y += (INT32)gr_viewheight; + y += (INT32)gl_viewheight; else #endif y += viewheight; diff --git a/src/m_menu.c b/src/m_menu.c index 98178c15c..338d9b1be 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1446,19 +1446,19 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_OpenGLOptionsMenu[] = { {IT_HEADER, NULL, "3D Models", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Models", &cv_grmodels, 12}, - {IT_STRING|IT_CVAR, NULL, "Frame interpolation", &cv_grmodelinterpolation, 22}, - {IT_STRING|IT_CVAR, NULL, "Ambient lighting", &cv_grmodellighting, 32}, + {IT_STRING|IT_CVAR, NULL, "Models", &cv_glmodels, 12}, + {IT_STRING|IT_CVAR, NULL, "Frame interpolation", &cv_glmodelinterpolation, 22}, + {IT_STRING|IT_CVAR, NULL, "Ambient lighting", &cv_glmodellighting, 32}, {IT_HEADER, NULL, "General", NULL, 51}, - {IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 63}, - {IT_STRING|IT_CVAR, NULL, "Lack of perspective", &cv_grshearing, 73}, + {IT_STRING|IT_CVAR, NULL, "Shaders", &cv_glshaders, 63}, + {IT_STRING|IT_CVAR, NULL, "Lack of perspective", &cv_glshearing, 73}, {IT_STRING|IT_CVAR, NULL, "Field of view", &cv_fov, 83}, {IT_HEADER, NULL, "Miscellaneous", NULL, 102}, {IT_STRING|IT_CVAR, NULL, "Bit depth", &cv_scr_depth, 114}, - {IT_STRING|IT_CVAR, NULL, "Texture filter", &cv_grfiltermode, 124}, - {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 134}, + {IT_STRING|IT_CVAR, NULL, "Texture filter", &cv_glfiltermode, 124}, + {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 134}, #ifdef ALAM_LIGHTING {IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 144}, #endif @@ -1470,10 +1470,10 @@ static menuitem_t OP_OpenGLOptionsMenu[] = #ifdef ALAM_LIGHTING static menuitem_t OP_OpenGLLightingMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Coronas", &cv_grcoronas, 0}, - {IT_STRING|IT_CVAR, NULL, "Coronas size", &cv_grcoronasize, 10}, - {IT_STRING|IT_CVAR, NULL, "Dynamic lighting", &cv_grdynamiclighting, 20}, - {IT_STRING|IT_CVAR, NULL, "Static lighting", &cv_grstaticlighting, 30}, + {IT_STRING|IT_CVAR, NULL, "Coronas", &cv_glcoronas, 0}, + {IT_STRING|IT_CVAR, NULL, "Coronas size", &cv_glcoronasize, 10}, + {IT_STRING|IT_CVAR, NULL, "Dynamic lighting", &cv_gldynamiclighting, 20}, + {IT_STRING|IT_CVAR, NULL, "Static lighting", &cv_glstaticlighting, 30}, }; #endif // ALAM_LIGHTING @@ -2306,9 +2306,9 @@ void Nextmap_OnChange(void) // Check if file exists, if not, disable REPLAY option sprintf(tabase,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name); -#ifdef OLDNREPLAYNAME +#ifdef OLDNREPLAYNAME sprintf(tabaseold,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); -#endif +#endif for (i = 0; i < 4; i++) { SP_NightsReplayMenu[i].status = IT_DISABLED; @@ -2336,7 +2336,7 @@ void Nextmap_OnChange(void) active = true; } - // Old style name compatibility + // Old style name compatibility #ifdef OLDNREPLAYNAME if (FIL_FileExists(va("%s-score-best.lmp", tabaseold))) { SP_NightsReplayMenu[0].status = IT_WHITESTRING|IT_CALL; diff --git a/src/p_user.c b/src/p_user.c index 261e4b28c..df037504e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10042,7 +10042,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (camorbit) //Sev here, I'm guessing this is where orbital cam lives { #ifdef HWRENDER - if (rendermode == render_opengl && !cv_grshearing.value) + if (rendermode == render_opengl && !cv_glshearing.value) distxy = FixedMul(dist, FINECOSINE((focusaiming>>ANGLETOFINESHIFT) & FINEMASK)); else #endif diff --git a/src/r_main.c b/src/r_main.c index cf7360804..ead1403be 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1064,7 +1064,7 @@ static void R_SetupFreelook(void) // (lmps, network and use F12...) if (rendermode == render_soft #ifdef HWRENDER - || cv_grshearing.value + || cv_glshearing.value #endif ) { From 1757002ddbde9de4e4d503e85d7ffaac5ff84c6c Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Jul 2020 22:20:33 -0700 Subject: [PATCH 29/75] Automate VERSION/SUBVERSION; move version related definitions to version.h CMake support. Srb2win.rc still needs touchy, whatever. --- CMakeLists.txt | 6 +++++- src/d_main.c | 18 ++++++++++++++++++ src/doomdef.h | 20 ++------------------ src/version.h | 12 ++++++++++++ 4 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 src/version.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e12b0d345..25a44f016 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,12 @@ cmake_minimum_required(VERSION 3.0) + +file(STRINGS src/version.h SRB2_VERSION) +string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION}) + # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 - VERSION 2.2.6 + VERSION ${SRB2_VERSION} LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) diff --git a/src/d_main.c b/src/d_main.c index 28570b909..22875593c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1142,6 +1142,21 @@ static inline void D_Titlebar(void) } #endif +static void +D_ConvertVersionNumbers (void) +{ + /* leave at defaults (0) under DEVELOP */ +#ifndef DEVELOP + int major; + int minor; + + sscanf(SRB2VERSION, "%d.%d.%d", &major, &minor, &SUBVERSION); + + /* this is stupid */ + VERSION = ( major * 100 ) + minor; +#endif +} + // // D_SRB2Main // @@ -1152,6 +1167,9 @@ void D_SRB2Main(void) INT32 pstartmap = 1; boolean autostart = false; + /* break the version string into version numbers, for netplay */ + D_ConvertVersionNumbers(); + // Print GPL notice for our console users (Linux) CONS_Printf( "\n\nSonic Robo Blast 2\n" diff --git a/src/doomdef.h b/src/doomdef.h index 380adf781..50e4b9b77 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -86,6 +86,7 @@ // warning C4213: nonstandard extension used : cast on l-value +#include "version.h" #include "doomtype.h" #include @@ -135,17 +136,11 @@ extern char logfilename[1024]; //#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 #ifdef DEVELOP -#define VERSION 0 // Game version -#define SUBVERSION 0 // more precise version number #define VERSIONSTRING "Development EXE" -#define VERSIONSTRINGW L"Development EXE" // most interface strings are ignored in development mode. // we use comprevision and compbranch instead. #else -#define VERSION 202 // Game version -#define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "v2.2.6" -#define VERSIONSTRINGW L"v2.2.6" +#define VERSIONSTRING "v"SRB2VERSION // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -204,17 +199,6 @@ extern char logfilename[1024]; // Will always resemble the versionstring, 205 = 2.0.5, 210 = 2.1, etc. #define CODEBASE 220 -// The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/showgroups.php ). -// DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. -// "18" is the default mod ID for version 2.2 -#define MODID 18 - -// The Modification Version, starting from 1. Do not follow your version string for this, -// 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.2.0 is not version "1". -#define MODVERSION 47 - // To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically. // Increment MINOREXECVERSION whenever a config change is needed that does not correspond // to an increment in MODVERSION. This might never happen in practice. diff --git a/src/version.h b/src/version.h new file mode 100644 index 000000000..31cf85bdc --- /dev/null +++ b/src/version.h @@ -0,0 +1,12 @@ +#define SRB2VERSION "2.2.6"/* this must be the first line, for cmake !! */ + +// The Modification ID; must be obtained from a Master Server Admin ( https://mb.srb2.org/showgroups.php ). +// DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. +// "18" is the default mod ID for version 2.2 +#define MODID 18 + +// The Modification Version, starting from 1. Do not follow your version string for this, +// 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.2.0 is not version "1". +#define MODVERSION 47 From 99e0c48f7b85e06e25c4d1a96765ba7cad5a41e9 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Jul 2020 22:39:46 -0700 Subject: [PATCH 30/75] Fix a lot of stuff related to the version automation --- src/d_clisrv.c | 4 ++-- src/d_main.c | 4 ++++ src/dehacked.c | 2 -- src/doomdef.h | 4 ++++ src/doomtype.h | 4 ++++ src/lua_script.c | 6 ++++++ src/mserv.c | 4 ++-- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c7c5470ae..71e2e947e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2336,8 +2336,8 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room) if (server_list) { char version[8] = ""; -#if VERSION > 0 || SUBVERSION > 0 - snprintf(version, sizeof (version), "%d.%d.%d", VERSION/100, VERSION%100, SUBVERSION); +#ifndef DEVELOP + strcpy(version, SRB2VERSION); #else strcpy(version, GetRevisionString()); #endif diff --git a/src/d_main.c b/src/d_main.c index 22875593c..96167ac0b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -93,6 +93,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...); #include "lua_script.h" +// Version numbers for netplay :upside_down_face: +int VERSION; +int SUBVERSION; + // platform independant focus loss UINT8 window_notinfocus = false; diff --git a/src/dehacked.c b/src/dehacked.c index 99d4883f6..d02dc3d24 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9484,8 +9484,6 @@ struct { {"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. {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. - {"VERSION",VERSION}, // Grab the game's version! - {"SUBVERSION",SUBVERSION}, // more precise version number {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO {"NEWTICRATERATIO",NEWTICRATERATIO}, diff --git a/src/doomdef.h b/src/doomdef.h index 50e4b9b77..249bd5128 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -145,6 +145,8 @@ extern char logfilename[1024]; // Otherwise we can't force updates! #endif +#define VERSIONSTRINGW WSTRING (VERSIONSTRING) + /* A custom URL protocol for server links. */ #define SERVER_URL_PROTOCOL "srb2://" @@ -487,6 +489,8 @@ char *sizeu4(size_t num); char *sizeu5(size_t num); // d_main.c +extern int VERSION; +extern int SUBVERSION; extern boolean devparm; // development mode (-debug) // d_netcmd.c extern INT32 cv_debug; diff --git a/src/doomtype.h b/src/doomtype.h index 571e930e0..0aa3e23e0 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -367,4 +367,8 @@ typedef UINT32 tic_t; #define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) #endif +/* preprocessor dumb and needs second macro to expand input */ +#define WSTRING2(s) L ## s +#define WSTRING(s) WSTRING2 (s) + #endif //__DOOMTYPE__ diff --git a/src/lua_script.c b/src/lua_script.c index 5fb153c0e..9d7d536b9 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -344,6 +344,12 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"gravity")) { lua_pushinteger(L, gravity); return 1; + } else if (fastcmp(word,"VERSION")) { + lua_pushinteger(L, VERSION); + return 1; + } else if (fastcmp(word,"SUBVERSION")) { + lua_pushinteger(L, SUBVERSION); + return 1; } else if (fastcmp(word,"VERSIONSTRING")) { lua_pushstring(L, VERSIONSTRING); return 1; diff --git a/src/mserv.c b/src/mserv.c index 05a5344ba..af5690788 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -754,8 +754,8 @@ static INT32 AddToMasterServer(boolean firstadd) strcpy(info->port, int2str(current_port)); strcpy(info->name, cv_servername.string); M_Memcpy(&info->room, & room, sizeof (INT32)); -#if VERSION > 0 || SUBVERSION > 0 - sprintf(info->version, "%d.%d.%d", VERSION/100, VERSION%100, SUBVERSION); +#ifndef DEVELOP + strcpy(info->version, SRB2VERSION); #else // Trunk build, send revision info strcpy(info->version, GetRevisionString()); #endif From e95265a7fabed5fffcf78af3a45e003c2247342b Mon Sep 17 00:00:00 2001 From: sphere Date: Sat, 11 Jul 2020 12:11:26 +0200 Subject: [PATCH 31/75] Comment out unused border patch variables, so GFZFLR01 isn't required anymore. --- src/st_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 53d988913..d5aa5fbac 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -240,8 +240,8 @@ void ST_LoadGraphics(void) int i; // SRB2 border patch - st_borderpatchnum = W_GetNumForName("GFZFLR01"); - scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); + // st_borderpatchnum = W_GetNumForName("GFZFLR01"); + // scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); // the original Doom uses 'STF' as base name for all face graphics // Graue 04-08-2004: face/name graphics are now indexed by skins From 4e1d54c3322c17276e532ab4d9e875a8c8ebc399 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 11 Jul 2020 12:45:35 -0700 Subject: [PATCH 32/75] It's not always GCC, but it probably is gcc (I hope) --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 23e602798..4a2c0687b 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -47,7 +47,7 @@ endif # Automatically set version flag, but not if one was manually set ifeq (,$(filter GCC%,$(.VARIABLES))) - ifneq (,$(findstring GCC,$(shell $(CC) --version))) # if it's GCC + ifneq (,$(findstring gcc,$(shell $(CC) --version))) # if it's GCC version:=$(shell $(CC) -dumpversion) # Turn version into words of major, minor From 7015e656ce2887d827a7ca5d7818907eef44e649 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 12 Jul 2020 00:36:22 -0500 Subject: [PATCH 33/75] Expose P_RailThinker to Lua. --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 775d9ec02..2e05008ca 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -902,6 +902,17 @@ static int lib_pMaceRotate(lua_State *L) return 0; } +static int lib_pRailThinker(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_RailThinker(mobj)); + return 1; +} + // P_USER //////////// @@ -3259,6 +3270,7 @@ static luaL_Reg lib[] = { {"P_CheckSolidLava",lib_pCheckSolidLava}, {"P_CanRunOnWater",lib_pCanRunOnWater}, {"P_MaceRotate",lib_pMaceRotate}, + {"P_RailThinker",lib_pRailThinker}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, From 0f9e3554e2995d8f586d47d420571856b4d510ef Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Sun, 12 Jul 2020 07:39:52 -0400 Subject: [PATCH 34/75] various color fixes --- src/command.c | 13 +++++++++++++ src/dehacked.c | 43 ++++++++++++++++++++++++++++++++++++++++--- src/lua_baselib.c | 9 +++++++++ src/lua_infolib.c | 46 ++++++++++++++++++++++++++++++---------------- src/r_draw.c | 4 ++-- src/r_skins.c | 11 +++++++++-- 6 files changed, 103 insertions(+), 23 deletions(-) diff --git a/src/command.c b/src/command.c index 6fd8c11f9..1d0b9883e 100644 --- a/src/command.c +++ b/src/command.c @@ -33,6 +33,7 @@ #include "p_setup.h" #include "lua_script.h" #include "d_netfil.h" // findfile +#include "r_data.h" // Color_cons_t //======== // protos. @@ -818,6 +819,18 @@ static void COM_Help_f(void) CONS_Printf(" Yes or No (On or Off, 1 or 0)\n"); else if (cvar->PossibleValue == CV_OnOff) CONS_Printf(" On or Off (Yes or No, 1 or 0)\n"); + else if (cvar->PossibleValue == Color_cons_t) + { + for (i = 1; i < numskincolors; ++i) + { + if (skincolors[i].accessible) + { + CONS_Printf(" %-2d : %s\n", i, skincolors[i].name); + if (i == cvar->value) + cvalue = skincolors[i].name; + } + } + } else { #define MINVAL 0 diff --git a/src/dehacked.c b/src/dehacked.c index 99d4883f6..f9cec3a51 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -806,8 +806,41 @@ static void readskincolor(MYFILE *f, INT32 num) if (fastcmp(word, "NAME")) { - deh_strlcpy(skincolors[num].name, word2, - sizeof (skincolors[num].name), va("Skincolor %d: name", num)); + size_t namesize = sizeof(skincolors[num].name); + char truncword[namesize]; + + deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes + if (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword)) + { + size_t lastchar = strlen(truncword); + char oldword[lastchar+1]; + + strlcpy(oldword, truncword, lastchar+1); + lastchar--; + if (lastchar == namesize-2) // exactly max length, replace last character with 0 + truncword[lastchar] = '0'; + else // append 0 + { + strcat(truncword, "0"); + lastchar++; + } + + char dupenum = '1'; + while (R_GetColorByName(truncword)) + { + truncword[lastchar] = dupenum; + if (dupenum == '9') + dupenum = 'A'; + else if (dupenum == 'Z') // give up :? + break; + else + dupenum++; + } + + deh_warning("Skincolor %d: name %s is a duplicate of another skincolor's name - renamed to %s", num, oldword, truncword); + } + + deh_strlcpy(skincolors[num].name, truncword, namesize, NULL); // already truncated } else if (fastcmp(word, "RAMP")) { @@ -821,7 +854,11 @@ static void readskincolor(MYFILE *f, INT32 num) } else if (fastcmp(word, "INVCOLOR")) { - skincolors[num].invcolor = (UINT16)get_number(word2); + UINT16 v = (UINT16)get_number(word2); + if (v < numskincolors) + skincolors[num].invcolor = v; + else + skincolors[num].invcolor = SKINCOLOR_GREEN; } else if (fastcmp(word, "INVSHADE")) { diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 775d9ec02..213add31a 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2451,6 +2451,14 @@ static int lib_rGetColorByName(lua_State *L) return 1; } +static int lib_rGetSuperColorByName(lua_State *L) +{ + const char* colorname = luaL_checkstring(L, 1); + //HUDSAFE + lua_pushinteger(L, R_GetSuperColorByName(colorname)); + return 1; +} + // Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant. // SKINCOLOR_GREEN > "Green" for example static int lib_rGetNameByColor(lua_State *L) @@ -3385,6 +3393,7 @@ static luaL_Reg lib[] = { // r_draw {"R_GetColorByName", lib_rGetColorByName}, + {"R_GetSuperColorByName", lib_rGetSuperColorByName}, {"R_GetNameByColor", lib_rGetNameByColor}, // s_sound diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 81a215c53..c745d8323 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -19,6 +19,7 @@ #include "z_zone.h" #include "r_patch.h" #include "r_things.h" +#include "r_draw.h" // R_GetColorByName #include "doomstat.h" // luabanks[] #include "lua_script.h" @@ -1540,7 +1541,13 @@ static int lib_setSkinColor(lua_State *L) const char* n = luaL_checkstring(L, 3); strlcpy(info->name, n, MAXCOLORNAME+1); if (strlen(n) > MAXCOLORNAME) - CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; shortened to %s.\n", n, MAXCOLORNAME, info->name); + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name); + if (strchr(info->name, ' ') != NULL) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name); + + UINT16 dupecheck = R_GetColorByName(info->name); + if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors))) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name); } else if (i == 2 || (str && fastcmp(str,"ramp"))) { if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); @@ -1550,19 +1557,18 @@ static int lib_setSkinColor(lua_State *L) for (j=0; jramp[j] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[j]; R_FlushTranslationColormapCache(); - } else if (i == 3 || (str && fastcmp(str,"invcolor"))) - info->invcolor = (UINT16)luaL_checkinteger(L, 3); - else if (i == 4 || (str && fastcmp(str,"invshade"))) + } 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); + else + info->invcolor = v; + } else if (i == 4 || (str && fastcmp(str,"invshade"))) 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"))) { - boolean v = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true; - if (cnum < FIRSTSUPERCOLOR && v != skincolors[cnum].accessible) - return luaL_error(L, "skincolors[] index %d is a standard color; accessibility changes are prohibited.", i); - else - info->accessible = v; - } + else if (i == 6 || (str && fastcmp(str,"accessible"))) + info->accessible = lua_isboolean(L,3) ? lua_toboolean(L, 3) : true; lua_pop(L, 1); } return 0; @@ -1616,11 +1622,15 @@ static int skincolor_set(lua_State *L) if (fastcmp(field,"name")) { const char* n = luaL_checkstring(L, 3); - if (strchr(n, ' ') != NULL) - CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", n); strlcpy(info->name, n, MAXCOLORNAME+1); if (strlen(n) > MAXCOLORNAME) CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') longer than %d chars; clipped to %s.\n", n, MAXCOLORNAME, info->name); + if (strchr(info->name, ' ') != NULL) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name); + + UINT16 dupecheck = R_GetColorByName(info->name); + if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors))) + 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")) { if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); @@ -1630,9 +1640,13 @@ static int skincolor_set(lua_State *L) for (i=0; iramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i]; R_FlushTranslationColormapCache(); - } else if (fastcmp(field,"invcolor")) - info->invcolor = (UINT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"invshade")) + } 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); + else + info->invcolor = v; + } else if (fastcmp(field,"invshade")) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); diff --git a/src/r_draw.c b/src/r_draw.c index 5351ef37f..6492d9d36 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -427,12 +427,12 @@ UINT16 R_GetColorByName(const char *name) for (color = 1; color < numskincolors; color++) if (!stricmp(skincolors[color].name, name)) return color; - return SKINCOLOR_GREEN; + return SKINCOLOR_NONE; } UINT16 R_GetSuperColorByName(const char *name) { - UINT16 i, color = SKINCOLOR_SUPERGOLD1; + UINT16 i, color = SKINCOLOR_NONE; char *realname = Z_Malloc(MAXCOLORNAME+1, PU_STATIC, NULL); snprintf(realname, MAXCOLORNAME+1, "Super %s 1", name); for (i = 1; i < numskincolors; i++) diff --git a/src/r_skins.c b/src/r_skins.c index 57ce382c4..a1484a2b3 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -464,12 +464,19 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) GETINT(contangle) #undef GETINT -#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) skin->field = R_GetColorByName(value); +#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) \ +{ \ + UINT16 color = R_GetColorByName(value); \ + skin->field = (color ? color : SKINCOLOR_GREEN); \ +} GETSKINCOLOR(prefcolor) GETSKINCOLOR(prefoppositecolor) #undef GETSKINCOLOR else if (!stricmp(stoken, "supercolor")) - skin->supercolor = R_GetSuperColorByName(value); + { + UINT16 color = R_GetSuperColorByName(value); + skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1); + } #define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); GETFLOAT(jumpfactor) From 74cfeaff30a16b3ad44cbff2b13f3b4d3f293843 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Sun, 12 Jul 2020 07:56:25 -0400 Subject: [PATCH 35/75] A bit of cleaning --- src/dehacked.c | 2 +- src/lua_infolib.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index f9cec3a51..976706948 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -840,7 +840,7 @@ static void readskincolor(MYFILE *f, INT32 num) deh_warning("Skincolor %d: name %s is a duplicate of another skincolor's name - renamed to %s", num, oldword, truncword); } - deh_strlcpy(skincolors[num].name, truncword, namesize, NULL); // already truncated + strlcpy(skincolors[num].name, truncword, namesize); // already truncated } else if (fastcmp(word, "RAMP")) { diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c745d8323..e58b9d4ba 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1561,8 +1561,7 @@ static int lib_setSkinColor(lua_State *L) 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); - else - info->invcolor = v; + info->invcolor = v; } else if (i == 4 || (str && fastcmp(str,"invshade"))) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (i == 5 || (str && fastcmp(str,"chatcolor"))) @@ -1644,8 +1643,7 @@ static int skincolor_set(lua_State *L) 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); - else - info->invcolor = v; + info->invcolor = v; } else if (fastcmp(field,"invshade")) info->invshade = (UINT8)luaL_checkinteger(L, 3)%COLORRAMPSIZE; else if (fastcmp(field,"chatcolor")) From e1a217dc105d568fb1ef76ee124b5d3636dbf3b2 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 12 Jul 2020 13:00:08 +0100 Subject: [PATCH 36/75] Two minor fixes for Marathon Mode. * Apply the RTA penalty to the live event backup rather than the current timer. (Resolves #184) * Snap the character name and timer mode text to the bottom of the screen, just above the bar. --- src/f_finale.c | 2 +- src/g_game.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index f47c6c1a7..8d39a7533 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1684,7 +1684,7 @@ void F_GameEvaluationDrawer(void) endingtext = va("%s & %s, %s%s", skins[players[consoleplayer].skin].realname, skins[botskin-1].realname, rtatext, cuttext); else endingtext = va("%s, %s%s", skins[players[consoleplayer].skin].realname, rtatext, cuttext); - V_DrawCenteredString(BASEVIDWIDTH/2, 182, (ultimatemode ? V_REDMAP : V_YELLOWMAP), endingtext); + V_DrawCenteredString(BASEVIDWIDTH/2, 182, V_SNAPTOBOTTOM|(ultimatemode ? V_REDMAP : V_YELLOWMAP), endingtext); } } diff --git a/src/g_game.c b/src/g_game.c index 69aac5065..cce4ac822 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4505,7 +4505,7 @@ void G_SaveGame(UINT32 slot, INT16 mapnum) { UINT32 writetime = marathontime; if (!(marathonmode & MA_INGAME)) - marathontime += TICRATE*5; // live event backup penalty because we don't know how long it takes to get to the next map + writetime += TICRATE*5; // live event backup penalty because we don't know how long it takes to get to the next map WRITEUINT32(save_p, writetime); WRITEUINT8(save_p, (marathonmode & ~MA_INIT)); } From a734129eaedb74d9dafdf018acb3a25541f800b0 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Sun, 12 Jul 2020 10:07:32 -0400 Subject: [PATCH 37/75] lua_isboolean -> lua_toboolean solves bugged set field accessible --- src/lua_infolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index e58b9d4ba..d0bad123a 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1567,7 +1567,7 @@ static int lib_setSkinColor(lua_State *L) 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_isboolean(L,3) ? lua_toboolean(L, 3) : true; + info->accessible = (boolean)lua_toboolean(L, 3); lua_pop(L, 1); } return 0; @@ -1649,7 +1649,7 @@ static int skincolor_set(lua_State *L) else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"accessible")) - info->accessible = lua_isboolean(L,3); + info->accessible = (boolean)lua_toboolean(L, 3); else CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); return 1; From 6e4b14588c5ccc6e98cdd9e179b369a5a546fed8 Mon Sep 17 00:00:00 2001 From: Kays Ishaq Date: Sun, 12 Jul 2020 11:12:16 -0400 Subject: [PATCH 38/75] Update lua_infolib.c --- src/lua_infolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index d0bad123a..466679d19 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1567,7 +1567,7 @@ static int lib_setSkinColor(lua_State *L) 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 = (boolean)lua_toboolean(L, 3); + info->accessible = lua_toboolean(L, 3) != 0; lua_pop(L, 1); } return 0; @@ -1649,7 +1649,7 @@ static int skincolor_set(lua_State *L) else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"accessible")) - info->accessible = (boolean)lua_toboolean(L, 3); + info->accessible = lua_toboolean(L, 3) != 0; else CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); return 1; From a73f468ea4856358380da253c16d9791291a8a13 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Sun, 12 Jul 2020 12:02:49 -0400 Subject: [PATCH 39/75] Don't check empty string for duplicate name --- src/dehacked.c | 2 +- src/lua_infolib.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 976706948..6987a883d 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -810,7 +810,7 @@ static void readskincolor(MYFILE *f, INT32 num) char truncword[namesize]; deh_strlcpy(truncword, word2, namesize, va("Skincolor %d: name", num)); // truncate here to check for dupes - if (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword)) + if (truncword[0] != '\0' && (!stricmp(truncword, skincolors[SKINCOLOR_NONE].name) || R_GetColorByName(truncword))) { size_t lastchar = strlen(truncword); char oldword[lastchar+1]; diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 466679d19..fe0ca759f 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1545,9 +1545,12 @@ static int lib_setSkinColor(lua_State *L) if (strchr(info->name, ' ') != NULL) CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name); - UINT16 dupecheck = R_GetColorByName(info->name); - if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors))) - CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name); + 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))) + CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name); + } } else if (i == 2 || (str && fastcmp(str,"ramp"))) { if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); @@ -1567,7 +1570,7 @@ static int lib_setSkinColor(lua_State *L) 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) != 0; + info->accessible = lua_toboolean(L, 3); lua_pop(L, 1); } return 0; @@ -1627,9 +1630,12 @@ static int skincolor_set(lua_State *L) if (strchr(info->name, ' ') != NULL) CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') contains spaces.\n", info->name); - UINT16 dupecheck = R_GetColorByName(info->name); - if (!stricmp(info->name, skincolors[SKINCOLOR_NONE].name) || (dupecheck && (dupecheck != info-skincolors))) - CONS_Alert(CONS_WARNING, "skincolor_t field 'name' ('%s') is a duplicate of another skincolor's name.\n", info->name); + 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))) + 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")) { if (!lua_istable(L, 3) && luaL_checkudata(L, 3, META_COLORRAMP) == NULL) return luaL_error(L, LUA_QL("skincolor_t") " field 'ramp' must be a table or array."); @@ -1649,7 +1655,7 @@ static int skincolor_set(lua_State *L) else if (fastcmp(field,"chatcolor")) info->chatcolor = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"accessible")) - info->accessible = lua_toboolean(L, 3) != 0; + info->accessible = lua_toboolean(L, 3); else CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "skincolor_t", field); return 1; From 0a625d3e19807e2cea05f6f25b87832f306a49e7 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 12 Jul 2020 19:00:58 +0100 Subject: [PATCH 40/75] Fix live event backups being created at run start; there's no meaningful progress in GFZ1 to recover from. --- 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 b16e13faa..2fd7ba5b0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3756,7 +3756,7 @@ boolean P_LoadLevel(boolean fromnetsave) if (!lastmaploaded) // Start a new game? { // I'd love to do this in the menu code instead of here, but everything's a mess and I can't guarantee saving proper player struct info before the first act's started. You could probably refactor it, but it'd be a lot of effort. Easier to just work off known good code. ~toast 22/06/2020 - if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking) + if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || marathonmode) && (!modifiedgame || savemoddata) && cursaveslot > 0) G_SaveGame((UINT32)cursaveslot, gamemap); // If you're looking for saving sp file progression (distinct from G_SaveGameOver), check G_DoCompleted. From 990974671819ddf95224d657646ea691cbb9fce8 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 12 Jul 2020 21:50:00 +0300 Subject: [PATCH 41/75] Fix crash by handling precip mobjs correctly in ogl sprite sorting --- src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 8efa5a1f8..51b45178d 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -68,7 +68,7 @@ typedef struct gr_vissprite_s GLPatch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 - mobj_t *mobj; + mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out. boolean precip; // Tails 08-25-2002 boolean vflip; //Hurdler: 25/04/2000: now support colormap in hardware mode diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bde19dca0..f89e0d019 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4256,8 +4256,9 @@ static int CompareVisSprites(const void *p1, const void *p2) int transparency1; int transparency2; - int linkdraw1 = (spr1->mobj->flags2 & MF2_LINKDRAW) && spr1->mobj->tracer; - int linkdraw2 = (spr2->mobj->flags2 & MF2_LINKDRAW) && spr2->mobj->tracer; + // check for precip first, because then sprX->mobj is actually a precipmobj_t and does not have flags2 or tracer + int linkdraw1 = !spr1->precip && (spr1->mobj->flags2 & MF2_LINKDRAW) && spr1->mobj->tracer; + int linkdraw2 = !spr2->precip && (spr2->mobj->flags2 & MF2_LINKDRAW) && spr2->mobj->tracer; // ^ is the XOR operation // if comparing a linkdraw and non-linkdraw sprite or 2 linkdraw sprites with different tracers, then use @@ -4272,7 +4273,7 @@ static int CompareVisSprites(const void *p1, const void *p2) else { tz1 = spr1->tz; - transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); + transparency1 = !spr1->precip && ((spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK)); } if (linkdraw2) { @@ -4282,15 +4283,15 @@ static int CompareVisSprites(const void *p1, const void *p2) else { tz2 = spr2->tz; - transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + transparency2 = !spr2->precip && ((spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK)); } } else { tz1 = spr1->tz; - transparency1 = (spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK); + transparency1 = !spr1->precip && ((spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK)); tz2 = spr2->tz; - transparency2 = (spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK); + transparency2 = !spr2->precip && ((spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK)); } // first compare transparency flags, then compare tz, then compare dispoffset From 3a488c243f96869cec0b7f9fa4a88466b92ea43f Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 12 Jul 2020 22:23:15 +0300 Subject: [PATCH 42/75] Fix translucency comparison from previous commit --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f89e0d019..670683337 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4273,7 +4273,7 @@ static int CompareVisSprites(const void *p1, const void *p2) else { tz1 = spr1->tz; - transparency1 = !spr1->precip && ((spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK)); + transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK); } if (linkdraw2) { @@ -4283,15 +4283,15 @@ static int CompareVisSprites(const void *p1, const void *p2) else { tz2 = spr2->tz; - transparency2 = !spr2->precip && ((spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK)); + transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK); } } else { tz1 = spr1->tz; - transparency1 = !spr1->precip && ((spr1->mobj->flags2 & MF2_SHADOW) || (spr1->mobj->frame & FF_TRANSMASK)); + transparency1 = (!spr1->precip && (spr1->mobj->flags2 & MF2_SHADOW)) || (spr1->mobj->frame & FF_TRANSMASK); tz2 = spr2->tz; - transparency2 = !spr2->precip && ((spr2->mobj->flags2 & MF2_SHADOW) || (spr2->mobj->frame & FF_TRANSMASK)); + transparency2 = (!spr2->precip && (spr2->mobj->flags2 & MF2_SHADOW)) || (spr2->mobj->frame & FF_TRANSMASK); } // first compare transparency flags, then compare tz, then compare dispoffset From fe67781d682a4f532183c047d318bb527d0731c0 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 18:41:03 -0500 Subject: [PATCH 43/75] Expose P_XYMovement to Lua. It was so easy; it took a grand total of one compile to implement! Why wasn't this done before... --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 2e05008ca..2cfc251ff 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -913,6 +913,17 @@ static int lib_pRailThinker(lua_State *L) return 1; } +static int lib_pXYMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + P_XYMovement(actor); + return 0; +} + // P_USER //////////// @@ -3271,6 +3282,7 @@ static luaL_Reg lib[] = { {"P_CanRunOnWater",lib_pCanRunOnWater}, {"P_MaceRotate",lib_pMaceRotate}, {"P_RailThinker",lib_pRailThinker}, + {"P_XYMovement",lib_pXYMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, From 6ac3d623215ea3d80b79165852b3ba6940fd21ac Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 20:01:29 -0500 Subject: [PATCH 44/75] Expose P_RingXYMovement to Lua. Ever wanted to move like a ring horizontally? --- src/lua_baselib.c | 12 ++++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 2cfc251ff..58c7c80a3 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -924,6 +924,17 @@ static int lib_pXYMovement(lua_State *L) return 0; } +static int lib_pRingXYMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + P_RingXYMovement(actor); + return 0; +} + // P_USER //////////// @@ -3283,6 +3294,7 @@ static luaL_Reg lib[] = { {"P_MaceRotate",lib_pMaceRotate}, {"P_RailThinker",lib_pRailThinker}, {"P_XYMovement",lib_pXYMovement}, + {"P_RingXYMovement",lib_pRingXYMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index c26308a59..9d6efd950 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2102,7 +2102,7 @@ void P_XYMovement(mobj_t *mo) P_XYFriction(mo, oldx, oldy); } -static void P_RingXYMovement(mobj_t *mo) +void P_RingXYMovement(mobj_t *mo) { I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); diff --git a/src/p_mobj.h b/src/p_mobj.h index c94dbd650..d874ffe09 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -471,6 +471,7 @@ void P_NullPrecipThinker(precipmobj_t *mobj); void P_RemovePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); +void P_RingXYMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From 27c25bfa1e632bb8f09c2494ab72bc7eb930c7ef Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 20:22:41 -0500 Subject: [PATCH 45/75] Expose P_SceneryXYMovement to Lua. Ironically this seems slightly more advanced than P_RingXYMovement... --- src/lua_baselib.c | 12 ++++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 58c7c80a3..3e1f2c2dd 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -935,6 +935,17 @@ static int lib_pRingXYMovement(lua_State *L) return 0; } +static int lib_pSceneryXYMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + P_SceneryXYMovement(actor); + return 0; +} + // P_USER //////////// @@ -3295,6 +3306,7 @@ static luaL_Reg lib[] = { {"P_RailThinker",lib_pRailThinker}, {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, + {"P_SceneryXYMovement",lib_pSceneryXYMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 9d6efd950..a6886c1ad 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2111,7 +2111,7 @@ void P_RingXYMovement(mobj_t *mo) P_SlideMove(mo); } -static void P_SceneryXYMovement(mobj_t *mo) +void P_SceneryXYMovement(mobj_t *mo) { fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls diff --git a/src/p_mobj.h b/src/p_mobj.h index d874ffe09..99d091760 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -472,6 +472,7 @@ void P_RemovePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_RingXYMovement(mobj_t *mo); +void P_SceneryXYMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From 6d3a2919a2ce8b80ed1d3e2678a0eaa3a4f43251 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 20:41:30 -0500 Subject: [PATCH 46/75] Expose P_ZMovement to Lua. Because P_XYMovement wasn't enough. --- src/lua_baselib.c | 13 +++++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3e1f2c2dd..68455cd65 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -946,6 +946,18 @@ static int lib_pSceneryXYMovement(lua_State *L) return 0; } +static int lib_pZMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_ZMovement(actor)); + return 1; +} + + // P_USER //////////// @@ -3307,6 +3319,7 @@ static luaL_Reg lib[] = { {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement}, + {"P_ZMovement",lib_pZMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index a6886c1ad..02b9885b8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2337,7 +2337,7 @@ boolean P_CheckSolidLava(ffloor_t *rover) // P_ZMovement // Returns false if the mobj was killed/exploded/removed, true otherwise. // -static boolean P_ZMovement(mobj_t *mo) +boolean P_ZMovement(mobj_t *mo) { fixed_t dist, delta; boolean onground; diff --git a/src/p_mobj.h b/src/p_mobj.h index 99d091760..63095e2ff 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -473,6 +473,7 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_RingXYMovement(mobj_t *mo); void P_SceneryXYMovement(mobj_t *mo); +boolean P_ZMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From 4710e4f07c0299826767a84ef71e5ca11f916d3c Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 22:55:01 -0500 Subject: [PATCH 47/75] Expose P_RingZMovement to Lua. Ever wanted to move like a ring vertically? --- src/lua_baselib.c | 11 +++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 68455cd65..8f6c41e10 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -957,6 +957,16 @@ static int lib_pZMovement(lua_State *L) return 1; } +static int lib_pRingZMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + P_RingZMovement(actor); + return 0; +} // P_USER //////////// @@ -3320,6 +3330,7 @@ static luaL_Reg lib[] = { {"P_RingXYMovement",lib_pRingXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement}, {"P_ZMovement",lib_pZMovement}, + {"P_RingZMovement",lib_pRingZMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 02b9885b8..e9ebf571d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2270,7 +2270,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) } } -static void P_RingZMovement(mobj_t *mo) +void P_RingZMovement(mobj_t *mo) { I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); diff --git a/src/p_mobj.h b/src/p_mobj.h index 63095e2ff..f5c14fde5 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -474,6 +474,7 @@ void P_XYMovement(mobj_t *mo); void P_RingXYMovement(mobj_t *mo); void P_SceneryXYMovement(mobj_t *mo); boolean P_ZMovement(mobj_t *mo); +void P_RingZMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From df1fd0c4560cc4ca920c1d9781d69bfba3674fb2 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 23:08:33 -0500 Subject: [PATCH 48/75] Expose P_SceneryZMovement to Lua. Still more complex than P_RingZMovement. --- src/lua_baselib.c | 12 ++++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8f6c41e10..c81c1cd0f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -968,6 +968,17 @@ static int lib_pRingZMovement(lua_State *L) return 0; } +static int lib_pSceneryZMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_SceneryZMovement(actor)); + return 1; +} + // P_USER //////////// @@ -3331,6 +3342,7 @@ static luaL_Reg lib[] = { {"P_SceneryXYMovement",lib_pSceneryXYMovement}, {"P_ZMovement",lib_pZMovement}, {"P_RingZMovement",lib_pRingZMovement}, + {"P_SceneryZMovement",lib_pSceneryZMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index e9ebf571d..84ab1df39 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3069,7 +3069,7 @@ nightsdone: } } -static boolean P_SceneryZMovement(mobj_t *mo) +boolean P_SceneryZMovement(mobj_t *mo) { // Intercept the stupid 'fall through 3dfloors' bug if (mo->subsector->sector->ffloors) diff --git a/src/p_mobj.h b/src/p_mobj.h index f5c14fde5..ab1e1814f 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -475,6 +475,7 @@ void P_RingXYMovement(mobj_t *mo); void P_SceneryXYMovement(mobj_t *mo); boolean P_ZMovement(mobj_t *mo); void P_RingZMovement(mobj_t *mo); +boolean P_SceneryZMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From 4b3d6f04f8248256cf6aa57ca362d07d0871b1fb Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sun, 19 Apr 2020 23:15:46 -0500 Subject: [PATCH 49/75] Expose P_PlayerZMovement to Lua. Finishing off these changes; how a player moves vertically. --- src/lua_baselib.c | 12 ++++++++++++ src/p_mobj.c | 2 +- src/p_mobj.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c81c1cd0f..ba90912cf 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -979,6 +979,17 @@ static int lib_pSceneryZMovement(lua_State *L) return 1; } +static int lib_pPlayerZMovement(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + P_PlayerZMovement(actor); + return 0; +} + // P_USER //////////// @@ -3343,6 +3354,7 @@ static luaL_Reg lib[] = { {"P_ZMovement",lib_pZMovement}, {"P_RingZMovement",lib_pRingZMovement}, {"P_SceneryZMovement",lib_pSceneryZMovement}, + {"P_PlayerZMovement",lib_pPlayerZMovement}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, diff --git a/src/p_mobj.c b/src/p_mobj.c index 84ab1df39..6f3f53559 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2891,7 +2891,7 @@ static boolean P_PlayerPolyObjectZMovement(mobj_t *mo) return stopmovecut; } -static void P_PlayerZMovement(mobj_t *mo) +void P_PlayerZMovement(mobj_t *mo) { boolean onground; diff --git a/src/p_mobj.h b/src/p_mobj.h index ab1e1814f..643e3d04c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -476,6 +476,7 @@ void P_SceneryXYMovement(mobj_t *mo); boolean P_ZMovement(mobj_t *mo); void P_RingZMovement(mobj_t *mo); boolean P_SceneryZMovement(mobj_t *mo); +void P_PlayerZMovement(mobj_t *mo); void P_EmeraldManager(void); extern INT32 modulothing; From ada06910dc8115973d3d23b98c4d90a3e722b625 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Sat, 23 May 2020 09:50:35 -0500 Subject: [PATCH 50/75] Expose P_MovePlayer to Lua. --- src/lua_baselib.c | 12 ++++++++++++ src/p_local.h | 1 + src/p_user.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index ba90912cf..23aa060fe 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1360,6 +1360,17 @@ static int lib_pSpawnSkidDust(lua_State *L) return 0; } +static int lib_pMovePlayer(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_MovePlayer(player); + return 0; +} + static int lib_pDoPlayerFinish(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -3386,6 +3397,7 @@ static luaL_Reg lib[] = { {"P_BlackOw",lib_pBlackOw}, {"P_ElementalFire",lib_pElementalFire}, {"P_SpawnSkidDust", lib_pSpawnSkidDust}, + {"P_MovePlayer",lib_pMovePlayer}, {"P_DoPlayerFinish",lib_pDoPlayerFinish}, {"P_DoPlayerExit",lib_pDoPlayerExit}, {"P_InstaThrust",lib_pInstaThrust}, diff --git a/src/p_local.h b/src/p_local.h index 9873a20af..b6c34f357 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -177,6 +177,7 @@ void P_BlackOw(player_t *player); void P_ElementalFire(player_t *player, boolean cropcircle); void P_SpawnSkidDust(player_t *player, fixed_t radius, boolean sound); +void P_MovePlayer(player_t *player); void P_DoPityCheck(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); diff --git a/src/p_user.c b/src/p_user.c index d426277ff..7dd888117 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7889,7 +7889,7 @@ static void P_SkidStuff(player_t *player) // // P_MovePlayer -static void P_MovePlayer(player_t *player) +void P_MovePlayer(player_t *player) { ticcmd_t *cmd; INT32 i; From e849c9898e862e4464efb25a768e59cd9e480253 Mon Sep 17 00:00:00 2001 From: Kays Ishaq Date: Sun, 12 Jul 2020 19:05:27 -0400 Subject: [PATCH 51/75] move dupenum declaration to beginning of block --- src/dehacked.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6987a883d..61394bbad 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -814,6 +814,7 @@ static void readskincolor(MYFILE *f, INT32 num) { size_t lastchar = strlen(truncword); char oldword[lastchar+1]; + char dupenum = '1'; strlcpy(oldword, truncword, lastchar+1); lastchar--; @@ -825,7 +826,6 @@ static void readskincolor(MYFILE *f, INT32 num) lastchar++; } - char dupenum = '1'; while (R_GetColorByName(truncword)) { truncword[lastchar] = dupenum; From 839f0862162e577be27166badfc1d3f399f5b0a0 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Jul 2020 16:09:43 -0700 Subject: [PATCH 52/75] A few more instances of "gr" to purge --- src/hardware/hw_main.c | 10 +++++----- src/hardware/hw_md2.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 85d8d454e..0d7404c77 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3487,7 +3487,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void) typedef struct { FOutVector verts[4]; - gr_vissprite_t *spr; + gl_vissprite_t *spr; } zbuffersprite_t; // this list is used to store data about linkdraw sprites @@ -3495,7 +3495,7 @@ zbuffersprite_t linkdrawlist[MAXVISSPRITES]; UINT32 linkdrawcount = 0; // add the necessary data to the list for delayed z-buffer drawing -static void HWR_LinkDrawHackAdd(FOutVector *verts, gr_vissprite_t *spr) +static void HWR_LinkDrawHackAdd(FOutVector *verts, gl_vissprite_t *spr) { if (linkdrawcount < MAXVISSPRITES) { @@ -5007,11 +5007,11 @@ static void HWR_ProjectSprite(mobj_t *thing) // calculate tz for tracer, same way it is calculated for this sprite // transform the origin point - tr_x = FIXED_TO_FLOAT(thing->tracer->x) - gr_viewx; - tr_y = FIXED_TO_FLOAT(thing->tracer->y) - gr_viewy; + tr_x = FIXED_TO_FLOAT(thing->tracer->x) - gl_viewx; + tr_y = FIXED_TO_FLOAT(thing->tracer->y) - gl_viewy; // rotation around vertical axis - tracertz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); + tracertz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); // Software does not render the linkdraw sprite if the tracer is behind the view plane, // so do the same check here. diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index b23b3600c..fa5156758 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1309,13 +1309,13 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // texture loading before model init, so it knows if sprite graphics are used, which // means that texture coordinates have to be adjusted gpatch = md2->grpatch; - if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) + if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !md2->notexturefile)) md2_loadTexture(md2); gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... - if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available + if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available && (!md2->blendgrpatch - || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) + || ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); @@ -1332,7 +1332,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) md2_printModelInfo(md2->model); // if model uses sprite patch as texture, then // adjust texture coordinates to take power of two textures into account - if (!gpatch || !gpatch->mipmap->grInfo.format) + if (!gpatch || !gpatch->mipmap->format) adjustTextureCoords(md2->model, spr->gpatch); HWD.pfnCreateModelVBOs(md2->model); } From 5f85c722798d2154f8d823941ed1854dcae6cc4b Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Fri, 20 Mar 2020 09:12:19 -0500 Subject: [PATCH 53/75] 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 54/75] 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 55/75] 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 56/75] 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 29a116ba8103fc4aff51a977693cb678b4da5e3f Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Mon, 13 Jul 2020 18:56:07 -0400 Subject: [PATCH 57/75] Fix lib_freeslot --- src/dehacked.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8510d7a3d..6276854f5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -10665,7 +10665,7 @@ static inline int lib_freeslot(lua_State *L) CONS_Printf("State S_%s allocated.\n",word); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_STATES[i],word); - lua_pushinteger(L, i); + lua_pushinteger(L, S_FIRSTFREESLOT + i); r++; break; } @@ -10680,7 +10680,7 @@ static inline int lib_freeslot(lua_State *L) CONS_Printf("MobjType MT_%s allocated.\n",word); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_MOBJS[i],word); - lua_pushinteger(L, i); + lua_pushinteger(L, MT_FIRSTFREESLOT + i); r++; break; } @@ -10696,7 +10696,7 @@ static inline int lib_freeslot(lua_State *L) FREE_SKINCOLORS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_SKINCOLORS[i],word); M_AddMenuColor(numskincolors++); - lua_pushinteger(L, i); + lua_pushinteger(L, SKINCOLOR_FIRSTFREESLOT + i); r++; break; } @@ -10717,11 +10717,12 @@ static inline int lib_freeslot(lua_State *L) CONS_Printf("Sprite SPR2_%s allocated.\n",word); strncpy(spr2names[free_spr2],word,4); spr2defaults[free_spr2] = 0; + lua_pushinteger(L, free_spr2); + r++; spr2names[free_spr2++][4] = 0; } else CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); } - r++; } else if (fastcmp(type, "TOL")) { From 7f9175033d94752b79d4a9a1df825b749ee64dc1 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:34:57 -0400 Subject: [PATCH 58/75] minor lua fixes minor lua fixes --- src/lua_consolelib.c | 2 +- src/lua_mobjlib.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 4fe234dee..36b1c3669 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -444,7 +444,7 @@ static int lib_consPrintf(lua_State *L) if (n < 2) return luaL_error(L, "CONS_Printf requires at least two arguments: player and text."); //HUDSAFE - INLEVEL + plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); if (!plr) return LUA_ErrInvalid(L, "player_t"); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 129339b96..e2826e160 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -165,14 +165,15 @@ static int mobj_get(lua_State *L) enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt); lua_settop(L, 2); - INLEVEL - - if (!mo) { + if (!mo || !ISINLEVEL) { if (field == mobj_valid) { lua_pushboolean(L, 0); return 1; } - return LUA_ErrInvalid(L, "mobj_t"); + if (!mo) { + return LUA_ErrInvalid(L, "mobj_t"); + } else + return luaL_error(L, "Do not access an mobj_t field outside a level!"); } switch(field) From 734033250dcb9a085b07cafbe1a7bdd84b63aa14 Mon Sep 17 00:00:00 2001 From: SwitchKaze Date: Tue, 14 Jul 2020 17:09:31 -0500 Subject: [PATCH 59/75] Fix skincolor-related memory leak --- src/dehacked.c | 1 + src/lua_infolib.c | 10 +++++----- src/r_draw.c | 11 +++++++++++ src/r_draw.h | 3 +++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8510d7a3d..2e98a854c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -851,6 +851,7 @@ static void readskincolor(MYFILE *f, INT32 num) if ((tmp = strtok(NULL,",")) == NULL) break; } + skincolor_modified[num] = true; } else if (fastcmp(word, "INVCOLOR")) { diff --git a/src/lua_infolib.c b/src/lua_infolib.c index fe0ca759f..b3e92f833 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -26,8 +26,8 @@ #include "lua_libs.h" #include "lua_hud.h" // hud_running errors -extern CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -extern void R_FlushTranslationColormapCache(void); +extern CV_PossibleValue_t Color_cons_t[]; +extern UINT8 skincolor_modified[]; boolean LUA_CallAction(const char *action, mobj_t *actor); state_t *astate; @@ -1559,7 +1559,7 @@ static int lib_setSkinColor(lua_State *L) else for (j=0; jramp[j] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[j]; - R_FlushTranslationColormapCache(); + skincolor_modified[cnum] = true; } else if (i == 3 || (str && fastcmp(str,"invcolor"))) { UINT16 v = (UINT16)luaL_checkinteger(L, 3); if (v >= numskincolors) @@ -1644,7 +1644,7 @@ static int skincolor_set(lua_State *L) else for (i=0; iramp[i] = (*((UINT8 **)luaL_checkudata(L, 3, META_COLORRAMP)))[i]; - R_FlushTranslationColormapCache(); + skincolor_modified[info-skincolors] = true; } else if (fastcmp(field,"invcolor")) { UINT16 v = (UINT16)luaL_checkinteger(L, 3); if (v >= numskincolors) @@ -1698,7 +1698,7 @@ static int colorramp_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter skincolor_t in HUD rendering code!"); colorramp[n] = i; - R_FlushTranslationColormapCache(); + skincolor_modified[cnum] = true; return 0; } diff --git a/src/r_draw.c b/src/r_draw.c index 6492d9d36..2b798c3bf 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -134,6 +134,7 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; #define NUM_PALETTE_ENTRIES 256 static UINT8** translationtablecache[MAXSKINS + 7] = {NULL}; +UINT8 skincolor_modified[MAXSKINCOLORS]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; @@ -362,6 +363,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags { UINT8* ret; INT32 skintableindex; + INT32 i; // Adjust if we want the default colormap switch (skinnum) @@ -385,6 +387,15 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags // Get colormap ret = translationtablecache[skintableindex][color]; + + // Rebuild the cache if necessary + if (skincolor_modified[color]) + { + for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++) + if (translationtablecache[i] && translationtablecache[i][color]) + R_GenerateTranslationColormap(translationtablecache[i][color], i>=MAXSKINS ? MAXSKINS-i-1 : i, color); + skincolor_modified[color] = false; + } } else ret = NULL; diff --git a/src/r_draw.h b/src/r_draw.h index 329c4974a..1ca22f18a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -117,6 +117,9 @@ void R_FlushTranslationColormapCache(void); UINT16 R_GetColorByName(const char *name); UINT16 R_GetSuperColorByName(const char *name); +// Color ramp modification should force a recache +extern UINT8 skincolor_modified[]; + // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); void R_InitViewBorder(void); From 05ac0fc7ea7f232f804e9ca612be9ac437c4cc54 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 18 Jul 2020 16:36:41 -0400 Subject: [PATCH 60/75] 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 61/75] 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 62/75] 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 63/75] 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 64/75] 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 65/75] 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 66/75] 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 67/75] 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 68/75] 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 69/75] 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 70/75] 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 71/75] 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 72/75] 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 73/75] 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; From d90fe939828b488e89499971ac86260ca1b54d2b Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 03:58:38 -0700 Subject: [PATCH 74/75] Fix Credits sequence from Extras being unskippable This is because a server is not started before going to the credits. I'm way too stupid/lazy to try starting a server, so have a special case! --- src/g_game.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index cce4ac822..e165d5415 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2013,7 +2013,9 @@ boolean G_Responder(event_t *ev) if (F_CreditResponder(ev)) { // Skip credits for everyone - if (!netgame || server || IsPlayerAdmin(consoleplayer)) + if (! serverrunning)/* hahahahahaha */ + F_StartGameEvaluation(); + else if (server || IsPlayerAdmin(consoleplayer)) SendNetXCmd(XD_EXITLEVEL, NULL, 0); return true; } From f791c1b4ec7ff3eb4021ff3e515ecded7142baef Mon Sep 17 00:00:00 2001 From: Nev3r Date: Tue, 28 Jul 2020 20:39:11 +0200 Subject: [PATCH 75/75] Fix gl_linedef renaming which went off radars on the udmf branch --- 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 34cc530de..ec3a39692 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1466,8 +1466,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode = PF_Translucent; break; default: - if (gr_linedef->alpha >= 0 && gr_linedef->alpha < FRACUNIT) - blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gr_linedef->alpha), &Surf); + if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), &Surf); else blendmode = PF_Masked; break;