The source release of the qutils.

This commit is contained in:
Travis Bradshaw
2012-01-31 15:48:05 -06:00
commit 6df9737f9c
111 changed files with 23929 additions and 0 deletions

251
qutils/QFILES/QFILES.C Normal file
View File

@@ -0,0 +1,251 @@
#include "cmdlib.h"
#define MAX_SOUNDS 1024
#define MAX_MODELS 1024
#define MAX_FILES 1024
#define MAX_DATA_PATH 64
char precache_sounds[MAX_SOUNDS][MAX_DATA_PATH];
int precache_sounds_block[MAX_SOUNDS];
int numsounds;
char precache_models[MAX_MODELS][MAX_DATA_PATH];
int precache_models_block[MAX_SOUNDS];
int nummodels;
char precache_files[MAX_FILES][MAX_DATA_PATH];
int precache_files_block[MAX_SOUNDS];
int numfiles;
typedef struct
{
char name[56];
int filepos, filelen;
} packfile_t;
typedef struct
{
char id[4];
int dirofs;
int dirlen;
} packheader_t;
packfile_t pfiles[4096], *pf;
FILE *packhandle;
int packbytes;
/*
===========
PackFile
Copy a file into the pak file
===========
*/
void PackFile (char *src, char *name)
{
FILE *in;
int remaining, count;
char buf[4096];
if ( (byte *)pf - (byte *)pfiles > sizeof(pfiles) )
Error ("Too many files in pak file");
in = SafeOpenRead (src);
remaining = filelength (in);
pf->filepos = LittleLong (ftell (packhandle));
pf->filelen = LittleLong (remaining);
strcpy (pf->name, name);
printf ("%64s : %7i\n", pf->name, remaining);
packbytes += remaining;
while (remaining)
{
if (remaining < sizeof(buf))
count = remaining;
else
count = sizeof(buf);
SafeRead (in, buf, count);
SafeWrite (packhandle, buf, count);
remaining -= count;
}
fclose (in);
pf++;
}
/*
===========
CopyQFiles
===========
*/
void CopyQFiles (int blocknum)
{
int i, p;
char srcfile[1024];
char destfile[1024];
char name[1024];
packheader_t header;
int dirlen;
unsigned short crc;
// create a pak file
pf = pfiles;
sprintf (destfile, "%spak%i.pak", gamedir, blocknum);
packhandle = SafeOpenWrite (destfile);
SafeWrite (packhandle, &header, sizeof(header));
blocknum++;
for (i=0 ; i<numsounds ; i++)
{
if (precache_sounds_block[i] != blocknum)
continue;
sprintf (name, "sound/%s", precache_sounds[i]);
sprintf (srcfile,"%s%s",gamedir, name);
PackFile (srcfile, name);
}
for (i=0 ; i<nummodels ; i++)
{
if (precache_models_block[i] != blocknum)
continue;
sprintf (srcfile,"%s%s",gamedir, precache_models[i]);
PackFile (srcfile, precache_models[i]);
}
for (i=0 ; i<numfiles ; i++)
{
if (precache_files_block[i] != blocknum)
continue;
sprintf (srcfile,"%s%s",gamedir, precache_files[i]);
PackFile (srcfile, precache_files[i]);
}
header.id[0] = 'P';
header.id[1] = 'A';
header.id[2] = 'C';
header.id[3] = 'K';
dirlen = (byte *)pf - (byte *)pfiles;
header.dirofs = LittleLong(ftell (packhandle));
header.dirlen = LittleLong(dirlen);
SafeWrite (packhandle, pfiles, dirlen);
fseek (packhandle, 0, SEEK_SET);
SafeWrite (packhandle, &header, sizeof(header));
fclose (packhandle);
// do a crc of the file
CRC_Init (&crc);
for (i=0 ; i<dirlen ; i++)
CRC_ProcessByte (&crc, ((byte *)pfiles)[i]);
i = pf - pfiles;
printf ("%i files packed in %i bytes (%i crc)\n",i, packbytes, crc);
}
/*
=================
BspModels
Runs qbsp and light on all of the models with a .bsp extension
=================
*/
void BspModels (void)
{
int p;
int i;
char *m;
char cmd[1024];
char name[256];
for (i=0 ; i<nummodels ; i++)
{
m = precache_models[i];
if (strcmp(m+strlen(m)-4, ".bsp"))
continue;
strcpy (name, m);
name[strlen(m)-4] = 0;
sprintf (cmd, "qbsp %s%s",gamedir, name);
system (cmd);
sprintf (cmd, "light -extra %s%s", gamedir, name);
system (cmd);
}
}
/*
=============
ReadFiles
=============
*/
int ReadFiles (void)
{
FILE *f;
int i;
f = SafeOpenRead ("files.dat");
fscanf (f, "%i\n", &numsounds);
for (i=0 ; i<numsounds ; i++)
fscanf (f, "%i %s\n", &precache_sounds_block[i],
precache_sounds[i]);
fscanf (f, "%i\n", &nummodels);
for (i=0 ; i<nummodels ; i++)
fscanf (f, "%i %s\n", &precache_models_block[i],
precache_models[i]);
fscanf (f, "%i\n", &numfiles);
for (i=0 ; i<numfiles ; i++)
fscanf (f, "%i %s\n", &precache_files_block[i],
precache_files[i]);
fclose (f);
printf ("%3i sounds\n", numsounds);
printf ("%3i models\n", nummodels);
printf ("%3i files\n", numfiles);
}
/*
=============
main
=============
*/
int main (int argc, char **argv)
{
if (argc == 1)
{
printf ("qfiles -pak <0 / 1> : build a .pak file\n");
printf ("qfiles -bspmodels : regenerates all brush models\n");
exit (1);
}
SetQdirFromPath ("");
ReadFiles ();
if (!strcmp (argv[1], "-pak"))
{
CopyQFiles (atoi(argv[2]));
}
else if (!strcmp (argv[1], "-bspmodels"))
{
BspModels ();
}
else
Error ("unknown command: %s", argv[1]);
return 0;
}

221
qutils/QFILES/QFILES.MAK Normal file
View File

@@ -0,0 +1,221 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
!IF "$(CFG)" == ""
CFG=qfiles - Win32 Debug
!MESSAGE No configuration specified. Defaulting to qfiles - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "qfiles - Win32 Release" && "$(CFG)" != "qfiles - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "qfiles.mak" CFG="qfiles - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "qfiles - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "qfiles - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
RSC=rc.exe
CPP=cl.exe
!IF "$(CFG)" == "qfiles - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\qfiles.exe"
CLEAN :
-@erase ".\Release\qfiles.exe"
-@erase ".\Release\qfiles.obj"
-@erase ".\Release\cmdlib.obj"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
# ADD CPP /nologo /W1 /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
CPP_PROJ=/nologo /ML /W1 /GX /O2 /I "..\common" /D "WIN32" /D "NDEBUG" /D\
"_CONSOLE" /Fp"$(INTDIR)/qfiles.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
CPP_SBRS=
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/qfiles.bsc"
BSC32_SBRS=
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
odbccp32.lib /nologo /subsystem:console /incremental:no\
/pdb:"$(OUTDIR)/qfiles.pdb" /machine:I386 /out:"$(OUTDIR)/qfiles.exe"
LINK32_OBJS= \
"$(INTDIR)/qfiles.obj" \
"$(INTDIR)/cmdlib.obj"
"$(OUTDIR)\qfiles.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "qfiles - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=.\Debug
INTDIR=.\Debug
ALL : "$(OUTDIR)\qfiles.exe"
CLEAN :
-@erase ".\Debug\qfiles.exe"
-@erase ".\Debug\qfiles.obj"
-@erase ".\Debug\cmdlib.obj"
-@erase ".\Debug\qfiles.ilk"
-@erase ".\Debug\qfiles.pdb"
-@erase ".\Debug\vc40.pdb"
-@erase ".\Debug\vc40.idb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
# ADD CPP /nologo /W1 /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
CPP_PROJ=/nologo /MLd /W1 /Gm /GX /Zi /Od /I "..\common" /D "WIN32" /D "_DEBUG"\
/D "_CONSOLE" /Fp"$(INTDIR)/qfiles.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\Debug/
CPP_SBRS=
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/qfiles.bsc"
BSC32_SBRS=
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
odbccp32.lib /nologo /subsystem:console /incremental:yes\
/pdb:"$(OUTDIR)/qfiles.pdb" /debug /machine:I386 /out:"$(OUTDIR)/qfiles.exe"
LINK32_OBJS= \
"$(INTDIR)/qfiles.obj" \
"$(INTDIR)/cmdlib.obj"
"$(OUTDIR)\qfiles.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "qfiles - Win32 Release"
# Name "qfiles - Win32 Debug"
!IF "$(CFG)" == "qfiles - Win32 Release"
!ELSEIF "$(CFG)" == "qfiles - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\qfiles.c
DEP_CPP_QFILE=\
".\..\common\cmdlib.h"\
"$(INTDIR)\qfiles.obj" : $(SOURCE) $(DEP_CPP_QFILE) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\cmdlib.c
DEP_CPP_CMDLI=\
".\..\common\cmdlib.h"\
{$(INCLUDE)}"\sys\types.h"\
{$(INCLUDE)}"\sys\stat.h"\
"$(INTDIR)\cmdlib.obj" : $(SOURCE) $(DEP_CPP_CMDLI) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\quake\utils2\common\cmdlib.h
!IF "$(CFG)" == "qfiles - Win32 Release"
!ELSEIF "$(CFG)" == "qfiles - Win32 Debug"
!ENDIF
# End Source File
# End Target
# End Project
################################################################################

BIN
qutils/QFILES/QFILES.MDP Normal file

Binary file not shown.

BIN
qutils/QFILES/QFILES.NCB Normal file

Binary file not shown.