/** This method is used to load all of the paths * @param pathsNode The XML node to load the paths from * @return 0 , The file was loaded without problems * -2 , If the file is corrupt */ int CMapFileFilterXML::loadPaths(QDomElement *pathsNode) { QDomNode n = pathsNode->firstChild(); while (!n.isNull() ) { QDomElement e = n.toElement(); if (e.isNull() ) { kDebug() << "Unable to find path element "; return -2; } if (e.tagName()=="Path") { int srcLevelID = e.attribute("SrcLevel","-2").toInt(); int destLevelID = e.attribute("DestLevel","-2").toInt(); if (srcLevelID == -2 || destLevelID == -2) { kDebug() << "Unable to find path end points"; return -2; } CMapLevel *srcLevel = m_mapManager->findLevel(srcLevelID); CMapLevel *destLevel = m_mapManager->findLevel(destLevelID); int srcRoomID = e.attribute("SrcRoom","-2").toInt(); int destRoomID = e.attribute("DestRoom","-2").toInt(); if (destRoomID == -2 || srcRoomID == -2) { kDebug() << "Unable to find path end points"; return -2; } CMapRoom *srcRoom = srcLevel->findRoom(srcRoomID); CMapRoom *destRoom = destLevel->findRoom(destRoomID); if (srcRoom==NULL || destRoom==NULL) { kDebug() << "Src or Dest room is NULL while creating path"; return -2; } directionTyp srcDir = (directionTyp)e.attribute("SrcDir","0").toInt(); directionTyp destDir = (directionTyp)e.attribute("DestDir","0").toInt(); CMapPath *path = m_mapManager->createPath(srcRoom,srcDir,destRoom,destDir); path->loadQDomElement(&e); loadPluginPropertiesForElement(path,&e); } n = n.nextSibling(); } kDebug() << "loadPaths Here 4"; return 0; }
void CMapCmdSpeedwalkAdd::undo() { CMapLevel *level = m_plugin->getManager()->findLevel(m_levelID); if (!level) return; CMapRoom *room = level->findRoom(m_roomID); if (!room) return; m_plugin->delSpeedwalkRoomNoCmd(room); }
/** This method is used to load all of the links * @param pathsNode The XML node to load the links from * @return 0 , The file was loaded without problems * -2 , If the file is corrupt */ int CMapFileFilterXML::loadLinks(QDomElement *pathsNode) { QDomNode n = pathsNode->firstChild(); while (!n.isNull() ) { QDomElement e = n.toElement(); if (e.isNull() ) { kDebug() << "Unable to find link element "; return -2; } if (e.tagName()=="Link") { int srcLevelID = e.attribute("SrcLevel","-2").toInt(); int destLevelID = e.attribute("DestLevel","-2").toInt(); if (srcLevelID == -2 || destLevelID == -2) { kDebug() << "Unable to find link end points"; return -2; } CMapLevel *srcLevel = m_mapManager->findLevel(srcLevelID); CMapLevel *destLevel = m_mapManager->findLevel(destLevelID); int textID = e.attribute("SrcID","-2").toInt(); int destID = e.attribute("DestID","-2").toInt(); int labelPos = e.attribute("LabelPos","0").toInt(); int srcTyp = e.attribute("SrcType","-2").toInt(); int destTyp = e.attribute("DestType","-2").toInt(); if (textID == -2 || destID == -2 || destTyp == -2 || srcTyp == -2) { kDebug() << "Unable to find link end points"; return -2; } if (srcTyp == (int)TEXT) { CMapText *text = srcLevel->findText(textID); if (destTyp==(int)ROOM) { CMapRoom *destElement = destLevel->findRoom(destID); destElement->setLabelPosition((CMapRoom::labelPosTyp)labelPos,text); } if (destTyp==(int)ZONE) { CMapZone *destElement = m_mapManager->findZone(destID); destElement->setLabelPosition((CMapZone::labelPosTyp)labelPos,text); } } } n = n.nextSibling(); } return 0; }