widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #15501
[Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
Notabilis has proposed merging lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands.
Commit message:
Fixing crash on late joins of LAN games, fixing display of map name in LAN lobby.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1805325 in widelands: "Crash with late join in LAN"
https://bugs.launchpad.net/widelands/+bug/1805325
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1805325-joining-lan-games/+merge/359789
Fixing the crash by
1) no longer accepting new clients after the game started
2) no longer advertising a game after it started
3) double-clicking a game in the LAN lobby only connects to the game when still open / in setup phase
Fixing the empty "map name" entry in the LAN lobby by transmitting the current map name when it changes.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands.
=== modified file 'src/network/gamehost.cc'
--- src/network/gamehost.cc 2018-11-06 17:05:10 +0000
+++ src/network/gamehost.cc 2018-11-28 22:54:33 +0000
@@ -608,8 +608,13 @@
}
// if this is an internet game, tell the metaserver that the game started
- if (internet_)
+ if (internet_) {
InternetGaming::ref().set_game_playing();
+ } else {
+ // if it is a LAN game, no longer accept new clients
+ dynamic_cast<NetHost*>(d->net.get())->stop_listening();
+ d->promoter.reset();
+ }
for (uint32_t i = 0; i < d->clients.size(); ++i) {
if (d->clients.at(i).playernum == UserSettings::not_connected())
@@ -1054,6 +1059,11 @@
write_setting_map(packet);
broadcast(packet);
+ // Also broadcast on LAN
+ if (d->promoter) {
+ d->promoter->set_map(mapname.c_str());
+ }
+
// Broadcast new player settings
packet.reset();
packet.unsigned_8(NETCMD_SETTING_ALLPLAYERS);
@@ -1939,6 +1949,8 @@
Client peer;
assert(d->net != nullptr);
while (d->net->try_accept(&peer.sock_id)) {
+ // Should only happen if the game has not be started yet
+ assert(d->game == nullptr);
peer.playernum = UserSettings::not_connected();
peer.syncreport_arrived = false;
peer.desiredspeed = 1000;
=== modified file 'src/network/nethost.h'
--- src/network/nethost.h 2018-04-07 16:59:00 +0000
+++ src/network/nethost.h 2018-11-28 22:54:33 +0000
@@ -52,6 +52,11 @@
void send(ConnectionId id, const SendPacket& packet) override;
void send(const std::vector<ConnectionId>& ids, const SendPacket& packet) override;
+ /**
+ * Stops listening for connections.
+ */
+ void stop_listening();
+
private:
/**
* Returns whether the server is started and is listening.
@@ -61,12 +66,6 @@
bool is_listening() const;
/**
- * Stops listening for connections.
- */
- // Feel free to make this method public if you need it
- void stop_listening();
-
- /**
* Tries to listen on the given port.
* If it fails, is_listening() will return \c false.
* \param port The port to listen on.
=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc 2018-04-27 06:11:05 +0000
+++ src/ui_fsmenu/netsetup_lan.cc 2018-11-28 22:54:33 +0000
@@ -183,7 +183,12 @@
}
void FullscreenMenuNetSetupLAN::game_doubleclicked(uint32_t) {
- clicked_joingame();
+ assert(opengames.has_selection());
+ const NetOpenGame* const game = opengames.get_selected();
+ // Only join games that are open
+ if (game->info.state == LAN_GAME_OPEN) {
+ clicked_joingame();
+ }
}
void FullscreenMenuNetSetupLAN::update_game_info(
Follow ups
-
[Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: noreply, 2019-02-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: GunChleoc, 2019-02-10
-
[Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: bunnybot, 2019-02-09
-
[Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: bunnybot, 2019-02-09
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: GunChleoc, 2019-02-09
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: GunChleoc, 2019-02-09
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: GunChleoc, 2018-12-05
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: Notabilis, 2018-12-03
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: kaputtnik, 2018-12-03
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: GunChleoc, 2018-11-29
-
[Merge] lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands
From: bunnybot, 2018-11-29