mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 06:19:19 +02:00
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.
62 lines
2.1 KiB
C++
62 lines
2.1 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "application/uilayer.h"
|
|
|
|
// component implementing specific mode of application behaviour
|
|
// base interface
|
|
class application_mode {
|
|
|
|
public:
|
|
// destructor
|
|
virtual ~application_mode() = default;
|
|
// methods;
|
|
// initializes internal data structures of the mode. returns: true on success, false otherwise
|
|
virtual bool init() = 0;
|
|
// mode-specific update of simulation data. returns: false on error, true otherwise
|
|
virtual bool update() = 0;
|
|
// draws mode-specific user interface
|
|
inline
|
|
void render_ui() {
|
|
if( m_userinterface != nullptr ) {
|
|
m_userinterface->render(); } }
|
|
inline
|
|
void begin_ui_frame() {
|
|
if( m_userinterface != nullptr ) {
|
|
m_userinterface->begin_ui_frame(); } }
|
|
inline
|
|
void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) {
|
|
if( m_userinterface != nullptr ) {
|
|
m_userinterface->set_progress( Progress, Subtaskprogress ); } }
|
|
inline
|
|
void set_tooltip( std::string const &Tooltip ) {
|
|
if( m_userinterface != nullptr ) {
|
|
m_userinterface->set_tooltip( Tooltip ); } }
|
|
// maintenance method, called when the mode is activated
|
|
virtual void enter() = 0;
|
|
// maintenance method, called when the mode is deactivated
|
|
virtual void exit() = 0;
|
|
// input handlers
|
|
virtual void on_key( int Key, int Scancode, int Action, int Mods ) = 0;
|
|
virtual void on_cursor_pos( double X, double Y ) = 0;
|
|
virtual void on_mouse_button( int Button, int Action, int Mods ) = 0;
|
|
virtual void on_scroll( double Xoffset, double Yoffset ) = 0;
|
|
virtual void on_window_resize( int w, int h ) = 0;
|
|
virtual void on_event_poll() = 0;
|
|
// opens or closes the session chat; true when this mode has one to open
|
|
virtual bool toggle_chat() { return false; }
|
|
virtual bool is_command_processor() const = 0;
|
|
|
|
protected:
|
|
// members
|
|
std::shared_ptr<ui_layer> m_userinterface;
|
|
};
|