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:
@@ -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
|
||||
//*/
|
||||
*/
|
||||
Reference in New Issue
Block a user