+static void W_SwapLumps(int numlumps, lumpinfo_t *lumps)
+{
+ int i;
+ for (i = 0;i < numlumps;i++)
+ {
+ lumps[i].filepos = LittleLong(lumps[i].filepos);
+ lumps[i].disksize = LittleLong(lumps[i].disksize);
+ lumps[i].size = LittleLong(lumps[i].size);
+ W_CleanupName(lumps[i].name, lumps[i].name);
+ }
+}
+
+void W_UnloadAll(void)
+{
+ unsigned int i;
+ mwad_t *w;
+ // free gfx.wad if it is loaded
+ if (wad.gfx_base)
+ Mem_Free(wad.gfx_base);
+ wad.gfx_base = NULL;
+ // close all hlwad files and free their lumps data
+ for (i = 0;i < Mem_ExpandableArray_IndexRange(&wad.hlwads);i++)
+ {
+ w = (mwad_t *) Mem_ExpandableArray_RecordAtIndex(&wad.hlwads, i);
+ if (!w)
+ continue;
+ if (w->file)
+ FS_Close(w->file);
+ w->file = NULL;
+ if (w->lumps)
+ Mem_Free(w->lumps);
+ w->lumps = NULL;
+ }
+ // free the hlwads array
+ Mem_ExpandableArray_FreeArray(&wad.hlwads);
+ // clear all state
+ memset(&wad, 0, sizeof(wad));
+}
+
+unsigned char *W_GetLumpName(const char *name)