void portal::SeekEndRoom( entityid p_room )
{
    BeginPath();
    while( IsValidPath() )
    {
        // exit out when you find a match
        if( CurrentEnd() == p_room )
            return;
        NextPath();
    }
}
/**
	Checks the Uri to be valid. 
	If there is no valid Host, Port, userinfo, Path, Query or Fragment then the 
	return value indicates an appropriate invalid Component. else returns zero, 
	which indicates given uri is valid.

	@return whether the Uri is Valid by returning zero or appropriate error value 
			for Invalid Uri.
 */
TInt TValidatorBase::Validate()
	{
	if (!IsValidHost())
		{
		return KUriUtilsErrInvalidHost;
		}
	
	if (!IsValidPort())
		{
		return KUriUtilsErrInvalidPort;
		}
		
	if (!IsValidUserInfo())
		{
		return KUriUtilsErrInvalidUserInfo;
		}
	
	if (!IsValidPath())
		{
		return KUriUtilsErrInvalidParam;
		}
	
	if (!IsValidQuery())
		{
		return KUriUtilsErrInvalidHeaders;
		}
	
	if (!IsValidFragment())
		{
		return KUriUtilsErrInvalidFragment;
		}
	
	return KErrNone;
	}
Beispiel #3
0
	void Workspace::UnLoad(const char* relativePath)
	{
		BEHAVIAC_ASSERT(behaviac::StringUtils::FindExtension(relativePath) == 0, "no extention to specify");
		BEHAVIAC_ASSERT(IsValidPath(relativePath));

		BehaviorTrees_t::iterator it = ms_behaviortrees.find(relativePath);
		if (it != ms_behaviortrees.end())
		{
			BehaviorTree* bt = it->second;
			BEHAVIAC_DELETE(bt);
			ms_behaviortrees.erase(it);
		}
	}
Beispiel #4
0
//--------------------------------------------------------------------------------------------------
void App::AddImportedFile
(
    FileMapping&& mapping
)
//--------------------------------------------------------------------------------------------------
{
    if (!IsValidPath(mapping.m_DestPath))
    {
        throw Exception("'" + mapping.m_DestPath + "' is not a valid path.");
    }
    if (!IsAbsolutePath(mapping.m_DestPath))
    {
        throw Exception("Imported file system objects must be mapped to an absolute path ('"
                        + mapping.m_DestPath + "' is not).");
    }
    if (!IsValidPath(mapping.m_SourcePath))
    {
        throw Exception("'" + mapping.m_SourcePath + "' is not a valid path.");
    }

    m_ImportedFiles.push_back(mapping);
}
Beispiel #5
0
BOOL 
IsValidPathResult(
    HRESULT hr, 
    LPCTSTR pcszPath,
    UINT cchPathBufLen)
{
    return((hr == S_OK &&
            EVAL(IsValidPath(pcszPath)) &&
            EVAL((UINT)lstrlen(pcszPath) < cchPathBufLen)) ||
           (hr != S_OK &&
            EVAL(! cchPathBufLen ||
                 ! pcszPath ||
                 ! *pcszPath)));
}
FReply FDirectoryPathStructCustomization::OnPickDirectory(TSharedRef<IPropertyHandle> PropertyHandle, const bool bRelativeToGameContentDir, const bool bUseRelativePath, const bool bLongPackageName) const
{
	FString Directory;
	IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
	if (DesktopPlatform)
	{

		TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(BrowseButton.ToSharedRef());
		void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) ? ParentWindow->GetNativeWindow()->GetOSWindowHandle() : nullptr;

		FString StartDirectory = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT);
		if (bRelativeToGameContentDir && !IsValidPath(StartDirectory, bRelativeToGameContentDir))
		{
			StartDirectory = AbsoluteGameContentDir;
		}

		// Loop until; a) the user cancels (OpenDirectoryDialog returns false), or, b) the chosen path is valid (IsValidPath returns true)
		for (;;)
		{
			if (DesktopPlatform->OpenDirectoryDialog(ParentWindowHandle, LOCTEXT("FolderDialogTitle", "Choose a directory").ToString(), StartDirectory, Directory))
			{
				FText FailureReason;
				if (IsValidPath(Directory, bRelativeToGameContentDir, &FailureReason))
				{
					FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, Directory);

					if (bLongPackageName)
					{
						FString LongPackageName;
						FString StringFailureReason;
						if (FPackageName::TryConvertFilenameToLongPackageName(Directory, LongPackageName, &StringFailureReason) == false)
						{
							StartDirectory = Directory;
							FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(StringFailureReason));
							continue;
						}
						Directory = LongPackageName;
					}

					if (bRelativeToGameContentDir)
					{
						Directory = Directory.RightChop(AbsoluteGameContentDir.Len());
					}

					if (bUseRelativePath)
					{
						Directory = IFileManager::Get().ConvertToRelativePath(*Directory);
					}

					PropertyHandle->SetValue(Directory);
				}
				else
				{
					StartDirectory = Directory;
					FMessageDialog::Open(EAppMsgType::Ok, FailureReason);
					continue;
				}
			}
			break;
		}
	}

	return FReply::Handled();
}
Beispiel #7
0
BOOL CDirTreeCtrl::SetSelPath(LPCTSTR strPath)
{
	// Setting the Selection in the Tree
	HTREEITEM hParent  = TVI_ROOT;
	int       iLen    = _tcslen(strPath) + 2;
	TCHAR*     pszPath = new TCHAR[iLen];
	TCHAR*     pPath   = pszPath;
	BOOL      bRet    = FALSE;
    
	if ( !IsValidPath( strPath ) )
	{
		delete [] pszPath; // this must be added 29.03.99
		return FALSE;
	}
		
	_tcscpy( pszPath, strPath );
	_tcsupr( pszPath );
	
	if ( pszPath[_tcslen(pszPath)-1] != '\\' )
		_tcscat( pszPath, _T("\\") );
    
	int iLen2 = _tcslen( pszPath );
	
	for (WORD i = 0; i < iLen2; i++ )
	{
		if ( pszPath[i] == '\\' )
		{
			SetRedraw( FALSE );
			pszPath[i] = '\0';
			hParent = SearchSiblingItem( hParent, pPath );
			if ( !hParent )  // Not found!
				break;
			else
			{				
				// Info:
				// the notification OnItemExpanded 
				// will not called every time 
				// after the call Expand. 
				// You must call Expand with TVE_COLLAPSE | TVE_COLLAPSERESET
				// to Reset the TVIS_EXPANDEDONCE Flag
				
				UINT uState;
				uState = GetItemState( hParent, TVIS_EXPANDEDONCE );
				if ( uState )
				{
					Expand( hParent, TVE_EXPAND );
					Expand( hParent, TVE_COLLAPSE | TVE_COLLAPSERESET );
					InsertItem(_T(""), hParent ); // insert a blank child-item
					Expand( hParent, TVE_EXPAND ); // now, expand send a notification
				}
				else
					Expand( hParent, TVE_EXPAND );
			}
			pPath += _tcslen(pPath) + 1;
		}
	}

	delete [] pszPath;
	
	if ( hParent ) // Ok the last subpath was found
	{		
		SelectItem( hParent ); // select the last expanded item
		bRet = TRUE;
	}
	else
	{
		bRet = FALSE;
	}
	
	SetRedraw( TRUE );

    return bRet;
}
Beispiel #8
0
    BehaviorTreeTask* Workspace::CreateBehaviorTreeTask(const char* relativePath)
    {
        BEHAVIAC_ASSERT(behaviac::StringUtils::FindExtension(relativePath) == 0, "no extention to specify");
        BEHAVIAC_ASSERT(IsValidPath(relativePath));

        BehaviorTrees_t::iterator it = m_behaviortrees.find(relativePath);
        const BehaviorTree* bt = 0;

        if (it != m_behaviortrees.end())
        {
            bt = it->second;
        }
        else
        {
            bool bOk = (Workspace::Load(relativePath));

            if (bOk)
            {
                BehaviorTrees_t::iterator it1 = m_behaviortrees.find(relativePath);

                if (it1 != m_behaviortrees.end())
                {
                    bt = it1->second;
                }
            }
        }

        if (bt)
        {
            BehaviorTask* task = bt->CreateAndInitTask();

            BEHAVIAC_ASSERT(BehaviorTreeTask::DynamicCast(task));
            BehaviorTreeTask* behaviorTreeTask = (BehaviorTreeTask*)task;

#if BEHAVIAC_ENABLE_HOTRELOAD
			if (behaviac::Config::IsHotReload())
			{
				if (!m_allBehaviorTreeTasks)
				{
					m_allBehaviorTreeTasks = BEHAVIAC_NEW AllBehaviorTreeTasks_t;
				}

				AllBehaviorTreeTasks_t::iterator it1 = m_allBehaviorTreeTasks->find(relativePath);

				if (it1 == m_allBehaviorTreeTasks->end())
				{
					(*m_allBehaviorTreeTasks)[relativePath] = BTItem_t();
				}

				BTItem_t& btItems = (*m_allBehaviorTreeTasks)[relativePath];

				bool isAdded = false;

				for (uint32_t i = 0; i < btItems.bts.size(); ++i)
				{
					if (btItems.bts[i] == behaviorTreeTask)
					{
						isAdded = true;
						break;
					}
				}

				if (!isAdded)
				{
					btItems.bts.push_back(behaviorTreeTask);
				}
			}
#endif//BEHAVIAC_ENABLE_HOTRELOAD

            return behaviorTreeTask;
        }

        return 0;
    }
Beispiel #9
0
    bool Workspace::Load(const char* relativePath, bool bForce)
    {
        bool bOk = this->TryInit();
		if (!bOk)
		{
			//not init correctly
			return false;
		}

        //BEHAVIAC_ASSERT(behaviac::StringUtils::FindExtension(relativePath) == 0, "no extention to specify");
        BEHAVIAC_ASSERT(IsValidPath(relativePath));

        BehaviorTree* pBT = 0;
        BehaviorTrees_t::iterator it = m_behaviortrees.find(relativePath);

        if (it != m_behaviortrees.end())
        {
            if (!bForce)
            {
                return true;
            }

            pBT = it->second;
        }

        behaviac::string fullPath = StringUtils::CombineDir(this->GetFilePath(), relativePath);

        Workspace::EFileFormat f = this->GetFileFormat();

        switch (f)
        {
            case EFF_default:
            {
                // try to load the behavior in xml
                behaviac::string path = fullPath + ".xml";

                if (behaviac::CFileManager::GetInstance()->FileExists(path.c_str()))
                {
                    f = EFF_xml;
                    fullPath = path;
                }
                else
                {
                    // try to load the behavior in bson
                    path = fullPath + ".bson.bytes";

                    if (behaviac::CFileManager::GetInstance()->FileExists(path.c_str()))
                    {
                        f = EFF_bson;
                        fullPath = path;
                    }
                    // try to load the behavior in cpp
                    else
                    {
                        f = EFF_cpp;
                    }
                }
            }
            break;

            case EFF_xml:
                fullPath += ".xml";
                break;

            case EFF_bson:
                fullPath += ".bson.bytes";
                break;

            case EFF_cpp:
                break;

            default:
                BEHAVIAC_ASSERT(0);
                break;
        }

        bool bLoadResult = false;
        bool bNewly = false;

        if (!pBT)
        {
            //in case of circular referencebehavior
            bNewly = true;
            pBT = BEHAVIAC_NEW BehaviorTree();
            m_behaviortrees[relativePath] = pBT;
        }

        BEHAVIAC_ASSERT(pBT);

        bool bCleared = false;

        if (f == EFF_xml || f == EFF_bson)
        {
            char* pBuffer = ReadFileToBuffer(fullPath.c_str());

            if (pBuffer)
            {
                //if forced to reload
                if (!bNewly)
                {
                    bCleared = true;
                    pBT->Clear();
                }

                if (f == EFF_xml)
                {
                    bLoadResult = pBT->load_xml(pBuffer);
                }
                else
                {
                    bLoadResult = pBT->load_bson(pBuffer);
                }

                PopFileFromBuffer(pBuffer);
            }
            else
            {
                BEHAVIAC_LOGERROR("'%s' doesn't exist!, Please check the file name or override Workspace and its GetFilePath()\n", fullPath.c_str());
                BEHAVIAC_ASSERT(false);
            }
        }
        else if (f == EFF_cpp)
        {
            if (!bNewly)
            {
                bCleared = true;
                pBT->Clear();
            }

            if (m_behaviortreeCreators && m_behaviortreeCreators->find(relativePath) != m_behaviortreeCreators->end())
            {
                BehaviorTreeCreator_t btCreator = (*m_behaviortreeCreators)[relativePath];
                bLoadResult = (*btCreator)(pBT);
            }
            else
            {
                BEHAVIAC_ASSERT(0);
                BEHAVIAC_LOGWARNING("The behaviac_generated/behaviors/generated_behaviors.h should be included by one of your apps.");
            }
        }
        else
        {
            BEHAVIAC_ASSERT(0);
        }

        if (bLoadResult)
        {
            BEHAVIAC_ASSERT(pBT->GetName() == relativePath);

            if (!bNewly)
            {
                BEHAVIAC_ASSERT(m_behaviortrees[pBT->GetName()] == pBT);
            }
        }
        else
        {
            if (bNewly)
            {
                //if it is forced to reload
                m_behaviortrees.erase(relativePath);

                BEHAVIAC_DELETE(pBT);
            }
            else if (bCleared)
            {
                //it has been cleared but failed to load, to remove it
                m_behaviortrees.erase(relativePath);
            }

            BEHAVIAC_LOGWARNING("'%s' is not loaded!\n", fullPath.c_str());
        }

        return bLoadResult;
    }
Beispiel #10
0
	bool Workspace::Load(const char* relativePath, bool bForce)
	{
		BEHAVIAC_ASSERT(behaviac::StringUtils::FindExtension(relativePath) == 0, "no extention to specify");
		BEHAVIAC_ASSERT(IsValidPath(relativePath));

		BehaviorTree* pBT = 0;
		BehaviorTrees_t::iterator it = ms_behaviortrees.find(relativePath);
		if (it != ms_behaviortrees.end())
		{
			if (!bForce) {
				return true;
			}
			pBT = it->second;
		}

		behaviac::string fullPath = ms_workspace_export_path;
		fullPath += relativePath;

		Workspace::EFileFormat f = Workspace::GetFileFormat();
		switch (f)
		{
			case EFF_default:
				{
					// try to load the behavior in xml
					behaviac::string path = fullPath + ".xml";
					if (CFileManager::GetInstance()->FileExists(path.c_str()))
					{
						f = EFF_xml;
						fullPath = path;
					}
					else
					{
						// try to load the behavior in bson
						path = fullPath + ".bson.bytes";
						if (CFileManager::GetInstance()->FileExists(path.c_str()))
						{
							f = EFF_bson;
							fullPath = path;
						}
						// try to load the behavior in cpp
						else
						{
							f = EFF_cpp;
						}
					}
				}
				break;

			case EFF_xml:
				fullPath += ".xml";
				break;

			case EFF_bson:
				fullPath += ".bson.bytes";
				break;

			case EFF_cpp:
				break;

			default:
				BEHAVIAC_ASSERT(0);
				break;
		}

		bool bLoadResult = false;
		bool bNewly = false;
		if (!pBT) {
			//in case of circular referencebehavior
			bNewly = true;
			pBT = BEHAVIAC_NEW BehaviorTree();
			ms_behaviortrees[relativePath] = pBT;
		}

		BEHAVIAC_ASSERT(pBT);

		bool bCleared = false;

		if (f == EFF_xml || f == EFF_bson)
		{
			char* pBuffer = ReadFileToBuffer(fullPath.c_str());
			if (pBuffer) {
				//if forced to reload
				if (!bNewly) {
					bCleared = true;
					pBT->Clear();
				}

				if (f == EFF_xml) {
					bLoadResult = pBT->load_xml(pBuffer);
				}
				else {
					bLoadResult = pBT->load_bson(pBuffer);
				}

				PopFileFromBuffer(pBuffer);
			}
			else {
				BEHAVIAC_LOGWARNING("Workspace::Load:FileNotOpen %s", fullPath.c_str());
			}
		}
		else if (f == EFF_cpp)
		{
			if (!bNewly) {
				bCleared = true;
				pBT->Clear();
			}

			if (ms_behaviortreeCreators && ms_behaviortreeCreators->find(relativePath) != ms_behaviortreeCreators->end())
			{
				BehaviorTreeCreator_t btCreator = (*ms_behaviortreeCreators)[relativePath];
				bLoadResult = (*btCreator)(pBT);
			}
			else {
				BEHAVIAC_ASSERT(0);
				BEHAVIAC_LOGWARNING("The generated_behaviors.cpp file should be included by the app.");
			}
		}
		else
		{
			BEHAVIAC_ASSERT(0);
		}

		if (bLoadResult) {
			BEHAVIAC_ASSERT(pBT->GetName() == relativePath);
			if (!bNewly) {
				BEHAVIAC_ASSERT(ms_behaviortrees[pBT->GetName()] == pBT);
			}
		}
		else {
			if (bNewly) {
				//if it is forced to reload
				ms_behaviortrees.erase(relativePath);

				BEHAVIAC_DELETE(pBT);
			}
			else if (bCleared) {
				//it has been cleared but failed to load, to remove it
				ms_behaviortrees.erase(relativePath);
			}

			BEHAVIAC_LOGWARNING("BehaviorTree %s not loaded!\n", fullPath.c_str());
		}

		return bLoadResult;
	}