wxTreeItemId BFBackupTree::FindItemByPath (wxTreeItemId idStart, const wxString& strPath)
{
    wxTreeItemId            idCurr, idLast;
    wxTreeItemIdValue       idCookie;
    wxString                str;

    // check start item
    if (HasPath(idStart, strPath))
        return idStart;

    if (ItemHasChildren(idStart))
    {
        for (idCurr = GetFirstChild(idStart, idCookie);
             idCurr.IsOk();
             idCurr = GetNextChild(idStart, idCookie))
        {
            idLast = FindItemByPath(idCurr, strPath);

            if (idLast.IsOk())
                return idLast;
        }
    }

    return wxTreeItemId();
}
Exemplo n.º 2
0
void CCinemaManager::AddPathToQueue(const CStrW& name)
{
	if (!HasPath(name))
	{
		LOGWARNING("Path with name '%s' doesn't exist", name.ToUTF8());
		return;
	}
	m_CinematicSimulationData.m_PathQueue.push_back(m_CinematicSimulationData.m_Paths[name]);
}
Exemplo n.º 3
0
status_t
PathList::RemovePath(const char* path)
{
	int32 index;
	if (!HasPath(path, &index))
		return B_ENTRY_NOT_FOUND;

	if (--fPaths.ItemAt(index)->ref_count == 0)
		delete fPaths.RemoveItemAt(index);

	return B_OK;
}
Exemplo n.º 4
0
// Compute closest point on path to given point
// NOTE: This does not do line-of-sight tests, so closest point may be thru the floor, etc
bool CCSBot::FindClosestPointOnPath(const Vector *worldPos, int startIndex, int endIndex, Vector *close) const
{
	if (!HasPath() || !close)
		return false;

	Vector along, toWorldPos;
	Vector pos;
	const Vector *from, *to;
	float length;
	float closeLength;
	float closeDistSq = 9999999999.9f;
	float distSq;

	for (int i = startIndex; i <= endIndex; i++)
	{
		from = &m_path[i - 1].pos;
		to = &m_path[i].pos;

		// compute ray along this path segment
		along = *to - *from;

		// make it a unit vector along the path
		length = along.NormalizeInPlace();

		// compute vector from start of segment to our point
		toWorldPos = *worldPos - *from;

		// find distance of closest point on ray
		closeLength = DotProduct(toWorldPos, along);

		// constrain point to be on path segment
		if (closeLength <= 0.0f)
			pos = *from;
		else if (closeLength >= length)
			pos = *to;
		else
			pos = *from + closeLength * along;

		distSq = (pos - *worldPos).LengthSquared();

		// keep the closest point so far
		if (distSq < closeDistSq)
		{
			closeDistSq = distSq;
			*close = pos;
		}
	}

	return true;
}
Exemplo n.º 5
0
NOXREF bool CCSBot::FindApproachPointNearestPath(Vector *pos)
{
	if (!HasPath())
		return false;

	// make sure approach points are accurate
	ComputeApproachPoints();

	if (m_approachPointCount == 0)
		return false;

	Vector target = Vector(0, 0, 0), close;
	float targetRangeSq = 0.0f;
	bool found = false;

	int start = m_pathIndex;
	int end = m_pathLength;

	// We dont want the strictly closest point, but the farthest approach point
	// from us that is near our path
	const float nearPathSq = 10000.0f;

	for (int i = 0; i < m_approachPointCount; ++i)
	{
		if (FindClosestPointOnPath(&m_approachPoint[i], start, end, &close) == false)
			continue;

		float rangeSq = (m_approachPoint[i] - close).LengthSquared();
		if (rangeSq > nearPathSq)
			continue;

		if (rangeSq > targetRangeSq)
		{
			target = close;
			targetRangeSq = rangeSq;
			found = true;
		}
	}

	if (found)
	{
		*pos = target + Vector(0, 0, HalfHumanHeight);
		return true;
	}

	return false;
}
Exemplo n.º 6
0
// Draw a portion of our current path for debugging.
void CCSBot::DrawPath()
{
	if (!HasPath())
		return;

	for (int i = 1; i < m_pathLength; i++)
	{
		UTIL_DrawBeamPoints(m_path[i - 1].pos, m_path[i].pos, 2, 255, 75, 0);
	}

	Vector close;
	if (FindOurPositionOnPath(&close, true) >= 0)
	{
		UTIL_DrawBeamPoints(close + Vector(0, 0, 25), close, 1, 0, 255, 0);
		UTIL_DrawBeamPoints(close + Vector(25, 0, 0), close + Vector(-25, 0, 0), 1, 0, 255, 0);
		UTIL_DrawBeamPoints(close + Vector(0, 25, 0), close + Vector(0, -25, 0), 1, 0, 255, 0);
	}
}
Exemplo n.º 7
0
// Return estimated distance left to travel along path
float CCSBot::GetPathDistanceRemaining() const
{
	if (!HasPath())
		return -1.0f;

	int idx = (m_pathIndex < m_pathLength) ? m_pathIndex : m_pathLength - 1;

	float dist = 0.0f;
	const Vector *prevCenter = m_path[m_pathIndex].area->GetCenter();

	for (int i = idx + 1; i < m_pathLength; i++)
	{
		dist += (*m_path[i].area->GetCenter() - *prevCenter).Length();
		prevCenter = m_path[i].area->GetCenter();
	}

	return dist;
}
Exemplo n.º 8
0
status_t
PathList::AddPath(const char* path)
{
	if (path == NULL)
		return B_BAD_VALUE;

	int32 index;
	if (HasPath(path, &index)) {
		fPaths.ItemAt(index)->ref_count++;
		return B_OK;
	}

	path_entry* entry = new(std::nothrow) path_entry(path);
	if (entry == NULL || entry->path == NULL || !fPaths.AddItem(entry)) {
		delete entry;
		return B_NO_MEMORY;
	}

	return B_OK;
}
Exemplo n.º 9
0
// AddPath
bool
PathContainer::AddPath(VectorPath* path, int32 index)
{
	if (!path)
		return false;

	// prevent adding the same path twice
	if (HasPath(path))
		return false;

	if (fPaths.AddItem((void*)path, index)) {
#ifdef ICON_O_MATIC
		_NotifyPathAdded(path, index);
#endif
		return true;
	}

	fprintf(stderr, "PathContainer::AddPath() - out of memory!\n");
	return false;
}
Exemplo n.º 10
0
void wxURI::Resolve(const wxURI& base, int flags)
{
    wxASSERT_MSG(!base.IsReference(),
                "wxURI to inherit from must not be a reference!");

    // If we aren't being strict, enable the older (pre-RFC2396) loophole that
    // allows this uri to inherit other properties from the base uri - even if
    // the scheme is defined
    if ( !(flags & wxURI_STRICT) &&
            HasScheme() && base.HasScheme() &&
                m_scheme == base.m_scheme )
    {
        m_fields -= wxURI_SCHEME;
    }


    // Do nothing if this is an absolute wxURI
    //    if defined(R.scheme) then
    //       T.scheme    = R.scheme;
    //       T.authority = R.authority;
    //       T.path      = remove_dot_segments(R.path);
    //       T.query     = R.query;
    if (HasScheme())
        return;

    //No scheme - inherit
    m_scheme = base.m_scheme;
    m_fields |= wxURI_SCHEME;

    // All we need to do for relative URIs with an
    // authority component is just inherit the scheme
    //       if defined(R.authority) then
    //          T.authority = R.authority;
    //          T.path      = remove_dot_segments(R.path);
    //          T.query     = R.query;
    if (HasServer())
        return;

    //No authority - inherit
    if (base.HasUserInfo())
    {
        m_userinfo = base.m_userinfo;
        m_fields |= wxURI_USERINFO;
    }

    m_server = base.m_server;
    m_hostType = base.m_hostType;
    m_fields |= wxURI_SERVER;

    if (base.HasPort())
    {
        m_port = base.m_port;
        m_fields |= wxURI_PORT;
    }


    // Simple path inheritance from base
    if (!HasPath())
    {
        //             T.path = Base.path;
        m_path = base.m_path;
        m_fields |= wxURI_PATH;


        //             if defined(R.query) then
        //                T.query = R.query;
        //             else
        //                T.query = Base.query;
        //             endif;
        if (!HasQuery())
        {
            m_query = base.m_query;
            m_fields |= wxURI_QUERY;
        }
    }
    else if ( m_path.empty() || m_path[0u] != '/' )
    {
        //             if (R.path starts-with "/") then
        //                T.path = remove_dot_segments(R.path);
        //             else
        //                T.path = merge(Base.path, R.path);
        //                T.path = remove_dot_segments(T.path);
        //             endif;
        //             T.query = R.query;
        //
        // So we don't do anything for absolute paths and implement merge for
        // the relative ones

        wxArrayString our(SplitInSegments(m_path)),
                      result(SplitInSegments(base.m_path));

        if ( !result.empty() )
            result.pop_back();

        if ( our.empty() )
        {
            // if we have an empty path it means we were constructed from a "."
            // string or something similar (e.g. "././././"), it should count
            // as (empty) segment
            our.push_back("");
        }

        const wxArrayString::const_iterator end = our.end();
        for ( wxArrayString::const_iterator i = our.begin(); i != end; ++i )
        {
            if ( i->empty() || *i == "." )
            {
                // as in ParsePath(), while normally we ignore the empty
                // segments, we need to take account of them at the end
                if ( i == end - 1 )
                    result.push_back("");
                continue;
            }

            if ( *i == ".." )
            {
                if ( !result.empty() )
                {
                    result.pop_back();

                    if ( i == end - 1 )
                        result.push_back("");
                }
                //else: just ignore, extra ".." don't accumulate
            }
            else
            {
                if ( result.empty() )
                {
                    // ensure that the resulting path will always be absolute
                    result.push_back("");
                }

                result.push_back(*i);
            }
        }

        m_path = wxJoin(result, '/', '\0');
    }

    //T.fragment = R.fragment;
}
Exemplo n.º 11
0
bool wxURI::operator==(const wxURI& uri) const
{
    if (HasScheme())
    {
        if(m_scheme != uri.m_scheme)
            return false;
    }
    else if (uri.HasScheme())
        return false;


    if (HasServer())
    {
        if (HasUserInfo())
        {
            if (m_userinfo != uri.m_userinfo)
                return false;
        }
        else if (uri.HasUserInfo())
            return false;

        if (m_server != uri.m_server ||
            m_hostType != uri.m_hostType)
            return false;

        if (HasPort())
        {
            if(m_port != uri.m_port)
                return false;
        }
        else if (uri.HasPort())
            return false;
    }
    else if (uri.HasServer())
        return false;


    if (HasPath())
    {
        if(m_path != uri.m_path)
            return false;
    }
    else if (uri.HasPath())
        return false;

    if (HasQuery())
    {
        if (m_query != uri.m_query)
            return false;
    }
    else if (uri.HasQuery())
        return false;

    if (HasFragment())
    {
        if (m_fragment != uri.m_fragment)
            return false;
    }
    else if (uri.HasFragment())
        return false;

    return true;
}
Exemplo n.º 12
0
// Return the closest point to our current position on our current path
// If "local" is true, only check the portion of the path surrounding m_pathIndex.
int CCSBot::FindOurPositionOnPath(Vector *close, bool local) const
{
	if (!HasPath())
		return -1;

	Vector along, toFeet;
	Vector feet(pev->origin.x, pev->origin.y, GetFeetZ());
	Vector eyes = feet + Vector(0, 0, HalfHumanHeight); // in case we're crouching
	Vector pos;
	const Vector *from, *to;
	real_t length;
	float closeLength;
	float closeDistSq = 9999999999.9;
	int closeIndex = -1;
	real_t distSq;

	int start, end;

	if (local)
	{
		start = m_pathIndex - 3;
		if (start < 1)
			start = 1;

		end = m_pathIndex + 3;
		if (end > m_pathLength)
			end = m_pathLength;
	}
	else
	{
		start = 1;
		end = m_pathLength;
	}

	for (int i = start; i < end; i++)
	{
		from = &m_path[i - 1].pos;
		to = &m_path[i].pos;

		// compute ray along this path segment
		along = *to - *from;

		// make it a unit vector along the path
		length = along.NormalizeInPlace();

		// compute vector from start of segment to our point
		toFeet = feet - *from;

		// find distance of closest point on ray
		closeLength = DotProduct(toFeet, along);

		// constrain point to be on path segment
		if (closeLength <= 0.0f)
			pos = *from;
		else if (closeLength >= length)
			pos = *to;
		else
			pos = *from + closeLength * along;

		distSq = (pos - feet).LengthSquared();

		// keep the closest point so far
		if (distSq < closeDistSq)
		{
			// don't use points we cant see
			Vector probe = pos + Vector(0, 0, HalfHumanHeight);
			if (!IsWalkableTraceLineClear(eyes, probe, WALK_THRU_EVERYTHING))
				continue;

			// don't use points we cant reach
			if (!IsStraightLinePathWalkable(&pos))
				continue;

			closeDistSq = distSq;
			if (close)
				*close = pos;

			closeIndex = i - 1;
		}
	}

	return closeIndex;
}
/** Constructs a CUri16 object from the input string.

Can leave if it cannot allocate memory for a CUri object.
The calling program must destroy the CUri16 object when it is no longer
needed.

@return pointer to CUri16 object
@param aUri descriptor to URI
@leave KErrBadName	if the input is invalid

*/
CUri16* TUriShortcutParser16::CreateUriL( const TDesC16& aUri ) const
{
    const TInt uriLen = aUri.Length();

    if ( uriLen == 0 || UriUtils::HasInvalidChars( aUri ) )
    {
        User::Leave( KErrBadName );
    }


    TPtrC16 scheme;
    TPtrC16 prefix;
    TPtrC16 tld;

    if ( !HasScheme( aUri ) )
    {
        if ( HasPath( aUri ) )
        {
            scheme.Set( DefaultScheme() );
        }
        else
        {

            if ( UriUtils::HostType( aUri ) != UriUtils::ETextHost )
            {
                scheme.Set( DefaultScheme() );
            }
            else
            {
                switch ( ComponentCount( aUri ) )
                {
                case 1:

                    if ( aUri.CompareF( KLocalhost ) != 0)
                    {
                        //add prefix, and tld
                        prefix.Set( KWww );
                        tld.Set( DefaultDomain() );
                    }
                //no break after this case

                case 2:
                    scheme.Set( DefaultScheme() );
                    break;

                case 3:
                default:
                    //it has a prefix
                    scheme.Set( MatchingScheme( aUri ) );
                    break;
                }
            }
        }
    }

    //Calculates the length of the buffer needed to construct the complete URI
    TInt bufLen = uriLen;

    if ( scheme.Length() > 0 )
    {
        bufLen += scheme.Length() + KSizeOfSchemeSeparator;
    }

    if ( prefix.Length() > 0 )
    {
        bufLen += prefix.Length() + 1;//dot separator
    }

    if ( tld.Length() > 0 )
    {
        bufLen += tld.Length() + 1;//dot separator
    }

    //This descriptor must be long enough to contain the entire URI.
    HBufC16* uriBuf = HBufC16::NewLC( bufLen );

    TPtr16 uriDes( uriBuf->Des() );

    //Copy the scheme and separator
    if ( scheme.Length() > 0 )
    {
        uriDes.Copy( scheme );
        uriDes.Append( KSchemeSeparator );
    }

    //Append the prefix and dot char
    if ( prefix.Length() > 0 )
    {
        uriDes.Append( prefix );
        uriDes.Append( KSeparatorDot );
    }

    //Appends user supplied string here
    uriDes.Append( aUri );

    //Finally appends the domain
    if ( tld.Length() > 0 )
    {
        uriDes.Append( KSeparatorDot );
        uriDes.Append( tld );
    }

    //Constructs the CUri object
    TUriParser16 uriParser;
    User::LeaveIfError( uriParser.Parse( uriDes ) );

    CUri16* uri = CUri16::NewL( uriParser );

    CleanupStack::PopAndDestroy( uriBuf );

    return uri;
}
Exemplo n.º 14
0
void wxURI::Resolve(const wxURI& base, int flags)
{
    wxASSERT_MSG(!base.IsReference(),
                wxT("wxURI to inherit from must not be a reference!"));

    // If we arn't being strict, enable the older (pre-RFC2396)
    // loophole that allows this uri to inherit other
    // properties from the base uri - even if the scheme
    // is defined
    if ( !(flags & wxURI_STRICT) &&
            HasScheme() && base.HasScheme() &&
                m_scheme == base.m_scheme )
    {
        m_fields -= wxURI_SCHEME;
    }


    // Do nothing if this is an absolute wxURI
    //    if defined(R.scheme) then
    //       T.scheme    = R.scheme;
    //       T.authority = R.authority;
    //       T.path      = remove_dot_segments(R.path);
    //       T.query     = R.query;
    if (HasScheme())
    {
        return;
    }

    //No scheme - inherit
    m_scheme = base.m_scheme;
    m_fields |= wxURI_SCHEME;

    // All we need to do for relative URIs with an
    // authority component is just inherit the scheme
    //       if defined(R.authority) then
    //          T.authority = R.authority;
    //          T.path      = remove_dot_segments(R.path);
    //          T.query     = R.query;
    if (HasServer())
    {
        return;
    }

    //No authority - inherit
    if (base.HasUserInfo())
    {
        m_userinfo = base.m_userinfo;
        m_fields |= wxURI_USERINFO;
    }

    m_server = base.m_server;
    m_hostType = base.m_hostType;
    m_fields |= wxURI_SERVER;

    if (base.HasPort())
    {
        m_port = base.m_port;
        m_fields |= wxURI_PORT;
    }


    // Simple path inheritance from base
    if (!HasPath())
    {
        //             T.path = Base.path;
        m_path = base.m_path;
        m_fields |= wxURI_PATH;


        //             if defined(R.query) then
        //                T.query = R.query;
        //             else
        //                T.query = Base.query;
        //             endif;
        if (!HasQuery())
        {
            m_query = base.m_query;
            m_fields |= wxURI_QUERY;
        }
    }
    else
    {
        //             if (R.path starts-with "/") then
        //                T.path = remove_dot_segments(R.path);
        //             else
        //                T.path = merge(Base.path, R.path);
        //                T.path = remove_dot_segments(T.path);
        //             endif;
        //             T.query = R.query;
        if (m_path.empty() || m_path[0u] != wxT('/'))
        {
            //Merge paths
            const wxChar* op = m_path.c_str();
            const wxChar* bp = base.m_path.c_str() + base.m_path.Length();

            //not a ending directory?  move up
            if (base.m_path[0] && *(bp-1) != wxT('/'))
                UpTree(base.m_path, bp);

            //normalize directories
            while(*op == wxT('.') && *(op+1) == wxT('.') &&
                       (*(op+2) == '\0' || *(op+2) == wxT('/')) )
            {
                UpTree(base.m_path, bp);

                if (*(op+2) == '\0')
                    op += 2;
                else
                    op += 3;
            }

            m_path = base.m_path.substr(0, bp - base.m_path.c_str()) +
                    m_path.substr((op - m_path.c_str()), m_path.Length());
        }
    }

    //T.fragment = R.fragment;
}