Added force disconnect from server

This commit is contained in:
Vladislav Khorev committed 2026-03-06 20:05:55 +03:00
1 parent 8528b4dc90
commit ac551122d9
9 files changed
+93 -3

No files matched your search

+23
View File
@@ -1822,6 +1822,18 @@ namespace ZL
void Space::update() {
if (networkClient) {
if (networkClient->IsConnected()) {
wasConnectedToServer = true;
}
else if (wasConnectedToServer && shipAlive && !gameOver) {
wasConnectedToServer = false;
shipAlive = false;
gameOver = true;
Environment::shipState.velocity = 0.0f;
std::cout << "Client: Lost connection to server\n";
menuManager.showGameOver(this->playerScore);
}
auto pending = networkClient->getPendingProjectiles();
if (!pending.empty()) {
const float projectileSpeed = PROJECTILE_VELOCITY;
@@ -1911,6 +1923,17 @@ namespace ZL
}
}
auto disconnects = networkClient->getPendingDisconnects();
for (int pid : disconnects) {
remotePlayerStates.erase(pid);
deadRemotePlayers.erase(pid);
if (trackedTargetId == pid) {
trackedTargetId = -1;
targetAcquireAnim = 0.f;
}
std::cout << "Client: Remote player " << pid << " left the game, removed from scene\n";
}
auto boxDestructions = networkClient->getPendingBoxDestructions();
if (!boxDestructions.empty()) {
std::cout << "Game: Received " << boxDestructions.size() << " box destruction events" << std::endl;