void crashGame() {
while (true) {
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
if (pInfo(currentPeer)->onCrash) {
pInfo(currentPeer)->crashRes += 0.01;
std::string ananss = std::to_string(pInfo(currentPeer)->crashRes);
size_t decimalPos = ananss.find('.');
if (decimalPos != std::string::npos && ananss.length() > decimalPos + 3) {
ananss = ananss.substr(0, decimalPos + 3);
}
gamepacket_t p;
p.Insert("OnTalkBubble");
p.Insert(pInfo(currentPeer)->netID);
p.Insert("`4Crash: `w" + ananss + "x");
p.Insert(0), p.Insert(0);
p.CreatePacket(currentPeer);
if (pInfo(currentPeer)->onCrash2) {
gamepacket_t p;
p.Insert("OnTalkBubble");
p.Insert(pInfo(currentPeer)->netID);
p.Insert("`2You stopped at: `w" + ananss + "x");
p.Insert(0), p.Insert(0);
p.CreatePacket(currentPeer);
pInfo(currentPeer)->onCrash = false;
pInfo(currentPeer)->crashRes = 0;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
}
}