Check dictionaries before key deletion

This commit is contained in:
Layla 2020-08-21 03:37:38 -04:00
parent b5fd5947ff
commit b0f9df9029
No known key found for this signature in database
GPG Key ID: A494D9357BA1BE31

View File

@ -138,8 +138,12 @@ func (m *Match) MatchLeave(ctx context.Context, logger runtime.Logger, db *sql.D
return state return state
} }
for _, presence := range presences { for _, presence := range presences {
delete(mState.presences, presence.GetUserId()) if _, ok := mState.presences[presence.GetUserId()]; ok {
delete(mState.players, presence.GetUserId()) delete(mState.presences, presence.GetUserId())
}
if _, ok := mState.players[presence.GetUserId()]; ok {
delete(mState.players, presence.GetUserId())
}
} }
return mState return mState
} }