17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-28 18:07:29 +01:00

multiplayer stage 1: --host/--connect startup, client without a local scenario

Networking used to be reachable only through the eu07.ini network.server /
network.client entries, and init_modes() refused to start at all unless a
scenery file was already known. That made it impossible to join a session
without knowing (and typing) the host's scenario up front, even though
SERVER_HELLO already carries the scenario name.

- add --host [address:port] and --connect address:port to the command line
  (default port 7420, --host defaults to 0.0.0.0), plus --scenario/--vehicle
  aliases and -h/--help; the existing ini settings keep working
- drop the init_modes() restriction: a client goes straight to the scenario
  loader and waits there for the handshake, a host without -s still gets the
  launcher and simply refuses joins until a scenario is up
- the loader screen reports the network state instead of sitting on a blank
  progress bar
- a client that did not ask for a vehicle with -v starts as an observer
  rather than failing to find the default EU07-424; the lobby of stage 2 will
  take over the choice
- handshake carries build identification and the server answers an
  impossible join with SERVER_REJECT and a readable reason instead of
  dropping the socket silently; protocol version bumped to 3
- deserialize_message() no longer dereferences a null message on an unknown
  message type
This commit is contained in:
2026-09-06 17:28:44 +00:00
parent eed44dc858
commit 8460fc531f
6 changed files with 200 additions and 21 deletions

View File

@@ -81,6 +81,9 @@ struct global_settings {
std::string szDefaultExt{ szTexturesDDS };
std::string SceneryFile;
std::string local_start_vehicle{ "EU07-424" };
// set when the starting vehicle was explicitly requested (command line -v),
// so multiplayer clients can tell an intentional choice from the built-in default
bool local_start_vehicle_override{ false };
int iConvertModels{ 0 }; // tworzenie plików binarnych
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
bool file_binary_terrain{ true }; // enable binary terrain (de)serialization
@@ -347,6 +350,10 @@ struct global_settings {
std::vector<std::pair<std::string, std::string>> network_servers;
std::optional<std::pair<std::string, std::string>> network_client;
float desync = 0.0f;
// human readable state of the network session, presented on the connecting/loading screen
std::string network_status;
// set when the server refused us; keeps the reason for the ui and stops reconnect attempts
std::string network_reject_reason;
std::unordered_map<int, std::string> trainset_overrides;