forked from SoDOff-Project/sodoff
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) {
|
public AchievementReward? AddDragonAchievementPoints(Dragon dragon, int? value) {
|
||||||
dragon.PetXP = (dragon.PetXP ?? 0) + (value ?? 0);
|
dragon.PetXP = (dragon.PetXP ?? 0) + (value ?? 0);
|
||||||
|
|
||||||
|
if (dragon.PetXP < 0) {
|
||||||
|
dragon.PetXP = int.MaxValue;
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return new AchievementReward{
|
return new AchievementReward{
|
||||||
// NOTE: RewardID and EntityTypeID are not used by client
|
// NOTE: RewardID and EntityTypeID are not used by client
|
||||||
EntityID = Guid.Parse(dragon.EntityId),
|
EntityID = Guid.Parse(dragon.EntityId),
|
||||||
@ -76,6 +81,11 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
xpPoints.Value += value ?? 0;
|
xpPoints.Value += value ?? 0;
|
||||||
|
|
||||||
|
if (xpPoints.Value < 0) {
|
||||||
|
xpPoints.Value = int.MaxValue;
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return new AchievementReward{
|
return new AchievementReward{
|
||||||
EntityID = Guid.Parse(viking.Id),
|
EntityID = Guid.Parse(viking.Id),
|
||||||
PointTypeID = type,
|
PointTypeID = type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user