本文整理汇总了C++中BinaryNode::getU32方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryNode::getU32方法的具体用法?C++ BinaryNode::getU32怎么用?C++ BinaryNode::getU32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryNode
的用法示例。
在下文中一共展示了BinaryNode::getU32方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVersionInfo
ClientVersionID IOMapOTMM::getVersionInfo(const FileName& filename)
{
wxString wpath = filename.GetFullPath();
DiskNodeFileReadHandle f((const char*)wpath.mb_str(wxConvUTF8));
if(f.isOk() == false) {
return CLIENT_VERSION_NONE;
}
BinaryNode* root = f.getRootNode();
if(!root) {return CLIENT_VERSION_NONE;}
root->skip(1); // Skip the type byte
uint16_t u16;
uint32_t u32;
if(!root->getU32(u32) || u32 != 1) { // Version
return CLIENT_VERSION_NONE;
}
root->getU16(u16);
root->getU16(u16);
root->getU32(u32);
if(root->getU32(u32)) { // OTB minor version
return ClientVersionID(u32);
}
return CLIENT_VERSION_NONE;
}
示例2: loadMap
bool IOMapOTMM::loadMap(Map& map, NodeFileReadHandle& f, const FileName& identifier, bool showdialog) {
BinaryNode* root = f.getRootNode();
if(!root) {
error(wxT("Could not read root node."));
return false;
}
root->skip(1); // Skip the type byte
uint8_t u8;
uint16_t u16;
uint32_t u32;
if(!root->getU32(u32) || u32 != 1) { // Version
error(wxT("Unsupported or damaged map version."));
return false;
}
if(!root->getU16(u16)) {
error(wxT("Could not read root header."));
return false;
}
map.width = u16;
if(!root->getU16(u16)) {
error(wxT("Could not read root header."));
return false;
}
map.height = u16;
if(!root->getU32(u32) || u32 > (unsigned long)item_db.MajorVersion) { // OTB major version
if(queryUser(wxT("Map error"), wxT("The loaded map appears to be a items.otb format that deviates from the items.otb loaded by the editor. Do you still want to attempt to load the map?"))) {
warning(wxT("Unsupported or damaged map version"));
} else {
error(wxT("Outdated items.otb, could not load map."));
return false;
}
}
if(!root->getU32(u32) || u32 > (unsigned long)item_db.MinorVersion) { // OTB minor version
warning(wxT("The editor needs an updated items.otb version."));
}
BinaryNode* mapHeaderNode = root->getChild();
if(mapHeaderNode == NULL || !mapHeaderNode->getByte(u8) || u8 != OTMM_MAP_DATA) {
error(wxT("Could not get root child node. Cannot recover from fatal error!"));
return false;
}
int nodes_loaded = 0;
BinaryNode* mapNode = mapHeaderNode->getChild();
if(mapNode) do {
++nodes_loaded;
if(showdialog && nodes_loaded % 15 == 0) {
gui.SetLoadDone(int(100.0 * f.tell() / f.size()));
}
uint8_t node_type;
if(!mapNode->getByte(node_type)) {
warning(wxT("Invalid map node"));
continue;
}
switch(node_type) {
case OTMM_EDITOR: {
} break;
case OTMM_DESCRIPTION: {
std::string desc;
mapNode->getString(desc);
map.setMapDescription(desc);
} break;
case OTMM_TILE_DATA: {
BinaryNode* tileNode = mapNode->getChild();
if(tileNode) do {
Tile* tile = NULL;
uint8_t tile_type;
if(!tileNode->getByte(tile_type)) {
warning(wxT("Invalid tile type"));
continue;
}
if(tile_type != OTMM_TILE && tile_type != OTMM_HOUSETILE) {
warning(wxT("Unknown type of tile node"));
continue;
}
uint16_t x_offset, y_offset;
uint8_t z_offset;
if(!tileNode->getU16(x_offset) ||
!tileNode->getU16(y_offset) ||
!tileNode->getU8(z_offset)
)
{
warning(wxT("Could not read position of tile"));
continue;
}
const Position pos(x_offset, y_offset, z_offset);
if(map.getTile(pos)) {
warning(wxT("Duplicate tile at %d:%d:%d, discarding duplicate"), pos.x, pos.y, pos.z);
continue;
}
//.........这里部分代码省略.........