Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCUMM HE: Online/Network Multiplayer Support #4725

Merged
merged 69 commits into from Mar 5, 2023

Conversation

LittleToonCat
Copy link
Contributor

@LittleToonCat LittleToonCat commented Feb 20, 2023

List of things left to do before this could be merged (more could be added due to feedback):

  • Cleanup net_main.cpp, using JSONObjects instead of constructing messages via string formatting, like how net_lobby.cpp does.
  • Document code.
  • Put debug messages in a separate debug channel.
  • Move sessionselector.* to SCUMM engine and bump theme version.
  • Session and player name setup dialog for Backyard Football 2002.
  • ENet needs a test compile on various different platforms and disabled on configure as needed.

This has been a pet project I've been working on for multiple months, and I believe it's finally time to gather some code feedback. :)

This adds network multiplayer play supported by the compatible Humongous Entertainment games: Backyard Football, Backyard Baseball 2001, Backyard Football 2002, and Moonbase Commander.

It includes a new networking backend based of ENet. It is primarily used for hosting and joining peer-to-peer game sessions and transferring in-game data. For Internet-wide game sessions, it communicates with a separate "session server" to advertise and join such sessions, with basic hole-punching to bypass NAT, if that does not work, the server will relay data for the user. Hosting from and joining to other devices in your local network is also possible. It also contains lobby client code for Football 1999 and Baseball 2001.

The ENet backend is located in backends/networking/enet, while the source code for its latest stable version (1.3.17) is located in the source directory. While the whole netcode itself is located in engines/scumm/he/net

A couple of years back, I've gotten online play for Backyard Football (the 1999 version) and Backyard Baseball 2001 working on an old and soon to be obsolete fork, and support for these games is provided by Backyard Sports Online, a service and community I maintain. Clicking the register button on these games in this branch has a brief mention of the service, this is because ScummVM will be generously providing support and hosting of the project itself. (Thanks sev and rootfather!)

At Backyard Sports Online, we have our competitive online leagues, and have implemented game modifications that suit our needs, notably custom teams, which includes kids not normally playable online (such as Season Play NPCs and Mr. Clanky). We've included such mods here, but under a toggle option in the game settings (disabled by default), since such mods are not needed for casual players. sev has said this is completely fine.

The old lobby code communication was previously done via SDL2_net, but for this one, I've decided to use libcurl, simply because it can communicate with TLS/SSL servers and does the handshaking, making the connection secure. The new backend code can be found in backends/networking/curl/socket.cpp.

Server code and more information for both the session and lobby servers will be located in the scummvm-sites repository. The PR for the server could be found here: scummvm/scummvm-sites/pull/20

For those interested in testing: You should be able to checkout the branch from the fork and start hosting games as the default servers are already up and running as of writing, feedback is greatly appreciated.

Special Thanks:

  • Vissery for testing the sports games with me.
  • Autumm, iDUMB, and "Fluff?" from the Moonbase Commander Discord for Moonbase testing and support.
  • PatchMixolydic, QuestionMonkey, Sarah (onfy) for miscellaneous testing.
  • The Backyard Sports Online community and admins for their ongoing love and support since the very start. ❤️

@BLooperZ
Copy link
Contributor

Amazing work, thank you!

Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did my first round of reviews. sessionselector.* has to be moved back to the SCUMM engine, since gui/ code cannot depend on some engine code.

Also, please bump themes version (in THEMERC in every theme dir as well as in gui/ThemeEngine.h and put themes regeneration, e.g. .zip files into a separate commit.


} // End of namespace Networking

#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end of line


} // End of Namespace Networking

#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end of line

backends/networking/curl/url.h Show resolved Hide resolved
backends/networking/enet/enet.h Show resolved Hide resolved
backends/networking/enet/host.h Show resolved Hide resolved
#include "common/debug.h"
#include "common/system.h"
#include "common/taskbar.h"
#include "common/translation.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have to add this file to po/POTFILES, so it goes to our Weblate for translation.

_timestamp = 0;

_queryProgressText = new StaticTextWidget(this, "SessionSelector.QueryProgressText",
_("Querying games..."));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a commend for translators here with I18N: prefix. Something like

// I18N: Retrieving list of online games


_joinButton->setEnabled(false);
// Update the dialog
_queryProgressText->setLabel(Common::U32String::format(_("Found %d available games."), l.size()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is also, please add a comment to the translators that the games here are online and active ones, not like game files.

*
*/

#ifndef SESSION_SELECTOR_DIALOG_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename it to match the current file name

#include "common/stack.h"
#include "common/str.h"

#include "scumm/he/intern_he.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. You cannot do it from the GUI. This means that you have to move these two files, sessionselector.* back to engines/scumm. Perhaps, call it there dialog_sessionselector.h

@sev-
Copy link
Member

sev- commented Mar 5, 2023

Thank you for addressing all my notes.

Once it is rebased, so there are no conflicts, I'll merge and the work could be continued in-tree

Useful for connecting to a "rendezvous" server or some sort.
Normally, GameSpy Arcade (or a third-party app) would set these settings
into moonbase.ini for the game to read.  But I feel like a couple of
command line options would be a lot simpler.

Also, doubles as a quick way to host and join a game for testing.

Unfortunately this does not support the demo version.
This can be used to create custom protocols with an SDL_net like
interface while being able to connect to SSL/TLS servers.
@sev- sev- marked this pull request as ready for review March 5, 2023 23:06
@sev-
Copy link
Member

sev- commented Mar 5, 2023

Thank you!

@sev- sev- merged commit 82bc36d into scummvm:master Mar 5, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants