]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - wad.c
... forgot to add the files, I'm too used to git now :P
[xonotic/darkplaces.git] / wad.c
diff --git a/wad.c b/wad.c
index 60cabff9b0b36ba49dc5d543a42a63730cc79b40..a07f87bb135560c919b9564c038cc8b337b85eaf 100644 (file)
--- a/wad.c
+++ b/wad.c
@@ -95,7 +95,7 @@ void W_UnloadAll(void)
        // close all hlwad files and free their lumps data
        for (i = 0;i < Mem_ExpandableArray_IndexRange(&wad.hlwads);i++)
        {
-               w = Mem_ExpandableArray_RecordAtIndex(&wad.hlwads, i);
+               w = (mwad_t *) Mem_ExpandableArray_RecordAtIndex(&wad.hlwads, i);
                if (!w)
                        continue;
                if (w->file)
@@ -148,11 +148,6 @@ 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))
                        return (wad.gfx_base + lump->filepos);
-
-       if (wad.gfx_base)
-               Con_DPrintf("W_GetLumpByName(\"%s\"): couldn't find file in gfx.wad\n", name);
-       else
-               Con_DPrintf("W_GetLumpByName(\"%s\"): couldn't load gfx.wad\n", name);
        return NULL;
 }
 
@@ -169,7 +164,7 @@ void W_LoadTextureWadFile (char *filename, int complain)
        int                             numlumps;
        mwad_t                  *w;
 
-       file = FS_Open (filename, "rb", false, false);
+       file = FS_OpenVirtualFile(filename, false);
        if (!file)
        {
                if (complain)
@@ -192,10 +187,10 @@ void W_LoadTextureWadFile (char *filename, int complain)
 
        if (!wad.hlwads.mempool)
                Mem_ExpandableArray_NewArray(&wad.hlwads, cls.permanentmempool, sizeof(mwad_t), 16);
-       w = Mem_ExpandableArray_AllocRecord(&wad.hlwads);
+       w = (mwad_t *) Mem_ExpandableArray_AllocRecord(&wad.hlwads);
        w->file = file;
        w->numlumps = numlumps;
-       w->lumps = Mem_Alloc(cls.permanentmempool, w->numlumps * sizeof(lumpinfo_t));
+       w->lumps = (lumpinfo_t *) Mem_Alloc(cls.permanentmempool, w->numlumps * sizeof(lumpinfo_t));
 
        if (!w->lumps)
        {
@@ -222,7 +217,7 @@ void W_LoadTextureWadFile (char *filename, int complain)
        // leaves the file open
 }
 
-unsigned char *W_ConvertWAD3Texture(miptex_t *tex)
+unsigned char *W_ConvertWAD3TextureBGRA(miptex_t *tex)
 {
        unsigned char *in, *data, *out, *pal;
        int d, p;
@@ -243,9 +238,9 @@ unsigned char *W_ConvertWAD3Texture(miptex_t *tex)
                else
                {
                        p *= 3;
-                       out[0] = pal[p];
+                       out[2] = pal[p];
                        out[1] = pal[p+1];
-                       out[2] = pal[p+2];
+                       out[0] = pal[p+2];
                        out[3] = 255;
                }
                out += 4;
@@ -253,19 +248,21 @@ unsigned char *W_ConvertWAD3Texture(miptex_t *tex)
        return data;
 }
 
-unsigned char *W_GetTexture(char *name)
+unsigned char *W_GetTextureBGRA(char *name)
 {
        unsigned int i, j, k;
        miptex_t *tex;
        unsigned char *data;
        mwad_t *w;
        char texname[17];
+       size_t range;
 
        texname[16] = 0;
        W_CleanupName(name, texname);
        if (!wad.hlwads.mempool)
                Mem_ExpandableArray_NewArray(&wad.hlwads, cls.permanentmempool, sizeof(mwad_t), 16);
-       for (k = 0;k < Mem_ExpandableArray_IndexRange(&wad.hlwads);k++)
+       range = Mem_ExpandableArray_IndexRange(&wad.hlwads);
+       for (k = 0;k < range;k++)
        {
                w = (mwad_t *)Mem_ExpandableArray_RecordAtIndex(&wad.hlwads, k);
                if (!w)
@@ -287,7 +284,7 @@ unsigned char *W_GetTexture(char *name)
                                tex->height = LittleLong(tex->height);
                                for (j = 0;j < MIPLEVELS;j++)
                                        tex->offsets[j] = LittleLong(tex->offsets[j]);
-                               data = W_ConvertWAD3Texture(tex);
+                               data = W_ConvertWAD3TextureBGRA(tex);
                                Mem_Free(tex);
                                return data;
                        }