From 8e31c34b06d04f7d13e71badb973fc2cb965abd9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Apr 2021 21:00:41 +0200 Subject: [PATCH 1/4] - fixed tileImportFromTexture. * the parser read numbers with leading zeros as octal, which is not wanted here * texture lookup by file name must be forced for root directory entries. --- source/build/src/defs.cpp | 1 + source/core/textures/buildtiles.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 137a0d701..0ed7faeb5 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -363,6 +363,7 @@ static int32_t defsparser(scriptfile *script) { "rffdefineid", T_RFFDEFINEID }, // dummy }; + script->SetNoOctals(true); while (1) { #ifdef USE_DEF_PROGRESS diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index 653dd717c..07efd696f 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -499,7 +499,7 @@ CCMD(tilecrc) int tileImportFromTexture(const char* fn, int tilenum, int alphacut, int istexture) { - FTextureID texid = TexMan.CheckForTexture(fn, ETextureType::Any); + FTextureID texid = TexMan.CheckForTexture(fn, ETextureType::Any, FTextureManager::TEXMAN_ForceLookup); if (!texid.isValid()) return -1; auto tex = TexMan.GetGameTexture(texid); @@ -508,7 +508,7 @@ int tileImportFromTexture(const char* fn, int tilenum, int alphacut, int istextu if (xsiz <= 0 || ysiz <= 0) return -2; - // create a new game texture here - we want to give it a new name! + // create a new game texture here - we want to give it a different name! tex = MakeGameTexture(tex->GetTexture(), FStringf("#%05d", tilenum), ETextureType::Override); TexMan.AddGameTexture(tex); TileFiles.tiledata[tilenum].backup = TileFiles.tiledata[tilenum].texture = tex; From eb2e77fb75a63a76ad5370f616cc7fcf046f7ed4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Apr 2021 00:14:15 +0200 Subject: [PATCH 2/4] - Apply fix from EDuke32 commit 7225643e. Fix undefined behavior/potential OOB access in ST_21_FLOOR_DOOR. g_AnimateGoal does not take a sector number, it takes an animation index, and caps at 1024, not 4096. --- source/games/duke/src/sectors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 5abe987fa..b08ca0c5d 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -753,7 +753,7 @@ static void handle_st21(int sn, DDukeActor* actor) int j; if (i >= 0) { - if (animategoal[sn] == sptr->ceilingz) + if (animategoal[i] == sptr->ceilingz) animategoal[i] = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; else animategoal[i] = sptr->ceilingz; j = animategoal[i]; From 658712d893f68898b3816c4ea6cb3c30271ec4f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Apr 2021 08:56:44 +0200 Subject: [PATCH 3/4] - removed duplicate d_gui.h file. --- source/core/console/d_gui.h | 115 ------------------------------------ 1 file changed, 115 deletions(-) delete mode 100644 source/core/console/d_gui.h diff --git a/source/core/console/d_gui.h b/source/core/console/d_gui.h deleted file mode 100644 index 774f928ac..000000000 --- a/source/core/console/d_gui.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -** d_gui.h -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** So when do I get a real UT-like windowing system? -*/ - -#ifndef __D_GUI_H__ -#define __D_GUI_H__ - -// For a GUIEvent, x and y specify absolute location of mouse pointer -enum EGUIEvent -{ - EV_GUI_None, - EV_GUI_KeyDown, // data1: unshifted ASCII, data2: shifted ASCII, data3: modifiers - EV_GUI_KeyRepeat, // same - EV_GUI_KeyUp, // same - EV_GUI_Char, // data1: translated character (for user text input), data2: alt down? - EV_GUI_FirstMouseEvent, - EV_GUI_MouseMove, - EV_GUI_LButtonDown, - EV_GUI_LButtonUp, - EV_GUI_LButtonDblClick, - EV_GUI_MButtonDown, - EV_GUI_MButtonUp, - EV_GUI_MButtonDblClick, - EV_GUI_RButtonDown, - EV_GUI_RButtonUp, - EV_GUI_RButtonDblClick, - EV_GUI_WheelUp, // data3: shift/ctrl/alt - EV_GUI_WheelDown, // " - EV_GUI_WheelRight, // " - EV_GUI_WheelLeft, // " - EV_GUI_BackButtonDown, - EV_GUI_BackButtonUp, - EV_GUI_FwdButtonDown, - EV_GUI_FwdButtonUp, - EV_GUI_LastMouseEvent, -}; - -enum GUIKeyModifiers -{ - GKM_SHIFT = 1, - GKM_CTRL = 2, - GKM_ALT = 4, - GKM_META = 8, - GKM_LBUTTON = 16 -}; - -// Special codes for some GUI keys, including a few real ASCII codes. -enum ESpecialGUIKeys -{ - GK_PGDN = 1, - GK_PGUP = 2, - GK_HOME = 3, - GK_END = 4, - GK_LEFT = 5, - GK_RIGHT = 6, - GK_ALERT = 7, // ASCII bell - GK_BACKSPACE= 8, // ASCII - GK_TAB = 9, // ASCII - GK_LINEFEED = 10, // ASCII - GK_DOWN = 10, - GK_VTAB = 11, // ASCII - GK_UP = 11, - GK_FORMFEED = 12, // ASCII - GK_RETURN = 13, // ASCII - GK_F1 = 14, - GK_F2 = 15, - GK_F3 = 16, - GK_F4 = 17, - GK_F5 = 18, - GK_F6 = 19, - GK_F7 = 20, - GK_F8 = 21, - GK_F9 = 22, - GK_F10 = 23, - GK_F11 = 24, - GK_F12 = 25, - GK_DEL = 26, - GK_ESCAPE = 27, // ASCII - GK_FREE1 = 28, - GK_FREE2 = 29, - GK_BACK = 30, // browser back key - GK_CESCAPE = 31 // color escape -}; - -#endif //__D_GUI_H__ From 008391a2ad252ec778f539049927f9cd38d8f409 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Apr 2021 08:59:06 +0200 Subject: [PATCH 4/4] - license correction for ct_chat.cpp This was supposed to get the same treatment as d_net.cpp, i.e get the old license restored and be released under a duplicate GPL/Doom Source license but it was somehow missed when it got added. Also removed all leftover Doom specific parts. --- source/core/ct_chat.cpp | 135 ++++++++++++---------------------------- 1 file changed, 39 insertions(+), 96 deletions(-) diff --git a/source/core/ct_chat.cpp b/source/core/ct_chat.cpp index 0cce9c3c5..6e04e7e49 100644 --- a/source/core/ct_chat.cpp +++ b/source/core/ct_chat.cpp @@ -17,6 +17,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see http://www.gnu.org/licenses/ // +// +// Alternatively the following applies: +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// //----------------------------------------------------------------------------- // @@ -308,42 +320,42 @@ static void CT_ClearChatMessage () static void ShoveChatStr (const char *str, uint8_t who) { -#if 0 // Don't send empty messages if (str == NULL || str[0] == '\0') return; - FString substBuff; - - if (str[0] == '/' && - (str[1] == 'm' || str[1] == 'M') && - (str[2] == 'e' || str[2] == 'E')) - { // This is a /me message - str += 3; - who |= 2; - } - - Net_WriteByte (DEM_SAY); - Net_WriteByte (who); - - if (!chat_substitution || !DoSubstitution (substBuff, str)) - { - Net_WriteString(MakeUTF8(str)); - } - else - { - Net_WriteString(MakeUTF8(substBuff)); - } -#else if (*str == '#') { C_DoCommand(FStringf("activatecheat %s", str + 1)); } else { +#if 0 + FString substBuff; + + if (str[0] == '/' && + (str[1] == 'm' || str[1] == 'M') && + (str[2] == 'e' || str[2] == 'E')) + { // This is a /me message + str += 3; + who |= 2; + } + + Net_WriteByte(DEM_SAY); + Net_WriteByte(who); + + if (!chat_substitution || !DoSubstitution(substBuff, str)) + { + Net_WriteString(MakeUTF8(str)); + } + else + { + Net_WriteString(MakeUTF8(substBuff)); + } +#else Printf("%s %s\n", GStrings("TXT_SAY"), str); - } #endif + } } //=========================================================================== @@ -358,10 +370,6 @@ static void ShoveChatStr (const char *str, uint8_t who) static bool DoSubstitution (FString &out, const char *in) { #if 0 - player_t *player = &players[consoleplayer]; - auto weapon = player->ReadyWeapon; - auto ammo1 = weapon ? weapon->PointerVar(NAME_Ammo1) : nullptr; - auto ammo2 = weapon ? weapon->PointerVar(NAME_Ammo2) : nullptr; const char *a, *b; a = in; @@ -378,75 +386,10 @@ static bool DoSubstitution (FString &out, const char *in) ptrdiff_t ByteLen = b - a; - if (ByteLen == 6) + // todo: forward to the game modules. Doom used the following tokens: + // health, weapon, armor, ammocount, ammo + if (0) { - if (strnicmp(a, "health", 6) == 0) - { - out.AppendFormat("%d", player->health); - } - else if (strnicmp(a, "weapon", 6) == 0) - { - if (weapon == NULL) - { - out += "no weapon"; - } - else - { - out += weapon->GetClass()->TypeName.GetChars(); - } - } - } - else if (ByteLen == 5) - { - if (strnicmp(a, "armor", 5) == 0) - { - auto armor = player->mo->FindInventory(NAME_BasicArmor); - out.AppendFormat("%d", armor != NULL ? armor->IntVar(NAME_Amount) : 0); - } - } - else if (ByteLen == 9) - { - if (strnicmp(a, "ammocount", 9) == 0) - { - if (weapon == NULL) - { - out += '0'; - } - else - { - out.AppendFormat("%d", ammo1 != NULL ? ammo1->IntVar(NAME_Amount) : 0); - if (ammo2 != NULL) - { - out.AppendFormat("/%d", ammo2->IntVar(NAME_Amount)); - } - } - } - } - else if (ByteLen == 4) - { - if (strnicmp(a, "ammo", 4) == 0) - { - if (ammo1 == NULL) - { - out += "no ammo"; - } - else - { - out.AppendFormat("%s", ammo1->GetClass()->TypeName.GetChars()); - if (ammo2 != NULL) - { - out.AppendFormat("/%s", ammo2->GetClass()->TypeName.GetChars()); - } - } - } - } - else if (ByteLen == 0) - { - out += '$'; - if (*b == '$') - { - b++; - } } else {