src/game/Editor/Smoothing_Utils.cc
UINT16 SearchForWallType( UINT32 iMapIndex )
{
	LEVELNODE *pWall;
	INT16 sOffset;
	INT16 x, y, sRadius = 0;
	if( gfBasement )
	{
		UINT16 usWallType;
		usWallType = GetRandomIndexByRange( FIRSTWALL, LASTWALL );
		if( usWallType == 0xffff )
			usWallType = FIRSTWALL;
		return usWallType;
	}
	while( sRadius < 32 )
	{
		//NOTE:  start at the higher y value and go negative because it is possible to have another
		// structure type one tile north, but not one tile south -- so it'll find the correct wall first.
		for( y = sRadius; y >= -sRadius; y-- ) for( x = -sRadius; x <= sRadius; x++ )
		{
			if (ABS(x) == sRadius || ABS(y) == sRadius)
			{
				sOffset = y * WORLD_COLS + x;
				if( !GridNoOnVisibleWorldTile( (INT16)(iMapIndex + sOffset) ) )
				{
					continue;
				}
				pWall = gpWorldLevelData[ iMapIndex + sOffset ].pStructHead;
				while( pWall )
				{
					const UINT32 uiTileType = GetTileType(pWall->usIndex);
					if( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL )
					{	//found a roof, so return its type.
						return (UINT16)uiTileType;
					}
					//if( uiTileType >= FIRSTWINDOW && uiTileType <= LASTWINDOW )
					//{	//Window types can be converted to a wall type.
					//	return (UINT16)(FIRSTWALL + uiTileType - FIRSTWINDOW );
					//}
					pWall = pWall->pNext;
				}
			}
		}
		sRadius++;
	}
	return 0xffff;
}
//This method isn't foolproof, but because erasing large areas of buildings could result in
//multiple wall types for each building.  When processing the region, it is necessary to
//calculate the roof type by searching for the nearest roof tile.
This method isn't foolproof, but because erasing large areas of buildings could result in
multiple wall types for each building.  When processing the region, it is necessary to
calculate the roof type by searching for the nearest roof tile.
This method isn ' t foolproof but because erasing large areas of buildings could result in multiple wall types for each building . When processing the region it is necessary to calculate the roof type by searching for the nearest roof tile .
UINT16 SearchForWallType( UINT32 iMapIndex )
{
	LEVELNODE *pWall;
	INT16 sOffset;
	INT16 x, y, sRadius = 0;
	if( gfBasement )
	{
		UINT16 usWallType;
		usWallType = GetRandomIndexByRange( FIRSTWALL, LASTWALL );
		if( usWallType == 0xffff )
			usWallType = FIRSTWALL;
		return usWallType;
	}
	while( sRadius < 32 )
	{
		for( y = sRadius; y >= -sRadius; y-- ) for( x = -sRadius; x <= sRadius; x++ )
		{
			if (ABS(x) == sRadius || ABS(y) == sRadius)
			{
				sOffset = y * WORLD_COLS + x;
				if( !GridNoOnVisibleWorldTile( (INT16)(iMapIndex + sOffset) ) )
				{
					continue;
				}
				pWall = gpWorldLevelData[ iMapIndex + sOffset ].pStructHead;
				while( pWall )
				{
					const UINT32 uiTileType = GetTileType(pWall->usIndex);
					if( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL )
					{	
						return (UINT16)uiTileType;
					}
					pWall = pWall->pNext;
				}
			}
		}
		sRadius++;
	}
	return 0xffff;
}
UINT16 SearchForWallType ( UINT32 iMapIndex ) { LEVELNODE * pWall ; INT16 sOffset ; INT16 x , y , sRadius = 0 ; if ( gfBasement ) { UINT16 usWallType ; usWallType = GetRandomIndexByRange ( FIRSTWALL , LASTWALL ) ; if ( usWallType == 0xffff ) usWallType = FIRSTWALL ; return usWallType ; } while ( sRadius < 32 ) { for ( y = sRadius ; y >= - sRadius ; y -- ) for ( x = - sRadius ; x <= sRadius ; x ++ ) { if ( ABS ( x ) == sRadius || ABS ( y ) == sRadius ) { sOffset = y * WORLD_COLS + x ; if ( ! GridNoOnVisibleWorldTile ( ( INT16 ) ( iMapIndex + sOffset ) ) ) { continue ; } pWall = gpWorldLevelData [ iMapIndex + sOffset ] . pStructHead ; while ( pWall ) { const UINT32 uiTileType = GetTileType ( pWall -> usIndex ) ; if ( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL ) { return ( UINT16 ) uiTileType ; } pWall = pWall -> pNext ; } } } sRadius ++ ; } return 0xffff ; }
This method isn't foolproof, but because erasing large areas of buildings could result in
multiple wall types for each building.
This method isn ' t foolproof but because erasing large areas of buildings could result in multiple wall types for each building .
//NOTE:  start at the higher y value and go negative because it is possible to have another // structure type one tile north, but not one tile south -- so it'll find the correct wall first. //found a roof, so return its type. //if( uiTileType >= FIRSTWINDOW && uiTileType <= LASTWINDOW ) //{	//Window types can be converted to a wall type. //	return (UINT16)(FIRSTWALL + uiTileType - FIRSTWINDOW ); //}