1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00
This commit is contained in:
AriAvery 2018-11-23 11:46:39 +01:00
parent d1dc8c937d
commit bd315d9b45
3 changed files with 15 additions and 8 deletions

View file

@ -1533,6 +1533,13 @@ uint32_t Core::Entity::Player::getTerritoryTypeId() const
void Core::Entity::Player::sendZonePackets() void Core::Entity::Player::sendZonePackets()
{ {
if( isLogin() )
{
//Update player map in servermgr - in case player name has been changed
auto pServerMgr = g_fw.get< Core::ServerMgr >();
pServerMgr->updatePlayerName( getId(), getName() );
}
getCurrentZone()->onBeforePlayerZoneIn( *this ); getCurrentZone()->onBeforePlayerZoneIn( *this );
auto initPacket = makeZonePacket< FFXIVIpcInit >( getId() ); auto initPacket = makeZonePacket< FFXIVIpcInit >( getId() );

View file

@ -365,12 +365,15 @@ bool Core::ServerMgr::isRunning() const
return m_bRunning; return m_bRunning;
} }
std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId ) std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId, bool forceDbLoad )
{ {
if( !forceDbLoad )
{
auto it = m_playerNameMapById.find( playerId ); auto it = m_playerNameMapById.find( playerId );
if( it != m_playerNameMapById.end() ) if( it != m_playerNameMapById.end() )
return ( it->second ); return ( it->second );
}
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto res = pDb->query( "SELECT name FROM charainfo WHERE characterid = " + std::to_string( playerId ) ); auto res = pDb->query( "SELECT name FROM charainfo WHERE characterid = " + std::to_string( playerId ) );
@ -387,9 +390,6 @@ std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId )
void Core::ServerMgr::updatePlayerName( uint32_t playerId, const std::string & playerNewName ) void Core::ServerMgr::updatePlayerName( uint32_t playerId, const std::string & playerNewName )
{ {
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
pDb->execute( "UPDATE charainfo SET name = '" + playerNewName + "' WHERE characterid = " + std::to_string( playerId ) );
m_playerNameMapById[ playerId ] = playerNewName; m_playerNameMapById[ playerId ] = playerNewName;
} }

View file

@ -44,7 +44,7 @@ public:
Entity::BNpcTemplatePtr getBNpcTemplate( const std::string& key ); Entity::BNpcTemplatePtr getBNpcTemplate( const std::string& key );
Entity::BNpcTemplatePtr getBNpcTemplate( uint32_t id ); Entity::BNpcTemplatePtr getBNpcTemplate( uint32_t id );
std::string getPlayerNameFromDb( uint32_t playerId ); std::string getPlayerNameFromDb( uint32_t playerId, bool forceDbLoad = false );
void updatePlayerName( uint32_t playerId, const std::string& playerNewName ); void updatePlayerName( uint32_t playerId, const std::string& playerNewName );
private: private: