mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-06 12:25:00 +08:00
Compare commits
13 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dabed4f9eb | ||
|
|
f9b6389248 | ||
|
|
9ec1e259b4 | ||
|
|
0c2d480d89 | ||
|
|
350d8ccb7b | ||
|
|
0c512d0431 | ||
|
|
3bf55c9ea4 | ||
|
|
9994c57796 | ||
|
|
3f724b6b17 | ||
|
|
255773b4de | ||
|
|
5b73a788da | ||
|
|
748b06a00e | ||
|
|
273bccdc9a |
@@ -202,7 +202,6 @@ SCR_PlayCinematic
|
|||||||
*/
|
*/
|
||||||
qboolean SCR_PlayCinematic( const char *arg )
|
qboolean SCR_PlayCinematic( const char *arg )
|
||||||
{
|
{
|
||||||
string path;
|
|
||||||
const char *fullpath;
|
const char *fullpath;
|
||||||
|
|
||||||
fullpath = FS_GetDiskPath( arg, false );
|
fullpath = FS_GetDiskPath( arg, false );
|
||||||
|
|||||||
@@ -1136,8 +1136,6 @@ As Cvar_Set, but also flags it as glconfig
|
|||||||
*/
|
*/
|
||||||
void Cvar_SetGL_f( void )
|
void Cvar_SetGL_f( void )
|
||||||
{
|
{
|
||||||
convar_t *var;
|
|
||||||
|
|
||||||
if( Cmd_Argc() != 3 )
|
if( Cmd_Argc() != 3 )
|
||||||
{
|
{
|
||||||
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
|
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
|
||||||
|
|||||||
@@ -1087,7 +1087,6 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
|||||||
delta_info_t *dt = NULL;
|
delta_info_t *dt = NULL;
|
||||||
delta_t *pField;
|
delta_t *pField;
|
||||||
int i, countBits;
|
int i, countBits;
|
||||||
int numChanges = 0;
|
|
||||||
|
|
||||||
countBits = MAX_ENTITY_BITS + 2;
|
countBits = MAX_ENTITY_BITS + 2;
|
||||||
|
|
||||||
@@ -1121,7 +1120,7 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
|||||||
|
|
||||||
if( !Delta_CompareField( pField, from, to, timebase ))
|
if( !Delta_CompareField( pField, from, to, timebase ))
|
||||||
{
|
{
|
||||||
// strings are handled difference
|
// strings are handled differently
|
||||||
if( FBitSet( pField->flags, DT_STRING ))
|
if( FBitSet( pField->flags, DT_STRING ))
|
||||||
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
|
countBits += Q_strlen((char *)((byte *)to + pField->offset )) * 8;
|
||||||
else countBits += pField->bits;
|
else countBits += pField->bits;
|
||||||
|
|||||||
@@ -654,9 +654,9 @@ static void VID_SetWindowIcon( SDL_Window *hWnd )
|
|||||||
{
|
{
|
||||||
rgbdata_t *icon = NULL;
|
rgbdata_t *icon = NULL;
|
||||||
char iconpath[MAX_STRING];
|
char iconpath[MAX_STRING];
|
||||||
|
#if XASH_WIN32 // ICO support only for Win32
|
||||||
const char *localIcoPath;
|
const char *localIcoPath;
|
||||||
|
|
||||||
#if XASH_WIN32 // ICO support only for Win32
|
|
||||||
if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true )))
|
if(( localIcoPath = FS_GetDiskPath( GI->iconpath, true )))
|
||||||
{
|
{
|
||||||
HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE );
|
HICON ico = (HICON)LoadImage( NULL, localIcoPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE );
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ static void SV_SourceQuery_Details( netadr_t from )
|
|||||||
{
|
{
|
||||||
sizebuf_t buf;
|
sizebuf_t buf;
|
||||||
char answer[2048];
|
char answer[2048];
|
||||||
int i, bot_count, client_count;
|
int bot_count, client_count;
|
||||||
int is_private = 0;
|
int is_private = 0;
|
||||||
|
|
||||||
SV_GetPlayerCount( &client_count, &bot_count );
|
SV_GetPlayerCount( &client_count, &bot_count );
|
||||||
|
|||||||
@@ -1475,7 +1475,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
|||||||
float ds, dt, s, t;
|
float ds, dt, s, t;
|
||||||
int sample_size;
|
int sample_size;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
mtexinfo_t *tex;
|
|
||||||
mextrasurf_t *info;
|
mextrasurf_t *info;
|
||||||
color24 *lm;
|
color24 *lm;
|
||||||
vec3_t mid;
|
vec3_t mid;
|
||||||
@@ -1510,7 +1509,6 @@ static qboolean SV_RecursiveLightPoint( model_t *model, mnode_t *node, const vec
|
|||||||
{
|
{
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
|
|
||||||
tex = surf->texinfo;
|
|
||||||
info = surf->info;
|
info = surf->info;
|
||||||
|
|
||||||
if( FBitSet( surf->flags, SURF_DRAWTILED ))
|
if( FBitSet( surf->flags, SURF_DRAWTILED ))
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ def configure(conf):
|
|||||||
# re-enable undefined reference errors
|
# re-enable undefined reference errors
|
||||||
conf.env.CXXFLAGS += ['-Wl,--no-undefined']
|
conf.env.CXXFLAGS += ['-Wl,--no-undefined']
|
||||||
conf.env.CFLAGS += ['-Wl,--no-undefined']
|
conf.env.CFLAGS += ['-Wl,--no-undefined']
|
||||||
# allow the SDL2 sanity check to complete properly by linking in libstdc++ and lm normally
|
# allow the SDL2 sanity check to complete properly by linking in lm normally
|
||||||
conf.env.LDFLAGS += ['-lstdc++', '-lm']
|
conf.env.LDFLAGS += ['-lm']
|
||||||
conf.load('sdl2')
|
conf.load('sdl2')
|
||||||
if not conf.env.HAVE_SDL2:
|
if not conf.env.HAVE_SDL2:
|
||||||
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
|
conf.fatal('SDL2 not availiable! Install switch-sdl2!')
|
||||||
conf.define('XASH_SDL', 2)
|
conf.define('XASH_SDL', 2)
|
||||||
# then remove them to avoid them getting linked to shared objects
|
# then remove them to avoid them getting linked to shared objects
|
||||||
conf.env.LDFLAGS.remove('-lstdc++')
|
conf.env.LIB_SDL2.remove('stdc++') # remove libstdc++ linking from SDL2, we link it later
|
||||||
conf.env.LDFLAGS.remove('-lm')
|
conf.env.LDFLAGS.remove('-lm')
|
||||||
elif conf.env.DEST_OS == 'psvita':
|
elif conf.env.DEST_OS == 'psvita':
|
||||||
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
|
# allow the SDL2 sanity check to complete properly by linking in some deps missing from the pkg-config file
|
||||||
@@ -189,7 +189,7 @@ def build(bld):
|
|||||||
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
|
# HACK: link in the entirety of libstdc++ so that dynamic libs could use all of it without manual exporting
|
||||||
# we can't do this right away because std::filesystem will complain about not having pathconf(),
|
# we can't do this right away because std::filesystem will complain about not having pathconf(),
|
||||||
# which we have defined in sys_nswitch.c
|
# which we have defined in sys_nswitch.c
|
||||||
bld.env.LDFLAGS += ['-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
|
bld.env.LDFLAGS += ['-v', '-Wl,--whole-archive', '-lstdc++', '-Wl,--no-whole-archive', '-lm']
|
||||||
|
|
||||||
if bld.env.DEST_OS == 'psvita':
|
if bld.env.DEST_OS == 'psvita':
|
||||||
libs += [ 'VRTLD' ]
|
libs += [ 'VRTLD' ]
|
||||||
@@ -225,13 +225,9 @@ def build(bld):
|
|||||||
|
|
||||||
# Switch and PSVita have custom parameters
|
# Switch and PSVita have custom parameters
|
||||||
if bld.env.DEST_OS in ['nswitch', 'psvita']:
|
if bld.env.DEST_OS in ['nswitch', 'psvita']:
|
||||||
program = 'cxxprogram'
|
|
||||||
if bld.env.DEST_OS == 'nswitch':
|
|
||||||
program = 'cprogram' # avoid linking with g++, we link standard library explicitly
|
|
||||||
|
|
||||||
bld(source = source,
|
bld(source = source,
|
||||||
target = 'xash',
|
target = 'xash',
|
||||||
features = ['c', program],
|
features = 'c cxxprogram',
|
||||||
includes = includes,
|
includes = includes,
|
||||||
use = libs,
|
use = libs,
|
||||||
install_path = None,
|
install_path = None,
|
||||||
|
|||||||
@@ -449,7 +449,6 @@ static void FS_Search_DIR( searchpath_t *search, stringlist_t *list, const char
|
|||||||
|
|
||||||
static int FS_FileTime_DIR( searchpath_t *search, const char *filename )
|
static int FS_FileTime_DIR( searchpath_t *search, const char *filename )
|
||||||
{
|
{
|
||||||
int time;
|
|
||||||
char path[MAX_SYSPATH];
|
char path[MAX_SYSPATH];
|
||||||
|
|
||||||
Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename );
|
Q_snprintf( path, sizeof( path ), "%s%s", search->filename, filename );
|
||||||
|
|||||||
@@ -1078,29 +1078,39 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
|
|||||||
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
|
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
|
||||||
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
|
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
|
||||||
|
|
||||||
|
// if rodir's liblist.gam newer than rwdir's gameinfo.txt, then convert it
|
||||||
if( roLibListTime > rwGameInfoTime )
|
if( roLibListTime > rwGameInfoTime )
|
||||||
{
|
{
|
||||||
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
|
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
|
||||||
}
|
}
|
||||||
|
// if rodir's gameinfo.txt newer than rwdir's gameinfo.txt, just copy the file
|
||||||
else if( roGameInfoTime > rwGameInfoTime )
|
else if( roGameInfoTime > rwGameInfoTime )
|
||||||
{
|
{
|
||||||
fs_offset_t len;
|
file_t *ro, *rw;
|
||||||
char *afile_ro = (char *)FS_LoadDirectFile( gameinfo_ro, &len );
|
fs_offset_t ro_size;
|
||||||
|
|
||||||
if( afile_ro )
|
// read & write as binary to copy the exact file
|
||||||
{
|
ro = FS_SysOpen( gameinfo_ro, "rb" );
|
||||||
Con_DPrintf( "Copy rodir %s to rwdir %s\n", gameinfo_ro, gameinfo_path );
|
rw = FS_SysOpen( gameinfo_path, "wb" );
|
||||||
haveUpdate = true;
|
|
||||||
FS_WriteFile( gameinfo_path, afile_ro, len );
|
FS_Seek( ro, 0, SEEK_END );
|
||||||
Mem_Free( afile_ro );
|
ro_size = FS_Tell( ro );
|
||||||
}
|
FS_Seek( ro, 0, SEEK_SET );
|
||||||
|
|
||||||
|
FS_FileCopy( rw, ro, ro_size );
|
||||||
|
|
||||||
|
FS_Close( rw );
|
||||||
|
FS_Close( ro );
|
||||||
|
|
||||||
|
haveUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_AllowDirectPaths( false );
|
FS_AllowDirectPaths( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not update gameinfo.txt, if it was just copied from rodir's
|
||||||
// if user change liblist.gam update the gameinfo.txt
|
// if user change liblist.gam update the gameinfo.txt
|
||||||
if( FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
if( !haveUpdate && FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
||||||
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
||||||
|
|
||||||
// force to create gameinfo for specified game if missing
|
// force to create gameinfo for specified game if missing
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ searchpath_t *FS_AddPak_Fullpath( const char *pakfile, int flags )
|
|||||||
{
|
{
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
pack_t *pak;
|
pack_t *pak;
|
||||||
int i, errorcode = PAK_LOAD_COULDNT_OPEN;
|
int errorcode = PAK_LOAD_COULDNT_OPEN;
|
||||||
|
|
||||||
pak = FS_LoadPackPAK( pakfile, &errorcode );
|
pak = FS_LoadPackPAK( pakfile, &errorcode );
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ struct zip_s
|
|||||||
zipfile_t *files;
|
zipfile_t *files;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// #define ENABLE_CRC_CHECK // known to be buggy because of possible libpublic crc32 bug, disabled
|
||||||
|
|
||||||
#ifdef XASH_REDUCE_FD
|
#ifdef XASH_REDUCE_FD
|
||||||
static void FS_EnsureOpenZip( zip_t *zip )
|
static void FS_EnsureOpenZip( zip_t *zip )
|
||||||
{
|
{
|
||||||
@@ -423,12 +425,13 @@ FS_LoadZIPFile
|
|||||||
static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr )
|
static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_ind, fs_offset_t *sizeptr )
|
||||||
{
|
{
|
||||||
zipfile_t *file;
|
zipfile_t *file;
|
||||||
int index;
|
|
||||||
byte *compressed_buffer = NULL, *decompressed_buffer = NULL;
|
byte *compressed_buffer = NULL, *decompressed_buffer = NULL;
|
||||||
int zlib_result = 0;
|
int zlib_result = 0;
|
||||||
dword test_crc, final_crc;
|
|
||||||
z_stream decompress_stream;
|
z_stream decompress_stream;
|
||||||
size_t c;
|
size_t c;
|
||||||
|
#ifdef ENABLE_CRC_CHECK
|
||||||
|
dword test_crc, final_crc;
|
||||||
|
#endif // ENABLE_CRC_CHECK
|
||||||
|
|
||||||
if( sizeptr ) *sizeptr = 0;
|
if( sizeptr ) *sizeptr = 0;
|
||||||
|
|
||||||
@@ -460,7 +463,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#ifdef ENABLE_CRC_CHECK
|
||||||
CRC32_Init( &test_crc );
|
CRC32_Init( &test_crc );
|
||||||
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
||||||
|
|
||||||
@@ -472,7 +475,8 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
|||||||
Mem_Free( decompressed_buffer );
|
Mem_Free( decompressed_buffer );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ENABLE_CRC_CHECK
|
||||||
|
|
||||||
if( sizeptr ) *sizeptr = file->size;
|
if( sizeptr ) *sizeptr = file->size;
|
||||||
|
|
||||||
FS_EnsureOpenZip( NULL );
|
FS_EnsureOpenZip( NULL );
|
||||||
@@ -516,7 +520,7 @@ static byte *FS_LoadZIPFile( searchpath_t *search, const char *path, int pack_in
|
|||||||
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
|
if( zlib_result == Z_OK || zlib_result == Z_STREAM_END )
|
||||||
{
|
{
|
||||||
Mem_Free( compressed_buffer ); // finaly free compressed buffer
|
Mem_Free( compressed_buffer ); // finaly free compressed buffer
|
||||||
#if 0
|
#if ENABLE_CRC_CHECK
|
||||||
CRC32_Init( &test_crc );
|
CRC32_Init( &test_crc );
|
||||||
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
CRC32_ProcessBuffer( &test_crc, decompressed_buffer, file->size );
|
||||||
|
|
||||||
@@ -668,7 +672,7 @@ searchpath_t *FS_AddZip_Fullpath( const char *zipfile, int flags )
|
|||||||
{
|
{
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
zip_t *zip;
|
zip_t *zip;
|
||||||
int i, errorcode = ZIP_LOAD_COULDNT_OPEN;
|
int errorcode = ZIP_LOAD_COULDNT_OPEN;
|
||||||
|
|
||||||
zip = FS_LoadZip( zipfile, &errorcode );
|
zip = FS_LoadZip( zipfile, &errorcode );
|
||||||
|
|
||||||
|
|||||||
@@ -892,6 +892,11 @@ typedef float GLmatrix[16];
|
|||||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||||
#define WGL_SAMPLES_ARB 0x2042
|
#define WGL_SAMPLES_ARB 0x2042
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
#if defined( XASH_GL_STATIC ) && !defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
||||||
#define GL_FUNCTION( name ) name
|
#define GL_FUNCTION( name ) name
|
||||||
#elif defined( XASH_GL_STATIC ) && defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
#elif defined( XASH_GL_STATIC ) && defined( REF_GL_KEEP_MANGLED_FUNCTIONS )
|
||||||
@@ -1861,4 +1866,8 @@ APIENTRY_LINKAGE void GL_FUNCTION( glTexImage2DMultisample )(GLenum target, GLsi
|
|||||||
#define pglSwapInterval glSwapInterval
|
#define pglSwapInterval glSwapInterval
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif//GL_EXPORT_H
|
#endif//GL_EXPORT_H
|
||||||
|
|||||||
@@ -913,13 +913,7 @@ void GL_InitExtensionsBigGL( void )
|
|||||||
|
|
||||||
// gl4es may be used system-wide
|
// gl4es may be used system-wide
|
||||||
if( Q_stristr( glConfig.renderer_string, "gl4es" ))
|
if( Q_stristr( glConfig.renderer_string, "gl4es" ))
|
||||||
{
|
|
||||||
const char *vendor = (const char *)pglGetString( GL_VENDOR | 0x10000 );
|
|
||||||
const char *renderer = (const char *)pglGetString( GL_RENDERER | 0x10000 );
|
|
||||||
const char *version = (const char *)pglGetString( GL_VERSION | 0x10000 );
|
|
||||||
const char *extensions = (const char *)pglGetString( GL_EXTENSIONS | 0x10000 );
|
|
||||||
glConfig.wrapper = GLES_WRAPPER_GL4ES;
|
glConfig.wrapper = GLES_WRAPPER_GL4ES;
|
||||||
}
|
|
||||||
|
|
||||||
// multitexture
|
// multitexture
|
||||||
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
|
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
|
||||||
|
|||||||
@@ -351,11 +351,8 @@ static qboolean LoadMDL( const char *modelname )
|
|||||||
|
|
||||||
if( destdir[0] != '\0' )
|
if( destdir[0] != '\0' )
|
||||||
{
|
{
|
||||||
if( !MakeDirectory( destdir ))
|
if( !MakeFullPath( destdir ))
|
||||||
{
|
|
||||||
fprintf( stderr, "ERROR: Couldn't create directory %s\n", destdir );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
COM_ExtractFilePath( modelname, destdir );
|
COM_ExtractFilePath( modelname, destdir );
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ GNU General Public License for more details.
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "mdldec.h"
|
#include "mdldec.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "smd.h"
|
||||||
|
#include "texture.h"
|
||||||
#include "qc.h"
|
#include "qc.h"
|
||||||
|
|
||||||
static char **activity_names;
|
static char **activity_names;
|
||||||
@@ -62,7 +64,7 @@ qboolean LoadActivityList( const char *appname )
|
|||||||
|
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
fputs( "ERROR: Can't open file " ACTIVITIES_FILE ".\n", stderr );
|
fputs( "ERROR: Couldn't open file " ACTIVITIES_FILE ".\n", stderr );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,11 +476,11 @@ static void WriteSequenceInfo( FILE *fp )
|
|||||||
if( seqdesc->numblends > 1 )
|
if( seqdesc->numblends > 1 )
|
||||||
{
|
{
|
||||||
for( j = 0; j < seqdesc->numblends; j++ )
|
for( j = 0; j < seqdesc->numblends; j++ )
|
||||||
fprintf( fp, "\t\"%s_blend%02i\"\n", seqdesc->label, j + 1 );
|
fprintf( fp, "\t\"" DEFAULT_SEQUENCEPATH "%s_blend%02i\"\n", seqdesc->label, j + 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf( fp, "\t\"%s\"\n", seqdesc->label );
|
fprintf( fp, "\t\"" DEFAULT_SEQUENCEPATH "%s\"\n", seqdesc->label );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( seqdesc->activity )
|
if( seqdesc->activity )
|
||||||
@@ -565,7 +567,7 @@ void WriteQCScript( void )
|
|||||||
|
|
||||||
if( len == -1 )
|
if( len == -1 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.qc\n", modelfile );
|
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.qc\n", modelfile );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +575,7 @@ void WriteQCScript( void )
|
|||||||
|
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Can't write %s\n", filename );
|
fprintf( stderr, "ERROR: Couldn't write %s\n", filename );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,7 +596,7 @@ void WriteQCScript( void )
|
|||||||
fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile );
|
fprintf( fp, "$modelname \"%s.mdl\"\n", modelfile );
|
||||||
|
|
||||||
fputs( "$cd \".\"\n", fp );
|
fputs( "$cd \".\"\n", fp );
|
||||||
fputs( "$cdtexture \".\"\n", fp );
|
fputs( "$cdtexture \"./" DEFAULT_TEXTUREPATH "\"\n", fp );
|
||||||
fputs( "$cliptotextures\n", fp );
|
fputs( "$cliptotextures\n", fp );
|
||||||
fputs( "$scale 1.0\n", fp );
|
fputs( "$scale 1.0\n", fp );
|
||||||
fputs( "\n", fp );
|
fputs( "\n", fp );
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ GNU General Public License for more details.
|
|||||||
#include "studio.h"
|
#include "studio.h"
|
||||||
#include "mdldec.h"
|
#include "mdldec.h"
|
||||||
#include "smd.h"
|
#include "smd.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
static matrix3x4 *bonetransform;
|
static matrix3x4 *bonetransform;
|
||||||
static matrix3x4 *worldtransform;
|
static matrix3x4 *worldtransform;
|
||||||
@@ -520,7 +521,7 @@ static void WriteReferences( void )
|
|||||||
|
|
||||||
if( len == -1 )
|
if( len == -1 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", model->name );
|
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.smd\n", model->name );
|
||||||
goto _fail;
|
goto _fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +529,7 @@ static void WriteReferences( void )
|
|||||||
|
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Can't write %s\n", filename );
|
fprintf( stderr, "ERROR: Couldn't write %s\n", filename );
|
||||||
goto _fail;
|
goto _fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,31 +560,41 @@ WriteSequences
|
|||||||
static void WriteSequences( void )
|
static void WriteSequences( void )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int len;
|
int len, namelen, emptyplace;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char filename[MAX_SYSPATH];
|
char path[MAX_SYSPATH];
|
||||||
mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
|
mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex );
|
||||||
|
|
||||||
|
len = Q_snprintf( path, MAX_SYSPATH, "%s" DEFAULT_SEQUENCEPATH, destdir );
|
||||||
|
|
||||||
|
if( len == -1 || !MakeDirectory( path ))
|
||||||
|
{
|
||||||
|
fputs( "ERROR: Destination path is too long or write permission denied. Couldn't create directory for sequences\n", stderr );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emptyplace = MAX_SYSPATH - len;
|
||||||
|
|
||||||
for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
|
for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
|
||||||
{
|
{
|
||||||
for( j = 0; j < seqdesc->numblends; j++ )
|
for( j = 0; j < seqdesc->numblends; j++ )
|
||||||
{
|
{
|
||||||
if( seqdesc->numblends == 1 )
|
if( seqdesc->numblends == 1 )
|
||||||
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, seqdesc->label );
|
namelen = Q_snprintf( &path[len], emptyplace, "%s.smd", seqdesc->label );
|
||||||
else
|
else
|
||||||
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s_blend%02i.smd", destdir, seqdesc->label, j + 1 );
|
namelen = Q_snprintf( &path[len], emptyplace, "%s_blend%02i.smd", seqdesc->label, j + 1 );
|
||||||
|
|
||||||
if( len == -1 )
|
if( namelen == -1 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", seqdesc->label );
|
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s.smd\n", seqdesc->label );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen( filename, "w" );
|
fp = fopen( path, "w" );
|
||||||
|
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Can't write %s\n", filename );
|
fprintf( stderr, "ERROR: Couldn't write %s\n", path );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,7 +605,7 @@ static void WriteSequences( void )
|
|||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
printf( "Sequence: %s\n", filename );
|
printf( "Sequence: %s\n", path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ GNU General Public License for more details.
|
|||||||
#ifndef SMD_H
|
#ifndef SMD_H
|
||||||
#define SMD_H
|
#define SMD_H
|
||||||
|
|
||||||
|
#define DEFAULT_SEQUENCEPATH "anims/"
|
||||||
|
|
||||||
void WriteSMD( void );
|
void WriteSMD( void );
|
||||||
|
|
||||||
#endif // SMD_H
|
#endif // SMD_H
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ GNU General Public License for more details.
|
|||||||
#include "img_tga.h"
|
#include "img_tga.h"
|
||||||
#include "mdldec.h"
|
#include "mdldec.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
@@ -130,27 +131,37 @@ WriteTextures
|
|||||||
*/
|
*/
|
||||||
void WriteTextures( void )
|
void WriteTextures( void )
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len, namelen, emptyplace;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
|
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex );
|
||||||
char filename[MAX_SYSPATH];
|
char path[MAX_SYSPATH];
|
||||||
|
|
||||||
|
len = Q_snprintf( path, MAX_SYSPATH, "%s" DEFAULT_TEXTUREPATH, destdir );
|
||||||
|
|
||||||
|
if( len == -1 || !MakeDirectory( path ))
|
||||||
|
{
|
||||||
|
fputs( "ERROR: Destination path is too long or write permission denied. Couldn't create directory for textures\n", stderr );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emptyplace = MAX_SYSPATH - len;
|
||||||
|
|
||||||
for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
|
for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
|
||||||
{
|
{
|
||||||
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s", destdir, texture->name );
|
namelen = Q_strncpy( &path[len], texture->name, emptyplace );
|
||||||
|
|
||||||
if( len == -1 )
|
if( emptyplace - namelen < 0 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s\n", texture->name );
|
fprintf( stderr, "ERROR: Destination path is too long. Couldn't write %s\n", texture->name );
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen( filename, "wb" );
|
fp = fopen( path, "wb" );
|
||||||
|
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ERROR: Can't write texture file %s\n", filename );
|
fprintf( stderr, "ERROR: Couldn't write texture file %s\n", path );
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !Q_stricmp( COM_FileExtension( texture->name ), "tga" ))
|
if( !Q_stricmp( COM_FileExtension( texture->name ), "tga" ))
|
||||||
@@ -160,7 +171,7 @@ void WriteTextures( void )
|
|||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
printf( "Texture: %s\n", filename );
|
printf( "Texture: %s\n", path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ GNU General Public License for more details.
|
|||||||
#ifndef TEXTURE_H
|
#ifndef TEXTURE_H
|
||||||
#define TEXTURE_H
|
#define TEXTURE_H
|
||||||
|
|
||||||
|
#define DEFAULT_TEXTUREPATH "textures/"
|
||||||
|
|
||||||
void WriteTextures( void );
|
void WriteTextures( void );
|
||||||
|
|
||||||
#endif // TEXTURE_H
|
#endif // TEXTURE_H
|
||||||
|
|||||||
@@ -54,6 +54,40 @@ qboolean MakeDirectory( const char *path )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
MakeFullPath
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
qboolean MakeFullPath( const char *path )
|
||||||
|
{
|
||||||
|
char *p = (char *)path, tmp;
|
||||||
|
|
||||||
|
for( ; *p; )
|
||||||
|
{
|
||||||
|
p = Q_strpbrk( p, "/\\" );
|
||||||
|
|
||||||
|
if( p )
|
||||||
|
{
|
||||||
|
tmp = *p;
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !MakeDirectory( path ))
|
||||||
|
{
|
||||||
|
fprintf( stderr, "ERROR: Couldn't create directory %s\n", path );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !p )
|
||||||
|
break;
|
||||||
|
|
||||||
|
*p++ = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
ExtractFileName
|
ExtractFileName
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ GNU General Public License for more details.
|
|||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
qboolean MakeDirectory( const char *path );
|
qboolean MakeDirectory( const char *path );
|
||||||
|
qboolean MakeFullPath( const char *path );
|
||||||
void ExtractFileName( char *name, size_t size );
|
void ExtractFileName( char *name, size_t size );
|
||||||
off_t GetSizeOfFile( FILE *fp );
|
off_t GetSizeOfFile( FILE *fp );
|
||||||
byte *LoadFile( const char *filename, off_t *size );
|
byte *LoadFile( const char *filename, off_t *size );
|
||||||
|
|||||||
Reference in New Issue
Block a user