Skip to content

Commit 35fef00

Browse files
committed
Added on demand loading of web core dll
1 parent 947e589 commit 35fef00

File tree

9 files changed

+23
-30
lines changed

9 files changed

+23
-30
lines changed

Client/core/CCore.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,13 +1147,13 @@ void CCore::DestroyNetwork ( )
11471147
}
11481148

11491149

1150-
void CCore::InitialiseWeb ()
1150+
CWebCoreInterface* CCore::GetWebCore ()
11511151
{
1152-
// Don't initialise webcore twice
1153-
if ( m_pWebCore )
1154-
return;
1155-
1156-
m_pWebCore = CreateModule < CWebCoreInterface > ( m_WebCoreModule, "CefWeb", "cefweb", "InitWebCoreInterface", this );
1152+
if ( m_pWebCore == nullptr )
1153+
{
1154+
m_pWebCore = CreateModule < CWebCoreInterface > ( m_WebCoreModule, "CefWeb", "cefweb", "InitWebCoreInterface", this );
1155+
}
1156+
return m_pWebCore;
11571157
}
11581158

11591159

Client/core/CCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
107107
CMouseControl* GetMouseControl ( void ) { return m_pMouseControl; };
108108
CLocalGUI* GetLocalGUI ( void );
109109
CLocalizationInterface* GetLocalization ( void ) { return g_pLocalization; };
110-
CWebCoreInterface* GetWebCore ( void ) { return m_pWebCore; };
110+
CWebCoreInterface* GetWebCore ( void );
111111
CTrayIconInterface* GetTrayIcon ( void ) { return m_pTrayIcon; };
112112

113113
void SaveConfig ( bool bWaitUntilFinished = false );
@@ -184,7 +184,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
184184
void DestroyGUI ( void );
185185

186186
// Web
187-
void InitialiseWeb ( void );
187+
bool IsWebCoreLoaded ( void ) { return m_pWebCore != nullptr; }
188188
void DestroyWeb ( void );
189189

190190
// Hooks

Client/core/CGUI.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,9 @@ void CLocalGUI::EchoChat ( const char* szText, bool bColorCoded )
525525

526526
bool CLocalGUI::IsWebRequestGUIVisible ()
527527
{
528-
auto pWebCore = g_pCore->GetWebCore ();
529-
if ( pWebCore )
528+
if ( g_pCore->IsWebCoreLoaded () )
530529
{
531-
return pWebCore->IsRequestsGUIVisible ();
530+
return g_pCore->GetWebCore ()->IsRequestsGUIVisible ();
532531
}
533532
return false;
534533
}

Client/core/CKeyBinds.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ CKeyBinds::~CKeyBinds ( void )
301301

302302
bool CKeyBinds::ProcessMessage ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
303303
{
304-
if ( g_pCore->GetWebCore () && !m_pCore->IsMenuVisible() && !m_pCore->GetConsole()->IsVisible() && !m_pCore->IsChatInputEnabled() )
304+
if ( g_pCore->IsWebCoreLoaded () && !m_pCore->IsMenuVisible() && !m_pCore->GetConsole()->IsVisible() && !m_pCore->IsChatInputEnabled() )
305305
g_pCore->GetWebCore ()->ProcessInputMessage ( uMsg, wParam, lParam );
306306

307307
// Don't process Shift keys here, we have a hack for that

Client/core/CSettings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,9 +2896,9 @@ void CSettings::LoadData ( void )
28962896
m_pGridBrowserWhitelist->Clear ();
28972897
m_bBrowserListsChanged = false;
28982898

2899-
auto pWebCore = CCore::GetSingleton().GetWebCore();
2900-
if ( pWebCore )
2899+
if ( g_pCore->IsWebCoreLoaded() )
29012900
{
2901+
auto pWebCore = g_pCore->GetWebCore();
29022902
std::vector<std::pair<SString, bool>> customBlacklist;
29032903
pWebCore->GetFilterEntriesByType( customBlacklist, eWebFilterType::WEBFILTER_USER );
29042904
for ( std::vector<std::pair<SString, bool>>::iterator iter = customBlacklist.begin(); iter != customBlacklist.end(); ++iter )
@@ -3201,9 +3201,9 @@ void CSettings::SaveData ( void )
32013201
CVARS_SET ( "browser_remote_javascript", m_pCheckBoxRemoteJavascript->GetSelected () );
32023202
}
32033203

3204-
auto pWebCore = CCore::GetSingleton().GetWebCore();
3205-
if ( pWebCore )
3204+
if ( g_pCore->IsWebCoreLoaded() )
32063205
{
3206+
auto pWebCore = g_pCore->GetWebCore();
32073207
std::vector<SString> customBlacklist;
32083208
for ( int i = 0; i < m_pGridBrowserBlacklist->GetRowCount (); ++i )
32093209
{

Client/core/DXHook/CDirect3DEvents9.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ void CDirect3DEvents9::OnDirect3DDeviceCreate ( IDirect3DDevice9 *pDevice )
4949

5050
// Create the GUI elements
5151
CLocalGUI::GetSingleton().CreateObjects ( pDevice );
52-
53-
// Init webbrowser
54-
CCore::GetSingleton ().InitialiseWeb ();
5552
}
5653

5754
void CDirect3DEvents9::OnDirect3DDeviceDestroy ( IDirect3DDevice9 *pDevice )
@@ -147,11 +144,10 @@ void CDirect3DEvents9::OnPresent ( IDirect3DDevice9 *pDevice )
147144
CGraphics::GetSingleton ().GetRenderItemManager ()->FlushNonAARenderTarget();
148145

149146
bool bTookScreenShot = false;
150-
auto pWebCore = g_pCore->GetWebCore ();
151147
if ( !CGraphics::GetSingleton ().GetScreenGrabber ()->IsQueueEmpty () )
152148
{
153-
if ( pWebCore )
154-
pWebCore->OnPreScreenshot ();
149+
if ( g_pCore->IsWebCoreLoaded() )
150+
g_pCore->GetWebCore()->OnPreScreenshot();
155151

156152
bTookScreenShot = true;
157153
}
@@ -162,8 +158,8 @@ void CDirect3DEvents9::OnPresent ( IDirect3DDevice9 *pDevice )
162158
// Maybe grab screen for upload
163159
CGraphics::GetSingleton ().GetScreenGrabber ()->DoPulse ();
164160

165-
if ( bTookScreenShot && pWebCore )
166-
pWebCore->OnPostScreenshot ();
161+
if ( bTookScreenShot && g_pCore->IsWebCoreLoaded() )
162+
g_pCore->GetWebCore()->OnPostScreenshot();
167163

168164
// Draw the GUI
169165
CLocalGUI::GetSingleton().Draw ();

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,8 +2335,7 @@ bool CClientGame::KeyStrokeHandler ( const SString& strKey, bool bState, bool bI
23352335
bool bIgnore = false;
23362336
if ( bState )
23372337
{
2338-
auto pWebCore = g_pCore->GetWebCore();
2339-
auto pFocusedBrowser = pWebCore ? pWebCore->GetFocusedWebView () : nullptr;
2338+
auto pFocusedBrowser = g_pCore->IsWebCoreLoaded() ? g_pCore->GetWebCore()->GetFocusedWebView () : nullptr;
23402339
bool isMouseKey = strKey.substr(0, 5) == "mouse";
23412340

23422341
if ( g_pCore->IsMenuVisible() || ( g_pCore->GetConsole()->IsInputActive() && bIsConsoleInputKey )
@@ -2398,8 +2397,7 @@ bool CClientGame::CharacterKeyHandler ( WPARAM wChar )
23982397
if ( m_pRootEntity && g_pCore->IsMenuVisible() == false && g_pCore->GetConsole()->IsInputActive() == false )
23992398
{
24002399
// Cancel event if remote browser is focused
2401-
auto pWebCore = g_pCore->GetWebCore();
2402-
auto pFocusedBrowser = pWebCore ? pWebCore->GetFocusedWebView () : nullptr;
2400+
auto pFocusedBrowser = g_pCore->IsWebCoreLoaded() ? g_pCore->GetWebCore()->GetFocusedWebView () : nullptr;
24032401
if ( pFocusedBrowser && !pFocusedBrowser->IsLocal () )
24042402
return false;
24052403

@@ -6370,7 +6368,7 @@ void CClientGame::SetDevelopmentMode ( bool bEnable, bool bEnableWeb )
63706368
else
63716369
g_pGame->GetAudio ()->SetWorldSoundHandler ( NULL );
63726370

6373-
if ( g_pCore->GetWebCore() )
6371+
if ( g_pCore->IsWebCoreLoaded() )
63746372
g_pCore->GetWebCore()->SetTestModeEnabled ( bEnableWeb );
63756373
}
63766374

Client/mods/deathmatch/logic/CClientWebBrowser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ CClientWebBrowser::CClientWebBrowser ( CClientManager* pManager, ElementID ID, C
1919
SetTypeName ( "webbrowser" );
2020

2121
// Create the web view
22-
assert( g_pCore->GetWebCore() );
2322
m_pWebView = g_pCore->GetWebCore ()->CreateWebView ( pWebBrowserItem->m_uiSizeX, pWebBrowserItem->m_uiSizeY, bLocal, pWebBrowserItem, bTransparent );
2423

2524
// Set events interface

Client/sdk/core/CCoreInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class CCoreInterface
110110
virtual void SetConnected ( bool bConnected ) = 0;
111111
virtual void SetOfflineMod ( bool bOffline ) = 0;
112112
virtual void ApplyHooks3 ( bool bEnable ) = 0;
113+
virtual bool IsWebCoreLoaded ( void ) = 0;
113114

114115
virtual bool IsConnected ( void ) = 0;
115116
virtual bool Reconnect ( const char* szHost, unsigned short usPort, const char* szPassword, bool bSave = true ) = 0;

0 commit comments

Comments
 (0)