mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-01 06:52:45 +01:00
refactor(sonar): make narrowing conversions explicit (cpp:S5276)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,7 +106,7 @@ void network::tcp::connection::write_message(const message &msg, std::ostream &s
|
||||
return;
|
||||
}
|
||||
stream.seekp(beg + 4, std::ios_base::beg);
|
||||
sn_utils::ls_uint32(stream, size);
|
||||
sn_utils::ls_uint32(stream, static_cast<uint32_t>(size));
|
||||
|
||||
stream.seekp(0, std::ios_base::end);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void network::tcp::connection::send_message(const message &msg)
|
||||
network::tcp::server::server(std::shared_ptr<std::istream> buf, asio::io_context &io_ctx, const std::string &host, uint32_t port)
|
||||
: network::server(buf), m_acceptor(io_ctx), m_io_ctx(io_ctx)
|
||||
{
|
||||
auto endpoint = asio::ip::tcp::endpoint(asio::ip::make_address(host), port);
|
||||
auto endpoint = asio::ip::tcp::endpoint(asio::ip::make_address(host), static_cast<asio::ip::port_type>(port));
|
||||
m_acceptor.open(endpoint.protocol());
|
||||
m_acceptor.set_option(asio::socket_base::reuse_address(true));
|
||||
m_acceptor.set_option(asio::ip::tcp::no_delay(true));
|
||||
@@ -188,7 +188,7 @@ void network::tcp::client::connect()
|
||||
conn->set_handler(std::bind(&client::handle_message, this, conn, std::placeholders::_1));
|
||||
|
||||
asio::ip::tcp::endpoint endpoint(
|
||||
asio::ip::make_address(host), port);
|
||||
asio::ip::make_address(host), static_cast<asio::ip::port_type>(port));
|
||||
conn->m_socket.open(endpoint.protocol());
|
||||
conn->m_socket.set_option(asio::ip::tcp::no_delay(true));
|
||||
conn->m_socket.async_connect(endpoint,
|
||||
|
||||
@@ -32,11 +32,11 @@ void network::server_hello::deserialize(std::istream &stream)
|
||||
|
||||
void ::network::request_command::serialize(std::ostream &stream) const
|
||||
{
|
||||
sn_utils::ls_uint32(stream, commands.size());
|
||||
sn_utils::ls_uint32(stream, static_cast<uint32_t>(commands.size()));
|
||||
for (auto const &kv : commands)
|
||||
{
|
||||
sn_utils::ls_uint32(stream, kv.first);
|
||||
sn_utils::ls_uint32(stream, kv.second.size());
|
||||
sn_utils::ls_uint32(stream, static_cast<uint32_t>(kv.second.size()));
|
||||
for (command_data const &data : kv.second)
|
||||
{
|
||||
sn_utils::ls_uint32(stream, (uint32_t)data.command);
|
||||
|
||||
@@ -43,7 +43,7 @@ void network::connection::connected()
|
||||
if (is_client) {
|
||||
client_hello msg;
|
||||
msg.version = EU07_NETWORK_VERSION;
|
||||
msg.start_packet = packet_counter;
|
||||
msg.start_packet = static_cast<uint32_t>(packet_counter);
|
||||
send_message(msg);
|
||||
}
|
||||
}
|
||||
@@ -188,9 +188,9 @@ std::tuple<double, double, command_queue::commands_map> network::client::get_nex
|
||||
}
|
||||
|
||||
|
||||
float size = delta_queue.size() - consume_counter;
|
||||
float size = static_cast<float>(delta_queue.size()) - consume_counter;
|
||||
const auto& entry = delta_queue.front();
|
||||
float mult = entry.render_dt / std::chrono::duration_cast<std::chrono::duration<float>>(frame_time).count();
|
||||
float mult = static_cast<float>(entry.render_dt / std::chrono::duration_cast<std::chrono::duration<float>>(frame_time).count());
|
||||
|
||||
if (counter == 1 && size < MAX_BUFFER_SIZE * 2.0f) {
|
||||
last_target = last_target * TARGET_MIX +
|
||||
|
||||
@@ -99,10 +99,10 @@ namespace network
|
||||
std::tuple<double, double, command_queue::commands_map> get_next_delta(int counter);
|
||||
void send_commands(command_queue::commands_map commands);
|
||||
int get_frame_counter() {
|
||||
return resume_frame_counter;
|
||||
return static_cast<int>(resume_frame_counter);
|
||||
}
|
||||
int get_awaiting_frames() {
|
||||
return delta_queue.size();
|
||||
return static_cast<int>(delta_queue.size());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user