bool Object::load_nodes(TiXmlNode *node) { int result = true; if (node->Type() == TiXmlNode::TINYXML_ELEMENT) { if (strcmp(node->Value(), "object") == 0) { result = load_object_attributes(node->ToElement()); } else if (strcmp(node->Value(), "string") == 0) { load_strings(node->ToElement()); } else { load_attributes(node->ToElement()); } } for (TiXmlNode *child = node->FirstChild(); child != 0; child = child->NextSibling()) { if (!load_nodes(child)) { result = false; } } return result; }
bool Object::load_nodes(TiXmlNode *node) { int result = true; if (node->Type() == TiXmlNode::TINYXML_ELEMENT) { if (strcmp(node->Value(), "object") == 0) { result = load_object_attributes(node->ToElement()); } else if (strcmp(node->Value(), "string") == 0) { load_strings(node->ToElement()); } else if (strcmp(node->Value(), "weak_parts") == 0) { m_weak_parts.push_back(new CollisionParts(node->ToElement())); } else if (strcmp(node->Value(), "weak_part") == 0) { if (m_weak_parts.size()) { CollisionParts *parts = m_weak_parts.back(); parts->add_parts(node->ToElement()); } } else if (strcmp(node->Value(), "shielded_parts") == 0) { m_shielded_parts.push_back(new CollisionParts(node->ToElement())); } else if (strcmp(node->Value(), "shielded_part") == 0) { if (m_shielded_parts.size()) { CollisionParts *parts = m_shielded_parts.back(); parts->add_parts(node->ToElement()); } } else { load_attributes(node->ToElement()); } } for (TiXmlNode *child = node->FirstChild(); child != 0; child = child->NextSibling()) { if (!load_nodes(child)) { result = false; } } return result; }
bool WorldDB::load_nodes(TiXmlNode *node) { int result = true; if (node->Type() == TiXmlNode::TINYXML_ELEMENT) { if (strcmp(node->Value(), "world") == 0) { result = load_world_attributes(node->ToElement()); } else if (strcmp(node->Value(), "object") == 0) { WorldObject *object = new WorldObject; result = load_object_attributes(object, node->ToElement()); if (result) { // Check if location exists, otherwise allocate new and insert WorldLocation *location = get_location(object->m_location.c_str()); if (location) { location->m_nodes.push_back(object); } } } else if (strcmp(node->Value(), "lock") == 0) { WorldLock *lock = new WorldLock; result = load_lock_attributes(lock, node->ToElement()); if (result) { // Check if location exists, otherwise allocate new and insert WorldLocation *location = get_location(lock->m_location.c_str()); if (location) { location->m_nodes.push_back(lock); } } } else if (strcmp(node->Value(), "chest") == 0) { WorldChest *chest = new WorldChest; result = load_chest_attributes(chest, node->ToElement()); if (result) { // Check if location exists, otherwise allocate new and insert WorldLocation *location = get_location(chest->m_location.c_str()); if (location) { m_chest = chest; location->m_nodes.push_back(chest); } } } else if (m_chest) { if (strcmp(node->Value(), "treasure") == 0) { WorldObject *object = new WorldObject; result = load_object_attributes(object, node->ToElement()); if (result) { m_chest->m_objects.push_back(object); } else { goto error; } } } } for (TiXmlNode *child = node->FirstChild(); child != 0; child = child->NextSibling()) { if (!load_nodes(child)) { result = false; } } error: return result; }