From cc3c823ce3baf63d6d8f216c3bf4df88496eb231 Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Sun, 4 Mar 2001 01:04:38 +0000 Subject: [PATCH] rewrite of map texture loading (mainly to do with HL textures and wads) and all FALSE and TRUE changed to false and true git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@177 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 8 ++--- conproc.c | 40 ++++++++++----------- gl_rmain.c | 8 ++--- gl_rmisc.c | 2 +- gl_warp.c | 4 +-- image.c | 7 +--- in_win.c | 8 ++--- model_brush.c | 80 ++++++++++++++++++++++++++++++------------ net_wins.c | 4 +-- pr_cmds.c | 4 +-- r_part.c | 2 +- sv_main.c | 2 +- sys_win.c | 6 ++-- vid_wgl.c | 20 +++++------ wad.c | 96 ++++++++++++++++++++++++++++++++++++++------------- wad.h | 3 +- 16 files changed, 186 insertions(+), 108 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index c086496f..0d776abf 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -226,7 +226,7 @@ extern cvar_t r_farclip; void CL_ParseEntityLump(char *entdata) { char *data; - char key[128], value[1024]; + char key[128], value[4096]; char wadname[128]; int i, j, k; FOG_clear(); // LordHavoc: no fog until set @@ -282,12 +282,12 @@ void CL_ParseEntityLump(char *entdata) else if (!strcmp("wad", key)) // for HalfLife maps { j = 0; - for (i = 0;i < 128;i++) + for (i = 0;i < 4096;i++) if (value[i] != ';' && value[i] != '\\' && value[i] != '/' && value[i] != ':') break; if (value[i]) { - for (;i < 128;i++) + for (;i < 4096;i++) { // ignore path - the \\ check is for HalfLife... stupid windoze 'programmers'... if (value[i] == '\\' || value[i] == '/' || value[i] == ':') @@ -298,7 +298,7 @@ void CL_ParseEntityLump(char *entdata) value[i] = 0; strcpy(wadname, "textures/"); strcat(wadname, &value[j]); - W_LoadTextureWadFile (wadname, FALSE); + W_LoadTextureWadFile (wadname, false); j = i+1; if (!k) break; diff --git a/conproc.c b/conproc.c index 38e031bd..560be1f1 100644 --- a/conproc.c +++ b/conproc.c @@ -54,7 +54,7 @@ void InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild) heventChildSend = heventChild; // so we'll know when to go away. - heventDone = CreateEvent (NULL, FALSE, FALSE, NULL); + heventDone = CreateEvent (NULL, false, false, NULL); if (!heventDone) { @@ -102,7 +102,7 @@ DWORD RequestProc (DWORD dwNichts) while (1) { - dwRet = WaitForMultipleObjects (2, heventWait, FALSE, INFINITE); + dwRet = WaitForMultipleObjects (2, heventWait, false, INFINITE); // heventDone fired, so we're exiting. if (dwRet == WAIT_OBJECT_0 + 1) @@ -231,7 +231,7 @@ BOOL WriteText (LPCTSTR szText) upper = toupper(*sz); rec.EventType = KEY_EVENT; - rec.Event.KeyEvent.bKeyDown = TRUE; + rec.Event.KeyEvent.bKeyDown = true; rec.Event.KeyEvent.wRepeatCount = 1; rec.Event.KeyEvent.wVirtualKeyCode = upper; rec.Event.KeyEvent.wVirtualScanCode = CharToCode (*sz); @@ -245,7 +245,7 @@ BOOL WriteText (LPCTSTR szText) 1, &dwWritten); - rec.Event.KeyEvent.bKeyDown = FALSE; + rec.Event.KeyEvent.bKeyDown = false; WriteConsoleInput( hStdin, @@ -256,7 +256,7 @@ BOOL WriteText (LPCTSTR szText) sz++; } - return TRUE; + return true; } @@ -299,7 +299,7 @@ BOOL SetConsoleCXCY(HANDLE hStdout, int cx, int cy) cx = coordMax.X; if (!GetConsoleScreenBufferInfo(hStdout, &info)) - return FALSE; + return false; // height info.srWindow.Left = 0; @@ -309,27 +309,27 @@ BOOL SetConsoleCXCY(HANDLE hStdout, int cx, int cy) if (cy < info.dwSize.Y) { - if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow)) - return FALSE; + if (!SetConsoleWindowInfo(hStdout, true, &info.srWindow)) + return false; info.dwSize.Y = cy; if (!SetConsoleScreenBufferSize(hStdout, info.dwSize)) - return FALSE; + return false; } else if (cy > info.dwSize.Y) { info.dwSize.Y = cy; if (!SetConsoleScreenBufferSize(hStdout, info.dwSize)) - return FALSE; + return false; - if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow)) - return FALSE; + if (!SetConsoleWindowInfo(hStdout, true, &info.srWindow)) + return false; } if (!GetConsoleScreenBufferInfo(hStdout, &info)) - return FALSE; + return false; // width info.srWindow.Left = 0; @@ -339,25 +339,25 @@ BOOL SetConsoleCXCY(HANDLE hStdout, int cx, int cy) if (cx < info.dwSize.X) { - if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow)) - return FALSE; + if (!SetConsoleWindowInfo(hStdout, true, &info.srWindow)) + return false; info.dwSize.X = cx; if (!SetConsoleScreenBufferSize(hStdout, info.dwSize)) - return FALSE; + return false; } else if (cx > info.dwSize.X) { info.dwSize.X = cx; if (!SetConsoleScreenBufferSize(hStdout, info.dwSize)) - return FALSE; + return false; - if (!SetConsoleWindowInfo(hStdout, TRUE, &info.srWindow)) - return FALSE; + if (!SetConsoleWindowInfo(hStdout, true, &info.srWindow)) + return false; } - return TRUE; + return true; } diff --git a/gl_rmain.c b/gl_rmain.c index 24a08cdb..11a1c481 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -80,9 +80,9 @@ cvar_t r_novis = {"r_novis","0"}; cvar_t r_waterripple = {"r_waterripple","0"}; cvar_t r_fullbrights = {"r_fullbrights", "1"}; -cvar_t contrast = {"contrast", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction -cvar_t brightness = {"brightness", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction -cvar_t gl_lightmode = {"gl_lightmode", "1", TRUE}; // LordHavoc: overbright lighting +cvar_t contrast = {"contrast", "1.0", true}; // LordHavoc: a method of operating system independent color correction +cvar_t brightness = {"brightness", "1.0", true}; // LordHavoc: a method of operating system independent color correction +cvar_t gl_lightmode = {"gl_lightmode", "1", true}; // LordHavoc: overbright lighting //cvar_t r_dynamicbothsides = {"r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right... cvar_t r_farclip = {"r_farclip", "6144"}; @@ -413,7 +413,7 @@ void R_DrawViewModel (void) // hack the depth range to prevent view model from poking into walls glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); - R_DrawAliasModel (currententity, FALSE, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->angles, currententity->effects, currententity->model->flags, currententity->colormap); + R_DrawAliasModel (currententity, false, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->angles, currententity->effects, currententity->model->flags, currententity->colormap); glDepthRange (gldepthmin, gldepthmax); } diff --git a/gl_rmisc.c b/gl_rmisc.c index 2a07083b..c5c367d6 100644 --- a/gl_rmisc.c +++ b/gl_rmisc.c @@ -41,7 +41,7 @@ void R_InitTextures (void) r_notexture_mip->offsets[1] = r_notexture_mip->offsets[0] + 16*16; r_notexture_mip->offsets[2] = r_notexture_mip->offsets[1] + 8*8; r_notexture_mip->offsets[3] = r_notexture_mip->offsets[2] + 4*4; - r_notexture_mip->transparent = FALSE; + r_notexture_mip->transparent = false; for (m=0 ; m<4 ; m++) { diff --git a/gl_warp.c b/gl_warp.c index 8f35afba..5b37779c 100644 --- a/gl_warp.c +++ b/gl_warp.c @@ -202,10 +202,10 @@ void R_LoadSkyBox (void) for (i=0 ; i<6 ; i++) { sprintf (name, "env/%s%s", skyname, suf[i]); - if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0))) + if (!(image_rgba = loadimagepixels(name, false, 0, 0))) { sprintf (name, "gfx/env/%s%s", skyname, suf[i]); - if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0))) + if (!(image_rgba = loadimagepixels(name, false, 0, 0))) { Con_Printf ("Couldn't load %s\n", name); continue; diff --git a/image.c b/image.c index d12ed712..622ff526 100644 --- a/image.c +++ b/image.c @@ -428,7 +428,7 @@ byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int ma { FILE *f; char basename[256], name[256]; - byte *image_rgba, *c; + byte *c; Image_StripImageExtension(filename, basename); // strip .tga, .pcx and .lmp extensions to allow replacement by other types // replace *'s with #, so commandline utils don't get confused when dealing with the external files for (c = basename;*c;c++) @@ -454,11 +454,6 @@ byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int ma COM_FOpenFile (name, &f, true); if (f) return LoadLMP (f, matchwidth, matchheight); - if ((image_rgba = W_GetTexture(basename, matchwidth, matchheight))) - return image_rgba; - COM_StripExtension(filename, basename); // do it again with a * this time - if ((image_rgba = W_GetTexture(basename, matchwidth, matchheight))) - return image_rgba; if (complain) Con_Printf ("Couldn't load %s.tga or .pcx\n", filename); return NULL; diff --git a/in_win.c b/in_win.c index 139766d3..9b9f4fcb 100644 --- a/in_win.c +++ b/in_win.c @@ -191,7 +191,7 @@ void IN_ShowMouse (void) if (!mouseshowtoggle) { - ShowCursor (TRUE); + ShowCursor (true); mouseshowtoggle = 1; } } @@ -207,7 +207,7 @@ void IN_HideMouse (void) if (mouseshowtoggle) { - ShowCursor (FALSE); + ShowCursor (false); mouseshowtoggle = 0; } } @@ -319,8 +319,8 @@ void IN_RestoreOriginalMouseState (void) // try to redraw the cursor so it gets reinitialized, because sometimes it // has garbage after the mode switch - ShowCursor (TRUE); - ShowCursor (FALSE); + ShowCursor (true); + ShowCursor (false); } diff --git a/model_brush.c b/model_brush.c index 7dc551ef..a9860d91 100644 --- a/model_brush.c +++ b/model_brush.c @@ -160,27 +160,31 @@ void Mod_LoadTextures (lump_t *l) tx->height = mt->height; for (j=0 ; joffsets[j] = 0; - freeimage = TRUE; + freeimage = true; + transparent = true; + fullbrights = false; bytesperpixel = 4; - fullbrights = FALSE; - transparent = TRUE; - data = loadimagepixels(tx->name, FALSE, 0, 0); //tx->width, tx->height); + data = loadimagepixels(tx->name, false, 0, 0); //tx->width, tx->height); if (!data) // no external texture found { - freeimage = FALSE; - transparent = FALSE; - bytesperpixel = 1; - if (mt->offsets[0]) // texture included + if (hlbsp) { - data = (byte *)((int) mt + mt->offsets[0]); - if (hlbsp) + if (mt->offsets[0]) // texture included { + freeimage = true; + transparent = true; + bytesperpixel = 4; + data = W_ConvertWAD3Texture(mt); + tx->width = image_width; + tx->height = image_height; + /* byte *in, *out, *pal; // int palsize; int d, p; bytesperpixel = 4; - freeimage = TRUE; - in = data; + freeimage = true; + transparent = false; + in = (byte *)((int) mt + mt->offsets[0]); data = out = qmalloc(mt->width * mt->height * 4); pal = in + (((mt->width * mt->height) * 85) >> 6); // palsize = pal[1] * 0x100 + pal[0]; @@ -193,7 +197,7 @@ void Mod_LoadTextures (lump_t *l) if (mt->name[0] == '{' && p == 255) { out[0] = out[1] = out[2] = out[3] = 0; - transparent = TRUE; + transparent = true; } else { @@ -205,31 +209,61 @@ void Mod_LoadTextures (lump_t *l) } out += 4; } + */ } - else + if (!data) + { + freeimage = true; + transparent = true; + bytesperpixel = 4; + data = W_GetTexture(mt->name); + tx->width = image_width; + tx->height = image_height; + } + if (!data) + { + freeimage = false; + transparent = false; + bytesperpixel = 1; + data = (byte *)((int) r_notexture_mip + r_notexture_mip->offsets[0]); + tx->width = tx->height = 16; + } + } + else + { + if (mt->offsets[0]) // texture included { + freeimage = false; + transparent = false; + bytesperpixel = 1; + data = (byte *)((int) mt + mt->offsets[0]); + tx->width = mt->width; + tx->height = mt->height; if (r_fullbrights.value && tx->name[0] != '*') { for (j = 0;j < tx->width*tx->height;j++) { if (data[j] >= 224) // fullbright { - fullbrights = TRUE; + fullbrights = true; break; } } } } - } - else // no texture, and no external replacement texture was found - { - tx->width = tx->height = 16; - data = (byte *)((int) r_notexture_mip + r_notexture_mip->offsets[0]); + else // no texture, and no external replacement texture was found + { + freeimage = false; + transparent = false; + bytesperpixel = 1; + data = (byte *)((int) r_notexture_mip + r_notexture_mip->offsets[0]); + tx->width = tx->height = 16; + } } } if (!hlbsp && !strncmp(tx->name,"sky",3) && tx->width == 256 && tx->height == 128) // LordHavoc: HL sky textures are entirely unrelated { - tx->transparent = FALSE; + tx->transparent = false; R_InitSky (data, bytesperpixel); } else @@ -597,7 +631,7 @@ void Mod_LoadTexinfo (lump_t *l) { out->texture = r_notexture_mip; // checkerboard texture out->flags = 0; - out->texture->transparent = FALSE; + out->texture->transparent = false; } else { @@ -608,7 +642,7 @@ void Mod_LoadTexinfo (lump_t *l) { out->texture = r_notexture_mip; // texture not found out->flags = 0; - out->texture->transparent = FALSE; + out->texture->transparent = false; } } } diff --git a/net_wins.c b/net_wins.c index 87a75eed..e01a6191 100644 --- a/net_wins.c +++ b/net_wins.c @@ -71,7 +71,7 @@ BOOL PASCAL FAR BlockingHook(void) if ((Sys_FloatTime() - blocktime) > 2.0) { WSACancelBlockingCall(); - return FALSE; + return false; } /* get the next message, if any */ @@ -83,7 +83,7 @@ BOOL PASCAL FAR BlockingHook(void) DispatchMessage(&msg); } - /* TRUE if we got a message */ + /* true if we got a message */ return ret; } diff --git a/pr_cmds.c b/pr_cmds.c index ac18f05b..e9c3effd 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -95,11 +95,11 @@ qboolean checkextension(char *name) if (!*e) break; if (!strncasecmp(e, name, len)) - return TRUE; + return true; while (*e && *e != ' ') e++; } - return FALSE; + return false; } /* diff --git a/r_part.c b/r_part.c index 7c4abfa9..59d875ee 100644 --- a/r_part.c +++ b/r_part.c @@ -76,7 +76,7 @@ particle_t **freeparticles; // list used only in compacting particles array cvar_t r_particles = {"r_particles", "1"}; cvar_t r_drawparticles = {"r_drawparticles", "1"}; -cvar_t r_dynamicparticles = {"r_dynamicparticles", "1", TRUE}; +cvar_t r_dynamicparticles = {"r_dynamicparticles", "1", true}; byte shadebubble(float dx, float dy, vec3_t light) { diff --git a/sv_main.c b/sv_main.c index 0d51ed41..9a3c37ed 100644 --- a/sv_main.c +++ b/sv_main.c @@ -545,7 +545,7 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) // send an update bits = 0; - dodelta = FALSE; + dodelta = false; if ((int)ent->v.effects & EF_DELTA) dodelta = sv.time < client->nextfullupdate[e]; // every half second a full update is forced diff --git a/sys_win.c b/sys_win.c index bf7d54a1..8c8a595c 100644 --- a/sys_win.c +++ b/sys_win.c @@ -612,7 +612,7 @@ WinMain void SleepUntilInput (int time) { - MsgWaitForMultipleObjects(1, &tevent, FALSE, time, QS_ALLINPUT); + MsgWaitForMultipleObjects(1, &tevent, false, time, QS_ALLINPUT); } @@ -723,7 +723,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin // Sys_PageIn (parms.membase, parms.memsize); - tevent = CreateEvent(NULL, FALSE, FALSE, NULL); + tevent = CreateEvent(NULL, false, false, NULL); if (!tevent) Sys_Error ("Couldn't create event"); @@ -821,6 +821,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin } /* return success of application */ - return TRUE; + return true; } diff --git a/vid_wgl.c b/vid_wgl.c index c30a890d..3ef91f20 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -168,7 +168,7 @@ qboolean VID_SetWindowedMode (int modenum) ExWindowStyle = 0; rect = WindowRect; - AdjustWindowRectEx(&rect, WindowStyle, FALSE, 0); + AdjustWindowRectEx(&rect, WindowStyle, false, 0); width = rect.right - rect.left; height = rect.bottom - rect.top; @@ -194,8 +194,8 @@ qboolean VID_SetWindowedMode (int modenum) vid.width = vid.conwidth; vid.height = vid.conheight; - SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon); - SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon); + SendMessage (mainwindow, WM_SETICON, (WPARAM)true, (LPARAM)hIcon); + SendMessage (mainwindow, WM_SETICON, (WPARAM)false, (LPARAM)hIcon); return true; } @@ -234,7 +234,7 @@ qboolean VID_SetFullDIBMode (int modenum) ExWindowStyle = 0; rect = WindowRect; - AdjustWindowRectEx(&rect, WindowStyle, FALSE, 0); + AdjustWindowRectEx(&rect, WindowStyle, false, 0); width = rect.right - rect.left; height = rect.bottom - rect.top; @@ -259,8 +259,8 @@ qboolean VID_SetFullDIBMode (int modenum) window_x = 0; window_y = 0; - SendMessage (mainwindow, WM_SETICON, (WPARAM)TRUE, (LPARAM)hIcon); - SendMessage (mainwindow, WM_SETICON, (WPARAM)FALSE, (LPARAM)hIcon); + SendMessage (mainwindow, WM_SETICON, (WPARAM)true, (LPARAM)hIcon); + SendMessage (mainwindow, WM_SETICON, (WPARAM)false, (LPARAM)hIcon); return true; } @@ -566,16 +566,16 @@ BOOL bSetupPixelFormat(HDC hDC) if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ) { MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK); - return FALSE; + return false; } - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE) + if (SetPixelFormat(hDC, pixelformat, &pfd) == false) { MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK); - return FALSE; + return false; } - return TRUE; + return true; } diff --git a/wad.c b/wad.c index 00d7e7ef..177c7a70 100644 --- a/wad.c +++ b/wad.c @@ -211,7 +211,7 @@ void W_LoadTextureWadFile (char *filename, int complain) if (fread(lumps, sizeof(lumpinfo_t), numlumps, file) != numlumps) {Con_Printf ("W_LoadTextureWadFile: unable to read lump table");return;} - + for (i=0, lump_p = lumps ; iname, lump_p->name); @@ -236,7 +236,7 @@ void W_LoadTextureWadFile (char *filename, int complain) // leaves the file open } - +/* byte hlpalette[768] = { 0x00,0x00,0x00,0x0F,0x0F,0x0F,0x1F,0x1F,0x1F,0x2F,0x2F,0x2F,0x3F,0x3F,0x3F,0x4B, @@ -288,31 +288,78 @@ byte hlpalette[768] = 0xE7,0xFF,0xD7,0xFF,0xFF,0x67,0x00,0x00,0x8B,0x00,0x00,0xB3,0x00,0x00,0xD7,0x00, 0x00,0xFF,0x00,0x00,0xFF,0xF3,0x93,0xFF,0xF7,0xC7,0xFF,0xFF,0xFF,0x9F,0x5B,0x53, }; +*/ -byte *W_GetTexture(char *name, int matchwidth, int matchheight) +byte *W_ConvertWAD3Texture(miptex_t *tex) { - int i, c, datasize; - short colorcount; - FILE *file; - struct + byte *in, *data, *out, *pal; +// int palsize; + int d, p; + in = (byte *)((int) tex + tex->offsets[0]); + data = out = qmalloc(tex->width * tex->height * 4); + if (!data) + return NULL; + image_width = tex->width; + image_height = tex->height; + pal = in + (((image_width * image_height) * 85) >> 6); +// palsize = pal[1] * 0x100 + pal[0]; +// if (palsize >= 256) +// palsize = 256; + pal += 2; + for (d = 0;d < image_width * image_height;d++) { - char name[16]; - int width; - int height; - int ofs[4]; - } t; - byte pal[256][3], *indata, *outdata, *data; + p = *in++; + if (tex->name[0] == '{' && p == 255) + out[0] = out[1] = out[2] = out[3] = 0; + else + { + p *= 3; + out[0] = pal[p]; + out[1] = pal[p+1]; + out[2] = pal[p+2]; + out[3] = 255; + } + out += 4; + } + return data; +} + +byte *W_GetTexture(char *name) +{ +// int i, c, datasize; +// short colorcount; +// byte pal[256][3], *indata, *outdata, *data; + char texname[17]; + int i, j; + FILE *file; + miptex_t *tex; + byte *data; + texname[16] = 0; + W_CleanupName (name, texname); for (i = 0;i < TEXWAD_MAXIMAGES;i++) { if (texwadlump[i].name[0]) { - if (!strcmp(name, texwadlump[i].name)) // found it + if (!strcmp(texname, texwadlump[i].name)) // found it { file = texwadlump[i].file; if (fseek(file, texwadlump[i].position, SEEK_SET)) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} - if (fread(&t, sizeof(t), 1, file) != 1) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} + + tex = qmalloc(texwadlump[i].size); + if (!tex) + return NULL; + if (fread(tex, 1, texwadlump[i].size, file) < texwadlump[i].size) + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} + + tex->width = LittleLong(tex->width); + tex->height = LittleLong(tex->height); + for (j = 0;j < MIPLEVELS;j++) + tex->offsets[j] = LittleLong(tex->offsets[j]); + data = W_ConvertWAD3Texture(tex); + qfree(tex); + return data; + /* image_width = LittleLong(t.width); image_height = LittleLong(t.height); if (matchwidth && image_width != matchwidth) @@ -320,23 +367,23 @@ byte *W_GetTexture(char *name, int matchwidth, int matchheight) if (matchheight && image_height != matchheight) continue; if (image_width & 15 || image_height & 15) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} // allocate space for expanded image, // and load incoming image into upper area (overwritten as it expands) if (!(data = outdata = qmalloc(image_width*image_height*4))) - {Con_Printf("W_GetTexture: out of memory");return FALSE;} + {Con_Printf("W_GetTexture: out of memory");return NULL;} indata = outdata + image_width*image_height*3; datasize = image_width*image_height*85/64; // read the image data if (fseek(file, texwadlump[i].position + sizeof(t), SEEK_SET)) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} if (fread(indata, 1, image_width*image_height, file) != image_width*image_height) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} // read the number of colors used (always 256) if (fseek(file, texwadlump[i].position + sizeof(t) + datasize, SEEK_SET)) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} if (fread(&colorcount, 2, 1, file) != 1) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} if (texwadlump[i].size > (datasize + sizeof(t))) { colorcount = LittleShort(colorcount); @@ -346,7 +393,7 @@ byte *W_GetTexture(char *name, int matchwidth, int matchheight) // read the palette // fseek(file, texwadlump[i].position + sizeof(t) + datasize + 2, SEEK_SET); if (fread(&pal, 3, colorcount, file) != colorcount) - {Con_Printf("W_GetTexture: corrupt WAD3 file");return FALSE;} + {Con_Printf("W_GetTexture: corrupt WAD3 file");return NULL;} } else memcpy(&pal, hlpalette, 768); @@ -366,6 +413,7 @@ byte *W_GetTexture(char *name, int matchwidth, int matchheight) outdata += 4; } return data; + */ } } else diff --git a/wad.h b/wad.h index 001e293f..9c16b566 100644 --- a/wad.h +++ b/wad.h @@ -77,4 +77,5 @@ void SwapPic (qpic_t *pic); // LordHavoc: added alternate texture WAD2/WAD3 system for easier loading of HalfLife texture wads extern int image_width, image_height; void W_LoadTextureWadFile (char *filename, int complain); -byte *W_GetTexture (char *name, int matchwidth, int matchheight); // returns malloc'd image data, width and height are in image_width and image_height (yeah yeah so I'm lazy...) +byte *W_GetTexture (char *name); // returns malloc'd image data, width and height are in image_width and image_height +byte *W_ConvertWAD3Texture(miptex_t *tex); // returns malloc'd image data, width and height are in image_width and image_height -- 2.39.2