Browse Source

Change commands to use string getters/setters

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
5ecafc45bc
  1. 20
      sources/Avarice/Avarice.uc
  2. 13
      sources/Commands/Commands.uc

20
sources/Avarice/Avarice.uc

@ -46,7 +46,6 @@ var public config float reconnectTime;
protected function HashTable ToData()
{
local int i;
local Text nextValue;
local HashTable data;
local HashTable linkData;
local ArrayList linksArray;
@ -57,12 +56,8 @@ protected function HashTable ToData()
for (i = 0; i < link.length; i += 1)
{
linkData = __().collections.EmptyHashTable();
nextValue = __().text.FromString(link[i].name);
linkData.SetItem(P("name"), nextValue);
nextValue.FreeSelf();
nextValue = __().text.FromString(link[i].address);
linkData.SetItem(P("address"), nextValue);
nextValue.FreeSelf();
linkData.SetString(P("name"), link[i].name);
linkData.SetString(P("address"), link[i].address);
linksArray.AddItem(linkData);
linkData.FreeSelf();
}
@ -73,7 +68,6 @@ protected function HashTable ToData()
protected function FromData(HashTable source)
{
local int i;
local Text nextText;
local ArrayList linksArray;
local HashTable nextLink;
local AvariceLinkRecord nextRecord;
@ -92,14 +86,8 @@ protected function FromData(HashTable source)
if (nextLink == none) {
continue;
}
nextText = nextLink.GetText(P("name"));
if (nextText != none) {
nextRecord.name = __().text.ToString(nextText);
}
nextText = nextLink.GetText(P("address"));
if (nextText != none) {
nextRecord.address = __().text.ToString(nextText);
}
nextRecord.name = nextLink.GetString(P("name"));
nextRecord.address = nextLink.GetString(P("address"));
link[i] = nextRecord;
_.memory.Free(nextLink);
}

13
sources/Commands/Commands.uc

@ -27,31 +27,22 @@ var public config string chatCommandPrefix;
protected function HashTable ToData()
{
local Text chatPrefix;
local HashTable data;
data = __().collections.EmptyHashTable();
data.SetBool(P("useChatInput"), useChatInput, true);
data.SetBool(P("useMutateInput"), useMutateInput, true);
chatPrefix = _.text.FromString(chatCommandPrefix);
data.SetItem(P("chatCommandPrefix"), chatPrefix);
_.memory.Free(chatPrefix);
data.SetString(P("chatCommandPrefix"), chatCommandPrefix);
return data;
}
protected function FromData(HashTable source)
{
local Text newChatPrefix;
if (source == none) {
return;
}
useChatInput = source.GetBool(P("useChatInput"));
useMutateInput = source.GetBool(P("useMutateInput"));
newChatPrefix = source.GetText(P("chatCommandPrefix"));
chatCommandPrefix = "!";
if (newChatPrefix != none) {
chatCommandPrefix = newChatPrefix.ToString();
}
_.memory.Free(newChatPrefix);
chatCommandPrefix = source.GetString(P("chatCommandPrefix"), "!");
}
protected function DefaultIt()

Loading…
Cancel
Save