From c7cf619ff401d877fb7af68fb1e986762050e108 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Feb 2017 01:58:21 +0100 Subject: [PATCH 1/3] - Caution: Wads.GetLumpName with a char pointer is stupid because it doesn't 0-terminate its return. --- src/gl/data/gl_data.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 93e4d5697..36ae3ad8f 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -109,6 +109,7 @@ void AdjustSpriteOffsets() { char str[9]; Wads.GetLumpName(str, i); + str[8] = 0; FTextureID texid = TexMan.CheckForTexture(str, FTexture::TEX_Sprite, 0); if (texid.isValid() && Wads.GetLumpFile(TexMan[texid]->SourceLump) > FWadCollection::IWAD_FILENUM) { From 3a5124e10eac0d24ae59d9d10aca7ecdf1569675 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Feb 2017 02:09:56 +0100 Subject: [PATCH 2/3] - fixed: TakeInventory needs to check for subclasses of PowerInfiniteAmmo. --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 23e83425f..d6da38961 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -902,7 +902,7 @@ bool AActor::TakeInventory(PClassActor *itemclass, int amount, bool fromdecorate // Do not take ammo if the "no take infinite/take as ammo depletion" flag is set // and infinite ammo is on if (notakeinfinite && - ((dmflags & DF_INFINITE_AMMO) || (player && FindInventory(NAME_PowerInfiniteAmmo))) && item->IsKindOf(NAME_Ammo)) + ((dmflags & DF_INFINITE_AMMO) || (player && FindInventory(NAME_PowerInfiniteAmmo, true))) && item->IsKindOf(NAME_Ammo)) { // Nothing to do here, except maybe res = false;? Would it make sense? result = false; From 720e05d131f7d309e236240ca6b62b2ca16b03a4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Feb 2017 02:31:19 +0100 Subject: [PATCH 3/3] - fixed memory leak in DEM_NETEVENT. - added handling for DEM_NETEVENT to SkipCommand. - keep the data of DEM_NETEVENT at a fixed length to simplify handling. --- src/d_net.cpp | 9 +++++++-- src/events.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index fb7cac316..10ff7d0fc 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2666,12 +2666,13 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_NETEVENT: { - FString ename = ReadString(stream); + const char *ename = ReadString(stream); int argn = ReadByte(stream); int arg[3] = { 0, 0, 0 }; - for (int i = 0; i < argn; i++) + for (int i = 0; i < 3; i++) arg[i] = ReadLong(stream); E_Console(player, ename, arg[0], arg[1], arg[2]); + delete[] ename; } break; @@ -2721,6 +2722,10 @@ void Net_SkipCommand (int type, BYTE **stream) skip = strlen ((char *)(*stream)) + 5; break; + case DEM_NETEVENT: + skip = strlen((char *)(*stream)) + 13; + break; + case DEM_SUMMON2: case DEM_SUMMONFRIEND2: case DEM_SUMMONFOE2: diff --git a/src/events.cpp b/src/events.cpp index d714eefce..a0780fb92 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -1139,7 +1139,7 @@ CCMD(netevent) Net_WriteByte(DEM_NETEVENT); Net_WriteString(argv[1]); Net_WriteByte(argn); - for (int i = 0; i < argn; i++) + for (int i = 0; i < 3; i++) Net_WriteLong(arg[i]); } }