Fixed the crash bug
This commit is contained in:
@@ -218,7 +218,7 @@ void ServerApplication::HandleDisconnect(NetworkPacket packet) {
|
|||||||
|
|
||||||
erase_if(playerMap, [&](std::pair<int, PlayerEntry> it) -> bool {
|
erase_if(playerMap, [&](std::pair<int, PlayerEntry> it) -> bool {
|
||||||
//find the internal players to delete
|
//find the internal players to delete
|
||||||
if (it.first == packet.clientInfo.index) {
|
if (it.second.clientIndex == packet.clientInfo.index) {
|
||||||
delPacket.playerInfo.playerIndex = it.first;
|
delPacket.playerInfo.playerIndex = it.first;
|
||||||
//send the delete player command to all clients
|
//send the delete player command to all clients
|
||||||
PumpPacket(delPacket);
|
PumpPacket(delPacket);
|
||||||
@@ -246,7 +246,7 @@ void ServerApplication::HandleSynchronize(NetworkPacket packet) {
|
|||||||
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[it.second.clientIndex].address, buffer, sizeof(NetworkPacket));
|
network.Send(&clientMap[packet.clientInfo.index].address, buffer, sizeof(NetworkPacket));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,9 +256,7 @@ void ServerApplication::HandleShutdown(NetworkPacket packet) {
|
|||||||
|
|
||||||
//disconnect all clients
|
//disconnect all clients
|
||||||
packet.meta.type = NetworkPacket::Type::DISCONNECT;
|
packet.meta.type = NetworkPacket::Type::DISCONNECT;
|
||||||
for (auto& it : clientMap) {
|
PumpPacket(packet);
|
||||||
network.Send(&it.second.address, &packet, sizeof(NetworkPacket));
|
|
||||||
}
|
|
||||||
|
|
||||||
//finished this routine
|
//finished this routine
|
||||||
cout << "shutting down" << endl;
|
cout << "shutting down" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user