From e2a88e3f70dcd31337a45715de1d9236514a916c Mon Sep 17 00:00:00 2001 From: Bien Pham Date: Thu, 3 Nov 2022 03:07:07 +0800 Subject: [PATCH 1/2] engine: vgui: changes in vgui startup - move VGui_Startup call in CL_LoadProgs to below client.dll Initialize. VGui_Startup is actually called first in SCR_VidInit, so we can be sure that VGUI is loaded before loading client.dll. - pass client.dll path to vguiapi_t::Startup VGUI2 needs this to start client.dll vgui2 viewport. --- engine/client/cl_game.c | 7 ++----- engine/client/vgui/vgui_draw.c | 2 +- engine/vgui_api.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 6bb50705c..bd09f26cf 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -3937,11 +3937,6 @@ qboolean CL_LoadProgs( const char *name ) clgame.mempool = Mem_AllocPool( "Client Edicts Zone" ); clgame.entities = NULL; - // NOTE: important stuff! - // vgui must startup BEFORE loading client.dll to avoid get error ERROR_NOACESS - // during LoadLibrary - VGui_Startup( name, gameui.globals->scrWidth, gameui.globals->scrHeight ); - // a1ba: we need to check if client.dll has direct dependency on SDL2 // and if so, disable relative mouse mode #if XASH_WIN32 && !XASH_64BIT @@ -4042,6 +4037,8 @@ qboolean CL_LoadProgs( const char *name ) return false; } + VGui_Startup( name, gameui.globals->scrWidth, gameui.globals->scrHeight ); + Cvar_FullSet( "host_clientloaded", "1", FCVAR_READ_ONLY ); clgame.maxRemapInfos = 0; // will be alloc on first call CL_InitEdicts(); diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index cd134e249..ef1fbecc9 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -254,7 +254,7 @@ void VGui_Startup( const char *clientlib, int width, int height ) if( vgui.initialized ) { - vgui.Startup( width, height ); + vgui.Startup( clientlib, width, height ); } else if ( COM_CheckString( clientlib ) ) { diff --git a/engine/vgui_api.h b/engine/vgui_api.h index 2ce89226d..18c607831 100644 --- a/engine/vgui_api.h +++ b/engine/vgui_api.h @@ -187,7 +187,7 @@ typedef struct vguiapi_s void (*SetClipboardText)( const char *text ); key_modifier_t (*GetKeyModifiers)( void ); // called from engine side - void (*Startup)( int width, int height ); + void (*Startup)( const char *clientlib, int width, int height ); void (*Shutdown)( void ); void *(*GetPanel)( void ); void (*Paint)( void ); From 895e1986b3258d703b4b27fded3e632460e133c9 Mon Sep 17 00:00:00 2001 From: Bien Pham Date: Thu, 3 Nov 2022 18:43:24 +0800 Subject: [PATCH 2/2] engine: vgui: expose library management functions --- engine/client/vgui/vgui_draw.c | 3 +++ engine/vgui_api.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index ef1fbecc9..b63157217 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -98,6 +98,9 @@ vguiapi_t vgui = Platform_GetClipboardText, Platform_SetClipboardText, Platform_GetKeyModifiers, + COM_LoadLibrary, + COM_FreeLibrary, + COM_GetProcAddress, NULL, NULL, NULL, diff --git a/engine/vgui_api.h b/engine/vgui_api.h index 18c607831..b3d161e21 100644 --- a/engine/vgui_api.h +++ b/engine/vgui_api.h @@ -186,6 +186,9 @@ typedef struct vguiapi_s int (*GetClipboardText)( char *buffer, size_t bufferSize ); void (*SetClipboardText)( const char *text ); key_modifier_t (*GetKeyModifiers)( void ); + void *(*COM_LoadLibrary)( const char *dllname, int build_ordinals_table, qboolean directpath ); + void (*COM_FreeLibrary)( void *hInstance ); + void *(*COM_GetProcAddress)( void *hInstance, const char *name ); // called from engine side void (*Startup)( const char *clientlib, int width, int height ); void (*Shutdown)( void );