From 792aa781f215349281708594ae3255f3286e6204 Mon Sep 17 00:00:00 2001 From: TheGondos <103931250+TheGondos@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:10:52 +0100 Subject: [PATCH] Fix unchecked thruster level (#513) * Fix unchecked thruster level * [D3D9]Fix missing include * [Lua]Add XRSound assets dependency --- Src/Orbiter/Vessel.cpp | 1 + Src/Orbiter/Vessel.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Src/Orbiter/Vessel.cpp b/Src/Orbiter/Vessel.cpp index f1555c64d..71354e6f2 100644 --- a/Src/Orbiter/Vessel.cpp +++ b/Src/Orbiter/Vessel.cpp @@ -8297,6 +8297,7 @@ void VESSEL::IncThrusterLevel (THRUSTER_HANDLE th, double dlevel) const if (vessel->bFRplayback) return; ThrustSpec *ts = (ThrustSpec*)th; ts->level_permanent += dlevel; + ts->level_permanent = max (0.0, min (1.0, ts->level_permanent)); if (ts->tank && ts->tank->mass) ts->level = max (0.0, min (1.0, ts->level_permanent + ts->level_override)); } diff --git a/Src/Orbiter/Vessel.h b/Src/Orbiter/Vessel.h index 01b61fef1..f8189a394 100644 --- a/Src/Orbiter/Vessel.h +++ b/Src/Orbiter/Vessel.h @@ -443,6 +443,7 @@ class Vessel: public VesselBase { { if (!bFRplayback) { ts->level_permanent += dlevel; + ts->level_permanent = std::max(0.0, std::min(1.0, ts->level_permanent)); if (ts->tank && ts->tank->mass) ts->level = std::max(0.0, std::min(1.0, ts->level+dlevel)); }