/**
 * Finds a child property node from the provided parent node (does not recurse into grandchildren)
 *
 * @param InParentNode	The parent node to locate the child from
 * @param PropertyName	The property name to find
 * @param Index			The index of the property if its in an array
 */
static TSharedPtr<FPropertyNode> FindChildPropertyNode( FPropertyNode& InParentNode, const FString& PropertyName, int32 Index )
{
	TSharedPtr<FPropertyNode> FoundNode(NULL);

	// search each child for a property with the provided name
	for( int32 ChildIndex = 0; ChildIndex < InParentNode.GetNumChildNodes(); ++ChildIndex )
	{
		TSharedPtr<FPropertyNode>& ChildNode = InParentNode.GetChildNode(ChildIndex);
		UProperty* Property = ChildNode->GetProperty();
		if( Property && Property->GetFName() == *PropertyName )
		{
			FoundNode = ChildNode;
			break;
		}
	}

	// Find the array element.
	if( FoundNode.IsValid() && Index != INDEX_NONE )
	{
		// The found node is the top array so get its child which is the actual node
		FoundNode = FoundNode->GetChildNode( Index );
	}

	return FoundNode;
}
static void
ScanConflicts(char *path, unsigned inx, int argc, char **argv)
{
    DIR *dp;
    struct dirent *de;
    struct stat sb;
    int j;
    unsigned k;
#if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX
    char save_wd[MAXPATHLEN];
#endif

    /*
     * When scanning a directory, we first chdir to it, mostly to make
     * the scan+stat work faster, but also because some systems don't
     * scan properly otherwise.
     *
     * MSDOS and OS/2 are a little more complicated, because each drive
     * has its own current directory.
     */
#if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX
    (void) strcpy(save_wd, dot);
    if (!strcmp(".", path)) {
	path = dot;
    } else if (!same_drive(dot, path)) {
	if (!set_drive(path))
	    return;
	getwd(save_wd);
    }
#endif
    if (v_opt > 2)
	printf("ScanConflicts \"%s\"\n", path);

    if (set_directory(path)
	&& (dp = opendir(path)) != NULL) {

	while ((de = readdir(dp)) != NULL) {
	    register
	    type_t ok = 0;
	    int found = FALSE;
	    char buffer[MAXPATHLEN];
	    char *the_name;
	    char *the_NAME;

	    if (do_blips)
		blip('.');

	    (void) sprintf(buffer, "%.*s", (int) NAMLEN(de), de->d_name);
	    the_name = MakeString(DOS_upper(buffer));
	    the_NAME = ToCompare(the_name);

	    /* If arguments are given, restrict search to them */
	    if (argc > optind) {
		for (j = optind; j < argc; j++) {
		    if (SameName(argv[j], the_name)) {
			found = TRUE;
			break;
		    }
		}
		if (!found)
		    continue;
	    }

	    /* Verify that the name is a file, and executable */
	    if (stat(the_name, &sb) < 0)
		continue;
	    if ((sb.st_mode & S_IFMT) != S_IFREG)
		continue;

#if SYS_UNIX || SYS_OS2 || SYS_OS2_EMX
	    if (access(the_name, acc_mask) < 0)
		continue;
	    ok = 1;
#endif
	    if (FileTypes != 0) {
		if ((ok = LookupType(the_name)) == 0)
		    continue;
	    }

	    /* Find the name in our array of all names */
	    found = FALSE;
	    for (k = 0; k < total; k++) {
		if (SameName(inpath[k].ip_NAME, the_NAME)) {
		    FoundNode(&inpath[k], inx);
		    found = TRUE;
		    break;
		}
	    }

	    /* If not there, add it */
	    if (found) {
		if (the_NAME != the_name) {
		    FreeString(the_NAME);
		}
	    } else {
		if (!(total & CHUNK)) {
		    size_t need = (((total * 3) / 2) | CHUNK) + 1;
		    if (inpath != 0)
			inpath = TypeRealloc(INPATH, inpath, need);
		    else
			inpath = TypeAlloc(INPATH, need);
		}
		j = (int) total++;
		inpath[j].ip_name = the_name;
		inpath[j].ip_NAME = the_NAME;
		inpath[j].node = TypeAlloc(NODE, path_len);
		FoundNode(&inpath[j], inx);
	    }
	    if (v_opt > 2) {
		(void) printf("%c %s%c%s\n",
			      found ? '+' : '*',
			      path, PATHNAME_SEP, buffer);
	    }
	}
	(void) closedir(dp);
    }
#if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX
    if (strcmp(dot, save_wd)) {
	chdir(save_wd);
    }
#endif
    (void) set_directory(dot);
}
Beispiel #3
0
std::deque<Point> AStar::Search(const AStarDef &def)
{
	std::deque<Point> search_path;
	if (ValidAStarDef(def))
	{
		Init(def);

		std::vector<Point> around_point;
		around_point.reserve(def.allow_corner ? 8 : 4);

		Node *start_node = new Node(def.start_point);
		open_list_.push_back(start_node);

		Node *&node_ptr = maps_index_[start_node->pos.row * num_row_ + start_node->pos.col];
		assert(node_ptr == nullptr);
		node_ptr = start_node;
		node_ptr->state = IN_OPENLIST;

		while (!open_list_.empty())
		{
			Node *current_point = open_list_[0];
			std::pop_heap(open_list_.begin(), open_list_.end(), CompHeap);
			open_list_.pop_back();
			maps_index_[current_point->pos.row * num_row_ + current_point->pos.col]->state = IN_CLOSELIST;

			SearchCanReached(current_point->pos, def.allow_corner, around_point);

			unsigned int size = around_point.size();
			for (unsigned int index = 0; index < size; ++index)
			{
				Node *new_point = IsExistInOpenList(around_point[index]);
				if (new_point)
				{
					FoundNode(current_point, new_point);
				}
				else
				{
					new_point = new Node(around_point[index]);
					NotFoundNode(current_point, new_point, def.end_point);

					if (around_point[index] == def.end_point)
					{
						while (new_point->parent)
						{
							search_path.push_front(new_point->pos);
							new_point = new_point->parent;
						}
						goto end_search;
					}
				}
			}
		}

	end_search:
		Clear();
	}
	else
	{
		Clear();
		assert("Invalid AStarDef!");
	}

	return search_path;
}