Add PACKED type to CDB for brick bitfields

--HG--
branch : cdb-packed
hg/feature/cdb-packed
kaetemi 10 years ago
parent 14fda8a39a
commit 06e9d20850

@ -62,7 +62,7 @@ public:
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
TEXT, Nb_Prop_Type
TEXT, PACKED, Nb_Prop_Type
};

@ -79,6 +79,9 @@ void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBac
// IF it is a TEXT.
if(!strcmp(type, "TEXT"))
_Type = ICDBNode::TEXT;
// IF it is a PACKED.
else if (!strcmp(type, "PACKED"))
_Type = ICDBNode::PACKED;
// ELSE type unknown.
else
{
@ -123,6 +126,24 @@ void CCDBNodeLeaf::write( CTextId& id, FILE * f)
fprintf(f,"%"NL_I64"d\t%s\n",_Property,id.toString().c_str());
} // write //
inline uint readPackedBitCount(CBitMemStream & f)
{
uint64 isPacked;
f.serial(isPacked, 1);
if (isPacked)
{
uint64 bitCount;
f.serial(bitCount, 4);
nlinfo("PACKED: %u bits", (uint32)(bitCount << 2));
return bitCount << 2;
}
else
{
nlinfo("PACKED: Not packed");
return 64;
}
}
//-----------------------------------------------
// readDelta
//-----------------------------------------------
@ -136,6 +157,8 @@ void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f )
uint bits;
if (_Type == TEXT)
bits = 32;
else if (_Type == PACKED)
bits = readPackedBitCount(f);
else if (_Type <= I64)
bits = _Type;
else
@ -154,7 +177,7 @@ void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f )
_Property = (sint64)recvd;
// if signed
if (! ((_Type == TEXT) || (_Type <= I64)))
if (! ((_Type == TEXT) || (_Type == PACKED) || (_Type <= I64)))
{
// extend bit sign
sint64 mask = (((sint64)1)<<bits)-(sint64)1;

@ -924,15 +924,7 @@
<branch name=""
count="1024">
<leaf name="BRICKS"
type="I64" />
</branch>
</branch>
<branch name="FABER_PLANS"
bank="PLR">
<branch name=""
count="64">
<leaf name="KNOWN"
type="I64" />
type="PACKED" />
</branch>
</branch>
<branch name="MISSIONS"

@ -0,0 +1,2 @@
F:\tools\xsltproc\xsltproc.exe -o R:\code\ryzom\server\src\entities_game_service\database_plr.h --stringparam output header --stringparam filename DATABASE --stringparam side server --stringparam bank PLR R:\code\ryzom\common\src\game_share\generate_client_db.xslt R:\code\ryzom\common\data_common\database.xml
F:\tools\xsltproc\xsltproc.exe -o R:\code\ryzom\server\src\entities_game_service\database_plr.cpp --stringparam output cpp --stringparam filename database_plr --stringparam side server --stringparam bank PLR R:\code\ryzom\common\src\game_share\generate_client_db.xslt R:\code\ryzom\common\data_common\database.xml

@ -689,6 +689,7 @@ void <xsl:call-template name="makeFullClassName"/>::init(ICDBStructNode *parent<
<xsl:when test="$leafType = 'S64'"> <xsl:text>sint64</xsl:text> </xsl:when>
<xsl:when test="$leafType = 'TEXT'"> <xsl:text>ucstring</xsl:text> </xsl:when>
<xsl:when test="$leafType = 'PACKED'"> <xsl:text>uint64</xsl:text> </xsl:when>
<xsl:otherwise> <xsl:message terminate="yes">Unsupported leaf type <xsl:value-of select="$leafType"/></xsl:message></xsl:otherwise>
</xsl:choose>
</xsl:if>

@ -1,18 +1,3 @@
// 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/>.
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
@ -41,7 +26,6 @@ CBankAccessor_PLR::TASCENSOR CBankAccessor_PLR::_ASCENSOR;
CBankAccessor_PLR::TCHOOSE_MISSIONS CBankAccessor_PLR::_CHOOSE_MISSIONS;
CBankAccessor_PLR::TTRADING CBankAccessor_PLR::_TRADING;
CBankAccessor_PLR::TBRICK_FAMILY CBankAccessor_PLR::_BRICK_FAMILY;
CBankAccessor_PLR::TFABER_PLANS CBankAccessor_PLR::_FABER_PLANS;
CBankAccessor_PLR::TMISSIONS CBankAccessor_PLR::_MISSIONS;
CBankAccessor_PLR::TEXECUTE_PHRASE CBankAccessor_PLR::_EXECUTE_PHRASE;
CBankAccessor_PLR::TCHARACTER_INFO CBankAccessor_PLR::_CHARACTER_INFO;
@ -153,11 +137,6 @@ void CBankAccessor_PLR::init()
// call sub branch init
_BRICK_FAMILY.init(node);
node = bank->getICDBStructNodeFromName( BankTag, "FABER_PLANS" );
nlassert(node != NULL);
// call sub branch init
_FABER_PLANS.init(node);
node = bank->getICDBStructNodeFromName( BankTag, "MISSIONS" );
nlassert(node != NULL);
// call sub branch init
@ -2251,45 +2230,6 @@ void CBankAccessor_PLR::TBRICK_FAMILY::TArray::init(ICDBStructNode *parent, uint
}
void CBankAccessor_PLR::TFABER_PLANS::init(ICDBStructNode *parent)
{
ICDBStructNode *node = parent;
_BranchNode = node;
// leaf init
// branch init
for (uint i=0; i<64; ++i)
{
node = parent->getNode( ICDBStructNode::CTextId(NLMISC::toString("%u", i)), false );
nlassert(node != NULL);
_Array[i].init(node, i);
}
}
void CBankAccessor_PLR::TFABER_PLANS::TArray::init(ICDBStructNode *parent, uint index)
{
ICDBStructNode *node = parent;
_BranchNode = node;
// leaf init
node = parent->getNode( ICDBStructNode::CTextId("KNOWN"), false );
nlassert(node != NULL);
_KNOWN = node;
// branch init
}
void CBankAccessor_PLR::TMISSIONS::init(ICDBStructNode *parent)
{
ICDBStructNode *node = parent;
@ -3140,10 +3080,11 @@ void CBankAccessor_PLR::TPACK_ANIMAL::TBEAST::init(ICDBStructNode *parent, uint
nlassert(node != NULL);
_DESPAWN = node;
node = parent->getNode( ICDBStructNode::CTextId("NAME"), true );
node = parent->getNode( ICDBStructNode::CTextId("NAME"), false );
nlassert(node != NULL);
_NAME = node;
// branch init
}

@ -1,22 +1,7 @@
// 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 INCLUDED_database_PLR_H
#define INCLUDED_database_PLR_H
#ifndef INCLUDED_DATABASE_PLR_H
#define INCLUDED_DATABASE_PLR_H
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
@ -954,6 +939,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _DEFAULT_WEIGHT_HANDS;
}
void setIS_INVISIBLE(CCDBSynchronised &dbGroup, bool value, bool forceSending = false)
{
_setProp(dbGroup, _IS_INVISIBLE, value, forceSending);
}
bool getIS_INVISIBLE(const CCDBSynchronised &dbGroup)
{
bool value;
_getProp(dbGroup, _IS_INVISIBLE, value);
return value;
}
ICDBStructNode *getIS_INVISIBLECDBNode()
{
return _IS_INVISIBLE;
}
void setCOUNTER(CCDBSynchronised &dbGroup, uint8 value, bool forceSending = false)
{
@ -976,20 +981,6 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
return _COUNTER;
}
void setIS_INVISIBLE(CCDBSynchronised &dbGroup, bool value, bool forceSending = false)
{
_setProp(dbGroup, _IS_INVISIBLE, value, forceSending);
}
bool getIS_INVISIBLE(const CCDBSynchronised &dbGroup)
{
bool value;
_getProp(dbGroup, _IS_INVISIBLE, value);
return value;
}
TSKILL_POINTS_ &getSKILL_POINTS_(uint32 index)
{
nlassert(index < 4);
@ -1309,7 +1300,6 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
return _DODGE;
}
TBRICK_TICK_RANGE &getBRICK_TICK_RANGE()
{
return _BRICK_TICK_RANGE;
@ -3467,6 +3457,8 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
void setMONEY(CCDBSynchronised &dbGroup, uint64 value, bool forceSending = false)
{
_setProp(dbGroup, _MONEY, value, forceSending);
}
@ -4568,6 +4560,8 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
void setMONEY(CCDBSynchronised &dbGroup, uint64 value, bool forceSending = false)
{
_setProp(dbGroup, _MONEY, value, forceSending);
}
@ -4575,6 +4569,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
uint64 value;
_getProp(dbGroup, _MONEY, value);
return value;
}
@ -4582,8 +4577,10 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
return _MONEY;
}
};
private:
ICDBStructNode *_BranchNode;
@ -4605,8 +4602,11 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _BranchNode;
}
void setMONEY(CCDBSynchronised &dbGroup, uint64 value, bool forceSending = false)
{
_setProp(dbGroup, _MONEY, value, forceSending);
}
@ -6000,6 +6000,8 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
void setMONEY_SHEET(CCDBSynchronised &dbGroup, NLMISC::CSheetId value, bool forceSending = false)
{
_setProp(dbGroup, _MONEY_SHEET, value, forceSending);
}
@ -6536,77 +6538,6 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
};
class TFABER_PLANS
{
public:
class TArray
{
public:
private:
ICDBStructNode *_BranchNode;
ICDBStructNode *_KNOWN;
public:
void init(ICDBStructNode *parent, uint index);
// accessor to branch node
ICDBStructNode *getCDBNode()
{
return _BranchNode;
}
void setKNOWN(CCDBSynchronised &dbGroup, uint64 value, bool forceSending = false)
{
_setProp(dbGroup, _KNOWN, value, forceSending);
}
uint64 getKNOWN(const CCDBSynchronised &dbGroup)
{
uint64 value;
_getProp(dbGroup, _KNOWN, value);
return value;
}
ICDBStructNode *getKNOWNCDBNode()
{
return _KNOWN;
}
};
private:
ICDBStructNode *_BranchNode;
TArray _Array[64];
public:
void init(ICDBStructNode *parent);
// accessor to branch node
ICDBStructNode *getCDBNode()
{
return _BranchNode;
}
TArray &getArray(uint32 index)
{
nlassert(index < 64);
return _Array[index];
}
};
class TMISSIONS
{
public:
@ -8857,6 +8788,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
ICDBStructNode *_DESPAWN;
ICDBStructNode *_NAME;
public:
void init(ICDBStructNode *parent, uint index);
@ -9045,12 +8977,26 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
return _DESPAWN;
}
void setNAME(CCDBSynchronised &dbGroup, uint32 value, bool forceSending = false)
void setNAME(CCDBSynchronised &dbGroup, ucstring value, bool forceSending = false)
{
_setProp(dbGroup, _NAME, value, forceSending);
}
uint32 getNAME(const CCDBSynchronised &dbGroup)
ucstring getNAME(const CCDBSynchronised &dbGroup)
{
ucstring value;
_getProp(dbGroup, _NAME, value);
return value;
}
void setNAME(CCDBSynchronised &dbGroup, uint32 stringId, bool forceSending = false)
{
_setProp(dbGroup, _NAME, stringId, forceSending);
}
uint32 getNAME_id(const CCDBSynchronised &dbGroup)
{
uint32 value;
_getProp(dbGroup, _NAME, value);
@ -9062,6 +9008,7 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
return _NAME;
}
};
@ -10316,8 +10263,6 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
static TBRICK_FAMILY _BRICK_FAMILY;
static TFABER_PLANS _FABER_PLANS;
static TMISSIONS _MISSIONS;
static TEXECUTE_PHRASE _EXECUTE_PHRASE;
@ -10426,10 +10371,6 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
{
return _BRICK_FAMILY;
}
static TFABER_PLANS &getFABER_PLANS()
{
return _FABER_PLANS;
}
static TMISSIONS &getMISSIONS()
{
return _MISSIONS;
@ -10483,4 +10424,4 @@ inline void _getProp(const CCDBSynchronised &db, ICDBStructNode *node, NLMISC::C
};
#endif // INCLUDED_database_PLR_H
#endif // INCLUDED_DATABASE_PLR_H

@ -55,7 +55,7 @@ public:
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
TEXT, Nb_Prop_Type
TEXT, PACKED, Nb_Prop_Type
};

@ -79,6 +79,9 @@ void CCDBStructNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &progr
// IF it is a TEXT.
if(!strcmp(type, "TEXT"))
_Type = ICDBStructNode::TEXT;
// IF it is a PACKED.
else if(!strcmp(type, "PACKED"))
_Type = ICDBStructNode::PACKED;
// ELSE type unknown.
else
{

@ -517,6 +517,68 @@ bool CCDBSynchronised::writePermanentDelta( NLMISC::CBitMemStream& s )
return true;
}
inline void pushPackedValue( CBitMemStream& s, uint64 value, uint32& bitsize, uint &bits )
{
// fast count of max bit
uint32 next = (uint32)(value >> 32);
uint32 test;
bits = 0;
if (next) // 64bit
{
bits += 32;
test = next;
}
else
{
test = (uint32)(value & 0xFFFFFFFF);
}
next >>= 16;
if (next)
{
bits += 16;
test = next;
}
else
{
test = next & 0xFFFF;
}
next >>= 8;
if (next)
{
bits += 8;
test = next;
}
else
{
test = next & 0xFF;
}
next >>= 4;
if (next)
{
bits += 4;
test = next;
}
else
{
test = next & 0xF;
}
if (bits + 5 > 64) // 1 bit isPacked, 4 bits bitCount
{
uint64 isPacked = 0;
s.serialAndLog2( isPacked, 1 );
s.serialAndLog2( value, 64 );
bitsize += 65;
}
else
{
uint64 isPacked = 1;
uint64 bitCount = bits >> 2;
s.serialAndLog2( isPacked, 1 );
s.serialAndLog2( bitCount, 4 );
s.serialAndLog2( value, bits );
bitsize += (bits + 5);
}
}
/*
* Push one change to the stream
@ -540,6 +602,13 @@ void CCDBSynchronised::pushDelta( CBitMemStream& s, CCDBStructNodeLeaf *node, ui
if ( VerboseDatabase )
nldebug( "CDB: Pushing value %"NL_I64"d (TEXT-32) for index %d prop %s", (sint64)value, index, node->buildTextId().toString().c_str() );
}
else if ( node->type() == ICDBStructNode::PACKED )
{
uint bits;
pushPackedValue( s, value, bitsize, bits );
if ( VerboseDatabase )
nldebug( "CDB: Pushing value %"NL_I64"d (PACKED %u bits) for index %d prop %s", (sint64)value, bits, index, node->buildTextId().toString().c_str() );
}
else
{
s.serialAndLog2( value, (uint)node->type() );
@ -574,6 +643,13 @@ void CCDBSynchronised::pushDeltaPermanent( NLMISC::CBitMemStream& s, CCDBStructN
if ( VerboseDatabase )
nldebug( "CDB: Pushing permanent value %"NL_I64"d (TEXT-32) for index %d prop %s", (sint64)value, index, node->buildTextId().toString().c_str() );
}
else if ( node->type() == ICDBStructNode::PACKED )
{
uint bits;
pushPackedValue( s, value, bitsize, bits );
if ( VerboseDatabase )
nldebug( "CDB: Pushing permanent value %"NL_I64"d (PACKED %u bits) for index %d prop %s", (sint64)value, bits, index, node->buildTextId().toString().c_str() );
}
else
{
s.serialAndLog2( value, (uint)node->type() );

Loading…
Cancel
Save