Example #1
0
bool CClient::addGumpDialogProps( CGrayUID uid )
{
	ADDTOCALLSTACK("CClient::addGumpDialogProps");
	// put up a prop dialog for the object.
	CObjBase * pObj = uid.ObjFind();
	if ( pObj == NULL )
		return false;
	if ( m_pChar == NULL )
		return( false );
	if ( ! m_pChar->CanTouch( pObj ))	// probably a security issue.
		return( false );

	m_Prop_UID = m_Targ_UID = uid;
	if ( uid.IsChar() )
		addSkillWindow(static_cast<SKILL_TYPE>(g_Cfg.m_iMaxSkill), true);

	TCHAR *pszMsg = Str_GetTemp();
	strcpy(pszMsg, pObj->IsItem() ? "d_ITEMPROP1" : "d_CHARPROP1" );

	RESOURCE_ID rid = g_Cfg.ResourceGetIDType(RES_DIALOG, pszMsg);
	if ( ! rid.IsValidUID())
		return false;

	Dialog_Setup( CLIMODE_DIALOG, rid, 0, pObj );
	return( true );
}
Example #2
0
bool CItemMulti::Ship_Face( DIR_TYPE dir )
{
	// Change the direction of the ship.

	ASSERT( IsTopLevel());
	DEBUG_CHECK( m_pRegion );
	if ( m_pRegion == NULL ) 
	{
		return false;
	}

	int i=0;
	for ( ; true; i++ )
	{
		if ( i >= COUNTOF(sm_Ship_FaceDir))
			return( false );
		if ( dir == sm_Ship_FaceDir[i] )
			break;
	}

	int iFaceOffset = Ship_GetFaceOffset();
	ITEMID_TYPE idnew = (ITEMID_TYPE) ( GetID() - iFaceOffset + i );
	const CItemBaseMulti * pMultiNew = Multi_GetDef( idnew );
	if ( pMultiNew == NULL )
	{
		return false;
	}

	const CItemBaseMulti * pMultiDef = Multi_GetDef();
	ASSERT( pMultiDef);

	int iTurn = dir - sm_Ship_FaceDir[ iFaceOffset ];

	// ?? Are there blocking items in the way of the turn ?
	// CRectMap

	// Reorient everything on the deck
	CObjBase * ppObjs[MAX_MULTI_LIST_OBJS+1];
	int iCount = Ship_ListObjs( ppObjs );
   int i2 = 0;
	for ( i=0; i<iCount; i++ )
	{
		CObjBase * pObj = ppObjs[i];
		CPointMap pt = pObj->GetTopPoint();

		if ( pObj->IsItem())
		{
			CItem * pItem = STATIC_CAST <CItem*> (pObj);
			ASSERT( pItem );
			if ( pItem == this )
			{
				m_pRegion->UnRealizeRegion();
				pItem->SetID(idnew);
				// Adjust the region to be the new shape/area.
				MultiRealizeRegion();
				pItem->Update();
				continue;
			}

			// Is this a ship component ? transform it.
         
			//int i = Multi_IsComponentOf( pItem );
			if ( Multi_IsPartOf( pItem ) ) //i>=0 )
			{
				pItem->SetDispID( pMultiNew->m_Components[i2].m_id );
				pt = GetTopPoint();
				pt.m_x += pMultiNew->m_Components[i2].m_dx;
				pt.m_y += pMultiNew->m_Components[i2].m_dy;
				pt.m_z += pMultiNew->m_Components[i2].m_dz;
				pItem->MoveTo( pt );
            i2++;
				continue;
			}
		}

		// -2,6 = left.
		// +2,-6 = right.
		// +-4 = flip around

		int iTmp;
		int xdiff = GetTopPoint().m_x - pt.m_x;
		int ydiff = GetTopPoint().m_y - pt.m_y;
		switch ( iTurn )
		{
		case 2: // right
		case (2-DIR_QTY):
			iTmp = xdiff;
			xdiff = ydiff;
			ydiff = -iTmp;
			break;
		case -2: // left.
		case (DIR_QTY-2):
			iTmp = xdiff;
			xdiff = -ydiff;
			ydiff = iTmp;
			break;
		default: // u turn.
			xdiff = -xdiff;
			ydiff = -ydiff;
			break;
		}
		pt.m_x = GetTopPoint().m_x + xdiff;
		pt.m_y = GetTopPoint().m_y + ydiff;
		pObj->MoveTo( pt );

		if ( pObj->IsChar())
		{
			// Turn creatures as well.
			CChar * pChar = STATIC_CAST <CChar*> (pObj);
			ASSERT(pChar);
			pChar->m_dirFace = GetDirTurn( pChar->m_dirFace, iTurn );
			pChar->RemoveFromView();
			pChar->Update();
		}
	}

	m_itShip.m_DirFace = dir;
	return( true );
}