Skip to content

Commit b1fc0ad

Browse files
author
G_Moris
committed
Update 2
1 parent 03121b8 commit b1fc0ad

File tree

2 files changed

+63
-41
lines changed

2 files changed

+63
-41
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,26 @@ CGameSA::CGameSA()
245245
CVehicleSA::StaticSetHooks();
246246
CCheckpointSA::StaticSetHooks();
247247
}
248-
catch (...)
248+
catch (const std::bad_alloc& e)
249249
{
250-
MessageBoxUTF8(nullptr, _("Failed initialization game_sa"), _("Error"), MB_ICONERROR | MB_OK);
250+
std::string error = _("Failed initialization game_sa");
251+
error += "\n";
252+
error += _("Memory allocations failed");
253+
error += ": ";
254+
error += e.what();
255+
256+
MessageBoxUTF8(nullptr, error.c_str(), _("Error"), MB_ICONERROR | MB_OK);
257+
ExitProcess(EXIT_FAILURE);
258+
}
259+
catch (const std::exception& e)
260+
{
261+
std::string error = _("Failed initialization game_sa");
262+
error += "\n";
263+
error += _("Information");
264+
error += ": ";
265+
error += e.what();
266+
267+
MessageBoxUTF8(nullptr, error, _("Error"), MB_ICONERROR | MB_OK);
251268
ExitProcess(EXIT_FAILURE);
252269
}
253270
}

Server/mods/deathmatch/logic/luadefs/CLuaHandlingDefs.cpp

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -402,50 +402,55 @@ int CLuaHandlingDefs::GetVehicleHandling(lua_State* luaVM)
402402
SString strProperty;
403403
argStream.ReadString(strProperty);
404404

405+
bool bResult = true;
405406
eHandlingProperty eProperty = m_pHandlingManager->GetPropertyEnumFromName(strProperty);
406-
if (eProperty == HANDLING_MAX)
407+
if (eProperty != HANDLING_MAX)
407408
{
408-
argStream.SetCustomError("Invalid property");
409-
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
410-
lua_pushboolean(luaVM, false);
411-
return 1;
412-
}
413-
414-
float fValue = 0.0f;
415-
CVector vecValue = CVector(0.0f, 0.0f, 0.0f);
416-
SString strValue = "";
417-
unsigned int uiValue = 0;
418-
unsigned char ucValue = 0;
419-
if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, fValue))
420-
{
421-
lua_pushnumber(luaVM, fValue);
422-
}
423-
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, uiValue))
424-
{
425-
lua_pushnumber(luaVM, uiValue);
426-
}
427-
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, ucValue))
428-
{
429-
lua_pushnumber(luaVM, ucValue);
430-
}
431-
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, strValue))
432-
{
433-
lua_pushstring(luaVM, strValue);
409+
float fValue = 0.0f;
410+
CVector vecValue = CVector(0.0f, 0.0f, 0.0f);
411+
SString strValue = "";
412+
unsigned int uiValue = 0;
413+
unsigned char ucValue = 0;
414+
if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, fValue))
415+
{
416+
lua_pushnumber(luaVM, fValue);
417+
}
418+
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, uiValue))
419+
{
420+
lua_pushnumber(luaVM, uiValue);
421+
}
422+
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, ucValue))
423+
{
424+
lua_pushnumber(luaVM, ucValue);
425+
}
426+
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, strValue))
427+
{
428+
lua_pushstring(luaVM, strValue);
429+
}
430+
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, vecValue))
431+
{
432+
lua_createtable(luaVM, 3, 0);
433+
lua_pushnumber(luaVM, 1);
434+
lua_pushnumber(luaVM, vecValue.fX);
435+
lua_settable(luaVM, -3);
436+
lua_pushnumber(luaVM, 2);
437+
lua_pushnumber(luaVM, vecValue.fY);
438+
lua_settable(luaVM, -3);
439+
lua_pushnumber(luaVM, 3);
440+
lua_pushnumber(luaVM, vecValue.fZ);
441+
lua_settable(luaVM, -3);
442+
}
443+
else
444+
{
445+
bResult = false;
446+
}
434447
}
435-
else if (CStaticFunctionDefinitions::GetVehicleHandling(pVehicle, eProperty, vecValue))
448+
else
436449
{
437-
lua_createtable(luaVM, 3, 0);
438-
lua_pushnumber(luaVM, 1);
439-
lua_pushnumber(luaVM, vecValue.fX);
440-
lua_settable(luaVM, -3);
441-
lua_pushnumber(luaVM, 2);
442-
lua_pushnumber(luaVM, vecValue.fY);
443-
lua_settable(luaVM, -3);
444-
lua_pushnumber(luaVM, 3);
445-
lua_pushnumber(luaVM, vecValue.fZ);
446-
lua_settable(luaVM, -3);
450+
bResult = false;
447451
}
448-
else
452+
453+
if (!bResult)
449454
{
450455
argStream.SetCustomError("Invalid property");
451456
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

0 commit comments

Comments
 (0)