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

@ -688,7 +688,8 @@ void <xsl:call-template name="makeFullClassName"/>::init(ICDBStructNode *parent<
<xsl:when test="$leafType = 'S63'"> <xsl:text>sint64</xsl:text> </xsl:when>
<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 = '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
@ -362,7 +341,7 @@ void CBankAccessor_PLR::TUSER::init(ICDBStructNode *parent)
node = parent->getNode( ICDBStructNode::CTextId("IS_INVISIBLE"), false );
nlassert(node != NULL);
_IS_INVISIBLE = node;
node = parent->getNode( ICDBStructNode::CTextId("COUNTER"), false );
nlassert(node != NULL);
_COUNTER = node;
@ -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;
@ -3139,10 +3079,11 @@ void CBankAccessor_PLR::TPACK_ANIMAL::TBEAST::init(ICDBStructNode *parent, uint
node = parent->getNode( ICDBStructNode::CTextId("DESPAWN"), false );
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

File diff suppressed because it is too large Load Diff

@ -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