Avoid redundant calls to getDbProp in CEntityCL
This commit is contained in:
parent
041bf4cd99
commit
592e0d5e3e
3 changed files with 51 additions and 13 deletions
|
@ -435,28 +435,47 @@ void CEntityManager::initialize(uint nbMaxEntity)
|
|||
for (i=0; i<MAX_NUM_MISSIONS; i++)
|
||||
for (j=0; j<MAX_NUM_MISSION_TARGETS; j++)
|
||||
{
|
||||
textId = ICDBNode::CTextId( "SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE" );
|
||||
std::string text = toString("SERVER:MISSIONS:%d:TARGET%d:TITLE", i, j);
|
||||
textId = ICDBNode::CTextId(text);
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&MissionTargetObserver, textId );
|
||||
_MissionTargetTitleDB[i][j] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_MissionTargetTitleDB[i][j]);
|
||||
}
|
||||
|
||||
// Add an Observer to the Team database
|
||||
for (i=0; i<MaxNumPeopleInTeam; i++)
|
||||
{
|
||||
textId = ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:UID", i) );
|
||||
std::string text = toString(TEAM_DB_PATH ":%d:UID", i);
|
||||
textId = ICDBNode::CTextId(text);
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamUIDObserver, textId );
|
||||
_GroupMemberUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_GroupMemberUidDB[i]);
|
||||
|
||||
textId = ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:NAME", i) );
|
||||
text = toString(TEAM_DB_PATH ":%d:NAME", i);
|
||||
textId = ICDBNode::CTextId(text);
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamPresentObserver, textId );
|
||||
_GroupMemberNameDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_GroupMemberNameDB[i]);
|
||||
}
|
||||
|
||||
// Add an Observer to the Animal database
|
||||
for (i=0; i<MAX_INVENTORY_ANIMAL; i++)
|
||||
{
|
||||
textId = ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:UID",i) );
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalUIDObserver, textId );
|
||||
std::string text = toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i);
|
||||
textId = ICDBNode::CTextId(text);
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalUIDObserver, textId);
|
||||
_BeastUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_BeastUidDB[i]);
|
||||
|
||||
textId = ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i) );
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId );
|
||||
text = toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i);
|
||||
textId = ICDBNode::CTextId(text);
|
||||
NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId);
|
||||
_BeastStatusDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_BeastStatusDB[i]);
|
||||
|
||||
text = toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i);
|
||||
_BeastTypeDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false);
|
||||
nlassert(_BeastTypeDB[i]);
|
||||
}
|
||||
|
||||
}// initialize //
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include "ground_fx_manager.h"
|
||||
#include "projectile_manager.h"
|
||||
#include "user_entity.h"
|
||||
// Some constants
|
||||
#include "game_share/mission_desc.h"
|
||||
#include "interface_v3/people_interraction.h"
|
||||
#include "game_share/inventories.h"
|
||||
// Misc.
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/stream.h"
|
||||
|
@ -149,6 +153,14 @@ private:
|
|||
|
||||
NL3D::UInstance _LastInstanceUnderPos;
|
||||
|
||||
// DB node pointers used to update some entity flags
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _MissionTargetTitleDB[MAX_NUM_MISSIONS][MAX_NUM_MISSION_TARGETS];
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _GroupMemberUidDB[MaxNumPeopleInTeam];
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _GroupMemberNameDB[MaxNumPeopleInTeam];
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _BeastUidDB[MAX_INVENTORY_ANIMAL];
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _BeastStatusDB[MAX_INVENTORY_ANIMAL];
|
||||
NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _BeastTypeDB[MAX_INVENTORY_ANIMAL];
|
||||
|
||||
//////////////
|
||||
//// DEBUG ///
|
||||
uint _NbUser;
|
||||
|
@ -344,6 +356,13 @@ public:
|
|||
*/
|
||||
void refreshInsceneInterfaceOfFriendNPC(uint slot);
|
||||
|
||||
inline NLMISC::CCDBNodeLeaf *getMissionTargetTitleDB(int mission, int target) { return _MissionTargetTitleDB[mission][target]; }
|
||||
inline NLMISC::CCDBNodeLeaf *getGroupMemberUidDB(int member) { return _GroupMemberUidDB[member]; }
|
||||
inline NLMISC::CCDBNodeLeaf *getGroupMemberNameDB(int member) { return _GroupMemberNameDB[member]; }
|
||||
inline NLMISC::CCDBNodeLeaf *getBeastUidDB(int beast) { return _BeastUidDB[beast]; }
|
||||
inline NLMISC::CCDBNodeLeaf *getBeastStatusDB(int beast) { return _BeastStatusDB[beast]; }
|
||||
inline NLMISC::CCDBNodeLeaf *getBeastTypeDB(int beast) { return _BeastTypeDB[beast]; }
|
||||
|
||||
private:
|
||||
|
||||
// NB: don't return unselectable entities
|
||||
|
|
|
@ -2646,7 +2646,7 @@ void CEntityCL::updateMissionTarget()
|
|||
for (j=0; j<MAX_NUM_MISSION_TARGETS; j++)
|
||||
{
|
||||
// Get the db prop
|
||||
CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false);
|
||||
CCDBNodeLeaf *prop = EntitiesMngr.getMissionTargetTitleDB(i, j); // NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false);
|
||||
if (prop)
|
||||
{
|
||||
_MissionTarget = _NameId == (uint32)prop->getValue32();
|
||||
|
@ -2846,8 +2846,8 @@ void CEntityCL::updateIsInTeam ()
|
|||
for (uint i=0; i<MaxNumPeopleInTeam; i++)
|
||||
{
|
||||
// Get the db prop
|
||||
CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:UID", i), false);
|
||||
CCDBNodeLeaf *presentProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", i), false);
|
||||
CCDBNodeLeaf *uidProp = EntitiesMngr.getGroupMemberUidDB(i);
|
||||
CCDBNodeLeaf *presentProp = EntitiesMngr.getGroupMemberNameDB(i);
|
||||
// If same Entity uid than the one in the Database, ok the entity is in the Player TEAM!!
|
||||
if (uidProp && uidProp->getValue32() == (sint32)dataSetId() &&
|
||||
presentProp && presentProp->getValueBool() )
|
||||
|
@ -2876,9 +2876,9 @@ void CEntityCL::updateIsUserAnimal ()
|
|||
for (uint i=0; i<MAX_INVENTORY_ANIMAL; i++)
|
||||
{
|
||||
// Get the db prop
|
||||
CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false);
|
||||
CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false);
|
||||
CCDBNodeLeaf *typeProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false);
|
||||
CCDBNodeLeaf *uidProp = EntitiesMngr.getBeastUidDB(i);
|
||||
CCDBNodeLeaf *statusProp = EntitiesMngr.getBeastStatusDB(i);
|
||||
CCDBNodeLeaf *typeProp = EntitiesMngr.getBeastTypeDB(i);
|
||||
// I must have the same Id, and the animal entry must be ok.
|
||||
if(uidProp && statusProp && typeProp && uidProp->getValue32() == (sint32)dataSetId() &&
|
||||
ANIMAL_STATUS::isSpawned((ANIMAL_STATUS::EAnimalStatus)(statusProp->getValue32()) ))
|
||||
|
|
Loading…
Reference in a new issue