Probably something very simple, but having problems. C++/BP Array problem

I need a function that takes a path array (Basically, just a list of master tile indices to get from point A to point B) and removes all the tiles that are not at intersections. (Also removing dead-end tiles)

I’ve got another function that takes my array from BP and fills it with the list of tiles along the path. This works great. But I don’t need (or want) the intermediate tiles between the intersections as this list is strictly for navigation.

I have a function I had already created that makes a master list of all intersecting tiles which works just fine. I figured I could use the same logic in this function to create another array of tiles from a path array that it was fed, then copy that new list back to the source array, but I’m having a hard time getting this to work. The function is called okay, but I still have a full path array instead of a stripped down version.

These are the two functions that I have for the intersections. The first one builds a master list of intersecting tiles. And the second one is the function I’m trying to write to give me a path of only the intersection (or turning) tiles:


void ALabyrinth::FindAllIntersections()
{
	for (int32 i = 0; i < Tiles.Num(); i++)
	{
		int32 da = Tiles*.directionsAvailable;
		if ((da != NORTH) && (da != SOUTH) && (da != EAST) && (da != WEST) && (da != NORTH + SOUTH) && (da != EAST + WEST))
		{
			IntersectionArray.Add(i);
		}
	}
}

void ALabyrinth::RemoveNonIntersectionsInPath(TArray<int32> pathArray)
{
	TArray<int32> newPathArray;
	newPathArray.Empty();

	for (int32 i = 0; i < pathArray.Num(); i++)
	{
		int32 da = Tiles[pathArray*].directionsAvailable;
		if ((da != NORTH) && (da != SOUTH) && (da != EAST) && (da != WEST) && (da != NORTH + SOUTH) && (da != EAST + WEST))
		{
			newPathArray.Add(pathArray*);
		}
	}
	pathArray = newPathArray;
}


I’m sure I’m doing something stupid here. But I figured I’d for-loop through the int32 array of path tiles, check the tile against my master tile list and get the directions available to that tile.
If it’s not a dead end, or a straight through tile, I’ll add it to a temporary array. Then, finally, copy that new array to the array that was passed to the function. But I’m left with the exact same array I had before I went into the function.

I’m sure I’m overlooking something so obvious that it’s screaming into my face, but right now I cannot figure it out. I’m not that great with working with arrays and BP/C++ interfacing together, so I’m sure that’s where my problem lies, but I’m stuck on this one. I’ve tried things so many different ways that I’m calling for another set of eyes to help me out.

Thanks!

P.S. Just for completeness, this is how I’m using the node in BP:

As a workaround for now, I’ve added the code above–removing the parts that check for dead ends–directly to my Generate Path function since the path (by it’s very nature) doesn’t have to worry about dead ends, and this seems to give me an intersection/turn only path. I’m still going to come back and try to get this other function working properly because I still may have some uses for it, but its importance has gone way down.

A small sample of what I’m talking about with the FindPath function:


bool ALabyrinth::FindPath(int32 Tile, int32 endingTile, int32 enteredFrom, TArray<int32> &pathTiles)
{
	if (Tile == endingTile) return true;

	int32 da = Tiles[Tile].directionsAvailable;

	// see if NORTH is available and go there
	if ((Tiles[Tile].directionsAvailable & NORTH) && (enteredFrom != NORTH) && FindPath(Tile - sizeX, endingTile,  SOUTH, pathTiles))
	{
		if ((da != NORTH + SOUTH) && (da != EAST + WEST))
			pathTiles.Add(Tile);
		return true;
	}