diff --git a/server/plugin/control/control.go b/server/plugin/control/control.go index 69e4030..60335de 100644 --- a/server/plugin/control/control.go +++ b/server/plugin/control/control.go @@ -96,6 +96,14 @@ func (m *Match) MatchJoin(ctx context.Context, logger runtime.Logger, db *sql.DB Presence: precense, } + if jsonObj, err := player.GetPosJSON(); err != nil { + logger.Error(err.Error()) + } else { + if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, player.Presence, true); sendErr != nil { + logger.Error(sendErr.Error()) + } + } + mState.players[precense.GetUserId()] = player // Get intial tile data around player @@ -108,12 +116,12 @@ func (m *Match) MatchJoin(ctx context.Context, logger runtime.Logger, db *sql.DB logger.Error(sendErr.Error()) } } - for _, player := range mState.players { + for _, otherPlayer := range mState.players { // Broadcast player data to client - if jsonObj, err := player.GetPosJSON(); err != nil { + if jsonObj, err := otherPlayer.GetPosJSON(); err != nil { logger.Error(err.Error()) } else { - if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, player.Presence, true); sendErr != nil { + if sendErr := dispatcher.BroadcastMessage(OpCodeUpdatePosition, jsonObj, []runtime.Presence{precense}, otherPlayer.Presence, true); sendErr != nil { logger.Error(sendErr.Error()) } }