From 4163d3655ab4ebede4d426ecc29448b21ca899fa Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 12 Jun 2024 10:39:52 +0300 Subject: [PATCH] engine: reformat and reorder host_parm_s struct, remove now unused host.daemonize and host.enabledll --- engine/common/common.h | 118 ++++++++++++++---------------- engine/common/host.c | 14 +--- engine/common/host_state.c | 16 +++- engine/platform/posix/sys_posix.c | 3 +- 4 files changed, 73 insertions(+), 78 deletions(-) diff --git a/engine/common/common.h b/engine/common/common.h index e476723d..9a0250e4 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -276,78 +276,70 @@ typedef enum bugcomp_e typedef struct host_parm_s { - host_status_t status; // global host state - game_status_t game; // game manager - uint type; // running at - jmp_buf abortframe; // abort current frame - dword errorframe; // to prevent multiple host error - poolhandle_t mempool; // static mempool for misc allocations - string finalmsg; // server shutdown final message - string downloadfile; // filename to be downloading - int downloadcount; // how many files remain to downloading - char deferred_cmd[128]; // deferred commands - host_redirect_t rd; // remote console + // ==== shared through RefAPI's ref_host_t + double realtime; // host.curtime + double frametime; // time between engine frames + uint features; // custom features that enables by mod-maker request + // ==== shared through RefAPI's ref_host_t + + host_status_t status; // global host state + game_status_t game; // game manager + uint type; // running at + poolhandle_t mempool; // static mempool for misc allocations + poolhandle_t imagepool; // imagelib mempool + poolhandle_t soundpool; // soundlib mempool + string finalmsg; // server shutdown final message + string downloadfile; // filename to be downloading + int downloadcount; // how many files remain to downloading + char deferred_cmd[128];// deferred commands + + host_redirect_t rd; // remote console + + void *hWnd; // main window // command line parms - int argc; - char **argv; + char **argv; + int argc; - // ==== shared through RefAPI's ref_host_t - double realtime; // host.curtime - double frametime; // time between engine frames - uint features; // custom features that enables by mod-maker request - // ==== shared through RefAPI's ref_host_t + uint framecount; // global framecount + uint errorframe; // to prevent multiple host error + uint32_t bugcomp; // bug compatibility level, for very "special" games + double realframetime; // for some system events, e.g. console animations + double starttime; // measure time to first frame + double pureframetime; // count of sleeps can be inserted between frames + double force_draw_version_time; - double realframetime; // for some system events, e.g. console animations + char draw_decals[MAX_DECALS][MAX_QPATH]; // list of unique decal indexes + vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed + vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed - uint framecount; // global framecount - - // list of unique decal indexes - char draw_decals[MAX_DECALS][MAX_QPATH]; - - vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed - vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed - - void* hWnd; // main window - qboolean allow_console; // allow console in dev-mode or multiplayer game - qboolean allow_console_init; // initial value to allow the console - qboolean key_overstrike; // key overstrike mode - qboolean stuffcmds_pending; // should execute stuff commands - qboolean allow_cheats; // this host will allow cheating - qboolean change_game; // initialize when game is changed - qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!) - qboolean shutdown_issued; // engine is shutting down - double force_draw_version_time; - qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands - qboolean apply_opengl_config;// when true apply only to opengl cvars and ignore all other commands - qboolean config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc - qboolean crashed; // set to true if crashed - qboolean daemonized; - qboolean enabledll; - qboolean textmode; + qboolean allow_console; // allow console in dev-mode or multiplayer game + qboolean allow_console_init; // initial value to allow the console + qboolean key_overstrike; // key overstrike mode + qboolean stuffcmds_pending; // should execute stuff commands + qboolean allow_cheats; // this host will allow cheating + qboolean change_game; // initialize when game is changed + qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!) + qboolean shutdown_issued; // engine is shutting down + qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands + qboolean apply_opengl_config; // when true apply only to opengl cvars and ignore all other commands + qboolean config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc + qboolean crashed; // set to true if crashed +#if XASH_DLL_LOADER + qboolean enabledll; +#endif + qboolean textmode; // some settings were changed and needs to global update - qboolean userinfo_changed; - qboolean movevars_changed; - qboolean renderinfo_changed; - - poolhandle_t imagepool; // imagelib mempool - poolhandle_t soundpool; // soundlib mempool + qboolean userinfo_changed; + qboolean movevars_changed; + qboolean renderinfo_changed; // for IN_MouseMove() easy access - int window_center_x; - int window_center_y; - - // bug compatibility level, for very "special" games - uint32_t bugcomp; - - // measure time to first frame - double starttime; - - // count of sleeps can be inserted between frames - double pureframetime; - string gamedll; - string clientlib; + int window_center_x; + int window_center_y; + string gamedll; + string clientlib; } host_parm_t; extern host_parm_t host; diff --git a/engine/common/host.c b/engine/common/host.c index e5169a00..12e586ae 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -318,18 +318,6 @@ void Host_EndGame( qboolean abort, const char *message, ... ) if( abort ) Host_AbortCurrentFrame (); } -/* -================ -Host_AbortCurrentFrame - -aborts the current host frame and goes on with the next one -================ -*/ -void Host_AbortCurrentFrame( void ) -{ - longjmp( host.abortframe, 1 ); -} - /* ================== Host_CalcSleep @@ -1044,7 +1032,9 @@ static void Host_InitCommon( int argc, char **argv, const char *progname, qboole if( !Sys_CheckParm( "-noch" )) Sys_SetupCrashHandler(); +#if XASH_DLL_LOADER host.enabledll = !Sys_CheckParm( "-nodll" ); +#endif host.change_game = bChangeGame || Sys_CheckParm( "-changegame" ); host.config_executed = false; diff --git a/engine/common/host_state.c b/engine/common/host_state.c index a25f6591..46517c25 100644 --- a/engine/common/host_state.c +++ b/engine/common/host_state.c @@ -16,6 +16,8 @@ GNU General Public License for more details. #include "common.h" #include "platform/platform.h" +static jmp_buf g_abortframe; + void COM_InitHostState( void ) { memset( GameState, 0, sizeof( game_status_t )); @@ -168,11 +170,23 @@ static void Host_RunFrame( double time ) } } +/* +================ +Host_AbortCurrentFrame + +aborts the current host frame and goes on with the next one +================ +*/ +void Host_AbortCurrentFrame( void ) +{ + longjmp( g_abortframe, 1 ); +} + void COM_Frame( double time ) { int loopCount = 0; - if( setjmp( host.abortframe )) + if( setjmp( g_abortframe )) return; while( 1 ) diff --git a/engine/platform/posix/sys_posix.c b/engine/platform/posix/sys_posix.c index 7d5e2261..11c58a0d 100644 --- a/engine/platform/posix/sys_posix.c +++ b/engine/platform/posix/sys_posix.c @@ -96,8 +96,7 @@ void Platform_ShellExecute( const char *path, const char *parms ) void Posix_Daemonize( void ) { - // to be accessed later - if( ( host.daemonized = Sys_CheckParm( "-daemonize" ) ) ) + if( Sys_CheckParm( "-daemonize" )) { #if XASH_POSIX && defined(_POSIX_VERSION) && !defined(XASH_MOBILE_PLATFORM) pid_t daemon;