@@ -29,61 +29,46 @@ function MiscVehicle:Init()
2929 self .m_entity :AddMemoryPatch ({
3030 name = self .m_entity .MemoryPatches .Turbulence ,
3131 onEnable = function (patch )
32- if (not self .m_entity :IsPlane ()) then
33- error (" Invalid vehicle type!" )
34- return
35- end
32+ if (not self .m_entity :IsPlane ()) then return end
3633
3734 --- @type CFlyingHandlingData
3835 local handingdata = self .m_entity :GetHandlingData ()
39- if (not handingdata ) then
40- error (" Handling data is null!" )
41- end
36+ if (not handingdata ) then return end
4237
43- local fturbulence = handingdata .m_turbulence_force_mult
44- if (fturbulence :is_null ()) then
45- error (" Pointer is null!" )
46- end
38+ local fTurbulence = handingdata .m_turbulence_force_mult
39+ if (fTurbulence :is_null ()) then return end
4740
4841 patch .m_state = {
49- ptr = fturbulence ,
50- default_value = fturbulence :get_float ()
42+ ptr = fTurbulence ,
43+ default_value = fTurbulence :get_float ()
5144 }
5245
53- fturbulence :set_float (0.0 )
46+ fTurbulence :set_float (0.0 )
5447 end ,
5548 onDisable = function (patch )
5649 if (not patch .m_state or patch .m_state .default_value == nil ) then
5750 return
5851 end
5952
6053 local ptr = patch .m_state .ptr
61- if (not ptr or ptr :is_null ()) then
62- error (" Pointer is null" )
63- end
64-
54+ if (not ptr or ptr :is_null ()) then return end
6555 ptr :set_float (patch .m_state .default_value )
6656 end
6757 })
6858
6959 self .m_entity :AddMemoryPatch ({
7060 name = self .m_entity .MemoryPatches .WindMult ,
7161 onEnable = function (patch )
72- if (not self .m_entity :IsPlane ()) then
73- error (" Invalid vehicle type!" )
74- return
75- end
62+ if (not self .m_entity :IsPlane ()) then return end
7663
77- --- @type CFlyingHandlingData
64+ --- @type CFlyingHandlingData ?
7865 local handingdata = self .m_entity :GetHandlingData ()
79- if (not handingdata ) then
80- error ( " Handling data is null! " )
66+ if (not handingdata or not handingdata : IsValid () ) then
67+ return
8168 end
8269
8370 local fwindForce = handingdata .m_wind_force_mult
84- if (fwindForce :is_null ()) then
85- error (" Pointer is null!" )
86- end
71+ if (fwindForce :is_null ()) then return end
8772
8873 patch .m_state = {
8974 ptr = fwindForce ,
@@ -98,10 +83,7 @@ function MiscVehicle:Init()
9883 end
9984
10085 local ptr = patch .m_state .ptr
101- if (not ptr or ptr :is_null ()) then
102- error (" Pointer is null" )
103- end
104-
86+ if (not ptr or ptr :is_null ()) then return end
10587 ptr :set_float (patch .m_state .default_value )
10688 end
10789 })
0 commit comments