From f78b08b5effbc57013e8535f9dadb0e73b58ae23 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 28 Jul 2013 08:16:02 +0200 Subject: [PATCH] Avoid redundant per-frame calls to getDbProp("UI:SAVE:USER_CHAR_FADE") --- code/ryzom/client/src/cursor_functions.cpp | 4 +++- code/ryzom/client/src/r2/tool.cpp | 4 +++- code/ryzom/client/src/r2/tool.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index a51877be1..902e63875 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -58,6 +58,7 @@ uint32 MissionRingId = 0; UInstance selectedInstance; const UInstance noSelectedInstance; string selectedInstanceURL; +static NLMISC::CRefPtr s_UserCharFade; /////////////// @@ -273,7 +274,8 @@ void checkUnderCursor() entity= EntitiesMngr.getEntityUnderPos(cursX, cursY, ClientCfg.SelectionDist, isPlayerUnderCursor); // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = s_UserCharFade ? &*s_UserCharFade + : (s_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index ddc97fb95..f11476930 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -55,6 +55,7 @@ const uint32 DEFAULT_ENTITY_MIN_OPACITY = 128; bool CTool::_MouseCaptured = false; +NLMISC::CRefPtr CTool::_UserCharFade; static const CVector cardinals[] = { @@ -551,7 +552,8 @@ void CTool::handleMouseOverPlayer(bool over) { //H_AUTO(R2_CTool_handleMouseOverPlayer) // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = _UserCharFade ? &*_UserCharFade + : (_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index f7262efc4..d36c514c1 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -284,6 +284,7 @@ private: sint64 _AutoPanDelay; sint64 _NumPans; static bool _MouseCaptured; + static NLMISC::CRefPtr _UserCharFade; private: /** compute the nearest valid surface at a given position from the island heightmap * (heightmap must not be empty or an assertion is raised)