feat: add error handling for calculate damage - #463
Conversation
WalkthroughException handling was added to damage calculation logic in both the Changes
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (1)
116-123: Good exception handling with minor suggestion.The try-catch block effectively prevents crashes during damage calculation and provides detailed error logging. Setting
damageAmount = 0as fallback is appropriate to prevent erroneous damage application.However, note that when an exception occurs, the damage record (
targetRecord.AddDamage) isn't updated, butdamageAmountis reset to 0, which could lead to inconsistency between recorded damage and actual health modification. Consider if the damage record should also be updated in the catch block.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Maple2.Server.Game/Model/Field/Actor/Actor.cs(1 hunks)Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs(1 hunks)Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs(1 hunks)Maple2.Server.Game/Model/Skill/DotDamageRecord.cs(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Maple2.Server.Game/Model/Field/Actor/Actor.cs (2)
Maple2.Server.Game/Util/DamageCalculator.cs (2)
DamageType(11-147)DamageCalculator(10-148)Maple2.Server.Game/Model/Skill/DamageRecord.cs (1)
AddDamage(58-60)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: build
🔇 Additional comments (4)
Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (1)
474-476: LGTM! Good debugging enhancement.The ToString() override provides comprehensive debug information including NPC metadata and state details. This will be valuable for debugging NPC behavior and state tracking.
Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (1)
652-658: LGTM! Excellent debugging enhancement.The ToString() override provides comprehensive debug information with well-organized multi-line formatting. The inclusion of position, state, flags, permissions, and debug flags will be invaluable for debugging player-related issues.
Maple2.Server.Game/Model/Skill/DotDamageRecord.cs (2)
5-5: Good addition for error handling support.Adding the Serilog import to support the new exception logging functionality.
35-43: Excellent exception handling implementation.The try-catch block follows the same robust pattern established in
Actor.cs. The error logging provides valuable debugging context, and the fallback tohpAmount = 0prevents DOT effects from causing crashes or applying erroneous damage when calculation failures occur.
…)" This reverts commit cd28248.
Summary by CodeRabbit
New Features
Bug Fixes