Browse Source

Add Feature aliases

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
17a2c5e88b
  1. 117
      config/AcediaAliases.ini
  2. 1
      config/AcediaSystem.ini
  3. 6
      sources/Aliases/AliasService.uc
  4. 67
      sources/Aliases/AliasesAPI.uc
  5. 26
      sources/Aliases/BuiltInSources/FeatureAliasSource.uc
  6. 28
      sources/Aliases/BuiltInSources/FeatureAliases.uc

117
config/AcediaAliases.ini

@ -0,0 +1,117 @@
[AcediaCore.FeatureAliasSource]
; Field Medic weapons
[AcediaCore:Commands_Feature FeatureAliases]
Alias="commands"
Alias="command"
Alias="comands"
Alias="comand"
Alias="cmds"
Alias="cmd"
[AcediaFixes:FixAmmoSelling_Feature FeatureAliases]
Alias="FixAmmoSelling"
Alias="FixSelling"
Alias="FixAmmo"
Alias="AmmoSellingFix"
Alias="SellingFix"
Alias="AmmoFix"
Alias="FixAmmoSell"
Alias="FixSell"
Alias="AmmoSellFix"
Alias="SellFix"
Alias="FixAmmoPrinting"
Alias="FixPrinting"
Alias="AmmoPrintingFix"
Alias="PrintingFix"
Alias="FixAmmoPrint"
Alias="FixPrint"
Alias="AmmoPrintFix"
Alias="PrintFix"
[AcediaFixes:FixDoshSpam_Feature FeatureAliases]
Alias="DoshSpamFix"
Alias="DoshFix"
Alias="CashSpamFix"
Alias="CashFix"
Alias="FixDoshSpamF"
Alias="FixDosh"
Alias="FixCashSpam"
Alias="FixCash"
[AcediaFixes:FixDualiesCost_Feature FeatureAliases]
Alias="FixDualiesCost"
Alias="FixDualies"
Alias="DualiesCostFix"
Alias="DualiesFix"
[AcediaFixes:FixFFHack_Feature FeatureAliases]
Alias="FixFFHack"
Alias="FixFriendlyFireHack"
Alias="FixFriendFireHack"
Alias="FixFFHack"
Alias="FFHackFix"
Alias="FriendlyFireHackFix"
Alias="FriendFireHackFix"
Alias="FFHackFix"
[AcediaFixes:FixInfiniteNades_Feature FeatureAliases]
Alias="FixInfiniteNades"
Alias="FixInfiniteNade"
Alias="FixInfNades"
Alias="FixInfNade"
Alias="FixNades"
Alias="FixNade"
Alias="InfiniteNadesFix"
Alias="InfiniteNadeFix"
Alias="InfNadesFix"
Alias="InfNadeFix"
Alias="NadesFix"
Alias="NadeFix"
[AcediaFixes:FixInventoryAbuse_Feature FeatureAliases]
Alias="FixInventoryAbuse"
Alias="FixInventory"
Alias="InventoryAbuseFix"
Alias="InventoryFix"
[AcediaFixes:FixLogSpam_Feature FeatureAliases]
Alias="FixLogSpam"
Alias="FixLog"
Alias="LogSpamFix"
Alias="LogFix"
[AcediaFixes:FixPipes_Feature FeatureAliases]
Alias="FixPipes"
Alias="FixPipe"
Alias="PipesFix"
Alias="PipeFix"
[AcediaFixes:FixProjectileFF_Feature FeatureAliases]
Alias="FixProjectileFriendlyFire"
Alias="FixProjectileFF"
Alias="FixProjFriendlyFire"
Alias="FixProjFF"
Alias="FixFriendlyFire"
Alias="FixFF"
Alias="ProjectileFriendlyFireFix"
Alias="ProjectileFFFix"
Alias="ProjFriendlyFireFix"
Alias="ProjFFFix"
Alias="FriendlyFireFix"
Alias="FFFix"
[AcediaFixes:FixSpectatorCrash_Feature FeatureAliases]
Alias="FixSpectatorCrash"
Alias="FixSpecCrash"
Alias="SpectatorCrashFix"
Alias="SpecCrashFix"
[AcediaFixes:FixZedTimeLags_Feature FeatureAliases]
Alias="FixZedTimeLags"
Alias="FixZedTime"
Alias="FixZTLags"
Alias="FixZT"
Alias="ZedTimeLagsFix"
Alias="ZedTimeFix"
Alias="ZTLagsFix"
Alias="ZTFix"

1
config/AcediaSystem.ini

@ -56,6 +56,7 @@ autoEnable=true
; looks for weapon and color aliases.
weaponAliasesSource=Class'WeaponAliasSource'
colorAliasesSource=Class'ColorAliasSource'
featureAliasesSource=Class'FeatureAliasSource'
; How often are different alias-storing objects are allowed to record
; their updated data into a config.
; Negative or zero values would be reset to `0.05`.

6
sources/Aliases/AliasService.uc

@ -39,6 +39,7 @@ var public config const float saveInterval;
// looks for weapon and color aliases.
var public config const class<AliasSource> weaponAliasesSource;
var public config const class<AliasSource> colorAliasesSource;
var public config const class<AliasSource> featureAliasesSource;
protected function OnLaunch()
{
@ -130,6 +131,7 @@ event Timer()
defaultproperties
{
saveInterval = 0.05
weaponAliasesSource = class'WeaponAliasSource'
colorAliasesSource = class'ColorAliasSource'
weaponAliasesSource = class'WeaponAliasSource'
colorAliasesSource = class'ColorAliasSource'
featureAliasesSource = class'FeatureAliasSource'
}

67
sources/Aliases/AliasesAPI.uc

@ -22,6 +22,7 @@ class AliasesAPI extends AcediaObject
var private LoggerAPI.Definition noWeaponAliasSource, invalidWeaponAliasSource;
var private LoggerAPI.Definition noColorAliasSource, invalidColorAliasSource;
var private LoggerAPI.Definition noFeatureAliasSource, invalidFeatureAliasSource;
/**
* Provides an easier access to the instance of the `AliasSource` of
@ -101,6 +102,37 @@ public final function AliasSource GetColorSource()
return colorSource;
}
/**
* Returns `AliasSource` that is designated in configuration files as
* a source for feature aliases.
*
* NOTE: while by default feature aliases source will contain only feature
* aliases, you should not assume that. Acedia allows admins to store all the
* aliases in the same config.
*
* @return Reference to the `AliasSource` that contains feature aliases.
* Can return `none` if no source for features was configured or
* the configured source is incorrectly defined.
*/
public final function AliasSource GetFeatureSource()
{
local AliasSource colorSource;
local class<AliasSource> sourceClass;
sourceClass = class'AliasService'.default.colorAliasesSource;
if (sourceClass == none)
{
_.logger.Auto(noColorAliasSource);
return none;
}
colorSource = AliasSource(sourceClass.static.GetInstance(true));
if (colorSource == none)
{
_.logger.Auto(invalidColorAliasSource).ArgClass(sourceClass);
return none;
}
return colorSource;
}
/**
* Tries to look up a value stored for given alias in an `AliasSource`
* configured to store weapon aliases. Returns `none` on failure.
@ -165,10 +197,45 @@ public final function Text ResolveColor(Text alias, optional bool copyOnFailure)
return none;
}
/**
* Tries to look up a value stored for given alias in an `AliasSource`
* configured to store feature aliases. Reports error on failure.
*
* Lookup of alias can fail if either alias does not exist in feature alias
* source or feature alias source itself does not exist
* (due to either faulty configuration or incorrect definition).
* To determine if feature alias source exists you can check
* `_.alias.GetFeatureSource()` value.
*
* @param alias Alias, for which method will attempt to
* look up a value. Case-insensitive.
* @param copyOnFailure Whether method should return copy of original
* `alias` value in case caller source did not have any records
* corresponding to `alias`.
* @return If look up was successful - value, associated with the given
* alias `alias`. If lookup was unsuccessful, it depends on `copyOnFailure`
* flag: `copyOnFailure == false` means method will return `none`
* and `copyOnFailure == true` means method will return `alias.Copy()`.
* If `alias == none` method always returns `none`.
*/
public final function Text ResolveFeature(
Text alias,
optional bool copyOnFailure)
{
local AliasSource source;
source = GetFeatureSource();
if (source != none) {
return source.Resolve(alias, copyOnFailure);
}
return none;
}
defaultproperties
{
noWeaponAliasSource = (l=LOG_Error,m="No weapon aliases source configured for Acedia's alias API. Error is most likely cause by erroneous config.")
invalidWeaponAliasSource = (l=LOG_Error,m="`AliasSource` class `%1` is configured to store weapon aliases, but it seems to be invalid. This is a bug and not configuration file problem, but issue might be avoided by using a different `AliasSource`.")
noColorAliasSource = (l=LOG_Error,m="No color aliases source configured for Acedia's alias API. Error is most likely cause by erroneous config.")
invalidColorAliasSource = (l=LOG_Error,m="`AliasSource` class `%1` is configured to store color aliases, but it seems to be invalid. This is a bug and not configuration file problem, but issue might be avoided by using a different `AliasSource`.")
noFeatureAliasSource = (l=LOG_Error,m="No feature aliases source configured for Acedia's alias API. Error is most likely cause by erroneous config.")
invalidFeatureAliasSource = (l=LOG_Error,m="`AliasSource` class `%1` is configured to store feature aliases, but it seems to be invalid. This is a bug and not configuration file problem, but issue might be avoided by using a different `AliasSource`.")
}

26
sources/Aliases/BuiltInSources/FeatureAliasSource.uc

@ -0,0 +1,26 @@
/**
* Source intended for feature aliases.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
* Acedia is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License, or
* (at your option) any later version.
*
* Acedia is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class FeatureAliasSource extends AliasSource
config(AcediaAliases);
defaultproperties
{
aliasesClass = class'FeatureAliases'
}

28
sources/Aliases/BuiltInSources/FeatureAliases.uc

@ -0,0 +1,28 @@
/**
* Per-object-configuration intended for feature aliases.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
* Acedia is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License, or
* (at your option) any later version.
*
* Acedia is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
*/
class FeatureAliases extends Aliases
perObjectConfig
config(AcediaAliases);
defaultproperties
{
configName = "AcediaAliases"
sourceClass = class'FeatureAliasSource'
}
Loading…
Cancel
Save