engine: server: implemented instant game library loading

This commit is contained in:
SNMetamorph 2021-07-12 14:43:36 +04:00 committed by a1batross
parent ef6ff3cfa6
commit ec95948b69
6 changed files with 10 additions and 7 deletions

View File

@ -1131,10 +1131,9 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
if( Host_IsDedicated() && GameState->nextstate == STATE_RUNFRAME ) if( Host_IsDedicated() && GameState->nextstate == STATE_RUNFRAME )
{ {
Con_Printf( "type 'map <mapname>' to run server... (TAB-autocomplete is working too)\n" );
// execute server.cfg after commandline // execute server.cfg after commandline
// so we have a chance to set servercfgfile // so we have a chance to set servercfgfile
Con_Printf( "Type 'map <mapname>' to start game... (TAB-autocomplete is working too)\n" );
Cbuf_AddText( va( "exec %s\n", Cvar_VariableString( "servercfgfile" ))); Cbuf_AddText( va( "exec %s\n", Cvar_VariableString( "servercfgfile" )));
Cbuf_Execute(); Cbuf_Execute();
} }

View File

@ -352,6 +352,7 @@ typedef struct
typedef struct typedef struct
{ {
qboolean initialized; // sv_init has completed qboolean initialized; // sv_init has completed
qboolean game_library_loaded; // is game library loaded in SV_InitGame
double timestart; // just for profiling double timestart; // just for profiling
int maxclients; // server max clients int maxclients; // server max clients
@ -467,7 +468,6 @@ void SV_AddToMaster( netadr_t from, sizebuf_t *msg );
qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent ); qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent );
void Host_SetServerState( int state ); void Host_SetServerState( int state );
qboolean SV_IsSimulating( void ); qboolean SV_IsSimulating( void );
qboolean SV_InitGame( void );
void SV_FreeClients( void ); void SV_FreeClients( void );
void Master_Add( void ); void Master_Add( void );
void Master_Heartbeat( void ); void Master_Heartbeat( void );
@ -476,6 +476,7 @@ void Master_Packet( void );
// //
// sv_init.c // sv_init.c
// //
qboolean SV_InitGame( void );
void SV_ActivateServer( int runPhysics ); void SV_ActivateServer( int runPhysics );
qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background ); qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background );
model_t *SV_ModelHandle( int modelindex ); model_t *SV_ModelHandle( int modelindex );

View File

@ -5028,6 +5028,7 @@ void SV_UnloadProgs( void )
Mod_ResetStudioAPI (); Mod_ResetStudioAPI ();
svs.game_library_loaded = false;
COM_FreeLibrary( svgame.hInstance ); COM_FreeLibrary( svgame.hInstance );
Mem_FreePool( &svgame.mempool ); Mem_FreePool( &svgame.mempool );
memset( &svgame, 0, sizeof( svgame )); memset( &svgame, 0, sizeof( svgame ));

View File

@ -668,8 +668,8 @@ qboolean SV_InitGame( void )
{ {
string dllpath; string dllpath;
if( svs.initialized ) if( svs.game_library_loaded )
return true; // already initialized ? return true;
// first initialize? // first initialize?
COM_ResetLibraryError(); COM_ResetLibraryError();
@ -683,8 +683,7 @@ qboolean SV_InitGame( void )
} }
// client frames will be allocated in SV_ClientConnect // client frames will be allocated in SV_ClientConnect
svs.initialized = true; svs.game_library_loaded = true;
return true; return true;
} }
@ -862,6 +861,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
if( !SV_InitGame( )) if( !SV_InitGame( ))
return false; return false;
svs.initialized = true;
Log_Open(); Log_Open();
Log_Printf( "Loading map \"%s\"\n", mapname ); Log_Printf( "Loading map \"%s\"\n", mapname );
Log_PrintServerVars(); Log_PrintServerVars();

View File

@ -959,6 +959,7 @@ void SV_Init( void )
SV_InitFilter(); SV_InitFilter();
SV_ClearGameState (); // delete all temporary *.hl files SV_ClearGameState (); // delete all temporary *.hl files
SV_InitGame();
} }
/* /*

View File

@ -2115,6 +2115,7 @@ qboolean SV_LoadGame( const char *pPath )
if( !SV_InitGame( )) if( !SV_InitGame( ))
return false; return false;
svs.initialized = true;
pFile = FS_Open( pPath, "rb", true ); pFile = FS_Open( pPath, "rb", true );
if( pFile ) if( pFile )