Fix BinaryTree skip, small otb changes
This commit is contained in:
parent
8dc831088e
commit
b7b8fdfd0c
|
@ -43,7 +43,8 @@ enum ItemCategory : uint8 {
|
||||||
ItemCategorySplash = 11,
|
ItemCategorySplash = 11,
|
||||||
ItemCategoryFluid = 12,
|
ItemCategoryFluid = 12,
|
||||||
ItemCategoryDoor = 13,
|
ItemCategoryDoor = 13,
|
||||||
ItemCategoryLast = 14
|
ItemCategoryDeprecated = 14,
|
||||||
|
ItemCategoryLast = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ItemTypeAttr : uint8 {
|
enum ItemTypeAttr : uint8 {
|
||||||
|
@ -76,7 +77,8 @@ enum ItemTypeAttr : uint8 {
|
||||||
ItemTypeAttrLight2 = 42,
|
ItemTypeAttrLight2 = 42,
|
||||||
ItemTypeAttrTopOrder = 43,
|
ItemTypeAttrTopOrder = 43,
|
||||||
ItemTypeAttrWrtiable3 = 44, // deprecated
|
ItemTypeAttrWrtiable3 = 44, // deprecated
|
||||||
ItemTypeAttrLast = 45
|
ItemTypeAttrWareId = 45,
|
||||||
|
ItemTypeAttrLast = 46
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ClientVersion
|
enum ClientVersion
|
||||||
|
|
|
@ -178,17 +178,23 @@ void ThingTypeManager::loadOtb(const std::string& file)
|
||||||
stdext::throw_exception("invalid otb file");
|
stdext::throw_exception("invalid otb file");
|
||||||
|
|
||||||
BinaryTreePtr root = fin->getBinaryTree();
|
BinaryTreePtr root = fin->getBinaryTree();
|
||||||
|
root->skip(1); // otb first byte is always 0
|
||||||
|
|
||||||
signature = root->getU32();
|
signature = root->getU32();
|
||||||
if(signature != 0)
|
if(signature != 0)
|
||||||
stdext::throw_exception("invalid otb file");
|
stdext::throw_exception("invalid otb file");
|
||||||
|
|
||||||
root->skip(4);
|
uint8 rootAttr = root->getU8();
|
||||||
|
if(rootAttr == 0x01) { // OTB_ROOT_ATTR_VERSION
|
||||||
|
uint16 size = root->getU16();
|
||||||
|
if(size != 4 + 4 + 4 + 128)
|
||||||
|
stdext::throw_exception("invalid otb root attr version size");
|
||||||
|
|
||||||
m_otbMajorVersion = root->getU32();
|
m_otbMajorVersion = root->getU32();
|
||||||
m_otbMinorVersion = root->getU32();
|
m_otbMinorVersion = root->getU32();
|
||||||
root->skip(4);
|
root->skip(4); // buildNumber
|
||||||
root->skip(128); // description
|
root->skip(128); // description
|
||||||
|
}
|
||||||
|
|
||||||
m_reverseItemTypes.clear();
|
m_reverseItemTypes.clear();
|
||||||
m_itemTypes.resize(root->getChildren().size() + 1, m_nullItemType);
|
m_itemTypes.resize(root->getChildren().size() + 1, m_nullItemType);
|
||||||
|
|
|
@ -111,6 +111,12 @@ void BinaryTree::seek(uint pos)
|
||||||
m_pos = pos;
|
m_pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BinaryTree::skip(uint len)
|
||||||
|
{
|
||||||
|
unserialize();
|
||||||
|
seek(tell() + len);
|
||||||
|
}
|
||||||
|
|
||||||
uint8 BinaryTree::getU8()
|
uint8 BinaryTree::getU8()
|
||||||
{
|
{
|
||||||
unserialize();
|
unserialize();
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
~BinaryTree();
|
~BinaryTree();
|
||||||
|
|
||||||
void seek(uint pos);
|
void seek(uint pos);
|
||||||
void skip(uint len) { seek(tell() + len); }
|
void skip(uint len);
|
||||||
uint tell() { return m_pos; }
|
uint tell() { return m_pos; }
|
||||||
uint size() { unserialize(); return m_buffer.size(); }
|
uint size() { unserialize(); return m_buffer.size(); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue