From 3969eb3824190900d341c73e762d9b92d115005d Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Wed, 8 Apr 2020 01:49:17 +0700 Subject: [PATCH] Refactor `Feature` Make events functions `OnEnabled()` and `OnEnabled()` protected rather than public. Move initialization and clean up logic into `OnCreated()` and `OnDestroyed()` event functions. --- sources/Features/FixAmmoSelling/FixAmmoSelling.uc | 4 ++-- sources/Features/FixDoshSpam/FixDoshSpam.uc | 4 ++-- sources/Features/FixDualiesCost/FixDualiesCost.uc | 4 ++-- sources/Features/FixFFHack/FixFFHack.uc | 4 ++-- sources/Features/FixInfiniteNades/FixInfiniteNades.uc | 4 ++-- sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc | 4 ++-- sources/Features/FixZedTimeLags/FixZedTimeLags.uc | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sources/Features/FixAmmoSelling/FixAmmoSelling.uc b/sources/Features/FixAmmoSelling/FixAmmoSelling.uc index e078a58..88f4541 100644 --- a/sources/Features/FixAmmoSelling/FixAmmoSelling.uc +++ b/sources/Features/FixAmmoSelling/FixAmmoSelling.uc @@ -133,7 +133,7 @@ struct WeaponRecord // All weapons we've detected so far. var private array registeredWeapons; -public function OnEnabled() +protected function OnEnabled() { local KFWeapon nextWeapon; local KFAmmoPickup nextPickup; @@ -149,7 +149,7 @@ public function OnEnabled() } } -public function OnDisabled() +protected function OnDisabled() { local int i; local AmmoPickupStalker nextStalker; diff --git a/sources/Features/FixDoshSpam/FixDoshSpam.uc b/sources/Features/FixDoshSpam/FixDoshSpam.uc index eecf2f3..ea298a0 100644 --- a/sources/Features/FixDoshSpam/FixDoshSpam.uc +++ b/sources/Features/FixDoshSpam/FixDoshSpam.uc @@ -89,7 +89,7 @@ var private array currentContributors; // Wads of cash that are lying around on the map. var private array wads; -public function OnEnabled() +protected function OnEnabled() { local CashPickup nextCash; // Find all wads of cash laying around on the map, @@ -100,7 +100,7 @@ public function OnEnabled() } } -public function OnDisabled() +protected function OnDisabled() { wads.length = 0; currentContributors.length = 0; diff --git a/sources/Features/FixDualiesCost/FixDualiesCost.uc b/sources/Features/FixDualiesCost/FixDualiesCost.uc index 2fd3822..639a689 100644 --- a/sources/Features/FixDualiesCost/FixDualiesCost.uc +++ b/sources/Features/FixDualiesCost/FixDualiesCost.uc @@ -145,7 +145,7 @@ var private const array storedValues; // Sell value of the last seen pickup in 'OverridePickupQuery' var private int nextSellValue; -public function OnEnabled() +protected function OnEnabled() { local KFWeapon nextWeapon; // Find all frags, that spawned when this fix wasn't running. @@ -156,7 +156,7 @@ public function OnEnabled() level.game.AddGameModifier(Spawn(class'DualiesCostRule')); } -public function OnDisabled() +protected function OnDisabled() { local GameRules rulesIter; local DualiesCostRule ruleToDestroy; diff --git a/sources/Features/FixFFHack/FixFFHack.uc b/sources/Features/FixFFHack/FixFFHack.uc index 33ad62a..ed38c9f 100644 --- a/sources/Features/FixFFHack/FixFFHack.uc +++ b/sources/Features/FixFFHack/FixFFHack.uc @@ -56,12 +56,12 @@ var private config const array< class > alwaysScale; // Damage types, for which we should never reapply friendly fire scaling. var private config const array< class > neverScale; -public function OnEnabled() +protected function OnEnabled() { level.game.AddGameModifier(Spawn(class'FFHackRule')); } -public function OnDisabled() +protected function OnDisabled() { local GameRules rulesIter; local FFHackRule ruleToDestroy; diff --git a/sources/Features/FixInfiniteNades/FixInfiniteNades.uc b/sources/Features/FixInfiniteNades/FixInfiniteNades.uc index bec784f..53e0e8a 100644 --- a/sources/Features/FixInfiniteNades/FixInfiniteNades.uc +++ b/sources/Features/FixInfiniteNades/FixInfiniteNades.uc @@ -58,7 +58,7 @@ struct FragAmmoRecord }; var private array ammoRecords; -public function OnEnabled() +protected function OnEnabled() { local Frag nextFrag; // Find all frags, that spawned when this fix wasn't running. @@ -69,7 +69,7 @@ public function OnEnabled() RecreateFrags(); } -public function OnDisabled() +protected function OnDisabled() { RecreateFrags(); ammoRecords.length = 0; diff --git a/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc b/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc index 4881386..e7146fd 100644 --- a/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc +++ b/sources/Features/FixInventoryAbuse/FixInventoryAbuse.uc @@ -44,7 +44,7 @@ struct DualiesPair // It's made configurable in case of custom dual weapons. var private config const array dualiesClasses; -public function OnEnabled() +protected function OnEnabled() { local float actualInterval; actualInterval = checkInterval; @@ -55,7 +55,7 @@ public function OnEnabled() SetTimer(actualInterval, true); } -public function OnDisabled() +protected function OnDisabled() { SetTimer(0.0f, false); } diff --git a/sources/Features/FixZedTimeLags/FixZedTimeLags.uc b/sources/Features/FixZedTimeLags/FixZedTimeLags.uc index 61e1092..5ec9fcd 100644 --- a/sources/Features/FixZedTimeLags/FixZedTimeLags.uc +++ b/sources/Features/FixZedTimeLags/FixZedTimeLags.uc @@ -65,7 +65,7 @@ var private float updateCooldown; // Recorded game type, to avoid constant conversions every tick var private KFGameType gameType; -public function OnEnabled() +protected function OnEnabled() { gameType = KFGameType(level.game); if (gameType == none) @@ -78,7 +78,7 @@ public function OnEnabled() } } -public function OnDisabled() +protected function OnDisabled() { gameType = KFGameType(level.game); if (gameType != none && disableTick)