mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
network changes
This commit is contained in:
2
EU07.cpp
2
EU07.cpp
@@ -41,5 +41,5 @@ int main( int argc, char *argv[] )
|
||||
{
|
||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||
}
|
||||
std::_Exit(0); // skip destructors, there are ordering errors which causes segfaults
|
||||
std::_Exit(0); // skip destructors, there are ordering errors which causes segfaults
|
||||
}
|
||||
|
||||
@@ -338,6 +338,7 @@ eu07_application::release_python_lock() {
|
||||
|
||||
void
|
||||
eu07_application::exit() {
|
||||
m_network.reset();
|
||||
|
||||
SafeDelete( simulation::Train );
|
||||
SafeDelete( simulation::Region );
|
||||
|
||||
@@ -11,6 +11,7 @@ network::tcp::connection::connection(asio::io_context &io_ctx, bool client, size
|
||||
|
||||
network::tcp::connection::~connection()
|
||||
{
|
||||
m_socket.shutdown(m_socket.shutdown_both);
|
||||
m_socket.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -188,13 +188,14 @@ std::tuple<double, double, command_queue::commands_map> network::client::get_nex
|
||||
consume_counter += speed;
|
||||
}
|
||||
|
||||
if (size > MAX_BUFFER_SIZE || consume_counter > mult) {
|
||||
float last_rcv_diff = std::chrono::duration_cast<std::chrono::duration<float>>(now - last_rcv).count();
|
||||
|
||||
if (size > MAX_BUFFER_SIZE || consume_counter > mult || last_rcv_diff > 3.0f) {
|
||||
if (consume_counter > mult) {
|
||||
consume_counter = std::clamp(consume_counter - mult, -MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
delta_queue.pop();
|
||||
last_update = now;
|
||||
|
||||
return std::make_tuple(entry.dt, entry.sync, entry.commands);
|
||||
} else {
|
||||
@@ -246,6 +247,7 @@ void network::client::handle_message(std::shared_ptr<connection> conn, const mes
|
||||
|
||||
auto delta = dynamic_cast<const frame_info&>(msg);
|
||||
delta_queue.push(delta);
|
||||
last_rcv = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace network
|
||||
float jitteriness = 1.0f;
|
||||
float consume_counter = 0.0f;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point last_update;
|
||||
std::chrono::high_resolution_clock::time_point last_rcv;
|
||||
std::chrono::high_resolution_clock::time_point last_frame;
|
||||
std::chrono::high_resolution_clock::duration frame_time;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user