From 72b2bd1ec5c1399f23d99e8bf9e9299dfd4a8886 Mon Sep 17 00:00:00 2001 From: Ilya Groshev Date: Wed, 27 May 2026 10:36:09 +0300 Subject: [PATCH] Fix enhance campaign bonus scale and int32 overflow --- server/internal/campaign/catalog.go | 2 +- server/internal/campaign/modifier.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/internal/campaign/catalog.go b/server/internal/campaign/catalog.go index 75727ab..97b4853 100644 --- a/server/internal/campaign/catalog.go +++ b/server/internal/campaign/catalog.go @@ -82,7 +82,7 @@ func loadEnhanceRows() ([]enhanceRow, error) { } rows = append(rows, enhanceRow{ effectType: EnhanceCampaignEffectType(c.EnhanceCampaignEffectType), - effectValue: c.EnhanceCampaignEffectValue, + effectValue: c.EnhanceCampaignEffectValue / 10, targets: grp, startMillis: c.StartDatetime, endMillis: c.EndDatetime, diff --git a/server/internal/campaign/modifier.go b/server/internal/campaign/modifier.go index 1cbdc2e..eb9be3f 100644 --- a/server/internal/campaign/modifier.go +++ b/server/internal/campaign/modifier.go @@ -10,7 +10,7 @@ func (b RateBonus) Apply(basePermil int32) int32 { if b.override > 0 { base = b.override } - return clampPermil(base + b.bonusPermil) + return clampPermil(int32(int64(base) + int64(b.bonusPermil))) } type ExpBonus struct { @@ -18,7 +18,7 @@ type ExpBonus struct { } func (b ExpBonus) Apply(base int32) int32 { - return base * (1000 + b.bonusPermil) / 1000 + return int32(int64(base) * int64(1000+b.bonusPermil) / 1000) } type StaminaMul struct { @@ -29,7 +29,7 @@ func (m StaminaMul) Apply(base int32) int32 { if m.permil == 1000 { return base } - return base * m.permil / 1000 + return int32(int64(base) * int64(m.permil) / 1000) } type DropRateMul struct { @@ -37,7 +37,7 @@ type DropRateMul struct { } func (m DropRateMul) Apply(base int32) int32 { - return (base*(1000+m.bonusPermil) + 999) / 1000 + return int32((int64(base)*int64(1000+m.bonusPermil) + 999) / 1000) } type BonusDrop struct {