prevent crash when not in guild on logout

This commit is contained in:
wish
2022-07-24 12:59:42 +10:00
parent bfd2671832
commit b7c293812c

View File

@@ -116,8 +116,8 @@ func handleMsgMhfAcquireGuildTresure(s *Session, p mhfpacket.MHFPacket) {
func treasureHuntUnregister(s *Session) {
guild, err := GetGuildInfoByCharacterId(s, s.charID)
if err != nil {
panic(err)
if err != nil || guild == nil {
return
}
var huntID int
var hunters string
@@ -125,10 +125,7 @@ func treasureHuntUnregister(s *Session) {
for rows.Next() {
rows.Scan(&huntID, &hunters)
hunters = stringsupport.CSVRemove(hunters, int(s.charID))
_, err = s.server.db.Exec("UPDATE guild_hunts SET hunters=$1 WHERE id=$2", hunters, huntID)
if err != nil {
panic(err)
}
s.server.db.Exec("UPDATE guild_hunts SET hunters=$1 WHERE id=$2", hunters, huntID)
}
}