mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
add int overflow protection for achievement values
This commit is contained in:
parent
9b1609c6ad
commit
e57e5ad44b
@ -54,6 +54,11 @@ namespace sodoff.Services {
|
||||
public AchievementReward? AddDragonAchievementPoints(Dragon dragon, int? value) {
|
||||
dragon.PetXP = (dragon.PetXP ?? 0) + (value ?? 0);
|
||||
|
||||
if (dragon.PetXP < 0) {
|
||||
dragon.PetXP = int.MaxValue;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
return new AchievementReward{
|
||||
// NOTE: RewardID and EntityTypeID are not used by client
|
||||
EntityID = Guid.Parse(dragon.EntityId),
|
||||
@ -76,6 +81,11 @@ namespace sodoff.Services {
|
||||
}
|
||||
xpPoints.Value += value ?? 0;
|
||||
|
||||
if (xpPoints.Value < 0) {
|
||||
xpPoints.Value = int.MaxValue;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
return new AchievementReward{
|
||||
EntityID = Guid.Parse(viking.Id),
|
||||
PointTypeID = type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user