diff --git a/sources/Commands/ACommandFeature.uc b/sources/Commands/ACommandFeature.uc index 15cd55f..ab7fe96 100644 --- a/sources/Commands/ACommandFeature.uc +++ b/sources/Commands/ACommandFeature.uc @@ -168,6 +168,7 @@ protected function DisableFeature(EPlayer callerPlayer, Text featureName) local Text playerName; local Text featureRealName; local class featureClass; + featureClass = LoadFeatureClass(featureName); if (featureClass == none) return; if (callerPlayer == none) return; @@ -185,15 +186,22 @@ protected function DisableFeature(EPlayer callerPlayer, Text featureName) return; } featureClass.static.DisableMe(); - callerConsole - .Write(P("Feature ")) - .UseColorOnce(_.color.TextEmphasis).Write(featureRealName) - .WriteLine(F(" is {$TextNegative disabled}")); - othersConsole - .Write(playerName).Write(F(" {$TextNegative disabled} feature ")) - .UseColorOnce(_.color.TextEmphasis).WriteLine(featureRealName); - _.memory.Free(featureRealName); - _.memory.Free(playerName); + // It is possible that this command itself is destroyed after above command + // so do the check just in case + if (IsAllocated()) + { + callerConsole + .Write(P("Feature ")) + .UseColorOnce(_.color.TextEmphasis).Write(featureRealName) + .WriteLine(F(" is {$TextNegative disabled}")); + othersConsole + .Write(playerName) + .Write(F(" {$TextNegative disabled} feature ")) + .UseColorOnce(_.color.TextEmphasis).WriteLine(featureRealName); + } + // `_` might be gone here + __().memory.Free(featureRealName); + __().memory.Free(playerName); } protected function class LoadFeatureClass(BaseText featureName) diff --git a/sources/Futility_Feature.uc b/sources/Futility_Feature.uc index 235063f..3d51d9e 100644 --- a/sources/Futility_Feature.uc +++ b/sources/Futility_Feature.uc @@ -45,6 +45,7 @@ protected function OnDisabled() { local int i; local Commands_Feature commandsFeature; + _.environment.OnFeatureEnabled(self).Disconnect(); commandsFeature = Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance()); if (commandsFeature == none) {