fix(guild): add nil guards for alliance guild lookups (#171)

scanAllianceWithGuilds dereferences guild pointers returned by GetByID
without checking for nil. Since GetByID returns (nil, nil) when a guild
is missing, alliances referencing deleted guilds cause nil-pointer
panics. The panic is caught by session recovery but no ACK is sent,
softlocking the client.

Add nil checks in scanAllianceWithGuilds, handleMsgMhfOperateJoint,
handleMsgMhfInfoJoint, and handleMsgMhfInfoGuild so that missing
guilds or alliances produce proper error responses instead of panics.
This commit is contained in:
Houmgaor
2026-03-02 19:43:11 +01:00
parent 07a587213d
commit aee53534a2
4 changed files with 127 additions and 41 deletions

View File

@@ -135,8 +135,8 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
if guild.AllianceID > 0 {
alliance, err := s.server.guildRepo.GetAllianceByID(guild.AllianceID)
if err != nil {
bf.WriteUint32(0) // Error, no alliance
if err != nil || alliance == nil {
bf.WriteUint32(0) // Error or missing alliance
} else {
bf.WriteUint32(alliance.ID)
bf.WriteUint32(uint32(alliance.CreatedAt.Unix()))