Avoid redundant per-frame calls to getDbProp in CNetManager

This commit is contained in:
kaetemi 2013-07-28 05:10:06 +02:00
parent 70f83e1fb9
commit 8bbb438674
2 changed files with 20 additions and 6 deletions

View file

@ -3861,22 +3861,28 @@ bool CNetManager::update()
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false);
CCDBNodeLeaf *node = m_PingLeaf ? &*m_PingLeaf
: (m_PingLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false));
if (node)
node->setValue32(getPing());
node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false);
node = m_UploadLeaf ? &*m_UploadLeaf
: (m_UploadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false));
if (node)
node->setValue32((sint32)(getMeanUpload()*1024.f/8.f));
node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false);
node = m_DownloadLeaf ? &*m_DownloadLeaf
: (m_DownloadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false));
if (node)
node->setValue32((sint32)(getMeanDownload()*1024.f/8.f));
node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false);
node = m_PacketLostLeaf ? &* m_PacketLostLeaf
: (m_PacketLostLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false));
if (node)
node->setValue32((sint32)getMeanPacketLoss());
node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false);
node = m_ServerStateLeaf ? &*m_ServerStateLeaf
: (m_ServerStateLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false));
if (node)
node->setValue32((sint32)getConnectionState());
node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false);
node = m_ConnectionQualityLeaf ? &*m_ConnectionQualityLeaf
: (m_ConnectionQualityLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false));
if (node)
node->setValue32((sint32)getConnectionQuality());
}

View file

@ -43,6 +43,7 @@ void initializeNetwork();
namespace NLMISC
{
class CBitMemStream;
class CCDBNodeLeaf;
};
@ -126,6 +127,13 @@ public:
protected:
bool _IsReplayStarting;
#endif
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_PingLeaf;
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_UploadLeaf;
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_DownloadLeaf;
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_PacketLostLeaf;
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_ServerStateLeaf;
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> m_ConnectionQualityLeaf;
};