Example #1
0
bool CItemMulti::MultiRealizeRegion()
{
	// Add/move a region for the multi so we know when we are in it.
	// RETURN: ignored.

	DEBUG_CHECK( IsType(IT_MULTI) || IsType(IT_SHIP) );
	ASSERT( IsTopLevel());

	const CItemBaseMulti * pMultiDef = Multi_GetDef();
	if ( pMultiDef == NULL )
	{
		DEBUG_ERR(( "Bad Multi type 0%x, uid=0%x\n", GetID(), (DWORD) GetUID()));
		return false;
	}

	if ( m_pRegion == NULL )
	{
		RESOURCE_ID rid;
		rid.SetPrivateUID( GetUID());
		m_pRegion = new CRegionWorld( rid );
	}

	// Get Background region.
	CPointMap pt = GetTopPoint();
	const CRegionWorld * pRegionBack = dynamic_cast <CRegionWorld*> (pt.GetRegion( REGION_TYPE_AREA ));
	ASSERT( pRegionBack );
	ASSERT( pRegionBack != m_pRegion );

	// Create the new region rectangle.
	CRectMap rect;
	reinterpret_cast<CGRect&>(rect) = pMultiDef->m_rect;
	rect.OffsetRect( pt.m_x, pt.m_y );
	m_pRegion->SetRegionRect( rect );
	m_pRegion->m_pt = pt;

	DWORD dwFlags;
	if ( IsType(IT_SHIP))
	{
		dwFlags = REGION_FLAG_SHIP;
	}
	else
	{
		// Houses get some of the attribs of the land around it.
		dwFlags = pRegionBack->GetRegionFlags();
	}
	dwFlags |= pMultiDef->m_dwRegionFlags;
	m_pRegion->SetRegionFlags( dwFlags );

	TCHAR *pszTemp = Str_GetTemp();
	sprintf(pszTemp, "%s (%s)", (LPCTSTR) pRegionBack->GetName(), (LPCTSTR) GetName());
	m_pRegion->SetName(pszTemp);

	return m_pRegion->RealizeRegion();
}
Example #2
0
RESOURCE_ID CResourceBase::ResourceGetID( RES_TYPE restype, LPCTSTR & pszName )
{
	ADDTOCALLSTACK("CResourceBase::ResourceGetID");
	// Find the Resource ID given this name.
	// We are NOT creating a new resource. just looking up an existing one
	// NOTE: Do not enforce the restype.
	//		Just fill it in if we are not sure what the type is.
	// NOTE: 
	//  Some restype's have private name spaces. (ie. RES_AREA)
	// RETURN:
	//  pszName is now set to be after the expression.

	// We are NOT creating.
	RESOURCE_ID rid;

	// Try to handle private name spaces.
	switch ( restype )
	{
		case RES_ACCOUNT:
		case RES_AREA:
		case RES_GMPAGE:
		case RES_ROOM:
		case RES_SECTOR:
			break;

		default:
			break;
	}

	rid.SetPrivateUID( Exp_GetVal(pszName));	// May be some complex expression {}

	if ( restype != RES_UNKNOWN && rid.GetResType() == RES_UNKNOWN )
	{
		// Label it with the type we want.
		return RESOURCE_ID( restype, rid.GetResIndex());
	}

	return( rid );
}