Server state query works, client doesn't use the result yet

Both sides of this message uses QUERY_CHARACTER_EXISTS because I'm just
trying to push forward, without worrying about mistakes I might be making.
I just want to merge this back into the main branch so I can say that I've
actually done something over the last few months.
This commit is contained in:
Kayne Ruse
2014-12-11 08:02:38 +11:00
parent 72f641bf63
commit ae046977f0
6 changed files with 33 additions and 70 deletions
+1 -70
View File
@@ -101,73 +101,4 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket)
PumpPacket(argPacket);
}
//-------------------------
//mismanagement
//-------------------------
//SET: delete
void ServerApplication::HandleSynchronize(ClientPacket* const argPacket) {
//TODO: compensate for large distances
//NOTE: I quite dislike this function
//send all of the server's data to this client
ClientData* client = clientMgr.Get(argPacket->clientIndex);
//send all characters
CharacterPacket newPacket;
newPacket.type = SerialPacketType::CHARACTER_SET_ORIGIN;
for (auto& it : *characterMgr.GetContainer()) {
CopyCharacterToPacket(&newPacket, it.first);
network.SendTo(client->GetAddress(), static_cast<SerialPacket*>(&newPacket));
}
//TODO: more in HandleSynchronize()
}
//SET: utility/manager
void ServerApplication::CleanupLostConnection(int clientIndex) {
//NOTE: This assumes each player has only one account and character at a time
//TODO: handle multiple characters (bots, etc.)
//send a disconnection message just in case
ClientPacket newPacket;
newPacket.type = SerialPacketType::DISCONNECT_FORCED;
network.SendTo(clientMgr.Get(clientIndex)->GetAddress(), &newPacket);
//find the account
int accountIndex = -1;
for (auto& it : *accountMgr.GetContainer()) {
if (it.second.GetClientIndex() == clientIndex) {
accountIndex = it.first;
break;
}
}
//find the character
int characterIndex = -1;
for (auto& it : *characterMgr.GetContainer()) {
if (it.second.GetOwner() == accountIndex) {
characterIndex = it.first;
break;
}
}
//clean up this mess
characterMgr.Unload(characterIndex);
accountMgr.Unload(accountIndex);
clientMgr.Unload(clientIndex);
PumpCharacterUnload(characterIndex);
//output a message
std::cerr << "Connection lost: " << std::endl;
std::cerr << "\tClient: " << clientIndex << std::endl;
std::cerr << "\tAccount: " << accountIndex << std::endl;
std::cerr << "\tCharacter: " << characterIndex << std::endl;
std::cout << clientMgr.GetLoadedCount() << " clients and " << accountMgr.GetLoadedCount() << " accounts total" << std::endl;
}
//TODO: remove this terminate comment
//*/
*/