예제 #1
0
//
// Setting the targets that this grunt will access.
//
BOOL Grunt::Set_Targets( int count, Target_Spec *target_specs )
{
	// Remove previous completion queue if it was created by the Grunt.
	if ( !IsType( type, GenericVIType ) && io_cq )
	{
		delete io_cq;
	}
	io_cq = NULL;

	// If no targets are being set, simply clear the target list.
	if ( !count )
	{
		cout << "   clearing target list." << endl;
		return Size_Target_Array( 0 );
	}

	// Allocate enough targets
	if ( !Size_Target_Array( count, target_specs ) )
		return FALSE;

	worker_performance.target_results.count = count;

	// Create appropriate completion queue object based on targets.
	// If the Grunt will manage VI targets, the targets will provide a
	// pointer to the completion queue to use.
#if defined(IOMTR_SETTING_VI_SUPPORT)
	if ( IsType( type, GenericVIType ) )
	{
		// VI targets must know where the data buffer is and its size before
		// being initialized.
		((TargetVI*)targets[0])->data_buffer = (char*) read_data;
		((TargetVI*)targets[0])->data_buffer_size = access_spec.max_transfer;
		io_cq = &((TargetVI*)targets[0])->vi.vi_cq;
	}
	else
#endif // IOMTR_SETTING_VI_SUPPORT
	{
		// Create completion queue and verify its creation.
		if ( !(io_cq = new CQAIO) )
		{
			cout << "*** Unable to create completion queue while setting "
				<< "targets." << endl;
			return FALSE;
		}
	}

	// Initialize the specific targets.
	for ( int i = 0; i < count; i++ )
	{
		if ( !targets[i]->Initialize( &target_specs[i], io_cq ) )
			return FALSE;
	}

	// Seed the random number generator.  Grunts transferring data over a
	// network will use the same seed to produce the same sequence of random
	// numbers.  This will keep them in synch.
	Srand( target_specs[0].random );

	return Resize_Transaction_Arrays();
}
예제 #2
0
void CItemSpawn::OnTick(bool fExec)
{
	ADDTOCALLSTACK("CitemSpawn:OnTick");

	INT64 iMinutes;

	if ( m_itSpawnChar.m_TimeHiMin <= 0 )
		iMinutes = Calc_GetRandLLVal(30) + 1;
	else
		iMinutes = minimum(m_itSpawnChar.m_TimeHiMin, m_itSpawnChar.m_TimeLoMin) + Calc_GetRandLLVal(abs(m_itSpawnChar.m_TimeHiMin - m_itSpawnChar.m_TimeLoMin));

	if ( iMinutes <= 0 )
		iMinutes = 1;

	if ( !fExec || IsTimerExpired() )
		SetTimeout(iMinutes * 60 * TICK_PER_SEC);	// set time to check again.

	if ( !fExec || m_currentSpawned >= GetAmount() )
		return;

	CResourceDef *pDef = FixDef();
	if ( !pDef )
	{
		RESOURCE_ID_BASE rid = IsType(IT_SPAWN_ITEM) ? m_itSpawnItem.m_ItemID : m_itSpawnChar.m_CharID;
		DEBUG_ERR(("Bad Spawn point uid=0%lx, id=%s\n", (DWORD)GetUID(), g_Cfg.ResourceGetName(rid)));
		return;
	}

	if ( IsType(IT_SPAWN_ITEM) )
		GenerateItem(pDef);
	else
		GenerateChar(pDef);
}
예제 #3
0
//
// Adding the specified worker to the display.
//
void CWorkerView::AddWorker(Worker * worker)
{
	HTREEITEM hmanager, hworker;
	int icon;

	// Get the handle to the tree view entry of the worker's manager.
	hmanager = GetManager(worker->manager);

	if (IsType(worker->Type(), GenericDiskType))
		icon = WORKER_ICON_DISKWORKER;
	else if (IsType(worker->Type(), GenericServerType))
		icon = WORKER_ICON_NETSERVER;
	else if (IsType(worker->Type(), GenericClientType))
		icon = WORKER_ICON_NETCLIENT;
	else
		icon = WORKER_ICON_MANAGER;

	// Add the worker to the manager in the tree view.
	hworker = m_TWorkers.InsertItem(worker->name, icon, icon, hmanager, TVI_LAST);
	m_TWorkers.SetItemData(hworker, (DWORD_PTR) worker);
	m_TWorkers.RedrawWindow();

	// Update the Assigned Access Specs listbox.
	theApp.pView->m_pPageAccess->ShowAssignedAccess();
}
예제 #4
0
//
// Returns TRUE if all of the workers (on all managers) have
// the same access specification list.
//
BOOL ManagerList::AreAccessSpecsIdentical()
{
	int m, w, s, wkr_count, mgr_count, spec_count;
	Worker *compare_worker, *current_worker;
	Manager *mgr;

	// Get the first non-client worker for any manager.
	mgr_count = ManagerCount();
	for (m = 0; m < mgr_count; m++) {
		mgr = GetManager(m);
		wkr_count = mgr->WorkerCount();

		// Find the first non-client worker for this manager.
		for (w = 0; w < wkr_count; w++) {
			compare_worker = mgr->GetWorker(w);

			if (!IsType(compare_worker->Type(), GenericClientType)) {
				spec_count = compare_worker->AccessSpecCount();
				break;
			}
		}

		// See if we found a valid worker for this manager
		if (w < wkr_count)
			break;
	}

	// Did we find a worker to compare against?
	if (m == mgr_count)
		return TRUE;

	// Compare the first worker's Test_Spec to each other worker's Test_Spec.
	// Include the manager with the worker being compared with in our testing.
	for (m; m < mgr_count; m++) {
		mgr = GetManager(m);
		wkr_count = mgr->WorkerCount();

		// Only compare against non-client workers.
		for (w = 0; w < wkr_count; w++) {
			current_worker = mgr->GetWorker(w);

			// Skip network clients.
			if (IsType(current_worker->Type(), GenericClientType))
				continue;

			// If this worker doesn't have the same number of access specs, return FALSE.
			if (current_worker->AccessSpecCount() != spec_count)
				return FALSE;

			// Check to make sure each returned Test_Spec pointer is identical to (and in the
			// same order as) the pointer in the first_worker.
			for (s = 0; s < spec_count; s++) {
				if (current_worker->GetAccessSpec(s) != compare_worker->GetAccessSpec(s))
					return FALSE;
			}
		}
	}

	return TRUE;
}
예제 #5
0
bool CItem::Ship_Plank( bool fOpen )
{
	// IT_SHIP_PLANK to IT_SHIP_SIDE and IT_SHIP_SIDE_LOCKED
	// This item is the ships plank.

	CItemBase * pItemDef = Item_GetDef();
	ITEMID_TYPE idState = (ITEMID_TYPE) RES_GET_INDEX( pItemDef->m_ttShipPlank.m_idState );
	if ( ! idState )
	{
		// Broken ?
		return( false );
	}
	if ( IsType(IT_SHIP_PLANK))
	{
		if ( fOpen )
			return( true );
	}
	else
	{
		DEBUG_CHECK( IsType(IT_SHIP_SIDE) || IsType(IT_SHIP_SIDE_LOCKED));
		if ( ! fOpen )
			return( true );
	}

	SetID( idState );
	Update();
	return( true );
}
예제 #6
0
 bool FundamentalValue::GetAsInteger(int* out_value) const
 {
     if(out_value && IsType(TYPE_INTEGER))
     {
         *out_value = integer_value_;
     }
     return (IsType(TYPE_INTEGER));
 }
예제 #7
0
 bool FundamentalValue::GetAsBoolean(bool* out_value) const
 {
     if(out_value && IsType(TYPE_BOOLEAN))
     {
         *out_value = boolean_value_;
     }
     return (IsType(TYPE_BOOLEAN));
 }
예제 #8
0
파일: CItemSp.cpp 프로젝트: zolter/Source
CResourceDef * CItemSpawn::FixDef()
{
	ADDTOCALLSTACK("CitemSpawn:FixDef");
	// Get a proper RESOURCE_ID from the id provided.
	// RETURN: true = ok.

	RESOURCE_ID_BASE rid = ( IsType(IT_SPAWN_ITEM) ? m_itSpawnItem.m_ItemID : m_itSpawnChar.m_CharID );

	if ( rid.GetResType() != RES_UNKNOWN )
	{
		return STATIC_CAST <CResourceDef *>(g_Cfg.ResourceGetDef(rid));
	}

	// No type info here !?
	if ( IsType(IT_SPAWN_ITEM))
	{
		ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
		if ( id < ITEMID_TEMPLATE )
		{
			return( TryItem( id ) );
		}
		else
		{
			// try a template.
			rid = RESOURCE_ID( RES_TEMPLATE, id );
			CResourceDef * pDef = g_Cfg.ResourceGetDef(rid);
			if ( pDef )
			{
				m_itSpawnItem.m_ItemID = rid;
				return( STATIC_CAST <CResourceDef *>( pDef ));
			} //if fails
			return( TryItem( id ) );
		}
	}
	else
	{
		CREID_TYPE id = static_cast<CREID_TYPE>(rid.GetResIndex());
		if ( id < SPAWNTYPE_START )
		{
			return( TryChar( id ));
		}
		else
		{
			// try a spawn group.
			rid = RESOURCE_ID( RES_SPAWN, id );
			CResourceDef * pDef = g_Cfg.ResourceGetDef(rid);
			if ( pDef )
			{
				m_itSpawnChar.m_CharID = rid;
				return( STATIC_CAST <CResourceDef *>( pDef ));
			} //if fails
			return( TryChar( id ));
		}
	}
}
예제 #9
0
void CMVPeriod::read_body(wistream& s)
{
	CMString str,token,token2;
	str = GetAssociation(L"yearend");
	int yearend = str.length() ? CMTime::Month(str.c_str()) : 12;
	if (IsType(L"trace"))
		traceno = 1;
	else {
		str = GetAssociation(L"trace");
		traceno = str.length() ? _wtoi(str.c_str()) : 0;
	}
	if (IsType(L"alwaysdraw") || IsType(L"monthly")) // LEGACY
		periodstate |= forceEvaluation;
	periodformat = -1;
	array.ResetAndDestroy(1);
	while(!s.eof()) {
		str.read_line(s);
		if (str.is_null() || str[0] == L'*')
			continue;
		if (str(0,wcslen(vardef_end)) == vardef_end)
			break;
		CMTokenizer next(str);
		token = next();
		token2 = next(L"\r\n");
		switch (token.length()) {
			case 1:
			case 2:
				SetExpression(CMTime(2000,_wtoi(token.c_str())),token2.c_str());
				if (periodformat<0) periodformat = CMTime::MM;
				break;
			case 4:
				{
				int yr = _wtoi(token.c_str());
				CMTime t((yearend<12)?(yr-1):yr,yearend%12+1);
				SetExpression(t,token2.c_str());
				if (periodformat<0) periodformat = CMTime::YYYY;
				}
				break;
			case 6:
				if (periodformat<0) periodformat = CMTime::YYYYMM;
			case 8:
				if (periodformat<0) periodformat = CMTime::YYYYMMDD;
			case 10:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHH;
			case 12:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMM;
			default:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMMSS;
				SetExpression(CMTime(token),token2.c_str());
				break;
		}
	}
	array.Resize(array.Count());
}
예제 #10
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();
}
예제 #11
0
 bool FundamentalValue::GetAsDouble(double* out_value) const
 {
     if(out_value && IsType(TYPE_DOUBLE))
     {
         *out_value = double_value_;
     }
     else if(out_value && IsType(TYPE_INTEGER))
     {
         *out_value = integer_value_;
     }
     return (IsType(TYPE_DOUBLE) || IsType(TYPE_INTEGER));
 }
예제 #12
0
파일: Class.cpp 프로젝트: revelator/MHDoom
/*
================
idClass::ProcessEventArgPtr
================
*/
bool idClass::ProcessEventArgPtr( const idEventDef *ev, int *data )
{
	idTypeInfo	*c;
	int			num;
	eventCallback_t	callback;
	
	assert( ev );
	assert( idEvent::initialized );
	
#ifdef _D3XP
	SetTimeState ts;
	
	if( IsType( idEntity::Type ) )
	{
		idEntity *ent = ( idEntity * )this;
		ts.PushState( ent->timeGroup );
	}
#endif
	
	if( g_debugTriggers.GetBool() && ( ev == &EV_Activate ) && IsType( idEntity::Type ) )
	{
		const idEntity *ent = *reinterpret_cast<idEntity **>( data );
		gameLocal.Printf( "%d: '%s' activated by '%s'\n", gameLocal.framenum, static_cast<idEntity *>( this )->GetName(), ent ? ent->GetName() : "NULL" );
	}
	
	c = GetType();
	num = ev->GetEventNum();
	if( !c->eventMap[ num ] )
	{
		// we don't respond to this event, so ignore it
		return false;
	}	
	callback = c->eventMap[ num ];
	
	switch( ev->GetFormatspecIndex() )
	{
		case 1 << D_EVENT_MAXARGS :
			( this->*callback )();
			break;
			
			// generated file - see CREATE_EVENT_CODE
#include "Callbacks.cpp"
			
		default:
			gameLocal.DWarning( "Invalid formatspec on event '%s'", ev->GetName() );
			break;
	}	
	return true;
}
예제 #13
0
//
// Setting the size of the target array to hold the number and type of 
// targets specified.  If the requested number of targets is 0, the 
// array will be freed.
//
BOOL Grunt::Size_Target_Array( int count, const Target_Spec *target_specs )
{
	int i;

	// Free all current targets.  This is needed in case the newer targets
	// are of a different type, even if we have the same number of targets.
	for ( i = 0; i < target_count; i++ )
		delete targets[i];
	target_count = 0;

	// Reset the grunt's target type.
	type = InvalidType;

	// Release the memory if everything is being freed.
	if ( !count || !target_specs )
	{
		free(targets);
		targets = NULL;
		return TRUE;
	}

	// Allocate enough pointers to refer to all targets.
	targets = (Target**)realloc( targets, sizeof(Target*) * count );
	if ( !targets )
		return FALSE;

	// Create the requested number of targets.
	for ( i = 0; i < count; i++ )
	{
		type = (TargetType)(type | target_specs[i].type);

		if ( IsType( target_specs[i].type, GenericDiskType ) )
			targets[i] = new TargetDisk;
		else if ( IsType( target_specs[i].type, GenericTCPType ) )
			targets[i] = new TargetTCP;
#if defined(NO_DYNAMO_VI)
 // nop
#else
		else if ( IsType( target_specs[i].type, GenericVIType ) )
			targets[i] = new TargetVI;
#endif // NO_DYNAMO_VI

		if ( !targets[i] )
			return FALSE;
	}

	target_count = count;
	return TRUE;
}
예제 #14
0
void CItem::Spawn_OnTick( bool fExec )
{
	int iMinutes;
	if ( m_itSpawnChar.m_TimeHiMin <= 0 )
	{
		iMinutes = Calc_GetRandVal(30) + 1;
	}
	else
	{
		iMinutes = min( m_itSpawnChar.m_TimeHiMin, m_itSpawnChar.m_TimeLoMin ) + Calc_GetRandVal( abs( m_itSpawnChar.m_TimeHiMin - m_itSpawnChar.m_TimeLoMin ));
	}

	if ( iMinutes <= 0 )
		iMinutes = 1;

	if ( !fExec || IsTimerExpired() )
	{
		SetTimeout( iMinutes * 60 * TICK_PER_SEC );	// set time to check again.
	}

	if ( ! fExec )
		return;

	CResourceDef * pDef = Spawn_FixDef();
	if ( pDef == NULL )
	{
		RESOURCE_ID_BASE rid;
		if ( IsType(IT_SPAWN_ITEM))
		{
			rid = m_itSpawnItem.m_ItemID;
		}
		else
		{
			rid = m_itSpawnChar.m_CharID;
		}
		DEBUG_ERR(( "Bad Spawn point uid=0%lx, id=%s\n", (DWORD) GetUID(), g_Cfg.ResourceGetName(rid) ));
		return;
	}

	if ( IsType(IT_SPAWN_ITEM))
	{
		Spawn_GenerateItem(pDef);
	}
	else
	{
		Spawn_GenerateChar(pDef);
	}
}
예제 #15
0
파일: cpp_xloper.cpp 프로젝트: daveysj/sjd
//-------------------------------------------------------------------
bool cpp_xloper::Transpose(void)
{
   if(!IsType(xltypeMulti))
      return false;

   WORD r, c, rows, columns;

   GetArraySize(rows, columns);

   xloper *new_array = (xloper *)malloc(sizeof(xloper) * rows * columns);
   xloper *p_source = m_Op.val.array.lparray;
   int new_index;

   for(r = 0; r < rows; r++)
   {
      new_index = r;

      for(c = 0; c < columns; c++, new_index += rows)
      {
         new_array[new_index] = *p_source++;
      }
   }

   r = m_Op.val.array.columns;
   m_Op.val.array.columns = m_Op.val.array.rows;
   m_Op.val.array.rows = r;

   memcpy(m_Op.val.array.lparray, new_array, sizeof(xloper) * rows * columns);
   free(new_array);
   return true;
}
예제 #16
0
파일: Class.cpp 프로젝트: 4DA/doom3.gpl
/*
================
idClass::PostEventArgs
================
*/
bool idClass::PostEventArgs( const idEventDef *ev, int time, int numargs, ... ) {
	idTypeInfo	*c;
	idEvent		*event;
	va_list		args;

	assert( ev );

	if ( !idEvent::initialized ) {
		return false;
	}

	c = GetType();
	if ( !c->eventMap[ ev->GetEventNum() ] ) {
		// we don't respond to this event, so ignore it
		return false;
	}

	// we service events on the client to avoid any bad code filling up the event pool
	// we don't want them processed usually, unless when the map is (re)loading.
	// we allow threads to run fine, though.
	if ( gameLocal.isClient && ( gameLocal.GameState() != GAMESTATE_STARTUP ) && !IsType( idThread::Type ) ) {
		return true;
	}

	va_start( args, numargs );
	event = idEvent::Alloc( ev, numargs, args );
	va_end( args );

	event->Schedule( this, c, time );

	return true;
}
예제 #17
0
//
// Displays the connection rate settings for the current selection in the
// worker view.  If the selection is a manager or all managers, displays
// a value if all the children's values are the same.
//
void CPageNetwork::ShowConnectionRate()
{
	Manager *manager;
	Worker	*worker;
	int		trans_per_conn;
	int		test_connection_rate;

	switch ( theApp.pView->m_pWorkerView->GetSelectedType() )
	{
	case WORKER:
		worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
		// update controls with worker's data
		if ( IsType( worker->Type(), GenericNetType ) )
		{
			trans_per_conn = worker->GetTransPerConn( GenericNetType );
			test_connection_rate = worker->GetConnectionRate( GenericNetType );
		}
		break;
	case MANAGER:
		manager = theApp.pView->m_pWorkerView->GetSelectedManager();
		trans_per_conn = manager->GetTransPerConn( GenericServerType );
		test_connection_rate = manager->GetConnectionRate( GenericServerType );
		break;
	default:
		trans_per_conn = 
			theApp.manager_list.GetTransPerConn( GenericServerType );
		test_connection_rate = 
			theApp.manager_list.GetConnectionRate( GenericServerType );
		break;
	}
	// If the test connection rate settings are different between a manager's
	// workers, set the state of the check box to AUTO3STATE and disable the
	// edit box and spin control.
	SetDlgItemInt( EConnectionRate, trans_per_conn );
	if ( test_connection_rate == AMBIGUOUS_VALUE )
	{
		m_CConnectionRate.SetButtonStyle( BS_AUTO3STATE );
		m_EConnectionRate.SetPasswordChar( 32 );
		m_EConnectionRate.Invalidate( TRUE );

		// Set check box to undetermined state.
		CheckDlgButton( CConnectionRate, 2 );
	}
	else
	{
		m_CConnectionRate.SetButtonStyle( BS_AUTOCHECKBOX );
		CheckDlgButton( CConnectionRate, test_connection_rate );

		if ( test_connection_rate == ENABLED_VALUE && trans_per_conn != 
			AMBIGUOUS_VALUE )
		{
			m_EConnectionRate.SetPasswordChar( 0 );
		}
		else
		{
			m_EConnectionRate.SetPasswordChar( 32 );
			m_EConnectionRate.Invalidate();
		}
	}
}
예제 #18
0
bool PCB_BASE_FRAME::Update3DView( const wxString* aTitle )
{
    // Update the 3D view only if the viewer is opened by this frame
    EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();

    if( draw3DFrame == NULL )
        return false;

    // Ensure the viewer was created by me, and not by another editor:
    PCB_BASE_FRAME* owner = draw3DFrame->Parent();

    // if I am not the owner, do not use the current viewer instance
    if( this != owner )
        return false;

    if( aTitle )
        draw3DFrame->SetTitle( *aTitle );

    // The 3D view update can be time consumming to rebuild a board 3D view.
    // So do not use a immediate update in the board editor
    bool immediate_update = true;

    if( IsType( FRAME_PCB ) )
        immediate_update = false;

    draw3DFrame->NewDisplay( immediate_update );

    return true;
}
예제 #19
0
CCharBase *CItemSpawn::SetTrackID()
{
	ADDTOCALLSTACK("CitemSpawn:SetTrackID");
	SetAttr(ATTR_INVIS);	// Indicate to GM's that it is invis.
	if (GetHue() == 0)
		SetHue(HUE_RED_DARK);

	if ( !IsType(IT_SPAWN_CHAR) )
	{
		SetDispID(ITEMID_WorldGem_lg);
		return NULL;
	}

	CCharBase *pCharDef = NULL;
	RESOURCE_ID_BASE rid = m_itSpawnChar.m_CharID;

	if ( rid.GetResType() == RES_CHARDEF )
	{
		CREID_TYPE id = static_cast<CREID_TYPE>(rid.GetResIndex());
		pCharDef = CCharBase::FindCharBase(id);
	}
	if ( pCharDef )		// They must want it to look like this.
		SetDispID(pCharDef ? pCharDef->m_trackID : ITEMID_TRACK_WISP);
		
	return pCharDef;
}
예제 #20
0
파일: Function.c 프로젝트: overzeroe/Vyquon
/* Parse a parameter. Currently only supports normal ones. */
Param ParseParam(VyObj param, bool opt, bool rest){
    VyObj default_val = None();
    if(opt){
        if(IsType(param, TypeCons)){
            VyObj name = ListGet(UNWRAP(param, VyCons), 0);

            default_val = ListGet(UNWRAP(param, VyCons), 0);
            param = name;
        }
    }

    Param p = {optional: opt,
        rest: rest,
        default_value: default_val,
        name: UNWRAP(param, VySymbol)};
    return p;
}

/* Find how many actual parameters there are */
int CountParams(VyObj list){
    int count = 0;
    while(!IsNil(list)){
        if(!ObjEq(Car(list), CreateSymbol("?")) && 
           !ObjEq(Car(list), CreateSymbol("..")))
                count++;

        list = Cdr(list);
    }

    return count;
}
예제 #21
0
bool PCB_BASE_FRAME::InvokeDialogGrid()
{
    wxPoint grid_origin = GetGridOrigin();

    DIALOG_SET_GRID dlg( this, &m_UserGridUnit, g_UserUnit, &m_UserGridSize,
        &grid_origin, &m_FastGrid1, &m_FastGrid2,
        m_gridSelectBox->GetStrings() );

    int ret = dlg.ShowModal();

    if( ret == wxID_OK )
    {
        if( GetGridOrigin() != grid_origin && IsType( FRAME_PCB ) )
            OnModify();     // because grid origin is saved in board, show as modified

        SetGridOrigin( grid_origin );

        GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );

        // If the user grid is the current option, recall SetGrid()
        // to force new values put in list as current grid value
        if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER )
            GetScreen()->SetGrid( ID_POPUP_GRID_USER  );

        m_canvas->Refresh();

        return true;
    }

    return false;
}
예제 #22
0
//
// Grunt destructor.
//
Grunt::~Grunt()
{
	// Remove completion queue, if any.
	if ( (type != InvalidType) && !IsType(type, GenericVIType) && io_cq )
		delete io_cq;

	Size_Target_Array( 0 );

	// Release grunt's I/O data buffers if they are in use.
	if ( data_size )
#if defined(IOMTR_OSFAMILY_NETWARE)
		NXMemFree( read_data );
		NXMemFree( write_data );
#elif defined(IOMTR_OSFAMILY_UNIX)
		free( read_data );
		free( write_data );
#elif defined(IOMTR_OSFAMILY_WINDOWS)
		VirtualFree( read_data, 0, MEM_RELEASE );
		VirtualFree( write_data, 0, MEM_RELEASE );
#else
 #warning ===> WARNING: You have to do some coding here to get the port done!
#endif

	Free_Transaction_Arrays();
}
예제 #23
0
int CItemSpawn::GetName(TCHAR * pszOut) const
{
	ADDTOCALLSTACK("CitemSpawn:GetName");
	RESOURCE_ID_BASE rid;
	if ( IsType(IT_SPAWN_ITEM))
	{
		rid = m_itSpawnItem.m_ItemID;
	}
	else
	{
		// Name the spawn type.
		rid = m_itSpawnChar.m_CharID;
	}

	LPCTSTR pszName = NULL;
	CResourceDef * pDef = g_Cfg.ResourceGetDef( rid );
	if ( pDef != NULL )
	{
		pszName = pDef->GetName();
	}
	if ( pDef == NULL || pszName == NULL || pszName[0] == '\0' )
	{
		pszName = g_Cfg.ResourceGetName( rid );
	}
	return sprintf( pszOut, " (%s)", pszName );
}
예제 #24
0
파일: Console.c 프로젝트: berkus/nemesis
static bool_t ConsoleControl_AddOffer_m (
    ConsoleControl_cl       *self,
    IDCOffer_clp    offer   /* IN */,
    bool_t flush)
{
    Console_st     *st = self->st;
    struct output * NOCLOBBER o;

    if (!TypeSystem$IsType(Pvs(types), IDCOffer$Type(offer), Wr_clp__code))
	return False;

    o=Heap$Malloc(Pvs(heap), sizeof(*o));

    o->offer=offer;
    o->flush=flush;

    TRY {
#if 0
	o->binding=IDCOffer$Bind(offer, Pvs(gkpr), &any);
	o->wr=NARROW(&any, Wr_clp);
#else
	o->wr=IDC_BIND(offer, Wr_clp);
#endif /* 0 */
    } CATCH_ALL {
	FREE(o);
	RERAISE;
    } ENDTRY;

    MU_LOCK(&st->mu);
    LINK_ADD_TO_HEAD(&st->outputs, o);
    MU_RELEASE(&st->mu);
    return True;
}
예제 #25
0
void CItem::Spawn_KillChildren()
{
	// kill all creatures spawned from this !
	DEBUG_CHECK( IsType(IT_SPAWN_CHAR));
	int iCurrent = m_itSpawnChar.m_current;

	for ( int j = 0; j < 256; j++ )	// loop through all maps
	{
		if ( !g_MapList.m_maps[j] ) continue;		// skip unsupported maps

		for ( int i = 0; i < g_MapList.GetSectorQty(j); i++ )
		{
			CSector * pSector = g_World.GetSector(j, i);
			ASSERT(pSector);
			CChar * pCharNext;
			CChar * pChar = STATIC_CAST <CChar*>( pSector->m_Chars_Active.GetHead());
			for ( ; pChar!=NULL; pChar = pCharNext )
			{
				pCharNext = pChar->GetNext();
				if ( pChar->NPC_IsSpawnedBy( this ))
				{
					pChar->Delete();
					iCurrent --;
				}
			}
		}
	}
	if (iCurrent && ! g_Serv.IsLoading())
	{
		DEBUG_CHECK(iCurrent==0);
	}
	m_itSpawnChar.m_current = 0;	// Should not be necessary
	Spawn_OnTick( false );
}
예제 #26
0
파일: Ship-AI.cpp 프로젝트: Luomu/pioneer
// Input: direction in ship's frame, doesn't need to be normalized
// Approximate positive angular velocity at match point
// Applies thrust directly
// old: returns whether it can reach that direction in this frame
// returns angle to target
double Ship::AIFaceDirection(const vector3d &dir, double av)
{
	double maxAccel = m_type->angThrust / GetAngularInertia();		// should probably be in stats anyway

	vector3d head = (dir * GetOrient()).Normalized();		// create desired object-space heading
	vector3d dav(0.0, 0.0, 0.0);	// desired angular velocity

	double ang = 0.0;
	if (head.z > -0.99999999)
	{
		ang = acos (Clamp(-head.z, -1.0, 1.0));		// scalar angle from head to curhead
		double iangvel = av + calc_ivel_pos(ang, 0.0, maxAccel);	// ideal angvel at current time

		// Normalize (head.x, head.y) to give desired angvel direction
		if (head.z > 0.999999) head.x = 1.0;
		double head2dnorm = 1.0 / sqrt(head.x*head.x + head.y*head.y);		// NAN fix shouldn't be necessary if inputs are normalized
		dav.x = head.y * head2dnorm * iangvel;
		dav.y = -head.x * head2dnorm * iangvel;
	}
	vector3d cav = GetAngVelocity() * GetOrient();				// current obj-rel angvel
	double frameAccel = maxAccel * Pi::game->GetTimeStep();
	vector3d diff = (dav - cav) / frameAccel;	// find diff between current & desired angvel

	// If the player is pressing a roll key, don't override roll.
	// XXX this really shouldn't be here. a better way would be to have a
	// field in Ship describing the wanted angvel adjustment from input. the
	// baseclass version in Ship would always be 0. the version in Player
	// would be constructed from user input. that adjustment could then be
	// considered by this method when computing the required change
	if (IsType(Object::PLAYER) && (KeyBindings::rollLeft.IsActive() || KeyBindings::rollRight.IsActive()))
		diff.z = m_angThrusters.z;
	SetAngThrusterState(diff);
	return ang;
}
예제 #27
0
//
// Displays the values from memory in the GUI.
//
void CPageDisk::ShowData()
{
	Manager	*manager;
	Worker	*worker;

	// Only enable the display if a disk worker or a manager with disk 
	// interfaces is selected.
	manager = theApp.pView->m_pWorkerView->GetSelectedManager();
	worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
	if (( theApp.pView->m_pWorkerView->GetSelectedType() == ALL_MANAGERS) ||
		( manager && !manager->InterfaceCount( GenericDiskType ) ) ||
		( worker && !IsType( worker->Type(), GenericDiskType ) ) )
	{
		Reset();
		return;
	}

	// This is a new view of the target assignment.  
	// It has not been modified.
	selected = NULL;
	highlighted = NULL;
	// Show the target list.
	ShowTargets();
	// Set the target selection check boxes.
	ShowTargetSelection();
	// Bold the last selected item.
	ShowFocus();
	// Show the connection rate settings.
	ShowConnectionRate();
	// Show the disk specific settings.
	ShowSettings();
	// Enable the apropriate windows and redraw the page.
	EnableWindow();
}
void dgCollisionInstance::SetScale (const dgVector& scale)
{
	dgFloat32 scaleX = dgAbs (scale.m_x);
	dgFloat32 scaleY = dgAbs (scale.m_y);
	dgFloat32 scaleZ = dgAbs (scale.m_z);
	dgAssert (scaleX > dgFloat32 (0.0f));
	dgAssert (scaleY > dgFloat32 (0.0f));
	dgAssert (scaleZ > dgFloat32 (0.0f));

	if (IsType(dgCollision::dgCollisionCompound_RTTI)) {
		dgAssert (m_scaleType == m_unit);
		dgCollisionCompound* const compound = (dgCollisionCompound*) m_childShape;
		compound->ApplyScale(scale);
	} else if ((dgAbs (scaleX - scaleY) < dgFloat32 (1.0e-4f)) && (dgAbs (scaleX - scaleZ) < dgFloat32 (1.0e-4f))) {
		if ((dgAbs (scaleX - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f))) {
			m_scaleType = m_unit;
			m_scale	= dgVector (dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f));	
			m_maxScale = m_scale;	
			m_invScale = m_scale;
		} else {
			m_scaleType = m_uniform;
			m_scale	= dgVector (scaleX, scaleX, scaleX, dgFloat32 (0.0f));	
			m_maxScale = m_scale;	
			m_invScale = dgVector (dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleX, dgFloat32 (0.0f));	
		}
	} else {
		m_scaleType = m_nonUniform;
		m_maxScale = dgMax(scaleX, scaleY, scaleZ);
		m_scale	= dgVector (scaleX, scaleY, scaleZ, dgFloat32 (0.0f));	
		m_invScale = dgVector (dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleY, dgFloat32 (1.0f) / scaleZ, dgFloat32 (0.0f));	
	}
}
예제 #29
0
void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
{
    if( Text == NULL )
        return;

    MODULE* module = (MODULE*) Text->GetParent();

    if( module && module->GetFlags() == 0 && Text->GetFlags() == 0 ) // prepare undo command
    {
        if( IsType( FRAME_PCB ) )
            SaveCopyInUndoList( module, UR_CHANGED );
    }

    // we expect MoveVector to be (0,0) if there is no move in progress
    Text->Draw( m_canvas, DC, GR_XOR, MoveVector );

    Text->SetTextAngle( Text->GetTextAngle() + 900 );

    Text->Draw( m_canvas, DC, GR_XOR, MoveVector );
    SetMsgPanel( Text );

    if( module )
        module->SetLastEditTime();

    OnModify();
}
NewtonCollision* dCollisionCompoundNodeInfo::CreateNewtonCollision (NewtonWorld* const world, dScene* const scene, dScene::dTreeNode* const myNode) const
{
	dAssert (IsType (dCollisionCompoundNodeInfo::GetRttiType()));

	// get the collision node	
	int collisionID = GetShapeId ();
	
	NewtonCollision* const collision = NewtonCreateCompoundCollision(world, collisionID); 
	NewtonCompoundCollisionBeginAddRemove(collision);

	// create space to load all sub shapes
	for (void* link = scene->GetFirstChildLink(myNode); link; link = scene->GetNextChildLink (myNode, link)) {
		dScene::dTreeNode* childNode = scene->GetNodeFromLink(link);
		dNodeInfo* info = scene->GetInfoFromNode(childNode);
		if (info->IsType (dCollisionNodeInfo::GetRttiType())) {
			dCollisionNodeInfo* collInfo = (dCollisionNodeInfo*) scene->GetInfoFromNode(childNode);
			NewtonCollision* const convex = collInfo->CreateNewtonCollision (world, scene, childNode);
			if (convex) {
				NewtonCompoundCollisionAddSubCollision(collision, convex);
				NewtonDestroyCollision(convex);
			}
		}
	}
	NewtonCompoundCollisionEndAddRemove(collision);
	
	return collision;

}