From f6eb76923589bccf2d912b463349d2ec4efe482b Mon Sep 17 00:00:00 2001 From: Jon Willahan <32025765+jon12156@users.noreply.github.com> Date: Sat, 26 May 2018 12:07:00 -0600 Subject: [PATCH] fixed issue with joining as spectator fixed an issue where if you had closed panel attack while spectating, the server didn't remove you as a spectator, and so you couldn't ever join that room again, even if you closed and reopened panel attack. --- mainloop.lua | 2 +- server.lua | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mainloop.lua b/mainloop.lua index b6b20653..9121f373 100644 --- a/mainloop.lua +++ b/mainloop.lua @@ -115,7 +115,7 @@ do {"2P fakevs at burke.ro", main_net_vs_setup, {"burke.ro"}}, {"2P fakevs at Jon's server (US-East, beta for spectating and ranking)", main_net_vs_setup, {"18.188.43.50"}}, {"2P fakevs at domi1819.xyz (Europe, beta for spectating and ranking)", main_net_vs_setup, {"domi1819.xyz"}}, - --{"2P fakevs at localhost (development-use only)", main_net_vs_setup, {"localhost"}}, + {"2P fakevs at localhost (development-use only)", main_net_vs_setup, {"localhost"}}, {"2P fakevs local game", main_local_vs_setup}, {"Replay of 1P endless", main_replay_endless}, {"Replay of 1P puzzle", main_replay_puzzle}, diff --git a/server.lua b/server.lua index ff22bf2a..dd62f780 100644 --- a/server.lua +++ b/server.lua @@ -509,6 +509,8 @@ function Connection.close(self) end if self.room and (self.room.a.name == self.name or self.room.b.name == self.name) then self.room:close() + elseif self.room then + self.room:remove_spectator(self) end clear_proposals(self.name) if self.opponent then @@ -784,7 +786,7 @@ function Connection.J(self, message) if requestedRoom and requestedRoom:state() == CHARACTERSELECT then -- TODO: allow them to join print("join allowed") - requestedRoom:add_spectator(connections[name_to_idx[message.spectate_request.sender]]) + requestedRoom:add_spectator(self) elseif requestedRoom and requestedRoom:state() == "playing, not joinable" then -- TODO: deny the join request, maybe queue them to join as soon as the status changes from "playing" to "room"