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. 17
      sources/Commands/Commands.uc

20
sources/Avarice/Avarice.uc

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

17
sources/Commands/Commands.uc

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

Loading…
Cancel
Save