bool QGeoRouteXmlParser::parseBoundingBox(QGeoBoundingBox &bounds)
{
    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "BoundingBox");

    QGeoCoordinate tl;
    QGeoCoordinate br;

    m_reader->readNext();
    while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "BoundingBox")) {
        if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
            if (m_reader->name() == "TopLeft") {
                QGeoCoordinate coordinates;
                if (parseCoordinates(coordinates))
                    tl = coordinates;
            } else if (m_reader->name() == "BottomRight") {
                QGeoCoordinate coordinates;
                if (parseCoordinates(coordinates))
                    br = coordinates;
            } else {
                m_reader->skipCurrentElement();
            }
        }
        m_reader->readNext();
    }

    if (tl.isValid() && br.isValid()) {
        bounds = QGeoBoundingBox(tl, br);
        return true;
    }

    return false;
}
// COMMAND IMPLEMENTATION
// Purpose:
// .go >> Gump with possible targets
// .go x,y,z,[map] >> Go to those coordinates
// .go placename >> Go to that specific place
void commandGo( cUOSocket *socket, const QString &command, QStringList &args ) throw()
{
	Q_UNUSED(command);
	P_CHAR pChar = socket->player();

	if( !pChar )
		return;

	UI08 map = pChar->pos().map;

	if( args.isEmpty() )
	{
		socket->sysMessage( "Bringin up travel gump" );
		return;
	}
	else
	{

		Coord_cl newPos = pChar->pos();
		QString argument = args.join(" ");
		if( parseCoordinates( argument, newPos ) )
		{
			// This is a bandwith saving method
			// Before we're moving the character anywhere we remove it
			// only from the sockets in range and then resend it to only the new sockets in range
			
			pChar->removeFromView( false );
			pChar->moveTo( newPos );
			pChar->resend( false, true );
			socket->resendPlayer( map == pChar->pos().map );
			socket->resendWorld();
			return;
		}

		// When we reached this point it's clear that we didn't find any valid coordinates in our arguments
		const QDomElement *node = DefManager->getSection( WPDT_LOCATION, argument );

		if( !node->isNull() && parseCoordinates( node->text(), newPos ) )
		{
			pChar->removeFromView( false );
			pChar->moveTo( newPos );
			pChar->resend( false, true );
			socket->resendPlayer( map == pChar->pos().map );
			socket->resendWorld();
			return;
		}			
	}

	// If we reached this end it's definetly an invalid command
	socket->sysMessage( tr( "Usage: go [location|x,y,z,[map]]" ) );
}
// Simple setting and getting of properties for scripts and the set command.
stError *cUObject::setProperty( const QString &name, const cVariant &value )
{
	changed( SAVE|TOOLTIP );
	SET_STR_PROPERTY( "bindmenu", bindmenu_ )
	else SET_INT_PROPERTY( "serial", serial_ )
	else SET_INT_PROPERTY( "multi", multis_ )
	else SET_BOOL_PROPERTY( "free", free )
	else SET_STR_PROPERTY( "name", this->name_ )

	else if( name == "pos" )
	{
		Coord_cl pos;
		if( !parseCoordinates( value.toString(), pos ) )
			PROPERTY_ERROR( -3, QString( "Invalid coordinate value: '%1'" ).arg( value.toString() ) )
		moveTo( pos );
		return 0;
	}

	// Trying to set new Eventlist
	else if( name == "eventlist" )
	{
		clearEvents();
		QStringList list = QStringList::split( ",", value.toString() );
		for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it )
		{
			WPDefaultScript *script = ScriptManager->find( *it );
			if( script )
				addEvent( script );
			else
				PROPERTY_ERROR( -3, QString( "Script not found: '%1'" ).arg( *it ) )
		}
		return 0;
	}
Example #4
0
 /// Returns parsed relation.
 utymap::entities::Relation parseRelation(std::uint32_t featureId, const ptree &geometry) const {
   utymap::entities::Relation relation;
   relation.id = 0;
   for (const ptree::value_type &coordTree : geometry) {
     auto coordinates = parseCoordinates(coordTree.second);
     if (coordinates.size() > 3 && coordinates[0]==coordinates[coordinates.size() - 1])
       addToRelation<utymap::entities::Area>(relation, coordinates);
     else
       addToRelation<utymap::entities::Way>(relation, coordinates);
   }
   return relation;
 }
/*!
  Returns the variant as a Coordinate if the variant has type()
  StringType; or NULL otherwise.
*/
Coord cVariant::toCoord() const
{
	if ( typ == CoordType )
		return *( ( Coord * ) value.ptr );

	// Parse Coord
	if ( typ == StringType )
	{
		Coord pos;
		if ( parseCoordinates( *( ( QString * ) value.ptr ), pos ) )
			return pos;
	}

	return Coord( 0, 0, 0, 0 );
}
// Simple setting and getting of properties for scripts and the set command.
stError* cUObject::setProperty( const QString& name, const cVariant& value )
{
	changed( TOOLTIP );
	changed_ = true;
	// \rproperty object.serial This integer property contains the serial for this object.
	if ( name == "serial" )
	{
		if ( !value.canCast( cVariant::IntType ) )
		{
			PROPERTY_ERROR( -3, QString( "Invalid integer value: '%1'" ).arg( value.toString() ) );
		}
		setSerial( value.toInt() );
		return 0;
	}

	// \property object.free This boolean property indicates that the object has been freed and is awaiting deletion.
	else
		SET_BOOL_PROPERTY( "free", free )
		// \property object.name This string property contains the name of the object.
	else
		SET_STR_PROPERTY( "name", this->name_ )
		// \property object.pos This property is a <object id="coord">coord</object> object (Python) or a string representation (Show/Set) of the objects position.
	else if ( name == "pos" )
	{
		Coord pos;
		if ( !parseCoordinates( value.toString(), pos ) )
			PROPERTY_ERROR( -3, QString( "Invalid coordinate value: '%1'" ).arg( value.toString() ) )
			moveTo( pos );
		return 0;
	}

	// \property object.eventlist This string property contains a comma separated list of the names of the scripts that are assigned to this object.
	else if ( name == "scriptlist" )
	{
		clearScripts();
		QStringList list = value.toString().split( "," );
		for ( QStringList::const_iterator it( list.begin() ); it != list.end(); ++it )
		{
			cPythonScript* script = ScriptManager::instance()->find( ( *it ).toLatin1() );
			if ( script )
				addScript( script );
			else
				PROPERTY_ERROR( -3, QString( "Script not found: '%1'" ).arg( *it ) )
		}
		return 0;
	}
Example #7
0
bool Cube::parse(TextStream& textStream)
{
   // Header information
   textStream.skipLine(2);

   int nAtoms(parseGridAxes(textStream));
   if (nAtoms == 0) {
      QString msg("Incorrect format on line ");
      msg += QString::number(textStream.lineNumber());
      msg += "\nExpected: <int>  <double>  <double>  <double>";
      m_errors.append(msg);
      return false;
   }

   if (!parseCoordinates(textStream, nAtoms)) return false;
   parseGridData(textStream);

   return m_errors.isEmpty();
}
// Simple setting and getting of properties for scripts and the set command.
stError *cUObject::setProperty( const QString &name, const cVariant &value )
{
	changed( TOOLTIP );
	changed_ = true;
	// \property object.bindmenu This string property contains a comma separated list of context menu ids for this object.
	SET_STR_PROPERTY( "bindmenu", bindmenu_ )
	// \rproperty object.serial This integer property contains the serial for this object. Read Only
	else SET_INT_PROPERTY( "serial", serial_ )
	// \property object.multi This integer property contains the serial of the multi object this object is in.
	else SET_INT_PROPERTY( "multi", multis_ )
	// \property object.direction This is the integer direction of this object.
	else SET_INT_PROPERTY( "direction", dir_ )
	// \property object.free This boolean property indicates that the object has been freed and is awaiting deletion.
	else SET_BOOL_PROPERTY( "free", free )
	// \property object.name This string property contains the name of the object.
	else SET_STR_PROPERTY( "name", this->name_ )
	// \property object.pos This string property is the string representation of the position of the object.
	else if( name == "pos" )
	{
		Coord_cl pos;
		if( !parseCoordinates( value.toString(), pos ) )
			PROPERTY_ERROR( -3, QString( "Invalid coordinate value: '%1'" ).arg( value.toString() ) )
		moveTo( pos );
		return 0;
	}

	// \property object.pos This string property contains a comma separated list of the names of the scripts that are assigned to this object.
	else if( name == "eventlist" )
	{
		clearEvents();
		QStringList list = QStringList::split( ",", value.toString() );
		for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it )
		{
			cPythonScript *script = ScriptManager::instance()->find( (*it).latin1() );
			if( script )
				addEvent( script );
			else
				PROPERTY_ERROR( -3, QString( "Script not found: '%1'" ).arg( *it ) )
		}
		return 0;
	}
Example #9
0
void cTerritory::processNode( const cElement* Tag, uint hash )
{
	QString TagName( Tag->name() );
	QString Value( Tag->value() );

	//<guards>
	//  <npc mult="2">npcsection</npc> (mult inserts 2 same sections into the list so the probability rises!
	//	<npc><random list="npcsectionlist" /></npc>
	//  <list id="npcsectionlist" />
	//</guards>
	if ( TagName == "guards" )
	{
		for ( uint i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			if ( childNode->name() == "npc" )
			{
				uint mult = childNode->getAttribute( "mult" ).toInt();
				if ( mult < 1 )
					mult = 1;

				for ( uint j = 0; j < mult; j++ )
					this->guardSections_.push_back( childNode->value() );
			}
			else if ( childNode->name() == "list" && childNode->hasAttribute( "id" ) )
			{
				QStringList NpcList = Definitions::instance()->getList( childNode->getAttribute( "id" ) );
				QStringList::const_iterator it( NpcList.begin() );
				for ( ; it != NpcList.end(); ++it )
					this->guardSections_.push_back( *it );
			}
		}
	}

	// <fixedlight>number</fixedlight>
	else if ( TagName == "fixedlight" )
		this->fixedlight_ = Value.toShort();

	// <guardowner>text</guardowner>
	else if ( TagName == "guardowner" )
		if ( Value == "the town" )
			this->guardowner_ = "";
		else
			this->guardowner_ = Value;

	// <resores>ORES</resores>
	else if ( TagName == "resores" )
		this->resores_ = Value;

	// <firstcoin>IDofCOIN</firstcoin>
	else if ( TagName == "firstcoin" )
		this->firstcoin_ = Value;

	// <secondcoin>IDofCOIN</secondcoin>
	else if ( TagName == "secondcoin" )
		this->secondcoin_ = Value;

	// <thirdcoin>IDofCOIN</thirdcoin>
	else if ( TagName == "thirdcoin" )
		this->thirdcoin_ = Value;

	// <midilist>MIDI_COMBAT</midilist>
	else if ( TagName == "midilist" )
		this->midilist_ = Value;
	// <extraflags>ExtraFlags</extraflags>
	else if ( TagName == "extraflags" )
		this->extraflags_ = Value.toUShort();
	else if ( TagName == "flags" )
	{
		flags_ = 0;

		for ( unsigned int i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			if ( childNode->name() == "guarded" )
				setGuarded( true );
			else if ( childNode->name() == "nomark" )
				setNoMark( true );
			else if ( childNode->name() == "nogate" )
				setNoGate( true );
			else if ( childNode->name() == "norecallout" )
				setNoRecallOut( true );
			else if ( childNode->name() == "norecallin" )
				setNoRecallIn( true );
			else if ( childNode->name() == "recallshield" )
				setRecallShield( true );
			else if ( childNode->name() == "noagressivemagic" )
				setNoAgressiveMagic( true );
			else if ( childNode->name() == "antimagic" )
				setAntiMagic( true );
			else if ( childNode->name() == "escortregion" )
				setValidEscortRegion( true );
			else if ( childNode->name() == "cave" )
				setCave( true );
			else if ( childNode->name() == "nomusic" )
				setNoMusic( true );
			else if ( childNode->name() == "noguardmessage" )
				setNoGuardMessage( true );
			else if ( childNode->name() == "noentermessage" )
				setNoEnterMessage( true );
			else if ( childNode->name() == "nohousing" )
				setNoHousing( true );
			else if ( childNode->name() == "nodecay" )
				setNoDecay( true );
			else if ( childNode->name() == "instalogout" )
				setInstaLogout( true );
			else if ( childNode->name() == "noteleport" )
				setNoTeleport( true );
			else if ( childNode->name() == "safe" )
				setSafe( true );
			else if ( childNode->name() == "nocriminalcombat" )
				setNoCriminalCombat( true );
			else if ( childNode->name() == "nokillcount" )
				setNoKillCount( true );
		}
	}

	// <snowchance>50</snowchance>
	else if ( TagName == "snowchance" )
	{
		this->snowchance_ = Value.toUShort();
	}

	// <rainchance>50</rainchance>
	else if ( TagName == "rainchance" )
	{
		this->rainchance_ = Value.toUShort();
	}

	// <rainduration>2</rainduration>
	else if ( TagName == "rainduration" )
	{
		this->rainduration_ = Value.toUShort();
	}
	// <snowduration>2</snowduration>
	else if ( TagName == "snowduration" )
	{
		this->snowduration_ = Value.toUShort();
	}
	// <dryduration>4</dryduration>
	else if ( TagName == "dryduration" )
	{
		this->dryduration_ = Value.toUShort();
	}
	// <rainrangeduration>1</rainrangeduration>
	else if ( TagName == "rainrangeduration" )
	{
		this->rainrangeduration_ = Value.toUShort();
	}
	// <snowrangeduration>1</snowrangeduration>
	else if ( TagName == "snowrangeduration" )
	{
		this->snowrangeduration_ = Value.toUShort();
	}
	// <dryrangeduration>1</dryrangeduration>
	else if ( TagName == "dryrangeduration" )
	{
		this->dryrangeduration_ = Value.toUShort();
	}
	// <minintensity>1</minintensity>
	else if ( TagName == "minintensity" )
	{
		this->minintensity_ = Value.toUShort();
	}
	// <maxintensity>1</maxintensity>
	else if ( TagName == "maxintensity" )
	{
		this->maxintensity_ = Value.toUShort();
	}
	// <tradesystem>
	//		<good num="1">
	//			<buyable>10</buyable>
	//			<sellable>20</sellable>
	//			<randomvalue min="10" max="20" />
	//		</good>
	//		<good ...>
	//		...
	//		</good>
	// </tradesystem>
	else if ( TagName == "tradesystem" )
	{
		for ( unsigned int i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			good_st goods;
			goods.buyable = 0;
			goods.sellable = 0;
			goods.rndmin = 0;
			goods.rndmax = 0;
			uint num = 0xFFFFFFFF;

			if ( childNode->name() == "good" )
			{
				if ( childNode->hasAttribute( "num" ) )
					num = childNode->getAttribute( "num" ).toInt();

				for ( unsigned int j = 0; j < childNode->childCount(); ++j )
				{
					const cElement* chchildNode = childNode->getChild( j );

					QString childValue = chchildNode->value();

					if ( chchildNode->name() == "buyable" )
						goods.buyable = childValue.toInt();
					else if ( chchildNode->name() == "sellable" )
						goods.sellable = childValue.toInt();
					else if ( chchildNode->name() == "randomvalue" )
					{
						goods.rndmin = chchildNode->getAttribute( "min" ).toInt();
						goods.rndmax = chchildNode->getAttribute( "max" ).toInt();
					}
				}
			}

			if ( num != 0xFFFFFFFF )
				this->tradesystem_[num] = goods;
		}
	}

	// <region id="Cove Market Place">
	//		...region nodes...
	// </region>
	else if ( TagName == "region" )
	{
		cTerritory* toinsert_ = new cTerritory( Tag, this );
		this->subregions_.push_back( toinsert_ );
	}
	else if ( TagName == "teleport" )
	{
		if ( !Tag->hasAttribute( "source" ) )
		{
			Console::instance()->log( LOG_ERROR, tr("processing teleport tag, missing source attribute") );
			return;
		}

		if ( !Tag->hasAttribute( "destination" ) )
		{
			Console::instance()->log( LOG_ERROR, tr("processing teleport tag, missing destination attribute") );
			return;
		}
		Coord source, destination;
		if ( !parseCoordinates( Tag->getAttribute( "source" ), source ) )
		{
			Console::instance()->log( LOG_ERROR, tr("parsing source attribute, not a valid coordinate vector") );
			return;
		}
		if ( !parseCoordinates( Tag->getAttribute( "destination" ), destination ) )
		{
			Console::instance()->log( LOG_ERROR, tr("parsing destination attribute, not a valid coordinate vector") );
			return;
		}
		bool bothways = Tag->hasAttribute( "bothways" );
		teleporters_st teleporter;
		teleporter.source = source;
		teleporter.destination = destination;
		teleporters.append( teleporter );
		if ( bothways )
		{
			teleporter.source = destination;
			teleporter.destination = source;
			teleporters.append( teleporter );
		}
	}
	else
		cBaseRegion::processNode( Tag, hash );
}
void cTerritory::processNode( const cElement* Tag )
{
	QString TagName( Tag->name() );
	QString Value( Tag->value() );

	//<guards>
	//  <npc mult="2">npcsection</npc> (mult inserts 2 same sections into the list so the probability rises!
	//	<npc><random list="npcsectionlist" /></npc>
	//  <list id="npcsectionlist" />
	//</guards>
	if ( TagName == "guards" )
	{
		for ( unsigned int i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			if ( childNode->name() == "npc" )
			{
				UI32 mult = childNode->getAttribute( "mult" ).toInt();
				if ( mult < 1 )
					mult = 1;

				for ( UI32 i = 0; i < mult; i++ )
					this->guardSections_.push_back( childNode->value() );
			}
			else if ( childNode->name() == "list" && childNode->hasAttribute( "id" ) )
			{
				QStringList NpcList = Definitions::instance()->getList( childNode->getAttribute( "id" ) );
				QStringList::const_iterator it( NpcList.begin() );
				for ( ; it != NpcList.end(); ++it )
					this->guardSections_.push_back( *it );
			}
		}
	}

	// <guardowner>text</guardowner>
	else if ( TagName == "guardowner" )
		if ( Value == "the town" )
			this->guardowner_ = "";
		else
			this->guardowner_ = Value;

	// <midilist>MIDI_COMBAT</midilist>
	else if ( TagName == "midilist" )
		this->midilist_ = Value;
	else if ( TagName == "flags" )
	{
		flags_ = 0;

		for ( unsigned int i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			if ( childNode->name() == "guarded" )
				setGuarded( true );
			else if ( childNode->name() == "nomark" )
				setNoMark( true );
			else if ( childNode->name() == "nogate" )
				setNoGate( true );
			else if ( childNode->name() == "norecallout" )
				setNoRecallOut( true );
			else if ( childNode->name() == "norecallin" )
				setNoRecallIn( true );
			else if ( childNode->name() == "recallshield" )
				setRecallShield( true );
			else if ( childNode->name() == "noagressivemagic" )
				setNoAgressiveMagic( true );
			else if ( childNode->name() == "antimagic" )
				setAntiMagic( true );
			else if ( childNode->name() == "escortregion" )
				setValidEscortRegion( true );
			else if ( childNode->name() == "cave" )
				setCave( true );
			else if ( childNode->name() == "nomusic" )
				setNoMusic( true );
			else if ( childNode->name() == "noguardmessage" )
				setNoGuardMessage( true );
			else if ( childNode->name() == "noentermessage" )
				setNoEnterMessage( true );
		}
	}

	// <snowchance>50</snowchance>
	else if ( TagName == "snowchance" )
		this->snowchance_ = Value.toUShort();

	// <rainchance>50</rainchance>
	else if ( TagName == "rainchance" )
		this->rainchance_ = Value.toUShort();

	// <tradesystem>
	//		<good num="1">
	//			<buyable>10</buyable>
	//			<sellable>20</sellable>
	//			<randomvalue min="10" max="20" />
	//		</good>
	//		<good ...>
	//		...
	//		</good>
	// </tradesystem>
	else if ( TagName == "tradesystem" )
	{
		for ( unsigned int i = 0; i < Tag->childCount(); ++i )
		{
			const cElement* childNode = Tag->getChild( i );

			good_st goods;
			goods.buyable = 0;
			goods.sellable = 0;
			goods.rndmin = 0;
			goods.rndmax = 0;
			UI32 num = 0xFFFFFFFF;

			if ( childNode->name() == "good" )
			{
				if ( childNode->hasAttribute( "num" ) )
					num = childNode->getAttribute( "num" ).toInt();

				for ( unsigned int j = 0; j < childNode->childCount(); ++j )
				{
					const cElement* chchildNode = childNode->getChild( j );

					QString childValue = chchildNode->value();

					if ( chchildNode->name() == "buyable" )
						goods.buyable = childValue.toInt();
					else if ( chchildNode->name() == "sellable" )
						goods.sellable = childValue.toInt();
					else if ( chchildNode->name() == "randomvalue" )
					{
						goods.rndmin = chchildNode->getAttribute( "min" ).toInt();
						goods.rndmax = chchildNode->getAttribute( "max" ).toInt();
					}
				}
			}

			if ( num != 0xFFFFFFFF )
				this->tradesystem_[num] = goods;
		}
	}

	// <region id="Cove Market Place">
	//		...region nodes...
	// </region>
	else if ( TagName == "region" )
	{
		cTerritory* toinsert_ = new cTerritory( Tag, this );
		this->subregions_.push_back( toinsert_ );
	}
	else if ( TagName == "teleport" )
	{
		if ( !Tag->hasAttribute( "source" ) )
		{
			qWarning( "ERROR: processing teleport tag, missing source attribute" );
			return;
		}

		if ( !Tag->hasAttribute( "destination" ) )
		{
			qWarning( "ERROR: processing teleport tag, missing destination attribute" );
			return;
		}
		Coord_cl source, destination;
		if ( !parseCoordinates( Tag->getAttribute( "source" ), source ) )
		{
			qWarning( "ERROR: parsing source attribute, not a valid coordinate vector" );
			return;
		}
		if ( !parseCoordinates( Tag->getAttribute( "destination" ), destination ) )
		{
			qWarning( "ERROR: parsing destination attribute, not a valid coordinate vector" );
			return;
		}
		bool bothways = Tag->hasAttribute( "bothways" );
		teleporters_st teleporter;
		teleporter.source = source;
		teleporter.destination = destination;
		teleporters.append( teleporter );
		if ( bothways )
		{
			teleporter.source = destination;
			teleporter.destination = source;
			teleporters.append( teleporter );
		}
	}
	else
		cBaseRegion::processNode( Tag );
}
bool QGeoRouteXmlParser::parseManeuver()
{
    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "Maneuver");

    if (!m_reader->attributes().hasAttribute("id")) {
        m_reader->raiseError("The element \"Maneuver\" did not have the required attribute \"id\".");
        return false;
    }
    QGeoManeuverContainer maneuverContainter;
    maneuverContainter.id = m_reader->attributes().value("id").toString();

    m_reader->readNext();
    while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "Maneuver")) {
        if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
            if (m_reader->name() == "Position") {
                QGeoCoordinate coordinates;
                if (parseCoordinates(coordinates))
                    maneuverContainter.maneuver.setPosition(coordinates);
            } else if (m_reader->name() == "Instruction") {
                maneuverContainter.maneuver.setInstructionText(m_reader->readElementText());
            } else if (m_reader->name() == "ToLink") {
                maneuverContainter.toId = m_reader->readElementText();
            } else if (m_reader->name() == "TravelTime") {
                maneuverContainter.maneuver.setTimeToNextInstruction(m_reader->readElementText().toInt());
            } else if (m_reader->name() == "Length") {
                maneuverContainter.maneuver.setDistanceToNextInstruction(m_reader->readElementText().toDouble());
            } else if (m_reader->name() == "Direction") {
                QString value = m_reader->readElementText();
                if (value == "forward")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionForward);
                else if (value == "bearRight")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionBearRight);
                else if (value == "lightRight")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLightRight);
                else if (value == "right")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionRight);
                else if (value == "hardRight")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionHardRight);
                else if (value == "uTurnRight")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionUTurnRight);
                else if (value == "uTurnLeft")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionUTurnLeft);
                else if (value == "hardLeft")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionHardLeft);
                else if (value == "left")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLeft);
                else if (value == "lightLeft")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionLightLeft);
                else if (value == "bearLeft")
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::DirectionBearLeft);
                else
                    maneuverContainter.maneuver.setDirection(QGeoManeuver::NoDirection);
            } else {
                m_reader->skipCurrentElement();
            }
        }
        m_reader->readNext();
    }

    maneuvers.append(maneuverContainter);
    return true;
}
void cTerritories::load()
{
	// Make sure that there is one top level region for each map
	// Insert it at the beginning (last overrides first).
	for ( unsigned char i = 0; i <= 4; ++i )
	{
		if ( Maps::instance()->hasMap( i ) )
		{
			cTerritory* territory = new cTerritory();
			cBaseRegion::rect_st rect;
			rect.map = i;
			rect.x1 = 0;
			rect.y1 = 0;
			rect.x2 = Maps::instance()->mapTileWidth( i ) * 8;
			rect.y2 = Maps::instance()->mapTileHeight( i ) * 8;
			territory->rectangles().append( rect );
			topregions[i].append( territory );
			topregions[i].setAutoDelete( true ); // set to auto delete
		}
	}

	const QValueVector<cElement*>& elements = Definitions::instance()->getDefinitions( WPDT_REGION );

	QValueVector<cElement*>::const_iterator it( elements.begin() );
	while ( it != elements.end() )
	{
		cTerritory* territory = new cTerritory( *it, 0 );

		if ( territory->rectangles().empty() )
		{
			Console::instance()->log( LOG_WARNING, tr( "Region %1 lacks rectangle tag, ignoring region.\n" ).arg( territory->name() ) );
			delete territory;
		}
		else
		{
			unsigned char map = territory->rectangles()[0].map;

			if ( !topregions.contains( map ) )
			{
				topregions[map].setAutoDelete( true );
			}

			topregions[map].append( territory );
		}
		++it;
	}

	// Get the toplevel teleporters and insert them
	const QValueVector<cElement*> &teleporters = Definitions::instance()->getDefinitions( WPDT_TELEPORTER );
	QValueVector<cElement*>::const_iterator tit;
	for ( tit = teleporters.begin(); tit != teleporters.end(); ++tit )
	{
		cElement *element = *tit;

		// Source + Destination
		QString source = element->getAttribute( "source" );
		QString destination = element->getAttribute( "destination" );

		if ( source.isEmpty() || destination.isEmpty() )
		{
			continue; // Skip broken teleporters
		}

		// Convert into coordinates
		Coord clSource, clDestination;
		if ( !parseCoordinates( source, clSource ) || !parseCoordinates( destination, clDestination ) )
		{
			continue; // Skip broken coordinates
		}

		// Search the region for the source spot
		cTerritory *rSource = region( clSource );
		if ( rSource )
		{
			rSource->addTeleporter( clSource, clDestination ); // Add the teleportation spot
		}
		else if ( Maps::instance()->hasMap( clSource.map ) )
		{
			Console::instance()->log( LOG_WARNING, tr( "Couldn't find source region for teleporter at %1." ).arg( source ) );
		}

		// Add another teleportation spot at the destination coordinate if this is a two-way teleporter
		QString bothways = element->getAttribute( "bothways", "false" );
		if ( bothways == "true" || bothways == "1" || bothways == "on" )
		{
			cTerritory *rDestination = region( clDestination );
			if ( rDestination )
			{
				rDestination->addTeleporter( clDestination, clSource ); // Add the teleportation spot
			}
			else if ( Maps::instance()->hasMap( clDestination.map ) )
			{
				Console::instance()->log( LOG_WARNING, tr( "Couldn't find destination region for two-way teleporter at %1." ).arg( destination ) );
			}
		}
	}

	cComponent::load();
}
Example #13
0
void MoleculeSection::setCoordinates(QString const& coordinates) { 
   m_coordinates = coordinates; 
   parseCoordinates();
}
Example #14
0
 /// Parses way from line string and notifies visitor.
 void parseLineString(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Way way;
   parseProperties(way, featureId, feature.get_child("properties"));
   way.coordinates = parseCoordinates(feature.get_child("geometry.coordinates"));
   visitor.add(way);
 }