@@ -2733,156 +2733,149 @@ int CLuaVehicleDefs::GetVehicleHandling(lua_State* luaVM)
27332733 return 1 ;
27342734 }
27352735
2736- if (const auto * const entry = pVehicle->GetHandlingData ())
2737- {
2738- lua_newtable (luaVM);
2736+ const auto * const entry = pVehicle->GetHandlingData ();
27392737
2740- lua_pushnumber (luaVM, entry->GetMass ());
2741- lua_setfield (luaVM, -2 , " mass" );
2742-
2743- lua_pushnumber (luaVM, entry->GetTurnMass ());
2744- lua_setfield (luaVM, -2 , " turnMass" );
2745-
2746- lua_pushnumber (luaVM, entry->GetDragCoeff ());
2747- lua_setfield (luaVM, -2 , " dragCoeff" );
2748-
2749- lua_createtable (luaVM, 3 , 0 );
2750- CVector vecCenter = entry->GetCenterOfMass ();
2751- lua_pushnumber (luaVM, 1 );
2752- lua_pushnumber (luaVM, vecCenter.fX );
2753- lua_settable (luaVM, -3 );
2754- lua_pushnumber (luaVM, 2 );
2755- lua_pushnumber (luaVM, vecCenter.fY );
2756- lua_settable (luaVM, -3 );
2757- lua_pushnumber (luaVM, 3 );
2758- lua_pushnumber (luaVM, vecCenter.fZ );
2759- lua_settable (luaVM, -3 );
2760- lua_setfield (luaVM, -2 , " centerOfMass" );
2761-
2762- lua_pushnumber (luaVM, entry->GetPercentSubmerged ());
2763- lua_setfield (luaVM, -2 , " percentSubmerged" );
2764-
2765- lua_pushnumber (luaVM, entry->GetTractionMultiplier ());
2766- lua_setfield (luaVM, -2 , " tractionMultiplier" );
2767-
2768- CHandlingEntry::eDriveType eDriveType = entry->GetCarDriveType ();
2769- if (eDriveType == CHandlingEntry::FWD)
2770- lua_pushstring (luaVM, " fwd" );
2771- else if (eDriveType == CHandlingEntry::RWD)
2772- lua_pushstring (luaVM, " rwd" );
2773- else if (eDriveType == CHandlingEntry::FOURWHEEL)
2774- lua_pushstring (luaVM, " awd" );
2775- else // What the ... (yeah, security)
2776- lua_pushnil (luaVM);
2777- lua_setfield (luaVM, -2 , " driveType" );
2778- CHandlingEntry::eEngineType eEngineType = entry->GetCarEngineType ();
2779- if (eEngineType == CHandlingEntry::PETROL)
2780- lua_pushstring (luaVM, " petrol" );
2781- else if (eEngineType == CHandlingEntry::DIESEL)
2782- lua_pushstring (luaVM, " diesel" );
2783- else if (eEngineType == CHandlingEntry::ELECTRIC)
2784- lua_pushstring (luaVM, " electric" );
2785- else
2786- lua_pushnil (luaVM);
2787- lua_setfield (luaVM, -2 , " engineType" );
2738+ lua_newtable (luaVM);
27882739
2789- lua_pushnumber (luaVM, entry->GetNumberOfGears ());
2790- lua_setfield (luaVM, -2 , " numberOfGears" );
2740+ lua_pushnumber (luaVM, entry->GetMass ());
2741+ lua_setfield (luaVM, -2 , " mass" );
2742+
2743+ lua_pushnumber (luaVM, entry->GetTurnMass ());
2744+ lua_setfield (luaVM, -2 , " turnMass" );
2745+
2746+ lua_pushnumber (luaVM, entry->GetDragCoeff ());
2747+ lua_setfield (luaVM, -2 , " dragCoeff" );
2748+
2749+ lua_createtable (luaVM, 3 , 0 );
2750+ CVector vecCenter = entry->GetCenterOfMass ();
2751+ lua_pushnumber (luaVM, 1 );
2752+ lua_pushnumber (luaVM, vecCenter.fX );
2753+ lua_settable (luaVM, -3 );
2754+ lua_pushnumber (luaVM, 2 );
2755+ lua_pushnumber (luaVM, vecCenter.fY );
2756+ lua_settable (luaVM, -3 );
2757+ lua_pushnumber (luaVM, 3 );
2758+ lua_pushnumber (luaVM, vecCenter.fZ );
2759+ lua_settable (luaVM, -3 );
2760+ lua_setfield (luaVM, -2 , " centerOfMass" );
2761+
2762+ lua_pushnumber (luaVM, entry->GetPercentSubmerged ());
2763+ lua_setfield (luaVM, -2 , " percentSubmerged" );
2764+
2765+ lua_pushnumber (luaVM, entry->GetTractionMultiplier ());
2766+ lua_setfield (luaVM, -2 , " tractionMultiplier" );
2767+
2768+ CHandlingEntry::eDriveType eDriveType = entry->GetCarDriveType ();
2769+ if (eDriveType == CHandlingEntry::FWD)
2770+ lua_pushstring (luaVM, " fwd" );
2771+ else if (eDriveType == CHandlingEntry::RWD)
2772+ lua_pushstring (luaVM, " rwd" );
2773+ else if (eDriveType == CHandlingEntry::FOURWHEEL)
2774+ lua_pushstring (luaVM, " awd" );
2775+ else // What the ... (yeah, security)
2776+ lua_pushnil (luaVM);
2777+ lua_setfield (luaVM, -2 , " driveType" );
2778+ CHandlingEntry::eEngineType eEngineType = entry->GetCarEngineType ();
2779+ if (eEngineType == CHandlingEntry::PETROL)
2780+ lua_pushstring (luaVM, " petrol" );
2781+ else if (eEngineType == CHandlingEntry::DIESEL)
2782+ lua_pushstring (luaVM, " diesel" );
2783+ else if (eEngineType == CHandlingEntry::ELECTRIC)
2784+ lua_pushstring (luaVM, " electric" );
2785+ else
2786+ lua_pushnil (luaVM);
2787+ lua_setfield (luaVM, -2 , " engineType" );
27912788
2792- lua_pushnumber (luaVM, entry->GetEngineAcceleration ());
2793- lua_setfield (luaVM, -2 , " engineAcceleration " );
2789+ lua_pushnumber (luaVM, entry->GetNumberOfGears ());
2790+ lua_setfield (luaVM, -2 , " numberOfGears " );
27942791
2795- lua_pushnumber (luaVM, entry->GetEngineInertia ());
2796- lua_setfield (luaVM, -2 , " engineInertia " );
2792+ lua_pushnumber (luaVM, entry->GetEngineAcceleration ());
2793+ lua_setfield (luaVM, -2 , " engineAcceleration " );
27972794
2798- lua_pushnumber (luaVM, entry->GetMaxVelocity ());
2799- lua_setfield (luaVM, -2 , " maxVelocity " );
2795+ lua_pushnumber (luaVM, entry->GetEngineInertia ());
2796+ lua_setfield (luaVM, -2 , " engineInertia " );
28002797
2801- lua_pushnumber (luaVM, entry->GetBrakeDeceleration ());
2802- lua_setfield (luaVM, -2 , " brakeDeceleration " );
2798+ lua_pushnumber (luaVM, entry->GetMaxVelocity ());
2799+ lua_setfield (luaVM, -2 , " maxVelocity " );
28032800
2804- lua_pushnumber (luaVM, entry->GetBrakeBias ());
2805- lua_setfield (luaVM, -2 , " brakeBias " );
2801+ lua_pushnumber (luaVM, entry->GetBrakeDeceleration ());
2802+ lua_setfield (luaVM, -2 , " brakeDeceleration " );
28062803
2807- lua_pushboolean (luaVM, entry->GetABS ());
2808- lua_setfield (luaVM, -2 , " ABS " );
2804+ lua_pushnumber (luaVM, entry->GetBrakeBias ());
2805+ lua_setfield (luaVM, -2 , " brakeBias " );
28092806
2810- lua_pushnumber (luaVM, entry->GetSteeringLock ());
2811- lua_setfield (luaVM, -2 , " steeringLock " );
2807+ lua_pushboolean (luaVM, entry->GetABS ());
2808+ lua_setfield (luaVM, -2 , " ABS " );
28122809
2813- lua_pushnumber (luaVM, entry->GetTractionLoss ());
2814- lua_setfield (luaVM, -2 , " tractionLoss " );
2810+ lua_pushnumber (luaVM, entry->GetSteeringLock ());
2811+ lua_setfield (luaVM, -2 , " steeringLock " );
28152812
2816- lua_pushnumber (luaVM, entry->GetTractionBias ());
2817- lua_setfield (luaVM, -2 , " tractionBias " );
2813+ lua_pushnumber (luaVM, entry->GetTractionLoss ());
2814+ lua_setfield (luaVM, -2 , " tractionLoss " );
28182815
2819- lua_pushnumber (luaVM, entry->GetSuspensionForceLevel ());
2820- lua_setfield (luaVM, -2 , " suspensionForceLevel " );
2816+ lua_pushnumber (luaVM, entry->GetTractionBias ());
2817+ lua_setfield (luaVM, -2 , " tractionBias " );
28212818
2822- lua_pushnumber (luaVM, entry->GetSuspensionDamping ());
2823- lua_setfield (luaVM, -2 , " suspensionDamping " );
2819+ lua_pushnumber (luaVM, entry->GetSuspensionForceLevel ());
2820+ lua_setfield (luaVM, -2 , " suspensionForceLevel " );
28242821
2825- lua_pushnumber (luaVM, entry->GetSuspensionHighSpeedDamping ());
2826- lua_setfield (luaVM, -2 , " suspensionHighSpeedDamping " );
2822+ lua_pushnumber (luaVM, entry->GetSuspensionDamping ());
2823+ lua_setfield (luaVM, -2 , " suspensionDamping " );
28272824
2828- lua_pushnumber (luaVM, entry->GetSuspensionUpperLimit ());
2829- lua_setfield (luaVM, -2 , " suspensionUpperLimit " );
2825+ lua_pushnumber (luaVM, entry->GetSuspensionHighSpeedDamping ());
2826+ lua_setfield (luaVM, -2 , " suspensionHighSpeedDamping " );
28302827
2831- lua_pushnumber (luaVM, entry->GetSuspensionLowerLimit ());
2832- lua_setfield (luaVM, -2 , " suspensionLowerLimit " );
2828+ lua_pushnumber (luaVM, entry->GetSuspensionUpperLimit ());
2829+ lua_setfield (luaVM, -2 , " suspensionUpperLimit " );
28332830
2834- lua_pushnumber (luaVM, entry->GetSuspensionFrontRearBias ());
2835- lua_setfield (luaVM, -2 , " suspensionFrontRearBias " );
2831+ lua_pushnumber (luaVM, entry->GetSuspensionLowerLimit ());
2832+ lua_setfield (luaVM, -2 , " suspensionLowerLimit " );
28362833
2837- lua_pushnumber (luaVM, entry->GetSuspensionAntiDiveMultiplier ());
2838- lua_setfield (luaVM, -2 , " suspensionAntiDiveMultiplier " );
2834+ lua_pushnumber (luaVM, entry->GetSuspensionFrontRearBias ());
2835+ lua_setfield (luaVM, -2 , " suspensionFrontRearBias " );
28392836
2840- lua_pushnumber (luaVM, entry->GetCollisionDamageMultiplier ());
2841- lua_setfield (luaVM, -2 , " collisionDamageMultiplier " );
2837+ lua_pushnumber (luaVM, entry->GetSuspensionAntiDiveMultiplier ());
2838+ lua_setfield (luaVM, -2 , " suspensionAntiDiveMultiplier " );
28422839
2843- lua_pushnumber (luaVM, entry->GetSeatOffsetDistance ());
2844- lua_setfield (luaVM, -2 , " seatOffsetDistance " );
2840+ lua_pushnumber (luaVM, entry->GetCollisionDamageMultiplier ());
2841+ lua_setfield (luaVM, -2 , " collisionDamageMultiplier " );
28452842
2846- lua_pushnumber (luaVM, entry->GetHandlingFlags ());
2847- lua_setfield (luaVM, -2 , " handlingFlags " );
2843+ lua_pushnumber (luaVM, entry->GetSeatOffsetDistance ());
2844+ lua_setfield (luaVM, -2 , " seatOffsetDistance " );
28482845
2849- lua_pushnumber (luaVM, entry->GetModelFlags ());
2850- lua_setfield (luaVM, -2 , " modelFlags " );
2846+ lua_pushnumber (luaVM, entry->GetHandlingFlags ());
2847+ lua_setfield (luaVM, -2 , " handlingFlags " );
28512848
2852- lua_pushnumber (luaVM, entry->GetMonetary ());
2853- lua_setfield (luaVM, -2 , " monetary " );
2849+ lua_pushnumber (luaVM, entry->GetModelFlags ());
2850+ lua_setfield (luaVM, -2 , " modelFlags " );
28542851
2855- CHandlingEntry::eLightType eHeadType = entry->GetHeadLight ();
2856- if (eHeadType == CHandlingEntry::LONG)
2857- lua_pushstring (luaVM, " long" );
2858- else if (eHeadType == CHandlingEntry::SMALL)
2859- lua_pushstring (luaVM, " small" );
2860- else if (eHeadType == CHandlingEntry::BIG)
2861- lua_pushstring (luaVM, " big" );
2862- else
2863- lua_pushnil (luaVM);
2864- lua_setfield (luaVM, -2 , " headLight" );
2865-
2866- CHandlingEntry::eLightType eTailType = entry->GetTailLight ();
2867- if (eTailType == CHandlingEntry::LONG)
2868- lua_pushstring (luaVM, " long" );
2869- else if (eTailType == CHandlingEntry::SMALL)
2870- lua_pushstring (luaVM, " small" );
2871- else if (eTailType == CHandlingEntry::BIG)
2872- lua_pushstring (luaVM, " big" );
2873- else
2874- lua_pushnil (luaVM);
2875- lua_setfield (luaVM, -2 , " tailLight" );
2852+ lua_pushnumber (luaVM, entry->GetMonetary ());
2853+ lua_setfield (luaVM, -2 , " monetary" );
28762854
2877- lua_pushnumber (luaVM, entry->GetAnimGroup ());
2878- lua_setfield (luaVM, -2 , " animGroup" );
2879- }
2855+ CHandlingEntry::eLightType eHeadType = entry->GetHeadLight ();
2856+ if (eHeadType == CHandlingEntry::LONG)
2857+ lua_pushstring (luaVM, " long" );
2858+ else if (eHeadType == CHandlingEntry::SMALL)
2859+ lua_pushstring (luaVM, " small" );
2860+ else if (eHeadType == CHandlingEntry::BIG)
2861+ lua_pushstring (luaVM, " big" );
28802862 else
2881- {
2882- argStream.SetCustomError (" Invalid handling data" );
2883- m_pScriptDebugging->LogCustom (luaVM, argStream.GetFullErrorMessage ());
2884- lua_pushboolean (luaVM, false );
2885- }
2863+ lua_pushnil (luaVM);
2864+ lua_setfield (luaVM, -2 , " headLight" );
2865+
2866+ CHandlingEntry::eLightType eTailType = entry->GetTailLight ();
2867+ if (eTailType == CHandlingEntry::LONG)
2868+ lua_pushstring (luaVM, " long" );
2869+ else if (eTailType == CHandlingEntry::SMALL)
2870+ lua_pushstring (luaVM, " small" );
2871+ else if (eTailType == CHandlingEntry::BIG)
2872+ lua_pushstring (luaVM, " big" );
2873+ else
2874+ lua_pushnil (luaVM);
2875+ lua_setfield (luaVM, -2 , " tailLight" );
2876+
2877+ lua_pushnumber (luaVM, entry->GetAnimGroup ());
2878+ lua_setfield (luaVM, -2 , " animGroup" );
28862879 return 1 ;
28872880 }
28882881 else
@@ -3014,6 +3007,7 @@ int CLuaVehicleDefs::GetOriginalHandling(lua_State* luaVM)
30143007 lua_setfield (luaVM, -2 , " tailLight" );
30153008 lua_pushnumber (luaVM, entry->GetAnimGroup ());
30163009 lua_setfield (luaVM, -2 , " animGroup" );
3010+
30173011 return 1 ;
30183012 }
30193013 else
0 commit comments