diff --git a/realm/discovery.gno b/realm/discovery.gno index aed94b32..4b70f266 100644 --- a/realm/discovery.gno +++ b/realm/discovery.gno @@ -200,7 +200,9 @@ func getPlayer(addr std.Address) *Player { p.CategoryInfo[cat] = CategoryInfo{ PlayerRating: pr, } - playerRatings[cat] = append(playerRatings[cat], pr) + // https://github.com/gnolang/gno/pull/1170 + prs := append([]*PlayerRating{}, playerRatings[cat]...) + playerRatings[cat] = append(prs, pr) } playerStore.Set(addr.String(), p) return p @@ -387,6 +389,9 @@ func parseFilters(filters string) (r listGamesFilters) { if idx < 0 { panic("invalid filter: " + part) } + // TODO: this is likely to misbehave due to https://github.com/gnolang/gno/issues/1135 + // This is unlikely to cause much of an issue here, as we can expect player/white/black/finished + // to only exist once, though it should be kept in mind if/when adding additional filters. filt, pred := part[:idx+1], part[idx+1:] switch filt { case "player:": diff --git a/realm/lobby.gno b/realm/lobby.gno index f6574cb6..ed0ec639 100644 --- a/realm/lobby.gno +++ b/realm/lobby.gno @@ -110,7 +110,9 @@ func LobbyJoin(seconds, increment int) { lobbyPlayer2Game.Remove(caller.String()) now := time.Now() - lobby[tc] = append(lobby[tc], lobbyPlayer{joinedAt: now, seenAt: now, player: getPlayer(caller)}) + // https://github.com/gnolang/gno/pull/1170 + newLobby := append([]lobbyPlayer{}, lobby[tc]...) + lobby[tc] = append(newLobby, lobbyPlayer{joinedAt: now, seenAt: now, player: getPlayer(caller)}) refreshLobby(tc) } @@ -143,7 +145,9 @@ func refreshLobby(tc tcLobby) { // is seemingly active in the lobby. for i := 0; i < len(lobby[tc]); i++ { if now.Sub(lobby[tc][i].seenAt) >= time.Second*30 { - lobby[tc] = append(lobby[tc][:i], lobby[tc][i+1:]...) + // https://github.com/gnolang/gno/pull/1170 + newLobby := append([]lobbyPlayer{}, lobby[tc][:i]...) + lobby[tc] = append(newLobby, lobby[tc][i+1:]...) i-- } } @@ -195,7 +199,9 @@ func lobbyMatch(tc tcLobby, p1, p2 int) { if p1 > p2 { p1, p2 = p2, p1 } - nl := append(lobby[tc][:p1], lobby[tc][p1+1:p2]...) + // https://github.com/gnolang/gno/pull/1170 + nl := append([]lobbyPlayer{}, lobby[tc][:p1]...) + nl = append(nl, lobby[tc][p1+1:p2]...) nl = append(nl, lobby[tc][p2+1:]...) lobby[tc] = nl @@ -247,7 +253,10 @@ func LobbyQuit() { for tc, sublob := range lobby { for i, pl := range sublob { if pl.player.Address == caller { - lobby[tc] = append(sublob[:i], sublob[i+1:]...) + // https://github.com/gnolang/gno/pull/1170 + newLobby := append([]lobbyPlayer{}, sublob[:i]...) + newLobby = append(newLobby, sublob[i+1:]...) + lobby[tc] = newLobby lobbyPlayer2Game.Remove(caller.String()) return } diff --git a/realm/time.gno b/realm/time.gno index 1d30bb10..9668346a 100644 --- a/realm/time.gno +++ b/realm/time.gno @@ -69,7 +69,9 @@ func (tc *TimeControl) AddMove() (valid bool) { } else { tc.BlackTime = nd } - tc.MoveTimestamps = append(tc.MoveTimestamps, time.Now()) + // https://github.com/gnolang/gno/pull/1170 + mts := append([]time.Time{}, tc.MoveTimestamps...) + tc.MoveTimestamps = append(mts, time.Now()) return true }