mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-22 08:31:07 +00:00
add map info code
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
#include "ProtocolVersion.h"
|
#include "ProtocolVersion.h"
|
||||||
#include "ServerInfo.h"
|
#include "ServerInfo.h"
|
||||||
|
#include "Transport.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
@@ -73,6 +74,7 @@ void ServerNetwork::handle_packet(const bmp::Packet& packet) {
|
|||||||
handle_mod_download(packet);
|
handle_mod_download(packet);
|
||||||
break;
|
break;
|
||||||
case bmp::State::SessionSetup:
|
case bmp::State::SessionSetup:
|
||||||
|
handle_session_setup(packet);
|
||||||
break;
|
break;
|
||||||
case bmp::State::Playing:
|
case bmp::State::Playing:
|
||||||
break;
|
break;
|
||||||
@@ -99,6 +101,13 @@ void ServerNetwork::handle_mod_download(const bmp::Packet& packet) {
|
|||||||
tcp_write(ok);
|
tcp_write(ok);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case bmp::Purpose::MapInfo: {
|
||||||
|
auto data = packet.get_readable_data();
|
||||||
|
std::string map(data.begin(), data.end());
|
||||||
|
// TODO: Send to game
|
||||||
|
spdlog::debug("Map: '{}'", map);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case bmp::Purpose::StateChangeSessionSetup: {
|
case bmp::Purpose::StateChangeSessionSetup: {
|
||||||
spdlog::info("Starting session setup");
|
spdlog::info("Starting session setup");
|
||||||
m_state = bmp::State::SessionSetup;
|
m_state = bmp::State::SessionSetup;
|
||||||
@@ -253,3 +262,16 @@ void ServerNetwork::udp_write(bmp::Packet& packet) {
|
|||||||
std::copy(packet.raw_data.begin(), packet.raw_data.end(), data.begin() + static_cast<long>(offset));
|
std::copy(packet.raw_data.begin(), packet.raw_data.end(), data.begin() + static_cast<long>(offset));
|
||||||
m_udp_socket.send_to(buffer(data), m_udp_ep, {});
|
m_udp_socket.send_to(buffer(data), m_udp_ep, {});
|
||||||
}
|
}
|
||||||
|
void ServerNetwork::handle_session_setup(const bmp::Packet& packet) {
|
||||||
|
switch (packet.purpose) {
|
||||||
|
case bmp::Purpose::PlayersVehiclesInfo: {
|
||||||
|
spdlog::debug("Players and vehicles info: {} bytes ({} bytes on arrival)", packet.get_readable_data().size(), packet.raw_data.size());
|
||||||
|
// TODO: Send to game
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
spdlog::error("Got 0x{:x} in state {}. This is not allowed. Disconnecting", uint16_t(packet.purpose), int(m_state));
|
||||||
|
// todo: disconnect gracefully
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ private:
|
|||||||
void handle_identification(const bmp::Packet& packet);
|
void handle_identification(const bmp::Packet& packet);
|
||||||
void handle_authentication(const bmp::Packet& packet);
|
void handle_authentication(const bmp::Packet& packet);
|
||||||
void handle_mod_download(const bmp::Packet& packet);
|
void handle_mod_download(const bmp::Packet& packet);
|
||||||
|
void handle_session_setup(const bmp::Packet& packet);
|
||||||
|
|
||||||
io_context m_io {};
|
io_context m_io {};
|
||||||
ip::tcp::socket m_tcp_socket { m_io };
|
ip::tcp::socket m_tcp_socket { m_io };
|
||||||
|
|||||||
Reference in New Issue
Block a user