Skip to content

Commit

Permalink
v2.5.08
Browse files Browse the repository at this point in the history
* Optimised code for scanning skills when swapping TradeSkillFrame & CraftFrame and rehooking MTSL button
  • Loading branch information
Thumbkin committed Jun 19, 2021
1 parent 8889c0a commit 995ed91
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 372 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ Minimap button & Enhanced tooltip
### Latest version (v2.5.08)

* Optimised the way the addon scans for missing skills
* Added all upcoming patches as filter possibility to the regular MTSL window as well
* Optimised code for scanning skills when swapping TradeSkillFrame & CraftFrame and rehooking MTSL button
* Added all upcoming patches as filter possibility to the regular MTSL window as well
* Fixed data:
* All professions should now have their correct localised name
* Cooking recipe "Ravager dogs" is now also sold by Alliance vendor
* All skills should now have the correct phase
* All skills should now have the correct phase
* Added data:
* Added item_id for each skill that represents the id of the item that is created when executing the spell

Expand Down
12 changes: 12 additions & 0 deletions VERSION_HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
## Version History

### v2.5.08 (June 19, 2021)

* Optimised the way the addon scans for missing skills
* Optimised code for scanning skills when swapping TradeSkillFrame & CraftFrame and rehooking MTSL button
* Added all upcoming patches as filter possibility to the regular MTSL window as well
* Fixed data:
* All professions should now have their correct localised name
* Cooking recipe "Ravager dogs" is now also sold by Alliance vendor
* All skills should now have the correct phase (if you find any mistake, create an isssue)
* Added data:
* Added item_id for each skill that represents the id of the item that is created when executing the spell

### v2.5.07 (June 17, 2021)

* All professions should now have all the correct data
Expand Down
53 changes: 27 additions & 26 deletions logic/player_npc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -566,34 +566,35 @@ MTSL_LOGIC_PLAYER_NPC = {
-- @max_level Number Maximum number of skilllevel that can be achieved for current rank
------------------------------------------------------------------------------------------------
UpdateMissingSkillsForProfessionCurrentPlayer = function(self, profession_name, current_skill_level, max_level)
-- Reset any previously saved skills
MTSL_CURRENT_PLAYER.TRADESKILLS[profession_name] = {
["NAME"] = profession_name,
["AMOUNT_MISSING"] = 0,
["SKILL_LEVEL"] = current_skill_level,
["SPELLID_HIGHEST_KNOWN_RANK"] = 0,
-- Array because you can learn 2 specialisations as Blacksmith
["SPELLIDS_SPECIALISATION"] = {},
["HIGHEST_KNOWN_RANK"] = 0,
["AMOUNT_LEARNED"] = 0,
["MISSING_SKILLS"] = {},
["LEARNED_SKILLS"] = {},
}
if profession_name then
-- Reset any previously saved skills
MTSL_CURRENT_PLAYER.TRADESKILLS[profession_name] = {
["NAME"] = profession_name,
["AMOUNT_MISSING"] = 0,
["SKILL_LEVEL"] = current_skill_level,
["SPELLID_HIGHEST_KNOWN_RANK"] = 0,
-- Array because you can learn 2 specialisations as Blacksmith
["SPELLIDS_SPECIALISATION"] = {},
["HIGHEST_KNOWN_RANK"] = 0,
["AMOUNT_LEARNED"] = 0,
["MISSING_SKILLS"] = {},
["LEARNED_SKILLS"] = {},
}

-- only scan for missing skills if it has a tradeskill/craft frame
local amount_specs_learned = 0
local known_skill_ids = {}
if profession_name == "Enchanting" then
known_skill_ids = MTSL_LOGIC_PROFESSION:GetSkillIdsCurrentCraft(profession_name)
else
amount_specs_learned = self:UpdateSpecialisations(profession_name)
known_skill_ids = MTSL_LOGIC_PROFESSION:GetSkillIdsCurrentTradeSkill(profession_name)
end
print("Swapped to " .. profession_name)
print("Found " .. #known_skill_ids .. " known skills")
self:UpdateMissingSkillsForProfession(known_skill_ids, profession_name, amount_specs_learned)
-- only scan for missing skills if it has a tradeskill/craft frame
local amount_specs_learned = 0
local known_skill_ids = {}
if profession_name == "Enchanting" then
known_skill_ids = MTSL_LOGIC_PROFESSION:GetSkillIdsCurrentCraft(profession_name)
else
amount_specs_learned = self:UpdateSpecialisations(profession_name)
known_skill_ids = MTSL_LOGIC_PROFESSION:GetSkillIdsCurrentTradeSkill(profession_name)
end

self:UpdateMissingLevelsForProfessionCurrentPlayer(profession_name, max_level)
self:UpdateMissingSkillsForProfession(known_skill_ids, profession_name, amount_specs_learned)

self:UpdateMissingLevelsForProfessionCurrentPlayer(profession_name, max_level)
end
end,

UpdateSpecialisations = function(self, profession_name)
Expand Down
54 changes: 29 additions & 25 deletions logic/profession.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,16 @@ MTSL_LOGIC_PROFESSION = {
------------------------------------------------------------------------------------------------
GetSkillIdsCurrentCraft = function(self)
local learned_skill_ids = {}
-- Loop all known skills
for i = 1, GetNumCrafts() do
local _, _, skill_type = GetCraftInfo(i)
-- Skip the headers, only check real skills
if skill_type ~= "header" then
local itemLink = GetCraftItemLink(i)
local itemID = itemLink:match("enchant:(%d+)")
table.insert(learned_skill_ids, itemID)
if CraftFrame then
-- Loop all known skills
for i = 1, GetNumCrafts() do
local _, _, skill_type = GetCraftInfo(i)
-- Skip the headers, only check real skills
if skill_type ~= "header" then
local itemLink = GetCraftItemLink(i)
local itemID = itemLink:match("enchant:(%d+)")
table.insert(learned_skill_ids, itemID)
end
end
end
-- Sort the list
Expand Down Expand Up @@ -239,31 +241,33 @@ MTSL_LOGIC_PROFESSION = {
------------------------------------------------------------------------------------------------
GetSkillIdsCurrentTradeSkill = function(self, profession_name)
local learned_skill_ids = {}
local localised_profession_name, _, _ = GetTradeSkillLine()
if profession_name and localised_profession_name == profession_name and TradeSkillFrame then
-- Loop all known skills
for i = 1, GetNumTradeSkills() do
local skill_name, skill_type = GetTradeSkillInfo(i)
-- Skip the headers, only check real skills
if skill_name ~= nil and skill_type ~= "header" then
local crafted_item_id = GetTradeSkillItemLink(i):match("item:(%d+)")
if crafted_item_id then
local skill_id = MTSL_LOGIC_SKILL:GetSkillIdForProfessionByCraftedItemId(crafted_item_id, profession_name)
if skill_id ~= 0 then
table.insert(learned_skill_ids, skill_id)
else
local skill_id = MTSL_LOGIC_SKILL:GetSkillIdForProfessionByLocalisedName(skill_name, profession_name)
if TradeSkillFrame then
local localise_profession_name, _, _ = GetTradeSkillLine()
local localised_profession_name = MTSL_LOGIC_PROFESSION:GetEnglishProfessionNameFromLocalisedName(localise_profession_name)
-- make sure we try to get the skills for the openeed tradeskill window
if profession_name and localised_profession_name == profession_name then
-- Loop all known skills
for i = 1, GetNumTradeSkills() do
local skill_name, skill_type = GetTradeSkillInfo(i)
-- Skip the headers, only check real skills
if skill_name and skill_type ~= "header" then
local crafted_item_id = GetTradeSkillItemLink(i):match("item:(%d+)")
if crafted_item_id then
local skill_id = MTSL_LOGIC_SKILL:GetSkillIdForProfessionByCraftedItemId(crafted_item_id, profession_name)
if skill_id ~= 0 then
table.insert(learned_skill_ids, skill_id)
else
print("Could not find the skill id of '" .. skill_name .."' (" .. profession_name .. ')')
local skill_id = MTSL_LOGIC_SKILL:GetSkillIdForProfessionByLocalisedName(skill_name, profession_name)
if skill_id ~= 0 then
table.insert(learned_skill_ids, skill_id)
end
end
end
end
end
-- Sort the list
learned_skill_ids = MTSL_TOOLS:SortArrayNumeric(learned_skill_ids)
end
-- Sort the list
learned_skill_ids = MTSL_TOOLS:SortArrayNumeric(learned_skill_ids)
end
-- return the found list
return learned_skill_ids
Expand Down
Loading

0 comments on commit 995ed91

Please sign in to comment.