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
private function bool TryAPICallCommands(
BaseText subCommand,
EPlayer instigator,
AssociativeArray commandParameters)
BaseText subCommand,
EPlayer instigator,
HashTable commandParameters)
{
local Text databaseName;
if (subCommand.IsEmpty())
{
callerConsole.WriteLine(T(TNO_DEFAULT_COMMAND));
@ -242,14 +243,16 @@ private function bool TryAPICallCommands(
}
else if (subCommand.Compare(T(TCREATE)))
{
CreateDatabase( instigator,
commandParameters.GetText(T(TDATABASE_NAME)));
databaseName = commandParameters.GetText(T(TDATABASE_NAME));
CreateDatabase(instigator, databaseName);
_.memory.Free(databaseName);
return true;
}
else if (subCommand.Compare(T(TDELETE)))
{
DeleteDatabase( instigator,
commandParameters.GetText(T(TDATABASE_NAME)));
databaseName = commandParameters.GetText(T(TDATABASE_NAME));
DeleteDatabase(instigator, databaseName);
_.memory.Free(databaseName);
return true;
}
return false;

45
sources/Commands/ACommandInventory.uc

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

21
sources/Commands/ACommandTrader.uc

@ -436,8 +436,8 @@ protected function array<ETrader> GetTradersArray(
EPlayer callerPlayer)
{
local int i, j;
local Text nextTraderName;
local DynamicArray specifiedTrades;
local Text nextTraderName, nextSpecifiedTrader;
local ArrayList specifiedTrades;
local array<ETrader> resultTraders;
local array<ETrader> availableTraders;
// Boundary cases: all traders and no traders at all
@ -451,7 +451,7 @@ protected function array<ETrader> GetTradersArray(
resultTraders =
InsertTrader(resultTraders, FindClosestTrader(callerPlayer));
}
specifiedTrades = result.parameters.GetDynamicArray(T(TTRADERS));
specifiedTrades = result.parameters.GetArrayList(T(TTRADERS));
if (specifiedTrades == none) {
return resultTraders;
}
@ -465,14 +465,17 @@ protected function array<ETrader> GetTradersArray(
nextTraderName = availableTraders[i].GetName();
for (j = 0; j < specifiedTrades.GetLength(); j += 1)
{
if (nextTraderName.Compare(specifiedTrades.GetText(j)))
nextSpecifiedTrader = specifiedTrades.GetText(j);
if (nextTraderName.Compare(nextSpecifiedTrader))
{
resultTraders =
InsertTrader(resultTraders, availableTraders[i]);
availableTraders[i] = none;
specifiedTrades.Remove(j, 1);
_.memory.Free(nextSpecifiedTrader);
break;
}
_.memory.Free(nextSpecifiedTrader);
}
nextTraderName.FreeSelf();
if (specifiedTrades.GetLength() <= 0) {
@ -484,6 +487,7 @@ protected function array<ETrader> GetTradersArray(
if (callerPlayer != none && specifiedTrades.GetLength() > 0) {
ReportUnknowTraders(specifiedTrades);
}
_.memory.Free(specifiedTrades);
_.memory.FreeMany(availableTraders);
return resultTraders;
}
@ -510,9 +514,10 @@ protected function array<ETrader> InsertTrader(
return traders;
}
protected function ReportUnknowTraders(DynamicArray specifiedTrades)
protected function ReportUnknowTraders(ArrayList specifiedTrades)
{
local int i;
local int i;
local Text nextTraderName;
if (specifiedTrades == none) {
return;
}
@ -520,7 +525,9 @@ protected function ReportUnknowTraders(DynamicArray specifiedTrades)
.UseColorOnce(_.color.TextNegative).Write(T(TUNKNOWN_TRADERS));
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) {
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 float teamColorModifier;
protected function AssociativeArray ToData()
protected function HashTable ToData()
{
local AssociativeArray data;
data = __().collections.EmptyAssociativeArray();
data.SetItem( P("colorSetting"),
_.text.FromString(string(colorSetting)), true);
data.SetItem(P("configuredColor"), _.color.ToText(configuredColor), true);
data.SetFloat(P("teamColorModifier"), teamColorModifier, true);
local HashTable data;
local Text colorAsText;
data = __().collections.EmptyHashTable();
data.SetString(P("colorSetting"), string(colorSetting));
colorAsText = _.color.ToText(configuredColor);
data.SetItem(P("configuredColor"), colorAsText);
_.memory.Free(colorAsText);
data.SetFloat(P("teamColorModifier"), teamColorModifier);
return data;
}
protected function FromData(AssociativeArray source)
protected function FromData(HashTable source)
{
local Text storedText;
if (source == none) {
return;
}
colorSetting = ColorSettingFromText(source.GetText(P("colorSetting")));
_.color.Parse(source.GetText(P("configuredColor")), configuredColor);
storedText = source.GetText(P("colorSetting"));
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);
}

54
sources/Features/FutileNickames/FutilityNicknames.uc

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

8
sources/Futility.uc

@ -1,6 +1,6 @@
/**
* Config object for `Futility_Feature`.
* Copyright 2021 Anton Tarasenko
* Copyright 2021-2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Futility.
*
@ -21,12 +21,12 @@ class Futility extends FeatureConfig
perobjectconfig
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