mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
fix: deleting last character still shows the character (#1123)
* Fix deleting last character Fix an issue where deleting your last character caused the character to still show up on the character selection screen. Tested that deleting my final character results in an empty character selection scene. * Update UserManager.cpp
This commit is contained in:
parent
51540568fb
commit
44f466ac72
@ -204,40 +204,38 @@ void UserManager::RequestCharacterList(const SystemAddress& sysAddr) {
|
||||
stmt->setUInt(1, u->GetAccountID());
|
||||
|
||||
sql::ResultSet* res = stmt->executeQuery();
|
||||
if (res->rowsCount() > 0) {
|
||||
std::vector<Character*>& chars = u->GetCharacters();
|
||||
|
||||
for (size_t i = 0; i < chars.size(); ++i) {
|
||||
if (chars[i]->GetEntity() == nullptr) // We don't have entity data to save
|
||||
{
|
||||
delete chars[i];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* skillComponent = chars[i]->GetEntity()->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent != nullptr) {
|
||||
skillComponent->Reset();
|
||||
}
|
||||
|
||||
Game::entityManager->DestroyEntity(chars[i]->GetEntity());
|
||||
|
||||
chars[i]->SaveXMLToDatabase();
|
||||
|
||||
chars[i]->GetEntity()->SetCharacter(nullptr);
|
||||
std::vector<Character*>& chars = u->GetCharacters();
|
||||
|
||||
for (size_t i = 0; i < chars.size(); ++i) {
|
||||
if (chars[i]->GetEntity() == nullptr) // We don't have entity data to save
|
||||
{
|
||||
delete chars[i];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
chars.clear();
|
||||
auto* skillComponent = chars[i]->GetEntity()->GetComponent<SkillComponent>();
|
||||
|
||||
while (res->next()) {
|
||||
LWOOBJID objID = res->getUInt64(1);
|
||||
Character* character = new Character(uint32_t(objID), u);
|
||||
character->SetIsNewLogin();
|
||||
chars.push_back(character);
|
||||
if (skillComponent != nullptr) {
|
||||
skillComponent->Reset();
|
||||
}
|
||||
|
||||
Game::entityManager->DestroyEntity(chars[i]->GetEntity());
|
||||
|
||||
chars[i]->SaveXMLToDatabase();
|
||||
|
||||
chars[i]->GetEntity()->SetCharacter(nullptr);
|
||||
|
||||
delete chars[i];
|
||||
}
|
||||
|
||||
chars.clear();
|
||||
|
||||
while (res->next()) {
|
||||
LWOOBJID objID = res->getUInt64(1);
|
||||
Character* character = new Character(uint32_t(objID), u);
|
||||
character->SetIsNewLogin();
|
||||
chars.push_back(character);
|
||||
}
|
||||
|
||||
delete res;
|
||||
|
Loading…
Reference in New Issue
Block a user