← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/net-online-game-status into lp:widelands

 

Notabilis has proposed merging lp:~widelands-dev/widelands/net-online-game-status into lp:widelands with lp:~widelands-dev/widelands/net-remove-tell_ip as a prerequisite.

Commit message:
Dealing with more expressive information about game state from the metaserver.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/net-online-game-status/+merge/343768

Instead of only sending a boolean for connectable/unconnectable games, send more information to the client.

Currently, this is pretty much useless. A game is only connectable/joinable when the host is in the setup-screen (map selection, ...) and not later on. Since we are using the relay in trunk, we are always connectable when in this stage since we don't have problems with firewalls or NATs.

However, at some time after build20 I would like to add late joins for games, e.g., observers (or even players?) connecting to an already running game or dropped players reconnecting without requiring re-hosting of the game. This branch is a preparation for that feature, so I (hopefully) don't have to touch the metaserver protocol when adding it (and don't have to maintain three protocol versions). With the additional information provided in this branch, the lobby can then display information about the state of the game.

Currently I am aware of three relevant game states:
- Closed/unconnectable, i.e., game not on relay (i.e., build19) or host has not joined yet
- Setup, i.e., currently the map and player positions are assigned
- Running, i.e., the players are playing
Are there any more states to consider?

Also, this branch updates the protocol version for the metaserver communication.

This is the last feature branch I want to get in for build20. If there are sensible requests for internet features which might require an update of the metaserver, please tell me before build20.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/net-online-game-status into lp:widelands.
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc	2018-04-07 16:59:00 +0000
+++ src/network/internet_gaming.cc	2018-04-22 17:55:26 +0000
@@ -555,7 +555,7 @@
 				InternetGame* ing = new InternetGame();
 				ing->name = packet.string();
 				ing->build_id = packet.string();
-				ing->connectable = str2bool(packet.string());
+				ing->connectable = (packet.string() == INTERNET_GAME_SETUP);
 				gamelist_.push_back(*ing);
 
 				bool found = false;

=== modified file 'src/network/internet_gaming_protocol.h'
--- src/network/internet_gaming_protocol.h	2018-04-07 16:59:00 +0000
+++ src/network/internet_gaming_protocol.h	2018-04-22 17:55:26 +0000
@@ -37,9 +37,10 @@
  *    crashes. When logging twice with a registered account, the second connection gets a free
  *     username assigned. Dropping RELOGIN command.
  * 3: Between build 19 and build 20 - Added network relay for internet games
- * 4: Between build 19 and build 20 - Using CHAP for password authentication [supported]
+ * 4: Between build 19 and build 20 - Using CHAP for password authentication
+ * 5: Build 20 - Removed obsolete TELL_IP, modifications on user and game listing [supported]
  */
-constexpr unsigned int kInternetGamingProtocolVersion = 4;
+constexpr unsigned int kInternetGamingProtocolVersion = 5;
 
 /**
  * The default timeout time after which the client tries to resend a package or even finally closes
@@ -74,6 +75,14 @@
 static const std::string INTERNET_CLIENT_BOT = "BOT";
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * GAME STATUS                                                             *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/// States an online game can be in
+static const std::string INTERNET_GAME_CLOSED = "CLOSED"; // Not yet connectable or not over relay
+static const std::string INTERNET_GAME_SETUP = "SETUP"; // Map selection, ...
+static const std::string INTERNET_GAME_RUNNING = "RUNNING"; // Playing
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * COMMUNICATION PROTOCOL BETWEEN CLIENT AND METASERVER                    *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 /**
@@ -315,7 +324,8 @@
  * \li string:    Number of game packages and for uint8_t i = 0; i < num; ++i {:
  * \li string:    Name of the game
  * \li string:    Widelands version
- * \li string:    Whether game is connectable ("true", "false")
+ * \li string:    Status of the game, see above. Note that only because a game is connectable
+ *                this does not mean that gaming will work when the versions differ
  * }
  */
 static const std::string IGPCMD_GAMES = "GAMES";
@@ -405,19 +415,4 @@
  */
 static const std::string IGPCMD_GAME_START = "GAME_START";
 
-/**
- * Sent by every participating player of a game to announce the end of the game and to send the
- * statistics.
- * Payload is:
- * \li string:     name of the map
- * \li string:     names of the winners seperated with spaces
- * \li string:     informative string about the win condition.
- * \li string:     in game time until end
- *
- * \note this does not end the physical game and thus the metaserver should not remove the game from
- *       the list. The clients might want to play on, so...
- *
- */
-static const std::string IGPCMD_GAME_END = "GAME_END";
-
 #endif  // end of include guard: WL_NETWORK_INTERNET_GAMING_PROTOCOL_H


Follow ups