Skip to content

Commit

Permalink
add migrations for fix (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
derfloh205 authored Apr 26, 2024
1 parent de3b5e5 commit f341fc9
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 4 deletions.
12 changes: 12 additions & 0 deletions DB/ItemCountDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ function CraftSim.DB.ITEM_COUNT:Migrate()
CraftSimDB.itemCountDB.data = CraftSimItemCountCache or {}
CraftSimDB.itemCountDB.version = 1
end

-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.itemCountDB.version == 1 then
-- remove any crafter entries with colored names...
for crafterUID, _ in pairs(CraftSimDB.itemCountDB.data) do
if string.find(crafterUID, '\124c') then
CraftSimDB.itemCountDB.data[crafterUID] = nil
end
end

CraftSimDB.itemCountDB.version = 2
end
end

function CraftSim.DB.ITEM_COUNT:CleanUp()
Expand Down
5 changes: 5 additions & 0 deletions DB/craftQueueDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function CraftSim.DB.CRAFT_QUEUE:Migrate()
end
CraftSimDB.craftQueueDB.version = 1
end
-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.craftQueueDB.version == 1 then
CraftSim.DB.CRAFT_QUEUE:ClearAll()
CraftSimDB.craftQueueDB.version = 2
end
end

function CraftSim.DB.CRAFT_QUEUE:ClearAll()
Expand Down
13 changes: 12 additions & 1 deletion DB/crafterDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ function CraftSim.DB.CRAFTER:Migrate()
end
CraftSimDB.crafterDB.version = 1
end
-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.crafterDB.version == 1 then
-- remove any crafter entries with colored names...
for crafterUID, _ in pairs(CraftSimDB.crafterDB.data) do
if string.find(crafterUID, '\124c') then
CraftSimDB.crafterDB.data[crafterUID] = nil
end
end

CraftSimDB.crafterDB.version = 2
end
end

---@param crafterUID CrafterUID
Expand All @@ -93,7 +104,7 @@ function CraftSim.DB.CRAFTER:AddCachedRecipeID(crafterUID, profession, recipeID)
CraftSimDB.crafterDB.data[crafterUID] = CraftSimDB.crafterDB.data[crafterUID] or {}
CraftSimDB.crafterDB.data[crafterUID].cachedRecipeIDs = CraftSimDB.crafterDB.data[crafterUID].cachedRecipeIDs or {}
CraftSimDB.crafterDB.data[crafterUID].cachedRecipeIDs[profession] = CraftSimDB.crafterDB.data[crafterUID]
.cachedRecipeIDs[profession] or {}
.cachedRecipeIDs[profession] or {}

if not tContains(CraftSimDB.crafterDB.data[crafterUID].cachedRecipeIDs[profession], recipeID) then
tinsert(CraftSimDB.crafterDB.data[crafterUID].cachedRecipeIDs[profession], recipeID)
Expand Down
14 changes: 14 additions & 0 deletions DB/itemOptimizedCostsDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ function CraftSim.DB.ITEM_OPTIMIZED_COSTS:Migrate()
end
CraftSimDB.itemOptimizedCostsDB.version = 1
end

-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.itemOptimizedCostsDB.version == 1 then
-- remove any crafter entries with colored names...
for _, data in pairs(CraftSimDB.itemOptimizedCostsDB.data) do
for crafterUID, _ in pairs(data) do
if string.find(crafterUID, '\124c') then
data[crafterUID] = nil
end
end
end

CraftSimDB.itemOptimizedCostsDB.version = 2
end
end

function CraftSim.DB.ITEM_OPTIMIZED_COSTS:ClearAll()
Expand Down
16 changes: 16 additions & 0 deletions DB/itemRecipeDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ function CraftSim.DB.ITEM_RECIPE:Migrate()
end
CraftSimDB.itemRecipeDB.version = 1
end

-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.itemRecipeDB.version == 1 then
-- remove any crafter entries with colored names...
for _, data in pairs(CraftSimDB.itemRecipeDB.data) do
local correctedCrafterUIDs = {}
for _, crafterUID in pairs(data.crafters) do
if not string.find(crafterUID, '\124c') then
tinsert(correctedCrafterUIDs, crafterUID)
end
end
data.crafters = correctedCrafterUIDs
end

CraftSimDB.itemRecipeDB.version = 2
end
end

function CraftSim.DB.ITEM_RECIPE:ClearAll()
Expand Down
12 changes: 12 additions & 0 deletions DB/recipeSubCrafterDB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ function CraftSim.DB.RECIPE_SUB_CRAFTER:Migrate()
end
CraftSimDB.recipeSubCrafterDB.version = 1
end

-- 1 -> 2 (16.1.2 -> 16.1.3)
if CraftSimDB.recipeSubCrafterDB.version == 1 then
-- remove any crafter entries with colored names...
for itemID, crafterUID in pairs(CraftSimDB.recipeSubCrafterDB.data) do
if string.find(crafterUID, '\124c') then
CraftSimDB.recipeSubCrafterDB.data[itemID] = nil
end
end

CraftSimDB.recipeSubCrafterDB.version = 2
end
end

function CraftSim.DB.RECIPE_SUB_CRAFTER:ClearAll()
Expand Down
6 changes: 3 additions & 3 deletions Modules/RecipeScan/Frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ function CraftSim.RECIPE_SCAN.FRAMES:AddProfessionTabRow(crafterUID, profession)

local crafterClass = CraftSim.DB.CRAFTER:GetClass(crafterUID)
local crafterName, crafterRealm = strsplit("-", crafterUID)
crafterName = f.class(crafterName, crafterClass)
local coloredCrafterName = f.class(crafterName, crafterClass)
local professionIconSize = 20
local professionIcon = GUTIL:IconToText(CraftSim.CONST.PROFESSION_ICONS[row.profession], professionIconSize,
professionIconSize)
Expand All @@ -566,7 +566,7 @@ function CraftSim.RECIPE_SCAN.FRAMES:AddProfessionTabRow(crafterUID, profession)
}

-- todo: add profession icon prefix
crafterColumn.text:SetText(professionIcon .. " " .. crafterName)
crafterColumn.text:SetText(professionIcon .. " " .. coloredCrafterName)
---@type Enum.Profession
---@type CraftSim.CrafterData
row.crafterData = {
Expand Down Expand Up @@ -599,7 +599,7 @@ function CraftSim.RECIPE_SCAN.FRAMES:AddProfessionTabRow(crafterUID, profession)

row.content = CraftSim.RECIPE_SCAN.FRAMES:CreateProfessionTabContent(row, row.contentFrame.content)

row.content.recipeTitle:SetText(professionIcon .. " " .. crafterName)
row.content.recipeTitle:SetText(professionIcon .. " " .. coloredCrafterName)
end)
end

Expand Down

0 comments on commit f341fc9

Please sign in to comment.