Add an option to kick players from netplay.
This commit is contained in:
parent
3b23f4bbd6
commit
dbcd40111f
|
@ -583,6 +583,18 @@ void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid)
|
|||
}
|
||||
}
|
||||
|
||||
void NetPlayServer::KickPlayer(u8 player)
|
||||
{
|
||||
for (auto& current_player : m_players)
|
||||
{
|
||||
if (current_player.second.pid == player)
|
||||
{
|
||||
current_player.second.socket.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_UPNP
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
void AdjustPadBufferSize(unsigned int size);
|
||||
|
||||
void KickPlayer(u8 player);
|
||||
|
||||
bool is_connected;
|
||||
|
||||
#ifdef USE_UPNP
|
||||
|
|
|
@ -355,6 +355,12 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
|
|||
// player list
|
||||
if (is_hosting)
|
||||
{
|
||||
m_player_lbox->Bind(wxEVT_LISTBOX, &NetPlayDiag::OnPlayerSelect, this);
|
||||
m_kick_btn = new wxButton(panel, wxID_ANY, _("Kick Player"));
|
||||
m_kick_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnKick, this);
|
||||
player_szr->Add(m_kick_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
m_kick_btn->Disable();
|
||||
|
||||
wxButton* const player_config_btn = new wxButton(panel, wxID_ANY, _("Configure Pads"));
|
||||
player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnConfigPads, this);
|
||||
player_szr->Add(player_config_btn, 0, wxEXPAND | wxTOP, 5);
|
||||
|
@ -624,6 +630,27 @@ void NetPlayDiag::OnConfigPads(wxCommandEvent&)
|
|||
netplay_server->SetWiimoteMapping(wiimotemapping);
|
||||
}
|
||||
|
||||
void NetPlayDiag::OnKick(wxCommandEvent&)
|
||||
{
|
||||
wxString selection = m_player_lbox->GetStringSelection();
|
||||
unsigned long player = 0;
|
||||
selection.Mid(selection.find_last_of("[") + 1, selection.find_last_of("]")).ToULong(&player);
|
||||
|
||||
netplay_server->KickPlayer((u8)player);
|
||||
|
||||
m_player_lbox->SetSelection(wxNOT_FOUND);
|
||||
wxCommandEvent event;
|
||||
OnPlayerSelect(event);
|
||||
}
|
||||
|
||||
void NetPlayDiag::OnPlayerSelect(wxCommandEvent&)
|
||||
{
|
||||
if (m_player_lbox->GetSelection() > 0)
|
||||
m_kick_btn->Enable();
|
||||
else
|
||||
m_kick_btn->Disable();
|
||||
}
|
||||
|
||||
bool NetPlayDiag::IsRecording()
|
||||
{
|
||||
return m_record_chkbox->GetValue();
|
||||
|
|
|
@ -90,6 +90,8 @@ private:
|
|||
void OnChangeGame(wxCommandEvent& event);
|
||||
void OnAdjustBuffer(wxCommandEvent& event);
|
||||
void OnConfigPads(wxCommandEvent& event);
|
||||
void OnKick(wxCommandEvent& event);
|
||||
void OnPlayerSelect(wxCommandEvent& event);
|
||||
void GetNetSettings(NetSettings &settings);
|
||||
std::string FindGame();
|
||||
|
||||
|
@ -102,6 +104,7 @@ private:
|
|||
std::string m_selected_game;
|
||||
wxButton* m_game_btn;
|
||||
wxButton* m_start_btn;
|
||||
wxButton* m_kick_btn;
|
||||
|
||||
std::vector<int> m_playerids;
|
||||
|
||||
|
|
Loading…
Reference in New Issue