From 08272a29adf70b0a8ebaee40d6c29d2d79e054e6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 16 Jun 2012 03:29:44 +0000 Subject: [PATCH] - Added textual descriptions of the zlib errors. SVN r3689 (trunk) --- src/farchive.cpp | 3 ++- src/files.cpp | 3 ++- src/g_game.cpp | 2 +- src/i_net.cpp | 4 ++-- src/m_misc.cpp | 30 ++++++++++++++++++++++++++++++ src/m_misc.h | 2 ++ 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/farchive.cpp b/src/farchive.cpp index 6b0fafd18..1b41faef7 100644 --- a/src/farchive.cpp +++ b/src/farchive.cpp @@ -54,6 +54,7 @@ #include "c_cvars.h" #include "c_dispatch.h" #include "d_player.h" +#include "m_misc.h" #include "dobject.h" // These are special tokens found in the data stream of an archive. @@ -408,7 +409,7 @@ void FCompressedFile::Explode () _heapchk(); M_Free (expand); _heapchk(); - I_Error ("Could not decompress cfile"); + I_Error ("Could not decompress buffer: %s", M_ZLibError(r)); } } else diff --git a/src/files.cpp b/src/files.cpp index 2dbe2c778..d205429e1 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -36,6 +36,7 @@ #include "files.h" #include "i_system.h" #include "templates.h" +#include "m_misc.h" //========================================================================== // @@ -223,7 +224,7 @@ FileReaderZ::FileReaderZ (FileReader &file, bool zip) if (err != Z_OK) { - I_Error ("FileReaderZ: inflateInit failed: %d\n", err); + I_Error ("FileReaderZ: inflateInit failed: %s\n", M_ZLibError(err)); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index 224ade775..3aa4d3059 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2513,7 +2513,7 @@ bool G_ProcessIFFDemo (char *mapname) int r = uncompress (uncompressed, &uncompSize, demo_p, uLong(zdembodyend - demo_p)); if (r != Z_OK) { - Printf ("Could not decompress demo!\n"); + Printf ("Could not decompress demo! %s\n", M_ZLibError(r)); delete[] uncompressed; return true; } diff --git a/src/i_net.cpp b/src/i_net.cpp index ae28bb779..5b0b35907 100644 --- a/src/i_net.cpp +++ b/src/i_net.cpp @@ -62,7 +62,7 @@ #include "templates.h" #include "c_console.h" #include "st_start.h" - +#include "m_misc.h" #include "doomstat.h" #include "i_net.h" @@ -303,7 +303,7 @@ void PacketGet (void) // Printf("recv %d/%lu\n", c, msgsize + 1); if (err != Z_OK) { - Printf("Net decompression failed (zlib error %d)\n", err); + Printf("Net decompression failed (zlib error %s)\n", M_ZLibError(err)); // Pretend no packet doomcom.remotenode = -1; return; diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 924f45e7c..08149ad96 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -780,3 +780,33 @@ CCMD (screenshot) else G_ScreenShot (argv[1]); } + +// +// M_ZlibError +// +FString M_ZLibError(int zerr) +{ + if (zerr >= 0) + { + return "OK"; + } + else if (zerr < -6) + { + FString out; + out.Format("%d", zerr); + return out; + } + else + { + static const char *errs[6] = + { + "Errno", + "Stream Error", + "Data Error", + "Memory Error", + "Buffer Error", + "Version Error" + }; + return errs[-zerr - 1]; + } +} diff --git a/src/m_misc.h b/src/m_misc.h index 23905d765..27006cf87 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -47,4 +47,6 @@ void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, siz // Prepends ~/.zdoom to path FString GetUserFile (const char *path); +FString M_ZLibError(int zerrnum); + #endif