Skip to content

Commit

Permalink
New save format (#7050)
Browse files Browse the repository at this point in the history
* New save format

Uses the Path of Exile BaseItemType.Id for the gem in gemId (as it always has been).
The skillId attribute is also kept and maps to the gems variant primary GrantedEffect.Id.
Adds a new attribute called variantId that maps to the variant of the game, eg. Arc, ArcAltX, or ArcAltY. This is to help identify which variant is used rather than relying on every gem variant having its own unique granted effect.

For the majority of gems skillId and variantId are the same, but it is not true for every case.

* Remove redundant nil check
  • Loading branch information
asvanberg authored Dec 17, 2023
1 parent b219ce3 commit f754f69
Show file tree
Hide file tree
Showing 4 changed files with 1,437 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/Classes/SkillsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,23 @@ function SkillsTabClass:LoadSkill(node, skillSetId)
local gemInstance = { }
gemInstance.nameSpec = child.attrib.nameSpec or ""
if child.attrib.gemId then
local realGemId
-- For now the gemId in the save file is the base gems id, so we need to add the skill id to get the real gem id
-- The skillId holds which variant (transfiguration) it is, eg. Arc, ArcAltX, or ArcAltY
-- The save format may change in the future but it is what we have for now for backward compatibility
if child.attrib.gemId:match("Metadata/Items/Gems/SkillGem") then
realGemId = "Metadata/Items/Gems/SkillGem" .. child.attrib.skillId
else
realGemId = child.attrib.gemId
local gemData
local possibleVariants = self.build.data.gemsByGameId[child.attrib.gemId]
if possibleVariants then
-- If it is a known game, try to determine which variant is used
if child.attrib.variantId then
-- New save format from 3.23 that stores the specific variation (transfiguration)
gemData = possibleVariants[child.attrib.variantId]
elseif child.attrib.skillId then
-- Old format relying on the uniqueness of the granted effects id
for _, variant in pairs(possibleVariants) do
if variant.grantedEffectId == child.attrib.skillId then
gemData = variant
break
end
end
end
end
local gemData = self.build.data.gems[realGemId]
if gemData then
gemInstance.gemId = gemData.id
gemInstance.skillId = gemData.grantedEffectId
Expand Down Expand Up @@ -447,7 +454,8 @@ function SkillsTabClass:Save(xml)
t_insert(node, { elem = "Gem", attrib = {
nameSpec = gemInstance.nameSpec,
skillId = gemInstance.skillId,
gemId = gemInstance.gemId and gemInstance.gemId:match("(Metadata/Items/Gems/SkillGem%a+)Alt[XY]"),
gemId = gemInstance.gemData and gemInstance.gemData.gameId,
variantId = gemInstance.gemData and gemInstance.gemData.variantId,
level = tostring(gemInstance.level),
quality = tostring(gemInstance.quality),
qualityId = gemInstance.qualityId,
Expand Down
Loading

0 comments on commit f754f69

Please sign in to comment.