Implemented 'full unload' methods, not used yet

This commit is contained in:
Kayne Ruse
2014-12-19 15:52:05 +11:00
parent 7962692641
commit 0d9dfad4a5
2 changed files with 65 additions and 0 deletions
+3
View File
@@ -96,6 +96,9 @@ private:
void HandleCharacterExists(CharacterPacket* const);
void SaveServerState();
void FullClientUnload(int index);
void FullAccountUnload(int index);
void FullCharacterUnload(int index);
//character management
void HandleCharacterCreate(CharacterPacket* const);
+62
View File
@@ -79,3 +79,65 @@ void ServerApplication::HandleShutdownRequest(ClientPacket* const argPacket) {
//finished this routine
std::cout << "Shutdown signal accepted" << std::endl;
}
//-------------------------
//full unload methods
//-------------------------
void ServerApplication::FullClientUnload(int index) {
clientMgr.UnloadIf([&](std::pair<const int, ClientData> client) -> bool {
//skip the wrong clients
if (client.first != index) {
return false;
}
//unload associated accounts
for (auto& it : *accountMgr.GetContainer()) {
if (it.second.GetClientIndex() == index) {
FullAccountUnload(it.first);
}
}
//unload this client
return true;
});
}
void ServerApplication::FullAccountUnload(int index) {
accountMgr.UnloadIf([&](std::pair<const int, AccountData> account) -> bool {
//skip the wrong accounts
if (account.first != index) {
return false;
}
//unload associated characters
for (auto& it : *characterMgr.GetContainer()) {
if (it.second.GetOwner() == index) {
FullCharacterUnload(it.first);
}
}
//unload this account
return true;
});
}
void ServerApplication::FullCharacterUnload(int index) {
characterMgr.UnloadIf([&](std::pair<const int, CharacterData> character) -> bool {
//skip the wrong characters
if (character.first != index) {
return false;
}
//pump character unload
CharacterPacket newPacket;
newPacket.type = SerialPacketType::CHARACTER_DELETE;
newPacket.characterIndex = character.first;
//NOTE: more character info as needed
PumpPacket(&newPacket);
//unload this character
return true;
});
}