From 185f90da58430c51d3fd56bf68ae391614bc2442 Mon Sep 17 00:00:00 2001 From: Andrettin <6322423+Andrettin@users.noreply.github.com> Date: Tue, 10 Nov 2020 17:57:37 +0100 Subject: [PATCH] Reset the saved order, new order and critical order of a unit when releasing it, fixing a unit reference count error --- src/unit/unit.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index ef3cb53b7..3d2d64211 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -538,6 +538,19 @@ void CUnit::Release(bool final) } Orders.clear(); + if (SavedOrder != NULL) { + delete SavedOrder; + SavedOrder = NULL; + } + if (NewOrder != NULL) { + delete NewOrder; + NewOrder = NULL; + } + if (CriticalOrder != NULL) { + delete CriticalOrder; + CriticalOrder = NULL; + } + // Remove the unit from the global units table. UnitManager.ReleaseUnit(this); }