Skip to content

Commit 947e589

Browse files
committed
Changed web core to be in its own dll
1 parent 77a1e22 commit 947e589

File tree

13 files changed

+132
-24
lines changed

13 files changed

+132
-24
lines changed

Client/cefweb/CWebCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ std::unordered_set<SString> CWebCore::AllowPendingPages ( bool bRemember )
337337
}
338338

339339
// Trigger an event now
340-
auto pCurrentMod = CModManager::GetSingleton ().GetCurrentMod ();
340+
auto pCurrentMod = g_pCore->GetModManager ()->GetCurrentMod ();
341341
if ( !pCurrentMod )
342342
return std::unordered_set<SString>();
343343

@@ -346,7 +346,7 @@ std::unordered_set<SString> CWebCore::AllowPendingPages ( bool bRemember )
346346
if ( bRemember )
347347
{
348348
std::vector<std::pair<SString, bool>> result; // Contains only allowed entries
349-
CCore::GetSingleton ().GetWebCore ()->GetFilterEntriesByType ( result, eWebFilterType::WEBFILTER_USER, eWebFilterState::WEBFILTER_ALLOWED );
349+
g_pCore->GetWebCore ()->GetFilterEntriesByType ( result, eWebFilterType::WEBFILTER_USER, eWebFilterState::WEBFILTER_ALLOWED );
350350
std::vector<SString> customWhitelist;
351351
for ( std::vector<std::pair<SString, bool>>::iterator iter = result.begin (); iter != result.end (); ++iter )
352352
customWhitelist.push_back ( iter->first );
@@ -383,14 +383,14 @@ void CWebCore::DebugOutputThreadsafe ( const SString& message, unsigned char R,
383383
bool CWebCore::GetRemotePagesEnabled ()
384384
{
385385
bool bCanLoadRemotePages;
386-
CVARS_GET ( "browser_remote_websites", bCanLoadRemotePages );
386+
g_pCore->GetCVars ()->Get ( "browser_remote_websites", bCanLoadRemotePages );
387387
return bCanLoadRemotePages;
388388
}
389389

390390
bool CWebCore::GetRemoteJavascriptEnabled ()
391391
{
392392
bool bIsRemoteJavascriptEnabled;
393-
CVARS_GET ( "browser_remote_javascript", bIsRemoteJavascriptEnabled );
393+
g_pCore->GetCVars ()->Get ( "browser_remote_javascript", bIsRemoteJavascriptEnabled );
394394
return bIsRemoteJavascriptEnabled;
395395
}
396396

Client/cefweb/CefWeb.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto v1.0
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: CefWeb.cpp
6+
*
7+
* Multi Theft Auto is available from http://www.multitheftauto.com/
8+
*
9+
*****************************************************************************/
10+
11+
#include "StdInc.h"
12+
#include "SharedUtil.hpp"
13+
14+
CCoreInterface* g_pCore = NULL;
15+
16+
extern "C" _declspec(dllexport)
17+
CWebCoreInterface* InitWebCoreInterface(CCoreInterface* pCore)
18+
{
19+
g_pCore = pCore;
20+
21+
// Ensure main thread identification is consistent
22+
IsMainThread();
23+
24+
CWebCore* pWebCore = new CWebCore;
25+
pWebCore->Initialise();
26+
return pWebCore;
27+
}

Client/cefweb/StdInc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// StdInc.h
2+
#include "StdInc.h"

Client/cefweb/StdInc.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
#include <winsock.h>
3+
#define MTA_CLIENT
4+
#define SHARED_UTIL_WITH_FAST_HASH_MAP
5+
#include "SharedUtil.h"
6+
7+
// SDK includes
8+
#include <xml/CXMLNode.h>
9+
#include <xml/CXMLFile.h>
10+
#include <xml/CXMLAttribute.h>
11+
#include <xml/CXMLAttributes.h>
12+
#include <Common.h>
13+
14+
#include <net/CNet.h>
15+
#include <core/CClientBase.h>
16+
#include <core/CClientEntityBase.h>
17+
#include <core/CCoreInterface.h>
18+
#include "../version.h"
19+
20+
#include "CWebCore.h"
21+
#include "CWebView.h"
22+
23+
extern CCoreInterface* g_pCore;

Client/cefweb/premake5.lua

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
project "Client Webbrowser"
2+
language "C++"
3+
kind "SharedLib"
4+
targetname "cefweb"
5+
targetdir(buildpath("mta"))
6+
7+
filter "system:windows"
8+
includedirs { "../../vendor/sparsehash/current/src/windows" }
9+
linkoptions { "/SAFESEH\:NO" }
10+
buildoptions { "-Zm130" }
11+
12+
filter {}
13+
includedirs {
14+
".",
15+
"../sdk",
16+
"../../vendor/cef3",
17+
"../../vendor/sparsehash/current/src/"
18+
}
19+
20+
libdirs {
21+
"../../vendor/cef3/Release"
22+
}
23+
24+
25+
pchheader "StdInc.h"
26+
pchsource "StdInc.cpp"
27+
28+
vpaths {
29+
["Headers/*"] = "**.h",
30+
["Sources/*"] = "**.cpp",
31+
["*"] = "premake5.lua"
32+
}
33+
34+
files {
35+
"premake5.lua",
36+
"**.h",
37+
"**.cpp"
38+
}
39+
40+
links {
41+
"libcef", "CEF"
42+
}
43+
44+
defines {
45+
"_WIN32_WINNT=0x502",
46+
}
47+
48+
filter "architecture:x64"
49+
flags { "ExcludeFromBuild" }
50+
51+
filter "system:not windows"
52+
flags { "ExcludeFromBuild" }

Client/core/CCore.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ CCore::~CCore ( void )
231231
delete m_pGraphics;
232232

233233
// Delete the web
234-
SAFE_DELETE ( m_pWebCore );
234+
DestroyWeb ();
235235

236236
// Delete lazy subsystems
237237
DestroyGUI ();
@@ -617,7 +617,7 @@ void CCore::ApplyGameSettings ( void )
617617
CVARS_GET ( "fast_clothes_loading", iVal ); m_pMultiplayer->SetFastClothesLoading ( (CMultiplayer::EFastClothesLoading)iVal );
618618
CVARS_GET ( "tyre_smoke_enabled", bval ); m_pMultiplayer->SetTyreSmokeEnabled ( bval );
619619
pController->SetVerticalAimSensitivityRawValue( CVARS_GET_VALUE < float > ( "vertical_aim_sensitivity" ) );
620-
}
620+
}
621621

622622
void CCore::SetConnected ( bool bConnected )
623623
{
@@ -1153,17 +1153,15 @@ void CCore::InitialiseWeb ()
11531153
if ( m_pWebCore )
11541154
return;
11551155

1156-
// Ensure DllDirectory has not been changed
1157-
SString strDllDirectory = GetSystemDllDirectory();
1158-
SString strRequiredDllDirectory = CalcMTASAPath( "mta" );
1159-
if ( strRequiredDllDirectory.EqualsI( strDllDirectory ) == false )
1160-
{
1161-
AddReportLog( 3118, SString ( "DllDirectory wrong: DllDirectory:'%s' Path:'%s'", *strDllDirectory, *strRequiredDllDirectory ) );
1162-
SetDllDirectory( strRequiredDllDirectory );
1163-
}
1156+
m_pWebCore = CreateModule < CWebCoreInterface > ( m_WebCoreModule, "CefWeb", "cefweb", "InitWebCoreInterface", this );
1157+
}
11641158

1165-
m_pWebCore = new CWebCore;
1166-
m_pWebCore->Initialise ();
1159+
1160+
void CCore::DestroyWeb ()
1161+
{
1162+
WriteDebugEvent ( "CCore::DestroyWeb" );
1163+
SAFE_DELETE( m_pWebCore );
1164+
m_WebCoreModule.UnloadModule();
11671165
}
11681166

11691167

Client/core/CCore.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CCore;
4545
#include "CScreenShot.h"
4646
#include <xml/CXML.h>
4747
#include <ijsify.h>
48-
#include <Webbrowser/CWebCore.h>
48+
#include <core/CWebCoreInterface.h>
4949
#include "CTrayIcon.h"
5050

5151
#define DIRECTINPUT_VERSION 0x0800
@@ -185,6 +185,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
185185

186186
// Web
187187
void InitialiseWeb ( void );
188+
void DestroyWeb ( void );
188189

189190
// Hooks
190191
void ApplyHooks ( void );
@@ -285,7 +286,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
285286
// Instances (put new classes here!)
286287
CXMLFile* m_pConfigFile;
287288
CClientVariables m_ClientVariables;
288-
CWebCore* m_pWebCore = nullptr;
289+
CWebCoreInterface* m_pWebCore = nullptr;
289290
CTrayIcon* m_pTrayIcon;
290291

291292
// Hook interfaces.
@@ -306,6 +307,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
306307
CModuleLoader m_NetModule;
307308
CModuleLoader m_XMLModule;
308309
CModuleLoader m_GUIModule;
310+
CModuleLoader m_WebCoreModule;
309311

310312
// Mod manager
311313
CModManager* m_pModManager;

Client/core/StdInc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@
7070
#include "CMemStats.h"
7171
#include "CGraphStats.h"
7272
#include "CNickGen.h"
73-
#include <Webbrowser/CWebView.h>
73+
#include <core/CWebViewInterface.h>
7474
#include "CTrayIcon.h"

Client/core/premake5.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ project "Client Core"
1313
includedirs {
1414
".",
1515
"../sdk",
16-
"../../vendor/cef3",
1716
"../../vendor/tinygettext",
1817
"../../vendor/zlib",
1918
"../../vendor/jpeg-9b",
@@ -23,7 +22,6 @@ project "Client Core"
2322

2423
libdirs {
2524
"../../vendor/detours/lib",
26-
"../../vendor/cef3/Release"
2725
}
2826

2927

@@ -48,7 +46,7 @@ project "Client Core"
4846
links {
4947
"ws2_32", "d3dx9", "Userenv", "DbgHelp", "xinput", "Imagehlp", "dxguid", "dinput8",
5048
"strmiids", "odbc32", "odbccp32", "shlwapi", "winmm", "gdi32", "Imm32", "Psapi",
51-
"pthread", "libpng", "jpeg", "zlib", "tinygettext", "libcef", "CEF", "detours"
49+
"pthread", "libpng", "jpeg", "zlib", "tinygettext", "detours"
5250
}
5351

5452
defines {

Client/sdk/core/CModManagerInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef __CMODMANAGERINTERFACE_H
1313
#define __CMODMANAGERINTERFACE_H
1414

15+
class CClientBase;
16+
1517
class CModManagerInterface
1618
{
1719
public:
@@ -20,6 +22,7 @@ class CModManagerInterface
2022
virtual void RequestUnload ( void ) = 0;
2123

2224
virtual bool IsLoaded ( void ) = 0;
25+
virtual CClientBase* GetCurrentMod ( void ) = 0;
2326
};
2427

2528
#endif

0 commit comments

Comments
 (0)