1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 17:27:47 +00:00

style + update name

This commit is contained in:
AriAvery 2018-11-23 09:42:51 +01:00
parent 4d132f87e4
commit 308a0cf00e
2 changed files with 13 additions and 4 deletions

View file

@ -367,9 +367,9 @@ bool Core::ServerMgr::isRunning() const
std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId ) std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId )
{ {
auto it = m_payerNameMap.find( playerId ); auto it = m_payerNameMapById.find( playerId );
if( it != m_payerNameMap.end() ) if( it != m_payerNameMapById.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 > >();
@ -380,11 +380,19 @@ std::string Core::ServerMgr::getPlayerNameFromDb( uint32_t playerId )
std::string playerName = res->getString( 1 ); std::string playerName = res->getString( 1 );
m_payerNameMap[ playerId ] = playerName; m_payerNameMapById[ playerId ] = playerName;
return playerName; return playerName;
} }
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 name = " + std::to_string( playerId ) );
m_payerNameMapById[ playerId ] = playerNewName;
}
void Core::ServerMgr::loadBNpcTemplates() void Core::ServerMgr::loadBNpcTemplates()
{ {
auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); auto pDb = g_fw.get< Db::DbWorkerPool< Db::ZoneDbConnection > >();

View file

@ -45,6 +45,7 @@ public:
Entity::BNpcTemplatePtr getBNpcTemplate( uint32_t id ); Entity::BNpcTemplatePtr getBNpcTemplate( uint32_t id );
std::string getPlayerNameFromDb( uint32_t playerId ); std::string getPlayerNameFromDb( uint32_t playerId );
void updatePlayerName( uint32_t playerId, const std::string& playerNewName );
private: private:
uint16_t m_port; uint16_t m_port;
@ -59,7 +60,7 @@ private:
std::map< uint32_t, SessionPtr > m_sessionMapById; std::map< uint32_t, SessionPtr > m_sessionMapById;
std::map< std::string, SessionPtr > m_sessionMapByName; std::map< std::string, SessionPtr > m_sessionMapByName;
std::map< uint32_t, std::string > m_payerNameMap; std::map< uint32_t, std::string > m_payerNameMapById;
std::map< uint32_t, uint32_t > m_zones; std::map< uint32_t, uint32_t > m_zones;
std::map< std::string, Entity::BNpcTemplatePtr > m_bNpcTemplateMap; std::map< std::string, Entity::BNpcTemplatePtr > m_bNpcTemplateMap;