File tree 3 files changed +14
-5
lines changed
Filter options
3 files changed +14
-5
lines changed
Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ func GetPlayer(lobby *game.Lobby, request *http.Request) *game.Player {
544
544
return nil
545
545
}
546
546
547
- return lobby .GetPlayer (userSession )
547
+ return lobby .GetPlayerBySession (userSession )
548
548
}
549
549
550
550
// GetPlayername either retrieves the playername from a cookie, the URL form.
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ func (handler *V1Handler) websocketUpgrade(writer http.ResponseWriter, request *
61
61
}
62
62
63
63
lobby .Synchronized (func () {
64
- player := lobby .GetPlayer (userSession )
64
+ player := lobby .GetPlayerBySession (userSession )
65
65
if player == nil {
66
66
http .Error (writer , "you don't have access to this lobby;usersession unknown" , http .StatusUnauthorized )
67
67
return
Original file line number Diff line number Diff line change @@ -164,8 +164,17 @@ const (
164
164
Spectating PlayerState = "spectating"
165
165
)
166
166
167
- // GetPlayer searches for a player, identifying them by usersession.
168
- func (lobby * Lobby ) GetPlayer (userSession uuid.UUID ) * Player {
167
+ func (lobby * Lobby ) GetPlayerByID (id uuid.UUID ) * Player {
168
+ for _ , player := range lobby .Players {
169
+ if player .ID == player .ID {
170
+ return player
171
+ }
172
+ }
173
+
174
+ return nil
175
+ }
176
+
177
+ func (lobby * Lobby ) GetPlayerBySession (userSession uuid.UUID ) * Player {
169
178
for index , uuid := range lobby .UserSessions {
170
179
if uuid == userSession {
171
180
return lobby .Players [index ]
@@ -175,7 +184,7 @@ func (lobby *Lobby) GetPlayer(userSession uuid.UUID) *Player {
175
184
}
176
185
177
186
func (lobby * Lobby ) GetOwner () * Player {
178
- return lobby .GetPlayer (lobby .OwnerID )
187
+ return lobby .GetPlayerByID (lobby .OwnerID )
179
188
}
180
189
181
190
func (lobby * Lobby ) ClearDrawing () {
You can’t perform that action at this time.
0 commit comments