Browse Source

Fix console spam when disabling commands feature

feature_improvement
Anton Tarasenko 2 years ago
parent
commit
8d863f9b88
  1. 26
      sources/Commands/ACommandFeature.uc
  2. 1
      sources/Futility_Feature.uc

26
sources/Commands/ACommandFeature.uc

@ -168,6 +168,7 @@ protected function DisableFeature(EPlayer callerPlayer, Text featureName)
local Text playerName; local Text playerName;
local Text featureRealName; local Text featureRealName;
local class<Feature> featureClass; local class<Feature> featureClass;
featureClass = LoadFeatureClass(featureName); featureClass = LoadFeatureClass(featureName);
if (featureClass == none) return; if (featureClass == none) return;
if (callerPlayer == none) return; if (callerPlayer == none) return;
@ -185,15 +186,22 @@ protected function DisableFeature(EPlayer callerPlayer, Text featureName)
return; return;
} }
featureClass.static.DisableMe(); featureClass.static.DisableMe();
callerConsole // It is possible that this command itself is destroyed after above command
.Write(P("Feature ")) // so do the check just in case
.UseColorOnce(_.color.TextEmphasis).Write(featureRealName) if (IsAllocated())
.WriteLine(F(" is {$TextNegative disabled}")); {
othersConsole callerConsole
.Write(playerName).Write(F(" {$TextNegative disabled} feature ")) .Write(P("Feature "))
.UseColorOnce(_.color.TextEmphasis).WriteLine(featureRealName); .UseColorOnce(_.color.TextEmphasis).Write(featureRealName)
_.memory.Free(featureRealName); .WriteLine(F(" is {$TextNegative disabled}"));
_.memory.Free(playerName); 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<Feature> LoadFeatureClass(BaseText featureName) protected function class<Feature> LoadFeatureClass(BaseText featureName)

1
sources/Futility_Feature.uc

@ -45,6 +45,7 @@ protected function OnDisabled()
{ {
local int i; local int i;
local Commands_Feature commandsFeature; local Commands_Feature commandsFeature;
_.environment.OnFeatureEnabled(self).Disconnect();
commandsFeature = commandsFeature =
Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance()); Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (commandsFeature == none) { if (commandsFeature == none) {

Loading…
Cancel
Save