- Added textual descriptions of the zlib errors.

SVN r3689 (trunk)
This commit is contained in:
Randy Heit 2012-06-16 03:29:44 +00:00
parent c197d0687c
commit 08272a29ad
6 changed files with 39 additions and 5 deletions

View file

@ -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

View file

@ -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));
}
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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];
}
}

View file

@ -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