Skip to content

Commit

Permalink
fix crash when there are no health icon files
Browse files Browse the repository at this point in the history
  • Loading branch information
lemz1 committed Nov 9, 2024
1 parent f7b6fd9 commit 332c09d
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,23 @@ class CharCreatorImportExportHandler
}

// if the icon path isn't absolute, in the proper folder AND there already was an xml file (if we added one), then we don't save files and replace the typedef's id field
var iconPath = gameplayPage.currentCharacter.healthIconFiles[0].name;
if (CharCreatorUtil.isPathProvided(iconPath, "images/icons/icon-")
&& ((gameplayPage.currentCharacter.healthIconFiles.length > 1
&& CharCreatorUtil.isPathProvided(iconPath.replace(".png", ".xml"), "images/icons/icon-"))
|| gameplayPage.currentCharacter.healthIconFiles.length == 1))
if (gameplayPage.currentCharacter.healthIconFiles.length > 0)
{
var typicalPath = Path.withoutDirectory(iconPath).split(".")[0];
gameplayPage.currentCharacter.healthIcon.id = typicalPath.replace("icon-", "");
}
else
{
for (file in gameplayPage.currentCharacter.healthIconFiles)
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/icons/icon-${gameplayPage.currentCharacter.characterId}.${Path.extension(file.name)}',
file.bytes));
var iconPath = gameplayPage.currentCharacter.healthIconFiles[0].name;
if (CharCreatorUtil.isPathProvided(iconPath, "images/icons/icon-")
&& ((gameplayPage.currentCharacter.healthIconFiles.length > 1
&& CharCreatorUtil.isPathProvided(iconPath.replace(".png", ".xml"), "images/icons/icon-"))
|| gameplayPage.currentCharacter.healthIconFiles.length == 1))
{
var typicalPath = Path.withoutDirectory(iconPath).split(".")[0];
gameplayPage.currentCharacter.healthIcon.id = typicalPath.replace("icon-", "");
}
else
{
for (file in gameplayPage.currentCharacter.healthIconFiles)
zipEntries.push(FileUtil.makeZIPEntryFromBytes('images/icons/icon-${gameplayPage.currentCharacter.characterId}.${Path.extension(file.name)}',
file.bytes));
}
}

// we push this later in case we use a pre-existing icon
Expand Down

0 comments on commit 332c09d

Please sign in to comment.