Nothing special, just commiting minor changes
This commit is contained in:
@@ -150,7 +150,7 @@ void ServerApplication::HandlePacket(NetworkPacket packet) {
|
|||||||
HandleDisconnect(packet);
|
HandleDisconnect(packet);
|
||||||
break;
|
break;
|
||||||
case NetworkPacket::Type::SYNCHRONIZE:
|
case NetworkPacket::Type::SYNCHRONIZE:
|
||||||
// HandleSynchronize(packet);
|
HandleSynchronize(packet);
|
||||||
break;
|
break;
|
||||||
case NetworkPacket::Type::SHUTDOWN:
|
case NetworkPacket::Type::SHUTDOWN:
|
||||||
HandleShutdown(packet);
|
HandleShutdown(packet);
|
||||||
@@ -227,7 +227,7 @@ void ServerApplication::HandleDisconnect(NetworkPacket packet) {
|
|||||||
//finished this routine
|
//finished this routine
|
||||||
cout << "disconnect, total: " << clientMgr.Size() << endl;
|
cout << "disconnect, total: " << clientMgr.Size() << endl;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
void ServerApplication::HandleSynchronize(NetworkPacket packet) {
|
void ServerApplication::HandleSynchronize(NetworkPacket packet) {
|
||||||
//send all the server's data to this client
|
//send all the server's data to this client
|
||||||
//TODO: compensate for large distances
|
//TODO: compensate for large distances
|
||||||
@@ -235,18 +235,19 @@ void ServerApplication::HandleSynchronize(NetworkPacket packet) {
|
|||||||
char buffer[sizeof(NetworkPacket)];
|
char buffer[sizeof(NetworkPacket)];
|
||||||
|
|
||||||
//players
|
//players
|
||||||
|
//TODO: replace these lambda functions with proper iteration members
|
||||||
newPacket.meta.type = NetworkPacket::Type::PLAYER_UPDATE;
|
newPacket.meta.type = NetworkPacket::Type::PLAYER_UPDATE;
|
||||||
for (auto& it : playerMap) {
|
playerMgr.ForEach([&](PlayerManager::Iterator it) {
|
||||||
newPacket.playerInfo.playerIndex = it.first;
|
newPacket.playerInfo.playerIndex = it->first;
|
||||||
snprintf(newPacket.playerInfo.handle, PACKET_STRING_SIZE, "%s", it.second.handle.c_str());
|
// snprintf(newPacket.playerInfo.handle, PACKET_STRING_SIZE, "%s", it->second.handle.c_str());
|
||||||
snprintf(newPacket.playerInfo.avatar, PACKET_STRING_SIZE, "%s", it.second.avatar.c_str());
|
// snprintf(newPacket.playerInfo.avatar, PACKET_STRING_SIZE, "%s", it->second.avatar.c_str());
|
||||||
newPacket.playerInfo.position = it.second.position;
|
newPacket.playerInfo.position = it->second.position;
|
||||||
newPacket.playerInfo.motion = it.second.motion;
|
newPacket.playerInfo.motion = it->second.motion;
|
||||||
serialize(&newPacket, buffer);
|
serialize(&newPacket, buffer);
|
||||||
network.Send(&clientMap[packet.clientInfo.index].address, buffer, sizeof(NetworkPacket));
|
network.Send(&clientMgr.GetClient(it->second.clientIndex)->address, buffer, sizeof(NetworkPacket));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
void ServerApplication::HandleShutdown(NetworkPacket packet) {
|
void ServerApplication::HandleShutdown(NetworkPacket packet) {
|
||||||
//end the server
|
//end the server
|
||||||
running = false;
|
running = false;
|
||||||
@@ -320,7 +321,6 @@ void ServerApplication::HandlePlayerUpdate(NetworkPacket packet) {
|
|||||||
PumpPacket(packet);
|
PumpPacket(packet);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ServerApplication::PumpPacket(NetworkPacket packet) {
|
void ServerApplication::PumpPacket(NetworkPacket packet) {
|
||||||
//I don't really like this, but it'll do for now
|
//I don't really like this, but it'll do for now
|
||||||
char buffer[sizeof(NetworkPacket)];
|
char buffer[sizeof(NetworkPacket)];
|
||||||
|
|||||||
Reference in New Issue
Block a user