Compare commits

...

8 Commits

Author SHA1 Message Date
kaetemi c624984da1 Merge commit '6f545aedd5638e093f35f1e156d3ed4f9a91cb18' into feature/cdb-packed 4 years ago
kaetemi 998daa5c56 Add additional nullable
--HG--
branch : cdb-packed
10 years ago
kaetemi a3a347fab4 Add optional null bit to CDB leafs
--HG--
branch : cdb-packed
10 years ago
kaetemi ba42ed3320 Merge with default
--HG--
branch : cdb-packed
10 years ago
kaetemi 1359bbf8c2 (DB_INIT:PLR from 5364 -> 1810 bytes)
--HG--
branch : cdb-packed
10 years ago
kaetemi 5d9f3ce668 Optimize for more common case
--HG--
branch : cdb-packed
10 years ago
kaetemi 9fec239dfb Missed 4 bits
--HG--
branch : cdb-packed
10 years ago
kaetemi 06e9d20850 Add PACKED type to CDB for brick bitfields
--HG--
branch : cdb-packed
10 years ago

@ -64,7 +64,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
};

@ -93,6 +93,7 @@ public:
_Property = 0;
_oldProperty = 0;
_Type = UNKNOWN;
_Nullable = false;
_Changed = false;
_LastChangeGC = 0;
}
@ -232,6 +233,9 @@ private:
/// property type
EPropType _Type;
/// nullable
bool _Nullable;
/// true if this value has changed
bool _Changed;

@ -47,6 +47,18 @@ namespace NLMISC{
//-----------------------------------------------
void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBack */, bool /* mapBanks */, CCDBBankHandler * /* bankHandler */ )
{
// Read nullable
CXMLAutoPtr nullable((const char*)xmlGetProp (node, (xmlChar*)"nullable"));
if ((const char *) nullable != NULL)
{
_Nullable = (nullable.getDatas()[0] == '1');
}
else
{
_Nullable = false;
}
// Read type
CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type"));
nlassert((const char *) type != NULL);
@ -83,6 +95,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
{
@ -127,6 +142,15 @@ 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 nibbleCount;
f.serial(nibbleCount, 4);
uint bits = (nibbleCount << 2);
// nlinfo("PACKED: %u bits", (uint32)(bits));
return bits;
}
//-----------------------------------------------
// readDelta
//-----------------------------------------------
@ -137,15 +161,26 @@ void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f )
{
// Read the Property Value according to the Property Type.
uint64 recvd = 0;
uint bits;
if (_Type == TEXT)
bits = 32;
else if (_Type <= I64)
bits = _Type;
else
bits = _Type - 64;
f.serial(recvd, bits);
uint64 isNull = 0;
if (_Nullable)
{
f.serial(isNull, 1);
}
uint bits;
if (!isNull)
{
if (_Type == TEXT)
bits = 32;
else if (_Type == PACKED)
bits = readPackedBitCount(f);
else if (_Type <= I64)
bits = _Type;
else
bits = _Type - 64;
f.serial(recvd, bits);
}
// if the DB update is older than last DB update, abort (but after the read!!)
if(gc<_LastChangeGC)
@ -158,18 +193,24 @@ 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;
if( (_Property >> (bits-1))==1 )
if (!isNull)
{
_Property |= ~mask;
// extend bit sign
sint64 mask = (((sint64)1)<<bits)-(sint64)1;
if( (_Property >> (bits-1))==1 )
{
_Property |= ~mask;
}
}
}
if ( verboseDatabase )
{
nlinfo( "CDB: Read value (%u bits) %" NL_I64 "d", bits, _Property );
if (!isNull)
nlinfo( "CDB: Read value (%u bits) %" NL_I64 "d", bits, _Property );
else
nlinfo( "CDB: Read null value %" NL_I64 "d", _Property );
}
// bkup the date of change

@ -1,4 +1,8 @@
<database_description>
<!-- 2014-09-12: Now possible to use nullable="1" in leafs. This will
add 1 additional bit to the field, which will be the only bit sent
when the value of the field is 0. Use only for fields which are
updated less frequently and which are often reset. -KAE -->
<!-- Define bank superclass -->
<bank_superclass>
<bank name="PLR"
@ -108,6 +112,7 @@
bank="PLR">
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="RUN"
type="I32" />
@ -149,7 +154,8 @@
<branch name=""
count="64">
<leaf name="TICK_RANGE"
type="I64" />
type="I64"
nullable="1" />
<!-- 32b for start tick and 32b for end tick -->
</branch>
</branch>
@ -189,13 +195,15 @@
<branch name="CONTEXT_MENU"
atom="1">
<leaf name="PROGRAMMES"
type="I32" />
type="I32"
nullable="1" />
<!-- options for missions in the context menu -->
<branch name="MISSIONS_OPTIONS">
<branch name=""
count="8">
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<!-- a text ID of 0 means there's no action. Text ID are reseted when a new character is targeted -->
<leaf name="PLAYER_GIFT_NEEDED"
type="I1" />
@ -207,13 +215,16 @@
</branch>
<!-- A NPC may offer to view a webpage -->
<leaf name="WEB_PAGE_TITLE"
type="I32" />
type="I32"
nullable="1" />
<!-- a text ID of 0 means there's no WebPage -->
<leaf name="WEB_PAGE_URL"
type="I32" />
type="I32"
nullable="1" />
<!-- the URL text ID of the web page -->
<leaf name="OUTPOST"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- outpost this bot give access to (sheet id inside) -->
<!-- Mission rings -->
@ -221,10 +232,12 @@
<branch name=""
count="4">
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<!-- a text ID of 0 means there's no action. Text ID are reseted when a new character is targeted -->
<leaf name="ID"
type="I32" />
type="I32"
nullable="1" />
<!-- the id of the action if selected -->
</branch>
</branch>
@ -275,18 +288,23 @@
type="I2" />
<leaf name="ICON"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- sheet id of a .mission_icon sheet -->
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<leaf name="DETAIL_TEXT"
type="I32" />
type="I32"
nullable="1" />
<!-- begin date in tick -->
<leaf name="BEGIN_DATE"
type="I32" />
type="I32"
nullable="1" />
<!-- end date in tick -->
<leaf name="END_DATE"
type="I32" />
type="I32"
nullable="1" />
<!-- true if the step are "OR" -->
<leaf name="OR_STEPS"
type="I1" />
@ -294,9 +312,11 @@
<branch name=""
count="20">
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
<leaf name="NPC_ALIAS"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
<!-- Targets -->
@ -304,11 +324,14 @@
count="8"
atom="1">
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<leaf name="X"
type="I32" />
type="I32"
nullable="1" />
<leaf name="Y"
type="I32" />
type="I32"
nullable="1" />
</branch>
<!-- Indicate if the mission is finished (0-not 1-success 2-failed) -->
<leaf name="FINISHED"
@ -324,7 +347,8 @@
<branch name=""
count="30">
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
</branch>
@ -372,6 +396,7 @@
<!-- Common Item Data -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="QUALITY"
type="I10" />
@ -388,7 +413,8 @@
type="I16" />
<!-- weight. see DB_WEIGHT_SCALE -->
<leaf name="NAMEID"
type="I32" />
type="I32"
nullable="1" />
<!-- 0 or special name of item -->
<leaf name="INFO_VERSION"
type="I8" />
@ -408,6 +434,7 @@
<!-- Common Item Data -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="QUALITY"
type="I10" />
@ -424,7 +451,8 @@
type="I16" />
<!-- weight. see DB_WEIGHT_SCALE-->
<leaf name="NAMEID"
type="I32" />
type="I32"
nullable="1" />
<!-- 0 or special name of item -->
<leaf name="INFO_VERSION"
type="I8" />
@ -567,6 +595,7 @@
<!-- Common Item Data -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="QUALITY"
type="I12" />
@ -585,7 +614,8 @@
type="I16" />
<!-- weight. see DB_WEIGHT_SCALE-->
<leaf name="NAMEID"
type="I32" />
type="I32"
nullable="1" />
<!-- 0 or special name of item -->
<leaf name="INFO_VERSION"
type="I8" />
@ -613,6 +643,7 @@
<!-- Common Item Data -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="QUALITY"
type="I10" />
@ -628,7 +659,8 @@
type="I16" />
<!-- weight. see DB_WEIGHT_SCALE-->
<leaf name="NAMEID"
type="I32" />
type="I32"
nullable="1" />
<!-- 0 or special name of item -->
<leaf name="INFO_VERSION"
type="I8" />
@ -722,11 +754,13 @@
count="12">
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="DISABLED"
type="I1" />
<leaf name="DISABLED_TIME"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
<branch name="MALUS">
@ -734,11 +768,13 @@
count="12">
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="DISABLED"
type="I1" />
<leaf name="DISABLED_TIME"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
</branch>
@ -747,10 +783,12 @@
<branch name=""
count="12">
<leaf name="FAMILY"
type="I16" />
type="I16"
nullable="1" />
<!-- Disable consumablel family -->
<leaf name="DISABLE_TIME"
type="I32" />
type="I32"
nullable="1" />
<!-- End date of diable time in tick -->
</branch>
</branch>
@ -759,16 +797,20 @@
bank="PLR">
<!-- intro for player gift -->
<leaf name="PLAYER_GIFT"
type="I32" />
type="I32"
nullable="1" />
<!-- intro for guild creation -->
<leaf name="CREATE_GUILD"
type="I32" />
type="I32"
nullable="1" />
<!-- intro for trade window (pacts, action, item, or skills ..)-->
<leaf name="TRADE"
type="I32" />
type="I32"
nullable="1" />
<!-- intro for choose mission -->
<leaf name="CHOOSE_MISSION"
type="I32" />
type="I32"
nullable="1" />
<!-- intro before the reward of the mission -->
<!-- <leaf name="MISSION_END_REWARD" type="I32"/> -->
<!-- text of the mission end -->
@ -779,19 +821,23 @@
<branch name="DM_CHOICE"
count="3">
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<branch name=""
count="8">
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
<!-- title of dynamic mission -->
<leaf name="DM_TITLE"
type="I32" />
type="I32"
nullable="1" />
<!-- description of dynamic mission -->
<leaf name="DM_DESCRIPTION"
type="I32" />
type="I32"
nullable="1" />
<!-- the rolemaster type on 2 bits -->
<leaf name="ROLEMASTER_TYPE"
type="I2" />
@ -815,9 +861,11 @@
if high order bit == 1 : low order bits = entry in the LIFT_ICONS::TLiftIcon enum
-->
<leaf name="ICON"
type="I64" />
type="I64"
nullable="1" />
<leaf name="NAME"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
<branch name="CHOOSE_MISSIONS"
@ -835,12 +883,15 @@
count="8">
<leaf name="ICON"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- sheet id of a .mission_icon sheet -->
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
<leaf name="DETAIL_TEXT"
type="I32" />
type="I32"
nullable="1" />
<leaf name="PREREQ_STATE"
type="I8" />
<!-- game_share/mission_desc.h/TPreReqState -->
@ -884,6 +935,7 @@
<!-- Common Item Data -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="QUALITY"
type="I10" />
@ -900,7 +952,8 @@
type="I16" />
<!-- weight. see DB_WEIGHT_SCALE-->
<leaf name="NAMEID"
type="I32" />
type="I32"
nullable="1" />
<!-- 0 or special name of item -->
<leaf name="INFO_VERSION"
type="I8" />
@ -921,6 +974,7 @@
<!-- For rrp curency, specify the rrp level -->
<leaf name="MONEY_SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- For item curency, specify the item sheet -->
<leaf name="BASE_SKILL"
@ -938,7 +992,8 @@
<leaf name="RESALE_TIME_LEFT"
type="I16" />
<leaf name="VENDOR_NAMEID"
type="TEXT" />
type="TEXT"
nullable="1" />
<!-- name id of player vendor -->
<leaf name="FACTION_POINT_PRICE"
type="I32" />
@ -958,15 +1013,8 @@
<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"
nullable="1" />
</branch>
</branch>
<branch name="MISSIONS"
@ -978,18 +1026,23 @@
type="I2" />
<leaf name="ICON"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- sheet id of a .mission_icon sheet -->
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<leaf name="DETAIL_TEXT"
type="I32" />
type="I32"
nullable="1" />
<!-- begin date in tick -->
<leaf name="BEGIN_DATE"
type="I32" />
type="I32"
nullable="1" />
<!-- end date in tick -->
<leaf name="END_DATE"
type="I32" />
type="I32"
nullable="1" />
<!-- true if the step are "OR" -->
<leaf name="OR_STEPS"
type="I1" />
@ -997,9 +1050,11 @@
<branch name=""
count="20">
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
<leaf name="NPC_ALIAS"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
<!-- Targets -->
@ -1007,11 +1062,14 @@
count="8"
atom="1">
<leaf name="TITLE"
type="I32" />
type="I32"
nullable="1" />
<leaf name="X"
type="I32" />
type="I32"
nullable="1" />
<leaf name="Y"
type="I32" />
type="I32"
nullable="1" />
</branch>
<!-- Indicate if the mission is finished (0-not 1-success 2-failed) -->
<leaf name="FINISHED"
@ -1027,7 +1085,8 @@
<branch name=""
count="30">
<leaf name="TEXT"
type="I32" />
type="I32"
nullable="1" />
</branch>
</branch>
</branch>
@ -1041,6 +1100,7 @@
<!-- If not a phrase in the speel book, give the associated brick sheet id -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<!-- When the NEXT_COUNTER reach the one on client, reset -->
<leaf name="NEXT_COUNTER"
@ -1067,7 +1127,8 @@
type="I16" />
<!-- Entity name -->
<leaf name="TARGET_NAME"
type="TEXT" />
type="TEXT"
nullable="1" />
<!-- Entity State -->
<leaf name="TARGET_HP"
type="I7" />
@ -1135,7 +1196,8 @@
<branch name=""
count="256">
<leaf name="NAME"
type="TEXT" />
type="TEXT"
nullable="1" />
<!-- player name -->
<leaf name="GRADE"
type="I3" />
@ -1145,7 +1207,8 @@
cppType="TCharConnectionState" />
<!-- enum TCharConnectionState -->
<leaf name="ENTER_DATE"
type="I32" />
type="I32"
nullable="1" />
<!-- tick when player entered the guild-->
</branch>
</branch>
@ -1287,6 +1350,7 @@
count="16">
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
</branch>
</branch>
@ -1300,6 +1364,7 @@
<!-- Spawned -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
</branch>
<branch name="T"
@ -1307,6 +1372,7 @@
<!-- Training -->
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
<leaf name="SPAWN"
type="I4" />
@ -1323,6 +1389,7 @@
count="4">
<leaf name="SHEET"
type="I32"
nullable="1"
cppType="NLMISC::CSheetId" />
</branch>
</branch>
@ -1552,6 +1619,7 @@
type="I7" />
<leaf name="NAME"
type="I32"
nullable="1"
is_true="1" />
</branch>
</branch>
@ -1663,10 +1731,12 @@
count="8"
atom="1">
<leaf name="NAME"
type="I32" />
type="I32"
nullable="1" />
<!-- channel not available if anme is 0 -->
<leaf name="ID"
type="I64" />
type="I64"
nullable="1" />
<!-- unique ID of channel (eid) -->
<leaf name="WRITE_RIGHT"
type="I1" />

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

@ -743,7 +743,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>

@ -41,7 +41,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 +152,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
@ -2291,45 +2285,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;

@ -6763,77 +6763,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:
@ -10547,8 +10476,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;
@ -10657,10 +10584,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;

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

@ -45,6 +45,18 @@ using namespace std;
//-----------------------------------------------
void CCDBStructNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack )
{
// Read nullable
CXMLAutoPtr nullable((const char*)xmlGetProp (node, (xmlChar*)"nullable"));
if ((const char *) nullable != NULL)
{
_Nullable = (nullable.getDatas()[0] == '1');
}
else
{
_Nullable = false;
}
// Read type
CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type"));
nlassert((const char *) type != NULL);
@ -79,6 +91,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
{

@ -36,6 +36,9 @@ public:
/// Return the type of the property.
inline const EPropType & type() const {return _Type;}
/// Return the type of the property.
inline bool nullable() const {return _Nullable;}
/// The overridden version that is usable from ICDBStructNode
virtual EPropType getType() const {return _Type;}
@ -46,7 +49,7 @@ public:
/**
* Default constructor
*/
CCDBStructNodeLeaf() : ICDBStructNode(), _Parent( NULL ), _Type( UNKNOWN ) {}
CCDBStructNodeLeaf() : ICDBStructNode(), _Parent( NULL ), _Type( UNKNOWN ), _Nullable( false ) {}
/**
* Build the structure of the database from a file
@ -178,6 +181,9 @@ private:
/// property type
EPropType _Type;
/// nullable
bool _Nullable;
/// Binary property id of the leaf (precalculated & stored to avoid having to get back in the tree to build it)
CBinId _LeafId;
};

@ -516,6 +516,55 @@ 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; // 32 msb
}
else
{
test = (uint32)(value & 0xFFFFFFFF); // 32 lsb
}
next = (test >> 16);
if (next)
{
bits += 16;
test = next; // 16 msb
}
else
{
test = (test & 0xFFFF); // 16 lsb
}
next = (test >> 8);
if (next)
{
bits += 8;
test = next; // 8 msb
}
else
{
test = (test & 0xFF); // 8 lsb
}
next = (test >> 4);
if (next)
{
bits += 8;
}
else if (test & 0xF)
{
bits += 4;
}
uint64 nibbleCount = (bits >> 2);
s.serialAndLog2( nibbleCount, 4 );
s.serialAndLog2( value, bits );
bitsize += (4 + bits);
}
/*
* Push one change to the stream
@ -532,19 +581,42 @@ void CCDBSynchronised::pushDelta( CBitMemStream& s, CCDBStructNodeLeaf *node, ui
value = (uint64)_DataContainer.getValue64( index );
//_DataContainer.archiveCurrentValue( index );
if ( node->type() == ICDBStructNode::TEXT )
if ( node->nullable() && value == 0 )
{
s.serialAndLog2( value, 32 );
bitsize += 32;
if ( VerboseDatabase )
nldebug( "CDB: Pushing value %" NL_I64 "d (TEXT-32) for index %d prop %s", (sint64)value, index, node->buildTextId().toString().c_str() );
uint64 isNull = 1;
s.serialAndLog2( isNull, 1 );
bitsize += 1;
}
else
{
s.serialAndLog2( value, (uint)node->type() );
bitsize += (uint32)node->type();
if ( VerboseDatabase )
nldebug( "CDB: Pushing value %" NL_I64 "d (%u bits) for index %d prop %s", (sint64)value, (uint32)node->type(), index, node->buildTextId().toString().c_str() );
if ( node->nullable() )
{
uint64 isNull = 0;
s.serialAndLog2( isNull, 1 );
bitsize += 1;
}
if ( node->type() == ICDBStructNode::TEXT )
{
s.serialAndLog2( value, 32 );
bitsize += 32;
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() );
bitsize += (uint32)node->type();
if ( VerboseDatabase )
nldebug( "CDB: Pushing value %" NL_I64 "d (%u bits) for index %d prop %s", (sint64)value, (uint32)node->type(), index, node->buildTextId().toString().c_str() );
}
}
}
else
@ -573,6 +645,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