From df418cde9cc022cd49c2edbd3be46fa58b330e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:11:29 +0800 Subject: [PATCH] =?UTF-8?q?```=20fix(config):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E6=A6=82=E7=8E=87=E8=AE=A1=E7=AE=97=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E7=BB=84=E7=B4=A2=E5=BC=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正了EggService.GetResult方法中对pet.Probs数组的索引访问 - 将原来的pet.Probs[len(pet.OutputMons)-1]改为pet.Probs[len(pet.Probs)-1] - 确保数组边界安全,避免潜在的运行时panic ``` --- modules/config/service/egg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config/service/egg.go b/modules/config/service/egg.go index 3043a939..4c54a099 100644 --- a/modules/config/service/egg.go +++ b/modules/config/service/egg.go @@ -43,7 +43,7 @@ func (s *EggService) GetResult(m, f, level uint32) (uint32, bool) { md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m). Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).Scan(&pet) if pet != nil { - pet.Probs[len(pet.OutputMons)-1] += int32(level) + pet.Probs[len(pet.Probs)-1] += int32(level) t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs) if pet.OutputMons[len(pet.OutputMons)-1] == int32(t) { return uint32(t), true