本文整理汇总了C++中FileLoader::getNextNode方法的典型用法代码示例。如果您正苦于以下问题:C++ FileLoader::getNextNode方法的具体用法?C++ FileLoader::getNextNode怎么用?C++ FileLoader::getNextNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileLoader
的用法示例。
在下文中一共展示了FileLoader::getNextNode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
if(!Item::unserializeItemNode(f, node, propStream))
return false;
uint32_t type;
for(NODE nodeItem = f.getChildNode(node, type); nodeItem; nodeItem = f.getNextNode(nodeItem, type))
{
//load container items
if(type != OTBM_ITEM)
return false;
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item)
return false;
if(!item->unserializeItemNode(f, nodeItem, itemPropStream))
return false;
addItem(item);
updateItemWeight(item->getWeight());
}
return true;
}
示例2: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
bool ret = Item::unserializeItemNode(f, node, propStream);
if(ret){
unsigned long type;
NODE nodeItem = f.getChildNode(node, type);
while(nodeItem){
//load container items
if(type == OTBM_ITEM){
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item){
return false;
}
if(!item->unserializeItemNode(f, nodeItem, itemPropStream)){
return false;
}
addItem(item);
}
else /*unknown type*/
return false;
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
return false;
}
示例3: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
bool ret = Item::unserializeItemNode(f, node, propStream);
if(ret){
unsigned long type;
NODE nodeItem = f.getChildNode(node, type);
while(nodeItem){
//load container items
if(type == OTBM_ITEM){
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item){
return false;
}
if(!item->unserializeItemNode(f, nodeItem, itemPropStream)){
return false;
}
addItem(item);
//deepness
if (item->getContainer()){
if (getParentContainer())
item->getContainer()->setDeepness(getDeepness() + 1);
else{ //we only update deepness when a container get inside of another, so it means that deepness is not updated
setDeepness(1);
item->getContainer()->setDeepness(2);
}
}
updateAmountOfItems(item->getTotalAmountOfItemsInside());
total_weight += item->getWeight();
if(Container* parent_container = getParentContainer()) {
parent_container->updateItemWeight(item->getWeight());
}
}
else /*unknown type*/
return false;
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
return false;
}
示例4: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
bool ret = Item::unserializeItemNode(f, node, propStream);
if (!ret) {
return false;
}
uint32_t type;
NODE nodeItem = f.getChildNode(node, type);
while (nodeItem) {
//load container items
if (type != OTBM_ITEM) {
// unknown type
return false;
}
PropStream itemPropStream;
if (!f.getProps(nodeItem, itemPropStream)) {
return false;
}
Item* item = Item::CreateItem(itemPropStream);
if (!item) {
return false;
}
if (!item->unserializeItemNode(f, nodeItem, itemPropStream)) {
return false;
}
addItem(item);
totalWeight += item->getWeight();
if (Container* parent_container = getParentContainer()) {
parent_container->updateItemWeight(item->getWeight());
}
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
示例5: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
if(Item::unserializeItemNode(f, node, propStream))
{
uint32_t type;
NODE nodeItem = f.getChildNode(node, type);
while(nodeItem)
{
//load container items
if(type == OTBM_ITEM)
{
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item)
return false;
if(!item->unserializeItemNode(f, nodeItem, itemPropStream))
return false;
addItem(item);
totalWeight += item->getWeight();
if(Container* parent = getParentContainer())
parent->updateItemWeight(item->getWeight());
}
else/*unknown type*/
return false;
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
return false;
}
示例6: loadFromOtb
//.........这里部分代码省略.........
return ERROR_INVALID_FORMAT;
}
if (!stream.read<uint8_t>(alwaysOnTopOrder)) {
return ERROR_INVALID_FORMAT;
}
break;
}
case ITEM_ATTR_WAREID: {
if (datalen != sizeof(uint16_t)) {
return ERROR_INVALID_FORMAT;
}
if (!stream.read<uint16_t>(wareId)) {
return ERROR_INVALID_FORMAT;
}
break;
}
default: {
//skip unknown attributes
if (!stream.skip(datalen)) {
return ERROR_INVALID_FORMAT;
}
break;
}
}
}
reverseItemMap.emplace(clientId, serverId);
// store the found item
if (serverId >= items.size()) {
items.resize(serverId + 1);
}
ItemType& iType = items[serverId];
iType.group = static_cast<itemgroup_t>(type);
switch (type) {
case ITEM_GROUP_CONTAINER:
iType.type = ITEM_TYPE_CONTAINER;
break;
case ITEM_GROUP_DOOR:
//not used
iType.type = ITEM_TYPE_DOOR;
break;
case ITEM_GROUP_MAGICFIELD:
//not used
iType.type = ITEM_TYPE_MAGICFIELD;
break;
case ITEM_GROUP_TELEPORT:
//not used
iType.type = ITEM_TYPE_TELEPORT;
break;
case ITEM_GROUP_NONE:
case ITEM_GROUP_GROUND:
case ITEM_GROUP_SPLASH:
case ITEM_GROUP_FLUID:
case ITEM_GROUP_CHARGES:
case ITEM_GROUP_DEPRECATED:
break;
default:
return ERROR_INVALID_FORMAT;
}
iType.blockSolid = hasBitSet(FLAG_BLOCK_SOLID, flags);
iType.blockProjectile = hasBitSet(FLAG_BLOCK_PROJECTILE, flags);
iType.blockPathFind = hasBitSet(FLAG_BLOCK_PATHFIND, flags);
iType.hasHeight = hasBitSet(FLAG_HAS_HEIGHT, flags);
iType.useable = hasBitSet(FLAG_USEABLE, flags);
iType.pickupable = hasBitSet(FLAG_PICKUPABLE, flags);
iType.moveable = hasBitSet(FLAG_MOVEABLE, flags);
iType.stackable = hasBitSet(FLAG_STACKABLE, flags);
iType.alwaysOnTop = hasBitSet(FLAG_ALWAYSONTOP, flags);
iType.isVertical = hasBitSet(FLAG_VERTICAL, flags);
iType.isHorizontal = hasBitSet(FLAG_HORIZONTAL, flags);
iType.isHangable = hasBitSet(FLAG_HANGABLE, flags);
iType.allowDistRead = hasBitSet(FLAG_ALLOWDISTREAD, flags);
iType.rotatable = hasBitSet(FLAG_ROTATABLE, flags);
iType.canReadText = hasBitSet(FLAG_READABLE, flags);
iType.lookThrough = hasBitSet(FLAG_LOOKTHROUGH, flags);
// iType.walkStack = !hasBitSet(FLAG_FULLTILE, flags);
iType.forceUse = hasBitSet(FLAG_FORCEUSE, flags);
iType.id = serverId;
iType.clientId = clientId;
iType.speed = speed;
iType.lightLevel = lightLevel;
iType.lightColor = lightColor;
iType.wareId = wareId;
iType.alwaysOnTopOrder = alwaysOnTopOrder;
node = f.getNextNode(node, type);
}
items.shrink_to_fit();
return ERROR_NONE;
}
示例7: loadMap
//.........这里部分代码省略.........
{
if(groundItem)
delete groundItem;
groundItem = item;
}
else
{
tile = createTile(groundItem, item, px, py, pz);
tile->__internalAddThing(item);
item->__startDecaying();
item->setLoadedFromMap(true);
}
}
else
{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Failed to load item " << item->getID() << ".";
setLastErrorString(ss.str());
delete item;
item = NULL;
return false;
}
}
else
{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Unknown node type.";
setLastErrorString(ss.str());
}
nodeItem = f.getNextNode(nodeItem, type);
}
if(!tile)
tile = createTile(groundItem, NULL, px, py, pz);
tile->setFlag((tileflags_t)tileflags);
map->setTile(px, py, pz, tile);
}
else
{
setLastErrorString("Unknown tile node.");
return false;
}
nodeTile = f.getNextNode(nodeTile, type);
}
}
else if(type == OTBM_TOWNS)
{
NODE nodeTown = f.getChildNode(nodeMapData, type);
while(nodeTown != NO_NODE)
{
if(type == OTBM_TOWN)
{
if(!f.getProps(nodeTown, propStream))
{
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId = 0;
if(!propStream.GET_ULONG(townId))
示例8: loadMap
//.........这里部分代码省略.........
}
if (!item->unserializeItemNode(f, nodeItem, stream)) {
std::ostringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Failed to load item " << item->getID() << '.';
setLastErrorString(ss.str());
delete item;
return false;
}
if (isHouseTile && item->isMoveable()) {
std::cout << "[Warning - IOMap::loadMap] Moveable item with ID: " << item->getID() << ", in house: " << house->getId() << ", at position [x: " << px << ", y: " << py << ", z: " << pz << "]." << std::endl;
delete item;
} else {
if (item->getItemCount() <= 0) {
item->setItemCount(1);
}
if (tile) {
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
} else if (item->isGroundTile()) {
delete ground_item;
ground_item = item;
} else {
tile = createTile(ground_item, item, px, py, pz);
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
}
}
nodeItem = f.getNextNode(nodeItem, type);
}
if (!tile) {
tile = createTile(ground_item, nullptr, px, py, pz);
}
tile->setFlag(static_cast<tileflags_t>(tileflags));
map->setTile(px, py, pz, tile);
nodeTile = f.getNextNode(nodeTile, type);
}
} else if (type == OTBM_TOWNS) {
NODE nodeTown = f.getChildNode(nodeMapData, type);
while (nodeTown != NO_NODE) {
if (type != OTBM_TOWN) {
setLastErrorString("Unknown town node.");
return false;
}
if (!f.getProps(nodeTown, propStream)) {
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townId;
if (!propStream.read<uint32_t>(townId)) {
setLastErrorString("Could not read town id.");
return false;
}
Town* town = map->towns.getTown(townId);
示例9: loadMap
//.........这里部分代码省略.........
delete item;
}
else{
if(tile){
tile->__internalAddThing(item);
item->__startDecaying();
}
else if(item->isGroundTile()){
if(ground_item)
delete ground_item;
ground_item = item;
}
else{ // !tile
tile = createTile(ground_item, item, px, py, pz);
tile->__internalAddThing(item);
item->__startDecaying();
}
}
}
else{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Failed to load item " << item->getID() << ".";
setLastErrorString(ss.str());
delete item;
return false;
}
}
else{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Unknown node type.";
setLastErrorString(ss.str());
}
nodeItem = f.getNextNode(nodeItem, type);
}
if(!tile)
tile = createTile(ground_item, NULL, px, py, pz);
tile->setFlag((tileflags_t)tileflags);
map->setTile(px, py, pz, tile);
}
else{
setLastErrorString("Unknown tile node.");
return false;
}
nodeTile = f.getNextNode(nodeTile, type);
}
}
else if(type == OTBM_TOWNS){
NODE nodeTown = f.getChildNode(nodeMapData, type);
while(nodeTown != NO_NODE){
if(type == OTBM_TOWN){
if(!f.getProps(nodeTown, propStream)){
setLastErrorString("Could not read town data.");
return false;
}
uint32_t townid = 0;
if(!propStream.GET_UINT32(townid)){
setLastErrorString("Could not read town id.");
return false;
}