1616#include < cef3/cef/include/cef_stream.h>
1717#include < cef3/cef/include/wrapper/cef_stream_resource_handler.h>
1818#include " CAjaxResourceHandler.h"
19+ #include < cstdlib>
1920
2021namespace
2122{
23+ // Helper to detect Wine/Proton environment
24+ bool IsRunningOnWine ()
25+ {
26+ HMODULE hNtdll = GetModuleHandle (" ntdll.dll" );
27+ return hNtdll && GetProcAddress (hNtdll, " wine_get_version" );
28+ }
29+
2230 // Centralises command-line switch setup so both pre-launch callbacks stay in sync
2331 void ConfigureCommandLineSwitches (const CefRefPtr<CefCommandLine>& commandLine, const CefString& processType)
2432 {
@@ -30,7 +38,16 @@ namespace
3038 return ;
3139
3240 // Always provide base installation paths so loader-proxy can validate subprocess origin
33- const SString gtaPath = GetCommonRegistryValue (" " , " GTA:SA Path" );
41+ SString gtaPath = GetCommonRegistryValue (" " , " GTA:SA Path" );
42+ if (gtaPath.empty ())
43+ {
44+ // Fallback for Wine/compatibility layer: check environment variable
45+ if (const char * envGtaPath = std::getenv (" MTA_GTA_PATH" ))
46+ {
47+ gtaPath = envGtaPath;
48+ }
49+ }
50+
3451 if (!gtaPath.empty ())
3552 {
3653 commandLine->AppendSwitchWithValue (" mta-gta-path" , gtaPath);
@@ -70,6 +87,21 @@ namespace
7087 }
7188 }
7289
90+ // Wine/Proton compatibility: Allow GPU unless explicitly disabled or forced software
91+ if (IsRunningOnWine ())
92+ {
93+ if (std::getenv (" MTA_FORCE_SOFTWARE_RENDERING" ))
94+ {
95+ disableGpu = true ;
96+ }
97+ else
98+ {
99+ // In Wine, we generally want to try GPU (DXVK handles it well)
100+ // But disable-gpu-compositing is already set above which is key
101+ // If user hasn't explicitly disabled GPU in cvars, let it run
102+ }
103+ }
104+
73105 if (disableGpu)
74106 commandLine->AppendSwitch (" disable-gpu" );
75107 }
@@ -96,19 +128,6 @@ void CWebApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line)
96128 if (!command_line)
97129 return ;
98130
99- // Add GTA path and MTA base path switches before g_pCore check
100- // This callback runs in both browser process and subprocess
101- // In subprocess, g_pCore is NULL, so switches must be added before that check
102- // Read GTA path from registry
103- int iResult = 0 ;
104- const SString strGTAPath = GetCommonRegistryValue (" " , " GTA:SA Path" , &iResult);
105- if (!strGTAPath.empty ())
106- {
107- // Pass GTA directory path to CEFLauncher subprocess via command-line switch
108- // CEF's AppendSwitchWithValue handles quoting automatically
109- command_line->AppendSwitchWithValue (" mta-gta-path" , strGTAPath);
110- // AddReportLog only available in browser process where g_pCore exists
111- }
112131 const CefString processType = command_line->GetSwitchValue (" type" );
113132 ConfigureCommandLineSwitches (command_line, processType);
114133}
@@ -191,8 +210,8 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
191210
192211 if (pWebView->HasAjaxHandler (resourcePath))
193212 {
194- std::vector<SString > vecGet;
195- std::vector<SString > vecPost;
213+ std::vector<std::string > vecGet;
214+ std::vector<std::string > vecPost;
196215
197216 if (urlParts.query .str )
198217 {
@@ -201,6 +220,10 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
201220 vecTmp.reserve (8 ); // Reserve space for common query parameter count
202221 strGet.Split (" &" , vecTmp);
203222
223+ const size_t paramCount = vecTmp.size ();
224+ if (paramCount > 0 )
225+ vecGet.reserve (vecGet.size () + paramCount * 2 );
226+
204227 SString key;
205228 SString value;
206229 for (auto && param : vecTmp)
@@ -239,6 +262,10 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
239262 vecTmp.reserve (8 );
240263 postParam.Split (" &" , vecTmp);
241264
265+ const size_t postParamCount = vecTmp.size ();
266+ if (postParamCount > 0 )
267+ vecPost.reserve (vecPost.size () + postParamCount * 2 );
268+
242269 for (auto && param : vecTmp)
243270 {
244271 param.Split (" =" , &key, &value);
@@ -248,7 +275,7 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
248275 }
249276 }
250277
251- CefRefPtr<CAjaxResourceHandler> handler (new CAjaxResourceHandler (vecGet, vecPost, mimeType));
278+ CefRefPtr<CAjaxResourceHandler> handler (new CAjaxResourceHandler (std::move ( vecGet), std::move ( vecPost) , mimeType));
252279 pWebView->HandleAjaxRequest (resourcePath, handler.get ());
253280 return handler;
254281 }
0 commit comments