From 83af1368e1ca9fa25c6b217365acd335469afc8a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 9 May 2001 18:48:55 +0000 Subject: [PATCH] remove pcx.c's dependence on cl_parse.h --- include/QF/pcx.h | 5 ++--- qw/source/gl_screen.c | 5 ++++- qw/source/pcx.c | 22 +++++++--------------- qw/source/screen.c | 14 +++++++++++--- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/QF/pcx.h b/include/QF/pcx.h index c5b6ec1a0..511f6d269 100644 --- a/include/QF/pcx.h +++ b/include/QF/pcx.h @@ -47,9 +47,8 @@ typedef struct char filler[58]; } pcx_t; -void WritePCXfile (char *filename, byte * data, int width, int height, - int rowbytes, byte * palette, qboolean upload, - qboolean flip); +pcx_t *EncodePCX (byte * data, int width, int height, + int rowbytes, byte * palette, qboolean flip, int *length); struct tex_s *LoadPCX (QFile *f, int convert); // tex is from Hunk_TempAlloc #endif // __pcx_h diff --git a/qw/source/gl_screen.c b/qw/source/gl_screen.c index bcba12542..57fb3677e 100644 --- a/qw/source/gl_screen.c +++ b/qw/source/gl_screen.c @@ -734,6 +734,8 @@ SCR_RSShot_f (void) int x, y; unsigned char *src, *dest; char pcxname[80]; + pcx_t *pcx; + int pcx_len; unsigned char *newbuf; int w, h; int dx, dy, dex, dey, nx; @@ -825,7 +827,8 @@ SCR_RSShot_f (void) st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, h - 21, w); - WritePCXfile (pcxname, newbuf, w, h, w, vid_basepal, true, true); + pcx = EncodePCX (newbuf, w, h, w, vid_basepal, true, &pcx_len); + CL_StartUpload ((void *)pcx, pcx_len); free (newbuf); diff --git a/qw/source/pcx.c b/qw/source/pcx.c index d553883aa..86e360901 100644 --- a/qw/source/pcx.c +++ b/qw/source/pcx.c @@ -45,10 +45,6 @@ #include "QF/vid.h" #include "QF/zone.h" -#include "cl_parse.h" -#include "host.h" - - tex_t * LoadPCX (QFile *f, int convert) { @@ -149,17 +145,17 @@ LoadPCX (QFile *f, int convert) } -void -WritePCXfile (char *filename, byte * data, int width, int height, - int rowbytes, byte * palette, qboolean upload, qboolean flip) +pcx_t * +EncodePCX (byte * data, int width, int height, + int rowbytes, byte * palette, qboolean flip, int *length) { - int i, j, length; + int i, j; pcx_t *pcx; byte *pack; if (!(pcx = Hunk_TempAlloc (width * height * 2 + 1000))) { Con_Printf ("WritePCXfile: not enough memory\n"); - return; + return 0; } pcx->manufacturer = 0x0a; // PCX id @@ -205,10 +201,6 @@ WritePCXfile (char *filename, byte * data, int width, int height, *pack++ = *palette++; // write output file - length = pack - (byte *) pcx; - - if (upload) - CL_StartUpload ((void *) pcx, length); - else - COM_WriteFile (filename, pcx, length); + *length = pack - (byte *) pcx; + return pcx; } diff --git a/qw/source/screen.c b/qw/source/screen.c index fb6917f29..78510cdb8 100644 --- a/qw/source/screen.c +++ b/qw/source/screen.c @@ -641,6 +641,8 @@ void SCR_ScreenShot_f (void) { char pcxname[MAX_OSPATH]; + pcx_t *pcx; + int pcx_len; // find a file name to save it to if (!COM_NextFilename (pcxname, "qf", ".pcx")) { @@ -652,8 +654,10 @@ SCR_ScreenShot_f (void) D_EnableBackBufferAccess (); // save the pcx file - WritePCXfile (pcxname, vid.buffer, vid.width, vid.height, vid.rowbytes, - vid_basepal, false, false); + pcx = EncodePCX (vid.buffer, vid.width, vid.height, vid.rowbytes, + vid_basepal, false, &pcx_len); + COM_WriteFile (pcxname, pcx, pcx_len); + // for adapters that can't stay mapped in for linear writes all the time D_DisableBackBufferAccess (); @@ -751,6 +755,8 @@ SCR_RSShot_f (void) int x, y; unsigned char *src, *dest; char pcxname[80]; + pcx_t *pcx; + int pcx_len; unsigned char *newbuf; int w, h; int dx, dy, dex, dey, nx; @@ -831,7 +837,9 @@ SCR_RSShot_f (void) st[sizeof (st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - strlen (st) * 8, 20, w); - WritePCXfile (pcxname, newbuf, w, h, w, vid_basepal, true, false); + pcx = EncodePCX (newbuf, w, h, w, vid_basepal, false, &pcx_len); + CL_StartUpload ((void *)pcx, pcx_len); + free (newbuf);