Skip to content

Commit

Permalink
Prevent crash when spell training sends a spell ID of 0. This happens…
Browse files Browse the repository at this point in the history
… on the 'setskillpoints' command in etheos.
  • Loading branch information
ethanmoffat committed Jun 10, 2022
1 parent 15ba78c commit 5653707
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions EOLib/PacketHandlers/SpellTrainingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ public override bool HandlePacket(IPacket packet)
var spellId = packet.ReadShort();
var spellLevel = packet.ReadShort();

_characterInventoryRepository.SpellInventory.RemoveWhere(x => x.ID == spellId);
_characterInventoryRepository.SpellInventory.Add(new InventorySpell(spellId, spellLevel));
if (spellId > 0)
{
_characterInventoryRepository.SpellInventory.RemoveWhere(x => x.ID == spellId);
_characterInventoryRepository.SpellInventory.Add(new InventorySpell(spellId, spellLevel));
}

var stats = _characterRepository.MainCharacter.Stats.WithNewStat(CharacterStat.SkillPoints, skillPoints);
_characterRepository.MainCharacter = _characterRepository.MainCharacter.WithStats(stats);
Expand Down

0 comments on commit 5653707

Please sign in to comment.