Skip to content

Commit

Permalink
Fix integer overflow errors for values that can get very large
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed May 1, 2023
1 parent 0ad9e22 commit deac6f3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions EOLib.Config.Test/ConfigFileLoadActionsTest.cs
Expand Up @@ -56,9 +56,6 @@ public void InvalidConfigFileThatExists_UsesConfigurationValueDefaults()
Assert.IsTrue(_configurationRepository.ShowChatBubbles);
Assert.IsFalse(_configurationRepository.ShowTransition);

Assert.AreEqual(ConfigDefaults.InGameWidth, _configurationRepository.InGameWidth);
Assert.AreEqual(ConfigDefaults.InGameHeight, _configurationRepository.InGameHeight);

Assert.IsFalse(_configurationRepository.MusicEnabled);
Assert.IsFalse(_configurationRepository.SoundEnabled);

Expand Down
6 changes: 3 additions & 3 deletions EOLib/Domain/Character/CharacterSessionRepository.cs
Expand Up @@ -11,7 +11,7 @@ public interface ICharacterSessionRepository : IResettable

int LastKillExp { get; set; }

int TodayTotalExp { get; set; }
ulong TodayTotalExp { get; set; }
}

public interface ICharacterSessionProvider : IResettable
Expand All @@ -22,7 +22,7 @@ public interface ICharacterSessionProvider : IResettable

int LastKillExp { get; }

int TodayTotalExp { get; }
ulong TodayTotalExp { get; }
}

[AutoMappedType(IsSingleton = true)]
Expand All @@ -34,7 +34,7 @@ public class CharacterSessionRepository : ICharacterSessionRepository, ICharacte

public int LastKillExp { get; set; }

public int TodayTotalExp { get; set; }
public ulong TodayTotalExp { get; set; }

public CharacterSessionRepository()
{
Expand Down
2 changes: 1 addition & 1 deletion EOLib/PacketHandlers/NPC/NPCSpecHandler.cs
Expand Up @@ -92,7 +92,7 @@ public override bool HandlePacket(IPacket packet)
_characterSessionRepository.LastKillExp = expDifference;
if (expDifference > _characterSessionRepository.BestKillExp)
_characterSessionRepository.BestKillExp = expDifference;
_characterSessionRepository.TodayTotalExp += expDifference;
_characterSessionRepository.TodayTotalExp += Convert.ToUInt64(Math.Max(expDifference, 0));
}

if (droppedItemID > 0)
Expand Down

0 comments on commit deac6f3

Please sign in to comment.