EH LALA.
This commit is contained in:
parent
c24123362a
commit
9a7d25c1d9
@ -21,7 +21,7 @@ uint64_t Connection::GetTeamHash() const { return m_loginfo.tid; }
|
||||
|
||||
std::string Connection::GetName() const { return m_loginfo.name; }
|
||||
|
||||
void Connection::AddInput(Input in) { m_input_manifest.insert({ in.timestamp, in }); }
|
||||
void Connection::AddInput(Input in) { m_input_manifest.insert({ in.timestamp, in }); m_input_vector.push_back(in); }
|
||||
|
||||
Output* Connection::getOutput(Timestamp time) {
|
||||
auto out = m_output_manifest.find(time);
|
||||
@ -52,7 +52,6 @@ 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)) {
|
||||
@ -79,7 +78,8 @@ void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*
|
||||
for (auto& [key, conn] : conns) {
|
||||
if (m_playinfo.id == conn->GetHash(false))
|
||||
continue;
|
||||
std::cout << "c";
|
||||
//std::cout << m_playinfo.id << ": " << m_playinfo.name << ": " << conn->GetName() << std::endl;
|
||||
std::cout << out.id << ": " << out.position << std::endl;
|
||||
sendPackTo<Output>(sock, &out, &m_bufout, conn->getAddr());
|
||||
}
|
||||
m_output_vector.pop_front();
|
||||
|
@ -149,6 +149,7 @@ int Server::Ready() {
|
||||
sendPack<LoginInfo>(sock, log, &m_buf);
|
||||
|
||||
play.id = getUniqueId();
|
||||
play.tid = log->tid;
|
||||
strcpy(play.name, log->name);
|
||||
|
||||
Log(str.append(play.name).append(" SID: [").append(std::to_string(log->sid)).append("]")
|
||||
@ -205,10 +206,32 @@ void Server::Run() {
|
||||
|
||||
while (!endgame) {
|
||||
for (auto& [key, conn] : m_players) {
|
||||
conn->getPacks(m_sock_udp);
|
||||
std::vector<char*> lsPck;
|
||||
Input in;
|
||||
Sync sync;
|
||||
lsPck = recvPacks(m_sock_udp, &m_buf);
|
||||
for (auto& pck : lsPck) {
|
||||
uint32_t bsize = m_buf.len - (pck - m_buf.ptr);
|
||||
switch (netprot::getType(pck, 1)) {
|
||||
using enum netprot::PACKET_TYPE;
|
||||
case INPUT:
|
||||
if (Deserialize(&in, pck, &bsize)) {
|
||||
m_players[in.sid]->AddInput(in);
|
||||
//m_input_manifest[in.timestamp] = in;
|
||||
//m_input_vector.push_back(in);
|
||||
}
|
||||
break;
|
||||
case SYNC:
|
||||
if (Deserialize(&sync, pck, &bsize)) {}
|
||||
//m_nsync = true;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
lsPck.clear();
|
||||
//conn->getPacks(conn->getSock());
|
||||
if (conn->m_nsync) {
|
||||
conn->Run(m_world);
|
||||
std::cout << "b";
|
||||
conn->sendPacks(m_sock_udp, m_players);
|
||||
}
|
||||
}
|
||||
|
@ -871,7 +871,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
fPosY = fPosYJump;
|
||||
fPosY -= charSize;
|
||||
|
||||
ss << " Velocity : " << m_otherplayerpos;
|
||||
ss << " Velocity : " << m_player.GetVelocity();
|
||||
PrintText(fPosX, fPosY, ss.str());
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
@ -881,7 +881,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
|
||||
ss << " Remote Position : " << m_remotePlayer.GetPosition();//m_player.GetPosition();
|
||||
ss << " Remote Position : " << m_otherplayerpos;
|
||||
PrintText(fPosX, fPosY, ss.str());
|
||||
ss.str("");
|
||||
fPosY -= charSize;
|
||||
|
Loading…
Reference in New Issue
Block a user