Jim Babwe
This commit is contained in:
parent
bd14cd3962
commit
573316682b
@ -471,8 +471,6 @@ bool netprot::Deserialize(Input* in, char* buf, uint32_t *buflen) {
|
||||
|
||||
memcpy(&in->direction, vec, sizeof(uint32_t) * 3);
|
||||
|
||||
in->direction.Afficher();
|
||||
|
||||
*buflen = sizeof(uint64_t) * 2 + 2 + sizeof(uint32_t) * 3;
|
||||
|
||||
return true;
|
||||
|
@ -52,6 +52,10 @@ void Connection::getPacks(SOCKET sock) {
|
||||
Input in;
|
||||
while (true) {
|
||||
lsPck = recvPacksFrom(sock, &m_buf, m_addr);
|
||||
|
||||
if (lsPck.empty() && !m_buf.tmp)
|
||||
break;
|
||||
|
||||
for (auto& pck : lsPck) {
|
||||
uint32_t bsize = m_buf.len - (pck - m_buf.ptr);
|
||||
switch (netprot::getType(pck, 1)) {
|
||||
@ -59,8 +63,7 @@ void Connection::getPacks(SOCKET sock) {
|
||||
case INPUT:
|
||||
if (Deserialize(&in, pck, &bsize)) {
|
||||
m_input_manifest[in.timestamp] = in;
|
||||
if (in.keys.forward == true)
|
||||
std::cout << "!!!!";
|
||||
m_input_vector.push_back(in);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
@ -72,8 +75,7 @@ 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_manifest.at(m_last_out++);
|
||||
std::cout << "bip";
|
||||
Output out = m_output_vector.at(m_last_out++);
|
||||
for (auto& [key, conn] : conns) {
|
||||
if (m_playinfo.id == conn->GetHash(true))
|
||||
continue;
|
||||
@ -90,9 +92,9 @@ void Connection::Run(World* world) {
|
||||
if (m_input_manifest.size() < 2)
|
||||
return;
|
||||
|
||||
while (m_last_in < m_input_manifest.size()) {
|
||||
in = m_input_manifest.at(m_last_in + 1);
|
||||
last = m_input_manifest.at(m_last_in);
|
||||
while (m_last_in < m_input_vector.size() - 1) {
|
||||
in = m_input_vector.at(m_last_in + 1);
|
||||
last = m_input_vector.at(m_last_in);
|
||||
|
||||
el = (float)(in.timestamp - last.timestamp) / 1000.;
|
||||
player.get()->SetDirection(in.direction);
|
||||
@ -108,6 +110,7 @@ void Connection::Run(World* world) {
|
||||
out.id = m_playinfo.id;
|
||||
|
||||
m_output_manifest[out.timestamp] = out;
|
||||
m_output_vector.push_back(out);
|
||||
|
||||
++m_last_in;
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
void CleanInputManifest(Timestamp time);
|
||||
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::unordered_map<Timestamp, Chat> m_chatlog;
|
||||
|
||||
SOCKET m_sock;
|
||||
|
@ -201,6 +201,8 @@ void Server::Run() {
|
||||
sendPack<Sync>(conn->getSock(), &sync, &m_buf);
|
||||
}
|
||||
|
||||
std::cout << players << " players." << std::endl;
|
||||
|
||||
while (!endgame) {
|
||||
for (auto& [key, conn] : m_players) {
|
||||
conn->getPacks(m_sock_udp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user