Skip to content

Commit

Permalink
Null Reference Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurki committed Oct 5, 2022
1 parent 071fffe commit cce5824
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
43 changes: 36 additions & 7 deletions ProfessionMaster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.

-- define addon name
local addonName = "Profession Master";
local addonVersion = "1.5.2";
local addonVersion = "1.5.3";
local addonShortcut = "|cffDA8CFF[PM]|r ";

-- define addon
Expand Down Expand Up @@ -318,21 +318,50 @@ function ProfessionMasterAddon:Migrate()
end

-- check data version
if (Settings.storeVersion and Settings.storeVersion < 4) then
if (Settings.storeVersion and Settings.storeVersion < 5) then
-- check all professions
for _, profession in pairs(Professions) do
for professionId, profession in pairs(Professions) do
-- prepare valid skills
local validSkills = {};

-- iterate skills
for skillId, skill in pairs(profession) do
if (not skill.name) then
profession[skillId] = nil;
break;
-- check skill
if (skill.name ~= nil and skill.itemId ~= nil) then
validSkills[skillId] = skill;
end
end

-- store valid skills
Professions[professionId] = validSkills;
end

-- check own professions
for characterName, professions in pairs(OwnProfessions) do
-- iterate all professions
for professionId, skills in pairs(professions) do
-- prepare valid skills
local validSkills = {};

-- iterate all skills
for skillIndex = 1, #skills do
-- get skill
local skill = skills[skillIndex];

-- check skill
if (skill.skillId ~= nil and skill.itemId ~= nil) then
table.insert(validSkills, skill);
end
end

-- store valid skills
professions[professionId] = validSkills;
end
end
end

-- set store version
Settings.storeVersion = 4;
Settings.storeVersion = 5;
end

-- create addon
Expand Down
2 changes: 1 addition & 1 deletion ProfessionMaster.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Title: Profession Master |cffDA8CFF[PM]
## Notes: See your professions, those of your guild and those of your friends.
## Notes-deDE: Siehe deine Berufe, die deiner Gilde und die deiner Freunde ein.
## Version: 1.5.2
## Version: 1.5.3
## SavedVariables: Professions, OwnProfessions, SyncTimes, Settings, Logs, CharacterSets, BucketList, Guildmates
## SavedVariablesPerCharacter: Frames, CharacterSettings

Expand Down
12 changes: 12 additions & 0 deletions services/own-professions-service.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function OwnProfessionsService:GetTradeSkillProfessionData()

-- prepare item ids
local skills = {};
local skillItems = addon:GetModel("skill-items");

-- iterate trade skills
for tradeSkillIndex = 1, tradeSkillAmount do
Expand All @@ -80,6 +81,17 @@ function OwnProfessionsService:GetTradeSkillProfessionData()
local tradeSkillItemLink = GetTradeSkillItemLink(tradeSkillIndex);
if (tradeSkillItemLink) then
skill.itemId = GetItemInfoInstant(tradeSkillItemLink);
if (not skill.itemId) then
skill.itemId = 0;
end
end

-- check if item can be found by skill id
if (skill.itemId == 0) then
skill.itemId = skillItems[skill.skillId];
if (not skill.itemId) then
skill.itemId = 0;
end
end

-- add skill
Expand Down
4 changes: 2 additions & 2 deletions views/professions-view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ function ProfessionsView:AddFilteredSkills(professionId, searchParts)
-- filter skills
if (profession) then
for skillId, skill in pairs(profession) do
-- check if bop
if (not skill.bop) then
-- check if bop and skill ok
if (skill.name ~= nil and skill.itemId ~= nil) then
-- get bucket list amount
local bucketListAmount = BucketList[skillId];

Expand Down

0 comments on commit cce5824

Please sign in to comment.