21 Dec 2007

This commit is contained in:
g-cont 2007-12-21 00:00:00 +03:00 committed by Alibek Omarov
parent bf912f84f4
commit 71cebb95ba
22 changed files with 545 additions and 4235 deletions

View File

@ -4,71 +4,32 @@
Коллижен менеджер (который фейсы добавляет) на версии 1.53 вылетает при парсинге половины q2 карт почему-то.
DDS Converter 2.1 некорректно высчитывает размер dds файла (баг в devil ?), юзаем только nvdxt
Quake1 Quake2
SV_MoveBounds SV_TraceBounds
SV_Move SV_Trace
SV_ClipMoveToEntity CM_BoxTrace
SV_ClipToLinks SV_ClipMoveToEntities
case TYPE_Q1MIP:
if(FS_Seek(w->file, w->lumps[i].filepos - w->lumps[i].size, SEEK_SET))
{
MsgDev(D_ERROR, "FS_OpenWad3File: corrupt WAD3 file\n");
return NULL;
}
default:
if(FS_Seek(w->file, w->lumps[i].filepos, SEEK_SET))
{
MsgDev(D_ERROR, "FS_OpenWad3File: corrupt WAD3 file\n");
return NULL;
}
studioframeadvance
studiorewindframe
length = maxchars
widthInChars = visible_length
maxchars = length
scroll = visible_offset
// замеченные баги
1. не выводится текущее значение переменной в консоль OK
2. imglib не выводит сообщения в консоль OK
3. SC_ParseToken вылетает при парсинге сейв-файла
4. где-то бьется буффер при -dev 6
Èìïëåìåíòàöèÿ roqlib
1. Âåðíóòü read\save codebook OK
2. ïîäêëþ÷èòü çâóêîâîé êîäåð
1. ïåðåâåñòè óòèëèòû â êîíñîëüíûé ðåæèì OK
2. Èìïëåìåíòàöèÿ save-restore äëÿ ôèçèêè
Ñìåíà ôîðìàòà êàðòû: íîâàÿ âåðñèÿ bsp 39 XashBSP format
1. Èçáàâèòüñÿ îò short side â dface_t (ïåðåâåñòè ðåíäåð â íîâûé ðåæèì ðàáîòû)
2. ñæàòü entlump çèïîì
3. äîáàâèòü LUMP_MAPINFO (äëÿ áûñòðîãî ïîèñêà èìåíè êàðòû)
4. ïåðåïèñàòü âñå ñâàïû äëÿ ëóìïîâ
5. ïðèäóìàòü êàê óìåíüøèòü ðàçìåð êàðòû
íàó÷èòü imagelib ÷èòàòü ÿêîáû ñòðàííûå êàðòèíêè creditsfont è conchars (õîòÿ áû conchars)
typedef struct
{
char mapname[64]; // internal map name
char builddate[32]; // map builddate
char mpentity[32]; // name of multiplayer start entity, like "info_player_deathmath"
char svprogs[32]; // name of custom server.dat (just for debugging)
uint mapversion; // should be 220 ?
uint checksum; // compared with COM_Checksum
} dmapinfo_t;
создание wadlib:
1. придумать синтаксис
Текущие задачи:
1. ввести новые типы для вадов OK
2. имлементировать таблицу для их поиска внутри вада OK
3. Имплементировать FS_SearchLump в FS_Search OK
4. Создать wadlib с поддержкой компрессии лумпов OK
5. высвободить память, выделенную в FS_OpenWad3 в imglib OK
6. Тест на различные типы файлов, документация
7. подключить звуковой кодер к roqlib
8. Имплементация save-restore для физики
9. Избавиться от оригинальной партиклевой системы
10. Создать функцию R_CreateImage для удобства
11. Заменить уже gs_mapname на gs_filename (ато заебало)
//==================================================
// то, что уже готово
//==================================================
+поддержка всех типов для вадов тщательно оттестирована
+добавлена поддержка ВСЕХ существующих типов внутри вадов
+добавлена поддержка wad-файлов
+наконец-то добавлена аппаратная гамма

View File

@ -249,6 +249,10 @@ SOURCE=.\utils.c
# End Source File
# Begin Source File
SOURCE=.\wadlib.c
# End Source File
# Begin Source File
SOURCE=.\bsplib\winding.c
# End Source File
# Begin Source File

View File

@ -72,7 +72,7 @@ void InitPlatform ( uint funcname, int argc, char **argv )
case IMGLIB:
case SPRITE:
case STUDIO:
case PAKLIB:
case WADLIB:
FS_InitRootDir(".");
start = Sys_DoubleTime();
break;
@ -112,7 +112,7 @@ void RunPlatform ( void )
strcpy(searchmask[2], "*.wal" ); // quake2 textures
strcpy(searchmask[3], "*.lmp" ); // quake1 menu images
strcpy(searchmask[4], "*.mip" ); // quake1 textures
strcpy(searchmask[5], ".wad3" ); // half-life textures
strcpy(searchmask[5], "*.fnt" ); // half-life fonts
Msg("Processing images ...\n\n");
break;
case BSPLIB:
@ -120,13 +120,14 @@ void RunPlatform ( void )
strcpy(searchmask[0], "*.map" );
CompileBSPModel();
break;
case PAKLIB:
Sys_Break("not implemented\n");
case WADLIB:
CompileMod = CompileWad3Archive;
strcpy(typemod, "wads" );
strcpy(searchmask[0], "*.qc" );
break;
case QCCLIB:
strcpy(typemod, "progs" );
strcpy(searchmask[0], "*.src" );
strcpy(searchmask[1], "*.qc" ); // no longer used
CompileDATProgs();
break;
case ROQLIB:
@ -148,10 +149,8 @@ void RunPlatform ( void )
for( i = 0; i < 8; i++)
{
// skip blank mask
if(!strlen(searchmask[i])) continue;
if(com.stricmp(searchmask[i], ".wad3" ))
search = FS_Search( searchmask[i], true );
else search = FS_SearchLump( "*", true ); // hl-textures
if(!com.strlen(searchmask[i])) continue;
search = FS_Search( searchmask[i], true );
if(!search) continue; // try next mask
for( j = 0; j < search->numfilenames; j++ )
@ -180,7 +179,7 @@ elapced_time:
void FreePlatform ( void )
{
//Mem_Check(); // check for leaks
Mem_Check(); // check for leaks
Mem_FreePool( &basepool );
Mem_FreePool( &zonepool );
}

View File

@ -472,26 +472,7 @@ bool ROQ_ParseMovieScript (void)
else if (Com_MatchToken( "$framemask" )) Cmd_FrameMask();
else if (Com_MatchToken( "$sound" )) Cmd_Sound();
else if (Com_MatchToken( "$quality")) Cmd_Quality();
else if(Com_MatchToken( "$modelname" )) // check for studiomdl script
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$body" )) // check for studiomdl script
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if (Com_MatchToken("$spritename")) // check for spritegen script
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if (Com_MatchToken("$frame")) // check for spritegen script
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if (!Com_ValidScript( QC_ROQLIB )) return false;
else Cmd_MovieUnknown();
}
return true;

View File

@ -355,26 +355,7 @@ bool ParseSpriteScript (void)
else if (Com_MatchToken( "$color" )) Cmd_Color();
else if (Com_MatchToken( "$load" )) Cmd_Load();
else if (Com_MatchToken( "$type" )) Cmd_Type();
else if(Com_MatchToken( "$modelname" ))//check for studiomdl script
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$body" ))//check for studiomdl script
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$videoname" ))//check for studiomdl script
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$framemask" ))//check for studiomdl script
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if (!Com_ValidScript( QC_SPRITEGEN )) return false;
else Cmd_SpriteUnknown();
}
return true;

View File

@ -2502,26 +2502,7 @@ bool ParseModelScript (void)
else if (Com_MatchToken("$renamebone")) Cmd_Renamebone ();
else if (Com_MatchToken("$texrendermode")) Cmd_TexRenderMode();
else if (Com_MatchToken("$replacetexture")) Cmd_Replace();
else if (Com_MatchToken("$spritename"))
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if (Com_MatchToken("$frame"))
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$videoname" ))//check for studiomdl script
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$framemask" ))//check for studiomdl script
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if (!Com_ValidScript( QC_STUDIOMDL )) return false;
else Cmd_StudioUnknown();
}

View File

@ -78,6 +78,59 @@ void Profile_Time( void )
else MsgWarn("--- Profiler not supported ---\n");
}
/*
================
Com_ValidScript
validate qc-script for unexcpected keywords
================
*/
bool Com_ValidScript( int scripttype )
{
if(Com_MatchToken("$spritename") && scripttype != QC_SPRITEGEN )
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if (Com_MatchToken("$frame") && scripttype != QC_SPRITEGEN )
{
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$modelname" ) && scripttype != QC_STUDIOMDL )
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$body" ) && scripttype != QC_STUDIOMDL )
{
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$videoname" ) && scripttype != QC_ROQLIB )
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$framemask" ) && scripttype != QC_ROQLIB )
{
Msg("%s probably roq movie qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$wadname" ) && scripttype != QC_WADLIB )
{
Msg("%s probably wadlib qc.script, skipping...\n", gs_mapname );
return false;
}
else if(Com_MatchToken( "$addlump" ) && scripttype != QC_WADLIB )
{
Msg("%s probably wadlib qc.script, skipping...\n", gs_mapname );
return false;
}
return true;
};
/*
========================================================================

View File

@ -83,6 +83,16 @@ extern bool host_debug;
extern byte *qccpool;
extern byte *studiopool;
enum
{
QC_SPRITEGEN = 1,
QC_STUDIOMDL,
QC_ROQLIB,
QC_WADLIB
};
bool Com_ValidScript( int scripttype );
// misc common functions
byte *ReadBMP (char *filename, byte **palette, int *width, int *height);
@ -90,6 +100,7 @@ byte *ReadBMP (char *filename, byte **palette, int *width, int *height);
bool CompileStudioModel ( byte *mempool, const char *name, byte parms );
bool CompileSpriteModel ( byte *mempool, const char *name, byte parms );
bool ConvertImagePixels ( byte *mempool, const char *name, byte parms );
bool CompileWad3Archive ( byte *mempool, const char *name, byte parms );
bool CompileROQVideo( byte *mempool, const char *name, byte parms );
bool PrepareBSPModel ( const char *dir, const char *name, byte params );
bool CompileBSPModel ( void );

258
common/wadlib.c Normal file
View File

@ -0,0 +1,258 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// wadlib.c.c - wad archive compiler
//=======================================================================
#include "platform.h"
#include "utils.h"
char wadoutname[MAX_SYSPATH];
static dlumpinfo_t wadlumps[MAX_FILES_IN_PACK];
static char lumpname[MAX_SYSPATH];
dwadinfo_t wadfile; // main header
int wadheader;
int numlumps = 0;
bool compress_lumps = false;
file_t *handle = NULL;
void Wad3_NewWad( void )
{
handle = FS_Open( wadoutname, "wb" );
if(!handle) Sys_Break("Wad3_NewWad: can't create %s\n", wadoutname );
FS_Write( handle, &wadfile, sizeof(wadfile));
memset( wadlumps, 0, sizeof(wadlumps));
numlumps = 0;
}
/*
===============
AddLump
===============
*/
void Wad3_AddLump( const char *name, void *buffer, int length, int type, bool compress )
{
dlumpinfo_t *info;
int ofs;
if(!buffer || type == TYPE_NONE)
{
MsgWarn("Wad3_AddLump: file %s not found\n", name );
return;
}
FS_FileBase( (char *)name, lumpname );
if(strlen(lumpname) > WAD3_NAMELEN)
{
MsgWarn("Wad3_AddLump: %s have too long name, max %d symbols\n", lumpname, WAD3_NAMELEN );
return;
}
// create wad file
if(!handle) Wad3_NewWad();
info = &wadlumps[numlumps];
com.strncpy( info->name, lumpname, WAD3_NAMELEN );
com.strupr( info->name, info->name );
ofs = FS_Tell( handle );
info->filepos = LittleLong( ofs );
info->type = (char)type;
numlumps++; // increase lump number
if( compress )
{
vfile_t *h = VFS_Open( handle, "wz" );
info->compression = CMP_ZLIB;
info->size = length; // realsize
VFS_Write( h, buffer, length );
handle = VFS_Close( h ); // go back to real filesystem
ofs = FS_Tell( handle ); // ofs - info->filepos returns compressed size
info->disksize = LittleLong( ofs - info->filepos );
}
else
{
info->compression = CMP_NONE;
info->size = info->disksize = LittleLong( length );
FS_Write( handle, buffer, length ); // just write file
}
MsgDev(D_NOTE, "AddLump: %s, size %d\n", info->name, info->disksize );
}
int Lump_GetFileType( const char *name, byte *buf )
{
const char *ext = FS_FileExtension( name );
if(!buf) return TYPE_NONE;
switch(LittleLong(*(uint *)buf))
{
case IDSPRITEHEADER: return TYPE_SPRITE;
case IDSTUDIOHEADER: return TYPE_STUDIO;
case DDSHEADER: return TYPE_MIPDDS;
}
// otherwise get file type by extension
if(!com.stricmp( ext, "tga" )) return TYPE_MIPTGA;
else if(!com.stricmp( ext, "mip" )) return TYPE_MIPTEX; // quake1 texture
else if(!com.stricmp( ext, "tex" )) return TYPE_MIPTEX2; // half-life texture
else if(!com.stricmp( ext, "lmp" )) return TYPE_QPIC; // hud pics
else if(!com.stricmp( ext, "pal" )) return TYPE_QPAL; // palette
else if(!com.stricmp( ext, "wav" )) return TYPE_SOUND; // wav sound
else if(!com.stricmp( ext, "txt" )) return TYPE_SCRIPT; // text file
else if(!com.stricmp( ext, "dat" )) return TYPE_VPROGS; // qc progs
else if(!com.stricmp( ext, "raw" )) return TYPE_RAW; // raw data
// no compares found
return TYPE_NONE;
}
void Cmd_WadName( void )
{
com.strncpy( wadoutname, Com_GetToken(false), sizeof(wadoutname));
FS_DefaultExtension( wadoutname, ".wad" );
}
void Cmd_WadType( void )
{
Com_GetToken( false );
if (Com_MatchToken( "wad3")) wadheader = IDWAD3HEADER;
else if (Com_MatchToken( "wad2")) wadheader = IDWAD2HEADER;
else wadheader = IDWAD3HEADER; // default
}
void Cmd_AddLump( void )
{
int depth = 0;
char filename[MAX_SYSPATH];
byte *buf;
size_t filesize;
bool compress = false;
Com_GetToken( false );
com.strncpy( filename, com_token, sizeof(filename));
if(Com_TryToken()) compress = true;
if( compress_lumps ) compress = true;
Msg("loadfile %s\n", filename );
// we can load file from another wad ;)
buf = FS_LoadFile( filename, &filesize );
Wad3_AddLump( filename, buf, filesize, Lump_GetFileType( filename, buf ), compress );
}
/*
==============
Cmd_WadCompress
syntax: "$compression"
==============
*/
void Cmd_WadCompress( void )
{
compress_lumps = true;
}
/*
==============
Cmd_WadUnknown
syntax: "blabla"
==============
*/
void Cmd_WadUnknown( void )
{
MsgWarn("Cmd_WadUnknown: skip command \"%s\"\n", com_token);
while(Com_TryToken());
}
void ResetWADInfo( void )
{
FS_FileBase(gs_mapname, wadoutname );//kill path and ext
FS_DefaultExtension( wadoutname, ".wad" );//set new ext
memset (&wadheader, 0, sizeof(wadheader));
wadheader = IDWAD3HEADER;
numlumps = 0;
handle = NULL;
}
/*
===============
ParseScript
===============
*/
bool ParseWADfileScript( void )
{
ResetWADInfo();
while( 1 )
{
if(!Com_GetToken (true))break;
if (Com_MatchToken( "$wadname" )) Cmd_WadName();
else if (Com_MatchToken( "$wadtype" )) Cmd_WadType();
else if (Com_MatchToken( "$compression" )) Cmd_WadCompress();
else if (Com_MatchToken( "$addlump" )) Cmd_AddLump();
else if (!Com_ValidScript( QC_WADLIB )) return false;
else Cmd_WadUnknown();
}
return true;
}
void WriteWADFile( void )
{
int ofs;
if(!handle) return;
// write the lumpingo
ofs = FS_Tell( handle );
FS_Write( handle, wadlumps, numlumps * sizeof(dlumpinfo_t));
// write the header
wadfile.ident = wadheader;
wadfile.numlumps = LittleLong( numlumps );
wadfile.infotableofs = LittleLong( ofs );
FS_Seek( handle, 0, SEEK_SET );
FS_Write( handle, &wadfile, sizeof(wadfile));
FS_Close( handle );
}
void ClearWADfile( void )
{
compress_lumps = false;
handle = NULL;
}
bool BuildCurrentWAD( const char *name )
{
bool load = false;
if(name) com.strncpy( gs_mapname, name, sizeof(gs_mapname));
FS_DefaultExtension( gs_mapname, ".qc" );
load = Com_LoadScript( gs_mapname, NULL, 0 );
if(load)
{
if(!ParseWADfileScript())
return false;
WriteWADFile();
ClearWADfile();
return true;
}
Msg("%s not found\n", gs_mapname );
return false;
}
bool CompileWad3Archive( byte *mempool, const char *name, byte parms )
{
if(mempool) studiopool = mempool;
else
{
Msg("Wadlib: can't allocate memory pool.\nAbort compilation\n");
return false;
}
return BuildCurrentWAD( name );
}

View File

@ -1010,6 +1010,11 @@ static bool FS_AddWad3File( const char *filename )
switch( header.ident )
{
case IDIWADHEADER:
case IDPWADHEADER:
MsgDev(D_ERROR, "FS_AddWad3File: (%s) Doom1 wad-files are not supported\n", filename );
FS_Close( file );
return false;
case IDWAD2HEADER:
com_strncpy( type, "Quake1", 16 );
break;
@ -1716,59 +1721,39 @@ file_t *FS_OpenReadFile (const char *filename, const char *mode, bool quiet, boo
return FS_OpenPackedFile (search->pack, pack_ind);
}
search_t *FS_SearchLump( const char *pattern, int caseinsensitive )
/*
=============================================================================
WAD LOADING
=============================================================================
*/
typedef struct wadtype_s
{
stringlist_t resultlist;
search_t *search = NULL;
int i, k, resultlistindex, numfiles, numchars;
wadfile_t *w;
char *ext;
int type;
} wadtype_t;
// no wads loaded
if(!fs_searchwads) return NULL;
stringlistinit(&resultlist);
for( k = 0; k < Mem_ArraySize( fs_searchwads ); k++ )
{
// lookup all wads in list
w = (wadfile_t *)Mem_GetElement( fs_searchwads, k );
if( !w ) continue;
for(i = 0; i < (uint)w->numlumps; i++)
{
if(SC_FilterToken( (char *)pattern, w->lumps[i].name, !caseinsensitive ))
stringlistappend(&resultlist, w->lumps[i].name);
}
}
// sorting result
if (resultlist.numstrings)
{
stringlistsort(&resultlist);
numfiles = resultlist.numstrings;
numchars = 0;
for (resultlistindex = 0; resultlistindex < resultlist.numstrings; resultlistindex++)
numchars += (int)com_strlen(resultlist.strings[resultlistindex]) + 1;
search = Malloc(sizeof(search_t) + numchars + numfiles * sizeof(char *));
search->filenames = (char **)((char *)search + sizeof(search_t));
search->filenamesbuffer = (char *)((char *)search + sizeof(search_t) + numfiles * sizeof(char *));
search->numfilenames = (int)numfiles;
numfiles = 0;
numchars = 0;
for (resultlistindex = 0; resultlistindex < resultlist.numstrings; resultlistindex++)
{
size_t textlen;
search->filenames[numfiles] = search->filenamesbuffer + numchars;
textlen = com_strlen(resultlist.strings[resultlistindex]) + 1;
Mem_Copy(search->filenames[numfiles], resultlist.strings[resultlistindex], textlen);
numfiles++;
numchars += (int)textlen;
}
}
stringlistfreecontents(&resultlist);
return search;
}
wadtype_t wad_types[] =
{
// associate extension with wad type
{"pal", TYPE_QPAL },
{"lmp", TYPE_QPIC }, // quake1, hl pic
{"mip", TYPE_MIPTEX2}, // hl texture
{"mip", TYPE_MIPTEX }, // quake1 mip
{"raw", TYPE_RAW }, // signed raw data
{"fnt", TYPE_QFONT }, // qfont structure (e.g. fonts.wad in hl1)
{"dds", TYPE_MIPDDS }, // dds texture
{"tga", TYPE_MIPTGA }, // tga texture
{"dat", TYPE_VPROGS }, // QC progs
{"txt", TYPE_SCRIPT }, // txt script file
{"mdl", TYPE_STUDIO }, // studio model
{"spr", TYPE_SPRITE }, // sprite
{"wav", TYPE_SOUND }, // sound
{NULL, TYPE_NONE }
};
/*
===========
@ -1808,7 +1793,7 @@ static byte *FS_OpenWadFile( const char *name, fs_offset_t *filesizeptr, int mat
{
if(!com_strcmp(texname, w->lumps[i].name))
{
byte *buf;
byte *buf, *cbuf;
size_t size;
if(matchtype != (int)w->lumps[i].type) return NULL; // try next type
@ -1817,13 +1802,35 @@ static byte *FS_OpenWadFile( const char *name, fs_offset_t *filesizeptr, int mat
MsgDev(D_ERROR, "FS_OpenWadFile: %s probably corrupted\n", texname );
return NULL;
}
buf = (byte *)Mem_Alloc( fs_mempool, w->lumps[i].disksize );
size = FS_Read(w->file, buf, w->lumps[i].disksize );
if( size < w->lumps[i].disksize )
switch((int)w->lumps[i].compression)
{
MsgDev(D_WARN, "FS_OpenWadFile: lump %s is corrupt\n", texname );
case CMP_NONE:
buf = (byte *)Mem_Alloc( fs_mempool, w->lumps[i].disksize );
size = FS_Read(w->file, buf, w->lumps[i].disksize );
if( size < w->lumps[i].disksize )
{
Mem_Free( buf );
MsgDev(D_WARN, "FS_OpenWadFile: %s probably corrupted\n", texname );
return NULL;
}
break;
case CMP_LZSS:
// never used by Id Software or Valve ?
MsgDev(D_WARN, "FS_OpenWadFile: lump %s have unsupported compression type\n", texname );
return NULL;
}
case CMP_ZLIB:
cbuf = (byte *)Mem_Alloc( fs_mempool, w->lumps[i].disksize );
size = FS_Read(w->file, cbuf, w->lumps[i].disksize );
buf = (byte *)Mem_Alloc( fs_mempool, w->lumps[i].size );
if(!VFS_Unpack( cbuf, size, &buf, w->lumps[i].size ))
{
Mem_Free( buf ), Mem_Free( cbuf );
MsgDev(D_WARN, "FS_OpenWadFile: %s probably corrupted\n", texname );
return NULL;
}
Mem_Free( cbuf ); // no reason to keep this data
break;
}
if(filesizeptr) *filesizeptr = w->lumps[i].disksize;
return buf;
}
@ -1832,6 +1839,25 @@ static byte *FS_OpenWadFile( const char *name, fs_offset_t *filesizeptr, int mat
return NULL;
}
byte *FS_LoadFileFromWAD( const char *path, fs_offset_t *filesizeptr )
{
wadtype_t *type;
const char *ext = FS_FileExtension( path );
bool anyformat = !com_stricmp(ext, "") ? true : false;
byte *f;
// now try all the formats in the selected list
for (type = wad_types; type->ext; type++)
{
if(anyformat || !com_stricmp( ext, type->ext ))
{
f = FS_OpenWadFile( path, filesizeptr, type->type );
if( f ) return f; // found
}
}
return NULL;
}
/*
=============================================================================
@ -2356,33 +2382,13 @@ byte *FS_LoadFile (const char *path, fs_offset_t *filesizeptr )
if (file)
{
filesize = file->real_length;
buf = (byte *)Malloc(filesize + 1);
buf = (byte *)Mem_Alloc(fs_mempool, filesize + 1);
buf[filesize] = '\0';
FS_Read (file, buf, filesize);
FS_Close (file);
}
else if(!com_stricmp("mip", ext ))
{
// mip-texture form quake1 or half-life
buf = FS_OpenWadFile( path, &filesize, TYPE_MIPTEX );
if(!buf) buf = FS_OpenWadFile( path, &filesize, TYPE_MIPTEX2 );
}
else if(!com_stricmp("lmp", ext ))
{
// qpic from quake1 or half-life
buf = FS_OpenWadFile( path, &filesize, TYPE_QPIC );
}
else if(!com_stricmp("fnt", ext ))
{
// half-life qfont lump
buf = FS_OpenWadFile( path, &filesize, TYPE_QFONT );
}
else if(!com_stricmp("pal", ext ))
{
// quake1 palette lump
buf = FS_OpenWadFile( path, &filesize, TYPE_QPAL );
}
else buf = FS_LoadFileFromWAD( path, &filesize );
if(filesizeptr) *filesizeptr = filesize;
return buf;
}
@ -2512,7 +2518,7 @@ static search_t *_FS_Search(const char *pattern, int caseinsensitive, int quiet
search_t *search;
searchpath_t *searchpath;
pack_t *pak;
int i, basepathlength, numfiles, numchars, resultlistindex, dirlistindex;
int i, k, basepathlength, numfiles, numchars, resultlistindex, dirlistindex;
stringlist_t resultlist;
stringlist_t dirlist;
const char *slash, *backslash, *colon, *separator;
@ -2606,6 +2612,41 @@ static search_t *_FS_Search(const char *pattern, int caseinsensitive, int quiet
}
}
// also lookup all wad-files
if( fs_searchwads )
{
wadtype_t *type;
wadfile_t *w; // names will be associated with lump types
const char *ext = FS_FileExtension( pattern );
bool anyformat = !com_stricmp(ext, "*") ? true : false;
char lumpname[MAX_SYSPATH];
FS_FileBase( (char *)pattern, lumpname );
// lookup all wads in list
for( k = 0; k < Mem_ArraySize( fs_searchwads ); k++ )
{
w = (wadfile_t *)Mem_GetElement( fs_searchwads, k );
if( !w ) continue;
for(i = 0; i < (uint)w->numlumps; i++)
{
for (type = wad_types; type->ext; type++)
{
// associate extension with lump->type
if(anyformat || (!com_stricmp( ext, type->ext ) && type->type == (int)w->lumps[i].type))
{
if(SC_FilterToken(lumpname, w->lumps[i].name, !caseinsensitive ))
{
stringlistappend(&resultlist, w->lumps[i].name);
break; // found, compare to next lump
}
}
}
}
}
}
if (resultlist.numstrings)
{
stringlistsort(&resultlist);

View File

@ -1972,7 +1972,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize )
// now try all the formats in the selected list
for (format = load_formats; format->formatstring; format++)
{
if(anyformat || !stricmp(ext, format->ext ))
if(anyformat || !com_stricmp(ext, format->ext ))
{
com_sprintf (path, format->formatstring, loadname, "", format->ext );
f = FS_LoadFile( path, &filesize );
@ -1981,7 +1981,10 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize )
// this name will be used only for tell user about problems
FS_FileBase( path, texname );
if( format->loadfunc(texname, f, filesize ))
return ImagePack(); //loaded
{
Mem_Free(f); // release buffer
return ImagePack(); // loaded
}
}
}
}
@ -2004,6 +2007,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize )
if(FS_AddImageToPack(va("%s%s.%s", loadname, suf[i], format->ext)))
break; // loaded
}
Mem_Free(f);
}
}
}
@ -2028,7 +2032,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize )
for (format = load_formats; format->formatstring; format++)
{
if(anyformat || !stricmp(ext, format->ext ))
if(anyformat || !com_stricmp(ext, format->ext ))
{
if(buffer && buffsize > 0)
{

File diff suppressed because it is too large Load Diff

View File

@ -98,7 +98,6 @@ void Sys_GetStdAPI( void )
com.Com_ParseToken = SC_ParseToken; // parse token from char buffer
com.Com_ParseWord = SC_ParseWord; // parse word from char buffer
com.Com_Search = FS_Search; // returned list of founded files
com.Com_SearchLump = FS_SearchLump; // returned list of founded images in wadfile
com.Com_Filter = SC_FilterToken; // compare keyword by mask with filter
com.com_token = token; // contains current token
@ -293,11 +292,11 @@ void Sys_LookupInstance( void )
com_sprintf(Sys.log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file
com_strcpy(Sys.caption, "Xash3D Studio Models Compiler");
}
else if(!com_strcmp(Sys.progname, "paklib"))
else if(!com_strcmp(Sys.progname, "wadlib"))
{
Sys.app_name = PAKLIB;
Sys.app_name = WADLIB;
Sys.linked_dll = &common_dll; // pointer to common.dll info
com_sprintf(Sys.log_path, "%s/paklib.log", sys_rootdir ); // same as .exe file
com_sprintf(Sys.log_path, "%s/wadlib.log", sys_rootdir ); // same as .exe file
com_strcpy(Sys.caption, "Xash3D Pak\\Pk3 maker");
}
else if(!com_strcmp(Sys.progname, "credits")) // easter egg
@ -341,7 +340,7 @@ void Sys_CreateInstance( void )
case IMGLIB:
case SPRITE:
case STUDIO:
case PAKLIB:
case WADLIB:
CreateHost = (void *)Sys.linked_dll->main;
Host = CreateHost( &com, NULL ); // second interface not allowed
Sys.Init = Host->Init;
@ -358,7 +357,7 @@ void Sys_CreateInstance( void )
Sys_Exit();
break;
case HOST_OFFLINE:
Sys_Break("Host offline\n Press \"ESC\" to exit\n");
Sys_Break("Host offline\n");
break;
}
@ -384,7 +383,7 @@ void Sys_CreateInstance( void )
case IMGLIB:
case SPRITE:
case STUDIO:
case PAKLIB:
case WADLIB:
// always run stuffcmds for current instances
Cbuf_ExecuteText( EXEC_NOW, "stuffcmds\n" );
break;

View File

@ -248,7 +248,6 @@ void FS_FreeImage( rgbdata_t *pack );
bool Image_Processing( const char *name, rgbdata_t **pix );
search_t *FS_Search(const char *pattern, int caseinsensitive );
search_t *FS_SearchDirs(const char *pattern, int caseinsensitive );
search_t *FS_SearchLump( const char *pattern, int caseinsensitive );
// files managment (like fopen, fread etc)
file_t *FS_Open (const char* filepath, const char* mode );

View File

@ -7,13 +7,13 @@
!include <win32.mak>
MAINTARGET = paklib
MAINTARGET = wadlib
OBJS = $(MAINTARGET).obj
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj
$(link) $(OBJS) /out:"paklib.exe" /subsystem:console /opt:nowin98 /nodefaultlib:"libc.lib"
$(link) $(OBJS) /out:"wadlib.exe" /subsystem:console /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
@del $(MAINTARGET).exe

View File

@ -4,4 +4,4 @@
#include "../rundll.h"
Run( paklib );
Run( wadlib );

View File

@ -25,7 +25,7 @@ cd install
makefile.nmake
cd ..
cd paklib
cd wadlib
makefile.nmake
cd ..

View File

@ -138,7 +138,7 @@ enum host_state
ROQLIB, // "roqlib"
SPRITE, // "sprite"
STUDIO, // "studio"
PAKLIB, // "paklib"
WADLIB, // "wadlib"
CREDITS, // "splash"
HOST_INSTALL, // "install"
};

View File

@ -92,7 +92,6 @@ typedef struct stdilib_api_s
char *(*Com_ParseToken)(const char **data ); // parse token from char buffer
char *(*Com_ParseWord)( const char **data ); // parse word from char buffer
search_t *(*Com_Search)(const char *pattern, int casecmp ); // returned list of found files
search_t *(*Com_SearchLump)(const char *pat, int casecmp ); // returned list of found lumps in wad files
bool (*Com_Filter)(char *filter, char *name, int casecmp ); // compare keyword by mask with filter
char *com_token; // contains current token
@ -253,7 +252,6 @@ filesystem manager
#define FS_InitRootDir com.Com_InitRootDir
#define FS_LoadFile com.Com_LoadFile
#define FS_Search com.Com_Search
#define FS_SearchLump com.Com_SearchLump
#define FS_WriteFile com.Com_WriteFile
#define FS_Open( path, mode ) com.fopen( path, mode )
#define FS_Read( file, buffer, size ) com.fread( file, buffer, size )

View File

@ -1569,19 +1569,35 @@ typedef struct mip_s
/*
========================================================================
.WAD archive format (WhereAllData - WAD) Half-Life textures
.WAD archive format (WhereAllData - WAD)
========================================================================
*/
#define IDIWADHEADER (('D'<<24)+('A'<<16)+('W'<<8)+'I') // little-endian "IWAD" doom1 game wad
#define IDPWADHEADER (('D'<<24)+('A'<<16)+('W'<<8)+'P') // little-endian "PWAD" doom1 game wad
#define IDWAD2HEADER (('2'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD2" quake1 gfx.wad
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD3" half-life wads
#define WAD3_NAMELEN 16
#define TYPE_QPAL 64
#define CMP_NONE 0 // compression none
#define CMP_LZSS 1 // RLE compression ?
#define CMP_ZLIB 2 // zip-archive compression
#define TYPE_NONE 0 // blank lump
#define TYPE_QPAL 64 // quake palette
#define TYPE_QTEX 65 // probably was never used
#define TYPE_QPIC 66 // quake1 and hl pic (lmp_t)
#define TYPE_MIPTEX2 67 // half-life (mip_t) previous TYP_SOUND but never used in quake1
#define TYPE_MIPTEX 68 // quake1 (mip_t)
#define TYPE_RAW 69 // raw data
#define TYPE_QFONT 70 // half-life font (qfont_t)
#define TYPE_MIPDDS 71 // Xash3D dds texture
#define TYPE_MIPTGA 72 // Xash3D tga texture
#define TYPE_VPROGS 73 // Xash3D QC progs
#define TYPE_SCRIPT 74 // txt script file (e.g. shader)
#define TYPE_STUDIO 75 // studio models
#define TYPE_SPRITE 76 // normal sprite
#define TYPE_SOUND 77 // wav data
#define QCHAR_WIDTH 16
#define QFONT_WIDTH 16 // valve fonts used contant sizes
@ -1625,20 +1641,6 @@ typedef struct
/*
========================================================================
.FLAT image format (Doom I\II textures)
========================================================================
*/
typedef struct flat_s
{
short width;
short height;
long desc; // image desc (not used)
} flat_t;
/*
========================================================================
.TGA image format (Truevision Targa)
========================================================================

View File

@ -22,6 +22,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.h>
#include "gl_local.h"
/*
==================
R_CreateNoTexture
Quake3 style notexture
==================
*/
static void R_CreateNoTexture( void )
{
int x;
byte data[16][16][4];
rgbdata_t r_tex;
// the default image will be a box, to allow you to see the mapping coordinates
memset( data, 32, sizeof(data));
memset(&r_tex, 0, sizeof(r_tex));
for ( x = 0; x < 16; x++ )
{
data[0][x][0] = data[0][x][1] = data[0][x][2] = data[0][x][3] = 255;
data[x][0][0] = data[x][0][1] = data[x][0][2] = data[x][0][3] = 255;
data[15][x][0] = data[15][x][1] = data[15][x][2] = data[15][x][3] = 255;
data[x][15][0] = data[x][15][1] = data[x][15][2] = data[x][15][3] = 255;
}
r_tex.width = 16;
r_tex.height = 16;
r_tex.type = PF_RGBA_GN; // generated
r_tex.size = r_tex.width * r_tex.height * 4;
r_tex.numMips = 1;
r_tex.buffer = (byte *)data;
r_notexture = R_LoadImage("*r_notexture", &r_tex, it_wall );
}
/*
==================
R_InitParticleTexture

File diff suppressed because it is too large Load Diff