From b0f9df90290451d82e0132b6688280d1b2680ced Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Fri, 21 Aug 2020 03:37:38 -0400 Subject: [PATCH] Check dictionaries before key deletion --- server/plugin/control/control.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/plugin/control/control.go b/server/plugin/control/control.go index 60335de..218fa4f 100644 --- a/server/plugin/control/control.go +++ b/server/plugin/control/control.go @@ -138,8 +138,12 @@ func (m *Match) MatchLeave(ctx context.Context, logger runtime.Logger, db *sql.D return state } for _, presence := range presences { - delete(mState.presences, presence.GetUserId()) - delete(mState.players, presence.GetUserId()) + if _, ok := mState.presences[presence.GetUserId()]; ok { + delete(mState.presences, presence.GetUserId()) + } + if _, ok := mState.players[presence.GetUserId()]; ok { + delete(mState.players, presence.GetUserId()) + } } return mState }