mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
saving player names in map to reduce SQL query
This commit is contained in:
parent
7721f63f51
commit
4d132f87e4
2 changed files with 11 additions and 1 deletions
|
@ -367,13 +367,22 @@ bool Core::ServerMgr::isRunning() const
|
|||
|
||||
std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId )
|
||||
{
|
||||
auto it = m_payerNameMap.find( playerId );
|
||||
|
||||
if( it != m_payerNameMap.end() )
|
||||
return ( it->second );
|
||||
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto res = pDb->query( "SELECT name FROM charainfo WHERE characterid = " + std::to_string( playerId ) );
|
||||
|
||||
if( !res->next() )
|
||||
return "Unknown";
|
||||
|
||||
return res->getString( 1 );
|
||||
std::string playerName = res->getString( 1 );
|
||||
|
||||
m_payerNameMap[ playerId ] = playerName;
|
||||
|
||||
return playerName;
|
||||
}
|
||||
|
||||
void Core::ServerMgr::loadBNpcTemplates()
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
|
||||
std::map< uint32_t, SessionPtr > m_sessionMapById;
|
||||
std::map< std::string, SessionPtr > m_sessionMapByName;
|
||||
std::map< uint32_t, std::string > m_payerNameMap;
|
||||
std::map< uint32_t, uint32_t > m_zones;
|
||||
std::map< std::string, Entity::BNpcTemplatePtr > m_bNpcTemplateMap;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue