fixed: Box destroition

This commit is contained in:
Ariari04 2026-03-04 16:37:00 +06:00
parent 78046e5e2d
commit 05a13a40e7
3 changed files with 20 additions and 7 deletions

View File

@ -176,9 +176,18 @@ private:
std::lock_guard<std::mutex> lock(g_boxes_mutex); std::lock_guard<std::mutex> lock(g_boxes_mutex);
std::string boxMsg = "BOXES:"; std::string boxMsg = "BOXES:";
bool first = true;
for (size_t i = 0; i < g_serverBoxes.size(); ++i) { for (size_t i = 0; i < g_serverBoxes.size(); ++i) {
const auto& box = g_serverBoxes[i]; const auto& box = g_serverBoxes[i];
if (box.destroyed) continue;
Eigen::Quaternionf q(box.rotation); Eigen::Quaternionf q(box.rotation);
if (!first) boxMsg += "|";
first = false;
boxMsg += std::to_string(i) + ":" + boxMsg += std::to_string(i) + ":" +
std::to_string(box.position.x()) + ":" + std::to_string(box.position.x()) + ":" +
std::to_string(box.position.y()) + ":" + std::to_string(box.position.y()) + ":" +
@ -187,10 +196,10 @@ private:
std::to_string(q.x()) + ":" + std::to_string(q.x()) + ":" +
std::to_string(q.y()) + ":" + std::to_string(q.y()) + ":" +
std::to_string(q.z()) + ":" + std::to_string(q.z()) + ":" +
(std::to_string(box.destroyed ? 1 : 0)) + "|"; "0";
} }
if (!boxMsg.empty() && boxMsg.back() == '|') boxMsg.pop_back();
// Если все коробки уничтожены — отправится просто "BOXES:" (это нормально)
send_message(boxMsg); send_message(boxMsg);
} }

View File

@ -350,6 +350,10 @@ namespace ZL
} }
boxAlive.resize(boxCoordsArr.size(), true); boxAlive.resize(boxCoordsArr.size(), true);
#ifdef NETWORK
std::fill(boxAlive.begin(), boxAlive.end(), false);
serverBoxesApplied = false;
#endif
ZL::CheckGlError(); ZL::CheckGlError();
boxLabels.clear(); boxLabels.clear();
boxLabels.reserve(boxCoordsArr.size()); boxLabels.reserve(boxCoordsArr.size());
@ -662,10 +666,10 @@ namespace ZL
boxRenderArr[i].RefreshVBO(); boxRenderArr[i].RefreshVBO();
} }
boxAlive.assign(boxCoordsArr.size(), true); boxAlive.assign(boxCoordsArr.size(), true);
if (destroyedFlags.size() == boxAlive.size()) {
for (size_t i = 0; i < boxAlive.size(); ++i) { size_t n = (std::min)(destroyedFlags.size(), boxAlive.size());
if (destroyedFlags[i]) boxAlive[i] = false; for (size_t i = 0; i < n; ++i) {
} if (destroyedFlags[i]) boxAlive[i] = false; // destroyed => не рисуем
} }
serverBoxesApplied = true; serverBoxesApplied = true;
} }

View File

@ -144,7 +144,7 @@ namespace ZL {
if (msg.rfind("PROJECTILE:", 0) == 0) { if (msg.rfind("PROJECTILE:", 0) == 0) {
//auto parts = split(msg, ':'); //auto parts = split(msg, ':');
if (parts.size() >= 10) { if (parts.size() >= 11) {
try { try {
ProjectileInfo pi; ProjectileInfo pi;
pi.shooterId = std::stoi(parts[1]); pi.shooterId = std::stoi(parts[1]);