Browse Source

Change configs to adapt to AcediaCore's changes

feature_improvement
Anton Tarasenko 2 years ago
parent
commit
289501517e
  1. 17
      sources/Commands/ACommandDB.uc
  2. 45
      sources/Commands/ACommandInventory.uc
  3. 21
      sources/Commands/ACommandTrader.uc
  4. 27
      sources/Features/FutileChat/FutilityChat.uc
  5. 54
      sources/Features/FutileNickames/FutilityNicknames.uc
  6. 8
      sources/Futility.uc

17
sources/Commands/ACommandDB.uc

@ -226,10 +226,11 @@ protected function Executed(CallData arguments, EPlayer instigator)
// Simple API calls // Simple API calls
private function bool TryAPICallCommands( private function bool TryAPICallCommands(
BaseText subCommand, BaseText subCommand,
EPlayer instigator, EPlayer instigator,
AssociativeArray commandParameters) HashTable commandParameters)
{ {
local Text databaseName;
if (subCommand.IsEmpty()) if (subCommand.IsEmpty())
{ {
callerConsole.WriteLine(T(TNO_DEFAULT_COMMAND)); callerConsole.WriteLine(T(TNO_DEFAULT_COMMAND));
@ -242,14 +243,16 @@ private function bool TryAPICallCommands(
} }
else if (subCommand.Compare(T(TCREATE))) else if (subCommand.Compare(T(TCREATE)))
{ {
CreateDatabase( instigator, databaseName = commandParameters.GetText(T(TDATABASE_NAME));
commandParameters.GetText(T(TDATABASE_NAME))); CreateDatabase(instigator, databaseName);
_.memory.Free(databaseName);
return true; return true;
} }
else if (subCommand.Compare(T(TDELETE))) else if (subCommand.Compare(T(TDELETE)))
{ {
DeleteDatabase( instigator, databaseName = commandParameters.GetText(T(TDATABASE_NAME));
commandParameters.GetText(T(TDATABASE_NAME))); DeleteDatabase(instigator, databaseName);
_.memory.Free(databaseName);
return true; return true;
} }
return false; return false;

45
sources/Commands/ACommandInventory.uc

@ -97,15 +97,14 @@ protected function ExecutedFor(
EPlayer instigator) EPlayer instigator)
{ {
local InventoryTool tool; local InventoryTool tool;
local DynamicArray itemsArray, specifiedLists; local ArrayList itemsArray, specifiedLists;
LoadUserFlags(arguments.options); LoadUserFlags(arguments.options);
tool = class'InventoryTool'.static.CreateFor(target); tool = class'InventoryTool'.static.CreateFor(target);
if (tool == none) { if (tool == none) {
return; return;
} }
itemsArray = arguments.parameters.GetDynamicArray(T(TITEMS)); itemsArray = arguments.parameters.GetArrayList(T(TITEMS));
specifiedLists = arguments.options specifiedLists = arguments.options.GetArrayListBy(P("/list/lists names"));
.GetDynamicArrayBy(P("/list/lists names"));
if (arguments.subCommandName.IsEmpty()) { if (arguments.subCommandName.IsEmpty()) {
tool.ReportInventory(callerConsole, flagHidden); tool.ReportInventory(callerConsole, flagHidden);
} }
@ -127,15 +126,18 @@ protected function ExecutedFor(
tool.ReportChanges(instigator, callerConsole, IRT_Instigator); tool.ReportChanges(instigator, callerConsole, IRT_Instigator);
tool.ReportChanges(instigator, othersConsole, IRT_Others); tool.ReportChanges(instigator, othersConsole, IRT_Others);
_.memory.Free(tool); _.memory.Free(tool);
_.memory.Free(itemsArray);
_.memory.Free(specifiedLists);
} }
protected function SubCommandAdd( protected function SubCommandAdd(
InventoryTool tool, InventoryTool tool,
DynamicArray itemsArray, ArrayList itemsArray,
DynamicArray specifiedLists) ArrayList specifiedLists)
{ {
local int i; local int i;
local int itemsAmount; local int itemsAmount;
local Text nextItem;
local array<Text> itemsFromLists; local array<Text> itemsFromLists;
if (tool == none) { if (tool == none) {
return; return;
@ -145,8 +147,11 @@ protected function SubCommandAdd(
} }
// Add items user listed manually // Add items user listed manually
// Use `itemsAmount` because `itemsArray` can be `none` // Use `itemsAmount` because `itemsArray` can be `none`
for (i = 0; i < itemsAmount; i += 1) { for (i = 0; i < itemsAmount; i += 1)
tool.AddItem(itemsArray.GetText(i), flagForce, flagAmmo); {
nextItem = itemsArray.GetText(i);
tool.AddItem(nextItem, flagForce, flagAmmo);
_.memory.Free(nextItem);
} }
// Add items from specified lists // Add items from specified lists
itemsFromLists = LoadAllItemsLists(specifiedLists); itemsFromLists = LoadAllItemsLists(specifiedLists);
@ -158,11 +163,12 @@ protected function SubCommandAdd(
protected function SubCommandRemove( protected function SubCommandRemove(
InventoryTool tool, InventoryTool tool,
DynamicArray itemsArray, ArrayList itemsArray,
DynamicArray specifiedLists) ArrayList specifiedLists)
{ {
local int i; local int i;
local int itemsAmount; local int itemsAmount;
local Text nextItem;
local array<Text> itemsFromLists; local array<Text> itemsFromLists;
if (tool == none) { if (tool == none) {
return; return;
@ -182,8 +188,11 @@ protected function SubCommandRemove(
} }
// Remove items user listed manually // Remove items user listed manually
// Use `itemsAmount` because `itemsArray` can be `none` // Use `itemsAmount` because `itemsArray` can be `none`
for (i = 0; i < itemsAmount; i += 1) { for (i = 0; i < itemsAmount; i += 1)
tool.RemoveItem(itemsArray.GetText(i), flagKeep, flagForce, flagAll); {
nextItem = itemsArray.GetText(i);
tool.RemoveItem(nextItem, flagKeep, flagForce, flagAll);
_.memory.Free(nextItem);
} }
// Remove items from specified lists // Remove items from specified lists
itemsFromLists = LoadAllItemsLists(specifiedLists); itemsFromLists = LoadAllItemsLists(specifiedLists);
@ -193,7 +202,7 @@ protected function SubCommandRemove(
_.memory.FreeMany(itemsFromLists); _.memory.FreeMany(itemsFromLists);
} }
protected function LoadUserFlags(AssociativeArray options) protected function LoadUserFlags(HashTable options)
{ {
if (options == none) if (options == none)
{ {
@ -215,9 +224,10 @@ protected function LoadUserFlags(AssociativeArray options)
flagGroups = options.HasKey(T(TLIST)); flagGroups = options.HasKey(T(TLIST));
} }
protected function array<Text> LoadAllItemsLists(DynamicArray specifiedLists) protected function array<Text> LoadAllItemsLists(ArrayList specifiedLists)
{ {
local int i, j; local int i, j;
local Text nextList;
local array<Text> result; local array<Text> result;
local array<Text> nextItemBatch; local array<Text> nextItemBatch;
local array<Text> availableLists; local array<Text> availableLists;
@ -230,10 +240,11 @@ protected function array<Text> LoadAllItemsLists(DynamicArray specifiedLists)
badLists = ListBuilder(_.memory.Allocate(class'ListBuilder')); badLists = ListBuilder(_.memory.Allocate(class'ListBuilder'));
callerConsole.Write(T(TLISTS_SKIPPED)); callerConsole.Write(T(TLISTS_SKIPPED));
availableLists = _.kf.templates.GetAvailableLists(); availableLists = _.kf.templates.GetAvailableLists();
for (i = 0; i < specifiedLists.Getlength(); i += 1) for (i = 0; i < specifiedLists.GetLength(); i += 1)
{ {
nextItemBatch = nextList = specifiedLists.GetText(i);
LoadItemsList(specifiedLists.GetText(i), availableLists, badLists); nextItemBatch = LoadItemsList(nextList, availableLists, badLists);
_.memory.Free(nextList);
for (j = 0; j < nextItemBatch.length; j += 1) { for (j = 0; j < nextItemBatch.length; j += 1) {
result[result.length] = nextItemBatch[j]; result[result.length] = nextItemBatch[j];
} }

21
sources/Commands/ACommandTrader.uc

@ -436,8 +436,8 @@ protected function array<ETrader> GetTradersArray(
EPlayer callerPlayer) EPlayer callerPlayer)
{ {
local int i, j; local int i, j;
local Text nextTraderName; local Text nextTraderName, nextSpecifiedTrader;
local DynamicArray specifiedTrades; local ArrayList specifiedTrades;
local array<ETrader> resultTraders; local array<ETrader> resultTraders;
local array<ETrader> availableTraders; local array<ETrader> availableTraders;
// Boundary cases: all traders and no traders at all // Boundary cases: all traders and no traders at all
@ -451,7 +451,7 @@ protected function array<ETrader> GetTradersArray(
resultTraders = resultTraders =
InsertTrader(resultTraders, FindClosestTrader(callerPlayer)); InsertTrader(resultTraders, FindClosestTrader(callerPlayer));
} }
specifiedTrades = result.parameters.GetDynamicArray(T(TTRADERS)); specifiedTrades = result.parameters.GetArrayList(T(TTRADERS));
if (specifiedTrades == none) { if (specifiedTrades == none) {
return resultTraders; return resultTraders;
} }
@ -465,14 +465,17 @@ protected function array<ETrader> GetTradersArray(
nextTraderName = availableTraders[i].GetName(); nextTraderName = availableTraders[i].GetName();
for (j = 0; j < specifiedTrades.GetLength(); j += 1) for (j = 0; j < specifiedTrades.GetLength(); j += 1)
{ {
if (nextTraderName.Compare(specifiedTrades.GetText(j))) nextSpecifiedTrader = specifiedTrades.GetText(j);
if (nextTraderName.Compare(nextSpecifiedTrader))
{ {
resultTraders = resultTraders =
InsertTrader(resultTraders, availableTraders[i]); InsertTrader(resultTraders, availableTraders[i]);
availableTraders[i] = none; availableTraders[i] = none;
specifiedTrades.Remove(j, 1); specifiedTrades.Remove(j, 1);
_.memory.Free(nextSpecifiedTrader);
break; break;
} }
_.memory.Free(nextSpecifiedTrader);
} }
nextTraderName.FreeSelf(); nextTraderName.FreeSelf();
if (specifiedTrades.GetLength() <= 0) { if (specifiedTrades.GetLength() <= 0) {
@ -484,6 +487,7 @@ protected function array<ETrader> GetTradersArray(
if (callerPlayer != none && specifiedTrades.GetLength() > 0) { if (callerPlayer != none && specifiedTrades.GetLength() > 0) {
ReportUnknowTraders(specifiedTrades); ReportUnknowTraders(specifiedTrades);
} }
_.memory.Free(specifiedTrades);
_.memory.FreeMany(availableTraders); _.memory.FreeMany(availableTraders);
return resultTraders; return resultTraders;
} }
@ -510,9 +514,10 @@ protected function array<ETrader> InsertTrader(
return traders; return traders;
} }
protected function ReportUnknowTraders(DynamicArray specifiedTrades) protected function ReportUnknowTraders(ArrayList specifiedTrades)
{ {
local int i; local int i;
local Text nextTraderName;
if (specifiedTrades == none) { if (specifiedTrades == none) {
return; return;
} }
@ -520,7 +525,9 @@ protected function ReportUnknowTraders(DynamicArray specifiedTrades)
.UseColorOnce(_.color.TextNegative).Write(T(TUNKNOWN_TRADERS)); .UseColorOnce(_.color.TextNegative).Write(T(TUNKNOWN_TRADERS));
for (i = 0; i < specifiedTrades.GetLength(); i += 1) for (i = 0; i < specifiedTrades.GetLength(); i += 1)
{ {
callerConsole.Write(specifiedTrades.GetText(i)); nextTraderName = specifiedTrades.GetText(i);
callerConsole.Write(nextTraderName);
_.memory.Free(nextTraderName);
if (i != specifiedTrades.GetLength() - 1) { if (i != specifiedTrades.GetLength() - 1) {
callerConsole.Write(T(TCOMMA_SPACE)); callerConsole.Write(T(TCOMMA_SPACE));
} }

27
sources/Features/FutileChat/FutilityChat.uc

@ -34,24 +34,31 @@ var public config ChatColorSetting colorSetting;
var public config Color configuredColor; var public config Color configuredColor;
var public config float teamColorModifier; var public config float teamColorModifier;
protected function AssociativeArray ToData() protected function HashTable ToData()
{ {
local AssociativeArray data; local HashTable data;
data = __().collections.EmptyAssociativeArray(); local Text colorAsText;
data.SetItem( P("colorSetting"), data = __().collections.EmptyHashTable();
_.text.FromString(string(colorSetting)), true); data.SetString(P("colorSetting"), string(colorSetting));
data.SetItem(P("configuredColor"), _.color.ToText(configuredColor), true); colorAsText = _.color.ToText(configuredColor);
data.SetFloat(P("teamColorModifier"), teamColorModifier, true); data.SetItem(P("configuredColor"), colorAsText);
_.memory.Free(colorAsText);
data.SetFloat(P("teamColorModifier"), teamColorModifier);
return data; return data;
} }
protected function FromData(AssociativeArray source) protected function FromData(HashTable source)
{ {
local Text storedText;
if (source == none) { if (source == none) {
return; return;
} }
colorSetting = ColorSettingFromText(source.GetText(P("colorSetting"))); storedText = source.GetText(P("colorSetting"));
_.color.Parse(source.GetText(P("configuredColor")), configuredColor); colorSetting = ColorSettingFromText(storedText);
_.memory.Free(storedText);
storedText = source.GetText(P("configuredColor"));
_.color.Parse(storedText, configuredColor);
_.memory.Free(storedText);
teamColorModifier = source.GetFloat(P("teamColorModifier"), 0.5); teamColorModifier = source.GetFloat(P("teamColorModifier"), 0.5);
} }

54
sources/Features/FutileNickames/FutilityNicknames.uc

@ -45,45 +45,47 @@ var public config bool correctEmptyNicknames;
var public config int maxNicknameLength; var public config int maxNicknameLength;
var public config array<string> fallbackNickname; var public config array<string> fallbackNickname;
protected function AssociativeArray ToData() protected function HashTable ToData()
{ {
local int i; local int i;
local DynamicArray fallbackNicknamesData; local ArrayList fallbackNicknamesData;
local AssociativeArray data; local HashTable data;
data = __().collections.EmptyAssociativeArray(); data = __().collections.EmptyHashTable();
data.SetItem( P("spacesAction"), data.SetString(P("spacesAction"), string(spacesAction));
_.text.FromString(string(spacesAction)), true); data.SetString(P("colorPermissions"), string(colorPermissions));
data.SetItem( P("colorPermissions"),
_.text.FromString(string(colorPermissions)), true);
data.SetBool( P("replaceSpacesWithUnderscores"), data.SetBool( P("replaceSpacesWithUnderscores"),
replaceSpacesWithUnderscores, true); replaceSpacesWithUnderscores);
data.SetBool( P("removeSingleQuotationMarks"), data.SetBool( P("removeSingleQuotationMarks"),
removeSingleQuotationMarks, true); removeSingleQuotationMarks);
data.SetBool( P("removeDoubleQuotationMarks"), data.SetBool( P("removeDoubleQuotationMarks"),
removeDoubleQuotationMarks, true); removeDoubleQuotationMarks);
data.SetBool(P("correctEmptyNicknames"), correctEmptyNicknames, true); data.SetBool(P("correctEmptyNicknames"), correctEmptyNicknames);
data.SetInt(P("maxNicknameLength"), maxNicknameLength, true); data.SetInt(P("maxNicknameLength"), maxNicknameLength);
fallbackNicknamesData = __().collections.EmptyDynamicArray(); fallbackNicknamesData = __().collections.EmptyArrayList();
for (i = 0; i < fallbackNickname.length; i += 1) for (i = 0; i < fallbackNickname.length; i += 1)
{ {
fallbackNicknamesData.AddItem( fallbackNicknamesData.AddItem(
__().text.FromFormattedString(fallbackNickname[i]), true); __().text.FromFormattedString(fallbackNickname[i]));
} }
data.SetItem(P("fallbackNickname"), fallbackNicknamesData, true); data.SetItem(P("fallbackNickname"), fallbackNicknamesData);
_.memory.Free(fallbackNicknamesData);
return data; return data;
} }
protected function FromData(AssociativeArray source) protected function FromData(HashTable source)
{ {
local int i; local int i;
local Text nextNickName; local Text nextNickName, storedText;
local DynamicArray fallbackNicknamesData; local ArrayList fallbackNicknamesData;
if (source == none) { if (source == none) {
return; return;
} }
spacesAction = SpaceActionFromText(source.GetText(P("spacesAction"))); storedText = source.GetText(P("spacesAction"));
colorPermissions = ColorPermissionsFromText( spacesAction = SpaceActionFromText(storedText);
source.GetText(P("colorPermissions"))); _.memory.Free(storedText);
storedText = source.GetText(P("colorPermissions"));
colorPermissions = ColorPermissionsFromText(storedText);
_.memory.Free(storedText);
replaceSpacesWithUnderscores = replaceSpacesWithUnderscores =
source.GetBool(P("replaceSpacesWithUnderscores"), true); source.GetBool(P("replaceSpacesWithUnderscores"), true);
removeSingleQuotationMarks = removeSingleQuotationMarks =
@ -92,7 +94,7 @@ protected function FromData(AssociativeArray source)
source.GetBool(P("removeDoubleQuotationMarks"), true); source.GetBool(P("removeDoubleQuotationMarks"), true);
correctEmptyNicknames = source.GetBool(P("correctEmptyNicknames"), true); correctEmptyNicknames = source.GetBool(P("correctEmptyNicknames"), true);
maxNicknameLength = source.GetInt(P("correctEmptyNicknames"), 20); maxNicknameLength = source.GetInt(P("correctEmptyNicknames"), 20);
fallbackNicknamesData = DynamicArray(source.GetItem(P("fallbackNickname"))); fallbackNicknamesData = source.GetArrayList(P("fallbackNickname"));
if (fallbackNickname.length > 0) { if (fallbackNickname.length > 0) {
fallbackNickname.length = 0; fallbackNickname.length = 0;
} }
@ -105,7 +107,9 @@ protected function FromData(AssociativeArray source)
else { else {
fallbackNickname[i] = ""; fallbackNickname[i] = "";
} }
_.memory.Free(nextNickName);
} }
_.memory.Free(fallbackNicknamesData);
} }
private function NicknameSpacesAction SpaceActionFromText(BaseText action) private function NicknameSpacesAction SpaceActionFromText(BaseText action)

8
sources/Futility.uc

@ -1,6 +1,6 @@
/** /**
* Config object for `Futility_Feature`. * Config object for `Futility_Feature`.
* Copyright 2021 Anton Tarasenko * Copyright 2021-2022 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Futility. * This file is part of Futility.
* *
@ -21,12 +21,12 @@ class Futility extends FeatureConfig
perobjectconfig perobjectconfig
config(Futility); config(Futility);
protected function AssociativeArray ToData() protected function HashTable ToData()
{ {
return _.collections.EmptyAssociativeArray(); return _.collections.EmptyHashTable();
} }
protected function FromData(AssociativeArray source) protected function FromData(HashTable source)
{ {
} }

Loading…
Cancel
Save