CDB no longer depends on Ryzom database banks.

--HG--
branch : cdb-refactoring
This commit is contained in:
dfighter1985 2012-04-16 02:18:07 +02:00
parent 634739af81
commit 0b3eec581d
5 changed files with 21 additions and 23 deletions

View file

@ -68,25 +68,25 @@ CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL;
uint CCDBNodeBranch::_CurrNotifiedObsList = 0; uint CCDBNodeBranch::_CurrNotifiedObsList = 0;
// Mapping from server database index to client database index (first-level nodes) // Mapping from server database index to client database index (first-level nodes)
vector<uint> CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [NB_CDB_BANKS]; vector<uint> CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX];
// Mapping from client database index to TCDBBank (first-level nodes) // Mapping from client database index to TCDBBank (first-level nodes)
vector<TCDBBank> CCDBNodeBranch::_UnifiedIndexToBank; vector<uint> CCDBNodeBranch::_UnifiedIndexToBank;
// Last index mapped // Last index mapped
uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0; uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0;
// Number of bits for first-level branches, by bank // Number of bits for first-level branches, by bank
uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS]; uint CCDBNodeBranch::_FirstLevelIdBitsByBank [CDB_BANKS_MAX];
extern const char *CDBBankNames[INVALID_CDB_BANK+1]; extern const char *CDBBankNames[CDB_BANK_INVALID+1];
std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers; std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers;
// reset all static data // reset all static data
void CCDBNodeBranch::reset() void CCDBNodeBranch::reset()
{ {
for ( uint b=0; b<NB_CDB_BANKS; ++b ) for ( uint b=0; b<CDB_BANKS_MAX; ++b )
_CDBBankToUnifiedIndexMapping[b].clear(); _CDBBankToUnifiedIndexMapping[b].clear();
_UnifiedIndexToBank.clear(); _UnifiedIndexToBank.clear();
_CDBLastUnifiedIndex = 0; _CDBLastUnifiedIndex = 0;
@ -111,14 +111,14 @@ void CCDBNodeBranch::mapNodeByBank( ICDBNode * /* node */, const string& bankStr
} }
else*/ // now clientOnly indices are known by the server as well else*/ // now clientOnly indices are known by the server as well
{ {
for ( uint b=0; b!=INVALID_CDB_BANK; ++b ) for ( uint b=0; b!=CDB_BANK_INVALID; ++b )
{ {
if ( string(CDBBankNames[b]) == bankStr ) if ( string(CDBBankNames[b]) == bankStr )
{ {
//nldebug( "CDB: Mapping %s.%u to Unified.%u", CDBBankNames[b], _CDBBankToUnifiedIndexMapping[b].size(), _CDBLastUnifiedIndex ); //nldebug( "CDB: Mapping %s.%u to Unified.%u", CDBBankNames[b], _CDBBankToUnifiedIndexMapping[b].size(), _CDBLastUnifiedIndex );
_CDBBankToUnifiedIndexMapping[b].push_back( _CDBLastUnifiedIndex ); _CDBBankToUnifiedIndexMapping[b].push_back( _CDBLastUnifiedIndex );
++_CDBLastUnifiedIndex; ++_CDBLastUnifiedIndex;
_UnifiedIndexToBank.push_back( (TCDBBank)b ); _UnifiedIndexToBank.push_back( b );
break; break;
} }
} }
@ -270,7 +270,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressC
nlassertex( _UnifiedIndexToBank.size() == countNode, ("Mapped: %u Nodes: %u", _UnifiedIndexToBank.size(), countNode) ); nlassertex( _UnifiedIndexToBank.size() == countNode, ("Mapped: %u Nodes: %u", _UnifiedIndexToBank.size(), countNode) );
_IdBits = 0; _IdBits = 0;
for ( uint b=0; b!=NB_CDB_BANKS; ++b ) for ( uint b=0; b!=CDB_BANKS_MAX; ++b )
{ {
uint nbNodesOfBank = (uint)_CDBBankToUnifiedIndexMapping[b].size(); uint nbNodesOfBank = (uint)_CDBBankToUnifiedIndexMapping[b].size();
uint idb = 0; uint idb = 0;
@ -459,7 +459,7 @@ bool CCDBNodeBranch::setProp( CTextId& id, sint64 value )
/* /*
* Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping) * 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( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank )
{ {
nlassert( ! isAtomic() ); // root node mustn't be atomic nlassert( ! isAtomic() ); // root node mustn't be atomic

View file

@ -20,7 +20,11 @@
#define CDB_BRANCH_H #define CDB_BRANCH_H
#include "cdb.h" #include "cdb.h"
#include "game_share/ryzom_database_banks.h"
enum{
CDB_BANKS_MAX = 3,
CDB_BANK_INVALID
};
/** /**
* Database Node which contains a set of properties * Database Node which contains a set of properties
@ -99,7 +103,7 @@ public:
void write( CTextId& id, FILE * f); void write( CTextId& id, FILE * f);
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping) /// 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( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank );
/// Update the database from a stream coming from the FE /// Update the database from a stream coming from the FE
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ); void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
@ -125,7 +129,7 @@ public:
void clear(); void clear();
/// Reset the data corresponding to the bank (works only on top level node) /// Reset the data corresponding to the bank (works only on top level node)
void resetBank( NLMISC::TGameCycle gc, TCDBBank bank) void resetBank( NLMISC::TGameCycle gc, uint bank)
{ {
//nlassert( getParent() == NULL ); //nlassert( getParent() == NULL );
for ( uint i=0; i!=_Nodes.size(); ++i ) for ( uint i=0; i!=_Nodes.size(); ++i )
@ -323,16 +327,16 @@ protected:
static CDBBranchObsInfo *_NextNotifiedObs; static CDBBranchObsInfo *_NextNotifiedObs;
/// Mapping from server database index to client database index (first-level nodes) /// Mapping from server database index to client database index (first-level nodes)
static std::vector<uint> _CDBBankToUnifiedIndexMapping [NB_CDB_BANKS]; static std::vector<uint> _CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX];
// Mapping from client database index to TCDBBank (first-level nodes) // Mapping from client database index to TCDBBank (first-level nodes)
static std::vector<TCDBBank> _UnifiedIndexToBank; static std::vector<uint> _UnifiedIndexToBank;
/// Last index mapped /// Last index mapped
static uint _CDBLastUnifiedIndex; static uint _CDBLastUnifiedIndex;
/// Number of bits for first-level branches, by bank /// Number of bits for first-level branches, by bank
static uint _FirstLevelIdBitsByBank [NB_CDB_BANKS]; static uint _FirstLevelIdBitsByBank [CDB_BANKS_MAX];
/// called by clear /// called by clear
void removeAllBranchObserver(); void removeAllBranchObserver();

View file

@ -16,9 +16,6 @@
#include "stdpch.h"
//#define TRACE_READ_DELTA //#define TRACE_READ_DELTA
//#define TRACE_WRITE_DELTA //#define TRACE_WRITE_DELTA
//#define TRACE_SET_VALUE //#define TRACE_SET_VALUE
@ -31,7 +28,6 @@
#include "cdb_leaf.h" #include "cdb_leaf.h"
#include "game_share/xml_auto_ptr.h" #include "game_share/xml_auto_ptr.h"
//#include <iostream.h> //#include <iostream.h>
#include "interface_v3/interface_manager.h"
//////////////// ////////////////
// Namespaces // // Namespaces //

View file

@ -16,8 +16,6 @@
#include "stdpch.h"
//#define TRACE_READ_DELTA //#define TRACE_READ_DELTA
//#define TRACE_WRITE_DELTA //#define TRACE_WRITE_DELTA
//#define TRACE_SET_VALUE //#define TRACE_SET_VALUE
@ -175,7 +173,7 @@ void CCDBSynchronised::write( const string &fileName )
// readDelta // readDelta
// //
//----------------------------------------------- //-----------------------------------------------
void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, TCDBBank bank ) void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, uint bank )
{ {
nldebug("Update DB"); nldebug("Update DB");

View file

@ -84,7 +84,7 @@ public:
* Update the database from a stream coming from the FE * Update the database from a stream coming from the FE
* \param f the stream * \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) * Return the value of a property (the update flag is set to false)