fix: get entity from manager vs from character

fixes a possible crash due to null entity
This commit is contained in:
David Markowitz 2025-06-26 00:35:45 -07:00
parent 1f580491c7
commit e76d70c9c4
2 changed files with 2 additions and 1 deletions

View File

@ -167,6 +167,7 @@ Entity::~Entity() {
if (m_Character) {
m_Character->SaveXMLToDatabase();
m_Character->SetEntity(nullptr);
}
CancelAllTimers();

View File

@ -526,7 +526,7 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneID, character->GetZoneClone(), false, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (character) {
auto* entity = character->GetEntity();
auto* entity = Game::entityManager->GetEntity(character->GetObjectID());
if (entity) {
auto* characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent) {