From 87761b3383c159a757ea08c0f7988b3179b06b79 Mon Sep 17 00:00:00 2001 From: gez Date: Sun, 26 May 2013 11:33:33 +0000 Subject: [PATCH] * Updated to ZDoom 4289: - Added parentheses for clarity. - Fixed potential uninitialized access in FMapInfoParser::ParseEndGame(). - Fixed: 4, 2, and 1 bit grayscale images weren't properly supported. - Fixed: Valgrind uninitialized memory error and a signed/unsigned warning. - Just remembered that the true color stuff generates textures differently. Changed the previous commit to expand 1, 2, and 4 bit grayscale images while reading the PNG instead of changing the palette. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1576 b0f79afe-0144-0410-b225-9a4edf0717df --- src/intermission/intermission_parse.cpp | 26 +++++++++++++-------- src/m_png.cpp | 30 +++++++++++++++++++++---- src/p_mobj.cpp | 2 +- src/svnrevision.h | 4 ++-- src/v_font.cpp | 3 ++- 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/intermission/intermission_parse.cpp b/src/intermission/intermission_parse.cpp index d621d4c6..6166e608 100644 --- a/src/intermission/intermission_parse.cpp +++ b/src/intermission/intermission_parse.cpp @@ -660,7 +660,7 @@ FName FMapInfoParser::ParseEndGame() } } FIntermissionDescriptor *desc = new FIntermissionDescriptor; - FIntermissionAction *action; + FIntermissionAction *action = NULL; switch (newSeq.EndType) { @@ -699,15 +699,23 @@ FName FMapInfoParser::ParseEndGame() break; } - action->mBackground = newSeq.PicName; - action->mMusic = newSeq.Music; - action->mMusicLooping = newSeq.MusicLooping; - desc->mActions.Push(action); + if (action == NULL) + { + sc.ScriptError("Endgame type was not defined"); + return NAME_None; // We won't really get here. + } + else + { + action->mBackground = newSeq.PicName; + action->mMusic = newSeq.Music; + action->mMusicLooping = newSeq.MusicLooping; + desc->mActions.Push(action); - FString seq; - seq.Format("@EndSequence_%d_", generated++); - ReplaceIntermission(seq, desc); - return FName(seq); + FString seq; + seq.Format("@EndSequence_%d_", generated++); + ReplaceIntermission(seq, desc); + return FName(seq); + } } //========================================================================== diff --git a/src/m_png.cpp b/src/m_png.cpp index dd2e4697..1e1a331a 100644 --- a/src/m_png.cpp +++ b/src/m_png.cpp @@ -103,7 +103,7 @@ static inline void MakeChunk (void *where, DWORD type, size_t len); static inline void StuffPalette (const PalEntry *from, BYTE *to); static bool WriteIDAT (FILE *file, const BYTE *data, int len); static void UnfilterRow (int width, BYTE *dest, BYTE *stream, BYTE *prev, int bpp); -static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout); +static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout, bool grayscale); // EXTERNAL DATA DECLARATIONS ---------------------------------------------- @@ -604,7 +604,7 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc in = prev; if (bitdepth < 8) { - UnpackPixels (passwidth, bytesPerRowIn, bitdepth, in, adam7buff[2]); + UnpackPixels (passwidth, bytesPerRowIn, bitdepth, in, adam7buff[2], colortype == 0); in = adam7buff[2]; } // Distribute pixels into the output buffer @@ -688,7 +688,7 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc passpitch = pitch << interlace; for (curr = buffer + pitch * interlace; curr <= prev; curr += passpitch) { - UnpackPixels (width, bytesPerRowIn, bitdepth, curr, curr); + UnpackPixels (width, bytesPerRowIn, bitdepth, curr, curr, colortype == 0); } } return true; @@ -1155,7 +1155,7 @@ void UnfilterRow (int width, BYTE *dest, BYTE *row, BYTE *prev, int bpp) // //========================================================================== -static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout) +static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout, bool grayscale) { const BYTE *in; BYTE *out; @@ -1242,4 +1242,26 @@ static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE * } break; } + + // Expand gray scale to 8bpp + if(grayscale) + { + out = rowout + width; + while(--out >= rowout) + { + switch(bitdepth) + { + case 1: + *out *= 0xFF; + break; + case 2: + *out |= (*out<<2)|(*out<<4)|(*out<<6); + break; + case 4: + *out |= (*out<<4); + break; + default: break; + } + } + } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a6391a71..e70f3cc0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -911,7 +911,7 @@ bool AActor::IsVisibleToPlayer() const return true; if (VisibleToTeam != 0 && teamplay && - VisibleToTeam-1 != players[consoleplayer].userinfo.GetTeam()) + (signed)(VisibleToTeam-1) != players[consoleplayer].userinfo.GetTeam()) return false; const player_t* pPlayer = players[consoleplayer].camera->player; diff --git a/src/svnrevision.h b/src/svnrevision.h index c3423b7e..1479dd0c 100644 --- a/src/svnrevision.h +++ b/src/svnrevision.h @@ -3,5 +3,5 @@ // This file was automatically generated by the // updaterevision tool. Do not edit by hand. -#define ZD_SVN_REVISION_STRING "4285" -#define ZD_SVN_REVISION_NUMBER 4285 +#define ZD_SVN_REVISION_STRING "4289" +#define ZD_SVN_REVISION_NUMBER 4289 diff --git a/src/v_font.cpp b/src/v_font.cpp index c7a815c7..fad3243e 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -295,7 +295,7 @@ static int stripaccent(int code) return 'D' + (code & 0x20); if (acode == 0xD1) // N with tilde return 'N' + (code & 0x20); - if (acode >= 0xD2 && acode <= 0xD6 || // O with accents + if ((acode >= 0xD2 && acode <= 0xD6) || // O with accents acode == 0xD8) // O with stroke return 'O' + (code & 0x20); if (acode >= 0xD9 && acode <= 0xDC) // U with accents @@ -645,6 +645,7 @@ int FFont::SimpleTranslation (BYTE *colorsused, BYTE *translation, BYTE *reverse qsort (reverse+1, j-1, 1, compare); *luminosity = new double[j]; + (*luminosity)[0] = 0.0; // [BL] Prevent uninitalized memory max = 0.0; min = 100000000.0; for (i = 1; i < j; i++)