mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 22:38:34 +00:00
Add an option to kick players from netplay.
This commit is contained in:
parent
3b23f4bbd6
commit
dbcd40111f
4 changed files with 44 additions and 0 deletions
|
@ -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
|
#ifdef USE_UPNP
|
||||||
#include <miniwget.h>
|
#include <miniwget.h>
|
||||||
#include <miniupnpc.h>
|
#include <miniupnpc.h>
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
|
|
||||||
void AdjustPadBufferSize(unsigned int size);
|
void AdjustPadBufferSize(unsigned int size);
|
||||||
|
|
||||||
|
void KickPlayer(u8 player);
|
||||||
|
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
|
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
|
|
|
@ -355,6 +355,12 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
|
||||||
// player list
|
// player list
|
||||||
if (is_hosting)
|
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"));
|
wxButton* const player_config_btn = new wxButton(panel, wxID_ANY, _("Configure Pads"));
|
||||||
player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnConfigPads, this);
|
player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnConfigPads, this);
|
||||||
player_szr->Add(player_config_btn, 0, wxEXPAND | wxTOP, 5);
|
player_szr->Add(player_config_btn, 0, wxEXPAND | wxTOP, 5);
|
||||||
|
@ -624,6 +630,27 @@ void NetPlayDiag::OnConfigPads(wxCommandEvent&)
|
||||||
netplay_server->SetWiimoteMapping(wiimotemapping);
|
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()
|
bool NetPlayDiag::IsRecording()
|
||||||
{
|
{
|
||||||
return m_record_chkbox->GetValue();
|
return m_record_chkbox->GetValue();
|
||||||
|
|
|
@ -90,6 +90,8 @@ private:
|
||||||
void OnChangeGame(wxCommandEvent& event);
|
void OnChangeGame(wxCommandEvent& event);
|
||||||
void OnAdjustBuffer(wxCommandEvent& event);
|
void OnAdjustBuffer(wxCommandEvent& event);
|
||||||
void OnConfigPads(wxCommandEvent& event);
|
void OnConfigPads(wxCommandEvent& event);
|
||||||
|
void OnKick(wxCommandEvent& event);
|
||||||
|
void OnPlayerSelect(wxCommandEvent& event);
|
||||||
void GetNetSettings(NetSettings &settings);
|
void GetNetSettings(NetSettings &settings);
|
||||||
std::string FindGame();
|
std::string FindGame();
|
||||||
|
|
||||||
|
@ -102,6 +104,7 @@ private:
|
||||||
std::string m_selected_game;
|
std::string m_selected_game;
|
||||||
wxButton* m_game_btn;
|
wxButton* m_game_btn;
|
||||||
wxButton* m_start_btn;
|
wxButton* m_start_btn;
|
||||||
|
wxButton* m_kick_btn;
|
||||||
|
|
||||||
std::vector<int> m_playerids;
|
std::vector<int> m_playerids;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue