Merging default into cdb_refactoring.

This commit is contained in:
dfighter1985 2012-04-28 19:55:46 +02:00
commit ec0eb455e3
155 changed files with 1668 additions and 979 deletions

View file

@ -20,20 +20,20 @@
#define CDB_H
// misc
#include "nel/misc/types_nl.h"
#include "nel/misc/smart_ptr.h"
#include "nel/misc/string_mapper.h"
#include "types_nl.h"
#include "smart_ptr.h"
#include "string_mapper.h"
#include "sstring.h"
#include <libxml/parser.h>
namespace NLMISC
{
class IProgressCallback;
class CBitMemStream;
}
class IProgressCallback;
class CBitMemStream;
class CCDBNodeLeaf;
class CCDBNodeBranch;
class CCDBBankHandler;
///global bool, must be set to true if we want to display database modification. See displayDBModifs in commands.cpp
extern bool VerboseDatabase;
@ -48,7 +48,7 @@ extern bool VerboseDatabase;
* \date 2002
*/
class ICDBNode : public NLMISC::CRefCount
class ICDBNode : public CRefCount
{
//-----------------------------------------------------------------------
// end of IDBNode interface
@ -78,7 +78,7 @@ public:
* \author Nevrax France
* \date 2002
*/
class IPropertyObserver : public NLMISC::CRefCount
class IPropertyObserver : public CRefCount
{
public :
virtual ~IPropertyObserver() {}
@ -198,7 +198,7 @@ public :
* Build the structure of the database from a file
* \param f is the stream
*/
virtual void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ) = 0;
virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ) = 0;
/**
* Save a backup of the database
@ -212,7 +212,7 @@ public :
* \param gc the server gameCycle of this update. Any outdated update are aborted
* \param f : the stream.
*/
virtual void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ) = 0;
virtual void readDelta( TGameCycle gc, CBitMemStream & f ) = 0;
/**
* Get a node . Create it if it does not exist yet
@ -252,7 +252,7 @@ public :
virtual bool setProp( CTextId& id, sint64 value ) = 0;
/// Reset all leaf data from this point
virtual void resetData(NLMISC::TGameCycle gc, bool forceReset=false) = 0;
virtual void resetData(TGameCycle gc, bool forceReset=false) = 0;
/**
* Clear the node and his children
@ -314,16 +314,16 @@ public :
virtual void display (const std::string &/* prefix */){}
/// Return the string id corresponding to the argument
static NLMISC::TStringId getStringId(const std::string& nodeName)
static TStringId getStringId(const std::string& nodeName)
{
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return _DBSM->localMap(nodeName);
}
/// Return a pointer to the string corresponding to the argument
static const std::string *getStringFromId(NLMISC::TStringId nodeStringId)
static const std::string *getStringFromId(TStringId nodeStringId)
{
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return &_DBSM->localUnmap(nodeStringId);
}
@ -335,32 +335,34 @@ protected:
/// Constructor
ICDBNode() : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
_Name = NLMISC::CStringMapper::emptyId();
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = CStringMapper::emptyId();
}
/// Constructor
ICDBNode (const std::string &name) : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = _DBSM->localMap(name);
//_NameDbg = name;
}
// utility to build full name efficiently (without reallocating the string at each parent level)
void _buildFullName(NLMISC::CSString &fullName);
void _buildFullName(CSString &fullName);
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
bool _AtomicFlag : 1;
/// Name of the node
NLMISC::TStringId _Name;
TStringId _Name;
//std::string _NameDbg;
static NLMISC::CStringMapper *_DBSM;
static CStringMapper *_DBSM;
};
}
#endif // CDB_H

View file

@ -0,0 +1,139 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CDB_BANK_HANDLER
#define CDB_BANK_HANDLER
#include <vector>
#include "nel/misc/types_nl.h"
namespace NLMISC{
/**
@brief Manages the bank names and mappings of the CDB it's associated with
Banks are numeric identifiers for the top-level branches of the CDB.
They are used for saving bandwidth, because the local CDBs are updated with deltas,
that identify the updatable top-level branch with this id.
The CCDBBankHandler manages the mapping of banks to their names, unified (node) index,
and the other way around.
*/
class CCDBBankHandler{
public:
/**
@brief The class' constructor
@param maxbanks the maximum number of banks we need to handle
*/
CCDBBankHandler( uint maxbanks );
/// Very surprisingly this is the destructor
~CCDBBankHandler(){}
/**
@brief Returns the unified (node) index for the specified bank Id.
@param bank The bank whose uid we need.
@return Returns an uid or static_cast< uint >( -1 ) on failure.
*/
uint getUIDForBank( uint bank ) const;
/**
@brief Returns the bank Id for the specified unified (node) index.
@param uid The unified (node) index we need to translate to bank Id.
@return Returns a bank Id.
*/
uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; }
/// Returns the last unified (node) index we mapped.
uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; }
/**
@brief Returns the number of bits used to store the number of nodes that belong to this bank.
@param bank The banks whose id bits we need.
@return Returns the number of bits used to store the number of nodes that belong to this bank.
*/
uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; }
/**
@brief Returns the name of the specified bank.
@param bank The id of the bank we need the name of.
@return Returns the name of the specified bank.
*/
std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; }
/**
@brief Looks up the bank Id of the bank name specified.
@param name The name of the bank whose Id we need.
@return Returns the id of the bank, or static_cast< uint >( -1 ) on fail.
*/
uint getBankByName( const std::string &name ) const;
/**
@brief Maps the specified bank name to a unified (node) index and vica versa.
@param bankName Name of the bank to map.
*/
void mapNodeByBank( const std::string &bankName );
/**
@brief Loads the known bank names from an array ( the order decides the bank Id ).
@param strings The array of the banks names.
@param size The size of the array.
*/
void fillBankNames( const char **strings, uint size );
/// Resets the node to bank mapping vector
void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); }
/// Resets all maps, and sets _CDBLastUnifiedIndex to 0.
void reset();
uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); }
/// Calculates the number of bits used to store the number of nodes that belong to the banks.
void calcIdBitsByBank();
/**
@brief Looks up the unified (node) index of a bank node.
@param bank The bank id of the node we are looking up.
@param index The index of the node within the bank.
@return Returns the unified (node) index of the specified bank node.
*/
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
private:
/// Mapping from server database index to client database index (first-level nodes)
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
/// Mapping from client database index to bank IDs (first-level nodes)
std::vector< uint > _UnifiedIndexToBank;
/// Last index mapped
uint _CDBLastUnifiedIndex;
/// Number of bits for first-level branches, by bank
std::vector< uint > _FirstLevelIdBitsByBank;
/// Names of the CDB banks
std::vector< std::string > _CDBBankNames;
/// The number of banks used
uint maxBanks;
};
}
#endif

View file

@ -20,7 +20,8 @@
#define CDB_BRANCH_H
#include "cdb.h"
#include "game_share/ryzom_database_banks.h"
namespace NLMISC{
/**
* Database Node which contains a set of properties
@ -32,6 +33,21 @@ class CCDBNodeBranch : public ICDBNode
{
public:
class ICDBDBBranchObserverHandle
{
public:
virtual ~ICDBDBBranchObserverHandle(){}
virtual ICDBNode* owner() = 0;
virtual IPropertyObserver* observer() = 0;
virtual bool observesLeaf( const std::string &leafName ) = 0;
virtual bool inList( uint list ) = 0;
virtual void addToFlushableList() = 0;
virtual void removeFromFlushableList( uint list ) = 0;
virtual void removeFromFlushableList() = 0;
};
// default constructor
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
{
@ -44,7 +60,7 @@ public:
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, class NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Add a new sub node
@ -93,10 +109,10 @@ public:
void write( CTextId& id, FILE * f);
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
void readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank );
void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler );
/// Update the database from a stream coming from the FE
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
void readDelta( TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
@ -118,19 +134,16 @@ public:
/// Clear the node and his children
void clear();
/// Reset the data corresponding to the bank (works only on top level node)
void resetBank( NLMISC::TGameCycle gc, TCDBBank bank)
void resetNode( TGameCycle gc, uint node )
{
//nlassert( getParent() == NULL );
for ( uint i=0; i!=_Nodes.size(); ++i )
{
if ( _UnifiedIndexToBank[i] == bank )
_Nodes[i]->resetData(gc);
}
if( node > _Nodes.size() )
return;
_Nodes[ node ]->resetData( gc );
}
/// Reset all leaf data from this point
void resetData(NLMISC::TGameCycle gc, bool forceReset=false)
void resetData(TGameCycle gc, bool forceReset=false)
{
for ( uint i=0; i!=_Nodes.size(); ++i )
{
@ -190,7 +203,7 @@ public:
* and setting a branch observer on it, except you don't need to change your database paths
* and update large amounts of code!).
*/
void addBranchObserver(IPropertyObserver* observer, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
void addBranchObserver( ICDBDBBranchObserverHandle* handle, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
/**
* Easy version of addBranchObserver() (see above).
@ -198,7 +211,7 @@ public:
* "" -> this node
* "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node
*/
void addBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
void addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
// Remove observer from all sub-leaves
bool removeBranchObserver(IPropertyObserver* observer);
@ -208,82 +221,14 @@ public:
virtual bool isLeaf() const { return false; }
/** Update all observers of branchs that have been modified
*/
static void flushObserversCalls();
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
void linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName);
void onLeafChanged( TStringId leafName );
/// Find a subnode at this level
ICDBNode * find (const std::string &nodeName);
/// Main init
static void resetNodeBankMapping() { _UnifiedIndexToBank.clear(); }
// reset all static mappings
static void reset();
/// Internal use only
static void mapNodeByBank( ICDBNode *node, const std::string& bankStr, bool clientOnly, uint nodeIndex );
protected:
/** Struct identifying an observer of a db branch
* This struct can be linked in a list so that we can update observers only once per pass.
* An observer that watch a whole branch can be updated once and only once after each element of the branch has been modified
*/
class CDBBranchObsInfo
{
public:
NLMISC::CRefPtr<IPropertyObserver> Observer;
// 2 linked list are required : while the observer is notified, it can triger one other observer, so we must link it in another list
bool Touched[2];
CDBBranchObsInfo *PrevNotifiedObserver[2]; // NULL means this is the head
CDBBranchObsInfo *NextNotifiedObserver[2];
ICDBNode *Owner;
// If non-empty, only a leaf whose name is found here will notify something
// This is equivalent to creating a sub-branch containing only the specified leaves
// and setting a branch observer on it, except you don't need to change your database paths
// and update large amounts of code and script!
std::vector<NLMISC::TStringId> PositiveLeafNameFilter;
public:
/// Constructor. See above for usage of positiveLeafNameFilter.
CDBBranchObsInfo(IPropertyObserver *obs = NULL, ICDBNode *owner = NULL, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>())
{
Owner = owner;
Observer = obs;
Touched[0] = Touched[1] = false;
PrevNotifiedObserver[0] = PrevNotifiedObserver[1] = NULL;
NextNotifiedObserver[0] = NextNotifiedObserver[1] = NULL;
for (std::vector<std::string>::const_iterator ipf=positiveLeafNameFilter.begin(); ipf!=positiveLeafNameFilter.end(); ++ipf)
{
PositiveLeafNameFilter.push_back(ICDBNode::getStringId(*ipf)); // the ids are also mapped at database init, we don't need to unmap them in destructor
}
}
~CDBBranchObsInfo()
{
// should have been unlinked
nlassert(Touched[0] == false);
nlassert(Touched[1] == false);
nlassert(PrevNotifiedObserver[0] == NULL);
nlassert(PrevNotifiedObserver[1] == NULL);
nlassert(NextNotifiedObserver[0] == NULL);
nlassert(NextNotifiedObserver[1] == NULL);
}
// Unlink from the given list. This also clear the '_Touched' flag
void unlink(uint list);
void link(uint list, NLMISC::TStringId modifiedLeafName);
};
typedef std::list<CDBBranchObsInfo> TObsList; // must use a list because pointers on CDBObserverInfo instances must remains valids
protected:
typedef std::list< ICDBDBBranchObserverHandle* > TObserverHandleList;
CCDBNodeBranch *_Parent;
@ -298,34 +243,13 @@ protected:
bool _Sorted : 1;
// observers for this node or branch
TObsList _Observers;
friend class CDBBranchObsInfo;
// Global list of modified nodes
static CDBBranchObsInfo *_FirstNotifiedObs[2];
static CDBBranchObsInfo *_LastNotifiedObs[2];
static uint _CurrNotifiedObsList; // 0 or 1 => tell in which list observers of modified values must be added
// current & next observers being notified : if such observer if removed during notification, pointer will be valids
static CDBBranchObsInfo *_CurrNotifiedObs;
static CDBBranchObsInfo *_NextNotifiedObs;
/// Mapping from server database index to client database index (first-level nodes)
static std::vector<uint> _CDBBankToUnifiedIndexMapping [NB_CDB_BANKS];
// Mapping from client database index to TCDBBank (first-level nodes)
static std::vector<TCDBBank> _UnifiedIndexToBank;
/// Last index mapped
static uint _CDBLastUnifiedIndex;
/// Number of bits for first-level branches, by bank
static uint _FirstLevelIdBitsByBank [NB_CDB_BANKS];
TObserverHandleList observerHandles;
/// called by clear
void removeAllBranchObserver();
void removeBranchInfoIt(TObsList::iterator it);
};
}
#endif // CDB_BRANCH_H

View file

@ -0,0 +1,128 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CDB_BRANCH_OBS_HNDLR
#define CDB_BRANCH_OBS_HNDLR
#include "nel/misc/cdb_branch.h"
namespace NLMISC{
/**
@brief Manages the CDB branch observers.
When a leaf's data changes, it notifies the branch, which then marks the observers as notifiable.
The marked observers can then be notified and flushed on request.
*/
class CCDBBranchObservingHandler{
enum{
MAX_OBS_LST = 2
};
public:
CCDBBranchObservingHandler();
~CCDBBranchObservingHandler();
/// Notifies the observers, and flushes the list
void flushObserverCalls();
void reset();
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter );
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
///Observer for branch observer flush events.
class IBranchObserverCallFlushObserver : public CRefCount{
public:
virtual ~IBranchObserverCallFlushObserver(){}
virtual void onObserverCallFlush() = 0;
};
private:
void triggerFlushObservers();
public:
void addFlushObserver( IBranchObserverCallFlushObserver *observer );
void removeFlushObserver( IBranchObserverCallFlushObserver *observer );
private:
/**
@brief Handle to a branch observer.
The handle stores the owner branch, the observer and remembers if it's marked for notifying the observer.
Also it manages adding/removing itself to/from the marked observer handles list, which is handled by CCDBBranchObservingHandler.
*/
class CCDBDBBranchObserverHandle : public CCDBNodeBranch::ICDBDBBranchObserverHandle{
public:
CCDBDBBranchObserverHandle( ICDBNode::IPropertyObserver *observer, CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler );
~CCDBDBBranchObserverHandle();
ICDBNode* owner(){ return _owner; }
ICDBNode::IPropertyObserver* observer(){ return _observer; }
bool observesLeaf( const std::string &leafName );
bool inList( uint list );
void addToFlushableList();
void removeFromFlushableList( uint list );
void removeFromFlushableList();
private:
bool _inList[ MAX_OBS_LST ];
std::vector< std::string > _observedLeaves;
CCDBNodeBranch *_owner;
NLMISC::CRefPtr< ICDBNode::IPropertyObserver > _observer;
CCDBBranchObservingHandler *_handler;
};
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* > flushableObservers[ MAX_OBS_LST ];
CCDBNodeBranch::ICDBDBBranchObserverHandle *currentHandle;
uint currentList;
std::vector< IBranchObserverCallFlushObserver* > flushObservers;
};
}
#endif

View file

@ -19,8 +19,9 @@
#ifndef NL_CDB_CHECK_SUM_H
#define NL_CDB_CHECK_SUM_H
#include "nel/misc/types_nl.h"
#include "types_nl.h"
namespace NLMISC{
/**
* class implementing check sum for the client database
@ -81,6 +82,7 @@ private:
};
}
#endif // NL_CDB_CHECK_SUM_H

View file

@ -21,7 +21,10 @@
#include "cdb.h"
#include "cdb_branch.h"
#include "nel/misc/time_nl.h"
#include "time_nl.h"
#include "rgba.h"
namespace NLMISC{
/**
* Database node which contains a unique property
@ -50,16 +53,16 @@ public:
void setValue8 (sint8 prop);
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
void setValueBool (bool prop);
inline NLMISC::CRGBA getValueRGBA()
inline CRGBA getValueRGBA()
{
NLMISC::CRGBA col;
CRGBA col;
col.R = (uint8)(_Property&0xff);
col.G = (uint8)((_Property>>8)&0xff);
col.B = (uint8)((_Property>>16)&0xff);
col.A = (uint8)((_Property>>24)&0xff);
return col;
}
void setValueRGBA (const NLMISC::CRGBA &color);
void setValueRGBA (const CRGBA &color);
/// Return the value of the property before the database change
inline sint64 getOldValue64() { return _oldProperty; }
@ -98,7 +101,7 @@ public:
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Get a node
@ -132,7 +135,7 @@ public:
* Update the database from a stream coming from the FE
* \param f : the stream.
*/
void readDelta(NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
void readDelta(TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
@ -154,10 +157,10 @@ public:
/**
* Set the value of a property, only if gc>=_LastChangeGC
*/
bool setPropCheckGC(NLMISC::TGameCycle gc, sint64 value);
bool setPropCheckGC(TGameCycle gc, sint64 value);
/// Reset all leaf data from this point
void resetData(NLMISC::TGameCycle gc, bool forceReset=false);
void resetData(TGameCycle gc, bool forceReset=false);
/**
* Clear the node and his children
@ -215,7 +218,7 @@ public:
/// get the last change GameCycle (server tick) for this value
NLMISC::TGameCycle getLastChangeGC() const {return _LastChangeGC;}
TGameCycle getLastChangeGC() const {return _LastChangeGC;}
private:
@ -234,7 +237,7 @@ private:
/// gamecycle (servertick) of the last change for this value.
/// change are made in readDelta only for change >= _LastChangeGC
NLMISC::TGameCycle _LastChangeGC;
TGameCycle _LastChangeGC;
/// observers to call when the value really change
std::vector<IPropertyObserver*> _Observers;
@ -249,7 +252,7 @@ private:
////////////////////
}
#endif // CDB_LEAF_H

View file

@ -0,0 +1,184 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CDB_MANAGER_H
#define CDB_MANAGER_H
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/cdb_bank_handler.h"
#include "nel/misc/cdb_branch_observing_handler.h"
namespace NLMISC{
/// Class that encapsulates the separate CDB components
class CCDBManager{
public:
/**
The constructor
@param maxBanks - The maximum number of banks to be used
*/
CCDBManager( const char *rootNodeName, uint maxBanks );
~CCDBManager();
/**
Returns the specified leaf node from the database.
@param name The name of the leaf node.
@param create Specifies if the node should be created if it doesn't exist yet.
*/
CCDBNodeLeaf* getDbLeaf( const std::string &name, bool create = true );
/**
Returns the specified branch node from the database.
@param name The name of the branch.
*/
CCDBNodeBranch* getDbBranch( const std::string &name );
/**
Deletes the specified database node.
@param name The name of the database node.
*/
void delDbNode( const std::string &name );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branch The branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 );
/**
Adds an observer to a branch of the database.
@param branch The branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branch The branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Adds a branch observer call flush observer. ( These are notified after the branch observers are notified )
@param observer The observer
*/
void addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Removes a branch observer call flush observer.
@param observer The observer
*/
void removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Notifies the observers whose observed branches were updated.
*/
void flushObserverCalls();
/**
Resets the specified bank.
@param gc GameCycle ( no idea what it is exactly, probably some time value )
@param bank The banks we want to reset
*/
void resetBank( uint gc, uint bank );
protected:
CCDBBankHandler bankHandler;
CCDBBranchObservingHandler branchObservingHandler;
CRefPtr< CCDBNodeBranch > _Database;
};
}
#endif

View file

@ -16,21 +16,19 @@
#include "stdpch.h"
//////////////
// Includes //
//////////////
#include "cdb.h"
#include "cdb_branch.h"
#include <nel/misc/bit_mem_stream.h>
#include "nel/misc/cdb.h"
#include "nel/misc/cdb_branch.h"
#include "nel/misc/bit_mem_stream.h"
////////////////
// Namespaces //
////////////////
using namespace NLMISC;
using namespace std;
namespace NLMISC{
CStringMapper *ICDBNode::_DBSM = NULL;
@ -82,3 +80,6 @@ void ICDBNode::releaseStringMapper()
delete _DBSM;
_DBSM = NULL;
}
}

View file

@ -0,0 +1,96 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/misc/cdb_bank_handler.h"
namespace NLMISC{
CCDBBankHandler::CCDBBankHandler(uint maxbanks) :
_CDBBankToUnifiedIndexMapping( maxbanks, std::vector< uint >() ),
_FirstLevelIdBitsByBank( maxbanks )
{
std::fill( _FirstLevelIdBitsByBank.begin(), _FirstLevelIdBitsByBank.end(), 0 );
maxBanks = maxbanks;
}
uint CCDBBankHandler::getUIDForBank( uint bank ) const
{
uint uid = static_cast< uint >( -1 );
for( uint i = 0; i < _UnifiedIndexToBank.size(); i++ )
if( _UnifiedIndexToBank[ i ] == bank )
return i;
return uid;
}
uint CCDBBankHandler::getBankByName( const std::string &name ) const
{
uint b = static_cast< uint >( -1 );
for( uint i = 0; i < _CDBBankNames.size(); i++ )
if( _CDBBankNames[ i ].compare( name ) == 0 )
return i;
return b;
}
void CCDBBankHandler::mapNodeByBank( const std::string &bankName )
{
uint b = getBankByName( bankName );
// no such bank
if( b == static_cast< uint >( -1 ) )
return;
_CDBBankToUnifiedIndexMapping[ b ].push_back( _CDBLastUnifiedIndex );
++_CDBLastUnifiedIndex;
_UnifiedIndexToBank.push_back( b );
}
void CCDBBankHandler::fillBankNames( const char **strings, uint size )
{
_CDBBankNames.clear();
for( uint i = 0; i < size; i++ )
_CDBBankNames.push_back( std::string( strings[ i ] ) );
}
void CCDBBankHandler::reset()
{
for( std::vector< std::vector< uint > >::iterator itr =_CDBBankToUnifiedIndexMapping.begin();
itr != _CDBBankToUnifiedIndexMapping.end(); ++itr )
itr->clear();
_UnifiedIndexToBank.clear();
_CDBLastUnifiedIndex = 0;
}
void CCDBBankHandler::calcIdBitsByBank()
{
for( uint bank = 0; bank != maxBanks; bank++ )
{
uint nbNodesOfBank = static_cast< uint >( _CDBBankToUnifiedIndexMapping[ bank ].size() );
uint idb = 0;
if ( nbNodesOfBank > 0 )
for ( idb = 1; nbNodesOfBank > unsigned( 1 << idb ) ; idb++ )
;
_FirstLevelIdBitsByBank[ bank ] = idb;
}
}
}

View file

@ -16,8 +16,6 @@
#include "stdpch.h"
//#define TRACE_READ_DELTA
//#define TRACE_WRITE_DELTA
//#define TRACE_SET_VALUE
@ -28,16 +26,14 @@
//////////////
// Includes //
//////////////
#include "cdb_branch.h"
#include "cdb_leaf.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/xml_auto_ptr.h"
//#include <iostream.h>
#include "interface_v3/interface_manager.h"
////////////////
// Namespaces //
////////////////
using namespace NLMISC;
using namespace std;
@ -46,6 +42,9 @@ using namespace std;
#include "nel/misc/file.h"
#include "nel/misc/i_xml.h"
#include "nel/misc/progress_callback.h"
#include "nel/misc/bit_mem_stream.h"
#include "nel/misc/bit_set.h"
#include "nel/misc/cdb_bank_handler.h"
#include <libxml/parser.h>
//#include <io.h>
@ -56,76 +55,9 @@ using namespace std;
using namespace std;
using namespace NLMISC;
/////////////
// GLOBALS //
/////////////
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_FirstNotifiedObs[2] = { NULL, NULL };
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_LastNotifiedObs[2] = { NULL, NULL };
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_CurrNotifiedObs = NULL;
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL;
//
uint CCDBNodeBranch::_CurrNotifiedObsList = 0;
// Mapping from server database index to client database index (first-level nodes)
vector<uint> CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [NB_CDB_BANKS];
// Mapping from client database index to TCDBBank (first-level nodes)
vector<TCDBBank> CCDBNodeBranch::_UnifiedIndexToBank;
// Last index mapped
uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0;
// Number of bits for first-level branches, by bank
uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS];
extern const char *CDBBankNames[INVALID_CDB_BANK+1];
// reset all static data
void CCDBNodeBranch::reset()
{
for ( uint b=0; b<NB_CDB_BANKS; ++b )
_CDBBankToUnifiedIndexMapping[b].clear();
_UnifiedIndexToBank.clear();
_CDBLastUnifiedIndex = 0;
_FirstNotifiedObs[0] = NULL;
_FirstNotifiedObs[1] = NULL;
_LastNotifiedObs[0] = NULL;
_LastNotifiedObs[1] = NULL;
_CurrNotifiedObsList = 0;
_CurrNotifiedObs = NULL;
_NextNotifiedObs = NULL;
}
// Internal use only. First-level bank-mapping.
void CCDBNodeBranch::mapNodeByBank( ICDBNode * /* node */, const string& bankStr, bool /* clientOnly */, uint /* nodeIndex */ )
{
/*if ( clientOnly )
{
//nldebug( "CDB: Unified.%u is ClientOnly", _CDBLastUnifiedIndex );
++_CDBLastUnifiedIndex;
_UnifiedIndexToBank.push_back( CDBPlayer );
}
else*/ // now clientOnly indices are known by the server as well
{
for ( uint b=0; b!=INVALID_CDB_BANK; ++b )
{
if ( string(CDBBankNames[b]) == bankStr )
{
//nldebug( "CDB: Mapping %s.%u to Unified.%u", CDBBankNames[b], _CDBBankToUnifiedIndexMapping[b].size(), _CDBLastUnifiedIndex );
_CDBBankToUnifiedIndexMapping[b].push_back( _CDBLastUnifiedIndex );
++_CDBLastUnifiedIndex;
_UnifiedIndexToBank.push_back( (TCDBBank)b );
break;
}
}
}
}
namespace NLMISC{
//-----------------------------------------------
// init
@ -135,8 +67,8 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode
std::vector<ICDBNode *> &nodes, std::vector<ICDBNode *> &nodesSorted,
xmlNodePtr &child, const string& bankName,
bool atomBranch, bool clientOnly,
NLMISC::IProgressCallback &progressCallBack,
bool mapBanks )
IProgressCallback &progressCallBack,
bool mapBanks, CCDBBankHandler *bankHandler = NULL )
{
nodesSorted.push_back(newNode);
nodes.push_back(newNode);
@ -149,7 +81,7 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode
{
if ( ! bankName.empty() )
{
CCDBNodeBranch::mapNodeByBank( newNode, bankName, clientOnly, (uint)nodes.size()-1 );
bankHandler->mapNodeByBank( bankName );
//nldebug( "CDB: Mapping %s for %s (node %u)", newName.c_str(), bankName.c_str(), nodes.size()-1 );
}
else
@ -159,7 +91,7 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode
}
}
void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks )
void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks, CCDBBankHandler *bankHandler )
{
xmlNodePtr child;
@ -198,7 +130,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
// nlinfo("+ %s%d",name,i);
string newName = string(name.getDatas())+toString(i);
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks );
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks, bankHandler );
// nlinfo("-");
// Progress bar
@ -210,7 +142,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
// dealing with a single entry
// nlinfo("+ %s",name);
string newName = string(name.getDatas());
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks );
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks, bankHandler );
// nlinfo("-");
}
@ -247,7 +179,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
// nlinfo(" %s%d",name,i);
string newName = string(name.getDatas())+toString(i);
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks );
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks, bankHandler );
// Progress bar
progressCallBack.popCropedValues ();
@ -257,7 +189,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
{
// nlinfo(" %s",name);
string newName = string(name.getDatas());
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks );
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks, bankHandler );
}
// Progress bar
@ -267,18 +199,11 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
// count number of bits required to store the id
if ( (mapBanks) && (getParent() == NULL) )
{
nlassertex( _UnifiedIndexToBank.size() == countNode, ("Mapped: %u Nodes: %u", _UnifiedIndexToBank.size(), countNode) );
{
nlassert( bankHandler != NULL );
nlassertex( bankHandler->getUnifiedIndexToBankSize() == countNode, ("Mapped: %u Nodes: %u", bankHandler->getUnifiedIndexToBankSize(), countNode) );
bankHandler->calcIdBitsByBank();
_IdBits = 0;
for ( uint b=0; b!=NB_CDB_BANKS; ++b )
{
uint nbNodesOfBank = (uint)_CDBBankToUnifiedIndexMapping[b].size();
uint idb = 0;
if ( nbNodesOfBank > 0 )
for ( idb=1; nbNodesOfBank > unsigned(1<<idb) ; idb++ ) {}
_FirstLevelIdBitsByBank[b] = idb;
}
}
else
{
@ -460,16 +385,16 @@ bool CCDBNodeBranch::setProp( CTextId& id, sint64 value )
/*
* Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
*/
void CCDBNodeBranch::readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank )
void CCDBNodeBranch::readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler )
{
nlassert( ! isAtomic() ); // root node mustn't be atomic
// Read index
uint32 idx;
s.serial( idx, _FirstLevelIdBitsByBank[bank] );
s.serial( idx, bankHandler->getFirstLevelIdBits( bank ) );
// Translate bank index -> unified index
idx = _CDBBankToUnifiedIndexMapping[bank][idx];
idx = bankHandler->getServerToClientUIDMapping( bank, idx );
if (idx >= _Nodes.size())
{
throw Exception ("idx %d > _Nodes.size() %d ", idx, _Nodes.size());
@ -492,7 +417,7 @@ void CCDBNodeBranch::readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStre
// readDelta
//
//-----------------------------------------------
void CCDBNodeBranch::readDelta( NLMISC::TGameCycle gc, CBitMemStream & f )
void CCDBNodeBranch::readDelta( TGameCycle gc, CBitMemStream & f )
{
if ( isAtomic() )
{
@ -674,126 +599,14 @@ void CCDBNodeBranch::removeNode (const CTextId& id)
delete pNode;
}
//-----------------------------------------------
void CCDBNodeBranch::flushObserversCalls()
void CCDBNodeBranch::onLeafChanged( NLMISC::TStringId leafName )
{
H_AUTO ( RZ_Interface_flushObserversCalls )
for( TObserverHandleList::iterator itr = observerHandles.begin(); itr != observerHandles.end(); ++itr )
if( (*itr)->observesLeaf( *leafName ) )
(*itr)->addToFlushableList();
// nlassert(_CrtCheckMemory());
_CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList];
while (_CurrNotifiedObs)
{
// modified node should now store them in other list when they're modified
_CurrNotifiedObsList = 1 - _CurrNotifiedObsList;
// switch list so that modified node are stored in the other list
while (_CurrNotifiedObs)
{
_NextNotifiedObs = _CurrNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList];
nlassert(_CurrNotifiedObs->Owner);
if (_CurrNotifiedObs->Observer)
_CurrNotifiedObs->Observer->update(_CurrNotifiedObs->Owner);
if (_CurrNotifiedObs) // this may be modified by the call (if current observer is removed)
{
_CurrNotifiedObs->unlink(1 - _CurrNotifiedObsList);
}
_CurrNotifiedObs = _NextNotifiedObs;
}
nlassert(_FirstNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
nlassert(_LastNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
// update triggered link
CInterfaceLink::updateTrigeredLinks();
// examine other list to see if nodes have been registered
_CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList];
}
CInterfaceLink::updateTrigeredLinks(); // should call it at least once
// nlassert(_CrtCheckMemory());
}
//-----------------------------------------------
void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, NLMISC::TStringId modifiedLeafName)
{
// If there a filter set?
if (!PositiveLeafNameFilter.empty())
{
// Don't link if modifiedLeafName is not in the filter
if (std::find(PositiveLeafNameFilter.begin(), PositiveLeafNameFilter.end(), modifiedLeafName) == PositiveLeafNameFilter.end())
return;
}
// nlassert(_CrtCheckMemory());
nlassert(list < 2);
if (Touched[list]) return; // already inserted in list
Touched[list] = true;
nlassert(!PrevNotifiedObserver[list]);
nlassert(!NextNotifiedObserver[list]);
if (!_FirstNotifiedObs[list])
{
_FirstNotifiedObs[list] = _LastNotifiedObs[list] = this;
}
else
{
nlassert(!_LastNotifiedObs[list]->NextNotifiedObserver[list]);
_LastNotifiedObs[list]->NextNotifiedObserver[list] = this;
PrevNotifiedObserver[list] = _LastNotifiedObs[list];
_LastNotifiedObs[list] = this;
}
// nlassert(_CrtCheckMemory());
}
//-----------------------------------------------
void CCDBNodeBranch::CDBBranchObsInfo::unlink(uint list)
{
// nlassert(_CrtCheckMemory());
nlassert(list < 2);
if (!Touched[list])
{
// not linked in this list
nlassert(PrevNotifiedObserver[list] == NULL);
nlassert(NextNotifiedObserver[list] == NULL);
return;
}
if (PrevNotifiedObserver[list])
{
PrevNotifiedObserver[list]->NextNotifiedObserver[list] = NextNotifiedObserver[list];
}
else
{
// this was the first node
_FirstNotifiedObs[list] = NextNotifiedObserver[list];
}
if (NextNotifiedObserver[list])
{
NextNotifiedObserver[list]->PrevNotifiedObserver[list] = PrevNotifiedObserver[list];
}
else
{
// this was the last node
_LastNotifiedObs[list] = PrevNotifiedObserver[list];
}
PrevNotifiedObserver[list] = NULL;
NextNotifiedObserver[list] = NULL;
Touched[list] = false;
// nlassert(_CrtCheckMemory());
}
//-----------------------------------------------
void CCDBNodeBranch::linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName)
{
// nlassert(_CrtCheckMemory());
CCDBNodeBranch *curr = this;
do
{
for(TObsList::iterator it = curr->_Observers.begin(); it != curr->_Observers.end(); ++it)
{
it->link(_CurrNotifiedObsList, modifiedLeafName);
}
curr = curr->getParent();
}
while(curr);
// nlassert(_CrtCheckMemory());
if( _Parent != NULL )
_Parent->onLeafChanged( leafName );
}
@ -866,14 +679,21 @@ bool CCDBNodeBranch::removeObserver(IPropertyObserver* observer, CTextId& id)
//-----------------------------------------------
void CCDBNodeBranch::addBranchObserver(IPropertyObserver* observer, const std::vector<std::string>& positiveLeafNameFilter)
void CCDBNodeBranch::addBranchObserver( ICDBDBBranchObserverHandle *handle, const std::vector<std::string>& positiveLeafNameFilter)
{
CDBBranchObsInfo oi(observer, this, positiveLeafNameFilter);
_Observers.push_front(oi);
CCDBNodeBranch::TObserverHandleList::iterator itr
= std::find( observerHandles.begin(), observerHandles.end(), handle );
if( itr != observerHandles.end() ){
delete handle;
return;
}
observerHandles.push_back( handle );
}
//-----------------------------------------------
void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize)
void CCDBNodeBranch::addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize)
{
CCDBNodeBranch *branchNode;
if (dbPathFromThisNode[0] == '\0') // empty string
@ -883,21 +703,37 @@ void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode:
else
{
branchNode = safe_cast<CCDBNodeBranch*>(getNode(ICDBNode::CTextId(dbPathFromThisNode), false));
BOMB_IF (!branchNode, (*getName()) << ":" << dbPathFromThisNode << " branch missing in DB", return);
if( branchNode == NULL ){
std::string msg = *getName();
msg += ":";
msg += dbPathFromThisNode;
msg += " branch missing in DB";
nlerror( msg.c_str() );
delete handle;
return;
}
}
std::vector<std::string> leavesToMonitor(positiveLeafNameFilterSize);
for (uint i=0; i!=positiveLeafNameFilterSize; ++i)
{
leavesToMonitor[i] = string(positiveLeafNameFilter[i]);
}
branchNode->addBranchObserver(&observer, leavesToMonitor);
branchNode->addBranchObserver(handle, leavesToMonitor);
}
//-----------------------------------------------
void CCDBNodeBranch::removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer)
{
CCDBNodeBranch *branchNode = safe_cast<CCDBNodeBranch*>(getNode(ICDBNode::CTextId(dbPathFromThisNode), false));
BOMB_IF (!branchNode, (*getName()) << ":" << dbPathFromThisNode << " branch missing in DB", return);
if( branchNode == NULL ){
std::string msg = *getName();
msg += ":";
msg += dbPathFromThisNode;
msg += " branch missing in DB";
nlerror( msg.c_str() );
return;
}
branchNode->removeBranchObserver(&observer);
}
@ -906,55 +742,38 @@ void CCDBNodeBranch::removeBranchObserver(const char *dbPathFromThisNode, ICDBNo
bool CCDBNodeBranch::removeBranchObserver(IPropertyObserver* observer)
{
bool found = false;
TObsList::iterator it = _Observers.begin();
while (it != _Observers.end())
TObserverHandleList::iterator itr = observerHandles.begin();
while( itr != observerHandles.end() )
{
if (it->Observer == observer)
if( (*itr)->observer() == observer )
{
removeBranchInfoIt(it);
it = _Observers.erase(it);
(*itr)->removeFromFlushableList();
delete *itr;
itr = observerHandles.erase( itr );
found = true;
}
else
{
++it;
++itr;
}
}
return found;
}
//-----------------------------------------------
void CCDBNodeBranch::removeAllBranchObserver()
{
TObsList::iterator it = _Observers.begin();
while (it != _Observers.end())
{
removeBranchInfoIt(it);
++it;
for( TObserverHandleList::iterator itr = observerHandles.begin();
itr != observerHandles.end(); ++itr ){
(*itr)->removeFromFlushableList();
delete *itr;
}
_Observers.clear();
}
//-----------------------------------------------
void CCDBNodeBranch::removeBranchInfoIt(TObsList::iterator it)
{
CDBBranchObsInfo *oi = &(*it);
// if this node is currenlty being notified, update iterators
if (oi == _CurrNotifiedObs)
{
_CurrNotifiedObs = NULL;
}
if (oi == _NextNotifiedObs)
{
nlassert(_CurrNotifiedObsList < 2);
_NextNotifiedObs = _NextNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList];
}
// unlink observer from both update lists
oi->unlink(0);
oi->unlink(1);
observerHandles.clear();
}
//-----------------------------------------------
// Useful for find
//-----------------------------------------------
@ -1013,3 +832,5 @@ ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
#undef TRACE_SET_VALUE
#endif
}

View file

@ -0,0 +1,201 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/misc/cdb_branch_observing_handler.h"
namespace NLMISC{
CCDBBranchObservingHandler::CCDBBranchObservingHandler()
{
reset();
}
CCDBBranchObservingHandler::~CCDBBranchObservingHandler()
{
reset();
}
void CCDBBranchObservingHandler::flushObserverCalls()
{
bool flushed = false;
do
{
flushed = false;
uint oldList = currentList;
currentList = 1 - currentList;
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* >::iterator itr
= flushableObservers[ oldList ].begin();
while( itr != flushableObservers[ oldList ].end() )
{
currentHandle = *itr;
++itr;
if( currentHandle->observer() != NULL )
currentHandle->observer()->update( currentHandle->owner() );
// Update might have removed it
if( currentHandle != NULL )
currentHandle->removeFromFlushableList( oldList );
currentHandle = NULL;
flushed = true;
}
triggerFlushObservers();
}while( flushed );
triggerFlushObservers();
}
void CCDBBranchObservingHandler::reset()
{
currentList = 0;
currentHandle = NULL;
for( uint i = 0; i < MAX_OBS_LST; i++ )
flushableObservers[ i ].clear();
}
void CCDBBranchObservingHandler::addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter )
{
if( branch == NULL )
return;
CCDBDBBranchObserverHandle *handle = new CCDBDBBranchObserverHandle( observer, branch, this );
branch->addBranchObserver( handle, positiveLeafNameFilter );
}
void CCDBBranchObservingHandler::addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize )
{
if( branch == NULL )
return;
CCDBDBBranchObserverHandle *handle = new CCDBDBBranchObserverHandle( &observer, branch, this );
branch->addBranchObserver( handle, dbPathFromThisNode, positiveLeafNameFilter, positiveLeafNameFilterSize );
}
void CCDBBranchObservingHandler::removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer )
{
branch->removeBranchObserver( observer );
}
void CCDBBranchObservingHandler::removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer )
{
branch->removeBranchObserver( dbPathFromThisNode, observer );
}
void CCDBBranchObservingHandler::triggerFlushObservers()
{
for( std::vector< IBranchObserverCallFlushObserver* >::iterator itr = flushObservers.begin();
itr != flushObservers.end(); itr++ )
(*itr)->onObserverCallFlush();
}
void CCDBBranchObservingHandler::addFlushObserver( IBranchObserverCallFlushObserver *observer )
{
std::vector< IBranchObserverCallFlushObserver* >::iterator itr
= std::find( flushObservers.begin(), flushObservers.end(), observer );
if( itr != flushObservers.end() )
return;
flushObservers.push_back( observer );
}
void CCDBBranchObservingHandler::removeFlushObserver( IBranchObserverCallFlushObserver *observer )
{
std::vector< IBranchObserverCallFlushObserver* >::iterator itr
= std::find( flushObservers.begin(), flushObservers.end(), observer );
if( itr == flushObservers.end() )
return;
flushObservers.erase( itr );
}
CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::CCDBDBBranchObserverHandle( NLMISC::ICDBNode::IPropertyObserver *observer, NLMISC::CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler )
{
std::fill( _inList, _inList + MAX_OBS_LST, false );
_observer = observer;
_owner = owner;
_handler = handler;
}
CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::~CCDBDBBranchObserverHandle()
{
_observer = NULL;
}
bool CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::observesLeaf( const std::string &leafName )
{
if( !_observedLeaves.empty() ){
std::vector< std::string >::iterator itr
= std::find( _observedLeaves.begin(), _observedLeaves.end(), leafName );
if( itr == _observedLeaves.end() )
return false;
else
return true;
}
return true;
}
bool CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::inList( uint list )
{
return _inList[ list ];
}
void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::addToFlushableList()
{
uint list = _handler->currentList;
if( _inList[ list ] )
return;
_handler->flushableObservers[ list ].push_back( this );
_inList[ list ] = true;
}
void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::removeFromFlushableList( uint list )
{
if( !_inList[ list ] )
return;
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* >::iterator itr
= std::find( _handler->flushableObservers[ list ].begin(),
_handler->flushableObservers[ list ].end(), this );
if( itr == _handler->flushableObservers[ list ].end() )
return;
if( _handler->currentHandle == this )
_handler->currentHandle = NULL;
_handler->flushableObservers[ list ].erase( itr );
_inList[ list ] = false;
}
void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::removeFromFlushableList()
{
for( uint i = 0; i < MAX_OBS_LST; i++ )
removeFromFlushableList( i );
}
}

View file

@ -16,10 +16,11 @@
#include "stdpch.h"
#include "cdb_check_sum.h"
#include "nel/misc/cdb_check_sum.h"
namespace NLMISC{
/*
* Constructor
*/
@ -40,3 +41,6 @@ void CCDBCheckSum::add(uint8 el)
_Factor = (cipher + _Factor) * _Const1 + _Const2;
_Sum += cipher;
}
}

View file

@ -16,9 +16,6 @@
#include "stdpch.h"
//#define TRACE_READ_DELTA
//#define TRACE_WRITE_DELTA
//#define TRACE_SET_VALUE
@ -28,22 +25,23 @@
//////////////
// Includes //
//////////////
#include "cdb_leaf.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/misc/bit_mem_stream.h"
//#include <iostream.h>
#include "interface_v3/interface_manager.h"
////////////////
// Namespaces //
////////////////
using namespace NLMISC;
using namespace std;
namespace NLMISC{
//-----------------------------------------------
// init
//-----------------------------------------------
void CCDBNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &/* progressCallBack */, bool /* mapBanks */ )
void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBack */, bool /* mapBanks */, CCDBBankHandler * /* bankHandler */ )
{
CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type"));
nlassert((const char *) type != NULL);
@ -128,7 +126,7 @@ void CCDBNodeLeaf::write( CTextId& id, FILE * f)
//-----------------------------------------------
// readDelta
//-----------------------------------------------
void CCDBNodeLeaf::readDelta(NLMISC::TGameCycle gc, CBitMemStream & f )
void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f )
{
// If the property Type is valid.
if(_Type > UNKNOWN && _Type < Nb_Prop_Type)
@ -184,7 +182,7 @@ void CCDBNodeLeaf::readDelta(NLMISC::TGameCycle gc, CBitMemStream & f )
//-----------------------------------------------
// resetData
//-----------------------------------------------
void CCDBNodeLeaf::resetData(NLMISC::TGameCycle gc, bool forceReset)
void CCDBNodeLeaf::resetData(TGameCycle gc, bool forceReset)
{
if(forceReset)
{
@ -251,7 +249,7 @@ bool CCDBNodeLeaf::setProp( CTextId& id, sint64 value )
//-----------------------------------------------
// setPropCheckGC
//-----------------------------------------------
bool CCDBNodeLeaf::setPropCheckGC(NLMISC::TGameCycle gc, sint64 value)
bool CCDBNodeLeaf::setPropCheckGC(TGameCycle gc, sint64 value)
{
// Apply only if happens after the DB change
if(gc>=_LastChangeGC)
@ -322,7 +320,7 @@ void CCDBNodeLeaf::setValueBool(bool prop)
setValue64(newVal);
}
void CCDBNodeLeaf::setValueRGBA (const NLMISC::CRGBA &color)
void CCDBNodeLeaf::setValueRGBA (const CRGBA &color)
{
sint64 newVal = (uint32)(color.R+(color.G<<8)+(color.B<<16)+(color.A<<24));
setValue64(newVal);
@ -367,9 +365,7 @@ void CCDBNodeLeaf::notifyObservers()
}
// mark parent branchs
if (_Parent)
{
_Parent->linkInModifiedNodeList(_Name);
}
_Parent->onLeafChanged( _Name );
}
@ -390,3 +386,5 @@ void CCDBNodeLeaf::notifyObservers()
#endif
//#############################################################################################
}

View file

@ -0,0 +1,149 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/misc/cdb_manager.h"
namespace NLMISC{
CCDBManager::CCDBManager( const char *rootNodeName, uint maxBanks ) : bankHandler( maxBanks )
{
_Database = new CCDBNodeBranch( std::string( rootNodeName ) );
}
CCDBManager::~CCDBManager()
{
if( _Database != NULL )
{
_Database->clear();
delete _Database;
_Database = NULL;
}
}
CCDBNodeLeaf* CCDBManager::getDbLeaf( const std::string &name, bool create )
{
if( name.empty() )
return NULL;
CCDBNodeLeaf *leaf = NULL;
leaf = dynamic_cast< CCDBNodeLeaf* >( _Database->getNode( ICDBNode::CTextId( name ), create ) );
return leaf;
}
CCDBNodeBranch* CCDBManager::getDbBranch( const std::string &name )
{
if( name.empty() )
return NULL;
CCDBNodeBranch *branch = NULL;
branch = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( name ), false ) );
return branch;
}
void CCDBManager::delDbNode( const stlpx_std::string &name )
{
if( name.empty() )
return;
_Database->removeNode( ICDBNode::CTextId( name ) );
}
void CCDBManager::addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter )
{
CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) );
if( b == NULL )
return;
branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter );
}
void CCDBManager::addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter )
{
if( branch == NULL )
return;
branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter );
}
void CCDBManager::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize )
{
CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) );
if( b == NULL )
return;
branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize );
}
void CCDBManager::addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize )
{
if( branch == NULL )
return;
branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize );
}
void CCDBManager::removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer )
{
CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) );
if( b == NULL )
return;
branchObservingHandler.removeBranchObserver( b, observer );
}
void CCDBManager::removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer )
{
if( branch == NULL )
return;
branchObservingHandler.removeBranchObserver( branch, observer );
}
void CCDBManager::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer )
{
CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) );
if( b == NULL )
return;
branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer );
}
void CCDBManager::removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer )
{
if( branch == NULL )
return;
branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer );
}
void CCDBManager::addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer )
{
if( observer == NULL )
return;
branchObservingHandler.addFlushObserver( observer );
}
void CCDBManager::removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer )
{
if( observer == NULL )
return;
branchObservingHandler.removeFlushObserver( observer );
}
void CCDBManager::flushObserverCalls()
{
branchObservingHandler.flushObserverCalls();
}
void CCDBManager::resetBank( uint gc, uint bank )
{
_Database->resetNode( gc, bankHandler.getUIDForBank( bank ) );
}
}

View file

@ -16,8 +16,6 @@
#include "stdpch.h"
//#define TRACE_READ_DELTA
//#define TRACE_WRITE_DELTA
//#define TRACE_SET_VALUE
@ -42,6 +40,8 @@
#include <string>
#include "../../common/src/game_share/ryzom_database_banks.h"
////////////////
// Namespaces //
@ -50,7 +50,7 @@ using namespace NLMISC;
using namespace std;
bool VerboseDatabase = false;
bool NLMISC::VerboseDatabase = false;
uint32 NbDatabaseChanges = 0;
@ -58,11 +58,11 @@ uint32 NbDatabaseChanges = 0;
// CCDBSynchronised
//
//-----------------------------------------------
CCDBSynchronised::CCDBSynchronised() : _Database(0), _InitInProgress(true), _InitDeltaReceived(0)
CCDBSynchronised::CCDBSynchronised() : _InitInProgress(true), _InitDeltaReceived(0), CCDBManager( "SERVER", NB_CDB_BANKS )
{
}
extern const char *CDBBankNames[INVALID_CDB_BANK+1];
//-----------------------------------------------
// init
@ -80,9 +80,11 @@ void CCDBSynchronised::init( const string &fileName, NLMISC::IProgressCallback &
read.init (file);
//Parse the parser output!!!
CCDBNodeBranch::resetNodeBankMapping(); // in case the game is restarted from start
_Database = new CCDBNodeBranch("SERVER");
_Database->init( read.getRootNode (), progressCallBack, true );
bankHandler.resetNodeBankMapping(); // in case the game is restarted from start
bankHandler.fillBankNames( CDBBankNames, INVALID_CDB_BANK + 1 );
if( _Database == NULL )
_Database = new CCDBNodeBranch( "SERVER" );
_Database->init( read.getRootNode (), progressCallBack, true, &bankHandler );
}
}
catch (const Exception &e)
@ -175,7 +177,7 @@ void CCDBSynchronised::write( const string &fileName )
// readDelta
//
//-----------------------------------------------
void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, TCDBBank bank )
void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, uint bank )
{
nldebug("Update DB");
@ -195,7 +197,7 @@ void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, TCDBB
for( uint i=0; i!=propertyCount; ++i )
{
_Database->readAndMapDelta( gc, s, bank );
_Database->readAndMapDelta( gc, s, bank, &bankHandler );
}
/*// Read "client only" property changes
@ -304,11 +306,12 @@ void CCDBSynchronised::clear()
{
_Database->clear();
delete _Database;
_Database = 0;
_Database = NULL;
}
// clear CCDBNodeBranch static data
CCDBNodeBranch::reset();
branchObservingHandler.reset();
bankHandler.reset();
}
@ -322,7 +325,6 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB()
}
#ifdef TRACE_READ_DELTA
#undef TRACE_READ_DELTA
#endif

View file

@ -20,8 +20,9 @@
#define CDB_SYNCHRONISED_H
#include "cdb.h"
#include "cdb_branch.h"
#include "nel/misc/cdb.h"
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_manager.h"
/**
* Class to manage a database of properties
@ -29,11 +30,8 @@
* \author Nevrax France
* \date 2002
*/
class CCDBSynchronised
class CCDBSynchronised : public NLMISC::CCDBManager
{
/// database
NLMISC::CRefPtr<CCDBNodeBranch> _Database;
/// string associations
std::map<uint32,std::string> _Strings;
@ -60,7 +58,7 @@ public:
* Return a ptr on the node
* \return ptr on the node
*/
CCDBNodeBranch * getNodePtr() { return _Database; }
NLMISC::CCDBNodeBranch * getNodePtr() { return _Database; }
/**
* Build the structure of the database from a file
@ -84,7 +82,7 @@ public:
* Update the database from a stream coming from the FE
* \param f the stream
*/
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank );
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank );
/**
* Return the value of a property (the update flag is set to false)

View file

@ -76,7 +76,7 @@
#include "user_entity.h"
#include "projectile_manager.h"
#include "init_main_loop.h"
#include "cdb_branch.h"
#include "nel/misc/cdb_branch.h"
#include "animation_fx_misc.h"
#include "attack_list.h"
#include "animation_fx_id_array.h"

View file

@ -32,6 +32,10 @@
#include <map>
#include <string>
namespace NLMISC{
class CCDBNodeLeaf;
}
//#define OLD_STRING_SYSTEM
@ -338,8 +342,8 @@ private :
/// \name Dynamic Chat channel mgt
// @{
TChanID _ChatDynamicChannelId;
class CCDBNodeLeaf *_DynamicChannelNameLeaf[CChatGroup::MaxDynChanPerPlayer];
class CCDBNodeLeaf *_DynamicChannelIdLeaf[CChatGroup::MaxDynChanPerPlayer];
NLMISC::CCDBNodeLeaf *_DynamicChannelNameLeaf[CChatGroup::MaxDynChanPerPlayer];
NLMISC::CCDBNodeLeaf *_DynamicChannelIdLeaf[CChatGroup::MaxDynChanPerPlayer];
// Id cached. If different from precedent, then the channel must be flushed
enum {DynamicChannelEmptyId=-1};
uint32 _DynamicChannelIdCache[CChatGroup::MaxDynChanPerPlayer];

View file

@ -74,7 +74,7 @@
#include "commands.h"
#include "entities.h"
#include "teleport.h"
#include "cdb_leaf.h"
#include "nel/misc/cdb_leaf.h"
#include "view.h"
#include "misc.h"
#include "demo.h"

View file

@ -390,7 +390,8 @@ bool connection (const string &cookie, const string &fsaddr)
pIM->activateMasterGroup ("ui:outgame", true);
pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// Active inputs
Actions.enable(true);
@ -553,7 +554,8 @@ bool reconnection()
pIM->activateMasterGroup ("ui:outgame", true);
pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1);
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// Active inputs
Actions.enable(true);
@ -992,7 +994,8 @@ TInterfaceState globalMenu()
pIM->initOutGame();
pIM->activateMasterGroup ("ui:outgame", true);
pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
pIM->getElementFromId("ui:outgame:charsel")->setActive(false);
pIM->getElementFromId("ui:outgame:charsel")->setActive(true);
// Active inputs
@ -1030,7 +1033,8 @@ TInterfaceState globalMenu()
}
}
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// check if we can send another dated block
if (NetMngr.getCurrentServerTick() != serverTick)
@ -1056,7 +1060,8 @@ TInterfaceState globalMenu()
// Interface handling & displaying (processes clicks...)
pIM->updateFrameEvents();
pIM->updateFrameViews(NULL);
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// Movie shooter
globalMenuMovieShooter();
@ -1121,9 +1126,11 @@ TInterfaceState globalMenu()
if (pNL != NULL)
{
pNL->setValue64 (1); // Send impulse to interface observers
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
pNL->setValue64 (0);
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
}
}
else
@ -1184,9 +1191,11 @@ TInterfaceState globalMenu()
if (pNL != NULL)
{
pNL->setValue64 (1); // Send impulse to interface observers
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
pNL->setValue64 (0);
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
}
}
}

View file

@ -91,7 +91,10 @@ class CItemSheet;
class CPhysicalDamage;
namespace NLMISC{
class CCDBNodeLeaf;
class CCDBNodeBranch;
}
extern CLFECOMMON::TCLEntityId SlotUnderCursor;
@ -809,7 +812,7 @@ public:
virtual void setDiffuse(bool onOff, NLMISC::CRGBA diffuse);
static CCDBNodeLeaf *getOpacityDBNode();
static NLMISC::CCDBNodeLeaf *getOpacityDBNode();
static uint32 getOpacityMin();
static void setOpacityMin(uint32 value);
@ -884,7 +887,7 @@ protected:
// Persistent NPC Alias of the entity
uint32 _NPCAlias;
// Local DB Branch for this entity
class CCDBNodeBranch *_DBEntry;
class NLMISC::CCDBNodeBranch *_DBEntry;
// Playlist
NL3D::UPlayList *_PlayList;
NL3D::UPlayList *_FacePlayList;
@ -1108,7 +1111,7 @@ protected:
// for localSelectBox() computing
sint64 _LastLocalSelectBoxComputeTime;
static NLMISC::CRefPtr<CCDBNodeLeaf> _OpacityMinNodeLeaf;
static NLMISC::CRefPtr<NLMISC::CCDBNodeLeaf> _OpacityMinNodeLeaf;
protected:
/**

View file

@ -1267,7 +1267,8 @@ void CFarTP::sendReady()
CInputHandlerManager::getInstance()->pumpEventsNoIM();
// Update Network.
NetMngr.update();
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// Be nice to the system
nlSleep(100);
}
@ -1405,7 +1406,8 @@ void CFarTP::farTPmainLoop()
// Update Network.
NetMngr.update();
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// TODO: resend in case the last datagram sent was lost?
// // check if we can send another dated block

View file

@ -30,7 +30,9 @@
// ***************************************************************************
class CGroupMenu;
class CViewTextMenu;
namespace NLMISC{
class CCDBNodeLeaf;
}
// ***************************************************************************
/**
@ -77,21 +79,21 @@ private:
// MilkoPad
CInterfaceGroupPtr _GroupMilkoPad;
CCDBNodeLeaf *_MilkoAttackDisengage;
NLMISC::CCDBNodeLeaf *_MilkoAttackDisengage;
CCtrlTextButtonPtr _MilkoAttDisBut1;
CCtrlTextButtonPtr _MilkoAttDisBut2;
CGroupMenu *_GroupMenu;
CCDBNodeLeaf *_ContextVal;
CCDBNodeLeaf *_AvailablePrograms;
CCDBNodeLeaf *_ServerTeamPresent;
CCDBNodeLeaf *_MissionOption[NUM_MISSION_OPTIONS];
CCDBNodeLeaf *_ServerInDuel;
CCDBNodeLeaf *_ServerInPvpChallenge;
CCDBNodeLeaf *_WebPageTitle;
CCDBNodeLeaf *_OutpostSheet;
CCDBNodeLeaf *_OutpostRightToBannish;
CCDBNodeLeaf *_MissionRing[BOTCHATTYPE::MaxR2MissionEntryDatabase];
NLMISC::CCDBNodeLeaf *_ContextVal;
NLMISC::CCDBNodeLeaf *_AvailablePrograms;
NLMISC::CCDBNodeLeaf *_ServerTeamPresent;
NLMISC::CCDBNodeLeaf *_MissionOption[NUM_MISSION_OPTIONS];
NLMISC::CCDBNodeLeaf *_ServerInDuel;
NLMISC::CCDBNodeLeaf *_ServerInPvpChallenge;
NLMISC::CCDBNodeLeaf *_WebPageTitle;
NLMISC::CCDBNodeLeaf *_OutpostSheet;
NLMISC::CCDBNodeLeaf *_OutpostRightToBannish;
NLMISC::CCDBNodeLeaf *_MissionRing[BOTCHATTYPE::MaxR2MissionEntryDatabase];
CViewTextMenuPtr _TextLootAction;

View file

@ -27,9 +27,10 @@
// Misc.
#include "nel/misc/types_nl.h"
// Game share.
#include "cdb.h"
#include "cdb_leaf.h"
#include "cdb_branch.h"
#include "nel/misc/cdb.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_branch_observing_handler.h"
#include "cdb_synchronised.h"

View file

@ -315,7 +315,8 @@ inline void waitForNetworkMessage(bool &var)
CInputHandlerManager::getInstance()->pumpEventsNoIM();
// Update network.
NetMngr.update();
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
// Send dummy info
NetMngr.send();
// Do not take all the CPU.
@ -1216,7 +1217,8 @@ void initMainLoop()
CInputHandlerManager::getInstance()->pumpEventsNoIM();
// Update Network.
NetMngr.update();
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
}
// Set the LastGameCycle

View file

@ -23,7 +23,7 @@
#include <libxml/parser.h>
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include <map>
extern bool game_exit;

View file

@ -141,10 +141,10 @@ private:
};
// update the brick help window when weight of hands has changed
class CFittedWeaponWeightObserver : public ICDBNode::IPropertyObserver
class CFittedWeaponWeightObserver : public NLMISC::ICDBNode::IPropertyObserver
{
public:
virtual void update(ICDBNode* node);
virtual void update(NLMISC::ICDBNode* node);
};

View file

@ -186,16 +186,16 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn
// ensure remove (if setuped before), then add
CCDBNodeBranch *branch;
branch= pIM->getDbBranch("LOCAL:INVENTORY:BAG");
if(branch) branch->removeBranchObserver(&_DBInventoryObs);
if(branch) branch->addBranchObserver(&_DBInventoryObs);
if(branch) pIM->removeBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs);
if(branch) pIM->addBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs);
// and for all pack animals
uint i;
for(i=0;i<MAX_INVENTORY_ANIMAL;i++)
{
branch= pIM->getDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i));
if(branch) branch->removeBranchObserver(&_DBInventoryObs);
if(branch) branch->addBranchObserver(&_DBInventoryObs);
if(branch) pIM->removeBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs);
if(branch) pIM->addBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs);
}
// Add observers on animal status, cause inventory may become unavailabe during the process

View file

@ -143,18 +143,18 @@ private:
// The Inventory manipulated.
std::vector<CItem> _InventoryMirror;
bool _InventoryObsSetup;
class CDBInventoryObs : public ICDBNode::IPropertyObserver
class CDBInventoryObs : public NLMISC::ICDBNode::IPropertyObserver
{
public:
virtual void update(ICDBNode* node);
virtual void update(NLMISC::ICDBNode* node);
};
CDBInventoryObs _DBInventoryObs;
friend class CDBInventoryObs;
// The animals Status
class CDBAnimalObs : public ICDBNode::IPropertyObserver
class CDBAnimalObs : public NLMISC::ICDBNode::IPropertyObserver
{
public:
virtual void update(ICDBNode* node);
virtual void update(NLMISC::ICDBNode* node);
};
CDBAnimalObs _DBAnimalObs;
friend class CDBAnimalObs;

View file

@ -24,6 +24,8 @@
#include "group_compas.h"
#include "game_share/animal_status.h"
using NLMISC::CCDBNodeLeaf;
// ***************************************************************************
// CPositionState
// ***************************************************************************

View file

@ -26,7 +26,9 @@
// ***************************************************************************
namespace NLMISC{
class CCDBNodeLeaf;
}
// ***************************************************************************
/**
@ -58,7 +60,7 @@ protected:
virtual bool getDbPos(sint32 &px, sint32 &py) = 0;
// helper to serial a CDBNodeLeaf, based on itsname
void serialNodeLeaf(NLMISC::IStream &f, CCDBNodeLeaf *&dbNode);
void serialNodeLeaf(NLMISC::IStream &f, NLMISC::CCDBNodeLeaf *&dbNode);
};
@ -82,8 +84,8 @@ public:
virtual void serial(NLMISC::IStream &f);
protected:
// Database infos
CCDBNodeLeaf *_DBPos;
CCDBNodeLeaf *_Uid;
NLMISC::CCDBNodeLeaf *_DBPos;
NLMISC::CCDBNodeLeaf *_Uid;
// The slot of the entity that may be used to get more precise position
CLFECOMMON::TCLEntityId _EntitySlot;
virtual CEntityCL *getEntity();
@ -103,18 +105,18 @@ class CNamedEntityPositionState : public CPositionState
public:
NLMISC_DECLARE_CLASS(CNamedEntityPositionState)
virtual bool dbOk() {return _Name && _X && _Y;}
void build(CCDBNodeLeaf *name, CCDBNodeLeaf *x, CCDBNodeLeaf *y);
CCDBNodeLeaf *getNameNode() const { return _Name; }
CCDBNodeLeaf *getXNode() const { return _X; }
CCDBNodeLeaf *getYNode() const { return _X; }
void build(NLMISC::CCDBNodeLeaf *name, NLMISC::CCDBNodeLeaf *x, NLMISC::CCDBNodeLeaf *y);
NLMISC::CCDBNodeLeaf *getNameNode() const { return _Name; }
NLMISC::CCDBNodeLeaf *getXNode() const { return _X; }
NLMISC::CCDBNodeLeaf *getYNode() const { return _X; }
//
virtual bool canSave() const { return true; }
virtual void serial(NLMISC::IStream &f);
protected:
// Database infos
CCDBNodeLeaf *_Name;
CCDBNodeLeaf *_X;
CCDBNodeLeaf *_Y;
NLMISC::CCDBNodeLeaf *_Name;
NLMISC::CCDBNodeLeaf *_X;
NLMISC::CCDBNodeLeaf *_Y;
virtual CEntityCL *getEntity();
virtual bool getDbPos(sint32 &px, sint32 &py);
};
@ -148,7 +150,7 @@ public:
virtual void serial(NLMISC::IStream &/* f */) { nlassert(0); /* notsavable */ }
protected:
// Database infos
CCDBNodeLeaf *_Present;
NLMISC::CCDBNodeLeaf *_Present;
// DB ok.
bool dbOk() {return _DBPos && _Present && _Uid;}
@ -182,7 +184,7 @@ public:
private:
// Animal Database infos
CCDBNodeLeaf *_Status;
NLMISC::CCDBNodeLeaf *_Status;
// DB ok.
bool dbOk() {return _DBPos && _Status && _Uid;}

View file

@ -23,6 +23,10 @@
#include "game_share/inventories.h"
#include "game_share/scores.h"
namespace NLMISC{
class CCDBNodeLeaf;
}
// ***************************************************************************
/**
@ -214,12 +218,12 @@ private:
CBarInfo BarInfo;
// Connection input (used only for TargetType, TeamMemberType and AnimalType)
class CCDBNodeLeaf *UIDIn;
class CCDBNodeLeaf *PresentIn; // if not NULL, this is an additional test: if(PresentIn->getValue()==0) => not present
class CCDBNodeLeaf *ScoreIn[SCORES::NUM_SCORES];
NLMISC::CCDBNodeLeaf *UIDIn;
NLMISC::CCDBNodeLeaf *PresentIn; // if not NULL, this is an additional test: if(PresentIn->getValue()==0) => not present
NLMISC::CCDBNodeLeaf *ScoreIn[SCORES::NUM_SCORES];
// Connection output
class CCDBNodeLeaf *ScoreOut[SCORES::NUM_SCORES];
NLMISC::CCDBNodeLeaf *ScoreOut[SCORES::NUM_SCORES];
public:
CBarDataEntry();
@ -258,11 +262,11 @@ private:
// last score get from impulse USER:BARS
sint32 Score;
// input DB value, to get the current MAX
class CCDBNodeLeaf *DBInMax;
NLMISC::CCDBNodeLeaf *DBInMax;
// output DB to store the real value, but clamped to 0
class CCDBNodeLeaf *DBOutVal;
NLMISC::CCDBNodeLeaf *DBOutVal;
// output DB to store the ratio -1024,1024 value
class CCDBNodeLeaf *DBOutRatio;
NLMISC::CCDBNodeLeaf *DBOutRatio;
CUserScore()
{
Score= 0;

View file

@ -50,7 +50,7 @@ void CBotChatPageMission::init()
{
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im->getDbBranch("SERVER:CHOOSE_MISSIONS"))
im->getDbBranch("SERVER:CHOOSE_MISSIONS")->addBranchObserver(&_MissionPagesObs);
im->addBranchObserver("SERVER:CHOOSE_MISSIONS", &_MissionPagesObs);
}

View file

@ -29,6 +29,8 @@
static const char *WIN_BOT_CHAT_PAGE_PLAYER_GIFT = "ui:interface:bot_chat_player_gift";
using NLMISC::CCDBNodeLeaf;
// *************************************************************************************
void CBotChatPagePlayerGift::begin()
{

View file

@ -161,7 +161,7 @@ void CBotChatPageTrade::init()
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im->getDbBranch("SERVER:TRADING"))
{
im->getDbBranch("SERVER:TRADING")->addBranchObserver(&_TradePagesObs);
im->addBranchObserver( "SERVER:TRADING", &_TradePagesObs);
}
_FamePriceFactorLeaf = im->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR");
@ -2990,7 +2990,8 @@ NLMISC_COMMAND( testResaleItems, "Temp : test resale", "" )
//
// Force for next page
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
return true;
}

View file

@ -142,7 +142,7 @@ private:
uint32 _FilterBuyDlgMaxValue;
// keep pointer on leaf for fame price factor
CCDBNodeLeaf * _FamePriceFactorLeaf;
NLMISC::CCDBNodeLeaf * _FamePriceFactorLeaf;
bool _DownloadComplete;
private:

View file

@ -23,6 +23,9 @@
class CViewBase;
class ucstring;
namespace NLMISC{
class CCDBNodeLeaf;
}
/** Class to get chat text parameters, and to build new text lines
* \author Nicolas Vizerie
@ -56,9 +59,9 @@ public:
private:
static CChatTextManager *_Instance;
mutable class CCDBNodeLeaf *_TextFontSize;
mutable CCDBNodeLeaf *_TextMultilineSpace;
mutable CCDBNodeLeaf *_TextShadowed;
mutable NLMISC::CCDBNodeLeaf *_TextFontSize;
mutable NLMISC::CCDBNodeLeaf *_TextMultilineSpace;
mutable NLMISC::CCDBNodeLeaf *_TextShadowed;
// ctor, private because of singleton
CChatTextManager();

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "ctrl_base.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "interface_manager.h"
using namespace NLMISC;

View file

@ -20,7 +20,7 @@
#include "ctrl_base_button.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../time_client.h"
#include "lua_ihm.h"

View file

@ -21,7 +21,7 @@
#include "ctrl_button.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
// ----------------------------------------------------------------------------
using namespace std;

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "interface_manager.h"
#include "ctrl_col_pick.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace NLMISC;
using namespace std;

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "interface_manager.h"
#include "ctrl_scroll.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "group_menu.h"
#include "lua_ihm.h"

View file

@ -28,7 +28,7 @@
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlBase, public ICDBNode::IPropertyObserver
class CCtrlScroll : public CCtrlBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
@ -183,7 +183,7 @@ protected:
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(ICDBNode *node);
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);

View file

@ -22,7 +22,7 @@
#include "ctrl_text_button.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "view_text.h"
#include "view_text_id.h"
#include "group_container.h"

View file

@ -21,7 +21,7 @@
#include "ctrl_tooltip.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
// ----------------------------------------------------------------------------
using namespace std;

View file

@ -43,7 +43,7 @@
#include "sbrick_manager.h"
#include "sphrase_manager.h"
#include "../client_sheets/sphrase_sheet.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "lua_ihm.h"
#include "game_share/bot_chat_types.h"

View file

@ -318,7 +318,7 @@ public:
static void setCurrSelection(CDBCtrlSheet *selected);
// get the root branch containing the properties for that sheet
CCDBNodeBranch *getRootBranch() const;
NLMISC::CCDBNodeBranch *getRootBranch() const;
/** If the branch in setSheet(branch) is of the form ...:# (where # is a number), return this number.
* The value is hence modified by setSheet(). return 0 if not of this form.
@ -443,7 +443,7 @@ public:
sint getIndexInParent() const;
// get the 'LOCKED' field in the db
CCDBNodeLeaf *getLockValuePtr() { return _GrayedLink; }
NLMISC::CCDBNodeLeaf *getLockValuePtr() { return _GrayedLink; }
/// \name Macro
// @{
@ -483,35 +483,35 @@ public:
void initSheetSize();
// @}
CCDBNodeLeaf *getSlotType() const { return _TradeSlotType.getNodePtr(); }
NLMISC::CCDBNodeLeaf *getSlotType() const { return _TradeSlotType.getNodePtr(); }
// get item weight
uint16 getItemWeight() const;
CCDBNodeLeaf *getItemWeightPtr() const;
NLMISC::CCDBNodeLeaf *getItemWeightPtr() const;
// set item weight
void setItemWeight(uint16 weight);
// get item info version
uint8 getItemInfoVersion() const;
CCDBNodeLeaf *getItemInfoVersionPtr() const;
NLMISC::CCDBNodeLeaf *getItemInfoVersionPtr() const;
// set item info version
void setItemInfoVersion(uint8 infoVersion);
// get item Locked state
uint16 getItemLocked() const;
CCDBNodeLeaf *getItemLockedPtr() const;
NLMISC::CCDBNodeLeaf *getItemLockedPtr() const;
// set item locked state
void setItemLocked(uint16 lock);
// get item PRICE. 0 if no DB
sint32 getItemPrice() const;
CCDBNodeLeaf *getItemPricePtr() const;
NLMISC::CCDBNodeLeaf *getItemPricePtr() const;
// set item PRICE
void setItemPrice(sint32 price);
// get item RESALE_FLAG. 0 if no DB
sint32 getItemResaleFlag() const;
CCDBNodeLeaf *getItemResaleFlagPtr() const;
NLMISC::CCDBNodeLeaf *getItemResaleFlagPtr() const;
// set item RESALE_FLAG
void setItemResaleFlag(sint32 rf);
@ -523,25 +523,25 @@ public:
// get item SELLER_TYPE. 0 if no DB
sint32 getItemSellerType() const;
CCDBNodeLeaf *getItemSellerTypePtr() const;
NLMISC::CCDBNodeLeaf *getItemSellerTypePtr() const;
// set item SELLER_TYPE
void setItemSellerType(sint32 rf);
// get item FABER_QUALITY. 0 if no DB
RM_CLASS_TYPE::TRMClassType getItemRMClassType() const;
CCDBNodeLeaf *getItemRMClassTypePtr() const {return _ItemRMClassType;}
NLMISC::CCDBNodeLeaf *getItemRMClassTypePtr() const {return _ItemRMClassType;}
// set item FABER_QUALITY
void setItemRMClassType(sint32 fq);
// get item FABER_STAT_TYPE. 0 if no DB
RM_FABER_STAT_TYPE::TRMStatType getItemRMFaberStatType() const;
CCDBNodeLeaf *getItemRMFaberStatTypePtr() const {return _ItemRMFaberStatType;}
NLMISC::CCDBNodeLeaf *getItemRMFaberStatTypePtr() const {return _ItemRMFaberStatType;}
// set item FABER_STAT_TYPE
void setItemRMFaberStatType(sint32 fss);
// get item PREREQUISIT_VALID. true of no DB
bool getItemPrerequisitValid() const;
CCDBNodeLeaf *getItemPrerequisitValidPtr() const;
NLMISC::CCDBNodeLeaf *getItemPrerequisitValidPtr() const;
// set item PREREQUISIT_VALID
void setItemPrerequisitValid(bool prv);
@ -610,8 +610,8 @@ protected:
CInterfaceProperty _Worned; // if true means that item is worned (red cross, no longer usable unless it's a tool)
// As node leaf for backward compatibilities
CCDBNodeLeaf *_ItemRMClassType;
CCDBNodeLeaf *_ItemRMFaberStatType;
NLMISC::CCDBNodeLeaf *_ItemRMClassType;
NLMISC::CCDBNodeLeaf *_ItemRMFaberStatType;
mutable sint32 _LastSheetId;
@ -703,7 +703,7 @@ protected:
// This String is optional and usage dependent for Item, Macro, or Sentence
std::string _OptString;
CCDBNodeLeaf *_GrayedLink;
NLMISC::CCDBNodeLeaf *_GrayedLink;
// Macro or sentence String compiled as texture Ids and positions, from the _OptString.
struct CCharBitmap
@ -734,7 +734,7 @@ protected:
sint32 _ItemCaracReqValue;
// Special for Armour
CCDBNodeLeaf *_UserColor;
NLMISC::CCDBNodeLeaf *_UserColor;
// keep pointer on item sheet
const CItemSheet *_ItemSheet;

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "dbgroup_combo_box.h"
#include "group_menu.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "interface_manager.h"
#include "ctrl_button.h"
#include "action_handler.h"

View file

@ -123,7 +123,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
_DbBranch= branch;
_DbBranchName= (const char*)prop;
// add observer
_DbBranch->addBranchObserver(&_DbBranchObs);
pIM->addBranchObserver(branch, &_DbBranchObs);
}
// parse the common ctrl info

View file

@ -141,14 +141,14 @@ protected:
// branch of the DB
CCDBNodeBranch *_DbBranch;
NLMISC::CCDBNodeBranch *_DbBranch;
std::string _DbBranchName;
// Branch observer
class CDBObs : public ICDBNode::IPropertyObserver
class CDBObs : public NLMISC::ICDBNode::IPropertyObserver
{
public:
CDBGroupListSheet *Owner;
virtual void update(ICDBNode* /* node */) {Owner->_BranchModified= true;}
virtual void update(NLMISC::ICDBNode* /* node */) {Owner->_BranchModified= true;}
};
friend class CDBObs;
CDBObs _DbBranchObs;
@ -192,7 +192,7 @@ protected:
}
// For animals only
CCDBNodeLeaf *_AnimalStatus;
NLMISC::CCDBNodeLeaf *_AnimalStatus;
sint32 _CacheAnimalStatus;
// For sectionnable purpose

View file

@ -44,7 +44,7 @@ public:
private:
sint32 _TextId;
std::vector<CCDBNodeLeaf*> _DisableStates;
std::vector<NLMISC::CCDBNodeLeaf*> _DisableStates;
};

View file

@ -45,7 +45,7 @@ public:
virtual bool isInvalidated(CDBGroupListSheet *pFather);
virtual void update(CDBGroupListSheet *pFather);
virtual sint getSectionId() const;
CCDBNodeLeaf *LevelDB;
NLMISC::CCDBNodeLeaf *LevelDB;
uint LevelCache;
};

View file

@ -20,7 +20,7 @@
#include "dbgroup_list_sheet_mission.h"
#include "view_text_id_formated.h"
#include "../cdb_leaf.h"
#include "nel/misc/cdb_leaf.h"
#include "interface_manager.h"
using namespace std;

View file

@ -20,7 +20,7 @@
#include "dbgroup_list_sheet_text.h"
#include "group_container.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../sheet_manager.h"
#include "ctrl_button.h"
#include "view_text.h"
@ -107,7 +107,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
_DbBranch= branch;
_DbBranchName= (const char*)prop;
// add observer
_DbBranch->addBranchObserver(&_DbBranchObs);
pIM->addBranchObserver( branch, &_DbBranchObs );
}
// parse the common ctrl info

View file

@ -203,14 +203,14 @@ protected:
// branch of the DB
CCDBNodeBranch *_DbBranch;
NLMISC::CCDBNodeBranch *_DbBranch;
std::string _DbBranchName;
// Branch observer
class CDBObs : public ICDBNode::IPropertyObserver
class CDBObs : public NLMISC::ICDBNode::IPropertyObserver
{
public:
CDBGroupListSheetText *Owner;
virtual void update(ICDBNode* /* node */) {Owner->_BranchModified= true;}
virtual void update(NLMISC::ICDBNode* /* node */) {Owner->_BranchModified= true;}
};
friend class CDBObs;
CDBObs _DbBranchObs;
@ -269,7 +269,7 @@ protected:
sint getIndexOf(const CCtrlButton *button) const;
// For animals only
CCDBNodeLeaf *_AnimalStatus;
NLMISC::CCDBNodeLeaf *_AnimalStatus;
sint32 _CacheAnimalStatus;
// For items only (requirement color)

View file

@ -17,7 +17,7 @@
#include "stdpch.h"
#include "dbgroup_list_sheet_text_brick_composition.h"
#include "../client_sheets/sbrick_sheet.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../string_manager_client.h"
#include "sbrick_manager.h"

View file

@ -46,7 +46,7 @@ public:
virtual void update(CDBGroupListSheetText *pFather);
virtual void updateViewText(CDBGroupListSheetText *pFather);
virtual sint getSectionId() const;
CCDBNodeLeaf *LevelDB;
NLMISC::CCDBNodeLeaf *LevelDB;
uint LevelCache;
};

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "dbgroup_list_sheet_text_share.h"
#include "../client_sheets/sbrick_sheet.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "interface_manager.h"
#include "view_bitmap.h"
#include "ctrl_text_button.h"

View file

@ -20,7 +20,7 @@
#include "dbgroup_list_sheet_trade.h"
#include "interface_manager.h"
#include "inventory_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../sheet_manager.h"
#include "ctrl_button.h"
#include "view_text.h"

View file

@ -140,7 +140,7 @@ protected:
bool _ApplyFamePriceFactor;
// keep pointer on leaf for fame price factor
CCDBNodeLeaf * _FamePriceFactorLeaf;
NLMISC::CCDBNodeLeaf * _FamePriceFactorLeaf;
sint16 _LastFamePriceFactor;
TSellerTypeFilter _SellerTypeFilter;

View file

@ -21,7 +21,7 @@
#include "dbview_bar.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;

View file

@ -21,7 +21,7 @@
#include "dbview_bar3.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NL3D;

View file

@ -20,7 +20,7 @@
#include "dbview_digit.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NL3D;

View file

@ -20,7 +20,7 @@
#include "dbview_number.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/misc/common.h"
using namespace std;

View file

@ -21,7 +21,7 @@
#include "dbview_quantity.h"
#include "interface_manager.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NL3D;

View file

@ -23,7 +23,7 @@
#include "interface_element.h"
//#include "game_share/jobs.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;

View file

@ -18,7 +18,7 @@
#include "stdpch.h"
//
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
//
#include "group_compas.h"
#include "interface_3d_scene.h"

View file

@ -110,7 +110,7 @@ private:
CCompassTarget _SavedTarget;
bool _SavedTargetValid;
CCDBNodeLeaf *_DynamicTargetPos;
NLMISC::CCDBNodeLeaf *_DynamicTargetPos;
uint32 _LastDynamicTargetPos;
// Color for each type of target

View file

@ -22,7 +22,7 @@
#include "group_container.h"
#include "interface_manager.h"
#include "interface_options.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "action_handler.h"
#include "../time_client.h"
#include "group_editbox.h"

View file

@ -23,7 +23,7 @@
#include "input_handler_manager.h"
#include "nel/misc/command.h"
#include "view_text.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "interface_options.h"
#include "dbctrl_sheet.h"
#include "group_container.h"

View file

@ -21,7 +21,7 @@
#include "group_frame.h"
#include "interface_manager.h"
#include "interface_element.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -22,7 +22,7 @@
#include "stdpch.h"
#include "group_html_cs.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "interface_manager.h"

View file

@ -22,7 +22,7 @@
#include "stdpch.h"
#include "group_html_forum.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "../user_entity.h"
#include "guild_manager.h"

View file

@ -22,7 +22,7 @@
#include "stdpch.h"
#include "group_html_mail.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "../user_entity.h"
#include "interface_manager.h"

View file

@ -22,7 +22,7 @@
#include "stdpch.h"
#include "group_html_qcm.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "interface_manager.h"
#include "../user_entity.h"

View file

@ -17,7 +17,7 @@
#include "stdpch.h"
#include "group_html_webig.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"
#include "../user_entity.h"
#include "../entities.h"

View file

@ -24,7 +24,7 @@
#include "group_in_scene.h"
#include "interface_manager.h"
#include "view_renderer.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -93,9 +93,9 @@ protected:
static NLMISC::CRGBA BarColorHPNegative;
// Node user leaf
static CCDBNodeLeaf *_Value;
static CCDBNodeLeaf *_ValueBegin;
static CCDBNodeLeaf *_ValueEnd;
static NLMISC::CCDBNodeLeaf *_Value;
static NLMISC::CCDBNodeLeaf *_ValueBegin;
static NLMISC::CCDBNodeLeaf *_ValueEnd;
// Special guild
bool _NeedGuildNameId;

View file

@ -29,7 +29,7 @@
#include "lua_ihm.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -38,7 +38,7 @@
#include "../global.h"
#include "ctrl_quad.h"
//
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "game_share/mission_desc.h"
#include "game_share/inventories.h"
#include "game_share/animal_type.h"

View file

@ -35,7 +35,9 @@
class CContinent;
namespace NLMISC{
class CCDBNodeLeaf;
}
class CWorldSheet;
class CCtrlQuad;
struct SMap;
@ -425,8 +427,8 @@ private:
// have the texts been received for mission targets ?
std::vector<bool> _MissionTargetTextReceived;
// ptr on db leaf for coordinates of special landmarks
CCDBNodeLeaf *_TargetPos;
CCDBNodeLeaf *_HomePos;
NLMISC::CCDBNodeLeaf *_TargetPos;
NLMISC::CCDBNodeLeaf *_HomePos;
// Animals State for landMarks
std::vector<NLMISC::CSmartPtr<CAnimalPositionState> > _AnimalPosStates;
// Teammate State for landMarks

View file

@ -21,7 +21,7 @@
#include "interface_manager.h"
#include "interface_expr.h"
#include "group_menu.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "view_bitmap.h"
#include "action_handler.h" // Just for getAllParams
#include "lua_ihm.h"

View file

@ -21,7 +21,7 @@
#include "group_modal.h"
#include "interface_manager.h"
#include "interface_element.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;

View file

@ -30,7 +30,7 @@
#include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -26,7 +26,7 @@
#include "game_share/skills.h"
#include "game_share/brick_families.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "skill_manager.h"
#include "sbrick_manager.h"

View file

@ -53,12 +53,12 @@ private:
private:
// observer to know that brick family are modified
struct CBrickFamilyObs : public ICDBNode::IPropertyObserver
struct CBrickFamilyObs : public NLMISC::ICDBNode::IPropertyObserver
{
CGroupPhraseSkillFilter *Owner;
BRICK_FAMILIES::TBrickFamily BrickFamily;
virtual void update (ICDBNode *node);
virtual void update (NLMISC::ICDBNode *node);
};
friend struct CBrickFamilyObs;
CBrickFamilyObs _BrickFamilyObs[BRICK_FAMILIES::NbFamilies];

View file

@ -27,7 +27,7 @@
#include "../libwww.h"
#include "interface_manager.h"
#include "action_handler.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../client_cfg.h"

View file

@ -29,7 +29,7 @@
#include "dbview_bar.h"
#include "game_share/skills.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "skill_manager.h"
#include "nel/misc/i_xml.h"

View file

@ -51,10 +51,10 @@ private:
private:
// observer to know that skills are modified
struct CSkillsObs : public ICDBNode::IPropertyObserver
struct CSkillsObs : public NLMISC::ICDBNode::IPropertyObserver
{
CGroupSkills *Owner;
virtual void update (ICDBNode *node);
virtual void update (NLMISC::ICDBNode *node);
} _SkillsObs;
friend struct CSkillsObs;

View file

@ -19,7 +19,7 @@
#include "stdpch.h"
#include "group_tab.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "../time_client.h"
#include "interface_manager.h"

View file

@ -29,7 +29,7 @@
#include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -30,7 +30,7 @@
#include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
using namespace std;
using namespace NLMISC;

View file

@ -672,20 +672,14 @@ void CGuildManager::initDBObservers()
CInterfaceManager *pIM = CInterfaceManager::getInstance();
// add an observer on the whole guild
CCDBNodeBranch *pGuild = pIM->getDbBranch("SERVER:GUILD");
if (pGuild != NULL)
pGuild->addBranchObserver(&_DBObs);
pIM->addBranchObserver( "SERVER:GUILD", &_DBObs );
// add an observer on members only => need to update all
CCDBNodeBranch *pGuildMembers = pIM->getDbBranch("SERVER:GUILD:MEMBERS");
if (pGuildMembers != NULL)
pGuildMembers->addBranchObserver(&_DBObsMembers);
pIM->addBranchObserver("SERVER:GUILD:MEMBERS", &_DBObsMembers);
// observer on ascencors
Ascensors.setListType(CHugeListObs::Ascensor);
CCDBNodeBranch *pAscensor = pIM->getDbBranch("SERVER:ASCENSOR");
if (pAscensor != NULL)
pAscensor->addBranchObserver(&Ascensors);
pIM->addBranchObserver("SERVER:ASCENSOR", &Ascensors);
}
// ***************************************************************************

View file

@ -22,7 +22,7 @@
#include "nel/misc/types_nl.h"
#include "obs_huge_list.h"
#include "dbgroup_list_sheet_text.h"
#include "../cdb.h"
#include "nel/misc/cdb.h"
#include "game_share/guild_grade.h"
#include "game_share/misc_const.h"
@ -209,15 +209,15 @@ private:
// Database management stuff
class CDBObs : public ICDBNode::IPropertyObserver
class CDBObs : public NLMISC::ICDBNode::IPropertyObserver
{
public:
virtual void update(ICDBNode* node);
virtual void update(NLMISC::ICDBNode* node);
};
class CDBObsMembers : public ICDBNode::IPropertyObserver
class CDBObsMembers : public NLMISC::ICDBNode::IPropertyObserver
{
public:
virtual void update(ICDBNode* node);
virtual void update(NLMISC::ICDBNode* node);
};
CDBObs _DBObs;

View file

@ -22,7 +22,7 @@
#include "nel/misc/file.h"
#include "nel/misc/game_device_events.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "input_handler_manager.h"
#include "interface_manager.h"

View file

@ -29,7 +29,7 @@
#include "nel/3d/u_particle_system_instance.h"
#include "nel/3d/u_animation_set.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "action_handler.h"
#include "lua_ihm.h"

View file

@ -22,7 +22,7 @@
#include "interface_anim.h"
#include "interface_manager.h"
#include "interface_expr.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
#include "action_handler.h"
#include "../time_client.h"

View file

@ -22,7 +22,9 @@
#include "nel/misc/stream.h"
class CGroupContainer;
namespace NLMISC{
class CCDBNodeLeaf;
}
/**
* interface config
@ -111,8 +113,8 @@ public:
// ------------------------------
void serial (NLMISC::IStream &f);
// ------------------------------
void setFrom (CCDBNodeLeaf *pNL);
void setTo (CCDBNodeLeaf *pNL);
void setFrom (NLMISC::CCDBNodeLeaf *pNL);
void setTo (NLMISC::CCDBNodeLeaf *pNL);
};
void dataBaseToStream (NLMISC::IStream &f);

View file

@ -25,7 +25,7 @@
#include "group_modal.h"
#include "../client_cfg.h"
#include "game_share/xml_auto_ptr.h"
#include "nel/misc/xml_auto_ptr.h"
//
using namespace std;
@ -790,7 +790,8 @@ void CInterfaceDDX::updateRealtime(CCtrlBase *pSB, bool updateOnScrollEnd)
ClientCfg.IsInvalidated = true;
}
CCDBNodeBranch::flushObserversCalls();
IngameDbMngr.flushObserverCalls();
CInterfaceManager::getInstance()->flushObserverCalls();
for (i = 0; i < _Parameters.size(); ++i)
{

Some files were not shown because too many files have changed in this diff Show more