Updated platform files to ioq3 codebase

This commit is contained in:
L 2023-01-31 00:53:24 +01:00
parent 0d074c09e8
commit dc36511b5a
16 changed files with 2248 additions and 884 deletions

View file

@ -99,6 +99,7 @@ cvar_t *com_cameraMode;
cvar_t *com_ansiColor;
cvar_t *com_unfocused;
cvar_t *com_minimized;
cvar_t *com_homepath;
cvar_t *precache;
// com_speeds times
@ -291,7 +292,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
lastErrorTime = currentTime;
if ( com_errorEntered ) {
SyScriptError( "recursive error after: %s", com_errorMessage );
Sys_Error( "recursive error after: %s", com_errorMessage );
}
com_errorEntered = qtrue;
@ -336,7 +337,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
Com_Shutdown ();
SyScriptError ("%s", com_errorMessage);
Sys_Error("%s", com_errorMessage);
}
@ -1266,7 +1267,7 @@ void Com_Init( char *commandLine ) {
Com_Printf( "%s %s %s\n", PRODUCT_VERSION_FULL, PLATFORM_STRING, __DATE__ );
if ( setjmp (abortframe) ) {
SyScriptError ("Error during initialization");
Sys_Error("Error during initialization");
}
// prepare enough of the subsystems to handle
@ -1291,6 +1292,8 @@ void Com_Init( char *commandLine ) {
// done early so bind command exists
CL_InitKeyCommands();
com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT|CVAR_ROM);
FS_InitFilesystem ();
Com_InitJournaling();
@ -1404,7 +1407,7 @@ void Com_Init( char *commandLine ) {
}
}
s = va( "%s %s %s", PRODUCT_VERSION_FULL, PLATFORM_STRING, __DATE__ );
s = va( "%s %s %s", PRODUCT_VERSION_FULL, PLATFORM_STRING, PRODUCT_DATE );
com_version = Cvar_Get( "version", s, CVAR_ROM | CVAR_SERVERINFO );
com_shortversion = Cvar_Get( "shortversion", TARGET_GAME_VERSION, CVAR_ROM );

View file

@ -245,8 +245,7 @@ cvar_t *fs_basepath;
static cvar_t *fs_basegame;
static cvar_t *fs_gamedirvar;
static cvar_t *fs_restrict;
static cvar_t *fs_userpath;
static cvar_t *fs_outputpath;
static cvar_t *fs_homepath;
static cvar_t *fs_copyfiles;
static cvar_t *fs_filedir;
static searchpath_t *fs_searchpaths;
@ -671,7 +670,7 @@ qboolean FS_FileExists( const char *file )
FILE *f;
char *testpath;
testpath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, file );
testpath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, file );
f = fopen( testpath, "rb" );
if (f) {
@ -693,7 +692,7 @@ qboolean FS_SV_FileExists( const char *file )
FILE *f;
char *testpath;
testpath = FS_BuildOSPath( fs_outputpath->string, file, "");
testpath = FS_BuildOSPath( fs_homepath->string, file, "");
testpath[strlen(testpath)-1] = '\0';
f = fopen( testpath, "rb" );
@ -718,7 +717,7 @@ fileHandle_t FS_SV_FOpenFileWrite( const char *filename ) {
Com_Error( ERR_FATAL, "Filesystem call made without initialization\n" );
}
ospath = FS_BuildOSPath( fs_outputpath->string, filename, "" );
ospath = FS_BuildOSPath( fs_homepath->string, filename, "" );
ospath[strlen(ospath)-1] = '\0';
f = FS_HandleForFile();
@ -769,20 +768,20 @@ int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) {
S_ClearSoundBuffer();
// search homepath
ospath = FS_BuildOSPath( fs_outputpath->string, filename, "" );
ospath = FS_BuildOSPath( fs_homepath->string, filename, "" );
// remove trailing slash
ospath[strlen(ospath)-1] = '\0';
if ( fs_debug->integer ) {
Com_Printf( "FS_SV_FOpenFileRead (fs_outputpath): %s\n", ospath );
Com_Printf( "FS_SV_FOpenFileRead (fs_homepath): %s\n", ospath );
}
fsh[f].handleFiles.file.o = fopen( ospath, "rb" );
fsh[f].handleSync = qfalse;
if (!fsh[f].handleFiles.file.o)
{
// If fs_outputpath == fs_basepath, don't bother
if (Q_stricmp(fs_outputpath->string,fs_basepath->string))
// If fs_homepath == fs_basepath, don't bother
if (Q_stricmp(fs_homepath->string,fs_basepath->string))
{
// search basepath
ospath = FS_BuildOSPath( fs_basepath->string, filename, "" );
@ -827,8 +826,8 @@ void FS_SV_Rename( const char *from, const char *to ) {
// don't let sound stutter
S_ClearSoundBuffer();
from_ospath = FS_BuildOSPath( fs_outputpath->string, from, "" );
to_ospath = FS_BuildOSPath( fs_outputpath->string, to, "" );
from_ospath = FS_BuildOSPath( fs_homepath->string, from, "" );
to_ospath = FS_BuildOSPath( fs_homepath->string, to, "" );
from_ospath[strlen(from_ospath)-1] = '\0';
to_ospath[strlen(to_ospath)-1] = '\0';
@ -861,8 +860,8 @@ void FS_Rename( const char *from, const char *to ) {
// don't let sound stutter
S_ClearSoundBuffer();
from_ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, from );
to_ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, to );
from_ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, from );
to_ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, to );
if ( fs_debug->integer ) {
Com_Printf( "FS_Rename: %s --> %s\n", from_ospath, to_ospath );
@ -923,7 +922,7 @@ fileHandle_t FS_FOpenFileWrite( const char *filename ) {
f = FS_HandleForFile();
fsh[f].zipFile = qfalse;
ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, filename );
ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );
if ( fs_debug->integer ) {
Com_Printf( "FS_FOpenFileWrite: %s\n", ospath );
@ -962,7 +961,7 @@ fileHandle_t FS_FOpenTextFileWrite( const char *filename ) {
Q_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );
ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, filename );
ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );
if ( fs_debug->integer ) {
Com_Printf( "FS_FOpenFileWrite: %s\n", ospath );
@ -1002,7 +1001,7 @@ fileHandle_t FS_FOpenFileAppend( const char *filename ) {
// don't let sound stutter
S_ClearSoundBuffer();
ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, filename );
ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );
if ( fs_debug->integer ) {
Com_Printf( "FS_FOpenFileAppend: %s\n", ospath );
@ -1084,7 +1083,7 @@ void FS_DeleteFile( const char *filename )
Com_Error( 0, "Filesystem call made without initialization\n" );
}
ospath = FS_BuildOSPath( fs_outputpath->string, fs_gamedir, filename );
ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );
if( fs_debug->integer ) {
Com_Printf( "FS_DeleteFile: %s\n", ospath );
@ -1130,7 +1129,6 @@ Used for streaming data out of either a
separate file or a ZIP file.
===========
*/
extern "C" qboolean com_fullyInitialized;
int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet ) {
searchpath_t *search;
@ -1288,7 +1286,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
continue;
}
}
dir = search->dir;
netpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );
@ -2397,7 +2395,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
nMods = 0;
nPotential = nTotal = 0;
pFiles0 = Sys_ListFiles( fs_outputpath->string, NULL, NULL, &dummy, qtrue );
pFiles0 = Sys_ListFiles( fs_homepath->string, NULL, NULL, &dummy, qtrue );
pFiles1 = Sys_ListFiles( fs_basepath->string, NULL, NULL, &dummy, qtrue );
// we searched for mods in the three paths
// it is likely that we have duplicate names now, which we will cleanup below
@ -2437,7 +2435,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
/* try on home path */
if ( nPaks <= 0 )
{
path = FS_BuildOSPath( fs_outputpath->string, name, "" );
path = FS_BuildOSPath( fs_homepath->string, name, "" );
nPaks = 0;
pPaks = Sys_ListFiles( path, ".pk3", NULL, &nPaks, qfalse );
Sys_FreeFileList( pPaks );
@ -3072,13 +3070,20 @@ FS_Startup
*/
static void FS_Startup( const char *gameName )
{
const char* homePath;
if( !silentStart ) {
Com_Printf( "----- FS_Startup -----\n" );
}
fs_debug = Cvar_Get( "fs_debug", "0", 0 );
fs_copyfiles = Cvar_Get( "fs_copyfiles", "0", CVAR_INIT );
fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultBasePath(), CVAR_INIT );
fs_basepath = Cvar_Get("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT);
homePath = Sys_DefaultHomePath();
if (!homePath || !homePath[0]) {
homePath = fs_basepath->string;
}
fs_homepath = Cvar_Get("fs_homepath", homePath, CVAR_INIT | CVAR_ROM);
fs_gamedirvar = Cvar_Get( "fs_game", "", CVAR_INIT | CVAR_SYSTEMINFO );
fs_restrict = Cvar_Get( "fs_restrict", "", CVAR_INIT );
@ -3097,14 +3102,7 @@ static void FS_Startup( const char *gameName )
Cmd_AddCommand ("fdir", FS_NewDir_f );
Cmd_AddCommand ("touchFile", FS_TouchFile_f );
fs_userpath = Cvar_Get( "fs_userpath", Sys_DefaultUserPath(), CVAR_INIT );
fs_outputpath = Cvar_Get( "fs_outputpath", Sys_DefaultOutputPath(), CVAR_INIT );
Sys_Mkdir( fs_userpath->string );
Sys_Mkdir( fs_outputpath->string );
FS_AddGameDirectory( fs_userpath->string, gameName );
Sys_Mkdir(fs_homepath->string);
if( !silentStart ) {
// print the current search paths
@ -3593,8 +3591,7 @@ void FS_InitFilesystem( void ) {
Com_StartupVariable( "fs_game" );
Com_StartupVariable( "fs_copyfiles" );
Com_StartupVariable( "fs_restrict" );
Com_StartupVariable( "fs_userpath" );
Com_StartupVariable( "fs_outputpath" );
Com_StartupVariable( "fs_homepath" );
// try to start up normally
FS_Startup( BASEGAME );
@ -3893,3 +3890,8 @@ void FS_GetRelativeFilename( const char *currentDirectory, const char *absoluteF
// copy the rest of the filename into the result string
strcpy( &out[ rfMarker ], &absoluteFilename[ afMarker ] );
}
const char* FS_GetCurrentGameDir()
{
return fs_gamedirvar->string;
}

View file

@ -220,6 +220,30 @@ void COM_StripExtension( const char *in, char *out, int destsize ) {
out[length] = 0;
}
/*
============
COM_CompareExtension
string compare the end of the strings and return qtrue if strings match
============
*/
qboolean COM_CompareExtension(const char* in, const char* ext)
{
int inlen, extlen;
inlen = strlen(in);
extlen = strlen(ext);
if (extlen <= inlen)
{
in += inlen - extlen;
if (!Q_stricmp(in, ext))
return qtrue;
}
return qfalse;
}
/*
==================
@ -1040,34 +1064,86 @@ int Com_HexStrToInt( const char *str )
============================================================================
*/
int Q_isprint( int c )
int Q_isprint(int c)
{
if ( c >= 0x20 && c <= 0x7E )
return ( 1 );
return ( 0 );
if (c >= 0x20 && c <= 0x7E)
return (1);
return (0);
}
int Q_islower( int c )
int Q_islower(int c)
{
if (c >= 'a' && c <= 'z')
return ( 1 );
return ( 0 );
return (1);
return (0);
}
int Q_isupper( int c )
int Q_isupper(int c)
{
if (c >= 'A' && c <= 'Z')
return ( 1 );
return ( 0 );
return (1);
return (0);
}
int Q_isalpha( int c )
int Q_isalpha(int c)
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return ( 1 );
return ( 0 );
return (1);
return (0);
}
qboolean Q_isanumber(const char* s)
{
char* p;
double d;
if (*s == '\0')
return qfalse;
d = strtod(s, &p);
return *p == '\0';
}
qboolean Q_isintegral(float f)
{
return (int)f == f;
}
#ifdef _WIN32
/*
=============
Q_vsnprintf
Special wrapper function for Microsoft's broken _vsnprintf() function.
MinGW comes with its own vsnprintf() which is not broken. mingw-w64
however, uses Microsoft's broken _vsnprintf() function.
=============
*/
int Q_vsnprintf(char* str, size_t size, const char* format, va_list ap)
{
int retval;
retval = _vsnprintf(str, size, format, ap);
if (retval < 0 || retval == size)
{
// Microsoft doesn't adhere to the C99 standard of vsnprintf,
// which states that the return value must be the number of
// bytes written if the output string had sufficient length.
//
// Obviously we cannot determine that value from Microsoft's
// implementation, so we have no choice but to return size.
str[size - 1] = '\0';
return size;
}
return retval;
}
#endif
char* Q_strrchr( const char* string, int c )
{
char cc = c;
@ -1325,24 +1401,18 @@ char *Q_CleanStr( char *string ) {
}
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
size_t len;
int QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
int len;
va_list argptr;
char bigbuffer[32000]; // big, but small enough to fit in PPC stack
va_start (argptr,fmt);
len = vsprintf (bigbuffer,fmt,argptr);
va_end (argptr);
if ( len >= sizeof( bigbuffer ) ) {
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
}
if (len >= size) {
Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
#ifdef _DEBUG
__debugbreak();
#endif
}
Q_strncpyz (dest, bigbuffer, size );
va_start(argptr, fmt);
len = Q_vsnprintf(dest, size, fmt, argptr);
va_end(argptr);
if (len >= size)
Com_Printf("Com_sprintf: Output length %d too short, require %d bytes.\n", size, len + 1);
return len;
}
void Com_BackslashToSlash( char *str )

View file

@ -31,6 +31,7 @@ extern "C" {
#define PRODUCT_NAME "OpenMoHAA"
#define PRODUCT_VERSION "0.49-alpha"
#define PRODUCT_DATE __DATE__
#if TARGET_GAME_TYPE == 1
// Team Assault
@ -39,6 +40,10 @@ extern "C" {
// The version string must be equal or above 2.0 to be able to connect to spearhead servers
#define TARGET_GAME_VERSION "2.41"
#define TARGET_GAME_PROTOCOL 17
#define HOMEPATH_NAME_UNIX ".mohta"
#define HOMEPATH_NAME_WIN "mohta"
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
#elif TARGET_GAME_TYPE == 2
// Team Tactics
#define BASEGAME "maintt"
@ -46,6 +51,10 @@ extern "C" {
// The version string must be equal or above 2.0 to be able to connect to breakthrough servers
#define TARGET_GAME_VERSION "2.41"
#define TARGET_GAME_PROTOCOL 17
#define HOMEPATH_NAME_UNIX ".mohtt"
#define HOMEPATH_NAME_WIN "mohtt"
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
#else
// The default: the base game (no expansion)
@ -54,6 +63,10 @@ extern "C" {
// The version string must be below 1.12, otherwise it's not possible to connect
#define TARGET_GAME_VERSION "1.12"
#define TARGET_GAME_PROTOCOL 8
#define HOMEPATH_NAME_UNIX ".moh"
#define HOMEPATH_NAME_WIN "moh"
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
#endif
#define PRODUCT_NAME_FULL PRODUCT_NAME ": " PRODUCT_EXTENSION
@ -141,28 +154,25 @@ extern "C" {
#ifdef _MSC_VER
#include <io.h>
#ifndef _STDINT
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef __int8 int8_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#endif
// vsnprintf is ISO/IEC 9899:1999
// abstracting this to make it portable
int Q_vsnprintf( char *str, size_t size, const char *format, va_list ap );
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef __int8 int8_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#else
#include <stdint.h>
#define Q_vsnprintf vsnprintf
#endif
#define HAVE_STDINT_H
#define _HAVE_STDINT_H 1
#ifdef _WIN32
// vsnprintf is ISO/IEC 9899:1999
// abstracting this to make it portable
int Q_vsnprintf(char* str, size_t size, const char* format, va_list ap);
#else
#define Q_vsnprintf vsnprintf
#endif
#endif
@ -1097,6 +1107,7 @@ float Com_Clamp( float min, float max, float value );
const char *COM_SkipPath( const char *pathname );
const char *COM_GetExtension( const char *name );
void COM_StripExtension(const char *in, char *out, int destsize);
qboolean COM_CompareExtension(const char* in, const char* ext);
void COM_DefaultExtension( char *path, int maxSize, const char *extension );
void COM_BeginParseSession( const char *name );
@ -1147,7 +1158,7 @@ void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);
int Com_HexStrToInt( const char *str );
void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
int QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
char *Com_SkipTokens( char *s, int numTokens, char *sep );
char *Com_SkipCharset( char *s, char *sep );

View file

@ -647,7 +647,7 @@ qboolean FS_FileExists( const char *file );
char *FS_BuildOSPath( const char *base, const char *game, const char *qpath );
qboolean FS_CreatePath( char *OSPath );
qboolean FS_CreatePath(char *OSPath);
int FS_LoadStack( void );
@ -767,6 +767,7 @@ void FS_Remove( const char *osPath );
void FS_FilenameCompletion( const char *dir, const char *ext,
qboolean stripExt, void(*callback)(const char *s) );
const char* FS_GetCurrentGameDir();
void FS_GetRelativeFilename( const char *currentDirectory, const char *absoluteFilename, char *out, size_t destlen );
extern char fs_gamedir[];
@ -1098,6 +1099,7 @@ extern cvar_t *com_cameraMode;
extern cvar_t *com_ansiColor;
extern cvar_t *com_unfocused;
extern cvar_t *com_minimized;
extern cvar_t *com_homepath;
extern cvar_t *com_altivec;
// both client and server must agree to pause
@ -1116,6 +1118,7 @@ extern int com_frameTime;
extern int com_frameMsec;
extern qboolean com_errorEntered;
extern qboolean com_fullyInitialized;
extern fileHandle_t com_journalFile;
extern fileHandle_t com_journalDataFile;
@ -1299,6 +1302,14 @@ void SV_Frame( int msec );
void SV_PacketEvent( netadr_t from, msg_t *msg );
qboolean SV_GameCommand( void );
//
// input interface
//
void IN_Init(void* windowData);
void IN_Frame(void);
void IN_Shutdown(void);
void IN_Restart(void);
void Com_Pause();
void Com_Unpause();
void Com_FakePause();
@ -1350,10 +1361,10 @@ sysEvent_t Com_GetSystemEvent( void );
void Sys_Init (void);
// general development dll loading for virtual machine testing
void * QDECL Sys_LoadDll( const char *name, char *fqpath , intptr_t (QDECL **entryPoint)(int, ...),
intptr_t (QDECL *systemcalls)(intptr_t, ...) );
void Sys_UnloadDll( void *dllHandle );
qboolean Sys_DllExtension(const char* name);
void Sys_UnloadGame( void );
void *Sys_GetGameAPI( void *parms );
@ -1369,7 +1380,7 @@ void *Sys_GetBotLibAPI( void *parms );
char *Sys_GetCurrentUser( void );
void QDECL SyScriptError( const char *error, ...) __attribute__ ((format (printf, 1, 2)));
void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2)));
void Sys_Quit (void);
char *Sys_GetClipboardData( void ); // note that this isn't journaled...
@ -1399,7 +1410,7 @@ qboolean Sys_StringToAdr( const char *s, netadr_t *a );
qboolean Sys_IsLANAddress (netadr_t adr);
void Sys_ShowIP(void);
void Sys_Mkdir( const char *path );
qboolean Sys_Mkdir( const char *path );
char *Sys_Cwd( void );
void Sys_SetDefaultInstallPath(const char *path);
char *Sys_DefaultInstallPath( void );