Skip to content

Commit 72b2bd1

Browse files
Fix enhance campaign bonus scale and int32 overflow
1 parent dc7c1df commit 72b2bd1

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

server/internal/campaign/catalog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func loadEnhanceRows() ([]enhanceRow, error) {
8282
}
8383
rows = append(rows, enhanceRow{
8484
effectType: EnhanceCampaignEffectType(c.EnhanceCampaignEffectType),
85-
effectValue: c.EnhanceCampaignEffectValue,
85+
effectValue: c.EnhanceCampaignEffectValue / 10,
8686
targets: grp,
8787
startMillis: c.StartDatetime,
8888
endMillis: c.EndDatetime,

server/internal/campaign/modifier.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ func (b RateBonus) Apply(basePermil int32) int32 {
1010
if b.override > 0 {
1111
base = b.override
1212
}
13-
return clampPermil(base + b.bonusPermil)
13+
return clampPermil(int32(int64(base) + int64(b.bonusPermil)))
1414
}
1515

1616
type ExpBonus struct {
1717
bonusPermil int32
1818
}
1919

2020
func (b ExpBonus) Apply(base int32) int32 {
21-
return base * (1000 + b.bonusPermil) / 1000
21+
return int32(int64(base) * int64(1000+b.bonusPermil) / 1000)
2222
}
2323

2424
type StaminaMul struct {
@@ -29,15 +29,15 @@ func (m StaminaMul) Apply(base int32) int32 {
2929
if m.permil == 1000 {
3030
return base
3131
}
32-
return base * m.permil / 1000
32+
return int32(int64(base) * int64(m.permil) / 1000)
3333
}
3434

3535
type DropRateMul struct {
3636
bonusPermil int32
3737
}
3838

3939
func (m DropRateMul) Apply(base int32) int32 {
40-
return (base*(1000+m.bonusPermil) + 999) / 1000
40+
return int32((int64(base)*int64(1000+m.bonusPermil) + 999) / 1000)
4141
}
4242

4343
type BonusDrop struct {

0 commit comments

Comments
 (0)