From 5ecafc45bc21855613d23af3f84fc742be0114ec Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 4 Jul 2022 04:16:30 +0700 Subject: [PATCH] Change commands to use string getters/setters --- sources/Avarice/Avarice.uc | 20 ++++---------------- sources/Commands/Commands.uc | 17 ++++------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/sources/Avarice/Avarice.uc b/sources/Avarice/Avarice.uc index a7e0473..b8cdeba 100644 --- a/sources/Avarice/Avarice.uc +++ b/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); } diff --git a/sources/Commands/Commands.uc b/sources/Commands/Commands.uc index a22b005..d87c564 100644 --- a/sources/Commands/Commands.uc +++ b/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); + useChatInput = source.GetBool(P("useChatInput")); + useMutateInput = source.GetBool(P("useMutateInput")); + chatCommandPrefix = source.GetString(P("chatCommandPrefix"), "!"); } protected function DefaultIt()