Beispiel #1
0
bool CRegionBase::RealizeRegion()
{
	ADDTOCALLSTACK("CRegionBase::RealizeRegion");
	// Link the region to the world. RETURN: false = not valid.
	if ( IsRegionEmpty() )
		return false;
	if ( !m_pt.IsValidPoint() )
		m_pt = GetRegionCorner( DIR_QTY );	// center

	// Attach to all sectors that i overlap.
	ASSERT( m_iLinkedSectors == 0 );
	for ( long l = 0; l < g_MapList.GetSectorQty(m_pt.m_map); l++ )
	{
		CSector *pSector = g_World.GetSector(m_pt.m_map, l);

		if ( pSector && IsOverlapped(pSector->GetRect()) )
		{
			//	Yes, this sector overlapped, so add it to the sector list
			if ( !pSector->LinkRegion(this) )
			{
				g_Log.EventError("Linking sector #%ld for map %d for region %s failed (fatal for this region).\n", l, m_pt.m_map, GetName());
				return false;
			}
			m_iLinkedSectors++;
		}
	}
	return true;
}
Beispiel #2
0
size_t CGRegion::GetRegionRectCount() const
{
	ADDTOCALLSTACK("CGRegion::GetRegionRectCount");
	// How many rectangles in this region ?
	size_t iQty = m_Rects.GetCount();
	if ( iQty <= 0 )
	{
		if ( ! IsRegionEmpty())
			return 1;
	}
	return( iQty );
}
Beispiel #3
0
bool CGRegion::AddRegionRect( const CGRect & rect )
{
	ADDTOCALLSTACK("CGRegion::AddRegionRect");
	if ( rect.IsRectEmpty() )
		return false;

	size_t iQty = m_Rects.GetCount();
	if ( iQty <= 0 && IsRegionEmpty())
	{
		m_rectUnion = rect;
	}
	else
	{
		if ( rect.m_map != m_rectUnion.m_map )
		{
			g_Log.Event(LOGL_ERROR, "Adding rect [%d,%d,%d,%d,%d] to region with different map (%d)\n",
				rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rect.m_map, m_rectUnion.m_map);
		}

		// Make sure it is not inside or equal to a previous rect !
		for ( size_t j = 0; j < iQty; j++ )
		{
			if ( rect.IsInside( m_Rects[j] ))
				return( true );
		}

		if ( iQty <= 0 )
		{
			if ( rect.IsInside( m_rectUnion ))
				return( true );
			m_Rects.Add( m_rectUnion );
		}

		m_Rects.Add( rect );
		m_rectUnion.UnionRect( rect );
	}
	return( true );
}
Beispiel #4
0
bool CGRegion::RealizeRegion()
{
	ADDTOCALLSTACK("CGRegion::RealizeRegion");
	if ( IsRegionEmpty()) return( false );
	return( true );
}