Skip to content

Commit

Permalink
Virtual wad, pk3 files
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 3, 2003
1 parent 2d4fd34 commit d2aea7a
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 133 deletions.
2 changes: 1 addition & 1 deletion doomsday/Include/dd_main.h
Expand Up @@ -23,7 +23,7 @@ extern directory_t ddRuntimeDir, ddBinDir;

void DD_Main();
void DD_GameUpdate(int flags);
void DD_AddStartupWAD(char *file);
void DD_AddStartupWAD(const char *file);
void DD_AddIWAD(const char *path);
void DD_SetConfigFile(char *filename);
void DD_SetDefsFile(char *filename);
Expand Down
15 changes: 7 additions & 8 deletions doomsday/Include/dd_wad.h
@@ -1,6 +1,8 @@
#ifndef __JHEXEN_WAD_H__
#define __JHEXEN_WAD_H__

#include "sys_file.h"

#define RECORD_FILENAMELEN 256

// File record flags.
Expand All @@ -19,14 +21,15 @@ typedef struct
char filename[RECORD_FILENAMELEN]; // Full filename (every '\' -> '/').
int numlumps; // Number of lumps.
int flags;
int handle; // File handle.
DFILE *handle; // File handle.
char iwad;
} filerecord_t;

typedef struct
{
char name[9]; // End in \0.
int handle, position, size;
DFILE *handle;
int position, size;
int sent;
char group; // Lump grouping tag (LGT_*).
} lumpinfo_t;
Expand All @@ -35,11 +38,7 @@ extern lumpinfo_t *lumpinfo;
extern int numlumps;

void W_InitMultipleFiles(char **filenames);
void W_OpenAuxiliary(char *filename);
void W_CloseAuxiliaryFile(void);
void W_CloseAuxiliary(void);
void W_UsePrimary(void);
void W_UseAuxiliary(void);
void W_EndStartup(void);
int W_CheckNumForName(char *name);
int W_GetNumForName(char *name);
int W_LumpLength(int lump);
Expand All @@ -48,7 +47,7 @@ void W_ReadLump(int lump, void *dest);
void W_ReadLumpSection(int lump, void *dest, int startoffset, int length);
void *W_CacheLumpNum(int lump, int tag);
void *W_CacheLumpName(char *name, int tag);
boolean W_AddFile(char *filename);
boolean W_AddFile(const char *filename, boolean allowDuplicate);
boolean W_RemoveFile(char *filename);
void W_Reset();
void W_ChangeCacheTag(int lump, int tag);
Expand Down
4 changes: 3 additions & 1 deletion doomsday/Include/dd_zip.h
Expand Up @@ -4,12 +4,14 @@
#ifndef __DOOMSDAY_ZIP_PACKAGE_H__
#define __DOOMSDAY_ZIP_PACKAGE_H__

#include "sys_file.h"

typedef int zipindex_t;

void Zip_Init(void);
void Zip_Shutdown(void);

boolean Zip_Open(const char *fileName);
boolean Zip_Open(const char *fileName, DFILE *prevOpened);
zipindex_t Zip_Find(int (*finder)(const char*, void*), void *parm);
uint Zip_GetSize(zipindex_t index);
uint Zip_Read(zipindex_t index, void *buffer);
Expand Down
6 changes: 3 additions & 3 deletions doomsday/Include/doomsday.h
Expand Up @@ -20,7 +20,7 @@ extern "C" {
// Base.
void * DD_GetDGLProcAddress(const char *name);
void DD_AddIWAD(const char *path);
void DD_AddStartupWAD(char *file);
void DD_AddStartupWAD(const char *file);
void DD_SetConfigFile(char *filename);
void DD_SetDefsFile(char *filename);
int _DECALL DD_GetInteger(int ddvalue);
Expand Down Expand Up @@ -176,7 +176,7 @@ void GL_SetColor(int palidx);
void GL_SetColorAndAlpha(float r, float g, float b, float a);
void GL_SetNoTexture(void);
void GL_SetPatch(int lump);
void GL_SetSprite(int pnum);
void GL_SetSprite(int pnum, int spriteType);
void GL_SetFlat(int idx);
void GL_SetTexture(int idx);
unsigned int GL_SetRawImage(int lump, int part);
Expand Down Expand Up @@ -231,7 +231,7 @@ void S_StopMusic(void);
int M_ReadFile(char const *name, byte **buffer);
int M_ReadFileCLib(char const *name, byte **buffer);
boolean M_WriteFile (char const *name, void *source, int length);
void M_ExtractFileBase(char *path, char *dest);
void M_ExtractFileBase(const char *path, char *dest);
void M_GetFileExt(const char *path, char *ext);
boolean M_CheckPath(char *path);
int M_FileExists(const char *file);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/Include/m_misc.h
Expand Up @@ -23,7 +23,7 @@ boolean M_CheckFileID(const char *path);
int M_ReadFile(char const *name, byte **buffer);
int M_ReadFileCLib(char const *name, byte **buffer);
boolean M_WriteFile(char const *name, void *source, int length);
void M_ExtractFileBase(char *path, char *dest);
void M_ExtractFileBase(const char *path, char *dest);
void M_GetFileExt(const char *path, char *ext);
void M_ReplaceFileExt(char *path, char *newext);
boolean M_CheckPath(char *path);
Expand Down
1 change: 1 addition & 0 deletions doomsday/Include/r_extres.h
Expand Up @@ -18,6 +18,7 @@ typedef enum resourceclass_e {

void R_InitExternalResources(void);
void R_SetDataPath(const char *path);
const char *R_GetDataPath(void);
void R_PrependDataPath(const char *origPath, char *newPath);
boolean R_FindResource(resourceclass_t resClass, const char *name,
const char *optionalSuffix, char *fileName);
Expand Down
1 change: 1 addition & 0 deletions doomsday/Include/sys_direc.h
Expand Up @@ -14,5 +14,6 @@ void Dir_MakeDir(const char *path, directory_t *dir);
int Dir_FileID(const char *str);
void Dir_ValidDir(char *str);
int Dir_IsAbsolute(const char *str);
void Dir_MakeAbsolute(char *path);

#endif
1 change: 1 addition & 0 deletions doomsday/Include/sys_file.h
Expand Up @@ -25,6 +25,7 @@ void F_ShutdownDirec(void);
int F_Access(const char *path);
DFILE * F_Open(const char *path, const char *mode);
void F_Close(DFILE *file);
int F_Length(DFILE *file);
int F_Read(void *dest, int count, DFILE *file);
int F_GetC(DFILE *file);
int F_Tell(DFILE *file);
Expand Down
55 changes: 53 additions & 2 deletions doomsday/Src/con_console.c
Expand Up @@ -97,6 +97,7 @@ D_CMD(AddSub);
D_CMD(Ping);
D_CMD(Login);
D_CMD(Logout);
D_CMD(Dir);

#ifdef _DEBUG
D_CMD(TranslateFont);
Expand Down Expand Up @@ -473,6 +474,8 @@ ccmd_t engineCCmds[] =
"dumpkeymap", CCmdDumpKeyMap, "Write the current keymap to a file.",
"connect", CCmdConnect, "Connect to a server using TCP/IP.",
"write", CCmdWriteConsole, "Write variables, bindings and aliases to a file.",
"dir", CCmdDir, "Print contents of directories.",
"ls", CCmdDir, "Print contents of directories.",

#ifdef _DEBUG
"TranslateFont", CCmdTranslateFont, "Ha ha.",
Expand Down Expand Up @@ -2315,7 +2318,7 @@ int CCmdLoadFile(int argc, char **argv)
for(i=1; i<argc; i++)
{
Con_Message( "Loading %s...\n", argv[i]);
if(W_AddFile(argv[i]))
if(W_AddFile(argv[i], true))
{
Con_Message( "OK\n");
succeeded = true; // At least one has been loaded.
Expand Down Expand Up @@ -2486,7 +2489,7 @@ D_CMD(Font)
Cfont.Width = FR_TextWidth;
Cfont.Filter = NULL;
}
else if(!stricmp(argv[1], "name"))
else if(!stricmp(argv[1], "name") && argc == 3)
{
FR_DestroyFont(FR_GetCurrent());
if(!FR_PrepareFont(argv[2])) FR_PrepareFont("Fixed");
Expand Down Expand Up @@ -2761,3 +2764,51 @@ void Con_Error (char *error, ...)
// Get outta here.
exit (1);
}

/*
* Prints a file name to the console.
* This is a f_forall_func_t.
*/
int Con_PrintFileName(const char *fn, int parm)
{
const char *dir = (const char*) parm;

// Exclude the path.
Con_Printf(" %s\n", fn + strlen(dir));

// Continue the listing.
return true;
}

/*
* Print contents of directories as Doomsday sees them.
*/
int CCmdDir(int argc, char **argv)
{
char dir[256], pattern[256];
int i;

if(argc == 1)
{
Con_Printf("Usage: %s (dirs)\n", argv[0]);
Con_Printf("Prints the contents of one or more directories.\n");
Con_Printf("Virtual files are listed, too.\n");
Con_Printf("Paths are relative to the base path:\n");
Con_Printf(" %s\n", ddBasePath);
return true;
}

for(i = 1; i < argc; i++)
{
M_PrependBasePath(argv[i], dir);
Dir_ValidDir(dir);
Dir_MakeAbsolute(dir);
Con_Printf("Directory: %s\n", dir);

// Make the pattern.
sprintf(pattern, "%s*.*", dir);
F_ForAll(pattern, (int) dir, Con_PrintFileName);
}

return true;
}
67 changes: 52 additions & 15 deletions doomsday/Src/dd_main.c
Expand Up @@ -28,7 +28,7 @@

// MACROS ------------------------------------------------------------------

#define MAXWADFILES 30
#define MAXWADFILES 128

// TYPES -------------------------------------------------------------------

Expand Down Expand Up @@ -116,17 +116,7 @@ static int WarpMap;
static int demosequence;
static int pagetic;
static char *pagename;
static char *wadfiles[MAXWADFILES];/* =
{
"Data\\Doomsday.wad"
};*/

/*static execOpt_t ExecOptions[] =
{
{ "-file", ExecOptionFILE, 1, 0 },*/
// { "-maxzone", ExecOptionMAXZONE, 1, 0 },
/* { NULL, NULL, 0, 0 } // Terminator
};*/
static char *wadfiles[MAXWADFILES];

// CODE --------------------------------------------------------------------

Expand Down Expand Up @@ -165,6 +155,38 @@ static void AddToWadList(char *list)
free(buffer);
}

//===========================================================================
// autoDataAdder (f_forall_func_t)
//===========================================================================
static int autoDataAdder(const char *fileName, int loadFiles)
{
if(loadFiles)
W_AddFile(fileName, false);
else
DD_AddStartupWAD(fileName);

// Continue searching.
return true;
}

//===========================================================================
// DD_AddAutoData
// Files with the extensions wad, lmp, pk3 and zip in the automatical data
// directory are added to the wadfiles list.
//===========================================================================
void DD_AddAutoData(boolean loadFiles)
{
const char *extensions[] = { "wad", "lmp", "pk3", "zip", NULL };
char pattern[256];
int i;

for(i = 0; extensions[i]; i++)
{
sprintf(pattern, "%sAuto\\*.%s", R_GetDataPath(), extensions[i]);
F_ForAll(pattern, loadFiles, autoDataAdder);
}
}

//===========================================================================
// DD_SetConfigFile
//===========================================================================
Expand Down Expand Up @@ -197,6 +219,7 @@ void DD_Verbosity(void)
//===========================================================================
// DD_Main
// Engine and game initialization. When complete, starts the game loop.
// What a mess...
//===========================================================================
void DD_Main(void)
{
Expand Down Expand Up @@ -234,6 +257,8 @@ void DD_Main(void)
strcpy(ddBasePath, ArgNext());
Dir_ValidDir(ddBasePath);
}

Dir_MakeAbsolute(ddBasePath);

// We need to get the console initialized. Otherwise Con_Message() will
// crash the system (yikes).
Expand Down Expand Up @@ -332,9 +357,21 @@ void DD_Main(void)
HandleArgs(1); // Only the WADs.

Con_Message("W_Init: Init WADfiles.\n");

// Add real files from the Auto directory to the wadfiles list.
DD_AddAutoData(false);

W_InitMultipleFiles(wadfiles);
F_InitDirec();


// Load files from the Auto directory. (If already loaded, won't be
// loaded again.) This is done again because virtual files may now
// exist in the Auto directory.
DD_AddAutoData(true);

// No more WADs will be loaded in startup mode after this point.
W_EndStartup();

// Execute the startup script (Startup.cfg).
Con_ParseCommands("startup.cfg", false);

Expand Down Expand Up @@ -521,7 +558,7 @@ void DD_CheckTimeDemo(void)
// greater-than character (>) in front of the name to prepend the base
// path to the file name (providing it's a relative path).
//==========================================================================
void DD_AddStartupWAD(char *file/*, boolean inc_base*/)
void DD_AddStartupWAD(const char *file)
{
int i;
char *new, temp[300];
Expand Down Expand Up @@ -686,7 +723,7 @@ void DD_SetInteger(int ddvalue, int parm)
if(table)
GL_SetTranslatedSprite(lump, table, cls);
else
GL_SetSprite(lump);
GL_SetSprite(lump, 0);
}
else if(ddvalue == DD_TEXTURE_GLOW)
{
Expand Down

0 comments on commit d2aea7a

Please sign in to comment.