当前位置: 首页>>代码示例>>C++>>正文


C++ BinaryNode::advance方法代码示例

本文整理汇总了C++中BinaryNode::advance方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryNode::advance方法的具体用法?C++ BinaryNode::advance怎么用?C++ BinaryNode::advance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryNode的用法示例。


在下文中一共展示了BinaryNode::advance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unserializeItemNode_OTMM

bool Container::unserializeItemNode_OTMM(const IOMap& maphandle, BinaryNode* node)
{
	bool ret = Item::unserializeAttributes_OTMM(maphandle, node);

	if(ret) {
		BinaryNode* child = node->getChild();
		if(child) do {
			uint8_t type;
			if(!child->getByte(type)) {
				return false;
			}
			//load container items
			if(type == OTMM_ITEM) {
				Item* item = Item::Create_OTMM(maphandle, child);
				if(!item) {
					return false;
				}
				if(!item->unserializeItemNode_OTMM(maphandle, child)) {
					delete item;
					return false;
				}
				contents.push_back(item);
			} else {
				// corrupted file data!
				return false;
			}
		} while(child->advance());
		return true;
	}
	return false;
}
开发者ID:mattyx14,项目名称:rme,代码行数:31,代码来源:iomap_otmm.cpp

示例2: receiveFloor

void LiveSocket::receiveFloor(NetworkMessage& message, Editor& editor, Action* action, int32_t ndx, int32_t ndy, int32_t z, QTreeNode* node, Floor* floor)
{
	Map& map = editor.map;

	uint16_t tileBits = message.read<uint16_t>();
	if(tileBits == 0) {
		for(uint_fast8_t x = 0; x < 4; ++x) {
			for(uint_fast8_t y = 0; y < 4; ++y) {
				action->addChange(new Change(map.allocator(node->createTile(ndx * 4 + x, ndy * 4 + y, z))));
			}
		}
		return;
	}
	
	// -1 on address since we skip the first START_NODE when sending
	const std::string& data = message.read<std::string>();
	mapReader.assign(reinterpret_cast<const uint8_t*>(data.c_str() - 1), data.size());

	BinaryNode* rootNode = mapReader.getRootNode();
	BinaryNode* tileNode = rootNode->getChild();

	Position position(0, 0, z);
	for(uint_fast8_t x = 0; x < 4; ++x) {
		for(uint_fast8_t y = 0; y < 4; ++y) {
			position.x = (ndx * 4) + x;
			position.y = (ndy * 4) + y;

			if(testFlags(tileBits, 1 << ((x * 4) + y))) {
				receiveTile(tileNode, editor, action, &position);
				tileNode->advance();
			} else {
				action->addChange(new Change(map.allocator(node->createTile(position.x, position.y, z))));
			}
		}
	}
	mapReader.close();
}
开发者ID:Codex-NG,项目名称:rme,代码行数:37,代码来源:live_socket.cpp

示例3: OnReceiveChanges

void LiveServer::OnReceiveChanges(LivePeer* connection, NetworkMessage* nmsg)
{
	std::string data = nmsg->ReadString();
	// -1 on address since we skip the first START_NODE when sending
	bn_reader.assign((uint8_t*)data.c_str() - 1, data.size());
	BinaryNode* rootNode = bn_reader.getRootNode();
	BinaryNode* tileNode = rootNode->getChild();

	NetworkedAction* action = dynamic_cast<NetworkedAction*>(editor->actionQueue->createAction(ACTION_REMOTE));
	action->owner = connection->GetClientID();

	if (tileNode) do
	{
		Tile* t = ReadTile(tileNode, editor->map);
		if(!t) continue;
		action->addChange(newd Change(t));
	} while (tileNode->advance());
	
	bn_reader.close();

	editor->actionQueue->addAction(action);

	gui.RefreshView();
}
开发者ID:mattyx14,项目名称:rme,代码行数:24,代码来源:live_server.cpp

示例4: readTile

Tile* LiveSocket::readTile(BinaryNode* node, Editor& editor, const Position* position)
{
	ASSERT(node != nullptr);

	Map& map = editor.map;

	uint8_t tileType;
	node->getByte(tileType);

	if(tileType != OTBM_TILE && tileType != OTBM_HOUSETILE) {
		return nullptr;
	}

	Position pos;
	if(position) {
		pos = *position;
	} else {
		uint16_t x; node->getU16(x); pos.x = x;
		uint16_t y; node->getU16(y); pos.y = y;
		uint8_t z; node->getU8(z); pos.z = z;
	}

	Tile* tile = map.allocator(
		map.createTileL(pos)
	);

	if(tileType == OTBM_HOUSETILE) {
		uint32_t houseId;
		if(!node->getU32(houseId)) {
			//warning(wxT("House tile without house data, discarding tile"));
			delete tile;
			return nullptr;
		}

		if(houseId) {
			House* house = map.houses.getHouse(houseId);
			if(house) {
				tile->setHouse(house);
			}
		} else {
			//warning(wxT("Invalid house id from tile %d:%d:%d"), pos.x, pos.y, pos.z);
		}
	}

	uint8_t attribute;
	while(node->getU8(attribute)) {
		switch (attribute) {
			case OTBM_ATTR_TILE_FLAGS: {
				uint32_t flags = 0;
				if(!node->getU32(flags)) {
					//warning(wxT("Invalid tile flags of tile on %d:%d:%d"), pos.x, pos.y, pos.z);
				}
				tile->setMapFlags(flags);
				break;
			}
			case OTBM_ATTR_ITEM: {
				Item* item = Item::Create_OTBM(mapVersion, node);
				if(!item) {
					//warning(wxT("Invalid item at tile %d:%d:%d"), pos.x, pos.y, pos.z);
				}
				tile->addItem(item);
				break;
			}
			default:
				//warning(wxT("Unknown tile attribute at %d:%d:%d"), pos.x, pos.y, pos.z);
				break;
		}
	}

	//for(BinaryNode* itemNode = node->getChild(); itemNode; itemNode->advance()) {
	BinaryNode* itemNode = node->getChild();
	if(itemNode) do {
		uint8_t itemType;
		if(!itemNode->getByte(itemType)) {
			//warning(wxT("Unknown item type %d:%d:%d"), pos.x, pos.y, pos.z);
			delete tile;
			return nullptr;
		}

		if(itemType == OTBM_ITEM) {
			Item* item = Item::Create_OTBM(mapVersion, itemNode);
			if(item) {
				if(!item->unserializeItemNode_OTBM(mapVersion, itemNode)) {
					//warning(wxT("Couldn't unserialize item attributes at %d:%d:%d"), pos.x, pos.y, pos.z);
				}
				tile->addItem(item);
			}
		} else {
			//warning(wxT("Unknown type of tile child node"));
		}
	//}
	} while(itemNode->advance());

	return tile;
}
开发者ID:Codex-NG,项目名称:rme,代码行数:95,代码来源:live_socket.cpp

示例5: loadMap


//.........这里部分代码省略.........
						switch(attribute) {
							case OTMM_ATTR_TILE_FLAGS: {
								uint32_t flags = 0;
								if(!tileNode->getU32(flags)) {
									warning(wxT("Invalid tile flags of tile on %d:%d:%d"), pos.x, pos.y, pos.z);
								}
								tile->setMapFlags(flags);
							} break;
							default: {
								warning(wxT("Unknown tile attribute at %d:%d:%d"), pos.x, pos.y, pos.z);
							} break;
						}
					}
					
					BinaryNode* itemNode = tileNode->getChild();
					if(itemNode) do {
						Item* item = NULL;
						uint8_t item_type;
						if(!itemNode->getByte(item_type)) {
							warning(wxT("Unknown item type %d:%d:%d"), pos.x, pos.y, pos.z);
							continue;
						}
						if(item_type == OTMM_ITEM) {
							item = Item::Create_OTMM(*this, itemNode);
							if(item) {
								if(item->unserializeItemNode_OTMM(*this, itemNode) == false) {
									warning(wxT("Couldn't unserialize item attributes at %d:%d:%d"), pos.x, pos.y, pos.z);
								}
								tile->addItem(item);
							}
						} else {
							warning(wxT("Unknown type of tile child node"));
						}
					} while(itemNode->advance());

					tile->update();
					if(house) {
						house->addTile(tile);
					}
					map.setTile(pos, tile);
				} while(tileNode->advance());
			} break;
			case OTMM_SPAWN_DATA: {
				BinaryNode* spawnNode = mapNode->getChild();
				if(spawnNode) do {
					uint8_t spawn_type;
					if(!spawnNode->getByte(spawn_type)) {
						warning(wxT("Could not read spawn type."));
						continue;
					}
					if(spawn_type != OTMM_SPAWN_AREA) {
						warning(wxT("Invalid spawn type."));
						continue;
					}
					
					// Read position
					uint16_t spawn_x, spawn_y;
					uint8_t spawn_z;
					uint32_t radius;
					if(!spawnNode->getU16(spawn_x) ||
							!spawnNode->getU16(spawn_y) ||
							!spawnNode->getU8(spawn_z)
						)
					{
						warning(wxT("Could not read spawn position."));
						continue;
开发者ID:mattyx14,项目名称:rme,代码行数:67,代码来源:iomap_otmm.cpp


注:本文中的BinaryNode::advance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。