forked from FWGS/Paranoia2
Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -19,16 +19,15 @@ int main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
COM_InitCmdlib( argv, argc );
|
// if( argc <= 1 )
|
||||||
i = COM_CheckParm( "-dev" );
|
// COM_FatalError( "usage: bsp31migrate -file <path.bsp> -output <path.bsp>\n" );
|
||||||
if( i != 0 && argc > i+1 )
|
|
||||||
SetDeveloperLevel( atoi( argv[i+1] ));
|
|
||||||
|
|
||||||
if( COM_CheckParm( "-help" ) != 0 )
|
COM_InitCmdlib( argv, argc );
|
||||||
|
|
||||||
|
if(( i = COM_CheckParm( "-dev" )) != 0 )
|
||||||
{
|
{
|
||||||
Msg( "usage: bsp31migrate -file <path.bsp> -output <path.bsp>\n" );
|
SetDeveloperLevel( atoi( argv[i+1] ));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BspConvert( argc, argv );
|
return BspConvert( argc, argv );
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
|||||||
#ifndef BSP31MIGRATE_H
|
#ifndef BSP31MIGRATE_H
|
||||||
#define BSP31MIGRATE_H
|
#define BSP31MIGRATE_H
|
||||||
|
|
||||||
#include "port.h"
|
#include <windows.h>
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
@ -26,6 +26,7 @@ GNU General Public License for more details.
|
|||||||
#include "wadfile.h"
|
#include "wadfile.h"
|
||||||
#include "bspfile31.h"
|
#include "bspfile31.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -45,4 +46,4 @@ typedef enum
|
|||||||
|
|
||||||
extern int BspConvert( int argc, char **argv );
|
extern int BspConvert( int argc, char **argv );
|
||||||
|
|
||||||
#endif//BSP31MIGRATE_H
|
#endif//BSP31MIGRATE_H
|
@ -15,7 +15,6 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#include "bsp31migrate.h"
|
#include "bsp31migrate.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "stringlib.h"
|
|
||||||
|
|
||||||
#define VALVE_FORMAT 220
|
#define VALVE_FORMAT 220
|
||||||
|
|
||||||
@ -118,38 +117,46 @@ void PrintMapInfo( void )
|
|||||||
char *ptr = &g_mapinfo[infolen-2];
|
char *ptr = &g_mapinfo[infolen-2];
|
||||||
|
|
||||||
if( *ptr == ',' ) *ptr = '.';
|
if( *ptr == ',' ) *ptr = '.';
|
||||||
Msg( "Map name: %s\n", g_mapname );
|
|
||||||
|
Msg( "Map name: %s", g_mapname );
|
||||||
|
Msg( "\nMap type: " );
|
||||||
|
|
||||||
switch( g_maptype )
|
switch( g_maptype )
|
||||||
{
|
{
|
||||||
case MAP_XASH31:
|
case MAP_XASH31:
|
||||||
Msg("Map Type: ^2XashXT BSP31^7\n");
|
Msg( "^2XashXT BSP31^7" );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
COM_FatalError( "%s unknown map format\n", g_mapname );
|
COM_FatalError( "%s unknown map format\n", g_mapname );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( g_subtype != MAP_NORMAL )
|
||||||
|
Msg( "\nSub type: " );
|
||||||
|
else Msg( "\n" );
|
||||||
|
|
||||||
switch( g_subtype )
|
switch( g_subtype )
|
||||||
{
|
{
|
||||||
case MAP_HLFX06:
|
case MAP_HLFX06:
|
||||||
Msg( "Sub type: ^4HLFX 0.6^7\n" );
|
Msg( "^4HLFX 0.6^7\n" );
|
||||||
break;
|
break;
|
||||||
case MAP_XASHXT_OLD:
|
case MAP_XASHXT_OLD:
|
||||||
Msg( "Sub type: ^4XashXT 0.5^7\n" );
|
Msg( "^4XashXT 0.5^7\n" );
|
||||||
break;
|
break;
|
||||||
case MAP_P2SAVIOR:
|
case MAP_P2SAVIOR:
|
||||||
Msg( "Sub type: ^4Paranoia2: Savior^7\n" );
|
Msg( "^4Paranoia2: Savior^7\n" );
|
||||||
break;
|
break;
|
||||||
case MAP_DEPRECATED:
|
case MAP_DEPRECATED:
|
||||||
Msg( "Sub type: ^1intermediate deprecated version^7\n" );
|
Msg( "^1intermediate deprecated version^7\n" );
|
||||||
break;
|
break;
|
||||||
case MAP_XASH3D_EXT:
|
case MAP_XASH3D_EXT:
|
||||||
Msg( "Sub type: ^4Xash3D extended^7\n" );
|
Msg( "^4Xash3D extended^7\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( g_mapinfo[0] ) Msg( "Map info: %s\n", g_mapinfo );
|
if( g_mapinfo[0] ) Msg( "Map info: %s", g_mapinfo );
|
||||||
|
|
||||||
|
Msg( "\n\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -1177,13 +1184,8 @@ int BspConvert( int argc, char **argv )
|
|||||||
char output[1024];
|
char output[1024];
|
||||||
|
|
||||||
|
|
||||||
if( COM_GetParmExt( "-file", source, sizeof( source )) && COM_GetParmExt( "-output", output, sizeof( output )) )
|
if( !COM_GetParmExt( "-file", source, sizeof( source )))
|
||||||
{
|
Q_strncpy( source, "*.bsp", sizeof( source ));
|
||||||
LoadBSPFile( source, output );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_strncpy( source, "*.bsp", sizeof( source ));
|
|
||||||
|
|
||||||
search_t *search = COM_Search( source, true );
|
search_t *search = COM_Search( source, true );
|
||||||
|
|
||||||
@ -1193,11 +1195,18 @@ int BspConvert( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
COM_FileBase( search->filenames[i], name );
|
COM_FileBase( search->filenames[i], name );
|
||||||
Q_snprintf( output, sizeof( output ), "%s.bsp", name );
|
Q_snprintf( output, sizeof( output ), "%s.bsp", name );
|
||||||
|
#if 0
|
||||||
|
if( COM_FileExists( output ))
|
||||||
|
continue; // map already converted
|
||||||
|
#endif
|
||||||
LoadBSPFile( search->filenames[i], output );
|
LoadBSPFile( search->filenames[i], output );
|
||||||
}
|
}
|
||||||
|
|
||||||
Mem_Free( search );
|
Mem_Free( search );
|
||||||
Mem_Check();
|
Mem_Check();
|
||||||
|
|
||||||
|
Msg( "press any key to exit\n" );
|
||||||
|
system( "pause>nul" );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -34,15 +34,12 @@ typedef unsigned long ulong;
|
|||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef signed char int8;
|
typedef signed char int8;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
typedef __int16 int16;
|
typedef __int16 int16;
|
||||||
typedef unsigned __int16 uint16;
|
typedef unsigned __int16 uint16;
|
||||||
typedef __int32 int32;
|
typedef __int32 int32;
|
||||||
typedef unsigned __int32 uint32;
|
typedef unsigned __int32 uint32;
|
||||||
typedef __int64 int64;
|
typedef __int64 int64;
|
||||||
typedef unsigned __int64 uint64;
|
typedef unsigned __int64 uint64;
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef true
|
#undef true
|
||||||
#undef false
|
#undef false
|
||||||
@ -80,4 +77,4 @@ enum
|
|||||||
#define DXT_ENCODE_ALPHA_SDF 0x1A04 // signed distance field
|
#define DXT_ENCODE_ALPHA_SDF 0x1A04 // signed distance field
|
||||||
#define DXT_ENCODE_NORMAL_AG_PARABOLOID 0x1A07 // paraboloid projection
|
#define DXT_ENCODE_NORMAL_AG_PARABOLOID 0x1A07 // paraboloid projection
|
||||||
|
|
||||||
#endif//BASETYPES_H
|
#endif//BASETYPES_H
|
@ -76,7 +76,7 @@ BRUSH MODELS
|
|||||||
.bsp contain level static geometry with including PVS and lightning info
|
.bsp contain level static geometry with including PVS and lightning info
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
#include "../../common/bspfile.h"
|
#include "..\..\common\bspfile.h"
|
||||||
|
|
||||||
// header
|
// header
|
||||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||||
|
@ -21,19 +21,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// cmdlib.c
|
// cmdlib.c
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static char **com_argv;
|
static char **com_argv;
|
||||||
static int com_argc = 0;
|
static int com_argc = 0;
|
||||||
@ -124,7 +118,7 @@ void COM_FatalError( const char *error, ... )
|
|||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
va_start( argptr, error );
|
va_start( argptr, error );
|
||||||
snprintf( message, sizeof( message ), error, argptr );
|
_vsnprintf( message, sizeof( message ), error, argptr );
|
||||||
va_end( argptr );
|
va_end( argptr );
|
||||||
|
|
||||||
Msg( "^1Fatal Error:^7 %s", message );
|
Msg( "^1Fatal Error:^7 %s", message );
|
||||||
@ -144,7 +138,7 @@ void COM_Assert( const char *error, ... )
|
|||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
|
||||||
va_start( argptr, error );
|
va_start( argptr, error );
|
||||||
snprintf( message, sizeof( message ), error, argptr );
|
_vsnprintf( message, sizeof( message ), error, argptr );
|
||||||
va_end( argptr );
|
va_end( argptr );
|
||||||
|
|
||||||
Msg( "^1assert failed at:^7 %s", message );
|
Msg( "^1assert failed at:^7 %s", message );
|
||||||
@ -153,12 +147,8 @@ void COM_Assert( const char *error, ... )
|
|||||||
|
|
||||||
void Q_getwd( char *out, size_t size )
|
void Q_getwd( char *out, size_t size )
|
||||||
{
|
{
|
||||||
getcwd( out, size );
|
_getcwd( out, size );
|
||||||
#ifdef _WIN32
|
|
||||||
Q_strncat( out, "\\", size );
|
Q_strncat( out, "\\", size );
|
||||||
#else
|
|
||||||
Q_strncat( out, "/", size );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -219,40 +209,19 @@ I_FloatTime
|
|||||||
g-cont. the prefix 'I' was come from Doom code heh
|
g-cont. the prefix 'I' was come from Doom code heh
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
|
double I_FloatTime( void )
|
||||||
#ifdef _WIN32
|
|
||||||
#include <winbase.h>
|
|
||||||
|
|
||||||
double GAME_EXPORT I_FloatTime( void )
|
|
||||||
{
|
{
|
||||||
static LARGE_INTEGER g_PerformanceFrequency;
|
static LARGE_INTEGER g_Frequency;
|
||||||
static LARGE_INTEGER g_ClockStart;
|
static LARGE_INTEGER g_ClockStart;
|
||||||
LARGE_INTEGER CurrentTime;
|
LARGE_INTEGER CurrentTime;
|
||||||
|
|
||||||
if( !g_PerformanceFrequency.QuadPart )
|
if( !g_Frequency.QuadPart )
|
||||||
{
|
{
|
||||||
QueryPerformanceFrequency( &g_PerformanceFrequency );
|
QueryPerformanceFrequency( &g_Frequency );
|
||||||
QueryPerformanceCounter( &g_ClockStart );
|
QueryPerformanceCounter( &g_ClockStart );
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryPerformanceCounter( &CurrentTime );
|
QueryPerformanceCounter( &CurrentTime );
|
||||||
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_PerformanceFrequency.QuadPart );
|
|
||||||
}
|
|
||||||
#elif _LINUX
|
|
||||||
double GAME_EXPORT I_FloatTime( void )
|
|
||||||
{
|
|
||||||
static longtime_t g_PerformanceFrequency;
|
|
||||||
static longtime_t g_ClockStart;
|
|
||||||
longtime_t CurrentTime;
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
if( !g_PerformanceFrequency )
|
return (double)( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double)( g_Frequency.QuadPart );
|
||||||
{
|
}
|
||||||
struct timespec res;
|
|
||||||
if( !clock_getres(CLOCK_MONOTONIC, &res) )
|
|
||||||
g_PerformanceFrequency = 1000000000LL/res.tv_nsec;
|
|
||||||
}
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
||||||
return (double) ts.tv_sec + (double) ts.tv_nsec/1000000000.0;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -18,10 +18,8 @@ GNU General Public License for more details.
|
|||||||
#ifndef CMDLIB_H
|
#ifndef CMDLIB_H
|
||||||
#define CMDLIB_H
|
#define CMDLIB_H
|
||||||
|
|
||||||
#include "port.h"
|
|
||||||
#include <basetypes.h>
|
#include <basetypes.h>
|
||||||
#include "conprint.h"
|
#include "conprint.h"
|
||||||
#include "mathlib.h"
|
|
||||||
|
|
||||||
// bit routines
|
// bit routines
|
||||||
#define BIT( n ) (1<<( n ))
|
#define BIT( n ) (1<<( n ))
|
||||||
@ -110,4 +108,4 @@ void CRC32_Final( dword *pulCRC );
|
|||||||
void CRC32_ProcessByte( dword *pulCRC, byte ch );
|
void CRC32_ProcessByte( dword *pulCRC, byte ch );
|
||||||
void CRC32_ProcessBuffer( dword *pulCRC, const void *pBuffer, int nBuffer );
|
void CRC32_ProcessBuffer( dword *pulCRC, const void *pBuffer, int nBuffer );
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -14,19 +14,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "basetypes.h"
|
#include <basetypes.h>
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
#include "conprint.h"
|
#include "conprint.h"
|
||||||
#include "stdarg.h"
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
|
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
|
||||||
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
|
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
static unsigned short g_color_table[8] =
|
static unsigned short g_color_table[8] =
|
||||||
{
|
{
|
||||||
FOREGROUND_INTENSITY, // black
|
FOREGROUND_INTENSITY, // black
|
||||||
@ -38,7 +34,6 @@ FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY, // cyan
|
|||||||
FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY, // magenta
|
FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY, // magenta
|
||||||
FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE, // default color (white)
|
FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE, // default color (white)
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
static int devloper_level = DEFAULT_DEVELOPER;
|
static int devloper_level = DEFAULT_DEVELOPER;
|
||||||
static bool ignore_log = false;
|
static bool ignore_log = false;
|
||||||
@ -92,77 +87,8 @@ void Sys_PrintLog( const char *pMsg )
|
|||||||
if( !pMsg || ignore_log )
|
if( !pMsg || ignore_log )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
time_t crt_time;
|
if( !logfile ) return;
|
||||||
const struct tm *crt_tm;
|
fprintf( logfile, "%s", pMsg );
|
||||||
char logtime[32] = "";
|
|
||||||
static char lastchar;
|
|
||||||
|
|
||||||
time( &crt_time );
|
|
||||||
crt_tm = localtime( &crt_time );
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
__android_log_print( ANDROID_LOG_DEBUG, "Xash", "%s", pMsg );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !lastchar || lastchar == '\n')
|
|
||||||
strftime( logtime, sizeof( logtime ), "[%H:%M:%S] ", crt_tm ); //short time
|
|
||||||
|
|
||||||
#ifdef COLORIZE_CONSOLE
|
|
||||||
{
|
|
||||||
char colored[4096];
|
|
||||||
const char *msg = pMsg;
|
|
||||||
int len = 0;
|
|
||||||
while( *msg && ( len < 4090 ) )
|
|
||||||
{
|
|
||||||
static char q3ToAnsi[ 8 ] =
|
|
||||||
{
|
|
||||||
'0', // COLOR_BLACK
|
|
||||||
'1', // COLOR_RED
|
|
||||||
'2', // COLOR_GREEN
|
|
||||||
'3', // COLOR_YELLOW
|
|
||||||
'4', // COLOR_BLUE
|
|
||||||
'6', // COLOR_CYAN
|
|
||||||
'5', // COLOR_MAGENTA
|
|
||||||
0 // COLOR_WHITE
|
|
||||||
};
|
|
||||||
|
|
||||||
if( IsColorString( msg ) )
|
|
||||||
{
|
|
||||||
int color;
|
|
||||||
|
|
||||||
msg++;
|
|
||||||
color = q3ToAnsi[ *msg++ % 8 ];
|
|
||||||
colored[len++] = '\033';
|
|
||||||
colored[len++] = '[';
|
|
||||||
if( color )
|
|
||||||
{
|
|
||||||
colored[len++] = '3';
|
|
||||||
colored[len++] = color;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
colored[len++] = '0';
|
|
||||||
colored[len++] = 'm';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
colored[len++] = *msg++;
|
|
||||||
}
|
|
||||||
colored[len] = 0;
|
|
||||||
printf( "\033[34m%s\033[0m%s\033[0m", logtime, colored );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if !defined __ANDROID__
|
|
||||||
printf( "%s %s", logtime, pMsg );
|
|
||||||
fflush( stdout );
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
lastchar = pMsg[strlen(pMsg)-1];
|
|
||||||
if( !logfile )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !lastchar || lastchar == '\n')
|
|
||||||
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S]", crt_tm ); //full time
|
|
||||||
|
|
||||||
fprintf( logfile, "%s %s", logtime, pMsg );
|
|
||||||
fflush( logfile );
|
fflush( logfile );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +101,6 @@ print into win32 console
|
|||||||
*/
|
*/
|
||||||
void Sys_Print( const char *pMsg )
|
void Sys_Print( const char *pMsg )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
char tmpBuf[8192];
|
char tmpBuf[8192];
|
||||||
HANDLE hOut = GetStdHandle( STD_OUTPUT_HANDLE );
|
HANDLE hOut = GetStdHandle( STD_OUTPUT_HANDLE );
|
||||||
unsigned long cbWritten;
|
unsigned long cbWritten;
|
||||||
@ -221,9 +146,6 @@ void Sys_Print( const char *pMsg )
|
|||||||
Sys_PrintLog( tmpBuf );
|
Sys_PrintLog( tmpBuf );
|
||||||
pTemp = tmpBuf;
|
pTemp = tmpBuf;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
Sys_PrintLog( pMsg );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -281,7 +203,6 @@ void MsgDev( int level, const char *pMsg, ... )
|
|||||||
|
|
||||||
void MsgAnim( int level, const char *pMsg, ... )
|
void MsgAnim( int level, const char *pMsg, ... )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char text[1024];
|
char text[1024];
|
||||||
char empty[1024];
|
char empty[1024];
|
||||||
@ -307,5 +228,4 @@ void MsgAnim( int level, const char *pMsg, ... )
|
|||||||
Sleep( 150 );
|
Sleep( 150 );
|
||||||
}
|
}
|
||||||
Msg( "^7\n" );
|
Msg( "^7\n" );
|
||||||
#endif
|
}
|
||||||
}
|
|
@ -13,19 +13,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#define O_BINARY 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <io.h>
|
||||||
#include "conprint.h"
|
#include "conprint.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
@ -155,21 +147,16 @@ void stringlistsort( stringlist_t *list )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listdirectory( stringlist_s *list, const char *path, bool lowercase )
|
void listdirectory( stringlist_t *list, const char *path, bool tolower )
|
||||||
{
|
{
|
||||||
int i;
|
char pattern[4096];
|
||||||
signed char *c;
|
|
||||||
#ifdef _WIN32
|
|
||||||
char pattern[4096];
|
|
||||||
struct _finddata_t n_file;
|
struct _finddata_t n_file;
|
||||||
int hFile;
|
long hFile;
|
||||||
#else
|
char *c;
|
||||||
DIR *dir;
|
int i;
|
||||||
struct dirent *entry;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
Q_strncpy( pattern, path, sizeof( pattern ));
|
||||||
Q_snprintf( pattern, sizeof( pattern ), "%s*", path );
|
Q_strncat( pattern, "*", sizeof( pattern ));
|
||||||
|
|
||||||
// ask for the directory listing handle
|
// ask for the directory listing handle
|
||||||
hFile = _findfirst( pattern, &n_file );
|
hFile = _findfirst( pattern, &n_file );
|
||||||
@ -177,33 +164,22 @@ void listdirectory( stringlist_s *list, const char *path, bool lowercase )
|
|||||||
|
|
||||||
// start a new chain with the the first name
|
// start a new chain with the the first name
|
||||||
stringlistappend( list, n_file.name );
|
stringlistappend( list, n_file.name );
|
||||||
|
|
||||||
// iterate through the directory
|
// iterate through the directory
|
||||||
while( _findnext( hFile, &n_file ) == 0 )
|
while( _findnext( hFile, &n_file ) == 0 )
|
||||||
stringlistappend( list, n_file.name );
|
stringlistappend( list, n_file.name );
|
||||||
_findclose( hFile );
|
_findclose( hFile );
|
||||||
#else
|
|
||||||
if( !( dir = opendir( path ) ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// iterate through the directory
|
if( !tolower ) return;
|
||||||
while( ( entry = readdir( dir ) ))
|
|
||||||
stringlistappend( list, entry->d_name );
|
|
||||||
closedir( dir );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// convert names to lowercase because windows doesn't care, but pattern matching code often does
|
// convert names to lowercase because windows doesn't care, but pattern matching code often does
|
||||||
if( lowercase )
|
for( i = 0; i < list->numstrings; i++ )
|
||||||
{
|
{
|
||||||
for( i = 0; i < list->numstrings; i++ )
|
for( c = list->strings[i]; *c; c++ )
|
||||||
{
|
*c = Q_tolower( *c );
|
||||||
for( c = (signed char *)list->strings[i]; *c; c++ )
|
|
||||||
{
|
|
||||||
if( *c >= 'A' && *c <= 'Z' )
|
|
||||||
*c += 'a' - 'A';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
|
||||||
@ -224,7 +200,7 @@ search_t *COM_Search( const char *pattern, int caseinsensitive, wfile_t *source_
|
|||||||
int i, basepathlength, numfiles, numchars;
|
int i, basepathlength, numfiles, numchars;
|
||||||
int resultlistindex, dirlistindex;
|
int resultlistindex, dirlistindex;
|
||||||
const char *slash, *backslash, *colon, *separator;
|
const char *slash, *backslash, *colon, *separator;
|
||||||
char netpath[1024], temp[1024], root[1024];
|
char netpath[1024], temp[1024], root[1204];
|
||||||
stringlist_t resultlist, dirlist;
|
stringlist_t resultlist, dirlist;
|
||||||
char *basepath;
|
char *basepath;
|
||||||
|
|
||||||
@ -236,21 +212,20 @@ search_t *COM_Search( const char *pattern, int caseinsensitive, wfile_t *source_
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_getwd( root, sizeof( root ) );
|
if( !GetCurrentDirectory( sizeof( root ), root ))
|
||||||
if( !root )
|
|
||||||
{
|
{
|
||||||
MsgDev( D_ERROR, "couldn't determine current directory\n" );
|
MsgDev( D_ERROR, "couldn't determine current directory\n" );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_strncat( root, "\\", sizeof( root ));
|
||||||
stringlistinit( &resultlist );
|
stringlistinit( &resultlist );
|
||||||
stringlistinit( &dirlist );
|
stringlistinit( &dirlist );
|
||||||
|
|
||||||
slash = Q_strrchr( pattern, '/' );
|
slash = Q_strrchr( pattern, '/' );
|
||||||
backslash = Q_strrchr( pattern, '\\' );
|
backslash = Q_strrchr( pattern, '\\' );
|
||||||
colon = Q_strrchr( pattern, ':' );
|
colon = Q_strrchr( pattern, ':' );
|
||||||
separator = Q_max( slash, backslash );
|
separator = max( slash, backslash );
|
||||||
separator = Q_max( separator, colon );
|
separator = max( separator, colon );
|
||||||
basepathlength = separator ? (separator + 1 - pattern) : 0;
|
basepathlength = separator ? (separator + 1 - pattern) : 0;
|
||||||
basepath = (char *)Mem_Alloc( basepathlength + 1 );
|
basepath = (char *)Mem_Alloc( basepathlength + 1 );
|
||||||
if( basepathlength ) memcpy( basepath, pattern, basepathlength );
|
if( basepathlength ) memcpy( basepath, pattern, basepathlength );
|
||||||
@ -382,11 +357,7 @@ void COM_CreatePath( char *path )
|
|||||||
// create the directory
|
// create the directory
|
||||||
save = *ofs;
|
save = *ofs;
|
||||||
*ofs = 0;
|
*ofs = 0;
|
||||||
#ifdef _WIN32
|
_mkdir( path );
|
||||||
mkdir( path );
|
|
||||||
#else
|
|
||||||
mkdir( path, 0777);
|
|
||||||
#endif
|
|
||||||
*ofs = save;
|
*ofs = save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,25 +370,13 @@ COM_FileExists
|
|||||||
*/
|
*/
|
||||||
bool COM_FileExists( const char *path )
|
bool COM_FileExists( const char *path )
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
int desc;
|
int desc;
|
||||||
|
|
||||||
if(( desc = open( path, O_RDONLY|O_BINARY )) < 0 )
|
if(( desc = open( path, O_RDONLY|O_BINARY )) < 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
close( desc );
|
close( desc );
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
int ret;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
ret = stat( path, &buf );
|
|
||||||
|
|
||||||
if( ret < 0 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return S_ISREG( buf.st_mode );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -596,28 +555,9 @@ COM_FolderExists
|
|||||||
*/
|
*/
|
||||||
bool COM_FolderExists( const char *path )
|
bool COM_FolderExists( const char *path )
|
||||||
{
|
{
|
||||||
#if XASH_WIN32
|
DWORD dwFlags = GetFileAttributes( path );
|
||||||
DWORD dwFlags = GetFileAttributes( path );
|
|
||||||
|
|
||||||
return ( dwFlags != -1 ) && ( dwFlags & FILE_ATTRIBUTE_DIRECTORY );
|
return ( dwFlags != -1 ) && FBitSet( dwFlags, FILE_ATTRIBUTE_DIRECTORY );
|
||||||
#else
|
|
||||||
DIR *dir = opendir( path );
|
|
||||||
|
|
||||||
if( dir )
|
|
||||||
{
|
|
||||||
closedir( dir );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if( (errno == ENOENT) || (errno == ENOTDIR) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MsgDev( D_ERROR, "FS_SysFolderExists: problem while opening dir: %s\n", strerror( errno ) );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -678,4 +618,4 @@ void SafeWriteExt( long handle, void *buffer, int count, const char *file, const
|
|||||||
|
|
||||||
if( write_count != (size_t)count )
|
if( write_count != (size_t)count )
|
||||||
COM_FatalError( "file write failure ( %i != %i ) at %s:%i\n", write_count, count, file, line );
|
COM_FatalError( "file write failure ( %i != %i ) at %s:%i\n", write_count, count, file, line );
|
||||||
}
|
}
|
@ -193,7 +193,6 @@ SinCos
|
|||||||
*/
|
*/
|
||||||
void SinCos( float radians, float *sine, float *cosine )
|
void SinCos( float radians, float *sine, float *cosine )
|
||||||
{
|
{
|
||||||
#if defined _MSC_VER && defined(__i386__)
|
|
||||||
_asm
|
_asm
|
||||||
{
|
{
|
||||||
fld dword ptr [radians]
|
fld dword ptr [radians]
|
||||||
@ -205,10 +204,6 @@ void SinCos( float radians, float *sine, float *cosine )
|
|||||||
fstp dword ptr [edx]
|
fstp dword ptr [edx]
|
||||||
fstp dword ptr [eax]
|
fstp dword ptr [eax]
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
*sine = sin(radians);
|
|
||||||
*cosine = cos(radians);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -410,8 +405,7 @@ fast box on planeside test
|
|||||||
*/
|
*/
|
||||||
int SignbitsForPlane( const vec3_t normal )
|
int SignbitsForPlane( const vec3_t normal )
|
||||||
{
|
{
|
||||||
int bits, i;
|
for( int bits = 0, i = 0; i < 3; i++ )
|
||||||
for( bits = 0, i = 0; i < 3; i++ )
|
|
||||||
if( normal[i] < 0.0f )
|
if( normal[i] < 0.0f )
|
||||||
bits |= 1<<i;
|
bits |= 1<<i;
|
||||||
return bits;
|
return bits;
|
||||||
@ -1226,4 +1220,4 @@ bool Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
@ -557,4 +558,4 @@ void TokenError( const char *fmt, ... )
|
|||||||
vsprintf( output, fmt, args );
|
vsprintf( output, fmt, args );
|
||||||
COM_FatalError( "%s", output );
|
COM_FatalError( "%s", output );
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,12 +3,11 @@
|
|||||||
// stringlib.cpp - safety string routines
|
// stringlib.cpp - safety string routines
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
#include "port.h"
|
#include <windows.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
|
#include <direct.h>
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "stdarg.h"
|
|
||||||
|
|
||||||
void Q_strnupr( const char *in, char *out, size_t size_out )
|
void Q_strnupr( const char *in, char *out, size_t size_out )
|
||||||
{
|
{
|
||||||
@ -288,21 +287,17 @@ int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list ar
|
|||||||
{
|
{
|
||||||
size_t result;
|
size_t result;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
__try
|
__try
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
result = vsnprintf( buffer, buffersize, format, args );
|
result = _vsnprintf( buffer, buffersize, format, args );
|
||||||
}
|
}
|
||||||
|
|
||||||
// to prevent crash while output
|
// to prevent crash while output
|
||||||
#ifdef _MSC_VER
|
|
||||||
__except( EXCEPTION_EXECUTE_HANDLER )
|
__except( EXCEPTION_EXECUTE_HANDLER )
|
||||||
{
|
{
|
||||||
Q_strncpy( buffer, "^1sprintf throw exception^7\n", buffersize );
|
Q_strncpy( buffer, "^1sprintf throw exception^7\n", buffersize );
|
||||||
result = buffersize;
|
result = buffersize;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if( result < 0 || result >= buffersize )
|
if( result < 0 || result >= buffersize )
|
||||||
{
|
{
|
||||||
@ -539,4 +534,4 @@ skipwhite:
|
|||||||
token[len] = 0;
|
token[len] = 0;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
@ -14,8 +14,11 @@ GNU General Public License for more details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "conprint.h"
|
#include "conprint.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include <direct.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <io.h>
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
@ -927,4 +930,4 @@ void W_SearchForFile( wfile_t *wad, const char *pattern, stringlist_t *resultlis
|
|||||||
*((char *)separator) = 0;
|
*((char *)separator) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include <windows.h>
|
#include <windows.h>
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "threads.h"
|
#include "threads.h"
|
||||||
#include "stringlib.h"
|
#include "stringlib.h"
|
||||||
@ -62,7 +62,7 @@ static void *attempt_calloc( size_t size )
|
|||||||
if(( base = (void *)calloc( size, 1 )) != NULL )
|
if(( base = (void *)calloc( size, 1 )) != NULL )
|
||||||
return base;
|
return base;
|
||||||
// try for half a second or so
|
// try for half a second or so
|
||||||
usleep( 100000 );
|
Sleep( 100 );
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -173,4 +173,4 @@ size_t Mem_Size( void *ptr )
|
|||||||
chunk = (memhdr_t *)((byte *)ptr - sizeof( memhdr_t ));
|
chunk = (memhdr_t *)((byte *)ptr - sizeof( memhdr_t ));
|
||||||
|
|
||||||
return chunk->size;
|
return chunk->size;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user