Backported ioq3 features

This commit is contained in:
OM 2023-06-25 19:35:20 +02:00
parent 7e44b955d7
commit 02993eaa9b
7 changed files with 1042 additions and 456 deletions

View file

@ -716,7 +716,7 @@ void CL_ParseDownload ( msg_t *msg ) {
clc.download = 0;
// rename the file
FS_SV_Rename ( clc.downloadTempName, clc.downloadName );
FS_SV_Rename ( clc.downloadTempName, clc.downloadName, qfalse );
}
*clc.downloadTempName = *clc.downloadName = 0;
Cvar_Set( "cl_downloadName", "" );

View file

@ -416,7 +416,7 @@ typedef struct gameImport_s {
int ( *Argc )( void );
char *( *Argv )( int n );
const char *( *Args )();
int ( *FS_FOpenFile )( const char *qpath, fileHandle_t *f, fsMode_t mode );
long ( *FS_FOpenFile )( const char *qpath, fileHandle_t *f, fsMode_t mode );
void ( *FS_Read )( void *buffer, int len, fileHandle_t f );
int ( *FS_Write )( const void *buffer, int len, fileHandle_t f );
void ( *FS_FCloseFile )( fileHandle_t f );

View file

@ -1273,6 +1273,8 @@ static void Com_Crash_f(void) {
*(int*)invalid_ptr = 0x12345678;
}
#ifndef STANDALONE
// TTimo: centralizing the cl_cdkey stuff after I discovered a buffer overflow problem with the dedicated server version
// not sure it's necessary to have different defaults for regular and dedicated, but I don't want to risk it
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470
@ -1282,6 +1284,118 @@ char cl_cdkey[34] = " ";
char cl_cdkey[34] = "123456789";
#endif
/*
=================
Com_ReadCDKey
=================
*/
qboolean CL_CDKeyValidate( const char *key, const char *checksum );
void Com_ReadCDKey( const char *filename ) {
fileHandle_t f;
char buffer[33];
char fbuffer[MAX_OSPATH];
Com_sprintf(fbuffer, sizeof(fbuffer), "%s/q3key", filename);
FS_SV_FOpenFileRead( fbuffer, &f );
if ( !f ) {
Com_Memset( cl_cdkey, '\0', 17 );
return;
}
Com_Memset( buffer, 0, sizeof(buffer) );
FS_Read( buffer, 16, f );
FS_FCloseFile( f );
if (CL_CDKeyValidate(buffer, NULL)) {
Q_strncpyz( cl_cdkey, buffer, 17 );
} else {
Com_Memset( cl_cdkey, '\0', 17 );
}
}
/*
=================
Com_AppendCDKey
=================
*/
void Com_AppendCDKey( const char *filename ) {
fileHandle_t f;
char buffer[33];
char fbuffer[MAX_OSPATH];
Com_sprintf(fbuffer, sizeof(fbuffer), "%s/q3key", filename);
FS_SV_FOpenFileRead( fbuffer, &f );
if (!f) {
Com_Memset( &cl_cdkey[16], '\0', 17 );
return;
}
Com_Memset( buffer, 0, sizeof(buffer) );
FS_Read( buffer, 16, f );
FS_FCloseFile( f );
if (CL_CDKeyValidate(buffer, NULL)) {
strcat( &cl_cdkey[16], buffer );
} else {
Com_Memset( &cl_cdkey[16], '\0', 17 );
}
}
#ifndef DEDICATED
/*
=================
Com_WriteCDKey
=================
*/
static void Com_WriteCDKey( const char *filename, const char *ikey ) {
fileHandle_t f;
char fbuffer[MAX_OSPATH];
char key[17];
#ifndef _WIN32
mode_t savedumask;
#endif
Com_sprintf(fbuffer, sizeof(fbuffer), "%s/q3key", filename);
Q_strncpyz( key, ikey, 17 );
if(!CL_CDKeyValidate(key, NULL) ) {
return;
}
#ifndef _WIN32
savedumask = umask(0077);
#endif
f = FS_SV_FOpenFileWrite( fbuffer );
if ( !f ) {
Com_Printf ("Couldn't write CD key to %s.\n", fbuffer );
goto out;
}
FS_Write( key, 16, f );
FS_Printf( f, "\n// generated by quake, do not modify\r\n" );
FS_Printf( f, "// Do not give this file to ANYONE.\r\n" );
FS_Printf( f, "// id Software and Activision will NOT ask you to send this file to them.\r\n");
FS_FCloseFile( f );
out:
#ifndef _WIN32
umask(savedumask);
#else
;
#endif
}
#endif
#endif // STANDALONE
static void Com_DetectAltivec(void)
{
// Only detect if user hasn't forcibly disabled it.
@ -1342,7 +1456,9 @@ void Com_Init( char *commandLine ) {
// done early so bind command exists
CL_InitKeyCommands();
com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT|CVAR_ROM);
com_standalone = Cvar_Get("com_standalone", "0", CVAR_ROM);
com_basegame = Cvar_Get("com_basegame", BASEGAME, CVAR_INIT);
com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT|CVAR_PROTECTED);
FS_InitFilesystem ();
@ -1517,8 +1633,6 @@ void Com_Init( char *commandLine ) {
com_fullyInitialized = qtrue;
SaveRegistryInfo( qtrue, "basepath", fs_basepath->string, 128 );
RecoverLostAutodialData();
iEnd = Sys_Milliseconds();

File diff suppressed because it is too large Load diff

View file

@ -92,6 +92,8 @@ extern "C" {
#define MAX_TEAMNAME 32
#define DEMOEXT "dm_" // standard demo extension
#ifdef _MSC_VER
#pragma warning(disable : 4018) // signed/unsigned mismatch

View file

@ -666,10 +666,15 @@ issues.
#define MAX_FILE_HANDLES 64
#ifdef DEDICATED
# define Q3CONFIG_CFG "q3config_server.cfg"
#else
# define Q3CONFIG_CFG "q3config.cfg"
#endif
qboolean FS_Initialized( void );
void FS_InitFilesystem( void );
void FS_InitFilesystem2( void );
void FS_Shutdown( qboolean closemfp );
qboolean FS_ConditionalRestart( int checksumFeed );
@ -705,14 +710,13 @@ fileHandle_t FS_FOpenFileWrite( const char *qpath );
fileHandle_t FS_FOpenTextFileWrite( const char *qpath );
// will properly create any needed paths and deal with seperater character issues
int FS_filelength( fileHandle_t f );
void FS_ReplaceSeparators( char *path );
void FS_DeleteFile( const char *filename );
void FS_CanonicalFilename( char *filename );
fileHandle_t FS_SV_FOpenFileWrite( const char *filename );
int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp );
void FS_SV_Rename( const char *from, const char *to );
int FS_FOpenFileRead( const char *qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet );
long FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp );
void FS_SV_Rename( const char *from, const char *to, qboolean safe );
long FS_FOpenFileRead(const char* filename, fileHandle_t* file, qboolean uniqueFILE, qboolean quiet);
// if uniqueFILE is true, then a new FILE will be fopened even if the file
// is found in an already open pak file. If uniqueFILE is false, you must call
// FS_FCloseFile instead of fclose, otherwise the pak FILE would be improperly closed
@ -756,7 +760,7 @@ int FS_WriteFile( const char *qpath, const void *buffer, int size );
void FS_WriteTextFile( const char *qpath, const void *buffer, int size );
// writes a complete text file, creating any subdirectories needed
int FS_filelength( fileHandle_t f );
long FS_filelength(fileHandle_t f);
// doesn't work for files that are opened from a pack file
int FS_FTell( fileHandle_t f );
@ -953,7 +957,12 @@ extern cvar_t *com_journal;
extern cvar_t *com_cameraMode;
extern cvar_t *com_ansiColor;
extern cvar_t *com_unfocused;
extern cvar_t *com_maxfpsUnfocused;
extern cvar_t *com_minimized;
extern cvar_t *com_maxfpsMinimized;
extern cvar_t *com_altivec;
extern cvar_t *com_standalone;
extern cvar_t *com_basegame;
extern cvar_t *com_homepath;
extern cvar_t *com_altivec;
@ -1269,12 +1278,17 @@ qboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message );
qboolean Sys_IsLANAddress (netadr_t adr);
void Sys_ShowIP(void);
qboolean Sys_Mkdir( const char *path );
char *Sys_Cwd( void );
void Sys_SetDefaultInstallPath(const char *path);
char *Sys_DefaultInstallPath( void );
FILE *Sys_FOpen( const char *ospath, const char *mode );
qboolean Sys_Mkdir( const char *path );
FILE *Sys_Mkfifo( const char *ospath );
char *Sys_Cwd( void );
void Sys_SetDefaultInstallPath(const char *path);
char *Sys_DefaultInstallPath(void);
char *Sys_SteamPath(void);
char *Sys_GogPath(void);
char *Sys_MicrosoftStorePath(void);
#ifdef MACOS_X
#ifdef __APPLE__
char *Sys_DefaultAppPath(void);
#endif

View file

@ -259,7 +259,7 @@ typedef struct {
void (*Clear)();
void (*Cvar_SetDefault)(cvar_t* var, const char* varValue);
int (*FS_OpenFile)(const char* qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet);
long (*FS_OpenFile)(const char* qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet);
size_t (*FS_Read)(void* buffer, size_t len, fileHandle_t fileHandle);
void (*FS_CloseFile)(fileHandle_t fileHandle);
int (*FS_Seek)(fileHandle_t fileHandle, long offset, fsOrigin_t origin);