mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
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:
@@ -106,11 +106,12 @@ func handleMsgMhfGetGuildScoutList(s *Session, p mhfpacket.MHFPacket) {
|
||||
s.logger.Warn("Failed to get guild for scout list", zap.Error(err))
|
||||
}
|
||||
|
||||
if guildInfo == nil && s.prevGuildID == 0 {
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
} else {
|
||||
guildInfo, err := s.server.guildRepo.GetByID(s.prevGuildID)
|
||||
if guildInfo == nil {
|
||||
if s.prevGuildID == 0 {
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
guildInfo, err = s.server.guildRepo.GetByID(s.prevGuildID)
|
||||
if guildInfo == nil || err != nil {
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user