Merge lp:~widelands-dev/widelands/bug-1805325-joining-lan-games into lp:widelands

Proposed by Notabilis
Status: Merged
Merged at revision: 8974
Proposed branch: lp:~widelands-dev/widelands/bug-1805325-joining-lan-games
Merge into: lp:widelands
Diff against target: 86 lines (+24/-8)
3 files modified
src/network/gamehost.cc (+13/-1)
src/network/nethost.h (+5/-6)
src/ui_fsmenu/netsetup_lan.cc (+6/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1805325-joining-lan-games
Reviewer Review Type Date Requested Status
GunChleoc code Approve
Review via email: mp+359789@code.launchpad.net

Commit message

Fixing crash on late joins of LAN games, fixing display of map name in LAN lobby.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4306. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/461050744.
Appveyor build 4099. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1805325_joining_lan_games-4099.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, no tested yet. 1 small nit for a comment.

review: Approve (code)
8942. By Notabilis

Fixing typo in comment.

Revision history for this message
kaputtnik (franku) wrote :

Notabilis, can you merge trunk (if needed) and cause bunnybot to merge? Thanks :-)

Revision history for this message
Notabilis (notabilis27) wrote :

I can do so, but this branch haven't been tested by a reviewer yet. Do you want me to merge this anyway?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I'd like to have some basic testing done.

8943. By GunChleoc

Merged trunk.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Merged trunk so that we can do some testing

Revision history for this message
GunChleoc (gunchleoc) wrote :

Tested and working

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4433. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/490911106.
Appveyor build 4221. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1805325_joining_lan_games-4221.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 4433. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/490911106.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This fixes a crash, so let's have it.

Clang install failure on Travis

@bunnybot merge force

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/network/gamehost.cc'
2--- src/network/gamehost.cc 2018-12-13 07:24:01 +0000
3+++ src/network/gamehost.cc 2019-02-09 09:03:55 +0000
4@@ -608,8 +608,13 @@
5 }
6
7 // if this is an internet game, tell the metaserver that the game started
8- if (internet_)
9+ if (internet_) {
10 InternetGaming::ref().set_game_playing();
11+ } else {
12+ // if it is a LAN game, no longer accept new clients
13+ dynamic_cast<NetHost*>(d->net.get())->stop_listening();
14+ d->promoter.reset();
15+ }
16
17 for (uint32_t i = 0; i < d->clients.size(); ++i) {
18 if (d->clients.at(i).playernum == UserSettings::not_connected())
19@@ -1054,6 +1059,11 @@
20 write_setting_map(packet);
21 broadcast(packet);
22
23+ // Also broadcast on LAN
24+ if (d->promoter) {
25+ d->promoter->set_map(mapname.c_str());
26+ }
27+
28 // Broadcast new player settings
29 packet.reset();
30 packet.unsigned_8(NETCMD_SETTING_ALLPLAYERS);
31@@ -1939,6 +1949,8 @@
32 Client peer;
33 assert(d->net != nullptr);
34 while (d->net->try_accept(&peer.sock_id)) {
35+ // Should only happen if the game has not been started yet
36+ assert(d->game == nullptr);
37 peer.playernum = UserSettings::not_connected();
38 peer.syncreport_arrived = false;
39 peer.desiredspeed = 1000;
40
41=== modified file 'src/network/nethost.h'
42--- src/network/nethost.h 2018-04-07 16:59:00 +0000
43+++ src/network/nethost.h 2019-02-09 09:03:55 +0000
44@@ -52,6 +52,11 @@
45 void send(ConnectionId id, const SendPacket& packet) override;
46 void send(const std::vector<ConnectionId>& ids, const SendPacket& packet) override;
47
48+ /**
49+ * Stops listening for connections.
50+ */
51+ void stop_listening();
52+
53 private:
54 /**
55 * Returns whether the server is started and is listening.
56@@ -61,12 +66,6 @@
57 bool is_listening() const;
58
59 /**
60- * Stops listening for connections.
61- */
62- // Feel free to make this method public if you need it
63- void stop_listening();
64-
65- /**
66 * Tries to listen on the given port.
67 * If it fails, is_listening() will return \c false.
68 * \param port The port to listen on.
69
70=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
71--- src/ui_fsmenu/netsetup_lan.cc 2018-04-27 06:11:05 +0000
72+++ src/ui_fsmenu/netsetup_lan.cc 2019-02-09 09:03:55 +0000
73@@ -183,7 +183,12 @@
74 }
75
76 void FullscreenMenuNetSetupLAN::game_doubleclicked(uint32_t) {
77- clicked_joingame();
78+ assert(opengames.has_selection());
79+ const NetOpenGame* const game = opengames.get_selected();
80+ // Only join games that are open
81+ if (game->info.state == LAN_GAME_OPEN) {
82+ clicked_joingame();
83+ }
84 }
85
86 void FullscreenMenuNetSetupLAN::update_game_info(

Subscribers

People subscribed via source and target branches

to status/vote changes: