mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
Remove duplicated logic in HostRoom
Fixes some issues with multiple warning messages
This commit is contained in:
parent
2be02f221d
commit
a5c8e07f46
3 changed files with 7 additions and 9 deletions
|
@ -75,13 +75,10 @@ void HostRoomWindow::Host() {
|
||||||
}
|
}
|
||||||
if (auto member = Network::GetRoomMember().lock()) {
|
if (auto member = Network::GetRoomMember().lock()) {
|
||||||
if (member->IsConnected()) {
|
if (member->IsConnected()) {
|
||||||
if (!NetworkMessage::WarnDisconnect()) {
|
auto parent = static_cast<MultiplayerState*>(parentWidget());
|
||||||
|
if (!parent->OnCloseRoom()) {
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
member->Leave();
|
|
||||||
auto parent = static_cast<MultiplayerState*>(parentWidget());
|
|
||||||
parent->OnCloseRoom();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->host->setDisabled(true);
|
ui->host->setDisabled(true);
|
||||||
|
|
|
@ -112,9 +112,9 @@ void MultiplayerState::OnCreateRoom() {
|
||||||
BringWidgetToFront(host_room);
|
BringWidgetToFront(host_room);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerState::OnCloseRoom() {
|
bool MultiplayerState::OnCloseRoom() {
|
||||||
if (!NetworkMessage::WarnCloseRoom())
|
if (!NetworkMessage::WarnCloseRoom())
|
||||||
return;
|
return false;
|
||||||
if (auto room = Network::GetRoom().lock()) {
|
if (auto room = Network::GetRoom().lock()) {
|
||||||
// if you are in a room, leave it
|
// if you are in a room, leave it
|
||||||
if (auto member = Network::GetRoomMember().lock()) {
|
if (auto member = Network::GetRoomMember().lock()) {
|
||||||
|
@ -123,11 +123,12 @@ void MultiplayerState::OnCloseRoom() {
|
||||||
|
|
||||||
// if you are hosting a room, also stop hosting
|
// if you are hosting a room, also stop hosting
|
||||||
if (room->GetState() != Network::Room::State::Open) {
|
if (room->GetState() != Network::Room::State::Open) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
room->Destroy();
|
room->Destroy();
|
||||||
announce_multiplayer_session->Stop();
|
announce_multiplayer_session->Stop();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerState::OnOpenNetworkRoom() {
|
void MultiplayerState::OnOpenNetworkRoom() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public slots:
|
||||||
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
||||||
void OnViewLobby();
|
void OnViewLobby();
|
||||||
void OnCreateRoom();
|
void OnCreateRoom();
|
||||||
void OnCloseRoom();
|
bool OnCloseRoom();
|
||||||
void OnOpenNetworkRoom();
|
void OnOpenNetworkRoom();
|
||||||
void OnDirectConnectToRoom();
|
void OnDirectConnectToRoom();
|
||||||
void OnAnnounceFailed(const Common::WebResult&);
|
void OnAnnounceFailed(const Common::WebResult&);
|
||||||
|
|
Loading…
Reference in a new issue