From 43a769a64582e0a74027ac4fb3c1e1903504000e Mon Sep 17 00:00:00 2001 From: Regisle Date: Mon, 18 Nov 2024 14:44:15 +1030 Subject: [PATCH 1/5] fix Import With Discriminators --- src/Classes/ImportTab.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 4dbab4dbb3..dea3b356a9 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -406,9 +406,9 @@ function ImportTabClass:DownloadCharacterList() local accountName -- Handle spaces in the account name if realm.realmCode == "pc" then - accountName = self.controls.accountName.buf:gsub("%s+", "") + accountName = self.controls.accountName.buf:gsub("%s+", ""):gsub("-", "%%23"):gsub("#", "%%23") else - accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+") + accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+"):gsub("-", "%%23"):gsub("#", "%%23") end local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName.."&realm="..realm.realmCode, function(response, errMsg) @@ -456,6 +456,7 @@ function ImportTabClass:DownloadCharacterList() return end self.controls.accountName:SetText(realAccountName) + realAccountName = realAccountName:gsub("-", "%%23"):gsub("#", "%%23") accountName = realAccountName self.charImportStatus = "Character list successfully retrieved." self.charImportMode = "SELECTCHAR" @@ -570,7 +571,7 @@ function ImportTabClass:DownloadPassiveTree() self.charImportMode = "IMPORTING" self.charImportStatus = "Retrieving character passive tree..." local realm = realmList[self.controls.accountRealm.selIndex] - local accountName = self.controls.accountName.buf + local accountName = self.controls.accountName.buf:gsub("-", "%%23"):gsub("#", "%%23") local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) local charSelect = self.controls.charSelect local charData = charSelect.list[charSelect.selIndex].char @@ -592,7 +593,7 @@ function ImportTabClass:DownloadItems() self.charImportMode = "IMPORTING" self.charImportStatus = "Retrieving character items..." local realm = realmList[self.controls.accountRealm.selIndex] - local accountName = self.controls.accountName.buf + local accountName = self.controls.accountName.buf:gsub("-", "%%23"):gsub("#", "%%23") local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) local charSelect = self.controls.charSelect local charData = charSelect.list[charSelect.selIndex].char From e33d62b681740c28cd26c2733bb289b4b516e69e Mon Sep 17 00:00:00 2001 From: Regisle Date: Mon, 18 Nov 2024 15:06:08 +1030 Subject: [PATCH 2/5] make it use `#` instead of `-` --- src/Classes/ImportTab.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index dea3b356a9..4863f77163 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -455,7 +455,7 @@ function ImportTabClass:DownloadCharacterList() self.charImportMode = "GETSESSIONID" return end - self.controls.accountName:SetText(realAccountName) + self.controls.accountName:SetText(realAccountName:gsub("-", "#")) realAccountName = realAccountName:gsub("-", "%%23"):gsub("#", "%%23") accountName = realAccountName self.charImportStatus = "Character list successfully retrieved." From 84a6b745ee16f07b3bcbf8fe1cde30a8f6fb15cc Mon Sep 17 00:00:00 2001 From: Regisle Date: Mon, 18 Nov 2024 15:37:00 +1030 Subject: [PATCH 3/5] update to only gsub on page downloads, and fix account name dropdown --- src/Classes/ImportTab.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 4863f77163..7c3433d204 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -406,12 +406,12 @@ function ImportTabClass:DownloadCharacterList() local accountName -- Handle spaces in the account name if realm.realmCode == "pc" then - accountName = self.controls.accountName.buf:gsub("%s+", ""):gsub("-", "%%23"):gsub("#", "%%23") + accountName = self.controls.accountName.buf:gsub("%s+", "") else - accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+"):gsub("-", "%%23"):gsub("#", "%%23") + accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+") end local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) - launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName.."&realm="..realm.realmCode, function(response, errMsg) + launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("-", "%%23"):gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg) if errMsg == "Response code: 401" then self.charImportStatus = colorCodes.NEGATIVE.."Sign-in is required." self.charImportMode = "GETSESSIONID" @@ -443,7 +443,7 @@ function ImportTabClass:DownloadCharacterList() end -- GGG's character API has an issue where for /get-characters the account name is not case-sensitive, but for /get-passive-skills and /get-items it is. -- This workaround grabs the profile page and extracts the correct account name from one of the URLs. - launch:DownloadPage(realm.hostName..realm.profileURL..accountName, function(response, errMsg) + launch:DownloadPage(realm.hostName..realm.profileURL..accountName:gsub("#", "%%23"), function(response, errMsg) if errMsg then self.charImportStatus = colorCodes.NEGATIVE.."Error retrieving character list, try again ("..errMsg:gsub("\n"," ")..")" self.charImportMode = "GETACCOUNTNAME" @@ -456,7 +456,6 @@ function ImportTabClass:DownloadCharacterList() return end self.controls.accountName:SetText(realAccountName:gsub("-", "#")) - realAccountName = realAccountName:gsub("-", "%%23"):gsub("#", "%%23") accountName = realAccountName self.charImportStatus = "Character list successfully retrieved." self.charImportMode = "SELECTCHAR" @@ -559,11 +558,11 @@ function ImportTabClass:SaveAccountHistory() if not historyList[self.controls.accountName.buf] then t_insert(historyList, self.controls.accountName.buf) historyList[self.controls.accountName.buf] = true - self.controls.accountHistory:SelByValue(self.controls.accountName.buf) table.sort(historyList, function(a,b) return a:lower() < b:lower() end) self.controls.accountHistory:CheckDroppedWidth(true) + self.controls.accountHistory:SelByValue(self.controls.accountName.buf) end end @@ -571,11 +570,11 @@ function ImportTabClass:DownloadPassiveTree() self.charImportMode = "IMPORTING" self.charImportStatus = "Retrieving character passive tree..." local realm = realmList[self.controls.accountRealm.selIndex] - local accountName = self.controls.accountName.buf:gsub("-", "%%23"):gsub("#", "%%23") + local accountName = self.controls.accountName.buf local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) local charSelect = self.controls.charSelect local charData = charSelect.list[charSelect.selIndex].char - launch:DownloadPage(realm.hostName.."character-window/get-passive-skills?accountName="..accountName.."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg) + launch:DownloadPage(realm.hostName.."character-window/get-passive-skills?accountName="..accountName:gsub("#", "%%23").."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg) self.charImportMode = "SELECTCHAR" if errMsg then self.charImportStatus = colorCodes.NEGATIVE.."Error importing character data, try again ("..errMsg:gsub("\n"," ")..")" @@ -593,11 +592,11 @@ function ImportTabClass:DownloadItems() self.charImportMode = "IMPORTING" self.charImportStatus = "Retrieving character items..." local realm = realmList[self.controls.accountRealm.selIndex] - local accountName = self.controls.accountName.buf:gsub("-", "%%23"):gsub("#", "%%23") + local accountName = self.controls.accountName.buf local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) local charSelect = self.controls.charSelect local charData = charSelect.list[charSelect.selIndex].char - launch:DownloadPage(realm.hostName.."character-window/get-items?accountName="..accountName.."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg) + launch:DownloadPage(realm.hostName.."character-window/get-items?accountName="..accountName:gsub("#", "%%23").."&character="..charData.name.."&realm="..realm.realmCode, function(response, errMsg) self.charImportMode = "SELECTCHAR" if errMsg then self.charImportStatus = colorCodes.NEGATIVE.."Error importing character data, try again ("..errMsg:gsub("\n"," ")..")" From b9db2e08171b2f8e19964cfd43b76ee2403aaa14 Mon Sep 17 00:00:00 2001 From: Regisle Date: Mon, 18 Nov 2024 15:39:40 +1030 Subject: [PATCH 4/5] fix saved value --- src/Classes/ImportTab.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 7c3433d204..198151d2a9 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -456,7 +456,7 @@ function ImportTabClass:DownloadCharacterList() return end self.controls.accountName:SetText(realAccountName:gsub("-", "#")) - accountName = realAccountName + accountName = realAccountName:gsub("-", "#") self.charImportStatus = "Character list successfully retrieved." self.charImportMode = "SELECTCHAR" self.lastRealm = realm.id From 410031bbe72769c93b9eb804683c6abd291c49b5 Mon Sep 17 00:00:00 2001 From: Regisle Date: Mon, 18 Nov 2024 15:40:49 +1030 Subject: [PATCH 5/5] cleanup extra gsub --- src/Classes/ImportTab.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 198151d2a9..45942e6ed2 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -455,8 +455,9 @@ function ImportTabClass:DownloadCharacterList() self.charImportMode = "GETSESSIONID" return end - self.controls.accountName:SetText(realAccountName:gsub("-", "#")) - accountName = realAccountName:gsub("-", "#") + realAccountName = realAccountName:gsub("-", "#") + self.controls.accountName:SetText(realAccountName) + accountName = realAccountName self.charImportStatus = "Character list successfully retrieved." self.charImportMode = "SELECTCHAR" self.lastRealm = realm.id