Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a110da

Browse filesBrowse files
committed
Fix editing lobby settings
1 parent b2d8339 commit 6a110da
Copy full SHA for 6a110da

File tree

3 files changed

+14
-5
lines changed
Filter options

3 files changed

+14
-5
lines changed

‎internal/api/v1.go

Copy file name to clipboardExpand all lines: internal/api/v1.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ func GetPlayer(lobby *game.Lobby, request *http.Request) *game.Player {
544544
return nil
545545
}
546546

547-
return lobby.GetPlayer(userSession)
547+
return lobby.GetPlayerBySession(userSession)
548548
}
549549

550550
// GetPlayername either retrieves the playername from a cookie, the URL form.

‎internal/api/ws.go

Copy file name to clipboardExpand all lines: internal/api/ws.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (handler *V1Handler) websocketUpgrade(writer http.ResponseWriter, request *
6161
}
6262

6363
lobby.Synchronized(func() {
64-
player := lobby.GetPlayer(userSession)
64+
player := lobby.GetPlayerBySession(userSession)
6565
if player == nil {
6666
http.Error(writer, "you don't have access to this lobby;usersession unknown", http.StatusUnauthorized)
6767
return

‎internal/game/data.go

Copy file name to clipboardExpand all lines: internal/game/data.go
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,17 @@ const (
164164
Spectating PlayerState = "spectating"
165165
)
166166

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 {
169178
for index, uuid := range lobby.UserSessions {
170179
if uuid == userSession {
171180
return lobby.Players[index]
@@ -175,7 +184,7 @@ func (lobby *Lobby) GetPlayer(userSession uuid.UUID) *Player {
175184
}
176185

177186
func (lobby *Lobby) GetOwner() *Player {
178-
return lobby.GetPlayer(lobby.OwnerID)
187+
return lobby.GetPlayerByID(lobby.OwnerID)
179188
}
180189

181190
func (lobby *Lobby) ClearDrawing() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.