fix(guild): fix variable shadowing causing nil panic in scout list (#171)

The else branch redeclared guildInfo with := scoping it to the block,
so the outer guildInfo remained nil when reaching ListInvitedCharacters.
Restructure the conditional to assign to the existing variable instead.
This commit is contained in:
Houmgaor
2026-03-03 18:01:20 +01:00
parent 5b631d1704
commit 8e79fe6834

View File

@@ -106,11 +106,12 @@ func handleMsgMhfGetGuildScoutList(s *Session, p mhfpacket.MHFPacket) {
s.logger.Warn("Failed to get guild for scout list", zap.Error(err)) s.logger.Warn("Failed to get guild for scout list", zap.Error(err))
} }
if guildInfo == nil && s.prevGuildID == 0 { if guildInfo == nil {
if s.prevGuildID == 0 {
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
return return
} else { }
guildInfo, err := s.server.guildRepo.GetByID(s.prevGuildID) guildInfo, err = s.server.guildRepo.GetByID(s.prevGuildID)
if guildInfo == nil || err != nil { if guildInfo == nil || err != nil {
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
return return