mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-18 14:59:19 +02:00
multiplayer: a cab belongs to the peer it is on, and the first one aboard drives
Joining a crew did nothing. The cab was being built by a replicated entervehicle that the authority posted only when it had no cab of its own - which is exactly the case that never happens for the second person to board. The host claims a vehicle, the server builds a cab, and from then on every further claim finds one already standing over there, posts nothing, and the joining peer waits forever for a command that is not coming. A cab is not a shared object. Each participant has their own, with their own camera and their own view of it, and nothing about it needs to travel. So it is built locally by whoever needs one: the driver mode does it for the player when their claim is granted, and the authority does it for itself, because it needs a cab to address the AI handover commands to. That also stops a cab being created on every peer for every claimed vehicle, which is what the entervehicle broadcast was doing. Who runs a shared train is no longer decided by car numbering. It is whoever boarded first, and it stays with them: every crew member is stamped with a session-wide counter when they sit down, and the smallest stamp on the whole consist owns the physics. Coupling, uncoupling and renumbering do not move it, and neither does somebody else joining - each handover is a stutter in the ride of the person who has been driving, and they are the one who would notice it. The stamps travel with CREW_UPDATE and in the snapshot, because a client works out ownership for itself and has to arrive at the same answer. Chat: the key that opens it is now read before imgui gets a look at the input. Any window holding the keyboard - the lobby, most likely, which is precisely where a client sits - would swallow it, so on that side the panel could not be opened at all. The exception is text actually being typed, which is the chat box itself; escape closes that. A client also logs what it says, so if a line goes missing it is clear which half of the trip lost it. Protocol version 6, snapshot version 7.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// 3 - handshake carries build identification and an explicit rejection message
|
||||
// 4 - peer identity, vehicle roster and crew handshake, command source,
|
||||
// logical simulation tick and a versioned state digest instead of the position sum
|
||||
std::uint32_t const EU07_NETWORK_VERSION = 5;
|
||||
std::uint32_t const EU07_NETWORK_VERSION = 6;
|
||||
|
||||
namespace network {
|
||||
|
||||
@@ -668,7 +668,7 @@ void network::client::handle_message(std::shared_ptr<connection> conn, const mes
|
||||
|
||||
if (msg.type == message::CREW_UPDATE) {
|
||||
const auto& cmd = dynamic_cast<const crew_update&>(msg);
|
||||
Crews.mirror(cmd.entity_id, cmd.crew);
|
||||
Crews.mirror(cmd.entity_id, cmd.crew, cmd.since);
|
||||
}
|
||||
|
||||
if (msg.type == message::CLAIM_GRANTED) {
|
||||
@@ -676,8 +676,7 @@ void network::client::handle_message(std::shared_ptr<connection> conn, const mes
|
||||
|
||||
WriteLog("net: claim of vehicle " + std::to_string(cmd.entity_id) + " granted", logtype::net);
|
||||
Global.network_lobby_message.clear();
|
||||
// the cab itself is built by the replicated entervehicle the server posts;
|
||||
// we only have to walk into it once it shows up
|
||||
// the driver mode builds this peer's own cab for the vehicle and moves in
|
||||
Global.network_pending_vehicle = Entities.name_of(cmd.entity_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user