mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Added com_target_game startup variable
FS_Startup now uses `fs_basegame` variable for mainta/maintt
This commit is contained in:
parent
ff0474a483
commit
75aeba31c6
4 changed files with 94 additions and 10 deletions
|
@ -123,6 +123,7 @@ cvar_t *con_autochat;
|
|||
#endif
|
||||
|
||||
cvar_t *precache;
|
||||
cvar_t *com_target_game;
|
||||
|
||||
// com_speeds times
|
||||
int time_game;
|
||||
|
@ -140,9 +141,18 @@ qboolean com_gameClientRestarting = qfalse;
|
|||
|
||||
char com_errorMessage[MAXPRINTMSG];
|
||||
|
||||
static const char *target_game_names[] =
|
||||
{
|
||||
"moh",
|
||||
"mohta",
|
||||
"mohtt"
|
||||
};
|
||||
|
||||
void Com_WriteConfig_f( void );
|
||||
void CIN_CloseAllVideos(void);
|
||||
|
||||
void Com_InitTargetGame();
|
||||
|
||||
//============================================================================
|
||||
|
||||
static char *rd_buffer;
|
||||
|
@ -1578,10 +1588,13 @@ void Com_Init( char *commandLine ) {
|
|||
// done early so bind command exists
|
||||
CL_InitKeyCommands();
|
||||
|
||||
com_target_game = Cvar_Get("com_target_game", "0", CVAR_LATCH | CVAR_PROTECTED);
|
||||
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);
|
||||
|
||||
Com_InitTargetGame();
|
||||
|
||||
FS_InitFilesystem ();
|
||||
|
||||
Com_InitJournaling();
|
||||
|
@ -1654,12 +1667,29 @@ void Com_Init( char *commandLine ) {
|
|||
Cmd_AddCommand( "crash", Com_Crash_f );
|
||||
Cmd_AddCommand( "freeze", Com_Freeze_f );
|
||||
}
|
||||
Cmd_AddCommand( "quit", Com_Quit_f );
|
||||
Cmd_AddCommand( "changeVectors", MSG_ReportChangeVectors_f );
|
||||
Cmd_AddCommand("quit", Com_Quit_f);
|
||||
Cmd_AddCommand("changeVectors", MSG_ReportChangeVectors_f );
|
||||
Cmd_AddCommand("writeconfig", Com_WriteConfig_f );
|
||||
Cmd_SetCommandCompletionFunc( "writeconfig", Cmd_CompleteCfgName );
|
||||
Cmd_AddCommand("game_restart", Com_GameRestart_f);
|
||||
|
||||
#ifndef DEDICATED
|
||||
Cmd_AddCommand( "writeconfig", Com_WriteConfig_f );
|
||||
// override anything from the config files with command line args
|
||||
Com_StartupVariable( NULL );
|
||||
|
||||
// get dedicated here for proper hunk megs initialization
|
||||
#ifdef DEDICATED
|
||||
com_dedicated = Cvar_Get ("dedicated", "1", CVAR_INIT);
|
||||
Cvar_CheckRange( com_dedicated, 1, 2, qtrue );
|
||||
#else
|
||||
com_dedicated = Cvar_Get ("dedicated", "0", CVAR_LATCH);
|
||||
Cvar_CheckRange( com_dedicated, 0, 2, qtrue );
|
||||
#endif
|
||||
// allocate the stack based hunk allocator
|
||||
Com_InitHunkMemory();
|
||||
|
||||
// if any archived cvars are modified after this, we will trigger a writing
|
||||
// of the config file
|
||||
cvar_modifiedFlags &= ~CVAR_ARCHIVE;
|
||||
|
||||
//
|
||||
// init commands and vars
|
||||
|
@ -2548,6 +2578,47 @@ void Field_AutoComplete(field_t* field)
|
|||
Field_CompleteCommand(completionField->buffer, qtrue, qtrue);
|
||||
}
|
||||
|
||||
void Com_InitTargetGameWithType(target_game_e target_game)
|
||||
{
|
||||
const char* protocol;
|
||||
|
||||
switch (target_game)
|
||||
{
|
||||
case target_game_e::TG_MOH:
|
||||
Cvar_Set("com_protocol", va("%i", protocol_e::PROTOCOL_MOH));
|
||||
Cvar_Set("com_legacyprotocol", va("%i", protocol_e::PROTOCOL_MOH));
|
||||
// "main" is already used as first argument of FS_Startup
|
||||
Cvar_Set("fs_basegame", "");
|
||||
break;
|
||||
|
||||
case target_game_e::TG_MOHTA:
|
||||
Cvar_Set("com_protocol", va("%i", protocol_e::PROTOCOL_MOHTA));
|
||||
Cvar_Set("com_legacyprotocol", va("%i", protocol_e::PROTOCOL_MOHTA));
|
||||
Cvar_Set("fs_basegame", "mainta");
|
||||
break;
|
||||
|
||||
case target_game_e::TG_MOHTT:
|
||||
// mohta and mohtt use the same protocol version number
|
||||
Cvar_Set("com_protocol", va("%i", protocol_e::PROTOCOL_MOHTA));
|
||||
Cvar_Set("com_legacyprotocol", va("%i", protocol_e::PROTOCOL_MOHTA));
|
||||
Cvar_Set("fs_basegame", "maintt");
|
||||
break;
|
||||
|
||||
default:
|
||||
Com_Error(ERR_FATAL, "Invalid target game '%d'", target_game);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Com_InitTargetGame
|
||||
===============
|
||||
*/
|
||||
void Com_InitTargetGame() {
|
||||
Com_InitTargetGameWithType(static_cast<target_game_e>(com_target_game->integer));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3442,7 +3442,7 @@ static void FS_ReorderPurePaks( void )
|
|||
FS_Startup
|
||||
================
|
||||
*/
|
||||
static void FS_Startup(const char* gameName, const char* extensionName)
|
||||
static void FS_Startup(const char* gameName)
|
||||
{
|
||||
const char* homePath;
|
||||
|
||||
|
@ -3464,9 +3464,6 @@ static void FS_Startup(const char* gameName, const char* extensionName)
|
|||
Cvar_ForceReset( "com_basegame" );
|
||||
}
|
||||
|
||||
if (extensionName && FS_FilenameCompare(extensionName, gameName)) {
|
||||
Cvar_Set("fs_basegame", extensionName);
|
||||
}
|
||||
|
||||
if (!FS_FilenameCompare(fs_gamedirvar->string, gameName)) {
|
||||
// This is the standard base game. Servers and clients should
|
||||
|
@ -3992,7 +3989,7 @@ void FS_InitFilesystem( void ) {
|
|||
Cvar_Set("fs_game", "");
|
||||
|
||||
// try to start up normally
|
||||
FS_Startup( com_basegame->string, GAME_EXTENSION_BASE);
|
||||
FS_Startup(com_basegame->string);
|
||||
FS_SetRestrictions();
|
||||
|
||||
#ifndef STANDALONE
|
||||
|
@ -4029,7 +4026,7 @@ void FS_Restart( int checksumFeed ) {
|
|||
FS_ClearPakReferences(0);
|
||||
|
||||
// try to start up normally
|
||||
FS_Startup(BASEGAME, GAME_EXTENSION_BASE);
|
||||
FS_Startup(com_basegame->string);
|
||||
|
||||
FS_CheckPak0( );
|
||||
|
||||
|
|
|
@ -299,6 +299,20 @@ typedef int clipHandle_t;
|
|||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TG_MOH,
|
||||
TG_MOHTA,
|
||||
TG_MOHTT,
|
||||
TG_INVALID
|
||||
} target_game_e;
|
||||
|
||||
typedef enum {
|
||||
PROTOCOL_MOH_MIN = 6,
|
||||
PROTOCOL_MOH = 8,
|
||||
PROTOCOL_MOHTA_MIN = 15,
|
||||
PROTOCOL_MOHTA = 17,
|
||||
} protocol_e;
|
||||
|
||||
// plane sides
|
||||
typedef enum
|
||||
{
|
||||
|
|
|
@ -980,6 +980,7 @@ extern cvar_t* com_legacyprotocol;
|
|||
#ifndef DEDICATED
|
||||
extern cvar_t* con_autochat;
|
||||
#endif
|
||||
extern cvar_t* com_target_game;
|
||||
|
||||
// com_speeds times
|
||||
extern int time_game;
|
||||
|
@ -1068,6 +1069,7 @@ void Hunk_Log( void);
|
|||
void Hunk_Trash( void );
|
||||
|
||||
void Com_TouchMemory( void );
|
||||
void Com_InitHunkMemory(void);
|
||||
|
||||
// commandLine should not include the executable name (argv[0])
|
||||
void Com_Init( char *commandLine );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue