This commit is contained in:
MarcEricMartel 2023-11-24 15:56:58 -05:00
parent 775c8cf26f
commit ea3d2ffc34
3 changed files with 7 additions and 4 deletions

View File

@ -52,7 +52,7 @@ void Connection::getPacks(SOCKET sock) {
Input in;
Sync sync;
lsPck = recvPacksFrom(sock, &m_buf, m_addr);
std::cout << "a";
for (auto& pck : lsPck) {
uint32_t bsize = m_buf.len - (pck - m_buf.ptr);
switch (netprot::getType(pck, 1)) {
@ -74,13 +74,15 @@ void Connection::getPacks(SOCKET sock) {
}
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns) {
while (m_last_out < m_output_manifest.size()) {
Output out = m_output_vector.at(m_last_out++);
while (!m_output_vector.empty()) {
std::cout << "c";
Output out = m_output_vector.front();
for (auto& [key, conn] : conns) {
if (m_playinfo.id == conn->GetHash(false))
continue;
sendPackTo<Output>(sock, &out, &m_bufout, conn->getAddr());
}
m_output_vector.pop_front();
}
}

View File

@ -45,7 +45,7 @@ private:
std::unordered_map<Timestamp, Input> m_input_manifest;
std::vector<Input> m_input_vector;
std::unordered_map<Timestamp, Output> m_output_manifest;
std::vector<Output> m_output_vector;
std::deque<Output> m_output_vector;
std::unordered_map<Timestamp, Chat> m_chatlog;
SOCKET m_sock;

View File

@ -206,6 +206,7 @@ void Server::Run() {
conn->getPacks(m_sock_udp);
if (conn->m_nsync) {
conn->Run(m_world);
std::cout << "b";
conn->sendPacks(m_sock_udp, m_players);
}
}