コード例 #1
0
Channel::Channel()
{
    pended = false;

    RtlZeroMemory(Overlapped(), sizeof(overlap));
    overlap.hEvent = CreateEvent(NULL, MANUAL_RESET_EVENT, false, NULL);
    if (overlap.hEvent == INVALID_HANDLE_VALUE)
    {
        // Really, this can't possibly have happened.
        die("CreateEvent failed for OVERLAPPED structure for Channel constructor.");
    }
}
コード例 #2
0
void GameWorld::CreateObstacles()
{
	for (int o=0; o < AICON.NumObstacles; ++o)
	{
		bool bOverlapped = true;
	
		//keep creating tiddlywinks until we find one that doesn't overlap
		//any others.Sometimes this can get into an endless loop because the
		//obstacle has nowhere to fit. We test for this case and exit accordingly

		int NumTrys = 0; int NumAllowableTrys = 2000;

		while (bOverlapped)
		{
			NumTrys++;

			if (NumTrys > NumAllowableTrys) return;

			float scale = 0.1f;
			int radius = RandInt((int)AICON.MinObstacleRadius,  (int)AICON.MaxObstacleRadius);
			radius *= scale;
			const int border                 = 10 * scale;
			const int MinGapBetweenObstacles = 20 * scale;

			noVec3 pos(RandInt(radius+border, m_cxClient-radius-border), 0.0f,  RandInt(radius+border, m_cyClient-radius-30-border));
			WowActor* ob = new WowActor(modelname[0]);
			ob->SetID(g_database.GetNewObjectID());
			ob->SetType(0);
			
			ActorController* pACtrl = new ActorController( ob,
				this, pos, RandFloat() * noMath::TWO_PI, 
				vec3_zero, AICON.VehicleMass, AICON.MaxSteeringForce, AICON.MaxSpeed, AICON.MaxTurnRatePerSecond );
			
			pACtrl->SetBRadius(radius);
			ob->PushStateMachine(*pACtrl);
							

			if (!Overlapped(pACtrl, m_Obstacles, MinGapBetweenObstacles))
			{
				//its not overlapped so we can add it
				m_Obstacles.push_back(pACtrl);

				GameObjectManager::Get()->AddGameObject(ob);
				GetApp()->GetActorRoot()->AddChild(ob->GetNode());

				bOverlapped = false;
			}			
		}
	}
}
コード例 #3
0
//---------------------------------------------------------------------------
// DiskAsyncResult Constructor (internal)
//
// Arguments:
//
//	handle		- Open DiskSafeHandle instance
//	state		- IAsyncResult state object

DiskAsyncResult::DiskAsyncResult(DiskSafeHandle^ handle, Object^ state) : 
	m_handle(handle), m_state(state), m_completed(false)
{
	// Can't check this
	// if(handle == nullptr) throw gcnew ArgumentNullException("handle");

	m_event = gcnew ManualResetEvent(false);
	m_overlapped = gcnew Overlapped(0, 0, m_event->SafeWaitHandle->DangerousGetHandle(), this);
	m_pNativeOverlapped = m_overlapped->Pack(nullptr, nullptr);
}

//---------------------------------------------------------------------------
// DiskAsyncResult Finalizer

DiskAsyncResult::!DiskAsyncResult()
{
	if(m_pNativeOverlapped) Overlapped::Free(m_pNativeOverlapped);
	m_pNativeOverlapped = NULL;
}

//---------------------------------------------------------------------------
// DiskAsyncResult::EndOperation (internal, static)
//