1
0
Fork 0

citra_qt/multiplayer: Disallow hosting rooms when preferred game is not selected

which can happen if the game list is empty, and would result in a 400 being returned from the server as the preferred_game field is empty.
This commit is contained in:
zhupengfei 2019-04-19 23:12:30 +08:00
parent 36051204cc
commit d6b168d7ed
No known key found for this signature in database
GPG Key ID: DD129E108BD09378
3 changed files with 8 additions and 0 deletions

View File

@ -111,6 +111,10 @@ void HostRoomWindow::Host() {
NetworkMessage::ShowError(NetworkMessage::PORT_NOT_VALID); NetworkMessage::ShowError(NetworkMessage::PORT_NOT_VALID);
return; return;
} }
if (ui->game_list->currentIndex() == -1) {
NetworkMessage::ShowError(NetworkMessage::GAME_NOT_SELECTED);
return;
}
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {
if (member->GetState() == Network::RoomMember::State::Joining) { if (member->GetState() == Network::RoomMember::State::Joining) {
return; return;

View File

@ -16,6 +16,9 @@ const ConnectionError USERNAME_NOT_VALID_SERVER(
QT_TR_NOOP("Username is already in use or not valid. Please choose another.")); QT_TR_NOOP("Username is already in use or not valid. Please choose another."));
const ConnectionError IP_ADDRESS_NOT_VALID(QT_TR_NOOP("IP is not a valid IPv4 address.")); const ConnectionError IP_ADDRESS_NOT_VALID(QT_TR_NOOP("IP is not a valid IPv4 address."));
const ConnectionError PORT_NOT_VALID(QT_TR_NOOP("Port must be a number between 0 to 65535.")); const ConnectionError PORT_NOT_VALID(QT_TR_NOOP("Port must be a number between 0 to 65535."));
const ConnectionError GAME_NOT_SELECTED(QT_TR_NOOP(
"You must choose a Preferred Game to host a room. If you do not have any games in your game "
"list yet, add a game folder by clicking on the plus icon in the game list."));
const ConnectionError NO_INTERNET( const ConnectionError NO_INTERNET(
QT_TR_NOOP("Unable to find an internet connection. Check your internet settings.")); QT_TR_NOOP("Unable to find an internet connection. Check your internet settings."));
const ConnectionError UNABLE_TO_CONNECT( const ConnectionError UNABLE_TO_CONNECT(

View File

@ -27,6 +27,7 @@ extern const ConnectionError ROOMNAME_NOT_VALID;
extern const ConnectionError USERNAME_NOT_VALID_SERVER; extern const ConnectionError USERNAME_NOT_VALID_SERVER;
extern const ConnectionError IP_ADDRESS_NOT_VALID; extern const ConnectionError IP_ADDRESS_NOT_VALID;
extern const ConnectionError PORT_NOT_VALID; extern const ConnectionError PORT_NOT_VALID;
extern const ConnectionError GAME_NOT_SELECTED;
extern const ConnectionError NO_INTERNET; extern const ConnectionError NO_INTERNET;
extern const ConnectionError UNABLE_TO_CONNECT; extern const ConnectionError UNABLE_TO_CONNECT;
extern const ConnectionError ROOM_IS_FULL; extern const ConnectionError ROOM_IS_FULL;