11 Sep 2010
This commit is contained in:
parent
195a6c7ea7
commit
9835598587
|
@ -1,3 +1,9 @@
|
|||
build ????
|
||||
|
||||
Launch: code revision, remove dead code, implement some missed functions
|
||||
Sound: fix some errors and crash
|
||||
Sound: implement music volume
|
||||
|
||||
build 1305
|
||||
|
||||
Engine: implement bit-stream network buffer
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: client - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
client.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,6 +1,6 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2010 ©
|
||||
// bmodel_ref.h - BSP format included q1, hl1 support
|
||||
// bspfile.h - BSP format included q1, hl1 support
|
||||
//=======================================================================
|
||||
#ifndef BSPFILE_H
|
||||
#define BSPFILE_H
|
||||
|
|
|
@ -121,7 +121,7 @@ typedef struct ui_enginefuncs_s
|
|||
// collect info from engine
|
||||
int (*pfnGetGameInfo)( GAMEINFO *pgameinfo );
|
||||
GAMEINFO **(*pfnGetGamesList)( int *numGames ); // collect info about all mods
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles ); // find in files
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); // find in files
|
||||
char **(*pfnGetVideoList)( int *numRenders );
|
||||
char **(*pfnGetAudioList)( int *numRenders );
|
||||
int (*pfnGetSaveComment)( const char *savename, char *comment );
|
||||
|
@ -129,7 +129,7 @@ typedef struct ui_enginefuncs_s
|
|||
char *(*pfnGetClipboardData)( void );
|
||||
|
||||
// engine launcher
|
||||
void (*pfnShellExecute)( const char *name, const char *args, bool closeEngine );
|
||||
void (*pfnShellExecute)( const char *name, const char *args, int closeEngine );
|
||||
void (*pfnWriteServerConfig)( const char *name );
|
||||
void (*pfnChangeInstance)( const char *newInstance, const char *szFinalMessage );
|
||||
void (*pfnChangeVideo)( const char *dllName );
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2008 ©
|
||||
// movie.h - RoQ video format
|
||||
//=======================================================================
|
||||
#ifndef MOVIE_H
|
||||
#define MOVIE_H
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
ROQ FILES
|
||||
|
||||
The .roq file are vector-compressed movies
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
#define RoQ_HEADER1 4228
|
||||
#define RoQ_HEADER2 -1
|
||||
#define RoQ_HEADER3 30
|
||||
#define RoQ_FRAMERATE 30
|
||||
|
||||
// RoQ markers
|
||||
#define RoQ_INFO 0x1001
|
||||
#define RoQ_QUAD_CODEBOOK 0x1002
|
||||
#define RoQ_QUAD_VQ 0x1011
|
||||
#define RoQ_SOUND_MONO 0x1020
|
||||
#define RoQ_SOUND_STEREO 0x1021
|
||||
|
||||
// RoQ movie type
|
||||
#define RoQ_ID_MOT 0x00
|
||||
#define RoQ_ID_FCC 0x01
|
||||
#define RoQ_ID_SLD 0x02
|
||||
#define RoQ_ID_CCC 0x03
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte y[4];
|
||||
byte u, v;
|
||||
} dcell_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte idx[4];
|
||||
} dquadcell_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short id;
|
||||
unsigned int size;
|
||||
unsigned short argument;
|
||||
} droqchunk_t;
|
||||
|
||||
#endif//REF_DFILES_H
|
|
@ -0,0 +1,35 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2010 ©
|
||||
// qfont.h - Quake font width variable widths
|
||||
//=======================================================================
|
||||
#ifndef QFONT_H
|
||||
#define QFONT_H
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.QFONT image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
#define QCHAR_WIDTH 16
|
||||
#define QFONT_WIDTH 16 // valve fonts used contant sizes
|
||||
#define QFONT_HEIGHT ((128 - 32) / 16)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short startoffset;
|
||||
short charwidth;
|
||||
} charset_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int rowcount;
|
||||
int rowheight;
|
||||
charset_t fontinfo[256];
|
||||
byte data[4]; // variable sized
|
||||
} qfont_t;
|
||||
|
||||
#endif//QFONT_H
|
|
@ -0,0 +1,92 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2008 ©
|
||||
// sprite.h - sprite model reference
|
||||
//=======================================================================
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
SPRITE MODELS
|
||||
|
||||
.spr extended version (Half-Life compatible sprites with some Xash3D extensions)
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I') // little-endian "IDSP"
|
||||
#define SPRITE_VERSION 2 // Half-Life sprites
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ST_SYNC = 0,
|
||||
ST_RAND
|
||||
} synctype_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FRAME_SINGLE = 0,
|
||||
FRAME_GROUP,
|
||||
FRAME_ANGLED // Xash3D ext
|
||||
} frametype_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPR_NORMAL = 0,
|
||||
SPR_ADDITIVE,
|
||||
SPR_INDEXALPHA,
|
||||
SPR_ALPHTEST,
|
||||
SPR_ADDGLOW // Xash3D ext
|
||||
} drawtype_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPR_FWD_PARALLEL_UPRIGHT = 0,
|
||||
SPR_FACING_UPRIGHT,
|
||||
SPR_FWD_PARALLEL,
|
||||
SPR_ORIENTED,
|
||||
SPR_FWD_PARALLEL_ORIENTED,
|
||||
} angletype_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPR_CULL_FRONT = 0, // oriented sprite will be draw with one face
|
||||
SPR_CULL_NONE, // oriented sprite will be draw back face too
|
||||
} facetype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ident; // LittleLong 'ISPR'
|
||||
int version; // current version 2
|
||||
angletype_t type; // camera align
|
||||
drawtype_t texFormat; // rendering mode
|
||||
int boundingradius; // quick face culling
|
||||
int bounds[2]; // mins\maxs
|
||||
int numframes; // including groups
|
||||
facetype_t facetype; // cullface (Xash3D ext)
|
||||
synctype_t synctype; // animation synctype
|
||||
} dsprite_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int origin[2];
|
||||
int width;
|
||||
int height;
|
||||
} dspriteframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int numframes;
|
||||
} dspritegroup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float interval;
|
||||
} dspriteinterval_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
frametype_t type;
|
||||
} dframetype_t;
|
||||
|
||||
#endif//SPRITE_H
|
|
@ -329,7 +329,7 @@ typedef struct
|
|||
int normindex; // normal vec3_t
|
||||
} mstudiomesh_t;
|
||||
|
||||
typedef struct
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
void *data;
|
||||
} cache_user_t;
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2010 ©
|
||||
// wadfile.h - WAD3 format (texture container)
|
||||
//=======================================================================
|
||||
#ifndef WADFILE_H
|
||||
#define WADFILE_H
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
.WAD archive format (WhereAllData - WAD)
|
||||
|
||||
List of compressed files, that can be identify only by TYPE_*
|
||||
|
||||
<format>
|
||||
header: dwadinfo_t[dwadinfo_t]
|
||||
file_1: byte[dwadinfo_t[num]->disksize]
|
||||
file_2: byte[dwadinfo_t[num]->disksize]
|
||||
file_3: byte[dwadinfo_t[num]->disksize]
|
||||
...
|
||||
file_n: byte[dwadinfo_t[num]->disksize]
|
||||
infotable dlumpinfo_t[dwadinfo_t->numlumps]
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W')
|
||||
|
||||
// dlumpinfo_t->compression
|
||||
#define CMP_NONE 0 // compression none
|
||||
#define CMP_LZSS 1 // LZSS compression
|
||||
|
||||
// dlumpinfo_t->type
|
||||
#define TYP_QPAL 64 // quake palette
|
||||
#define TYP_QTEX 65 // probably was never used
|
||||
#define TYP_QPIC 66 // quake1 and hl pic (lmp_t)
|
||||
#define TYP_MIPTEX 67 // half-life (mip_t) previous was TYP_SOUND but never used in quake1
|
||||
#define TYP_QMIP 68 // quake1 (mip_t) (replaced with TYPE_MIPTEX while loading)
|
||||
#define TYP_RAW 69 // raw data
|
||||
#define TYP_QFONT 70 // half-life font (qfont_t)
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.LMP image format (Half-Life gfx.wad lumps)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct lmp_s
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
} lmp_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.MIP image format (half-Life textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct mip_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int offsets[4]; // four mip maps stored
|
||||
} mip_t;
|
||||
|
||||
#endif//WADFILE_H
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: hl - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
hl.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -156,8 +156,7 @@ void CRpgRocket :: Spawn( void )
|
|||
pev->velocity = gpGlobals->v_forward * 250;
|
||||
pev->gravity = 0.5;
|
||||
|
||||
if( RANDOM_LONG( 0, 1 ))
|
||||
pev->nextthink = gpGlobals->time + 0.4;
|
||||
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.3, 0.5 );
|
||||
|
||||
pev->dmg = gSkillData.plrDmgRPG;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ void CL_LevelShot_f( void )
|
|||
|
||||
// check for exist
|
||||
com.sprintf( cls.shotname, "levelshots/%s.%s", cl.configstrings[CS_NAME], LEVELSHOT_TYPE );
|
||||
if( !FS_FileExists( va( "†%s", cls.shotname )))
|
||||
if( !FS_FileExistsEx( cls.shotname, true ))
|
||||
cls.scrshot_action = scrshot_plaque; // build new frame for levelshot
|
||||
else cls.scrshot_action = scrshot_inactive; // disable - not needs
|
||||
}
|
||||
|
|
|
@ -554,15 +554,15 @@ void CL_PlayDemo_f( void )
|
|||
CL_Disconnect();
|
||||
Host_ShutdownServer();
|
||||
|
||||
com.snprintf( filename, MAX_STRING, "†demos/%s.dem", Cmd_Argv( 1 ));
|
||||
if(!FS_FileExists( filename ))
|
||||
com.snprintf( filename, sizeof( filename ), "demos/%s.dem", Cmd_Argv( 1 ));
|
||||
if( !FS_FileExistsEx( filename, true ))
|
||||
{
|
||||
MsgDev( D_ERROR, "couldn't open %s\n", filename );
|
||||
cls.demonum = -1; // stop demo loop
|
||||
return;
|
||||
}
|
||||
|
||||
cls.demofile = FS_Open( filename, "rb" );
|
||||
cls.demofile = FS_OpenEx( filename, "rb", true );
|
||||
com.strncpy( cls.demoname, Cmd_Argv( 1 ), sizeof( cls.demoname ));
|
||||
com.strncpy( gameui.globals->demoname, Cmd_Argv( 1 ), sizeof( gameui.globals->demoname ));
|
||||
|
||||
|
|
|
@ -635,13 +635,13 @@ pfnGetFilesList
|
|||
release prev search on a next call
|
||||
=========
|
||||
*/
|
||||
static char **pfnGetFilesList( const char *pattern, int *numFiles )
|
||||
static char **pfnGetFilesList( const char *pattern, int *numFiles, int gamedironly )
|
||||
{
|
||||
static search_t *t = NULL;
|
||||
|
||||
if( t ) Mem_Free( t ); // release prev search
|
||||
|
||||
t = FS_Search( pattern, true );
|
||||
t = FS_SearchExt( pattern, true, gamedironly );
|
||||
if( !t )
|
||||
{
|
||||
if( numFiles ) *numFiles = 0;
|
||||
|
|
|
@ -569,7 +569,7 @@ void CL_ParseServerData( sizebuf_t *msg )
|
|||
if( cl_allow_levelshots->integer && !cls.changelevel )
|
||||
{
|
||||
// FIXME: Quake3 may be use both 'jpg' and 'tga' levelshot types
|
||||
if( !FS_FileExists( va( "†%s.%s", cl_levelshot_name->string, SI->levshot_ext )))
|
||||
if( !FS_FileExistsEx( va( "%s.%s", cl_levelshot_name->string, SI->levshot_ext ), true ))
|
||||
{
|
||||
Cvar_Set( "cl_levelshot_name", MAP_DEFAULT_SHADER ); // render a black screen
|
||||
cls.scrshot_request = scrshot_plaque; // make levelshot
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "common.h"
|
||||
#include "client.h"
|
||||
#include "byteorder.h"
|
||||
#include "qfont.h"
|
||||
|
||||
cvar_t *scr_viewsize;
|
||||
cvar_t *scr_centertime;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "r_efx.h"
|
||||
#include "event_flags.h"
|
||||
#include "entity_types.h"
|
||||
#include "studio.h"
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include "launch_api.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "engine_api.h"
|
||||
#include "render_api.h"
|
||||
#include "vsound_api.h"
|
||||
|
@ -191,7 +190,7 @@ long pfnRandomLong( long lLow, long lHigh );
|
|||
float pfnRandomFloat( float flLow, float flHigh );
|
||||
void pfnAddCommand( const char *cmd_name, xcommand_t func, const char *cmd_desc );
|
||||
void pfnDelCommand( const char *cmd_name );
|
||||
void *Cache_Check( byte *mempool, cache_user_t *c );
|
||||
void *Cache_Check( byte *mempool, struct cache_user_s *c );
|
||||
void pfnGetGameDir( char *szGetGameDir );
|
||||
const char *pfnCmd_Args( void );
|
||||
const char *pfnCmd_Argv( int argc );
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "cm_local.h"
|
||||
#include "sprite.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "studio.h"
|
||||
#include "wadfile.h"
|
||||
#include "const.h"
|
||||
|
||||
clipmap_t cm;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "cm_local.h"
|
||||
#include "studio.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "edict.h"
|
||||
|
|
|
@ -214,7 +214,7 @@ bool Cmd_GetDemoList( const char *s, char *completedname, int length )
|
|||
string matchbuf;
|
||||
int i, numdems;
|
||||
|
||||
t = FS_Search( va( "†demos/%s*.dem", s ), true );
|
||||
t = FS_SearchExt( va( "demos/%s*.dem", s ), true, true ); // lookup only in gamedir
|
||||
if( !t ) return false;
|
||||
|
||||
FS_FileBase( t->filenames[0], matchbuf );
|
||||
|
@ -348,7 +348,7 @@ bool Cmd_GetSavesList( const char *s, char *completedname, int length )
|
|||
string matchbuf;
|
||||
int i, numsaves;
|
||||
|
||||
t = FS_Search( va( "†save/%s*.sav", s ), true );
|
||||
t = FS_SearchExt( va( "save/%s*.sav", s ), true, true ); // lookup only in gamedir
|
||||
if( !t ) return false;
|
||||
|
||||
FS_FileBase( t->filenames[0], matchbuf );
|
||||
|
@ -663,10 +663,10 @@ bool Cmd_CheckMapsList( bool fRefresh )
|
|||
file_t *f;
|
||||
int i;
|
||||
|
||||
if( FS_FileExists( "†maps.lst" ) && !fRefresh )
|
||||
if( FS_FileExistsEx( "maps.lst", true ) && !fRefresh )
|
||||
return true; // exist
|
||||
|
||||
t = FS_Search( "maps/*.bsp", false );
|
||||
t = FS_SearchExt( "maps/*.bsp", false, true );
|
||||
if( !t ) return false;
|
||||
|
||||
buffer = Mem_Alloc( host.mempool, t->numfilenames * 2 * sizeof( result ));
|
||||
|
@ -678,7 +678,7 @@ bool Cmd_CheckMapsList( bool fRefresh )
|
|||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( com.stricmp( ext, "bsp" )) continue;
|
||||
f = FS_Open( t->filenames[i], "rb" );
|
||||
f = FS_OpenEx( t->filenames[i], "rb", true );
|
||||
FS_FileBase( t->filenames[i], mapname );
|
||||
|
||||
if( f )
|
||||
|
@ -756,8 +756,6 @@ bool Cmd_CheckMapsList( bool fRefresh )
|
|||
|
||||
if( f ) FS_Close( f );
|
||||
|
||||
|
||||
Msg( "spawnpoints %i\n", num_spawnpoints );
|
||||
if( num_spawnpoints > 1 )
|
||||
{
|
||||
// format: mapname "maptitle"\n
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "protocol.h" // get the protocol version
|
||||
#include "byteorder.h"
|
||||
#include "con_nprint.h"
|
||||
#include "qfont.h"
|
||||
|
||||
cvar_t *con_notifytime;
|
||||
cvar_t *scr_conspeed;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "studio.h"
|
||||
#include "byteorder.h"
|
||||
#include "mathlib.h"
|
||||
#include "const.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "studio.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "pm_local.h"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: engine - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
engine.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -5,6 +5,12 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
// main DLL entry point
|
||||
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Engine entry point
|
||||
|
|
|
@ -71,7 +71,7 @@ void Host_EndGame( const char *message, ... )
|
|||
static char string[MAX_SYSPATH];
|
||||
|
||||
va_start( argptr, message );
|
||||
vsprintf( string, message, argptr );
|
||||
com.vsprintf( string, message, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
MsgDev( D_INFO, "Host_EndGame: %s\n", string );
|
||||
|
|
|
@ -437,7 +437,7 @@ void SV_ClearSaveDir( void )
|
|||
int i;
|
||||
|
||||
// just delete all HL? files
|
||||
t = FS_Search( "†save/*.HL?", true );
|
||||
t = FS_SearchExt( "save/*.HL?", true, true ); // lookup only in gamedir
|
||||
if( !t ) return; // already empty
|
||||
|
||||
for( i = 0; i < t->numfilenames; i++ )
|
||||
|
@ -699,10 +699,10 @@ SAVERESTOREDATA *SV_LoadSaveData( const char *level )
|
|||
char *pszTokenList;
|
||||
int i, id, size, version;
|
||||
|
||||
com.snprintf( name, sizeof( name ), "†save/%s.HL1", level );
|
||||
com.snprintf( name, sizeof( name ), "save/%s.HL1", level );
|
||||
MsgDev( D_INFO, "Loading game from %s...\n", name + 1 );
|
||||
|
||||
pFile = FS_Open( name, "rb" );
|
||||
pFile = FS_OpenEx( name, "rb", true );
|
||||
if( !pFile )
|
||||
{
|
||||
MsgDev( D_INFO, "ERROR: couldn't open.\n" );
|
||||
|
@ -871,9 +871,9 @@ void SV_EntityPatchRead( SAVERESTOREDATA *pSaveData, const char *level )
|
|||
file_t *pFile;
|
||||
int i, size, entityId;
|
||||
|
||||
com.snprintf( name, sizeof( name ), "†save/%s.HL3", level );
|
||||
com.snprintf( name, sizeof( name ), "save/%s.HL3", level );
|
||||
|
||||
pFile = FS_Open( name, "rb" );
|
||||
pFile = FS_OpenEx( name, "rb", true );
|
||||
if( !pFile ) return;
|
||||
|
||||
// patch count
|
||||
|
@ -962,9 +962,9 @@ void SV_LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, bool adj
|
|||
decallist_t *decalList;
|
||||
int decalCount;
|
||||
|
||||
com.snprintf( name, sizeof( name ), "†save/%s.HL2", level );
|
||||
com.snprintf( name, sizeof( name ), "save/%s.HL2", level );
|
||||
|
||||
pFile = FS_Open( name, "rb" );
|
||||
pFile = FS_OpenEx( name, "rb", true );
|
||||
if( !pFile ) return;
|
||||
|
||||
FS_Read( pFile, &tag, sizeof( int ));
|
||||
|
@ -1501,7 +1501,7 @@ int SV_SaveGameSlot( const char *pSaveName, const char *pSaveComment )
|
|||
|
||||
pSaveData = SV_SaveInit( 0 );
|
||||
|
||||
com.strncpy( hlPath, "†save/*.HL?", sizeof( hlPath ));
|
||||
com.strncpy( hlPath, "save/*.HL?", sizeof( hlPath ));
|
||||
gameHeader.mapCount = SV_MapCount( hlPath );
|
||||
com.strncpy( gameHeader.mapName, sv.name, sizeof( gameHeader.mapName ));
|
||||
com.strncpy( gameHeader.comment, pSaveComment, sizeof( gameHeader.comment ));
|
||||
|
@ -1644,14 +1644,14 @@ bool SV_LoadGame( const char *pName )
|
|||
if( !pName || !pName[0] )
|
||||
return false;
|
||||
|
||||
com.snprintf( name, sizeof( name ), "†save/%s.sav", pName );
|
||||
com.snprintf( name, sizeof( name ), "save/%s.sav", pName );
|
||||
|
||||
MsgDev( D_INFO, "Loading game from %s...\n", name + 1 );
|
||||
SV_ClearSaveDir();
|
||||
|
||||
if( !svs.initialized ) SV_InitGame ();
|
||||
|
||||
pFile = FS_Open( name, "rb" );
|
||||
pFile = FS_OpenEx( name, "rb", true );
|
||||
|
||||
if( pFile )
|
||||
{
|
||||
|
@ -1763,7 +1763,7 @@ used for reload game after player death
|
|||
*/
|
||||
const char *SV_GetLatestSave( void )
|
||||
{
|
||||
search_t *f = FS_Search( "†save/*.sav", true );
|
||||
search_t *f = FS_SearchExt( "save/*.sav", true, true ); // lookup only in gamedir
|
||||
int i, found = 0;
|
||||
long newest = 0, ft;
|
||||
string savename;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
#include "studio.h"
|
||||
#include "matrix_lib.h"
|
||||
|
||||
static studiohdr_t *sv_studiohdr;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// first method: by filename, e.g. spirit.exe will be use basedir 'spirit', hostname must be "normal"
|
||||
// second method: by hostname with leading symbol '$'. e.g. hl.exe with hostname '$valve' set the basedir to 'valve'
|
||||
// for dedicated servers rename 'YourExeName.exe' to '#YourExeName.exe'
|
||||
// Keyword "normal" it's a reserved word which switch engine to game mode, other reserved words runs Xash Tools.
|
||||
// Keyword "normal" it's a reserved word which switch engine to game mode, other reserved words run Xash Tools.
|
||||
//
|
||||
// reserved words list:
|
||||
//
|
||||
|
@ -21,7 +21,7 @@
|
|||
// "ximage" - launch the image convertor
|
||||
//
|
||||
|
||||
#define GAME_PATH "$valve" // $ indicates a start of basefolder name
|
||||
#define GAME_PATH "$valve" // '$' indicates a start of basefolder name
|
||||
|
||||
typedef int (*pfnExecute)( const char *hostname, int console ); // engine entry point format
|
||||
|
||||
|
@ -44,7 +44,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
|
|||
|
||||
if(( mainFunc = (pfnExecute)GetProcAddress( hmain, "CreateAPI" )) == NULL )
|
||||
{
|
||||
Sys_Error( "Unable to find entry point in launch.dll" );
|
||||
Sys_Error( "Unable to find entry point in the launch.dll" );
|
||||
}
|
||||
|
||||
return mainFunc( GAME_PATH, false );
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: gameui - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
gameui.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -179,8 +179,7 @@ static void UI_CreateGame_GetMapsList( void )
|
|||
{
|
||||
char *afile;
|
||||
|
||||
// HACKHACK: symbol '†' allow lookup only gamedir not basedir
|
||||
if( !CHECK_MAP_LIST( FALSE ) || (afile = (char *)LOAD_FILE( "†maps.lst", NULL )) == NULL )
|
||||
if( !CHECK_MAP_LIST( FALSE ) || (afile = (char *)LOAD_FILE( "maps.lst", NULL )) == NULL )
|
||||
{
|
||||
uiCreateGame.done.generic.flags |= QMF_GRAYED;
|
||||
uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr;
|
||||
|
|
|
@ -130,7 +130,7 @@ static void UI_LoadGame_GetGameList( void )
|
|||
char **filenames;
|
||||
int i, numFiles;
|
||||
|
||||
filenames = FS_SEARCH( "†save/*.sav", &numFiles );
|
||||
filenames = FS_SEARCH( "save/*.sav", &numFiles, TRUE );
|
||||
|
||||
for ( i = 0; i < numFiles; i++ )
|
||||
{
|
||||
|
|
|
@ -131,7 +131,7 @@ static void UI_PlayDemo_GetDemoList( void )
|
|||
char **filenames;
|
||||
int i, numFiles;
|
||||
|
||||
filenames = FS_SEARCH( "†demos/*.dem", &numFiles );
|
||||
filenames = FS_SEARCH( "demos/*.dem", &numFiles, TRUE );
|
||||
|
||||
for( i = 0; i < numFiles; i++ )
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ static void UI_PlayerSetup_FindModels( void )
|
|||
uiPlayerSetup.num_models = 0;
|
||||
|
||||
// Get file list
|
||||
filenames = FS_SEARCH( "models/player/*", &numFiles );
|
||||
filenames = FS_SEARCH( "models/player/*", &numFiles, FALSE );
|
||||
|
||||
// add default singleplayer model
|
||||
strcpy( uiPlayerSetup.models[uiPlayerSetup.num_models], "player" );
|
||||
|
|
|
@ -131,7 +131,7 @@ static void UI_RecDemo_GetDemoList( void )
|
|||
char **filenames;
|
||||
int i = 0, j, numFiles;
|
||||
|
||||
filenames = FS_SEARCH( "†demos/*.dem", &numFiles );
|
||||
filenames = FS_SEARCH( "demos/*.dem", &numFiles, TRUE );
|
||||
|
||||
if ( CL_IsActive () && !gpGlobals->demorecording && !gpGlobals->demoplayback )
|
||||
{
|
||||
|
|
|
@ -131,7 +131,7 @@ static void UI_SaveGame_GetGameList( void )
|
|||
char **filenames;
|
||||
int i = 0, j, numFiles;
|
||||
|
||||
filenames = FS_SEARCH( "†save/*.sav", &numFiles );
|
||||
filenames = FS_SEARCH( "save/*.sav", &numFiles, TRUE );
|
||||
|
||||
if ( CL_IsActive() && !gpGlobals->demoplayback )
|
||||
{
|
||||
|
|
|
@ -66,10 +66,9 @@ Cbuf_InsertText
|
|||
|
||||
Adds command text immediately after the current command
|
||||
Adds a \n to the text
|
||||
FIXME: actually change the command buffer to do less copying
|
||||
============
|
||||
*/
|
||||
void Cbuf_InsertText (const char *text)
|
||||
void Cbuf_InsertText( const char *text )
|
||||
{
|
||||
int i, len;
|
||||
|
||||
|
@ -605,7 +604,7 @@ void Cmd_List_f( void )
|
|||
|
||||
for( cmd = cmd_functions; cmd; cmd = cmd->next )
|
||||
{
|
||||
if( match && !com_stricmpext( match, cmd->name ))
|
||||
if( match && !com.stricmpext( match, cmd->name ))
|
||||
continue;
|
||||
Msg( "%s\n", cmd->name );
|
||||
i++;
|
||||
|
|
|
@ -74,7 +74,7 @@ void Con_SetInputText( const char *inputText )
|
|||
if( Sys.con_readonly ) return;
|
||||
|
||||
SetWindowText( s_wcd.hwndInputLine, inputText );
|
||||
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, com_strlen( inputText ), -1 );
|
||||
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, com.strlen( inputText ), -1 );
|
||||
}
|
||||
|
||||
static int Con_KeyEvent( int key, bool down )
|
||||
|
@ -181,8 +181,8 @@ long _stdcall Con_InputLineProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||
if( wParam == 13 && Sys.app_state != SYS_ERROR )
|
||||
{
|
||||
GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ));
|
||||
com_strncat( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - com_strlen( s_wcd.consoleText ) - 5 );
|
||||
com_strcat( s_wcd.consoleText, "\n" );
|
||||
com.strncat( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - com.strlen( s_wcd.consoleText ) - 5 );
|
||||
com.strcat( s_wcd.consoleText, "\n" );
|
||||
SetWindowText( s_wcd.hwndInputLine, "" );
|
||||
Msg( ">%s\n", inputBuffer );
|
||||
|
||||
|
@ -216,7 +216,7 @@ void Con_PrintA( const char *pMsg )
|
|||
{
|
||||
DWORD cbWritten;
|
||||
|
||||
WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), pMsg, com_strlen( pMsg ), &cbWritten, 0 );
|
||||
WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), pMsg, com.strlen( pMsg ), &cbWritten, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -427,7 +427,7 @@ char *Sys_Input( void )
|
|||
if( s_wcd.consoleText[0] == 0 )
|
||||
return NULL;
|
||||
|
||||
com_strncpy( s_wcd.returnedText, s_wcd.consoleText, sizeof( s_wcd.returnedText ));
|
||||
com.strncpy( s_wcd.returnedText, s_wcd.consoleText, sizeof( s_wcd.returnedText ));
|
||||
s_wcd.consoleText[0] = 0;
|
||||
|
||||
return s_wcd.returnedText;
|
||||
|
@ -472,7 +472,7 @@ void Sys_InitLog( void )
|
|||
if(!Sys.logfile) MsgDev( D_ERROR, "Sys_InitLog: can't create log file %s\n", Sys.log_path );
|
||||
|
||||
fprintf( Sys.logfile, "=======================================================================\n" );
|
||||
fprintf( Sys.logfile, "\t%s started at %s\n", Sys.caption, com_timestamp( TIME_FULL ));
|
||||
fprintf( Sys.logfile, "\t%s started at %s\n", Sys.caption, com.timestamp( TIME_FULL ));
|
||||
fprintf( Sys.logfile, "=======================================================================\n");
|
||||
}
|
||||
}
|
||||
|
@ -484,18 +484,18 @@ void Sys_CloseLog( void )
|
|||
// continue logged
|
||||
switch( Sys.app_state )
|
||||
{
|
||||
case SYS_CRASH: com_strncpy( event_name, "crashed", sizeof( event_name )); break;
|
||||
case SYS_ABORT: com_strncpy( event_name, "aborted by user", sizeof( event_name )); break;
|
||||
case SYS_ERROR: com_strncpy( event_name, "stopped with error", sizeof( event_name )); break;
|
||||
case SYS_RESTART: com_strncpy( event_name, "restarted", sizeof( event_name )); break;
|
||||
default: com_strncpy( event_name, "stopped", sizeof( event_name )); break;
|
||||
case SYS_CRASH: com.strncpy( event_name, "crashed", sizeof( event_name )); break;
|
||||
case SYS_ABORT: com.strncpy( event_name, "aborted by user", sizeof( event_name )); break;
|
||||
case SYS_ERROR: com.strncpy( event_name, "stopped with error", sizeof( event_name )); break;
|
||||
case SYS_RESTART: com.strncpy( event_name, "restarted", sizeof( event_name )); break;
|
||||
default: com.strncpy( event_name, "stopped", sizeof( event_name )); break;
|
||||
}
|
||||
|
||||
if( Sys.logfile )
|
||||
{
|
||||
fprintf( Sys.logfile, "\n");
|
||||
fprintf( Sys.logfile, "=======================================================================");
|
||||
fprintf( Sys.logfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com_timestamp(TIME_FULL));
|
||||
fprintf( Sys.logfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com.timestamp(TIME_FULL));
|
||||
fprintf( Sys.logfile, "=======================================================================\n");
|
||||
if( Sys.app_state == SYS_RESTART ) fprintf( Sys.logfile, "\n" ); // just for tabulate
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ const char* GetProcessorVendorId()
|
|||
Mem_Set( VendorID, 0, sizeof( VendorID ));
|
||||
if( !vendor.retval )
|
||||
{
|
||||
com_strcpy( VendorID, "Generic_x86" );
|
||||
com.strcpy( VendorID, "Generic_x86" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -475,7 +475,7 @@ void Sys_InitCPU( void )
|
|||
szFrequencyDenomination = "Ghz";
|
||||
}
|
||||
|
||||
com_strcpy(szFeatureString, "" );
|
||||
com.strcpy(szFeatureString, "" );
|
||||
if( cpu.m_bMMX ) com.strcat( szFeatureString, "MMX " );
|
||||
if( cpu.m_b3DNow ) com.strcat( szFeatureString, "3DNow " );
|
||||
if( cpu.m_bSSE ) com.strcat( szFeatureString, "SSE " );
|
||||
|
@ -493,7 +493,7 @@ void Sys_InitCPU( void )
|
|||
{
|
||||
char buffer[256] = "";
|
||||
if( cpu.m_usNumPhysCore != cpu.m_usNumLogicCore )
|
||||
com_sprintf(buffer, " (%i physical)", (int) cpu.m_usNumPhysCore );
|
||||
com.sprintf(buffer, " (%i physical)", (int) cpu.m_usNumPhysCore );
|
||||
MsgDev(D_INFO, "CPU: %s [%i core's %s]. Frequency: %.01f %s\n ", cpu.m_szCPUID, (int)cpu.m_usNumLogicCore, buffer, fFrequency, szFrequencyDenomination );
|
||||
}
|
||||
MsgDev(D_NOTE, "CPU Features: %s\n", szFeatureString );
|
||||
|
|
|
@ -874,7 +874,7 @@ void Cvar_List_f( void )
|
|||
|
||||
for( var = cvar_vars; var; var = var->next, i++ )
|
||||
{
|
||||
if( match && !com_stricmpext( match, var->name ))
|
||||
if( match && !com.stricmpext( match, var->name ))
|
||||
continue;
|
||||
|
||||
if( var->flags & CVAR_SERVERINFO ) Msg( "SV " );
|
||||
|
@ -934,7 +934,7 @@ void Cvar_Restart_f( void )
|
|||
if( !var ) break;
|
||||
|
||||
// don't mess with rom values, or some inter-module
|
||||
// communication will get broken (com_cl_running, etc)
|
||||
// communication will get broken (cl.active, etc)
|
||||
if( var->flags & ( CVAR_READ_ONLY|CVAR_INIT|CVAR_RENDERINFO ))
|
||||
{
|
||||
prev = &var->next;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "launch.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "wadfile.h"
|
||||
#include "filesystem.h"
|
||||
#include "byteorder.h"
|
||||
#include "library.h"
|
||||
|
@ -56,7 +56,7 @@ typedef struct file_s
|
|||
// Contents buffer
|
||||
fs_offset_t buff_ind, buff_len; // buffer current index and length
|
||||
byte buff [FILE_BUFF_SIZE];
|
||||
ztoolkit_t* ztk; // For zipped files
|
||||
ztoolkit_t* ztk; // for zipped files
|
||||
};
|
||||
|
||||
typedef struct vfile_s
|
||||
|
@ -65,7 +65,6 @@ typedef struct vfile_s
|
|||
file_t *handle;
|
||||
int mode;
|
||||
|
||||
bool compress;
|
||||
fs_offset_t buffsize;
|
||||
fs_offset_t length;
|
||||
fs_offset_t offset;
|
||||
|
@ -116,7 +115,7 @@ searchpath_t fs_directpath; // static direct path
|
|||
|
||||
static void FS_InitMemory( void );
|
||||
const char *FS_FileExtension( const char *in );
|
||||
static searchpath_t *FS_FindFile( const char *name, int *index, bool quiet, bool gamedironly );
|
||||
static searchpath_t *FS_FindFile( const char *name, int *index, bool gamedironly );
|
||||
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype );
|
||||
static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack, fs_offset_t offset, fs_offset_t packsize, fs_offset_t realsize, int flags);
|
||||
static byte *W_LoadFile( const char *path, fs_offset_t *filesizeptr );
|
||||
|
@ -597,12 +596,12 @@ void FS_CreatePath( char *path )
|
|||
|
||||
for( ofs = path+1; *ofs; ofs++ )
|
||||
{
|
||||
if (*ofs == '/' || *ofs == '\\')
|
||||
if( *ofs == '/' || *ofs == '\\' )
|
||||
{
|
||||
// create the directory
|
||||
save = *ofs;
|
||||
*ofs = 0;
|
||||
_mkdir (path);
|
||||
_mkdir( path );
|
||||
*ofs = save;
|
||||
}
|
||||
}
|
||||
|
@ -1096,7 +1095,7 @@ void FS_AddGameDirectory( const char *dir, int flags )
|
|||
}
|
||||
|
||||
// use normal method because we want take access to wad files through pak or pk3 archives
|
||||
wads = FS_Search( "*.wad", true );
|
||||
wads = FS_Search( "*.wad", true, false );
|
||||
for( i = 0; wads && i < wads->numfilenames; i++ )
|
||||
FS_AddWad_Fullpath( wads->filenames[i], NULL, false );
|
||||
if( wads ) Mem_Free( wads );
|
||||
|
@ -1337,7 +1336,7 @@ static bool FS_WriteGameInfo( const char *filepath, gameinfo_t *GameInfo )
|
|||
int i;
|
||||
|
||||
if( !GameInfo ) return false;
|
||||
f = FS_Open( filepath, "w" ); // we in text-mode
|
||||
f = FS_Open( filepath, "w", false ); // we in binary-mode
|
||||
if( !f ) return false;
|
||||
|
||||
FS_Print( f, "// generated by Xash3D\r\r\n" );
|
||||
|
@ -1587,11 +1586,11 @@ static bool FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
|
|||
com.snprintf( filepath, sizeof( filepath ), "%s/gameinfo.txt", gamedir );
|
||||
com.snprintf( liblist, sizeof( liblist ), "%s/liblist.gam", gamedir );
|
||||
|
||||
if( !FS_FileExists( filepath ) && FS_FileExists( liblist ))
|
||||
if( !FS_FileExists( filepath, false ) && FS_FileExists( liblist, false ))
|
||||
FS_ConvertGameInfo( gamedir, filepath, liblist );
|
||||
|
||||
// force to create gameinfo for specified game if missing
|
||||
if( !com.stricmp( gs_basedir, gamedir ) && !FS_FileExists( filepath ))
|
||||
if( !com.stricmp( gs_basedir, gamedir ) && !FS_FileExists( filepath, false ))
|
||||
FS_CreateDefaultGameInfo( filepath );
|
||||
|
||||
if( !GameInfo ) return false; // no dest
|
||||
|
@ -2102,7 +2101,7 @@ Return the searchpath where the file was found (or NULL)
|
|||
and the file index in the package if relevant
|
||||
====================
|
||||
*/
|
||||
static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool gamedironly )
|
||||
static searchpath_t *FS_FindFile( const char *name, int* index, bool gamedironly )
|
||||
{
|
||||
searchpath_t *search;
|
||||
char *pEnvPath;
|
||||
|
@ -2134,7 +2133,6 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
// Found it
|
||||
if( !diff )
|
||||
{
|
||||
if( !quiet ) MsgDev( D_INFO, "FS_FindFile: %s in %s\n", pak->files[middle].name, pak->filename );
|
||||
if( index ) *index = middle;
|
||||
return search;
|
||||
}
|
||||
|
@ -2154,7 +2152,7 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
string shortname;
|
||||
|
||||
// quick reject by filetype
|
||||
if( type == TYPE_NONE ) continue;
|
||||
if( type == TYP_NONE ) continue;
|
||||
FS_ExtractFilePath( name, wadname );
|
||||
wadfolder[0] = '\0';
|
||||
|
||||
|
@ -2178,7 +2176,6 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
lump = W_FindLump( search->wad, shortname, type );
|
||||
if( lump )
|
||||
{
|
||||
if( !quiet ) MsgDev( D_INFO, "FS_FindFile: %s in %s\n", lump->name, search->wad->filename );
|
||||
if( index ) *index = lump - search->wad->lumps;
|
||||
return search;
|
||||
}
|
||||
|
@ -2189,7 +2186,6 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
com.sprintf( netpath, "%s%s", search->filename, name );
|
||||
if( FS_SysFileExists( netpath ))
|
||||
{
|
||||
if( !quiet ) MsgDev( D_INFO, "FS_FindFile: %s\n", netpath );
|
||||
if( index != NULL ) *index = -1;
|
||||
return search;
|
||||
}
|
||||
|
@ -2214,7 +2210,6 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
com.snprintf( netpath, MAX_SYSPATH, "%s%s", search->filename, name );
|
||||
if( FS_SysFileExists( netpath ))
|
||||
{
|
||||
if( !quiet ) MsgDev( D_INFO, "FS_FindFile: %s\n", netpath );
|
||||
if( index != NULL ) *index = -1;
|
||||
return search;
|
||||
}
|
||||
|
@ -2222,7 +2217,6 @@ static searchpath_t *FS_FindFile( const char *name, int* index, bool quiet, bool
|
|||
}
|
||||
}
|
||||
|
||||
if( !quiet ) MsgDev( D_WARN, "FS_FindFile: can't find %s\n", name );
|
||||
if( index != NULL ) *index = -1;
|
||||
|
||||
return NULL;
|
||||
|
@ -2236,19 +2230,12 @@ FS_OpenReadFile
|
|||
Look for a file in the search paths and open it in read-only mode
|
||||
===========
|
||||
*/
|
||||
file_t *FS_OpenReadFile( const char *filename, const char *mode, bool quiet )
|
||||
file_t *FS_OpenReadFile( const char *filename, const char *mode, bool gamedironly )
|
||||
{
|
||||
searchpath_t *search;
|
||||
bool gamedironly = false;
|
||||
int pack_ind;
|
||||
|
||||
if( filename[0] == '†' )
|
||||
{
|
||||
filename++;
|
||||
gamedironly = true;
|
||||
}
|
||||
|
||||
search = FS_FindFile( filename, &pack_ind, quiet, gamedironly );
|
||||
search = FS_FindFile( filename, &pack_ind, gamedironly );
|
||||
|
||||
// not found?
|
||||
if( search == NULL )
|
||||
|
@ -2282,7 +2269,7 @@ FS_Open
|
|||
Open a file. The syntax is the same as fopen
|
||||
====================
|
||||
*/
|
||||
file_t* _FS_Open( const char* filepath, const char* mode, bool quiet )
|
||||
file_t *FS_Open( const char *filepath, const char *mode, bool gamedironly )
|
||||
{
|
||||
if( Sys.app_name == HOST_NORMAL || Sys.app_name == HOST_DEDICATED || Sys.app_name == HOST_BSPLIB )
|
||||
{
|
||||
|
@ -2308,12 +2295,7 @@ file_t* _FS_Open( const char* filepath, const char* mode, bool quiet )
|
|||
}
|
||||
|
||||
// else, we look at the various search paths and open the file in read-only mode
|
||||
return FS_OpenReadFile( filepath, mode, quiet );
|
||||
}
|
||||
|
||||
file_t* FS_Open( const char* filepath, const char* mode )
|
||||
{
|
||||
return _FS_Open( filepath, mode, true );
|
||||
return FS_OpenReadFile( filepath, mode, gamedironly );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2806,7 +2788,8 @@ byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr )
|
|||
fs_offset_t filesize = 0;
|
||||
const char *ext = FS_FileExtension( path );
|
||||
|
||||
file = _FS_Open( path, "rb", true );
|
||||
file = FS_Open( path, "rb", false );
|
||||
|
||||
if( file )
|
||||
{
|
||||
filesize = file->real_length;
|
||||
|
@ -2833,8 +2816,9 @@ bool FS_WriteFile( const char *filename, const void *data, fs_offset_t len )
|
|||
{
|
||||
file_t *file;
|
||||
|
||||
file = _FS_Open( filename, "wb", false );
|
||||
if (!file)
|
||||
file = FS_Open( filename, "wb", false );
|
||||
|
||||
if( !file )
|
||||
{
|
||||
MsgDev( D_ERROR, "FS_WriteFile: failed on %s\n", filename);
|
||||
return false;
|
||||
|
@ -2902,17 +2886,9 @@ FS_FileExists
|
|||
Look for a file in the packages and in the filesystem
|
||||
==================
|
||||
*/
|
||||
bool FS_FileExists( const char *filename )
|
||||
bool FS_FileExists( const char *filename, bool gamedironly )
|
||||
{
|
||||
bool gamedironly = false;
|
||||
|
||||
if( filename[0] == '†' )
|
||||
{
|
||||
filename++;
|
||||
gamedironly = true;
|
||||
}
|
||||
|
||||
if( FS_FindFile( filename, NULL, true, gamedironly ))
|
||||
if( FS_FindFile( filename, NULL, gamedironly ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -2943,7 +2919,7 @@ dll_user_t *FS_FindLibrary( const char *dllname, bool directpath )
|
|||
else com.strncpy( dllpath, dllname, sizeof( dllpath ));
|
||||
FS_DefaultExtension( dllpath, ".dll" ); // trying to apply if forget
|
||||
|
||||
search = FS_FindFile( dllpath, &index, true, false );
|
||||
search = FS_FindFile( dllpath, &index, false );
|
||||
if( !search )
|
||||
{
|
||||
fs_ext_path = false;
|
||||
|
@ -2951,7 +2927,7 @@ dll_user_t *FS_FindLibrary( const char *dllname, bool directpath )
|
|||
|
||||
// trying check also 'bin' folder for indirect paths
|
||||
com.strncpy( dllpath, dllname, sizeof( dllpath ));
|
||||
search = FS_FindFile( dllpath, &index, true, false );
|
||||
search = FS_FindFile( dllpath, &index, false );
|
||||
if( !search ) return NULL; // unable to find
|
||||
}
|
||||
|
||||
|
@ -2986,12 +2962,12 @@ FS_FileSize
|
|||
return size of file in bytes
|
||||
==================
|
||||
*/
|
||||
fs_offset_t FS_FileSize (const char *filename)
|
||||
fs_offset_t FS_FileSize( const char *filename, bool gamedironly )
|
||||
{
|
||||
file_t *fp;
|
||||
int length = 0;
|
||||
|
||||
fp = _FS_Open( filename, "rb", true );
|
||||
fp = FS_Open( filename, "rb", gamedironly );
|
||||
|
||||
if( fp )
|
||||
{
|
||||
|
@ -3010,12 +2986,12 @@ FS_FileTime
|
|||
return time of creation file in seconds
|
||||
==================
|
||||
*/
|
||||
fs_offset_t FS_FileTime( const char *filename )
|
||||
fs_offset_t FS_FileTime( const char *filename, bool gamedironly )
|
||||
{
|
||||
searchpath_t *search;
|
||||
int pack_ind;
|
||||
|
||||
search = FS_FindFile( filename, &pack_ind, true, false );
|
||||
search = FS_FindFile( filename, &pack_ind, gamedironly );
|
||||
if( !search ) return -1; // doesn't exist
|
||||
|
||||
if( search->pack ) // grab pack filetime
|
||||
|
@ -3048,8 +3024,8 @@ bool FS_Rename( const char *oldname, const char *newname )
|
|||
if( !oldname || !newname || !*oldname || !*newname )
|
||||
return false;
|
||||
|
||||
com_snprintf( oldpath, sizeof( oldpath ), "%s/%s", fs_gamedir, oldname );
|
||||
com_snprintf( newpath, sizeof( newpath ), "%s/%s", fs_gamedir, newname );
|
||||
com.snprintf( oldpath, sizeof( oldpath ), "%s/%s", fs_gamedir, oldname );
|
||||
com.snprintf( newpath, sizeof( newpath ), "%s/%s", fs_gamedir, newname );
|
||||
|
||||
iRet = rename( oldpath, newpath );
|
||||
|
||||
|
@ -3071,7 +3047,7 @@ bool FS_Delete( const char *path )
|
|||
if( !path || !*path )
|
||||
return false;
|
||||
|
||||
com_snprintf( real_path, sizeof( real_path ), "%s/%s", fs_gamedir, path );
|
||||
com.snprintf( real_path, sizeof( real_path ), "%s/%s", fs_gamedir, path );
|
||||
iRet = remove( real_path );
|
||||
|
||||
return iRet;
|
||||
|
@ -3084,13 +3060,12 @@ FS_Search
|
|||
Allocate and fill a search structure with information on matching filenames.
|
||||
===========
|
||||
*/
|
||||
static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet )
|
||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
{
|
||||
search_t *search = NULL;
|
||||
searchpath_t *searchpath;
|
||||
pack_t *pak;
|
||||
wfile_t *wad;
|
||||
bool gamedironly = false;
|
||||
int i, basepathlength, numfiles, numchars;
|
||||
int resultlistindex, dirlistindex;
|
||||
const char *slash, *backslash, *colon, *separator;
|
||||
|
@ -3107,12 +3082,6 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if( pattern[0] == '†' )
|
||||
{
|
||||
gamedironly = true;
|
||||
pattern++; // ignore this symbol
|
||||
}
|
||||
|
||||
stringlistinit( &resultlist );
|
||||
stringlistinit( &dirlist );
|
||||
slash = com.strrchr( pattern, '/' );
|
||||
|
@ -3148,10 +3117,10 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
if( !com.strcmp( resultlist.strings[resultlistindex], temp ))
|
||||
break;
|
||||
}
|
||||
|
||||
if( resultlistindex == resultlist.numstrings )
|
||||
{
|
||||
stringlistappend( &resultlist, temp );
|
||||
if( !quiet ) MsgDev( D_INFO, "SearchPackFile: %s : %s\n", pak->filename, temp );
|
||||
}
|
||||
}
|
||||
// strip off one path element at a time until empty
|
||||
|
@ -3178,7 +3147,7 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
string wadfolder;
|
||||
|
||||
// quick reject by filetype
|
||||
if( type == TYPE_NONE ) continue;
|
||||
if( type == TYP_NONE ) continue;
|
||||
FS_ExtractFilePath( pattern, wadname );
|
||||
FS_FileBase( pattern, wadpattern );
|
||||
wadfolder[0] = '\0';
|
||||
|
@ -3200,7 +3169,7 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
for( i = 0; i < wad->numlumps; i++ )
|
||||
{
|
||||
// if type not matching, we already no chance ...
|
||||
if( type != TYPE_ANY && wad->lumps[i].type != type )
|
||||
if( type != TYP_ANY && wad->lumps[i].type != type )
|
||||
continue;
|
||||
com.strncpy( temp, wad->lumps[i].name, sizeof( temp ));
|
||||
while( temp[0] )
|
||||
|
@ -3218,7 +3187,6 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
com.snprintf( temp2, sizeof(temp2), "%s/%s", wadfolder, temp );
|
||||
FS_DefaultExtension( temp2, va(".%s", W_ExtFromType( wad->lumps[i].type ))); // make ext
|
||||
stringlistappend( &resultlist, temp2 );
|
||||
if( !quiet ) MsgDev( D_INFO, "SearchWadFile: %s : %s\n", wad->filename, temp2 );
|
||||
}
|
||||
}
|
||||
// strip off one path element at a time until empty
|
||||
|
@ -3253,10 +3221,10 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
if( !com.strcmp( resultlist.strings[resultlistindex], temp ))
|
||||
break;
|
||||
}
|
||||
|
||||
if( resultlistindex == resultlist.numstrings )
|
||||
{
|
||||
stringlistappend( &resultlist, temp );
|
||||
if( !quiet ) MsgDev( D_INFO, "SearchDirFile: %s\n", temp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3294,16 +3262,6 @@ static search_t *_FS_Search( const char *pattern, int caseinsensitive, int quiet
|
|||
return search;
|
||||
}
|
||||
|
||||
search_t *FS_Search(const char *pattern, int caseinsensitive )
|
||||
{
|
||||
return _FS_Search( pattern, caseinsensitive, true );
|
||||
}
|
||||
|
||||
void FS_Mem_FreeSearch( search_t *search )
|
||||
{
|
||||
Mem_Free( search );
|
||||
}
|
||||
|
||||
void FS_InitMemory( void )
|
||||
{
|
||||
fs_mempool = Mem_AllocPool( "Filesystem Pool" );
|
||||
|
@ -3443,36 +3401,34 @@ vfile_t *VFS_Create( const byte *buffer, size_t buffsize)
|
|||
return file;
|
||||
}
|
||||
|
||||
vfile_t *VFS_Open(file_t *handle, const char* mode)
|
||||
vfile_t *VFS_Open( file_t *handle, const char *mode )
|
||||
{
|
||||
vfile_t *file = (vfile_t *)Mem_Alloc (fs_mempool, sizeof (vfile_t));
|
||||
|
||||
// If the file is opened in "write", "append", or "read/write" mode
|
||||
if (mode[0] == 'w')
|
||||
if( mode[0] == 'w' )
|
||||
{
|
||||
file->compress = (mode[1] == 'z') ? true : false;
|
||||
file->handle = handle;
|
||||
file->buffsize = (64 * 1024); // will be resized if need
|
||||
file->buff = Mem_Alloc(fs_mempool, (file->buffsize));
|
||||
file->buff = Mem_Alloc( fs_mempool, file->buffsize );
|
||||
file->length = 0;
|
||||
file->offset = 0;
|
||||
file->mode = O_WRONLY;
|
||||
}
|
||||
else if (mode[0] == 'r')
|
||||
else if( mode[0] == 'r' )
|
||||
{
|
||||
int curpos, endpos;
|
||||
int curpos, endpos;
|
||||
|
||||
file->compress = false;
|
||||
file->handle = handle;
|
||||
curpos = FS_Tell(file->handle);
|
||||
FS_Seek(file->handle, 0, SEEK_END);
|
||||
endpos = FS_Tell(file->handle);
|
||||
FS_Seek(file->handle, curpos, SEEK_SET);
|
||||
curpos = FS_Tell( file->handle );
|
||||
FS_Seek( file->handle, 0, SEEK_END );
|
||||
endpos = FS_Tell( file->handle );
|
||||
FS_Seek( file->handle, curpos, SEEK_SET );
|
||||
|
||||
file->buffsize = endpos - curpos;
|
||||
file->buff = Mem_Alloc(fs_mempool, (file->buffsize));
|
||||
file->buff = Mem_Alloc( fs_mempool, file->buffsize );
|
||||
|
||||
FS_Read(file->handle, file->buff, file->buffsize);
|
||||
FS_Read( file->handle, file->buff, file->buffsize );
|
||||
file->length = file->buffsize;
|
||||
file->offset = 0;
|
||||
file->mode = O_RDONLY;
|
||||
|
@ -3488,17 +3444,18 @@ vfile_t *VFS_Open(file_t *handle, const char* mode)
|
|||
|
||||
fs_offset_t VFS_Read( vfile_t* file, void* buffer, size_t buffersize)
|
||||
{
|
||||
fs_offset_t read_size = 0;
|
||||
fs_offset_t read_size = 0;
|
||||
|
||||
if ( buffersize == 0 ) return 1;
|
||||
if (!file) return 0;
|
||||
if( buffersize == 0 ) return 1;
|
||||
if( !file ) return 0;
|
||||
|
||||
// check for enough room
|
||||
if(file->offset >= file->length)
|
||||
if( file->offset >= file->length )
|
||||
{
|
||||
return 0; //hit EOF
|
||||
return 0; // hit EOF
|
||||
}
|
||||
if(file->offset + buffersize <= file->length)
|
||||
|
||||
if( file->offset + buffersize <= file->length )
|
||||
{
|
||||
Mem_Copy( buffer, file->buff + file->offset, buffersize );
|
||||
file->offset += buffersize;
|
||||
|
@ -3512,18 +3469,19 @@ fs_offset_t VFS_Read( vfile_t* file, void* buffer, size_t buffersize)
|
|||
read_size = reduced_size;
|
||||
MsgDev( D_NOTE, "VFS_Read: vfs buffer is out\n");
|
||||
}
|
||||
|
||||
return read_size;
|
||||
}
|
||||
|
||||
fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size )
|
||||
{
|
||||
if(!file) return -1;
|
||||
if( !file ) return -1;
|
||||
|
||||
if (file->offset + size >= file->buffsize)
|
||||
if( file->offset + size >= file->buffsize )
|
||||
{
|
||||
int newsize = file->offset + size + (64 * 1024);
|
||||
int newsize = file->offset + size + (64 * 1024);
|
||||
|
||||
if (file->buffsize < newsize)
|
||||
if( file->buffsize < newsize )
|
||||
{
|
||||
// reallocate buffer now
|
||||
file->buff = Mem_Realloc( fs_mempool, file->buff, newsize );
|
||||
|
@ -3566,7 +3524,7 @@ VFS_VPrintf
|
|||
Print a string into a buffer
|
||||
====================
|
||||
*/
|
||||
int VFS_VPrintf(vfile_t* file, const char* format, va_list ap)
|
||||
int VFS_VPrintf( vfile_t* file, const char* format, va_list ap )
|
||||
{
|
||||
int len;
|
||||
fs_offset_t buff_size = MAX_SYSPATH;
|
||||
|
@ -3594,27 +3552,27 @@ VFS_Printf
|
|||
Print a string into a buffer
|
||||
====================
|
||||
*/
|
||||
int VFS_Printf(vfile_t* file, const char* format, ...)
|
||||
int VFS_Printf( vfile_t* file, const char* format, ... )
|
||||
{
|
||||
int result;
|
||||
va_list args;
|
||||
int result;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
result = VFS_VPrintf(file, format, args);
|
||||
va_end (args);
|
||||
va_start( args, format );
|
||||
result = VFS_VPrintf( file, format, args );
|
||||
va_end( args );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fs_offset_t VFS_Tell (vfile_t* file)
|
||||
fs_offset_t VFS_Tell( vfile_t *file )
|
||||
{
|
||||
if (!file) return -1;
|
||||
if( !file ) return -1;
|
||||
return file->offset;
|
||||
}
|
||||
|
||||
bool VFS_Eof( vfile_t* file)
|
||||
bool VFS_Eof( vfile_t *file )
|
||||
{
|
||||
if (!file) return true;
|
||||
if( !file ) return true;
|
||||
return (file->offset == file->length) ? true : false;
|
||||
}
|
||||
|
||||
|
@ -3641,89 +3599,62 @@ int VFS_Gets( vfile_t* file, byte *string, size_t bufsize )
|
|||
while( 1 )
|
||||
{
|
||||
c = VFS_Getc( file );
|
||||
if (c == '\r' || c == '\n' || c < 0)
|
||||
if( c == '\r' || c == '\n' || c < 0 )
|
||||
break;
|
||||
if (end < bufsize - 1) string[end++] = c;
|
||||
|
||||
if( end < bufsize - 1 )
|
||||
string[end++] = c;
|
||||
}
|
||||
string[end] = 0;
|
||||
|
||||
// remove \n following \r
|
||||
if (c == '\r')
|
||||
if( c == '\r' )
|
||||
{
|
||||
c = VFS_Getc( file );
|
||||
if (c != '\n') VFS_Seek( file, -1, SEEK_CUR ); // rewind
|
||||
if( c != '\n' ) VFS_Seek( file, -1, SEEK_CUR ); // rewind
|
||||
}
|
||||
MsgDev(D_INFO, "VFS_Gets: %s\n", string);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence )
|
||||
{
|
||||
if (!file) return -1;
|
||||
if( !file ) return -1;
|
||||
|
||||
// Compute the file offset
|
||||
switch (whence)
|
||||
switch( whence )
|
||||
{
|
||||
case SEEK_CUR:
|
||||
offset += file->offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
break;
|
||||
case SEEK_END:
|
||||
offset += file->length;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
case SEEK_CUR:
|
||||
offset += file->offset;
|
||||
break;
|
||||
case SEEK_SET:
|
||||
break;
|
||||
case SEEK_END:
|
||||
offset += file->length;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (offset < 0 || offset > (long)file->length) return -1;
|
||||
if( offset < 0 || offset > (long)file->length )
|
||||
return -1;
|
||||
|
||||
file->offset = offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VFS_Unpack( void* compbuf, size_t compsize, void **dst, size_t size )
|
||||
{
|
||||
char *buf = *dst;
|
||||
z_stream strm = {compbuf, compsize, 0, buf, size, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
inflateInit( &strm );
|
||||
if( Z_STREAM_END != inflate( &strm, Z_FINISH )) // decompress it in one go.
|
||||
{
|
||||
if( !com.strlen( strm.msg )) MsgDev( D_NOTE, "VFS_Unpack: failed block decompression\n" );
|
||||
else MsgDev( D_NOTE, "VFS_Unpack: failed block decompression: %s\n", strm.msg );
|
||||
return false;
|
||||
}
|
||||
inflateEnd( &strm );
|
||||
return true;
|
||||
}
|
||||
|
||||
file_t *VFS_Close( vfile_t *file )
|
||||
{
|
||||
file_t *handle;
|
||||
char out[8192]; // chunk size
|
||||
z_stream strm = {file->buff, file->length, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
if(!file) return NULL;
|
||||
if( !file ) return NULL;
|
||||
|
||||
if(file->mode == O_WRONLY)
|
||||
if( file->mode == O_WRONLY )
|
||||
{
|
||||
if( file->compress ) // deflate before writing
|
||||
{
|
||||
deflateInit( &strm, 9 ); // Z_BEST_COMPRESSION
|
||||
while(deflate(&strm, Z_FINISH) == Z_OK)
|
||||
{
|
||||
FS_Write( file->handle, out, sizeof(out) - strm.avail_out);
|
||||
strm.next_out = out;
|
||||
strm.avail_out = sizeof(out);
|
||||
}
|
||||
FS_Write( file->handle, out, sizeof(out) - strm.avail_out );
|
||||
deflateEnd( &strm );
|
||||
}
|
||||
else if( file->handle )
|
||||
if( file->handle )
|
||||
FS_Write(file->handle, file->buff, (file->length + 3) & ~3); // align
|
||||
}
|
||||
|
||||
handle = file->handle; // keep real handle
|
||||
|
||||
if( file->buff ) Mem_Free( file->buff );
|
||||
|
@ -3743,19 +3674,17 @@ WADSYSTEM PRIVATE COMMON FUNCTIONS
|
|||
// associate extension with wad type
|
||||
static const wadtype_t wad_types[] =
|
||||
{
|
||||
{ "flp", TYPE_FLMP }, // doom1 menu picture
|
||||
{ "snd", TYPE_SND }, // doom1 sound
|
||||
{ "mus", TYPE_MUS }, // doom1 .mus format
|
||||
{ "skn", TYPE_SKIN }, // doom1 sprite model
|
||||
{ "flt", TYPE_FLAT }, // doom1 wall texture
|
||||
{ "pal", TYPE_QPAL }, // palette
|
||||
{ "lmp", TYPE_QPIC }, // quake1, hl pic
|
||||
{ "fnt", TYPE_QFONT }, // hl qfonts
|
||||
{ "mip", TYPE_MIPTEX}, // hl/q1 mip
|
||||
{ "raw", TYPE_RAW }, // signed raw data
|
||||
{ "wav", TYPE_SOUND }, // wav sounds (hl2)
|
||||
{ "txt", TYPE_SCRIPT}, // any script file
|
||||
{ NULL, TYPE_NONE }
|
||||
{ "flp", TYP_FLMP }, // doom1 menu picture
|
||||
{ "snd", TYP_SND }, // doom1 sound
|
||||
{ "mus", TYP_MUS }, // doom1 .mus format
|
||||
{ "skn", TYP_SKIN }, // doom1 sprite model
|
||||
{ "flt", TYP_FLAT }, // doom1 wall texture
|
||||
{ "pal", TYP_QPAL }, // palette
|
||||
{ "lmp", TYP_QPIC }, // quake1, hl pic
|
||||
{ "fnt", TYP_QFONT }, // hl qfonts
|
||||
{ "mip", TYP_MIPTEX }, // hl/q1 mip
|
||||
{ "raw", TYP_RAW }, // signed raw data
|
||||
{ NULL, TYP_NONE }
|
||||
};
|
||||
|
||||
static char W_TypeFromExt( const char *lumpname )
|
||||
|
@ -3765,14 +3694,14 @@ static char W_TypeFromExt( const char *lumpname )
|
|||
|
||||
// we not known about filetype, so match only by filename
|
||||
if( !com.strcmp( ext, "*" ) || !com.strcmp( ext, "" ))
|
||||
return TYPE_ANY;
|
||||
return TYP_ANY;
|
||||
|
||||
for( type = wad_types; type->ext; type++ )
|
||||
{
|
||||
if(!com.stricmp( ext, type->ext ))
|
||||
return type->type;
|
||||
}
|
||||
return TYPE_NONE;
|
||||
return TYP_NONE;
|
||||
}
|
||||
|
||||
static const char *W_ExtFromType( char lumptype )
|
||||
|
@ -3780,7 +3709,7 @@ static const char *W_ExtFromType( char lumptype )
|
|||
const wadtype_t *type;
|
||||
|
||||
// we not known aboyt filetype, so match only by filename
|
||||
if( lumptype == TYPE_NONE || lumptype == TYPE_ANY )
|
||||
if( lumptype == TYP_NONE || lumptype == TYP_ANY )
|
||||
return "";
|
||||
|
||||
for( type = wad_types; type->ext; type++ )
|
||||
|
@ -3795,7 +3724,7 @@ static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char match
|
|||
{
|
||||
int left, right, middle;
|
||||
|
||||
if( !wad || !wad->lumps || matchtype == TYPE_NONE )
|
||||
if( !wad || !wad->lumps || matchtype == TYP_NONE )
|
||||
return NULL;
|
||||
|
||||
// look for the file (binary search)
|
||||
|
@ -3812,7 +3741,7 @@ static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char match
|
|||
// Found it
|
||||
if( !diff )
|
||||
{
|
||||
if( matchtype == TYPE_ANY || matchtype == wad->lumps[middle].type )
|
||||
if( matchtype == TYP_ANY || matchtype == wad->lumps[middle].type )
|
||||
return &wad->lumps[middle]; // found
|
||||
else break;
|
||||
}
|
||||
|
@ -3833,13 +3762,6 @@ static void W_CleanupName( const char *dirtyname, char *cleanname )
|
|||
|
||||
cleanname[0] = '\0'; // clear output
|
||||
FS_FileBase( dirtyname, tempname );
|
||||
if( com.strlen( tempname ) > WAD3_NAMELEN )
|
||||
{
|
||||
// windows style cutoff long names
|
||||
// FIXME: probably can make duplicate names
|
||||
tempname[14] = '~';
|
||||
tempname[15] = '1';
|
||||
}
|
||||
tempname[16] = '\0'; // cutoff all other ...
|
||||
com.strncpy( cleanname, tempname, 16 );
|
||||
|
||||
|
@ -3890,13 +3812,13 @@ static dlumpinfo_t *W_AddFileToWad( const char *name, wfile_t *wad, int filepos,
|
|||
plump->compression = compression;
|
||||
|
||||
// convert all qmip types to miptex
|
||||
if( type == TYPE_QMIP )
|
||||
plump->type = TYPE_MIPTEX;
|
||||
if( type == TYP_QMIP )
|
||||
plump->type = TYP_MIPTEX;
|
||||
else plump->type = type;
|
||||
|
||||
// check for Quake 'conchars' issues (only lmp loader supposed to read this lame pic)
|
||||
if( !com.stricmp( plump->name, "conchars" ) && plump->type == TYPE_QMIP )
|
||||
plump->type = TYPE_QPIC;
|
||||
if( !com.stricmp( plump->name, "conchars" ) && plump->type == TYP_QMIP )
|
||||
plump->type = TYP_QPIC;
|
||||
|
||||
return plump;
|
||||
}
|
||||
|
@ -3932,13 +3854,13 @@ static bool W_ConvertIWADLumps( wfile_t *wad )
|
|||
// W_Open will be swap lump later
|
||||
int filepos = doomlumps[i].filepos;
|
||||
int size = doomlumps[i].size;
|
||||
char type = TYPE_NONE;
|
||||
char type = TYP_NONE;
|
||||
char name[16];
|
||||
|
||||
com.strnlwr( doomlumps[i].name, name, 9 );
|
||||
|
||||
// check for backslash issues
|
||||
k = com.strlen( com_strchr( name, '\\' ));
|
||||
k = com.strlen( com.strchr( name, '\\' ));
|
||||
if( k ) name[com.strlen( name )-k] = '#'; // vile1.spr issues
|
||||
|
||||
// textures begin
|
||||
|
@ -3985,18 +3907,18 @@ static bool W_ConvertIWADLumps( wfile_t *wad )
|
|||
else flmp_images = false;
|
||||
|
||||
// setup lumptypes for doomwads
|
||||
if( flmp_images ) type = TYPE_FLMP; // mark as menu pic
|
||||
if( flat_images ) type = TYPE_FLAT; // mark as texture
|
||||
if( skin_images ) type = TYPE_SKIN; // mark as skin (sprite model)
|
||||
if(!com.strnicmp( name, "D_", 2 )) wad->lumps[i].type = TYPE_MUS;
|
||||
if(!com.strnicmp( name, "DS", 2 )) wad->lumps[i].type = TYPE_SND;
|
||||
if( flmp_images ) type = TYP_FLMP; // mark as menu pic
|
||||
if( flat_images ) type = TYP_FLAT; // mark as texture
|
||||
if( skin_images ) type = TYP_SKIN; // mark as skin (sprite model)
|
||||
if(!com.strnicmp( name, "D_", 2 )) wad->lumps[i].type = TYP_MUS;
|
||||
if(!com.strnicmp( name, "DS", 2 )) wad->lumps[i].type = TYP_SND;
|
||||
|
||||
// remove invalid resources
|
||||
if( !com.strnicmp( name, "ENDOOM", 6 )) type = TYPE_NONE;
|
||||
if( !com.strnicmp( name, "STEP1", 5 )) type = TYPE_NONE;
|
||||
if( !com.strnicmp( name, "STEP2", 5 )) type = TYPE_NONE;
|
||||
if( !com.strnicmp( name, "ENDOOM", 6 )) type = TYP_NONE;
|
||||
if( !com.strnicmp( name, "STEP1", 5 )) type = TYP_NONE;
|
||||
if( !com.strnicmp( name, "STEP2", 5 )) type = TYP_NONE;
|
||||
|
||||
if( type == TYPE_NONE ) continue; // invalid resource
|
||||
if( type == TYP_NONE ) continue; // invalid resource
|
||||
|
||||
// add wad file
|
||||
W_AddFileToWad( name, wad, filepos, size, size, type, CMP_NONE );
|
||||
|
@ -4070,7 +3992,30 @@ byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, size_t *lumpsizeptr )
|
|||
|
||||
switch( lump->compression )
|
||||
{
|
||||
case CMP_NONE:
|
||||
case CMP_LZSS:
|
||||
cbuf = (byte *)Mem_Alloc( wad->mempool, lump->disksize );
|
||||
size = FS_Read( wad->file, cbuf, lump->disksize );
|
||||
buf = (byte *)Mem_Alloc( wad->mempool, lump->size );
|
||||
|
||||
if( size < lump->disksize )
|
||||
{
|
||||
MsgDev( D_WARN, "W_ReadLump: %s is probably corrupted\n", lump->name );
|
||||
Mem_Free( cbuf );
|
||||
Mem_Free( buf );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( lzss_decompress( cbuf, cbuf + lump->disksize, buf, buf + lump->size ))
|
||||
{
|
||||
MsgDev( D_WARN, "W_ReadLump: can't unpack %s\n", lump->name );
|
||||
Mem_Free( cbuf );
|
||||
Mem_Free( buf );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Mem_Free( cbuf ); // no reason to keep this data
|
||||
break;
|
||||
default:
|
||||
buf = (byte *)Mem_Alloc( wad->mempool, lump->disksize );
|
||||
size = FS_Read( wad->file, buf, lump->disksize );
|
||||
if( size < lump->disksize )
|
||||
|
@ -4080,23 +4025,6 @@ byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, size_t *lumpsizeptr )
|
|||
return NULL;
|
||||
}
|
||||
break;
|
||||
case CMP_LZSS:
|
||||
// never used by Id Software or Valve ?
|
||||
MsgDev(D_WARN, "W_ReadLump: lump %s have unsupported compression type\n", lump->name );
|
||||
return NULL;
|
||||
case CMP_ZLIB:
|
||||
cbuf = (byte *)Mem_Alloc( wad->mempool, lump->disksize );
|
||||
size = FS_Read( wad->file, cbuf, lump->disksize );
|
||||
buf = (byte *)Mem_Alloc( wad->mempool, lump->size );
|
||||
if(!VFS_Unpack( cbuf, size, &buf, lump->size ))
|
||||
{
|
||||
MsgDev( D_WARN, "W_ReadLump: %s is probably corrupted\n", lump->name );
|
||||
Mem_Free( cbuf );
|
||||
Mem_Free( buf );
|
||||
return NULL;
|
||||
}
|
||||
Mem_Free( cbuf ); // no reason to keep this data
|
||||
break;
|
||||
}
|
||||
|
||||
if( lumpsizeptr ) *lumpsizeptr = lump->size;
|
||||
|
@ -4105,29 +4033,32 @@ byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, size_t *lumpsizeptr )
|
|||
|
||||
bool W_WriteLump( wfile_t *wad, dlumpinfo_t *lump, const void* data, size_t datasize, char cmp )
|
||||
{
|
||||
size_t ofs;
|
||||
vfile_t *h;
|
||||
byte *inbuf, *outbuf;
|
||||
|
||||
if( !wad || !lump ) return false;
|
||||
|
||||
if( !data || !datasize )
|
||||
{
|
||||
MsgDev( D_WARN, "W_WriteLump: ignore blank lump %s - nothing to save\n", lump->name );
|
||||
return false;
|
||||
}
|
||||
switch(( int )cmp)
|
||||
|
||||
switch( cmp )
|
||||
{
|
||||
case CMP_LZSS:
|
||||
// never used by Id Software or Valve ?
|
||||
MsgDev( D_WARN, "W_SaveLump: lump %s can't be saved with comptype LZSS\n", lump->name );
|
||||
return false;
|
||||
case CMP_ZLIB:
|
||||
h = VFS_Open( wad->file, "wz" );
|
||||
inbuf = (byte *)data;
|
||||
|
||||
// NOTE: abort compression if it matches or exceeds the original file's size
|
||||
outbuf = Mem_Alloc( fs_mempool, datasize - 1 );
|
||||
lump->disksize = lzss_compress( inbuf, inbuf + datasize, outbuf, outbuf + datasize - 1 );
|
||||
lump->size = datasize; // realsize
|
||||
VFS_Write( h, data, datasize );
|
||||
wad->file = VFS_Close( h ); // go back to real filesystem
|
||||
ofs = FS_Tell( wad->file ); // ofs - info->filepos returns compressed size
|
||||
lump->disksize = LittleLong( ofs - lump->filepos );
|
||||
return true;
|
||||
|
||||
if( lump->disksize > 0 )
|
||||
{
|
||||
FS_Write( wad->file, outbuf, lump->disksize ); // write compressed file
|
||||
}
|
||||
Mem_Free( outbuf );
|
||||
return ( lump->disksize != 0 ) ? true : false;
|
||||
default: // CMP_NONE method
|
||||
lump->size = lump->disksize = LittleLong( datasize );
|
||||
FS_Write( wad->file, data, datasize ); // just write file
|
||||
|
@ -4149,7 +4080,7 @@ int W_Check( const char *filename )
|
|||
int numlumps;
|
||||
int infotableofs;
|
||||
|
||||
testwad = FS_Open( filename, "rb" );
|
||||
testwad = FS_Open( filename, "rb", false );
|
||||
if( !testwad ) return 0; // just not exist
|
||||
|
||||
if( FS_Read( testwad, &header, sizeof(dwadinfo_t)) != sizeof(dwadinfo_t))
|
||||
|
@ -4195,9 +4126,9 @@ wfile_t *W_Open( const char *filename, const char *mode )
|
|||
dwadinfo_t header;
|
||||
wfile_t *wad = (wfile_t *)Mem_Alloc( fs_mempool, sizeof( wfile_t ));
|
||||
|
||||
if( mode[0] == 'a' ) wad->file = FS_Open( filename, "r+b" );
|
||||
else if( mode[0] == 'w' ) wad->file = FS_Open( filename, "wb" );
|
||||
else if( mode[0] == 'r' ) wad->file = FS_Open( filename, "rb" );
|
||||
if( mode[0] == 'a' ) wad->file = FS_Open( filename, "r+b", false );
|
||||
else if( mode[0] == 'w' ) wad->file = FS_Open( filename, "wb", false );
|
||||
else if( mode[0] == 'r' ) wad->file = FS_Open( filename, "rb", false );
|
||||
|
||||
if( !wad->file )
|
||||
{
|
||||
|
@ -4348,24 +4279,28 @@ fs_offset_t W_SaveLump( wfile_t *wad, const char *lump, const void* data, size_t
|
|||
{
|
||||
size_t lat_size;
|
||||
dlumpinfo_t *info;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if( !wad || !lump ) return -1;
|
||||
|
||||
if( !data || !datasize )
|
||||
{
|
||||
MsgDev( D_WARN, "W_SaveLump: ignore blank lump %s - nothing to save\n", lump );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( wad->mode == O_RDONLY )
|
||||
{
|
||||
MsgDev( D_ERROR, "W_SaveLump: %s opened in readonly mode\n", wad->filename );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( wad->numlumps >= MAX_FILES_IN_WAD )
|
||||
{
|
||||
MsgDev( D_ERROR, "W_SaveLump: %s is full\n", wad->filename );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( W_FindLump( wad, lump, type ))
|
||||
{
|
||||
// don't make mirror lumps
|
||||
|
@ -4386,7 +4321,7 @@ fs_offset_t W_SaveLump( wfile_t *wad, const char *lump, const void* data, size_t
|
|||
info->type = type;
|
||||
|
||||
i = FS_Tell( wad->file );
|
||||
if(!W_WriteLump( wad, info, data, datasize, cmp ))
|
||||
if( !W_WriteLump( wad, info, data, datasize, cmp ))
|
||||
return -1;
|
||||
|
||||
MsgDev( D_NOTE, "W_SaveLump: %s, size %d\n", info->name, info->disksize );
|
||||
|
@ -4417,7 +4352,7 @@ static byte *W_LoadFile( const char *path, fs_offset_t *lumpsizeptr )
|
|||
searchpath_t *search;
|
||||
int index;
|
||||
|
||||
search = FS_FindFile( path, &index, true, false );
|
||||
search = FS_FindFile( path, &index, false );
|
||||
if( search && search->wad )
|
||||
return W_ReadLump( search->wad, &search->wad->lumps[index], lumpsizeptr );
|
||||
return NULL;
|
||||
|
|
|
@ -81,14 +81,14 @@ infotable dlumpinfo_t[dwadinfo_t->numlumps]
|
|||
#define MAX_FILES_IN_WAD 8192
|
||||
|
||||
// hidden virtual lump types
|
||||
#define TYPE_ANY -1 // any type can be accepted
|
||||
#define TYPE_NONE 0 // unknown lump type
|
||||
#define TYPE_FLMP 1 // doom1 hud picture (doom1 mapped lump)
|
||||
#define TYPE_SND 2 // doom1 wav sound (doom1 mapped lump)
|
||||
#define TYPE_MUS 3 // doom1 music file (doom1 mapped lump)
|
||||
#define TYPE_SKIN 4 // doom1 sprite model (doom1 mapped lump)
|
||||
#define TYPE_FLAT 5 // doom1 wall texture (doom1 mapped lump)
|
||||
#define TYPE_MAXHIDDEN 63 // after this number started typeing letters ( 'a', 'b' etc )
|
||||
#define TYP_ANY -1 // any type can be accepted
|
||||
#define TYP_NONE 0 // unknown lump type
|
||||
#define TYP_FLMP 1 // doom1 hud picture (doom1 mapped lump)
|
||||
#define TYP_SND 2 // doom1 wav sound (doom1 mapped lump)
|
||||
#define TYP_MUS 3 // doom1 music file (doom1 mapped lump)
|
||||
#define TYP_SKIN 4 // doom1 sprite model (doom1 mapped lump)
|
||||
#define TYP_FLAT 5 // doom1 wall texture (doom1 mapped lump)
|
||||
#define TYP_MAXHIDDEN 63 // after this number started typeing letters ( 'a', 'b' etc )
|
||||
|
||||
#include "const.h"
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ bool Image_SaveBMP( const char *name, rgbdata_t *pix )
|
|||
dword biTrueWidth;
|
||||
int i, rc = 0;
|
||||
|
||||
if(FS_FileExists( name ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
// bogus parameter check
|
||||
|
@ -265,7 +265,7 @@ bool Image_SaveBMP( const char *name, rgbdata_t *pix )
|
|||
return false;
|
||||
}
|
||||
|
||||
pfile = FS_Open( name, "wb");
|
||||
pfile = FS_Open( name, "wb", false );
|
||||
if( !pfile ) return false;
|
||||
|
||||
// NOTE: align transparency column will sucessfully removed
|
||||
|
|
|
@ -2357,7 +2357,7 @@ bool Image_ForceDecompress( void )
|
|||
if( image.filter != CB_HINT_NO )
|
||||
return true;
|
||||
|
||||
// FIXME: load it properly with gl loader
|
||||
// UNDONE: load it properly with gl loader
|
||||
switch( image.type )
|
||||
{
|
||||
case PF_RXGB: return true; // g-cont. test it with GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ?
|
||||
|
@ -2459,7 +2459,7 @@ bool Image_SaveDDS( const char *name, rgbdata_t *pix )
|
|||
{
|
||||
vfile_t *file; // virtual file
|
||||
|
||||
if( FS_FileExists( name ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
file = VFS_Open( NULL, "w" );
|
||||
|
|
|
@ -581,11 +581,11 @@ bool Image_SaveJPG( const char *name, rgbdata_t *pix )
|
|||
uint i, linesize;
|
||||
file_t *file;
|
||||
|
||||
if( FS_FileExists( name ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
// Open the file
|
||||
file = FS_Open( name, "wb" );
|
||||
file = FS_Open( name, "wb", false );
|
||||
if( !file ) return false;
|
||||
|
||||
if( setjmp( error_save_jpeg ))
|
||||
|
|
|
@ -67,7 +67,7 @@ static const cubepack_t load_cubemap[] =
|
|||
{ "3Ds Sky1", skybox_qv1 },
|
||||
{ "3Ds Sky2", skybox_qv2 },
|
||||
{ "3Ds Cube", cubemap_v2 },
|
||||
{ "Tenebrae", cubemap_v1 }, // FIXME: remove this ?
|
||||
{ "Tenebrae", cubemap_v1 },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,7 @@ static const cubepack_t load_cubemap[] =
|
|||
const bpc_desc_t PFDesc[] =
|
||||
{
|
||||
{PF_UNKNOWN, "raw", 0x1908, 0x1401, 0, 0, 0 },
|
||||
{PF_INDEXED_24, "pal 24", 0x1908, 0x1401, 1, 1, 0 }, // expand data to RGBA buffer
|
||||
{PF_INDEXED_24, "pal 24", 0x1908, 0x1401, 1, 1, 0 },
|
||||
{PF_INDEXED_32, "pal 32", 0x1908, 0x1401, 1, 1, 0 },
|
||||
{PF_RGBA_32, "RGBA 32",0x1908, 0x1401, 4, 1, -4 },
|
||||
{PF_BGRA_32, "BGRA 32",0x80E1, 0x1401, 4, 1, -4 },
|
||||
|
@ -83,7 +83,7 @@ const bpc_desc_t PFDesc[] =
|
|||
{PF_ABGR_64, "ABGR 64",0x80E1, 0x1401, 4, 2, -8 },
|
||||
{PF_RGB_24, "RGB 24", 0x1908, 0x1401, 3, 1, -3 },
|
||||
{PF_BGR_24, "BGR 24", 0x80E0, 0x1401, 3, 1, -3 },
|
||||
{PF_RGB_16, "RGB 16", 0x8054, 0x8364, 3, 2, 16 }, // FIXME: do revision
|
||||
{PF_RGB_16, "RGB 16", 0x8054, 0x8364, 3, 2, 16 },
|
||||
{PF_DXT1, "DXT1", 0x1908, 0x1401, 4, 1, 8 },
|
||||
{PF_DXT2, "DXT2", 0x1908, 0x1401, 4, 1, 16 },
|
||||
{PF_DXT3, "DXT3", 0x1908, 0x1401, 4, 1, 16 },
|
||||
|
@ -97,7 +97,7 @@ const bpc_desc_t PFDesc[] =
|
|||
{PF_LUMINANCE_ALPHA,"LUM A", 0x190A, 0x1401, 2, 1, -2 },
|
||||
{PF_UV_16, "UV 16", 0x190A, 0x1401, 2, 1, -2 },
|
||||
{PF_UV_16, "UV 16", 0x190A, 0x1401, 2, 1, -4 },
|
||||
{PF_R_16F, "R 16f", 0x8884, 0x1406, 1, 4, -2 }, // FIXME: these NV extension, reinstall for ATI
|
||||
{PF_R_16F, "R 16f", 0x8884, 0x1406, 1, 4, -2 }, // UNDONE: these NV extension, reinstall for ATI
|
||||
{PF_R_32F, "R 32f", 0x8885, 0x1406, 1, 4, -4 },
|
||||
{PF_GR_32F, "GR 32f", 0x8886, 0x1406, 2, 4, -4 },
|
||||
{PF_GR_64F, "GR 64f", 0x8887, 0x1406, 2, 4, -8 },
|
||||
|
@ -177,7 +177,6 @@ rgbdata_t *ImagePack( void )
|
|||
================
|
||||
FS_AddSideToPack
|
||||
|
||||
FIXME: rewrite with VirtualFS using ?
|
||||
================
|
||||
*/
|
||||
bool FS_AddSideToPack( const char *name, int adjust_flags )
|
||||
|
@ -192,7 +191,9 @@ bool FS_AddSideToPack( const char *name, int adjust_flags )
|
|||
image.source_height = image.height;
|
||||
image.source_type = image.type;
|
||||
}
|
||||
image.size = image.source_width * image.source_height * 4; // keep constant size, render.dll expecting it
|
||||
|
||||
// keep constant size, render.dll expecting it
|
||||
image.size = image.source_width * image.source_height * 4;
|
||||
|
||||
// mixing dds format with any existing ?
|
||||
if( image.type != image.source_type )
|
||||
|
@ -261,9 +262,6 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
|||
const cubepack_t *cmap;
|
||||
byte *f;
|
||||
|
||||
#if 0 // don't try to be very clever
|
||||
if( !buffer || !buffsize ) buffer = (char *)florr1_2_jpg, buffsize = sizeof(florr1_2_jpg);
|
||||
#endif
|
||||
Image_Reset(); // clear old image
|
||||
com.strncpy( loadname, filename, sizeof( loadname ));
|
||||
|
||||
|
@ -291,10 +289,10 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
|||
// now try all the formats in the selected list
|
||||
for( format = image.loadformats; format && format->formatstring; format++)
|
||||
{
|
||||
if( !com_stricmp( format->ext, "dds" )) dds_installed = true;
|
||||
if( anyformat || !com_stricmp( ext, format->ext ))
|
||||
if( !com.stricmp( format->ext, "dds" )) dds_installed = true;
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
com_sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
com.sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
image.hint = format->hint;
|
||||
f = FS_LoadFile( path, &filesize );
|
||||
if( f && filesize > 0 )
|
||||
|
@ -310,7 +308,7 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
|||
}
|
||||
|
||||
// special case for extract cubemap side from dds image
|
||||
if( dds_installed && (anyformat || !com_stricmp( ext, "dds" )))
|
||||
if( dds_installed && (anyformat || !com.stricmp( ext, "dds" )))
|
||||
{
|
||||
// first, check for cubemap suffixes
|
||||
for( cmap = load_cubemap; cmap && cmap->type; cmap++ )
|
||||
|
@ -357,7 +355,7 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
|||
{
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
com_sprintf( path, format->formatstring, loadname, cmap->type[i].suf, format->ext );
|
||||
com.sprintf( path, format->formatstring, loadname, cmap->type[i].suf, format->ext );
|
||||
image.hint = cmap->type[i].hint; // side hint
|
||||
|
||||
f = FS_LoadFile( path, &filesize );
|
||||
|
@ -408,7 +406,7 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
|
|||
load_internal:
|
||||
for( format = image.baseformats; format && format->formatstring; format++ )
|
||||
{
|
||||
if( anyformat || !com_stricmp( ext, format->ext ))
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
image.hint = format->hint;
|
||||
if( buffer && size > 0 )
|
||||
|
@ -437,7 +435,7 @@ writes image as any known format
|
|||
bool FS_SaveImage( const char *filename, rgbdata_t *pix )
|
||||
{
|
||||
const char *ext = FS_FileExtension( filename );
|
||||
bool anyformat = !com_stricmp( ext, "" ) ? true : false;
|
||||
bool anyformat = !com.stricmp( ext, "" ) ? true : false;
|
||||
string path, savename;
|
||||
const savepixformat_t *format;
|
||||
|
||||
|
@ -492,7 +490,7 @@ bool FS_SaveImage( const char *filename, rgbdata_t *pix )
|
|||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -110,7 +110,7 @@ bool Image_SavePCX( const char *name, rgbdata_t *pix )
|
|||
int i, j;
|
||||
pcx_t pcx;
|
||||
|
||||
if(FS_FileExists( name ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
// bogus parameter check
|
||||
|
@ -173,7 +173,7 @@ bool Image_SavePCX( const char *name, rgbdata_t *pix )
|
|||
for( i = 0; i < 768; i++ )
|
||||
*pack++ = *palette++;
|
||||
|
||||
file = FS_Open( name, "wb" );
|
||||
file = FS_Open( name, "wb", false );
|
||||
if( !file ) return false;
|
||||
|
||||
// write header
|
||||
|
|
|
@ -115,14 +115,13 @@ bool Image_LoadPNG( const char *name, const byte *buffer, size_t filesize )
|
|||
uint y;
|
||||
void *fin, *pnginfo;
|
||||
|
||||
// FIXME: register an error handler so that abort() won't be called on error
|
||||
|
||||
if(png_sig_cmp((char*)buffer, 0, filesize ))
|
||||
if( png_sig_cmp((char *)buffer, 0, filesize ))
|
||||
return false;
|
||||
fin = (void *)png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, (void *)png_error_fn, (void *)png_warning_fn );
|
||||
|
||||
fin = (void *)png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, png_error_fn, png_warning_fn );
|
||||
if( !fin ) return false;
|
||||
|
||||
if(setjmp((int*)fin))
|
||||
if( setjmp((int *)fin ))
|
||||
{
|
||||
png_destroy_read_struct( &fin, &pnginfo, 0 );
|
||||
return false;
|
||||
|
@ -136,7 +135,7 @@ bool Image_LoadPNG( const char *name, const byte *buffer, size_t filesize )
|
|||
}
|
||||
png_set_sig_bytes( fin, 0);
|
||||
|
||||
Mem_Set(&png, 0, sizeof( png ));
|
||||
Mem_Set( &png, 0, sizeof( png ));
|
||||
png.tmpBuf = buffer;
|
||||
png.tmpBuflength = filesize;
|
||||
png.tmpi = 0;
|
||||
|
@ -186,7 +185,7 @@ bool Image_LoadPNG( const char *name, const byte *buffer, size_t filesize )
|
|||
png_read_update_info( fin, pnginfo );
|
||||
png.FRowBytes = png_get_rowbytes( fin, pnginfo );
|
||||
png.bpp = png_get_channels( fin, pnginfo );
|
||||
png.FRowPtrs = (byte **)Mem_Alloc( Sys.imagepool, png.height * sizeof(*png.FRowPtrs));
|
||||
png.FRowPtrs = (byte **)Mem_Alloc( Sys.imagepool, png.height * sizeof( *png.FRowPtrs ));
|
||||
|
||||
if( png.FRowPtrs )
|
||||
{
|
||||
|
@ -226,7 +225,7 @@ bool Image_SavePNG( const char *name, rgbdata_t *pix )
|
|||
byte **row;
|
||||
int i, pixel_size;
|
||||
|
||||
if(FS_FileExists( name ) && !(image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !( image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
// get image description
|
||||
|
@ -243,7 +242,7 @@ bool Image_SavePNG( const char *name, rgbdata_t *pix )
|
|||
return false;
|
||||
}
|
||||
|
||||
png.file = FS_Open( name, "wb" );
|
||||
png.file = FS_Open( name, "wb", false );
|
||||
if( !png.file ) return false;
|
||||
|
||||
if(!(fin = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL )))
|
||||
|
@ -252,14 +251,14 @@ bool Image_SavePNG( const char *name, rgbdata_t *pix )
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!(info = png_create_info_struct( fin )))
|
||||
if(!( info = png_create_info_struct( fin )))
|
||||
{
|
||||
png_destroy_write_struct( &fin, NULL );
|
||||
FS_Close( png.file );
|
||||
return false;
|
||||
}
|
||||
|
||||
if(setjmp((int*)fin))
|
||||
if( setjmp((int *)fin ))
|
||||
{
|
||||
png_destroy_write_struct( &fin, &info );
|
||||
FS_Close( png.file );
|
||||
|
|
|
@ -210,18 +210,18 @@ bool Image_SaveTGA( const char *name, rgbdata_t *pix )
|
|||
byte *buffer, *out;
|
||||
const char *comment = "Generated by Xash ImageLib\0";
|
||||
|
||||
if( FS_FileExists( name ) && !( image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
if( FS_FileExists( name, false ) && !( image.cmd_flags & IL_ALLOW_OVERWRITE ))
|
||||
return false; // already existed
|
||||
|
||||
if( pix->flags & IMAGE_HAS_ALPHA )
|
||||
outsize = pix->width * pix->height * 4 + 18 + com_strlen( comment );
|
||||
else outsize = pix->width * pix->height * 3 + 18 + com_strlen( comment );
|
||||
outsize = pix->width * pix->height * 4 + 18 + com.strlen( comment );
|
||||
else outsize = pix->width * pix->height * 3 + 18 + com.strlen( comment );
|
||||
|
||||
buffer = (byte *)Mem_Alloc( Sys.imagepool, outsize );
|
||||
Mem_Set( buffer, 0, 18 );
|
||||
|
||||
// prepare header
|
||||
buffer[0] = com_strlen( comment ); // tga comment length
|
||||
buffer[0] = com.strlen( comment ); // tga comment length
|
||||
buffer[2] = 2; // uncompressed type
|
||||
buffer[12] = (pix->width >> 0) & 0xFF;
|
||||
buffer[13] = (pix->width >> 8) & 0xFF;
|
||||
|
@ -229,8 +229,8 @@ bool Image_SaveTGA( const char *name, rgbdata_t *pix )
|
|||
buffer[15] = (pix->height >> 8) & 0xFF;
|
||||
buffer[16] = ( pix->flags & IMAGE_HAS_ALPHA ) ? 32 : 24;
|
||||
buffer[17] = ( pix->flags & IMAGE_HAS_ALPHA ) ? 8 : 0; // 8 bits of alpha
|
||||
com_strncpy( buffer + 18, comment, com_strlen( comment ));
|
||||
out = buffer + 18 + com_strlen( comment );
|
||||
com.strncpy( buffer + 18, comment, com.strlen( comment ));
|
||||
out = buffer + 18 + com.strlen( comment );
|
||||
|
||||
// get image description
|
||||
switch( pix->type )
|
||||
|
|
|
@ -435,7 +435,7 @@ bool Image_LumpValidSize( const char *name )
|
|||
{
|
||||
if( image.width > LUMP_MAXWIDTH || image.height > LUMP_MAXHEIGHT || image.width <= 0 || image.height <= 0 )
|
||||
{
|
||||
if(!com_stristr( name, "#internal" )) // internal errors are silent
|
||||
if(!com.stristr( name, "#internal" )) // internal errors are silent
|
||||
MsgDev(D_WARN, "Image_LumpValidSize: (%s) dims out of range[%dx%d]\n", name, image.width,image.height );
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,8 @@ size_t Image_VTFCalcMipmapSize( vtf_t *hdr, int mipNum )
|
|||
size_t buffsize = 0;
|
||||
int w, h, mipsize;
|
||||
|
||||
w = max( 1, LittleShort(hdr->width)>>mipNum );
|
||||
h = max( 1, LittleShort(hdr->height)>>mipNum );
|
||||
w = max( 1, LittleShort( hdr->width )>>mipNum );
|
||||
h = max( 1, LittleShort( hdr->height )>>mipNum );
|
||||
mipsize = Image_DXTGetLinearSize( image.type, w, h, 1, 0 );
|
||||
return mipsize;
|
||||
}
|
||||
|
@ -223,7 +223,9 @@ bool Image_LoadVTF( const char *name, const byte *buffer, size_t filesize )
|
|||
hdrSize = LittleLong( vtf.hdr_size );
|
||||
biasSize = 0;
|
||||
|
||||
if( LittleLong( vtf.ident ) != VTFHEADER ) return false; // it's not a vtf file, just skip it
|
||||
if( LittleLong( vtf.ident ) != VTFHEADER )
|
||||
return false; // it's not a vtf file, just skip it
|
||||
|
||||
FS_FileBase( name, shortname );
|
||||
|
||||
// bounds check
|
||||
|
@ -245,7 +247,7 @@ bool Image_LoadVTF( const char *name, const byte *buffer, size_t filesize )
|
|||
|
||||
// translate VF_flags into IMAGE_flags
|
||||
flags = LittleLong( vtf.flags );
|
||||
if((flags & VF_ONEBITALPHA) || (flags & VF_EIGHTBITALPHA))
|
||||
if(( flags & VF_ONEBITALPHA ) || ( flags & VF_EIGHTBITALPHA ))
|
||||
image.flags |= IMAGE_HAS_ALPHA;
|
||||
if( flags & VF_ENVMAP ) image.flags |= IMAGE_CUBEMAP;
|
||||
|
||||
|
@ -278,10 +280,10 @@ bool Image_LoadVTF( const char *name, const byte *buffer, size_t filesize )
|
|||
// convert VTF to DXT
|
||||
Image_VTFSwapBuffer( &vtf, fin, resSize, oldformat );
|
||||
|
||||
// FIXME: set IMAGE_HAS_ALPHA and IMAGE_HAS_COLOR properly
|
||||
// all supported VTF formats for now potentially has color
|
||||
image.flags |= IMAGE_HAS_COLOR;
|
||||
|
||||
if( Image_ForceDecompress())
|
||||
if( Image_ForceDecompress( ))
|
||||
{
|
||||
int offset, numsides = 1;
|
||||
uint target = 1;
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "imagelib.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "wadfile.h"
|
||||
#include "studio.h"
|
||||
#include "sprite.h"
|
||||
#include "qfont.h"
|
||||
|
||||
/*
|
||||
============
|
||||
|
|
|
@ -235,6 +235,10 @@ long Com_RandomLong( long lMin, long lMax );
|
|||
float Com_RandomFloat( float fMin, float fMax );
|
||||
uint Com_HashKey( const char *string, uint hashSize );
|
||||
|
||||
// lzss compression
|
||||
uint lzss_compress( const byte *in, const byte *inend, byte *out, byte *outend );
|
||||
bool lzss_decompress( const byte *in, const byte *inend, byte *out, byte *outend );
|
||||
|
||||
//
|
||||
// math.c
|
||||
//
|
||||
|
@ -341,23 +345,21 @@ wavdata_t *FS_StreamInfo( stream_t *stream );
|
|||
long FS_ReadStream( stream_t *stream, int bytes, void *buffer );
|
||||
void FS_FreeStream( stream_t *stream );
|
||||
|
||||
search_t *FS_Search(const char *pattern, int caseinsensitive );
|
||||
search_t *FS_SearchDirs(const char *pattern, int caseinsensitive );
|
||||
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly );
|
||||
|
||||
// files managment (like fopen, fread etc)
|
||||
file_t *FS_Open( const char *filepath, const char *mode );
|
||||
file_t* _FS_Open( const char *filepath, const char *mode, bool quiet );
|
||||
file_t *FS_Open( const char *filepath, const char *mode, bool gamedironly );
|
||||
fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize );
|
||||
fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize );
|
||||
int FS_VPrintf( file_t *file, const char *format, va_list ap );
|
||||
int FS_Seek( file_t *file, fs_offset_t offset, int whence );
|
||||
int FS_Gets( file_t *file, byte *string, size_t bufsize );
|
||||
int FS_Printf( file_t *file, const char *format, ... );
|
||||
fs_offset_t FS_FileSize( const char *filename );
|
||||
fs_offset_t FS_FileTime( const char *filename );
|
||||
fs_offset_t FS_FileSize( const char *filename, bool gamedironly );
|
||||
fs_offset_t FS_FileTime( const char *filename, bool gamedironly );
|
||||
int FS_Print( file_t *file, const char *msg );
|
||||
bool FS_Rename( const char *oldname, const char *newname );
|
||||
bool FS_FileExists( const char *filename );
|
||||
bool FS_FileExists( const char *filename, bool gamedironly );
|
||||
bool FS_Delete( const char *path );
|
||||
int FS_UnGetc( file_t *file, byte c );
|
||||
void FS_StripExtension( char *path );
|
||||
|
@ -428,7 +430,6 @@ int VFS_Print( vfile_t* file, const char *msg );
|
|||
int VFS_Printf( vfile_t* file, const char* format, ... );
|
||||
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence );
|
||||
int VFS_Gets( vfile_t *file, byte *string, size_t bufsize );
|
||||
bool VFS_Unpack( void *compbuf, size_t compsize, void **buf, size_t size );
|
||||
byte *VFS_GetBuffer( vfile_t *file );
|
||||
fs_offset_t VFS_Tell (vfile_t *file );
|
||||
file_t *VFS_Close( vfile_t *file );
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: launch - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB2.tmp" with contents
|
||||
[
|
||||
/nologo /MD /W3 /GX /O2 /I "./" /I "imagelib" /I "../public" /I "../common" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\launch\!release/" /Fd"..\temp\launch\!release/" /FD /c
|
||||
"D:\Xash3D\src_main\launch\filesystem.c"
|
||||
]
|
||||
Creating command line "cl.exe @"C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB2.tmp""
|
||||
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB3.tmp" with contents
|
||||
[
|
||||
zlib.lib png.lib jpg.lib ogg.lib vorbis.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmt" /out:"..\temp\launch\!release/launch.dll" /implib:"..\temp\launch\!release/launch.lib" /libpath:"./imagelib" /libpath:"./soundlib" /opt:nowin98
|
||||
"\Xash3D\src_main\temp\launch\!release\cmd.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\console.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\cpuinfo.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\crclib.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\cvar.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\export.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\filesystem.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_bmp.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_dds.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_jpg.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_main.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_pcx.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_png.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_tga.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_utils.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_vtf.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\img_wad.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\library.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\memlib.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\network.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\parselib.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\snd_main.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\snd_ogg.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\snd_raw.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\snd_utils.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\snd_wav.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\stdlib.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\system.obj"
|
||||
"\Xash3D\src_main\temp\launch\!release\utils.obj"
|
||||
]
|
||||
Creating command line "link.exe @"C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB3.tmp""
|
||||
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB4.bat" with contents
|
||||
[
|
||||
@echo off
|
||||
copy \Xash3D\src_main\temp\launch\!release\launch.dll "D:\Xash3D\bin\launch.dll"
|
||||
]
|
||||
Creating command line ""C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSP1FB4.bat""
|
||||
Compiling...
|
||||
filesystem.c
|
||||
D:\Xash3D\src_main\launch\filesystem.c(3668) : error C2039: 'compress' : is not a member of 'vfile_s'
|
||||
D:\Xash3D\src_main\launch\filesystem.c(63) : see declaration of 'vfile_s'
|
||||
D:\Xash3D\src_main\launch\filesystem.c(4053) : error C2065: 'CMP_ZLIB' : undeclared identifier
|
||||
D:\Xash3D\src_main\launch\filesystem.c(4053) : error C2051: case expression not constant
|
||||
D:\Xash3D\src_main\launch\filesystem.c(4110) : error C2051: case expression not constant
|
||||
Error executing cl.exe.
|
||||
<h3>Output Window</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
launch.dll - 4 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -542,7 +542,7 @@ bool LibraryLoadSymbols( dll_user_t *hInst )
|
|||
for( i = 0; i < hInst->num_ordinals; i++ )
|
||||
hInst->names[i] = NULL;
|
||||
|
||||
f = FS_Open( hInst->shortPath, "rb" );
|
||||
f = FS_Open( hInst->shortPath, "rb", false );
|
||||
if( !f )
|
||||
{
|
||||
com.sprintf( errorstring, "couldn't load %s", hInst->shortPath );
|
||||
|
|
|
@ -1116,7 +1116,7 @@ byte *_mem_allocpool(const char *name, const char *filename, int fileline)
|
|||
pool->chain = NULL;
|
||||
pool->totalsize = 0;
|
||||
pool->realsize = sizeof(mempool_t);
|
||||
com_strncpy(pool->name, name, sizeof (pool->name));
|
||||
com.strncpy(pool->name, name, sizeof (pool->name));
|
||||
pool->next = poolchain;
|
||||
poolchain = pool;
|
||||
|
||||
|
@ -1281,14 +1281,14 @@ void _mem_printlist( size_t minallocationsize )
|
|||
|
||||
void MemList_f( void )
|
||||
{
|
||||
switch(Cmd_Argc())
|
||||
switch( Cmd_Argc( ))
|
||||
{
|
||||
case 1:
|
||||
_mem_printlist(1<<30);
|
||||
_mem_printlist( 1<<30 );
|
||||
_mem_printstats();
|
||||
break;
|
||||
case 2:
|
||||
_mem_printlist(com_atoi(Cmd_Argv(1)) * 1024);
|
||||
_mem_printlist( com.atoi( Cmd_Argv( 1 )) * 1024 );
|
||||
_mem_printstats();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1340,7 +1340,7 @@ void PS_ScriptError( script_t *script, scFlags_t flags, const char *fmt, ... )
|
|||
return;
|
||||
|
||||
va_start( argPtr, fmt );
|
||||
com_vsnprintf( errorstring, sizeof( errorstring ), fmt, argPtr );
|
||||
com.vsnprintf( errorstring, sizeof( errorstring ), fmt, argPtr );
|
||||
va_end( argPtr );
|
||||
|
||||
MsgDev( D_ERROR, "source '%s', line %i: %s\n", script->name, script->line, errorstring );
|
||||
|
|
|
@ -81,9 +81,9 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
|||
// now try all the formats in the selected list
|
||||
for( format = sound.loadformats; format && format->formatstring; format++)
|
||||
{
|
||||
if( anyformat || !com_stricmp( ext, format->ext ))
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
com_sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
com.sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
f = FS_LoadFile( path, &filesize );
|
||||
if( f && filesize > 0 )
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
|||
load_internal:
|
||||
for( format = sound.baseformats; format && format->formatstring; format++ )
|
||||
{
|
||||
if( anyformat || !com_stricmp( ext, format->ext ))
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
if( buffer && size > 0 )
|
||||
{
|
||||
|
@ -127,8 +127,24 @@ writes image as any known format
|
|||
*/
|
||||
bool FS_SaveSound( const char *filename, wavdata_t *wav )
|
||||
{
|
||||
// FIXME: not implemented
|
||||
return false;
|
||||
const char *ext = FS_FileExtension( filename );
|
||||
bool anyformat = !com.stricmp( ext, "" ) ? true : false;
|
||||
string path, savename;
|
||||
const savewavformat_t *format;
|
||||
|
||||
if( !wav || !wav->buffer || anyformat ) return false;
|
||||
com.strncpy( savename, filename, sizeof( savename ));
|
||||
FS_StripExtension( savename ); // remove extension if needed
|
||||
|
||||
for( format = sound.saveformats; format && format->formatstring; format++ )
|
||||
{
|
||||
if( !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
com.sprintf( path, format->formatstring, savename, "", format->ext );
|
||||
if( format->savefunc( path, wav )) return true; // saved
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -187,9 +203,9 @@ stream_t *FS_OpenStream( const char *filename )
|
|||
// now try all the formats in the selected list
|
||||
for( format = sound.streamformat; format && format->formatstring; format++)
|
||||
{
|
||||
if( anyformat || !com_stricmp( ext, format->ext ))
|
||||
if( anyformat || !com.stricmp( ext, format->ext ))
|
||||
{
|
||||
com_sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
com.sprintf( path, format->formatstring, loadname, "", format->ext );
|
||||
if(( stream = format->openfunc( path )) != NULL )
|
||||
{
|
||||
stream->format = format;
|
||||
|
|
|
@ -415,7 +415,7 @@ stream_t *Stream_OpenOGG( const char *filename )
|
|||
stream_t *stream;
|
||||
file_t *file;
|
||||
|
||||
file = FS_Open( filename, "rb" );
|
||||
file = FS_Open( filename, "rb", false );
|
||||
if( !file ) return NULL;
|
||||
|
||||
// at this point we have valid stream
|
||||
|
|
|
@ -199,6 +199,15 @@ void Sound_Shutdown( void )
|
|||
Mem_FreePool( &Sys.soundpool );
|
||||
}
|
||||
|
||||
byte *Sound_Copy( size_t size )
|
||||
{
|
||||
byte *out;
|
||||
|
||||
out = Mem_Alloc( Sys.soundpool, size );
|
||||
Mem_Copy( out, sound.tempbuffer, size );
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Sound_ByteSwapRawSamples
|
||||
|
@ -218,8 +227,145 @@ void Sound_ByteSwapRawSamples( int samples, int width, int s_channels, const byt
|
|||
((short *)data)[i] = LittleShort((( short *)data)[i] );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sound_ConvertToSigned
|
||||
|
||||
Convert unsigned data to signed
|
||||
================
|
||||
*/
|
||||
void Sound_ConvertToSigned( const byte *data, int channels, int samples )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( channels == 2 )
|
||||
{
|
||||
for( i = 0; i < samples; i++ )
|
||||
{
|
||||
((signed char *)sound.tempbuffer)[i*2+0] = (int)((byte)(data[i*2+0]) - 128);
|
||||
((signed char *)sound.tempbuffer)[i*2+1] = (int)((byte)(data[i*2+1]) - 128);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < samples; i++ )
|
||||
((signed char *)sound.tempbuffer)[i] = (int)((unsigned char)(data[i]) - 128);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sound_ResampleInternal
|
||||
|
||||
We need convert sound to signed even if nothing to resample
|
||||
================
|
||||
*/
|
||||
bool Sound_ResampleInternal( wavdata_t *sc, int inrate, int inwidth, int outrate, int outwidth )
|
||||
{
|
||||
float stepscale;
|
||||
int outcount, srcsample;
|
||||
int i, sample, sample2, samplefrac, fracstep;
|
||||
byte *data;
|
||||
|
||||
data = sc->buffer;
|
||||
stepscale = (float)inrate / outrate; // this is usually 0.5, 1, or 2
|
||||
outcount = sc->samples / stepscale;
|
||||
sc->size = outcount * outwidth * sc->channels;
|
||||
|
||||
sound.tempbuffer = (byte *)Mem_Realloc( Sys.soundpool, sound.tempbuffer, sc->size );
|
||||
|
||||
sc->samples = outcount;
|
||||
if( sc->loopStart != -1 )
|
||||
sc->loopStart = sc->loopStart / stepscale;
|
||||
|
||||
// resample / decimate to the current source rate
|
||||
if( stepscale == 1.0f && inwidth == 1 && outwidth == 1 )
|
||||
{
|
||||
Sound_ConvertToSigned( data, sc->channels, outcount );
|
||||
}
|
||||
else
|
||||
{
|
||||
// general case
|
||||
samplefrac = 0;
|
||||
fracstep = stepscale * 256;
|
||||
|
||||
if( sc->channels == 2 )
|
||||
{
|
||||
for( i = 0; i < outcount; i++ )
|
||||
{
|
||||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
|
||||
if( inwidth == 2 )
|
||||
{
|
||||
sample = LittleShort(((short *)data)[srcsample*2+0] );
|
||||
sample2 = LittleShort(((short *)data)[srcsample*2+1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
sample = (int)( (unsigned char)(data[srcsample*2+0]) - 128) << 8;
|
||||
sample2 = (int)( (unsigned char)(data[srcsample*2+1]) - 128) << 8;
|
||||
}
|
||||
|
||||
if( outwidth == 2 )
|
||||
{
|
||||
((short *)sound.tempbuffer)[i*2+0] = sample;
|
||||
((short *)sound.tempbuffer)[i*2+1] = sample2;
|
||||
}
|
||||
else
|
||||
{
|
||||
((signed char *)sound.tempbuffer)[i*2+0] = sample >> 8;
|
||||
((signed char *)sound.tempbuffer)[i*2+1] = sample2 >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < outcount; i++ )
|
||||
{
|
||||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
|
||||
if( inwidth == 2 ) sample = LittleShort(((short *)data)[srcsample] );
|
||||
else sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
|
||||
|
||||
if( outwidth == 2 ) ((short *)sound.tempbuffer)[i] = sample;
|
||||
else ((signed char *)sound.tempbuffer)[i] = sample >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
MsgDev( D_NOTE, "Sound_Resample: from[%d bit %d kHz] to [%d bit %d kHz]\n",
|
||||
inwidth * 8, inrate, outwidth * 8, outrate );
|
||||
}
|
||||
|
||||
sc->rate = outrate;
|
||||
sc->width = outwidth;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sound_Process( wavdata_t **wav, int rate, int width, uint flags )
|
||||
{
|
||||
// FIXME: not implemented
|
||||
wavdata_t *snd = *wav;
|
||||
bool result = true;
|
||||
|
||||
// check for buffers
|
||||
if( !snd || !snd->buffer )
|
||||
{
|
||||
MsgDev( D_WARN, "Sound_Process: NULL sound\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( flags & SOUND_RESAMPLE && ( width > 0 || rate > 0 ))
|
||||
{
|
||||
if( Sound_ResampleInternal( snd, snd->rate, snd->width, rate, width ))
|
||||
{
|
||||
Mem_Free( snd->buffer ); // free original image buffer
|
||||
snd->buffer = Sound_Copy( snd->size ); // unzone buffer (don't touch image.tempbuffer)
|
||||
}
|
||||
else result = false; // not a resampled
|
||||
}
|
||||
*wav = snd;
|
||||
|
||||
return false;
|
||||
}
|
|
@ -259,7 +259,7 @@ stream_t *Stream_OpenWAV( const char *filename )
|
|||
return NULL;
|
||||
|
||||
// open
|
||||
file = FS_Open( filename, "rb" );
|
||||
file = FS_Open( filename, "rb", false );
|
||||
if( !file ) return NULL;
|
||||
|
||||
// find "RIFF" chunk
|
||||
|
|
325
launch/stdlib.c
325
launch/stdlib.c
|
@ -6,13 +6,13 @@
|
|||
#include "launch.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
void com_strnupr(const char *in, char *out, size_t size_out)
|
||||
void com_strnupr( const char *in, char *out, size_t size_out )
|
||||
{
|
||||
if (size_out == 0) return;
|
||||
if( size_out == 0 ) return;
|
||||
|
||||
while (*in && size_out > 1)
|
||||
while( *in && size_out > 1 )
|
||||
{
|
||||
if (*in >= 'a' && *in <= 'z')
|
||||
if( *in >= 'a' && *in <= 'z' )
|
||||
*out++ = *in++ + 'A' - 'a';
|
||||
else *out++ = *in++;
|
||||
size_out--;
|
||||
|
@ -20,18 +20,18 @@ void com_strnupr(const char *in, char *out, size_t size_out)
|
|||
*out = '\0';
|
||||
}
|
||||
|
||||
void com_strupr(const char *in, char *out)
|
||||
void com_strupr( const char *in, char *out )
|
||||
{
|
||||
com_strnupr(in, out, 99999 );
|
||||
com_strnupr( in, out, 99999 );
|
||||
}
|
||||
|
||||
void com_strnlwr(const char *in, char *out, size_t size_out)
|
||||
void com_strnlwr( const char *in, char *out, size_t size_out )
|
||||
{
|
||||
if (size_out == 0) return;
|
||||
if( size_out == 0 ) return;
|
||||
|
||||
while (*in && size_out > 1)
|
||||
while( *in && size_out > 1 )
|
||||
{
|
||||
if (*in >= 'A' && *in <= 'Z')
|
||||
if( *in >= 'A' && *in <= 'Z' )
|
||||
*out++ = *in++ + 'a' - 'A';
|
||||
else *out++ = *in++;
|
||||
size_out--;
|
||||
|
@ -39,7 +39,7 @@ void com_strnlwr(const char *in, char *out, size_t size_out)
|
|||
*out = '\0';
|
||||
}
|
||||
|
||||
void com_strlwr(const char *in, char *out)
|
||||
void com_strlwr( const char *in, char *out )
|
||||
{
|
||||
com_strnlwr(in, out, 99999 );
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ int com_cstrlen( const char *string )
|
|||
p = string;
|
||||
while( *p )
|
||||
{
|
||||
if(IsColorString( p ))
|
||||
if( IsColorString( p ))
|
||||
{
|
||||
p += 2;
|
||||
continue;
|
||||
|
@ -112,46 +112,48 @@ int com_cstrlen( const char *string )
|
|||
return len;
|
||||
}
|
||||
|
||||
char com_toupper(const char in )
|
||||
char com_toupper( const char in )
|
||||
{
|
||||
char out;
|
||||
char out;
|
||||
|
||||
if (in >= 'a' && in <= 'z')
|
||||
if( in >= 'a' && in <= 'z' )
|
||||
out = in + 'A' - 'a';
|
||||
else out = in;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
char com_tolower(const char in )
|
||||
char com_tolower( const char in )
|
||||
{
|
||||
char out;
|
||||
char out;
|
||||
|
||||
if (in >= 'A' && in <= 'Z')
|
||||
if( in >= 'A' && in <= 'Z' )
|
||||
out = in + 'a' - 'A';
|
||||
else out = in;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t com_strncat(char *dst, const char *src, size_t size)
|
||||
size_t com_strncat( char *dst, const char *src, size_t size )
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = size;
|
||||
size_t dlen;
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = size;
|
||||
size_t dlen;
|
||||
|
||||
if(!dst || !src || !size) return 0;
|
||||
if( !dst || !src || !size )
|
||||
return 0;
|
||||
|
||||
// find the end of dst and adjust bytes left but don't go past end
|
||||
while(n-- != 0 && *d != '\0') d++;
|
||||
while( n-- != 0 && *d != '\0' ) d++;
|
||||
dlen = d - dst;
|
||||
n = size - dlen;
|
||||
|
||||
if (n == 0) return(dlen + com_strlen(s));
|
||||
while (*s != '\0')
|
||||
if( n == 0 ) return( dlen + com_strlen( s ));
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
if (n != 1)
|
||||
if( n != 1 )
|
||||
{
|
||||
*d++ = *s;
|
||||
n--;
|
||||
|
@ -160,7 +162,7 @@ size_t com_strncat(char *dst, const char *src, size_t size)
|
|||
}
|
||||
|
||||
*d = '\0';
|
||||
return(dlen + (s - src)); // count does not include NULL
|
||||
return( dlen + ( s - src )); // count does not include NULL
|
||||
}
|
||||
|
||||
size_t com_strcat( char *dst, const char *src )
|
||||
|
@ -170,9 +172,9 @@ size_t com_strcat( char *dst, const char *src )
|
|||
|
||||
size_t com_strncpy( char *dst, const char *src, size_t size )
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = size;
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = size;
|
||||
|
||||
if( !dst || !src || !size )
|
||||
return 0;
|
||||
|
@ -194,7 +196,7 @@ size_t com_strncpy( char *dst, const char *src, size_t size )
|
|||
*d = '\0'; // NULL-terminate dst
|
||||
while( *s++ );
|
||||
}
|
||||
return( s - src - 1 ); // count does not include NULL
|
||||
return ( s - src - 1 ); // count does not include NULL
|
||||
}
|
||||
|
||||
size_t com_strcpy( char *dst, const char *src )
|
||||
|
@ -209,13 +211,13 @@ char *com_stralloc( byte *mempool, const char *s, const char *filename, int file
|
|||
if( !s ) return NULL;
|
||||
if( !mempool ) mempool = Sys.stringpool;
|
||||
|
||||
b = _mem_alloc( mempool, com_strlen(s) + 1, filename, fileline );
|
||||
b = _mem_alloc( mempool, com_strlen( s ) + 1, filename, fileline );
|
||||
com_strcpy( b, s );
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
int com_atoi(const char *str)
|
||||
int com_atoi( const char *str )
|
||||
{
|
||||
int val = 0;
|
||||
int c, sign;
|
||||
|
@ -285,34 +287,38 @@ float com_atof( const char *str )
|
|||
while( 1 )
|
||||
{
|
||||
c = *str++;
|
||||
if (c >= '0' && c <= '9') val = (val * 16) + c - '0';
|
||||
else if (c >= 'a' && c <= 'f') val = (val * 16) + c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F') val = (val * 16) + c - 'A' + 10;
|
||||
if( c >= '0' && c <= '9' ) val = (val * 16) + c - '0';
|
||||
else if( c >= 'a' && c <= 'f' ) val = (val * 16) + c - 'a' + 10;
|
||||
else if( c >= 'A' && c <= 'F' ) val = (val * 16) + c - 'A' + 10;
|
||||
else return val * sign;
|
||||
}
|
||||
}
|
||||
|
||||
// check for character
|
||||
if (str[0] == '\'') return sign * str[1];
|
||||
if( str[0] == '\'' ) return sign * str[1];
|
||||
|
||||
// assume decimal
|
||||
decimal = -1;
|
||||
total = 0;
|
||||
while (1)
|
||||
while( 1 )
|
||||
{
|
||||
c = *str++;
|
||||
if (c == '.')
|
||||
if( c == '.' )
|
||||
{
|
||||
decimal = total;
|
||||
continue;
|
||||
}
|
||||
if (c <'0' || c > '9') break;
|
||||
val = val*10 + c - '0';
|
||||
|
||||
if( c < '0' || c > '9' )
|
||||
break;
|
||||
val = val * 10 + c - '0';
|
||||
total++;
|
||||
}
|
||||
|
||||
if(decimal == -1) return val * sign;
|
||||
while (total > decimal)
|
||||
if( decimal == -1 )
|
||||
return val * sign;
|
||||
|
||||
while( total > decimal )
|
||||
{
|
||||
val /= 10;
|
||||
total--;
|
||||
|
@ -327,11 +333,11 @@ void com_atov( float *vec, const char *str, size_t siz )
|
|||
char *pstr, *pfront;
|
||||
int j;
|
||||
|
||||
com.strncpy( buffer, str, sizeof( buffer ));
|
||||
com_strncpy( buffer, str, sizeof( buffer ));
|
||||
Mem_Set( vec, 0, sizeof(vec_t) * siz );
|
||||
pstr = pfront = buffer;
|
||||
|
||||
for ( j = 0; j < siz; j++ )
|
||||
for( j = 0; j < siz; j++ )
|
||||
{
|
||||
vec[j] = com.atof( pfront );
|
||||
|
||||
|
@ -339,7 +345,7 @@ void com_atov( float *vec, const char *str, size_t siz )
|
|||
while( *pstr && *pstr != ' ' )
|
||||
pstr++;
|
||||
|
||||
if (!*pstr) break;
|
||||
if( !*pstr ) break;
|
||||
pstr++;
|
||||
pfront = pstr;
|
||||
}
|
||||
|
@ -356,7 +362,11 @@ char *com_strchr( const char *s, char c )
|
|||
{
|
||||
int len = com_strlen( s );
|
||||
|
||||
while( len-- ) if( *++s == c ) return(char *)s;
|
||||
while( len-- )
|
||||
{
|
||||
if( *++s == c )
|
||||
return(char *)s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -370,73 +380,79 @@ find one charcster in string
|
|||
char *com_strrchr( const char *s, char c )
|
||||
{
|
||||
int len = com_strlen( s );
|
||||
|
||||
s += len;
|
||||
while( len-- ) if( *--s == c ) return (char *)s;
|
||||
|
||||
while( len-- )
|
||||
{
|
||||
if( *--s == c )
|
||||
return (char *)s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int com_strnicmp( const char *s1, const char *s2, int n )
|
||||
{
|
||||
int c1, c2;
|
||||
int c1, c2;
|
||||
|
||||
if( s1 == NULL )
|
||||
{
|
||||
if ( s2 == NULL ) return 0;
|
||||
if( s2 == NULL ) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if ( s2 == NULL ) return 1;
|
||||
else if( s2 == NULL ) return 1;
|
||||
|
||||
do {
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
|
||||
if(!n--) return 0; // strings are equal until end point
|
||||
if( !n-- ) return 0; // strings are equal until end point
|
||||
|
||||
if(c1 != c2)
|
||||
if( c1 != c2 )
|
||||
{
|
||||
if(c1 >= 'a' && c1 <= 'z') c1 -= ('a' - 'A');
|
||||
if(c2 >= 'a' && c2 <= 'z') c2 -= ('a' - 'A');
|
||||
if(c1 != c2) return c1 < c2 ? -1 : 1;
|
||||
if( c1 >= 'a' && c1 <= 'z' ) c1 -= ('a' - 'A');
|
||||
if( c2 >= 'a' && c2 <= 'z' ) c2 -= ('a' - 'A');
|
||||
if( c1 != c2 ) return c1 < c2 ? -1 : 1;
|
||||
}
|
||||
} while (c1);
|
||||
} while( c1 );
|
||||
|
||||
// strings are equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
int com_strncmp (const char *s1, const char *s2, int n)
|
||||
int com_strncmp( const char *s1, const char *s2, int n )
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
if( s1 == NULL )
|
||||
{
|
||||
if ( s2 == NULL ) return 0;
|
||||
if( s2 == NULL ) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if ( s2 == NULL ) return 1;
|
||||
else if( s2 == NULL ) return 1;
|
||||
|
||||
do {
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
|
||||
// strings are equal until end point
|
||||
if (!n--) return 0;
|
||||
if (c1 != c2) return c1 < c2 ? -1 : 1;
|
||||
if( !n-- ) return 0;
|
||||
if( c1 != c2 ) return c1 < c2 ? -1 : 1;
|
||||
|
||||
} while (c1);
|
||||
} while( c1 );
|
||||
|
||||
// strings are equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
int com_stricmp(const char *s1, const char *s2)
|
||||
int com_stricmp( const char *s1, const char *s2 )
|
||||
{
|
||||
return com_strnicmp(s1, s2, 99999 );
|
||||
return com_strnicmp( s1, s2, 99999 );
|
||||
}
|
||||
|
||||
int com_strcmp (const char *s1, const char *s2)
|
||||
int com_strcmp( const char *s1, const char *s2 )
|
||||
{
|
||||
return com_strncmp(s1, s2, 99999 );
|
||||
return com_strncmp( s1, s2, 99999 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -457,7 +473,7 @@ static bool com_starcmp( const char *pattern, const char *text )
|
|||
|
||||
if( c == '\0' ) return true;
|
||||
|
||||
for( c1 = ((c == '\\') ? *p : c); ; )
|
||||
for( c1 = (( c == '\\' ) ? *p : c ); ; )
|
||||
{
|
||||
if( com_tolower( *t ) == c1 && com_stricmpext( p - 1, t ))
|
||||
return true;
|
||||
|
@ -474,26 +490,26 @@ bool com_stricmpext( const char *pattern, const char *text )
|
|||
{
|
||||
char c;
|
||||
|
||||
while( (c = *pattern++) != '\0' )
|
||||
while(( c = *pattern++ ) != '\0' )
|
||||
{
|
||||
switch( c )
|
||||
{
|
||||
case '?':
|
||||
if( *text++ == '\0' )
|
||||
return false;
|
||||
break;
|
||||
case '\\':
|
||||
if( com_tolower( *pattern++ ) != com_tolower( *text++ ))
|
||||
return false;
|
||||
break;
|
||||
case '*':
|
||||
return com_starcmp( pattern, text );
|
||||
default:
|
||||
if( com_tolower( c ) != com_tolower( *text++ ))
|
||||
return false;
|
||||
case '?':
|
||||
if( *text++ == '\0' )
|
||||
return false;
|
||||
break;
|
||||
case '\\':
|
||||
if( com_tolower( *pattern++ ) != com_tolower( *text++ ))
|
||||
return false;
|
||||
break;
|
||||
case '*':
|
||||
return com_starcmp( pattern, text );
|
||||
default:
|
||||
if( com_tolower( c ) != com_tolower( *text++ ))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (*text == '\0');
|
||||
return ( *text == '\0' );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -510,36 +526,37 @@ const char* com_timestamp( int format )
|
|||
|
||||
time( &crt_time );
|
||||
crt_tm = localtime( &crt_time );
|
||||
|
||||
switch( format )
|
||||
{
|
||||
case TIME_FULL:
|
||||
// Build the full timestamp (ex: "Apr03 2007 [23:31.55]");
|
||||
strftime(timestring, sizeof (timestring), "%b%d %Y [%H:%M.%S]", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%b%d %Y [%H:%M.%S]", crt_tm );
|
||||
break;
|
||||
case TIME_DATE_ONLY:
|
||||
// Build the date stamp only (ex: "Apr03 2007");
|
||||
strftime(timestring, sizeof (timestring), "%b%d %Y", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%b%d %Y", crt_tm );
|
||||
break;
|
||||
case TIME_TIME_ONLY:
|
||||
// Build the time stamp only (ex: "23:31.55");
|
||||
strftime(timestring, sizeof (timestring), "%H:%M.%S", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%H:%M.%S", crt_tm );
|
||||
break;
|
||||
case TIME_NO_SECONDS:
|
||||
// Build the time stamp exclude seconds (ex: "13:46");
|
||||
strftime(timestring, sizeof (timestring), "%H:%M", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%H:%M", crt_tm );
|
||||
break;
|
||||
case TIME_YEAR_ONLY:
|
||||
// Build the date stamp year only (ex: "2006");
|
||||
strftime(timestring, sizeof (timestring), "%Y", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%Y", crt_tm );
|
||||
break;
|
||||
case TIME_FILENAME:
|
||||
// Build a timestamp that can use for filename (ex: "Nov2006-26 (19.14.28)");
|
||||
strftime(timestring, sizeof (timestring), "%b%Y-%d_%H.%M.%S", crt_tm);
|
||||
strftime( timestring, sizeof (timestring), "%b%Y-%d_%H.%M.%S", crt_tm );
|
||||
break;
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
com.strncpy( timestamp, timestring, sizeof( timestamp ));
|
||||
com_strncpy( timestamp, timestring, sizeof( timestamp ));
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
@ -552,7 +569,26 @@ search case - sensitive for string2 in string
|
|||
*/
|
||||
char *com_strstr( const char *string, const char *string2 )
|
||||
{
|
||||
return strstr( string, string2 ); //FIXME
|
||||
int c, len;
|
||||
|
||||
if( !string || !string2 ) return NULL;
|
||||
|
||||
c = *string2;
|
||||
len = com_strlen( string2 );
|
||||
|
||||
while( string )
|
||||
{
|
||||
for( ; *string && *string != c; string++ );
|
||||
|
||||
if( *string )
|
||||
{
|
||||
if( !com_strncmp( string, string2, len ))
|
||||
break;
|
||||
string++;
|
||||
}
|
||||
else return NULL;
|
||||
}
|
||||
return (char *)string;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -564,19 +600,20 @@ search case - insensitive for string2 in string
|
|||
*/
|
||||
char *com_stristr( const char *string, const char *string2 )
|
||||
{
|
||||
int c, len;
|
||||
int c, len;
|
||||
|
||||
if (!string || !string2) return NULL;
|
||||
if( !string || !string2 ) return NULL;
|
||||
|
||||
c = com_tolower( *string2 );
|
||||
len = com_strlen( string2 );
|
||||
|
||||
while (string)
|
||||
while( string )
|
||||
{
|
||||
for ( ; *string && com_tolower( *string ) != c; string++ );
|
||||
if (*string)
|
||||
for( ; *string && com_tolower( *string ) != c; string++ );
|
||||
|
||||
if( *string )
|
||||
{
|
||||
if(!com_strnicmp( string, string2, len ))
|
||||
if( !com_strnicmp( string, string2, len ))
|
||||
break;
|
||||
string++;
|
||||
}
|
||||
|
@ -585,12 +622,13 @@ char *com_stristr( const char *string, const char *string2 )
|
|||
return (char *)string;
|
||||
}
|
||||
|
||||
int com_vsnprintf(char *buffer, size_t buffersize, const char *format, va_list args)
|
||||
int com_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args )
|
||||
{
|
||||
int result;
|
||||
size_t result;
|
||||
|
||||
result = _vsnprintf (buffer, buffersize, format, args);
|
||||
if (result < 0 || (size_t)result >= buffersize)
|
||||
result = _vsnprintf( buffer, buffersize, format, args );
|
||||
|
||||
if( result < 0 || result >= buffersize )
|
||||
{
|
||||
buffer[buffersize - 1] = '\0';
|
||||
return -1;
|
||||
|
@ -598,56 +636,55 @@ int com_vsnprintf(char *buffer, size_t buffersize, const char *format, va_list a
|
|||
return result;
|
||||
}
|
||||
|
||||
int com_vsprintf(char *buffer, const char *format, va_list args)
|
||||
int com_vsprintf( char *buffer, const char *format, va_list args )
|
||||
{
|
||||
return com_vsnprintf(buffer, 99999, format, args);
|
||||
return com_vsnprintf( buffer, 99999, format, args );
|
||||
}
|
||||
|
||||
int com_snprintf(char *buffer, size_t buffersize, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int result;
|
||||
|
||||
va_start (args, format);
|
||||
result = com_vsnprintf (buffer, buffersize, format, args);
|
||||
va_end (args);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int com_sprintf(char *buffer, const char *format, ...)
|
||||
int com_snprintf( char *buffer, size_t buffersize, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
int result;
|
||||
|
||||
va_start (args, format);
|
||||
result = com_vsnprintf (buffer, 99999, format, args);
|
||||
va_end (args);
|
||||
va_start( args, format );
|
||||
result = com_vsnprintf( buffer, buffersize, format, args );
|
||||
va_end( args );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int com_sprintf( char *buffer, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
int result;
|
||||
|
||||
va_start( args, format );
|
||||
result = com_vsnprintf( buffer, 99999, format, args );
|
||||
va_end( args );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *com_pretifymem( float value, int digitsafterdecimal )
|
||||
{
|
||||
static char output[8][32];
|
||||
static int current;
|
||||
|
||||
float onekb = 1024.0f;
|
||||
float onemb = onekb * onekb;
|
||||
char suffix[8];
|
||||
char *out = output[current];
|
||||
char val[32], *i, *o, *dot;
|
||||
int pos;
|
||||
static char output[8][32];
|
||||
static int current;
|
||||
float onekb = 1024.0f;
|
||||
float onemb = onekb * onekb;
|
||||
char suffix[8];
|
||||
char *out = output[current];
|
||||
char val[32], *i, *o, *dot;
|
||||
int pos;
|
||||
|
||||
current = ( current + 1 ) & ( 8 - 1 );
|
||||
|
||||
// first figure out which bin to use
|
||||
if ( value > onemb )
|
||||
if( value > onemb )
|
||||
{
|
||||
value /= onemb;
|
||||
com_sprintf( suffix, " Mb" );
|
||||
}
|
||||
else if ( value > onekb )
|
||||
else if( value > onekb )
|
||||
{
|
||||
value /= onekb;
|
||||
com_sprintf( suffix, " Kb" );
|
||||
|
@ -656,8 +693,9 @@ char *com_pretifymem( float value, int digitsafterdecimal )
|
|||
|
||||
// clamp to >= 0
|
||||
digitsafterdecimal = max( digitsafterdecimal, 0 );
|
||||
|
||||
// if it's basically integral, don't do any decimals
|
||||
if(fabs( value - (int)value ) < 0.00001)
|
||||
if( fabs( value - (int)value ) < 0.00001 )
|
||||
{
|
||||
com_sprintf( val, "%i%s", (int)value, suffix );
|
||||
}
|
||||
|
@ -675,20 +713,22 @@ char *com_pretifymem( float value, int digitsafterdecimal )
|
|||
o = out;
|
||||
|
||||
// search for decimal or if it was integral, find the space after the raw number
|
||||
dot = strstr( i, "." );
|
||||
if ( !dot ) dot = strstr( i, " " );
|
||||
dot = com_strstr( i, "." );
|
||||
if( !dot ) dot = com_strstr( i, " " );
|
||||
|
||||
pos = dot - i; // compute position of dot
|
||||
pos -= 3; // don't put a comma if it's <= 3 long
|
||||
|
||||
while ( *i )
|
||||
while( *i )
|
||||
{
|
||||
// if pos is still valid then insert a comma every third digit, except if we would be
|
||||
// putting one in the first spot
|
||||
if ( pos >= 0 && !( pos % 3 ))
|
||||
if( pos >= 0 && !( pos % 3 ))
|
||||
{
|
||||
// never in first spot
|
||||
if ( o != out ) *o++ = ',';
|
||||
if( o != out ) *o++ = ',';
|
||||
}
|
||||
|
||||
pos--; // count down comma position
|
||||
*o++ = *i++; // copy rest of data as normal
|
||||
}
|
||||
|
@ -701,9 +741,9 @@ char *com_pretifymem( float value, int digitsafterdecimal )
|
|||
============
|
||||
va
|
||||
|
||||
does a varargs printf into a temp buffer, so I don't need to have
|
||||
varargs versions of all text functions.
|
||||
FIXME: make this buffer size safe someday
|
||||
does a varargs printf into a temp buffer,
|
||||
so I don't need to have varargs versions
|
||||
of all text functions.
|
||||
============
|
||||
*/
|
||||
char *va( const char *format, ... )
|
||||
|
@ -715,7 +755,8 @@ char *va( const char *format, ... )
|
|||
s = string[stringindex];
|
||||
stringindex = (stringindex + 1) & 255;
|
||||
va_start( argptr, format );
|
||||
com_vsnprintf( s, sizeof(string[0]), format, argptr );
|
||||
com_vsnprintf( s, sizeof( string[0] ), format, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
return s;
|
||||
}
|
|
@ -184,7 +184,6 @@ void Sys_GetStdAPI( void )
|
|||
com.vfprint = VFS_Print; // write message
|
||||
com.vfprintf = VFS_Printf; // write formatted message
|
||||
com.vfseek = VFS_Seek; // fseek, can seek in packfiles too
|
||||
com.vfunpack = VFS_Unpack; // inflate zipped buffer
|
||||
com.vfbuffer = VFS_GetBuffer; // get pointer at start vfile buffer
|
||||
com.vftell = VFS_Tell; // like a ftell
|
||||
com.vfeof = VFS_Eof; // like a feof
|
||||
|
@ -267,6 +266,7 @@ void Sys_GetStdAPI( void )
|
|||
com.strstr = com_strstr;
|
||||
com.vsprintf = com_vsprintf;
|
||||
com.sprintf = com_sprintf;
|
||||
com.stricmpext = com_stricmpext;
|
||||
com.va = va;
|
||||
com.vsnprintf = com_vsnprintf;
|
||||
com.snprintf = com_snprintf;
|
||||
|
@ -323,7 +323,7 @@ void Sys_LookupInstance( void )
|
|||
if( Sys.ModuleName[0] == '#' || Sys.ModuleName[0] == '©' )
|
||||
{
|
||||
if( Sys.ModuleName[0] == '#' ) dedicated = true;
|
||||
if( Sys.ModuleName[0] == '©' ) com_strcpy( Sys.progname, "credits" );
|
||||
if( Sys.ModuleName[0] == '©' ) com.strcpy( Sys.progname, "credits" );
|
||||
|
||||
// cutoff hidden symbols
|
||||
com.strncpy( szTemp, Sys.ModuleName + 1, MAX_SYSPATH );
|
||||
|
@ -343,7 +343,7 @@ void Sys_LookupInstance( void )
|
|||
Sys.app_name = HOST_CREDITS; // easter egg
|
||||
Sys.linked_dll = NULL; // no need to loading library
|
||||
Sys.log_active = Sys.developer = 0; // clear all dbg states
|
||||
com_strcpy( Sys.caption, "About" );
|
||||
com.strcpy( Sys.caption, "About" );
|
||||
Sys.con_showcredits = true;
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "normal" ))
|
||||
|
@ -365,7 +365,7 @@ void Sys_LookupInstance( void )
|
|||
CloseHandle( Sys.hMutex );
|
||||
Sys.hMutex = CreateSemaphore( NULL, 0, 1, "Xash Dedicated Server" );
|
||||
if( !Sys.developer ) Sys.developer = 3; // otherwise we see empty console
|
||||
com_sprintf( Sys.log_path, "engine.log", com_timestamp( TIME_FILENAME )); // logs folder
|
||||
com.sprintf( Sys.log_path, "engine.log", com.timestamp( TIME_FILENAME )); // logs folder
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -375,39 +375,39 @@ void Sys_LookupInstance( void )
|
|||
if( Sys.developer < D_WARN )
|
||||
Sys.con_showalways = false;
|
||||
|
||||
com_sprintf( Sys.log_path, "engine.log", com_timestamp( TIME_FILENAME )); // logs folder
|
||||
com.sprintf( Sys.log_path, "engine.log", com.timestamp( TIME_FILENAME )); // logs folder
|
||||
}
|
||||
|
||||
Sys.linked_dll = &engine_dll; // pointer to engine.dll info
|
||||
com_strcpy( Sys.caption, va( "Xash3D ver.%g", XASH_VERSION ));
|
||||
com.strcpy( Sys.caption, va( "Xash3D ver.%g", XASH_VERSION ));
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "bsplib" ))
|
||||
{
|
||||
Sys.app_name = HOST_BSPLIB;
|
||||
Sys.linked_dll = &xtools_dll; // pointer to common.dll info
|
||||
com_strcpy( Sys.log_path, "bsplib.log" ); // xash3d root directory
|
||||
com_strcpy( Sys.caption, "Xash3D BSP Compiler");
|
||||
com.strcpy( Sys.log_path, "bsplib.log" ); // xash3d root directory
|
||||
com.strcpy( Sys.caption, "Xash3D BSP Compiler");
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "sprite" ))
|
||||
{
|
||||
Sys.app_name = HOST_SPRITE;
|
||||
Sys.linked_dll = &xtools_dll; // pointer to common.dll info
|
||||
com_sprintf( Sys.log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy( Sys.caption, "Xash3D Sprite Compiler");
|
||||
com.sprintf( Sys.log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file
|
||||
com.strcpy( Sys.caption, "Xash3D Sprite Compiler");
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "studio" ))
|
||||
{
|
||||
Sys.app_name = HOST_STUDIO;
|
||||
Sys.linked_dll = &xtools_dll; // pointer to common.dll info
|
||||
com_sprintf( Sys.log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy( Sys.caption, "Xash3D Studio Models Compiler" );
|
||||
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, "wadlib" ))
|
||||
{
|
||||
Sys.app_name = HOST_WADLIB;
|
||||
Sys.linked_dll = &xtools_dll; // pointer to common.dll info
|
||||
com_sprintf( Sys.log_path, "%s/wadlib.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy( Sys.caption, "Xash3D Wad2\\Wad3 maker" );
|
||||
com.sprintf( Sys.log_path, "%s/wadlib.log", sys_rootdir ); // same as .exe file
|
||||
com.strcpy( Sys.caption, "Xash3D Wad2\\Wad3 maker" );
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "ripper" ))
|
||||
{
|
||||
|
@ -415,16 +415,16 @@ void Sys_LookupInstance( void )
|
|||
Sys.con_readonly = true;
|
||||
Sys.log_active = true; // always create log
|
||||
Sys.linked_dll = &xtools_dll; // pointer to wdclib.dll info
|
||||
com_sprintf( Sys.log_path, "%s/decompile.log", sys_rootdir ); // default
|
||||
com_strcpy( Sys.caption, va("Quake Recource Extractor ver.%g", XASH_VERSION ));
|
||||
com.sprintf( Sys.log_path, "%s/decompile.log", sys_rootdir ); // default
|
||||
com.strcpy( Sys.caption, va("Quake Recource Extractor ver.%g", XASH_VERSION ));
|
||||
}
|
||||
else if( !com.strcmp( Sys.progname, "ximage" ))
|
||||
{
|
||||
Sys.app_name = HOST_XIMAGE;
|
||||
Sys.con_readonly = true;
|
||||
Sys.linked_dll = &xtools_dll; // pointer to dpvenc.dll info
|
||||
com_sprintf( Sys.log_path, "%s/image.log", sys_rootdir ); // logs folder
|
||||
com_strcpy( Sys.caption, "Image Processing Tool" );
|
||||
com.sprintf( Sys.log_path, "%s/image.log", sys_rootdir ); // logs folder
|
||||
com.strcpy( Sys.caption, "Image Processing Tool" );
|
||||
}
|
||||
|
||||
// share instance over all system
|
||||
|
@ -465,7 +465,7 @@ void Sys_CreateInstance( void )
|
|||
Sys.CmdAuto = Host->CmdComplete;
|
||||
break;
|
||||
case HOST_CREDITS:
|
||||
Sys_Break( show_credits, com_timestamp( TIME_YEAR_ONLY ));
|
||||
Sys_Break( show_credits, com.timestamp( TIME_YEAR_ONLY ));
|
||||
break;
|
||||
case HOST_OFFLINE:
|
||||
Sys_Break( "Host offline\n" );
|
||||
|
@ -544,24 +544,24 @@ void Sys_ParseCommandLine( LPSTR lpCmdLine )
|
|||
|
||||
void Sys_MergeCommandLine( LPSTR lpCmdLine )
|
||||
{
|
||||
const char *blank = "censored";
|
||||
int i;
|
||||
const char *blank = "censored";
|
||||
int i;
|
||||
|
||||
for( i = 0; i < fs_argc; i++ )
|
||||
{
|
||||
// we wan't return to first game
|
||||
if(!com_stricmp( "-game", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
if( !com.stricmp( "-game", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
// probably it's timewaster, because engine rejected second change
|
||||
if(!com_stricmp( "+game", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
if( !com.stricmp( "+game", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
// you sure what is map exists in new game?
|
||||
if(!com_stricmp( "+map", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
if( !com.stricmp( "+map", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
// just stupid action
|
||||
if(!com_stricmp( "+load", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
if( !com.stricmp( "+load", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
// changelevel beetwen games? wow it's great idea!
|
||||
if(!com_stricmp( "+changelevel", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
if( !com.stricmp( "+changelevel", fs_argv[i] )) fs_argv[i] = (char *)blank;
|
||||
|
||||
// second call
|
||||
if( Sys.app_name == HOST_DEDICATED && !com_strnicmp( "+menu_", fs_argv[i], 6 ))
|
||||
if( Sys.app_name == HOST_DEDICATED && !com.strnicmp( "+menu_", fs_argv[i], 6 ))
|
||||
fs_argv[i] = (char *)blank;
|
||||
}
|
||||
}
|
||||
|
@ -587,8 +587,8 @@ void Sys_Print( const char *pMsg )
|
|||
Sys.CPrint( pMsg );
|
||||
|
||||
// if the message is REALLY long, use just the last portion of it
|
||||
if ( com_strlen( pMsg ) > sizeof( buffer ) - 1 )
|
||||
msg = pMsg + com_strlen( pMsg ) - sizeof( buffer ) + 1;
|
||||
if ( com.strlen( pMsg ) > sizeof( buffer ) - 1 )
|
||||
msg = pMsg + com.strlen( pMsg ) - sizeof( buffer ) + 1;
|
||||
else msg = pMsg;
|
||||
|
||||
// copy into an intermediate buffer
|
||||
|
@ -651,7 +651,7 @@ void Sys_Msg( const char *pMsg, ... )
|
|||
char text[MAX_SYSPATH];
|
||||
|
||||
va_start( argptr, pMsg );
|
||||
com_vsprintf( text, pMsg, argptr );
|
||||
com.vsprintf( text, pMsg, argptr );
|
||||
va_end( argptr );
|
||||
Sys.printlevel = 0;
|
||||
|
||||
|
@ -667,7 +667,7 @@ void Sys_MsgDev( int level, const char *pMsg, ... )
|
|||
Sys.printlevel = level;
|
||||
|
||||
va_start( argptr, pMsg );
|
||||
com_vsprintf( text, pMsg, argptr );
|
||||
com.vsprintf( text, pMsg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
switch( level )
|
||||
|
@ -771,9 +771,9 @@ char *Sys_GetCurrentUser( void )
|
|||
dword size = sizeof( s_userName );
|
||||
|
||||
if( !GetUserName( s_userName, &size ))
|
||||
com_strcpy( s_userName, "player" );
|
||||
com.strcpy( s_userName, "player" );
|
||||
if( !s_userName[0] )
|
||||
com_strcpy( s_userName, "player" );
|
||||
com.strcpy( s_userName, "player" );
|
||||
|
||||
return s_userName;
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ void Sys_Error( const char *error, ... )
|
|||
Sys.error = true;
|
||||
Sys.app_state = SYS_ERROR;
|
||||
va_start( argptr, error );
|
||||
com_vsprintf( text, error, argptr );
|
||||
com.vsprintf( text, error, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
if( Sys.app_name == HOST_NORMAL )
|
||||
|
@ -873,7 +873,7 @@ void Sys_Break( const char *error, ... )
|
|||
char text[MAX_SYSPATH];
|
||||
|
||||
va_start( argptr, error );
|
||||
com_vsprintf( text, error, argptr );
|
||||
com.vsprintf( text, error, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
Sys.error = true;
|
||||
|
@ -969,7 +969,7 @@ void Sys_Init( void )
|
|||
if( FS_GetParmFromCmdLine( "-dev", dev_level, sizeof( dev_level )))
|
||||
{
|
||||
if( com.is_digit( dev_level ))
|
||||
Sys.developer = abs( com_atoi( dev_level ));
|
||||
Sys.developer = abs( com.atoi( dev_level ));
|
||||
else Sys.developer++; // -dev == 1, -dev -console == 2
|
||||
}
|
||||
else Sys.developer++; // -dev == 1, -dev -console == 2
|
||||
|
|
288
launch/utils.c
288
launch/utils.c
|
@ -4,7 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "launch.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "wadfile.h"
|
||||
#include "mathlib.h"
|
||||
#include "const.h"
|
||||
|
||||
|
@ -309,10 +309,10 @@ bool StringTable_SaveSystem( int h, wfile_t *wad )
|
|||
|
||||
if(!StringTable_CheckHandle( h, false ))
|
||||
return false;
|
||||
if(!W_SaveLump( wad, "stringdata", dstring[h]->data, dstring[h]->datasize, TYPE_RAW, CMP_ZLIB ))
|
||||
if(!W_SaveLump( wad, "stringdata", dstring[h]->data, dstring[h]->datasize, TYP_RAW, CMP_LZSS ))
|
||||
return false;
|
||||
table_size = dstring[h]->numstrings * sizeof( string_t );
|
||||
if( !W_SaveLump( wad, "stringtable", dstring[h]->table, table_size, TYPE_RAW, CMP_ZLIB ))
|
||||
if( !W_SaveLump( wad, "stringtable", dstring[h]->table, table_size, TYP_RAW, CMP_LZSS ))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -321,8 +321,8 @@ int StringTable_LoadSystem( wfile_t *wad, const char *name )
|
|||
{
|
||||
int datasize, table_size;
|
||||
int h = StringTable_CreateNewSystem( name, 0x10000 ); // 65535 unique strings
|
||||
char *data = (char *)W_LoadLump( wad, "stringdata", &datasize, TYPE_RAW );
|
||||
int *table = (int *)W_LoadLump( wad, "stringtable", &table_size, TYPE_RAW );
|
||||
char *data = (char *)W_LoadLump( wad, "stringdata", &datasize, TYP_RAW );
|
||||
int *table = (int *)W_LoadLump( wad, "stringtable", &table_size, TYP_RAW );
|
||||
|
||||
if(( datasize > dstring[h]->maxdatasize ) || ((table_size / sizeof( int )) > dstring[h]->maxstrings ))
|
||||
Sys_Error( "Too small StringTable for loading\n" );
|
||||
|
@ -358,8 +358,284 @@ void StringTable_Info_f( void )
|
|||
Msg( "------------- %i strings -------------\n", dstring[i]->numstrings );
|
||||
for( j = 0; j < dstring[i]->numstrings; j++ )
|
||||
Msg( "%s ", StringTable_GetString( i, j ));
|
||||
Msg( "\n ^3total %s used\n", com_pretifymem( dstring[i]->datasize, 3 ));
|
||||
Msg( "\n ^3total %s used\n", com.pretifymem( dstring[i]->datasize, 3 ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
LZSS COMPRESSION
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
#define REFERENCEMAXDIST 4096
|
||||
#define REFERENCEMAXSIZE 18
|
||||
#define PACKETMAXSYMBOLS 8
|
||||
|
||||
// this only needs 17 bytes (1+symbols*2) but is padded to a multiple of 8
|
||||
#define PACKETMAXBYTES 24
|
||||
#define REFERENCEHASHBITS 12
|
||||
#define REFERENCEHASHSIZE (1 << REFERENCEHASHBITS)
|
||||
#define MINWINDOWBUFFERSIZE (REFERENCEMAXDIST + REFERENCEMAXSIZE * PACKETMAXSYMBOLS)
|
||||
|
||||
// WINDOWBUFFERSIZE must be >= REFERENCEMAXDIST+REFERENCEMAXSIZE*PACKETMAXSYMBOLS
|
||||
#define WINDOWBUFFERSIZE (REFERENCEMAXDIST * 2)
|
||||
#define WINDOWBUFFERSIZE2 (WINDOWBUFFERSIZE*2)
|
||||
#define HASHSIZE (4096)
|
||||
|
||||
typedef struct lzss_state_s
|
||||
{
|
||||
int hashindex[HASHSIZE]; // contains hash indexes
|
||||
int hashnext[WINDOWBUFFERSIZE2]; // contains hash indexes
|
||||
int packetbit;
|
||||
int packetsize;
|
||||
int windowstart;
|
||||
int windowposition;
|
||||
int windowend;
|
||||
byte packetbytes[PACKETMAXBYTES];
|
||||
byte window[WINDOWBUFFERSIZE2];
|
||||
} lzss_state_t;
|
||||
|
||||
void lzss_state_packetreset( lzss_state_t *state )
|
||||
{
|
||||
state->packetbit = 0x80; // current bit to set if encoding a reference
|
||||
state->packetsize = 1; // size of packet
|
||||
state->packetbytes[0] = 0; // command byte indicating contents of packet
|
||||
}
|
||||
|
||||
void lzss_state_start( lzss_state_t *state )
|
||||
{
|
||||
int i;
|
||||
|
||||
lzss_state_packetreset( state );
|
||||
state->windowstart = 0; // start of search window
|
||||
state->windowposition = 0; // current position in search window
|
||||
state->windowend = 0; // end of search window
|
||||
|
||||
for( i = 0; i < HASHSIZE; i++ )
|
||||
state->hashindex[i] = -1;
|
||||
}
|
||||
|
||||
// returns number of bytes needed to fill the buffer
|
||||
uint lzss_state_wantbytes( lzss_state_t *state )
|
||||
{
|
||||
return WINDOWBUFFERSIZE - ( state->windowend - state->windowstart );
|
||||
}
|
||||
|
||||
// appends supplied bytes to buffer
|
||||
// do not feed more bytes than lzss_state_wantbytes returned! (less is fine)
|
||||
void lzss_state_feedbytes( lzss_state_t *state, const byte *in, uint inlength )
|
||||
{
|
||||
int i, pos;
|
||||
|
||||
if( (int)inlength > WINDOWBUFFERSIZE - ( state->windowend - state->windowstart ))
|
||||
return; // error!
|
||||
|
||||
while( inlength-- )
|
||||
{
|
||||
if( state->windowstart >= WINDOWBUFFERSIZE )
|
||||
{
|
||||
for( i = 0; i < HASHSIZE; i++ )
|
||||
{
|
||||
if( state->hashindex[i] >= state->windowstart )
|
||||
{
|
||||
state->hashindex[i] -= WINDOWBUFFERSIZE;
|
||||
pos = state->hashindex[i];
|
||||
state->hashnext[pos] = state->hashnext[pos + WINDOWBUFFERSIZE];
|
||||
|
||||
while( state->hashnext[pos] >= state->windowstart )
|
||||
{
|
||||
state->hashnext[pos] -= WINDOWBUFFERSIZE;
|
||||
pos = state->hashnext[pos];
|
||||
state->hashnext[pos] = state->hashnext[pos + WINDOWBUFFERSIZE];
|
||||
}
|
||||
state->hashnext[pos] = -1;
|
||||
}
|
||||
else state->hashindex[i] = -1;
|
||||
}
|
||||
|
||||
for( i = state->windowstart; i < state->windowend; i++ )
|
||||
state->window[i - WINDOWBUFFERSIZE] = state->window[i];
|
||||
|
||||
state->windowstart -= WINDOWBUFFERSIZE;
|
||||
state->windowposition -= WINDOWBUFFERSIZE;
|
||||
state->windowend -= WINDOWBUFFERSIZE;
|
||||
}
|
||||
|
||||
state->window[state->windowend] = *in;
|
||||
state->windowend++;
|
||||
in++;
|
||||
}
|
||||
}
|
||||
|
||||
// compress some data if the buffer is sufficiently full or flush is true
|
||||
void lzss_state_compress( lzss_state_t *state, int flush )
|
||||
{
|
||||
int w, l, maxl, bestl, bestcode, hash;
|
||||
byte c, c1, c2;
|
||||
|
||||
while( state->packetbit && ( maxl = ( state->windowend - state->windowposition )) >= ( flush ? 1 : REFERENCEMAXSIZE ))
|
||||
{
|
||||
if( maxl > REFERENCEMAXSIZE )
|
||||
maxl = REFERENCEMAXSIZE;
|
||||
|
||||
c = state->window[state->windowposition];
|
||||
bestl = 1;
|
||||
|
||||
if( maxl >= 3 && state->windowposition > state->windowstart )
|
||||
{
|
||||
c1 = state->window[state->windowposition+1];
|
||||
c2 = state->window[state->windowposition+2];
|
||||
|
||||
for( w = state->hashindex[(c + c1 * 16 + c2 * 256) % HASHSIZE]; w >= state->windowstart; w = state->hashnext[w] )
|
||||
{
|
||||
if( w < state->windowposition && state->window[w] == c && state->window[w+1] == c1 && state->window[w+2] == c2 )
|
||||
{
|
||||
for( l = 3; l < maxl && state->window[w+l] == state->window[state->windowposition+l]; l++ );
|
||||
|
||||
if( bestl < l )
|
||||
{
|
||||
bestl = l;
|
||||
bestcode = ((bestl - 3) << 12) | ( state->windowposition - w - 1 );
|
||||
|
||||
if( bestl == maxl )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( bestl >= 3 )
|
||||
{
|
||||
state->packetbytes[0] |= state->packetbit;
|
||||
state->packetbytes[state->packetsize++] = (byte)(bestcode >> 8);
|
||||
state->packetbytes[state->packetsize++] = (byte)bestcode;
|
||||
}
|
||||
else state->packetbytes[state->packetsize++] = c;
|
||||
|
||||
state->packetbit >>= 1;
|
||||
|
||||
while( bestl-- )
|
||||
{
|
||||
// add hash entry
|
||||
if( state->windowposition + 3 <= state->windowend )
|
||||
{
|
||||
hash = (state->window[state->windowposition] + state->window[state->windowposition + 1] * 16 + state->window[state->windowposition + 2] * 256) % HASHSIZE;
|
||||
state->hashnext[state->windowposition] = state->hashindex[hash];
|
||||
state->hashindex[hash] = state->windowposition;
|
||||
}
|
||||
state->windowposition++;
|
||||
}
|
||||
|
||||
if( state->windowstart < state->windowposition - REFERENCEMAXDIST )
|
||||
state->windowstart = state->windowposition - REFERENCEMAXDIST;
|
||||
}
|
||||
}
|
||||
|
||||
uint lzss_state_packetfull( lzss_state_t *state )
|
||||
{
|
||||
return !state->packetbit;
|
||||
}
|
||||
|
||||
uint lzss_state_getpacketsize( lzss_state_t *state )
|
||||
{
|
||||
return state->packetsize >= 2 ? state->packetsize : 0;
|
||||
}
|
||||
|
||||
void lzss_state_getpacketbytes( lzss_state_t *state, byte *out )
|
||||
{
|
||||
int i;
|
||||
|
||||
// copy the bytes to output
|
||||
for( i = 0; i < state->packetsize; i++ )
|
||||
out[i] = state->packetbytes[i];
|
||||
|
||||
// reset the packet
|
||||
lzss_state_packetreset( state );
|
||||
}
|
||||
|
||||
uint lzss_compress( const byte *in, const byte *inend, byte *out, byte *outend )
|
||||
{
|
||||
byte *outstart = out;
|
||||
uint b;
|
||||
lzss_state_t state;
|
||||
|
||||
lzss_state_start( &state );
|
||||
|
||||
// this code is a little complex because it implements the flush stage as
|
||||
// just a few checks (otherwise it would take two copies of this code)
|
||||
|
||||
// while the buffer is not empty, or there is more input
|
||||
while( state.windowposition != state.windowend || in != inend )
|
||||
{
|
||||
// keep compressing until it stops making new packets
|
||||
// (this means the buffer is not full enough anymore)
|
||||
// in == inend is setting the flush flag, which will finish the file,
|
||||
// and a packet is written if the packet is full or flush is true
|
||||
lzss_state_compress( &state, in == inend );
|
||||
|
||||
b = lzss_state_getpacketsize( &state );
|
||||
if( in == inend ? b : lzss_state_packetfull( &state ))
|
||||
{
|
||||
// write a packet
|
||||
if( out + b > outend )
|
||||
return 0; // error: made file bigger
|
||||
|
||||
lzss_state_getpacketbytes( &state, out );
|
||||
out += b;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill up buffer if needed
|
||||
if( in < inend && ( b = lzss_state_wantbytes( &state )))
|
||||
{
|
||||
if( b > (uint)( inend - in ))
|
||||
b = (uint)( inend - in );
|
||||
lzss_state_feedbytes( &state, in, b );
|
||||
in += b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out - outstart;
|
||||
}
|
||||
|
||||
bool lzss_decompress( const byte *in, const byte *inend, byte *out, byte *outend )
|
||||
{
|
||||
int i, commandbyte, code;
|
||||
const byte *copy;
|
||||
byte *outcopyend, *outstart = out;
|
||||
|
||||
// input file should not end with a command byte so make sure there are
|
||||
// at least two remaining bytes
|
||||
while( in + 2 <= inend && out < outend )
|
||||
{
|
||||
commandbyte = *in++;
|
||||
|
||||
for( i = 0x80; i && in < inend && out < outend; i >>= 1 )
|
||||
{
|
||||
if( commandbyte & i )
|
||||
{
|
||||
code = (*in++) * 0x100;
|
||||
if( in == inend )
|
||||
return true; // corrupt
|
||||
|
||||
code += *in++;
|
||||
outcopyend = out + ((code >> 12) & 15) + 3;
|
||||
copy = out - ((code & 0xFFF) + 1);
|
||||
|
||||
if( out < outstart || outcopyend > outend )
|
||||
return true; // corrupt
|
||||
while( out < outcopyend )
|
||||
*out++ = *copy++;
|
||||
}
|
||||
else *out++ = *in++;
|
||||
}
|
||||
}
|
||||
|
||||
// corrupt if non-zero
|
||||
return in != inend || out != outend;
|
||||
}
|
|
@ -166,5 +166,4 @@ _inline void SwapBlock( int *block, int sizeOfBlock )
|
|||
block[i] = LittleLong( block[i] );
|
||||
}
|
||||
|
||||
|
||||
#endif//BYTEORDER_H
|
|
@ -524,11 +524,11 @@ typedef struct stdilib_api_s
|
|||
int (*Com_CheckParm)( const char *parm ); // check parm in cmdline
|
||||
bool (*Com_GetParm)( char *parm, char *out, size_t size ); // get parm from cmdline
|
||||
void (*Com_FileBase)(const char *in, char *out); // get filename without path & ext
|
||||
bool (*Com_FileExists)(const char *filename); // return true if file exist
|
||||
long (*Com_FileSize)(const char *filename); // same as Com_FileExists but return filesize
|
||||
long (*Com_FileTime)(const char *filename); // same as Com_FileExists but return filetime
|
||||
const char *(*Com_FileExtension)(const char *in); // return extension of file
|
||||
const char *(*Com_RemovePath)(const char *in); // return filename without path
|
||||
bool (*Com_FileExists)( const char *filename, bool gamedir);// return true if file exist
|
||||
long (*Com_FileSize)( const char *filename, bool gamedir ); // same as Com_FileExists but return filesize
|
||||
long (*Com_FileTime)( const char *filename, bool gamedir ); // same as Com_FileExists but return filetime
|
||||
const char *(*Com_FileExtension)( const char *in ); // return extension of file
|
||||
const char *(*Com_RemovePath)( const char *in ); // return filename without path
|
||||
void (*Com_StripExtension)(char *path); // remove extension if present
|
||||
void (*Com_StripFilePath)(const char* const src, char* dst);// get file path without filename.ext
|
||||
void (*Com_DefaultExtension)(char *path, const char *ext ); // append extension if not present
|
||||
|
@ -561,7 +561,7 @@ typedef struct stdilib_api_s
|
|||
bool (*Com_ReadDword)( script_t *script, int flags, uint *value ); // unsigned integer
|
||||
bool (*Com_ReadLong)( script_t *script, int flags, int *value ); // signed integer
|
||||
|
||||
search_t *(*Com_Search)( const char *pattern, int casecmp ); // returned list of found files
|
||||
search_t *(*Com_Search)( const char *pattern, int casecmp, int gamedironly ); // returned list of found files
|
||||
uint (*Com_HashKey)( const char *string, uint hashSize ); // returns hash key for a string
|
||||
|
||||
// console variables
|
||||
|
@ -588,7 +588,7 @@ typedef struct stdilib_api_s
|
|||
void (*Cmd_DelCommand)( const char *name );
|
||||
|
||||
// real filesystem
|
||||
file_t *(*fopen)(const char* path, const char* mode); // same as fopen
|
||||
file_t *(*fopen)( const char* path, const char* mode, bool gamedir ); // same as fopen
|
||||
int (*fclose)(file_t* file); // same as fclose
|
||||
long (*fwrite)(file_t* file, const void* data, size_t datasize); // same as fwrite
|
||||
long (*fread)(file_t* file, void* buffer, size_t buffersize); // same as fread, can see through pakfile
|
||||
|
@ -697,6 +697,7 @@ typedef struct stdilib_api_s
|
|||
char *(*strstr)( const char *s1, const char *s2 ); // find s2 in s1 with case sensative
|
||||
int (*vsprintf)(char *buf, const char *fmt, va_list args); // format message
|
||||
int (*sprintf)(char *buffer, const char *format, ...); // print into buffer
|
||||
bool (*stricmpext)( const char *s1, const char *s2 ); // allow '*', '?' etc
|
||||
char *(*va)(const char *format, ...); // print into temp buffer
|
||||
int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list args); // format message
|
||||
int (*snprintf)(char *buffer, size_t buffersize, const char *format, ...); // print into buffer
|
||||
|
@ -793,18 +794,23 @@ filesystem manager
|
|||
#define FS_InitRootDir com.Com_InitRootDir
|
||||
#define FS_AllowDirectPaths com.Com_AllowDirectPaths
|
||||
#define FS_LoadFile com.Com_LoadFile
|
||||
#define FS_Search com.Com_Search
|
||||
#define FS_Search( str, casecmp ) com.Com_Search( str, casecmp, false )
|
||||
#define FS_SearchExt com.Com_Search
|
||||
#define FS_WriteFile com.Com_WriteFile
|
||||
#define FS_Open( path, mode ) com.fopen( path, mode )
|
||||
#define FS_Open( path, mode ) com.fopen( path, mode, false )
|
||||
#define FS_OpenEx com.fopen
|
||||
#define FS_Read( file, buffer, size ) com.fread( file, buffer, size )
|
||||
#define FS_Write( file, buffer, size ) com.fwrite( file, buffer, size )
|
||||
#define FS_StripExtension( path ) com.Com_StripExtension( path )
|
||||
#define FS_ExtractFilePath( src, dest) com.Com_StripFilePath( src, dest )
|
||||
#define FS_DefaultExtension com.Com_DefaultExtension
|
||||
#define FS_FileExtension( ext ) com.Com_FileExtension( ext )
|
||||
#define FS_FileExists( file ) com.Com_FileExists( file )
|
||||
#define FS_FileSize( file ) com.Com_FileSize( file )
|
||||
#define FS_FileTime( file ) com.Com_FileTime( file )
|
||||
#define FS_FileExists( file ) com.Com_FileExists( file, false )
|
||||
#define FS_FileSize( file ) com.Com_FileSize( file, false )
|
||||
#define FS_FileTime( file ) com.Com_FileTime( file, false )
|
||||
#define FS_FileExistsEx com.Com_FileExists
|
||||
#define FS_FileSizeEx com.Com_FileSize
|
||||
#define FS_FileTimeEx com.Com_FileTime
|
||||
#define FS_Close( file ) com.fclose( file )
|
||||
#define FS_FileBase( x, y ) com.Com_FileBase( x, y )
|
||||
#define FS_RemovePath( x ) com.Com_RemovePath( x )
|
||||
|
@ -896,7 +902,6 @@ virtual filesystem manager
|
|||
#define VFS_Tell com.vftell
|
||||
#define VFS_Eof com.vfeof
|
||||
#define VFS_Close com.vfclose
|
||||
#define VFS_Unpack com.vfunpack
|
||||
|
||||
/*
|
||||
===========================================
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define RENDER_API_H
|
||||
|
||||
#include "ref_params.h"
|
||||
#include "movie.h"
|
||||
|
||||
#define MAP_DEFAULT_SHADER "*black" // engine built-in default shader
|
||||
|
||||
|
@ -189,7 +190,7 @@ typedef struct render_imp_s
|
|||
|
||||
// client fundamental callbacks
|
||||
void (*UpdateScreen)( void ); // update screen while loading
|
||||
void (*StudioEvent)( mstudioevent_t *event, struct cl_entity_s *ent );
|
||||
void (*StudioEvent)( struct mstudioevent_s *event, struct cl_entity_s *ent );
|
||||
void (*StudioFxTransform)( struct cl_entity_s *ent, float matrix[4][4] );
|
||||
void (*ShowCollision)( cmdraw_t callback ); // debug
|
||||
long (*WndProc)( void *hWnd, uint uMsg, uint wParam, long lParam );
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
vsound_imp_t si;
|
||||
stdlib_api_t com;
|
||||
|
||||
// main DLL entry point
|
||||
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
vsound_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, vsound_imp_t *engfuncs )
|
||||
{
|
||||
static vsound_exp_t snd;
|
||||
|
|
128
snd_dx/s_load.c
128
snd_dx/s_load.c
|
@ -55,105 +55,6 @@ void S_SoundList_f( void )
|
|||
Msg( "\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
S_ResampleSfx
|
||||
================
|
||||
*/
|
||||
void S_ResampleSfx( sfx_t *sfx, int inrate, int inwidth, byte *data )
|
||||
{
|
||||
float stepscale;
|
||||
int outcount, srcsample;
|
||||
int i, sample, sample2, samplefrac, fracstep;
|
||||
wavdata_t *sc;
|
||||
|
||||
if( !sfx ) return;
|
||||
sc = sfx->cache;
|
||||
if( !sc ) return;
|
||||
|
||||
stepscale = (float)inrate / dma.speed; // this is usually 0.5, 1, or 2
|
||||
|
||||
outcount = sc->samples / stepscale;
|
||||
sc->samples = outcount;
|
||||
if( sc->loopStart != -1 )
|
||||
sc->loopStart = sc->loopStart / stepscale;
|
||||
|
||||
sc->rate = dma.speed;
|
||||
sc->width = inwidth;
|
||||
sc->channels = sc->channels;
|
||||
|
||||
// resample / decimate to the current source rate
|
||||
if( stepscale == 1 && inwidth == 1 && sc->width == 1 )
|
||||
{
|
||||
if( sc->channels == 2 )
|
||||
{
|
||||
// fast special case
|
||||
for( i = 0; i < outcount; i++ )
|
||||
{
|
||||
((signed char *)sc->buffer)[i*2+0] = (int)((unsigned char)(data[i*2+0]) - 128);
|
||||
((signed char *)sc->buffer)[i*2+1] = (int)((unsigned char)(data[i*2+1]) - 128);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// fast special case
|
||||
for( i = 0; i < outcount; i++ )
|
||||
((signed char *)sc->buffer)[i] = (int)((unsigned char)(data[i]) - 128);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// general case
|
||||
samplefrac = 0;
|
||||
fracstep = stepscale * 256;
|
||||
|
||||
if( sc->channels == 2 )
|
||||
{
|
||||
for( i = 0; i < outcount; i++ )
|
||||
{
|
||||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
|
||||
if( inwidth == 2 )
|
||||
{
|
||||
sample = LittleShort(((short *)data)[srcsample*2+0] );
|
||||
sample2 = LittleShort(((short *)data)[srcsample*2+1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
sample = (int)( (unsigned char)(data[srcsample*2+0]) - 128) << 8;
|
||||
sample2 = (int)( (unsigned char)(data[srcsample*2+1]) - 128) << 8;
|
||||
}
|
||||
|
||||
if( sc->width == 2 )
|
||||
{
|
||||
((short *)sc->buffer)[i*2+0] = sample;
|
||||
((short *)sc->buffer)[i*2+1] = sample2;
|
||||
}
|
||||
else
|
||||
{
|
||||
((signed char *)sc->buffer)[i*2+0] = sample >> 8;
|
||||
((signed char *)sc->buffer)[i*2+1] = sample2 >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < outcount; i++ )
|
||||
{
|
||||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
|
||||
if( inwidth == 2 ) sample = LittleShort(((short *)data)[srcsample] );
|
||||
else sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
|
||||
|
||||
if( sc->width == 2 ) ((short *)sc->buffer)[i] = sample;
|
||||
else ((signed char *)sc->buffer)[i] = sample >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return true if char 'c' is one of 1st 2 characters in pch
|
||||
bool S_TestSoundChar( const char *pch, char c )
|
||||
{
|
||||
|
@ -181,31 +82,6 @@ char *S_SkipSoundChar( const char *pch )
|
|||
return pcht;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_UploadSound
|
||||
=================
|
||||
*/
|
||||
static void S_UploadSound( wavdata_t *sc, sfx_t *sfx )
|
||||
{
|
||||
size_t samples;
|
||||
float stepscale;
|
||||
byte *indata;
|
||||
|
||||
// calculate buffer size
|
||||
stepscale = (float)sc->rate / dma.speed;
|
||||
samples = sc->samples / stepscale;
|
||||
sc->size = samples * sc->width * sc->channels;
|
||||
indata = sc->buffer; // detach old buffer
|
||||
sfx->cache = sc;
|
||||
|
||||
// UNDONE: we need resample sounds in launch.dll, not here
|
||||
sc->buffer = Z_Malloc( sc->size ); // allocate room for resampled wav
|
||||
|
||||
S_ResampleSfx( sfx, sc->rate, sc->width, indata );
|
||||
Mem_Free( indata ); // no reason to keep this data
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_CreateDefaultSound
|
||||
|
@ -253,7 +129,9 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
|
|||
if( !sc ) sc = S_CreateDefaultSound();
|
||||
|
||||
// upload and resample
|
||||
S_UploadSound( sc, sfx );
|
||||
Sound_Process( &sc, dma.speed, sc->width, SOUND_RESAMPLE );
|
||||
|
||||
sfx->cache = sc;
|
||||
|
||||
return sfx->cache;
|
||||
}
|
||||
|
|
|
@ -304,7 +304,6 @@ void S_MixAllChannels( int endtime, int end )
|
|||
|
||||
if( si.GetClientEdict( ch->entnum ) && ( ch->entchannel == CHAN_VOICE ))
|
||||
{
|
||||
// UNDONE: recode this as a member function of CAudioMixer
|
||||
SND_MoveMouth8( ch, sc, count );
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,7 @@ void SND_MoveMouth8( channel_t *ch, wavdata_t *pSource, int count )
|
|||
|
||||
pMouth = &clientEntity->mouth;
|
||||
|
||||
S_GetOutputData( pSource, &pdata, ch->pos, count );
|
||||
|
||||
count = S_GetOutputData( pSource, &pdata, ch->pos, count );
|
||||
if( pdata == NULL ) return;
|
||||
|
||||
i = 0;
|
||||
|
|
|
@ -74,15 +74,11 @@ void S_StreamBackgroundTrack( void )
|
|||
int fileSamples;
|
||||
byte raw[MAX_RAW_SAMPLES];
|
||||
int r, fileBytes;
|
||||
float musicVolume = 0.5f;
|
||||
|
||||
if( !s_bgTrack.stream ) return;
|
||||
|
||||
// graeme see if this is OK
|
||||
musicVolume = ( musicVolume + ( s_musicvolume->value * 2 )) / 4.0f;
|
||||
|
||||
// don't bother playing anything if musicvolume is 0
|
||||
if( musicVolume <= 0 ) return;
|
||||
if( !s_musicvolume->value ) return;
|
||||
|
||||
// see how many samples should be copied into the raw buffer
|
||||
if( s_rawend < soundtime )
|
||||
|
@ -118,7 +114,6 @@ void S_StreamBackgroundTrack( void )
|
|||
if( r > 0 )
|
||||
{
|
||||
// add to raw buffer
|
||||
// FIXME: apply musicVolume
|
||||
S_StreamRawSamples( fileSamples, info->rate, info->width, info->channels, raw );
|
||||
}
|
||||
else
|
||||
|
@ -169,77 +164,56 @@ Cinematic streaming and voice over network
|
|||
*/
|
||||
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data )
|
||||
{
|
||||
int i, src, dst;
|
||||
float scale;
|
||||
int i, snd_vol;
|
||||
int a, b, src, dst;
|
||||
int fracstep, samplefrac;
|
||||
int incount, outcount;
|
||||
|
||||
snd_vol = (int)(s_musicvolume->value * 256);
|
||||
if( snd_vol < 0 ) snd_vol = 0;
|
||||
|
||||
src = 0;
|
||||
samplefrac = 0;
|
||||
fracstep = (((double)rate) / (double)dma.speed) * 256.0;
|
||||
outcount = (double)samples * (double) dma.speed / (double)rate;
|
||||
incount = samples * channels;
|
||||
|
||||
#define TAKE_SAMPLE( s ) (sizeof(*in) == 1 ? (a = (in[src+(s)]-128)<<8,\
|
||||
b = (src < incount - channels) ? (in[src+channels+(s)]-128)<<8 : 128) : \
|
||||
(a = in[src+(s)],\
|
||||
b = (src < incount - channels) ? (in[src+channels+(s)]) : 0))
|
||||
|
||||
#define LERP_SAMPLE ((((((b - a) * (samplefrac & 255)) >> 8) + a) * snd_vol))
|
||||
|
||||
#define RESAMPLE_RAW \
|
||||
if( channels == 2 ) { \
|
||||
for( i = 0; i < outcount; i++, samplefrac += fracstep, src = (samplefrac >> 8) << 1 ) { \
|
||||
dst = s_rawend++ & (MAX_RAW_SAMPLES - 1); \
|
||||
TAKE_SAMPLE(0); \
|
||||
s_rawsamples[dst].left = LERP_SAMPLE; \
|
||||
TAKE_SAMPLE(1); \
|
||||
s_rawsamples[dst].right = LERP_SAMPLE; \
|
||||
} \
|
||||
} else { \
|
||||
for( i = 0; i < outcount; i++, samplefrac += fracstep, src = (samplefrac >> 8) << 0 ) { \
|
||||
dst = s_rawend++ & (MAX_RAW_SAMPLES - 1); \
|
||||
TAKE_SAMPLE(0); \
|
||||
s_rawsamples[dst].left = LERP_SAMPLE; \
|
||||
s_rawsamples[dst].right = s_rawsamples[dst].left; \
|
||||
} \
|
||||
}
|
||||
|
||||
if( s_rawend < paintedtime )
|
||||
s_rawend = paintedtime;
|
||||
scale = (float)rate / dma.speed;
|
||||
|
||||
if( channels == 2 && width == 2 )
|
||||
if( width == 2 )
|
||||
{
|
||||
if( scale == 1.0f )
|
||||
{
|
||||
// optimized case
|
||||
for( i = 0; i < samples; i++ )
|
||||
{
|
||||
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
|
||||
s_rawend++;
|
||||
s_rawsamples[dst].left = LittleShort(((short *)data)[i*2]) << 8;
|
||||
s_rawsamples[dst].right = LittleShort(((short *)data)[i*2+1]) << 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = src = 0; src < samples; i++ )
|
||||
{
|
||||
src = i * scale;
|
||||
if( src >= samples ) break;
|
||||
|
||||
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
|
||||
s_rawend++;
|
||||
s_rawsamples[dst].left = LittleShort(((short *)data)[src*2]) << 8;
|
||||
s_rawsamples[dst].right = LittleShort(((short *)data)[src*2+1]) << 8;
|
||||
}
|
||||
}
|
||||
short *in = (short *)data;
|
||||
RESAMPLE_RAW
|
||||
}
|
||||
else if( channels == 1 && width == 2 )
|
||||
else
|
||||
{
|
||||
for( i = src = 0; src < samples; i++ )
|
||||
{
|
||||
src = i * scale;
|
||||
if( src >= samples ) break;
|
||||
|
||||
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
|
||||
s_rawend++;
|
||||
s_rawsamples[dst].left = LittleShort(((short *)data)[src]) << 8;
|
||||
s_rawsamples[dst].right = LittleShort(((short *)data)[src]) << 8;
|
||||
}
|
||||
}
|
||||
else if( channels == 2 && width == 1 )
|
||||
{
|
||||
for( i = src = 0; src < samples; i++ )
|
||||
{
|
||||
src = i * scale;
|
||||
if( src >= samples ) break;
|
||||
|
||||
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
|
||||
s_rawend++;
|
||||
s_rawsamples[dst].left = ((char *)data)[src*2] << 16;
|
||||
s_rawsamples[dst].right = ((char *)data)[src*2+1] << 16;
|
||||
}
|
||||
}
|
||||
else if( channels == 1 && width == 1 )
|
||||
{
|
||||
for( i = src = 0; src < samples; i++ )
|
||||
{
|
||||
src = i * scale;
|
||||
if( src >= samples ) break;
|
||||
|
||||
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
|
||||
s_rawend++;
|
||||
s_rawsamples[dst].left = (((byte *)data)[src]-128) << 16;
|
||||
s_rawsamples[dst].right = (((byte *)data)[src]-128) << 16;
|
||||
}
|
||||
byte *in = (unsigned char *)data;
|
||||
RESAMPLE_RAW
|
||||
}
|
||||
}
|
|
@ -21,10 +21,17 @@ int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample )
|
|||
|
||||
if( pWaveData->type == WF_PCMDATA )
|
||||
{
|
||||
int sampleSize;
|
||||
|
||||
sampleSize = pWaveData->width * pWaveData->channels;
|
||||
|
||||
// this can never be zero -- other functions divide by this.
|
||||
// This should never happen, but avoid crashing
|
||||
if( sampleSize <= 0 ) sampleSize = 1;
|
||||
|
||||
if( pWaveData->width == 1 )
|
||||
{
|
||||
// FIXME: this is right ?
|
||||
char *pData = pWaveData->buffer + sample * pWaveData->width;
|
||||
char *pData = pWaveData->buffer + sample * sampleSize;
|
||||
bool zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
|
@ -59,8 +66,8 @@ int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample )
|
|||
}
|
||||
}
|
||||
else
|
||||
{ // FIXME: this is right ?
|
||||
short *pData = (short *)(pWaveData->buffer + sample * pWaveData->width);
|
||||
{
|
||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
||||
bool zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
|
@ -110,10 +117,17 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample )
|
|||
|
||||
if( pWaveData->type == WF_PCMDATA )
|
||||
{
|
||||
int sampleSize;
|
||||
|
||||
sampleSize = pWaveData->width * pWaveData->channels;
|
||||
|
||||
// this can never be zero -- other functions divide by this.
|
||||
// This should never happen, but avoid crashing
|
||||
if( sampleSize <= 0 ) sampleSize = 1;
|
||||
|
||||
if( pWaveData->width == 1 ) // 8-bit
|
||||
{
|
||||
// FIXME: this is right ?
|
||||
char *pData = pWaveData->buffer + sample * pWaveData->width;
|
||||
char *pData = pWaveData->buffer + sample * sampleSize;
|
||||
bool zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
|
@ -148,8 +162,8 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample )
|
|||
}
|
||||
}
|
||||
else
|
||||
{ // FIXME: this is right ?
|
||||
short *pData = (short *)(pWaveData->buffer + sample * pWaveData->width);
|
||||
{
|
||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
||||
bool zero = false;
|
||||
|
||||
if( pWaveData->channels == 1 )
|
||||
|
@ -219,6 +233,7 @@ int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition )
|
|||
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount )
|
||||
{
|
||||
int totalSampleCount;
|
||||
int sampleSize;
|
||||
|
||||
// handle position looping
|
||||
samplePosition = S_ConvertLoopedPosition( pSource, samplePosition );
|
||||
|
@ -233,13 +248,20 @@ int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int s
|
|||
if( sampleCount > totalSampleCount )
|
||||
sampleCount = totalSampleCount;
|
||||
|
||||
sampleSize = pSource->width * pSource->channels;
|
||||
|
||||
// this can never be zero -- other functions divide by this.
|
||||
// This should never happen, but avoid crashing
|
||||
if( sampleSize <= 0 ) sampleSize = 1;
|
||||
|
||||
// byte offset in sample database
|
||||
samplePosition *= pSource->width; // FIXME: this is right ?
|
||||
samplePosition *= sampleSize;
|
||||
|
||||
// if we are returning some samples, store the pointer
|
||||
if( sampleCount )
|
||||
{
|
||||
*pData = pSource->buffer + samplePosition;
|
||||
}
|
||||
|
||||
return sampleCount;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: snd_dx - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
snd_dx.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include "launch_api.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "engine_api.h"
|
||||
#include "vsound_api.h"
|
||||
#include "cl_entity.h"
|
||||
|
|
|
@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include <windows.h>
|
||||
#include "launch_api.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "engine_api.h"
|
||||
#include "render_api.h"
|
||||
#include "pmtrace.h"
|
||||
|
|
|
@ -2496,6 +2496,12 @@ bool R_AddDynamicLight( vec3_t pos, rgb_t color, float radius, int flags )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// main DLL entry point
|
||||
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@@@@@@@@@@@@@@@@@@@@
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "stdio.h" // sscanf
|
||||
#include "r_local.h"
|
||||
#include "wadfile.h"
|
||||
#include "mathlib.h"
|
||||
#include "matrix_lib.h"
|
||||
#include "byteorder.h"
|
||||
|
@ -1981,14 +1982,9 @@ static epair_t *Mod_ParseEpair( script_t *script, token_t *token )
|
|||
epair_t *e;
|
||||
|
||||
e = Mem_Alloc( cached_mempool, sizeof( epair_t ));
|
||||
|
||||
if( com.strlen( token->string ) >= MAX_KEY - 1 )
|
||||
Host_Error( "Mod_ParseEpair: key %s too long\n", token->string );
|
||||
e->key = com.stralloc( cached_mempool, token->string, __FILE__, __LINE__ );
|
||||
|
||||
Com_ReadToken( script, SC_PARSE_GENERIC, token );
|
||||
if( com.strlen( token->string ) >= MAX_VALUE - 1 )
|
||||
Host_Error( "Mod_ParseEpair: value %s too long\n", token->string );
|
||||
e->value = com.stralloc( cached_mempool, token->string, __FILE__, __LINE__ );
|
||||
|
||||
// strip trailing spaces if needs
|
||||
|
|
|
@ -28,6 +28,9 @@ m*_t structures are in-memory
|
|||
|
||||
*/
|
||||
|
||||
#include "sprite.h"
|
||||
#include "studio.h"
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
@ -333,7 +336,7 @@ ref_model_t *Mod_ForHandle( unsigned int elem );
|
|||
ref_model_t *R_RegisterModel( const char *name );
|
||||
void R_BeginRegistration( const char *model );
|
||||
void R_EndRegistration( const char *skyname );
|
||||
texture_t *Mod_LoadTexture( mip_t *mt );
|
||||
texture_t *Mod_LoadTexture( struct mip_s *mt );
|
||||
|
||||
#define Mod_Malloc( mod, size ) Mem_Alloc(( mod )->mempool, size )
|
||||
#define Mod_Realloc( mod, data, size ) Mem_Realloc(( mod )->mempool, data, size )
|
||||
|
|
|
@ -457,7 +457,7 @@ bool R_CreateWindow( int width, int height, bool fullscreen )
|
|||
wc.lpszMenuName = 0;
|
||||
|
||||
// find the icon file in the filesystem
|
||||
if( FS_FileExists( "†game.ico" ))
|
||||
if( FS_FileExistsEx( "game.ico", true ))
|
||||
{
|
||||
char localPath[MAX_PATH];
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// r_shader.c
|
||||
|
||||
#include "r_local.h"
|
||||
#include "wadfile.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
typedef struct ref_script_s
|
||||
|
|
|
@ -350,7 +350,7 @@ void R_ShaderFreeUnused( void );
|
|||
float R_LookupTable( int tableIndex, float index );
|
||||
float *R_GetTableByHandle( int tableIndex );
|
||||
bool R_ShaderCheckCache( const char *name );
|
||||
void R_SetInternalTexture( mip_t *mt );
|
||||
void R_SetInternalTexture( struct mip_s *mt );
|
||||
void Shader_TouchImages( ref_shader_t *shader, bool free_unused );
|
||||
void R_ShaderAddStageTexture( texture_t *mipTex );
|
||||
void R_ShaderSetMiptexFlags( uint addFlags );
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: vid_gl - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
vid_gl.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -6,8 +6,8 @@
|
|||
#define STUDIOMDL_H
|
||||
|
||||
#include "xtools.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "utils.h"
|
||||
#include "studio.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
#define FILEBUFFER (1024 * 1024 * 16) // 16 megs filebuffer
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "ripper.h"
|
||||
#include "wadfile.h"
|
||||
#include "byteorder.h"
|
||||
#include "qfiles_ref.h"
|
||||
|
||||
#define IDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') // little-endian "IBSP" q2, q3 bsp's
|
||||
#define VDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'V') // little-endian "VBSP" hl2 bsp's
|
||||
|
@ -269,6 +269,7 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext )
|
|||
if( !FS_FileExists( va( "%s/%s/%s.%s", gs_gamedir, name, mip->name, ext )))
|
||||
ConvMIP( va("%s/%s", name, mip->name ), buffer, size, ext ); // convert it
|
||||
}
|
||||
|
||||
mip_count = 0; // freed and invaliadte
|
||||
FS_Close( detail_txt );
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "ripper.h"
|
||||
#include "byteorder.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "sprite.h"
|
||||
|
||||
// sprite_decompiler.c
|
||||
#define SPR_VP_PARALLEL_UPRIGHT 0
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "xtools.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "sprite.h"
|
||||
#include "byteorder.h"
|
||||
#include "utils.h"
|
||||
#include "mathlib.h"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "mdllib.h"
|
||||
|
||||
typedef struct { int type; char *name; } activity_map_t; // studio activity map conversion
|
||||
int used[MAXSTUDIOTRIANGLES]; // the command list holds counts and s/t values
|
||||
short commands[MAXSTUDIOTRIANGLES * 13]; // that are valid for every frame
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "xtools.h"
|
||||
#include "qfiles_ref.h"
|
||||
#include "wadfile.h"
|
||||
#include "byteorder.h"
|
||||
#include "utils.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
string wadoutname;
|
||||
bool wad_append = false;
|
||||
bool wad_compress = false;
|
||||
script_t *wadqc = NULL;
|
||||
wfile_t *handle = NULL;
|
||||
string lumpname;
|
||||
|
@ -146,7 +147,7 @@ void Wad3_AddLump( const byte *buffer, size_t lumpsize, int lump_type, bool comp
|
|||
{
|
||||
int result;
|
||||
if( !handle ) Wad3_NewWad(); // create wad file
|
||||
result = WAD_Write( handle, lumpname, buffer, lumpsize, lump_type, ( compress ? CMP_ZLIB : CMP_NONE ));
|
||||
result = WAD_Write( handle, lumpname, buffer, lumpsize, lump_type, ( compress ? CMP_LZSS : CMP_NONE ));
|
||||
if( result != -1 ) Msg("Add %s\t#%3i\n", lumpname, result ); // FIXME: align message
|
||||
}
|
||||
|
||||
|
@ -320,7 +321,7 @@ void Cmd_GrabMip( void )
|
|||
plump += 768;
|
||||
|
||||
// write out and release intermediate buffers
|
||||
Wad3_AddLump( lump, plump_size, TYPE_MIPTEX, false );
|
||||
Wad3_AddLump( lump, plump_size, TYP_MIPTEX, wad_compress );
|
||||
}
|
||||
else MsgDev( D_WARN, "lump %s have invalid size, ignore\n", lumpname );
|
||||
FS_FreeImage( image );
|
||||
|
@ -377,7 +378,7 @@ void Cmd_GrabPic( void )
|
|||
yh = image->height;
|
||||
}
|
||||
|
||||
// lmp_t + picture[w*h] + numolors[short] + palette[768];
|
||||
// lmp_t + picture[w*h] + numcolors[short] + palette[768];
|
||||
plump_size = (int)sizeof(*pic) + (xh * yh) + sizeof(short) + 768;
|
||||
plump = lump = (byte *)Mem_Alloc( wadpool, plump_size );
|
||||
pic = (lmp_t *)plump;
|
||||
|
@ -396,41 +397,11 @@ void Cmd_GrabPic( void )
|
|||
plump += 768;
|
||||
|
||||
// write out and release intermediate buffers
|
||||
Wad3_AddLump( lump, plump_size, TYPE_QPIC, false );
|
||||
Wad3_AddLump( lump, plump_size, TYP_QPIC, wad_compress );
|
||||
FS_FreeImage( image );
|
||||
Mem_Free( lump );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Cmd_GrabScript
|
||||
|
||||
$wadqc filename
|
||||
==============
|
||||
*/
|
||||
void Cmd_GrabScript( void )
|
||||
{
|
||||
byte *lump;
|
||||
size_t plump_size;
|
||||
|
||||
Com_ReadString( wadqc, SC_PARSE_GENERIC, lumpname );
|
||||
|
||||
// load mip image or replaced with error.bmp
|
||||
lump = FS_LoadFile( lumpname, &plump_size );
|
||||
|
||||
if( !lump || !plump_size )
|
||||
{
|
||||
Com_SkipRestOfLine( wadqc );
|
||||
// no fatal error, just ignore this image for adding into wad-archive
|
||||
MsgDev( D_ERROR, "Cmd_LoadScript: unable to loading %s\n", lumpname );
|
||||
return;
|
||||
}
|
||||
|
||||
// write out and release intermediate buffers
|
||||
Wad3_AddLump( lump, plump_size, TYPE_SCRIPT, true ); // always compress text files
|
||||
Mem_Free( lump );
|
||||
}
|
||||
|
||||
void Cmd_WadName( void )
|
||||
{
|
||||
string parm;
|
||||
|
@ -444,6 +415,11 @@ void Cmd_WadName( void )
|
|||
if( !com.stricmp( parm, "append" )) wad_append = true;
|
||||
}
|
||||
|
||||
void Cmd_WadCompress( void )
|
||||
{
|
||||
wad_compress = true;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Cmd_WadUnknown
|
||||
|
@ -461,7 +437,9 @@ void ResetWADInfo( void )
|
|||
{
|
||||
FS_FileBase( gs_filename, wadoutname ); // kill path and ext
|
||||
FS_DefaultExtension( wadoutname, ".wad" ); // set new ext
|
||||
|
||||
handle = NULL;
|
||||
wad_compress = wad_append = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -481,9 +459,9 @@ bool ParseWADfileScript( void )
|
|||
break;
|
||||
|
||||
if( !com.stricmp( token.string, "$wadname" )) Cmd_WadName();
|
||||
if( !com.stricmp( token.string, "$compress" )) Cmd_WadCompress();
|
||||
else if( !com.stricmp( token.string, "$mipmap" )) Cmd_GrabMip();
|
||||
else if( !com.stricmp( token.string, "$gfxpic" )) Cmd_GrabPic();
|
||||
else if( !com.stricmp( token.string, "$wadqc" )) Cmd_GrabScript();
|
||||
else if( !Com_ValidScript( token.string, QC_WADLIB )) return false;
|
||||
else Cmd_WadUnknown( token.string );
|
||||
}
|
||||
|
@ -506,7 +484,7 @@ bool BuildCurrentWAD( const char *name )
|
|||
|
||||
if( wadqc )
|
||||
{
|
||||
if(!ParseWADfileScript())
|
||||
if( !ParseWADfileScript( ))
|
||||
return false;
|
||||
return WriteWADFile();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: xtools - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
xtools.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue