Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed Apr 7, 2023
2 parents 894c0f7 + 9cae917 commit 7b627e9
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 126 deletions.
6 changes: 0 additions & 6 deletions Client/ceflauncher_DLL/CCefApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class CCefApp : public CefApp, public CefRenderProcessHandler
}
}

virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override
{
// Register custom MTA scheme (has to be called in all proceseses)
registrar->AddCustomScheme("mtalocal", CEF_SCHEME_OPTION_CSP_BYPASSING);
}

// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefRenderProcessHandler.html#OnContextCreated(CefRefPtr%3CCefBrowser%3E,CefRefPtr%3CCefFrame%3E,CefRefPtr%3CCefV8Context%3E)
// //
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override
Expand Down
32 changes: 0 additions & 32 deletions Client/cefweb/CWebApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ CefRefPtr<CefResourceHandler> CWebApp::HandleError(const SString& strError, unsi
return new CefStreamResourceHandler(uiError, strError, "text/plain", CefResponse::HeaderMap(), stream);
}

void CWebApp::OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar)
{
// Register custom MTA scheme (has to be called in all proceseses)
registrar->AddCustomScheme("mtalocal", CEF_SCHEME_OPTION_CSP_BYPASSING);
}

void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line)
{
command_line->AppendSwitch("disable-gpu-compositing");
Expand Down Expand Up @@ -60,32 +54,6 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
if (!CefParseURL(request->GetURL(), urlParts))
return nullptr;

if (scheme_name == "mtalocal") // Backward compatibility
{
// Get full path
SString path = UTF16ToMbUTF8(urlParts.path.str).substr(2);

// Check if we're dealing with an external resource
if (path[0] == ':')
{
size_t end = path.find_first_of('/');
if (end != std::string::npos)
{
SString resourceName = path.substr(1, end - 1);
SString resourcePath = path.substr(end);

// Call this function recursively and use the mta scheme instead
request->SetURL("http://mta/local/" + resourceName + resourcePath);
return Create(browser, frame, "http", request);
}
return HandleError("404 - Not found", 404);
}

// Redirect mtalocal://* to http://mta/local/*, call recursively
request->SetURL("http://mta/local/" + path);
return Create(browser, frame, "http", request);
}

SString host = UTF16ToMbUTF8(urlParts.host.str);
if (scheme_name == "http" && host == "mta")
{
Expand Down
1 change: 0 additions & 1 deletion Client/cefweb/CWebApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CWebApp : public CefApp, public CefSchemeHandlerFactory
// Error Handler
static CefRefPtr<CefResourceHandler> HandleError(const SString& strError, unsigned int uiError);

virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override;
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) override;

// CefSchemeHandlerFactory methods
Expand Down
1 change: 0 additions & 1 deletion Client/cefweb/CWebCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ bool CWebCore::Initialise()
bool state = CefInitialize(mainArgs, settings, app, sandboxInfo);

// Register custom scheme handler factory
CefRegisterSchemeHandlerFactory("mtalocal", "", app);
CefRegisterSchemeHandlerFactory("http", "mta", app);

return state;
Expand Down
4 changes: 1 addition & 3 deletions Client/cefweb/CWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,6 @@ bool CWebView::OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame>
else
bResult = false;
}
else if (scheme == L"mtalocal")
bResult = false; // Allow mtalocal:// URLs
else
bResult = true; // Block other schemes

Expand Down Expand Up @@ -901,7 +899,7 @@ CefResourceRequestHandler::ReturnValue CWebView::OnBeforeResourceLoad(CefRefPtr<
else
return RV_CONTINUE;
}
else if (scheme == L"mtalocal" || scheme == L"blob")
else if (scheme == L"blob")
{
return RV_CONTINUE;
}
Expand Down
4 changes: 0 additions & 4 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,10 +2057,6 @@ void CClientPed::SetFrozenWaitingForGroundToLoad(bool bFrozen)

CWeapon* CClientPed::GiveWeapon(eWeaponType weaponType, unsigned int uiAmmo, bool bSetAsCurrent)
{
// Multiply ammo with 10 if flamethrower to get the numbers correct.
if (weaponType == WEAPONTYPE_FLAMETHROWER)
uiAmmo *= 10;

CWeapon* pWeapon = NULL;
if (m_pPlayerPed)
{
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientVehicleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ bool CClientVehicleManager::HasDoors(unsigned long ulModel)
case VT_MOWER:
case VT_RCCAM:
case VT_RCGOBLIN:
case VT_BLOODRA:
break;
default:
bHasDoors = true;
Expand Down
20 changes: 8 additions & 12 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3619,20 +3619,16 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
if (icon <= RADAR_MARKER_LIMIT)
pBlip->SetSprite(icon);

// Read out size and color if there's no icon
if (icon == 0)
{
// Read out the size
SIntegerSync<unsigned char, 5> size;
bitStream.Read(&size);
// Read out the size
SIntegerSync<unsigned char, 5> size;
bitStream.Read(&size);

// Read out the color
SColorSync color;
bitStream.Read(&color);
// Read out the color
SColorSync color;
bitStream.Read(&color);

pBlip->SetScale(size);
pBlip->SetColor(color);
}
pBlip->SetScale(size);
pBlip->SetColor(color);

break;
}
Expand Down
74 changes: 29 additions & 45 deletions Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,39 +131,37 @@ int CLuaBrowserDefs::CreateBrowser(lua_State* luaVM)
}
else if (vecSize.fX == 0 || vecSize.fY == 0)
{
m_pScriptDebugging->LogWarning(luaVM, "A browser must be at least 1x1 in size. This warning may be an error in future versions.");
argStream.SetCustomError("A browser must be at least 1x1 in size.", "Invalid parameter");
}
}

if (!argStream.HasErrors())
if (argStream.HasErrors())
return luaL_error(luaVM, argStream.GetFullErrorMessage());

if (!bIsLocal && !g_pCore->GetWebCore()->GetRemotePagesEnabled())
{
if (!bIsLocal && !g_pCore->GetWebCore()->GetRemotePagesEnabled())
{
lua_pushboolean(luaVM, false);
return 1;
}
lua_pushboolean(luaVM, false);
return 1;
}

CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
if (pLuaMain)
{
CResource* pParentResource = pLuaMain->GetResource();
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
if (pLuaMain)
{
CResource* pParentResource = pLuaMain->GetResource();

CClientWebBrowser* pBrowserTexture =
g_pClientGame->GetManager()->GetRenderElementManager()->CreateWebBrowser((int)vecSize.fX, (int)vecSize.fY, bIsLocal, bTransparent);
if (pBrowserTexture)
{
// Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's ElementGroup? **
pBrowserTexture->SetParent(pParentResource->GetResourceDynamicEntity());
CClientWebBrowser* pBrowserTexture =
g_pClientGame->GetManager()->GetRenderElementManager()->CreateWebBrowser((int)vecSize.fX, (int)vecSize.fY, bIsLocal, bTransparent);
if (pBrowserTexture)
{
// Make it a child of the resource's file root ** CHECK Should parent be pFileResource, and element added to pParentResource's ElementGroup? **
pBrowserTexture->SetParent(pParentResource->GetResourceDynamicEntity());

// Set our owner resource
pBrowserTexture->SetResource(pParentResource);
}
lua_pushelement(luaVM, pBrowserTexture);
return 1;
// Set our owner resource
pBrowserTexture->SetResource(pParentResource);
}
lua_pushelement(luaVM, pBrowserTexture);
return 1;
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
Expand Down Expand Up @@ -255,28 +253,14 @@ int CLuaBrowserDefs::LoadBrowserURL(lua_State* luaVM)
lua_pushboolean(luaVM, pWebBrowser->LoadURL(strURL, !isLocalURL, strPostData, bURLEncoded));
return 1;
}

// Are we dealing with a local website? If so, parse resource path. Otherwise, return false and load nothing
// Todo: Add an ACL right which is necessary to load local websites or websites in general
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
if (pLuaMain)
else
{
SString strAbsPath;
CResource* pResource = pLuaMain->GetResource();
if (CResourceManager::ParseResourcePathInput(strURL, pResource, &strAbsPath) && pWebBrowser->IsLocal())
{
// Output deprecated warning, TODO: Remove this at a later point
m_pScriptDebugging->LogWarning(luaVM,
"This URL scheme is deprecated and may not work in future versions. Please consider using http://mta/* instead. "
"See https://wiki.mtasa.com/wiki/LoadBrowserURL for details");

lua_pushboolean(luaVM, pWebBrowser->LoadURL("mtalocal://" + strURL, false, strPostData, bURLEncoded));
return 1;
}
argStream.SetCustomError("Invalid URL scheme provided. Only http:// and https:// is supported.", "Invalid parameter");
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

if (argStream.HasErrors())
return luaL_error(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
Expand Down Expand Up @@ -920,7 +904,7 @@ int CLuaBrowserDefs::GUICreateBrowser(lua_State* luaVM)
}
else if (size.fX == 0 || size.fY == 0)
{
m_pScriptDebugging->LogWarning(luaVM, "A browser must be at least 1x1 in size. This warning may be an error in future versions.");
argStream.SetCustomError("A browser must be at least 1x1 in size.", "Invalid parameter");
}
}

Expand Down Expand Up @@ -951,7 +935,7 @@ int CLuaBrowserDefs::GUICreateBrowser(lua_State* luaVM)
}

if (argStream.HasErrors())
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
return luaL_error(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
Expand Down
4 changes: 1 addition & 3 deletions Server/mods/deathmatch/logic/CRemoteCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,10 @@ void CRemoteCall::DownloadFinishedCallback(const SHttpDownloadResult& result)
if (result.bSuccess)
{
if (pCall->IsFetch())
{
arguments.PushString(std::string(result.pData, result.dataSize));
arguments.PushNumber(0);
}
else
arguments.ReadFromJSONString(result.pData);
arguments.PushNumber(0);
}
else
{
Expand Down
10 changes: 6 additions & 4 deletions Server/mods/deathmatch/logic/CResourceChecker.Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace
{
//
// Minimum version requirments for functions/events
// Minimum version requirements for functions/events
//

struct SVersionItem
Expand Down Expand Up @@ -294,6 +294,7 @@ namespace
{"svgGetSize", "1.5.8-9.20979"},
{"svgSetDocumentXML", "1.5.8-9.20979"},
{"svgSetSize", "1.5.8-9.20979"},
{"generateKeyPair", "1.5.8-9.21055"},
{"getProcessMemoryStats", "1.5.8-9.21389"},
{"isCapsLockEnabled", "1.5.8-9.21313"},
{"isMTAWindowFocused", "1.5.8-9.21313"},
Expand Down Expand Up @@ -417,6 +418,7 @@ namespace
{"onResourceLoadStateChange", "1.5.8-9.20809"},
{"onElementInteriorChange", "1.5.8-9.20837"},
{"onPlayerResourceStart", "1.5.8-9.20957"},
{"generateKeyPair", "1.5.8-9.21055"},
{"getProcessMemoryStats", "1.5.8-9.21389"},

// Features added in 1.6.0
Expand Down Expand Up @@ -569,9 +571,9 @@ namespace
// Server ped jetpack
{true, "givePlayerJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
{true, "removePlayerJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
//{true, "givePedJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
//{true, "removePedJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
//{false, "doesPedHaveJetPack", "isPedWearingJetpack"},
{true, "givePedJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
{true, "removePedJetPack", "Replaced with setPedWearingJetpack. Refer to the wiki for details"},
{false, "doesPedHaveJetPack", "isPedWearingJetpack"},

// XML
{false, "xmlNodeGetSubNodes", "xmlNodeGetChildren"},
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CVehicleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ bool CVehicleManager::HasDoors(unsigned short usModel)
case VT_MOWER:
case VT_RCCAM:
case VT_RCGOBLIN:
case VT_BLOODRA:
break;
default:
bHasDoors = true;
Expand Down
20 changes: 9 additions & 11 deletions Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,17 +747,15 @@ bool CEntityAddPacket::Write(NetBitStreamInterface& BitStream) const
// Write the icon
SIntegerSync<unsigned char, 6> icon(pBlip->m_ucIcon);
BitStream.Write(&icon);
if (pBlip->m_ucIcon == 0)
{
// Write the size
SIntegerSync<unsigned char, 5> size(pBlip->m_ucSize);
BitStream.Write(&size);

// Write the color
SColorSync color;
color = pBlip->GetColor();
BitStream.Write(&color);
}

// Write the size
SIntegerSync<unsigned char, 5> size(pBlip->m_ucSize);
BitStream.Write(&size);

// Write the color
SColorSync color;
color = pBlip->GetColor();
BitStream.Write(&color);

break;
}
Expand Down
12 changes: 8 additions & 4 deletions Shared/sdk/CScriptArgReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class CScriptArgReader
// The string received may not actually be a number
if (!lua_isnumber(m_luaVM, m_iIndex))
{
SetCustomWarning("Expected number, got non-convertible string. This warning may be an error in future versions.");
SetCustomError("Expected number, got non-convertible string", "Bad argument");
return;
}

// Returns 0 even if the string cannot be parsed as a number
Expand All @@ -76,7 +77,8 @@ class CScriptArgReader
{
if (checkSign && number < -FLT_EPSILON)
{
SetCustomWarning("Expected positive value, got negative. This warning may be an error in future versions.");
SetCustomError("Expected positive value, got negative", "Bad argument");
return;
}
outValue = static_cast<T>(static_cast<int64_t>(number));
return;
Expand All @@ -103,7 +105,8 @@ class CScriptArgReader
// The string received may not actually be a number
if (!lua_isnumber(m_luaVM, m_iIndex))
{
SetCustomWarning("Expected number, got non-convertible string. This warning may be an error in future versions.");
SetCustomError("Expected number, got non-convertible string", "Bad argument");
return;
}

// Returns 0 even if the string cannot be parsed as a number
Expand All @@ -118,7 +121,8 @@ class CScriptArgReader

if (checkSign && std::is_unsigned<T>() && number < -FLT_EPSILON)
{
SetCustomWarning("Expected positive value, got negative. This warning may be an error in future versions.");
SetCustomError("Expected positive value, got negative", "Bad argument");
return;
}

outValue = static_cast<T>(number);
Expand Down

0 comments on commit 7b627e9

Please sign in to comment.