X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=wad.c;h=55da49963bd731d96f612fa426a0173e5c7f2cbf;hb=220bfb551bac9181cd121366a3c858ef1499fcdf;hp=4e714b0b2712cfad3b6d9433abf5e8db5a58f929;hpb=ae946773a0fdc85c9fcd22615744a9b0e1b1b0c0;p=xonotic%2Fdarkplaces.git diff --git a/wad.c b/wad.c index 4e714b0b..55da4996 100644 --- a/wad.c +++ b/wad.c @@ -111,7 +111,7 @@ void W_UnloadAll(void) memset(&wad, 0, sizeof(wad)); } -unsigned char *W_GetLumpName(const char *name) +unsigned char *W_GetLumpName(const char *name, fs_offset_t *returnfilesize) { int i; fs_offset_t filesize; @@ -146,8 +146,14 @@ unsigned char *W_GetLumpName(const char *name) } for (lump = wad.gfx.lumps, i = 0;i < wad.gfx.numlumps;i++, lump++) + { if (!strcmp(clean, lump->name)) + { + if (returnfilesize) + *returnfilesize = lump->size; return (wad.gfx_base + lump->filepos); + } + } return NULL; } @@ -168,22 +174,22 @@ void W_LoadTextureWadFile (char *filename, int complain) if (!file) { if (complain) - Con_Printf("W_LoadTextureWadFile: couldn't find %s\n", filename); + Con_Printf(CON_ERROR "W_LoadTextureWadFile: couldn't find %s\n", filename); return; } if (FS_Read(file, &header, sizeof(wadinfo_t)) != sizeof(wadinfo_t)) - {Con_Print("W_LoadTextureWadFile: unable to read wad header\n");FS_Close(file);file = NULL;return;} + {Con_Print(CON_ERROR "W_LoadTextureWadFile: unable to read wad header\n");FS_Close(file);file = NULL;return;} if(memcmp(header.identification, "WAD3", 4)) - {Con_Printf("W_LoadTextureWadFile: Wad file %s doesn't have WAD3 id\n",filename);FS_Close(file);file = NULL;return;} + {Con_Printf(CON_ERROR "W_LoadTextureWadFile: Wad file %s doesn't have WAD3 id\n",filename);FS_Close(file);file = NULL;return;} numlumps = LittleLong(header.numlumps); if (numlumps < 1 || numlumps > 65536) - {Con_Printf("W_LoadTextureWadFile: invalid number of lumps (%i)\n", numlumps);FS_Close(file);file = NULL;return;} + {Con_Printf(CON_ERROR "W_LoadTextureWadFile: invalid number of lumps (%i)\n", numlumps);FS_Close(file);file = NULL;return;} infotableofs = LittleLong(header.infotableofs); if (FS_Seek (file, infotableofs, SEEK_SET)) - {Con_Print("W_LoadTextureWadFile: unable to seek to lump table\n");FS_Close(file);file = NULL;return;} + {Con_Print(CON_ERROR "W_LoadTextureWadFile: unable to seek to lump table\n");FS_Close(file);file = NULL;return;} if (!wad.hlwads.mempool) Mem_ExpandableArray_NewArray(&wad.hlwads, cls.permanentmempool, sizeof(mwad_t), 16); @@ -194,7 +200,7 @@ void W_LoadTextureWadFile (char *filename, int complain) if (!w->lumps) { - Con_Print("W_LoadTextureWadFile: unable to allocate temporary memory for lump table\n"); + Con_Print(CON_ERROR "W_LoadTextureWadFile: unable to allocate temporary memory for lump table\n"); FS_Close(w->file); w->file = NULL; w->numlumps = 0; @@ -203,7 +209,7 @@ void W_LoadTextureWadFile (char *filename, int complain) if (FS_Read(file, w->lumps, sizeof(lumpinfo_t) * w->numlumps) != (fs_offset_t)sizeof(lumpinfo_t) * numlumps) { - Con_Print("W_LoadTextureWadFile: unable to read lump table\n"); + Con_Print(CON_ERROR "W_LoadTextureWadFile: unable to read lump table\n"); FS_Close(w->file); w->file = NULL; w->numlumps = 0;