This commit is contained in:
Vlad committed 2026-02-02 14:45:36 +06:00
1 parent 204b79bf06
commit 88f68b20ea
4 files changed
+63 -16

No files matched your search

+11 -7
View File
@@ -82,7 +82,7 @@ class Session : public std::enable_shared_from_this<Session> {
timedClientStates.add_state(receivedState);
}
else if (parts[0] == "FIRE") {
if (parts.size() < 8) {
if (parts.size() < 10) {
std::cerr << "Invalid FIRE: too few parts\n";
return;
}
@@ -91,17 +91,19 @@ class Session : public std::enable_shared_from_this<Session> {
Eigen::Vector3f pos{
std::stof(parts[2]), std::stof(parts[3]), std::stof(parts[4])
};
Eigen::Vector3f dir{
std::stof(parts[5]), std::stof(parts[6]), std::stof(parts[7])
Eigen::Quaternion dir{
std::stof(parts[5]), std::stof(parts[6]), std::stof(parts[7]), std::stof(parts[8])
};
int shotCount = 1;
if (parts.size() >= 9) {
float velocity = std::stof(parts[9]);
int shotCount = 2;
if (parts.size() >= 11) {
try {
shotCount = std::stoi(parts[8]);
shotCount = std::stoi(parts[10]);
}
catch (...) {
shotCount = 1;
shotCount = 2;
}
}
@@ -111,9 +113,11 @@ class Session : public std::enable_shared_from_this<Session> {
std::to_string(pos.x()) + ":" +
std::to_string(pos.y()) + ":" +
std::to_string(pos.z()) + ":" +
std::to_string(dir.w()) + ":" +
std::to_string(dir.x()) + ":" +
std::to_string(dir.y()) + ":" +
std::to_string(dir.z()) + ":" +
std::to_string(velocity) + ":" +
std::to_string(shotCount);
std::lock_guard<std::mutex> lock(g_sessions_mutex);