Superman + Alfred

This commit is contained in:
MarcEricMartel
2023-11-27 16:12:12 -05:00
parent cfc7f7e01d
commit e8ca08ecab
4 changed files with 36 additions and 7 deletions

View File

@@ -72,7 +72,9 @@ void Connection::getPacks(SOCKET sock) {
lsPck.clear();
}
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns) {
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer) {
static int outs = 0;
static Timestamp last = 0;
while (!m_output_vector.empty()) {
Output out = m_output_vector.front();
for (auto& [key, conn] : conns) {
@@ -83,6 +85,26 @@ void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*
sendPackTo<Output>(sock, &out, &m_bufout, conn->getAddr());
}
++outs;
[[unlikely]] if (last == 0) // !
last = out.timestamp;
outs += out.timestamp + last;
if (outs >= 1000) {
outs -= 1000;
Sync sync;
sync.hp = player.get()->GetHP();
sync.timestamp = out.timestamp;
sync.position = out.position;
sync.sid = m_loginfo.sid;
sync.timer = timer;
sync.timestamp = out.timestamp;
sync.ammo = -1;
sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr);
}
m_output_vector.pop_front();
}
}