Beispiel #1
0
int CPathDialog::isValidDir(LPCTSTR lpPath)
{
	int iRet;
	try
	{
		//validate path
		iRet=Touch(lpPath, TRUE);
		if(iRet!=0)
		{
			throw iRet;
		}

		if(_taccess(lpPath, 0)==0)
		{
			return (int)0;
		}


		//create path
		iRet=Touch(lpPath, FALSE);
		if(iRet!=0)
		{
			throw iRet; 
		}

		return 0;
	}
	catch(int nErrCode)
	{
	}
	return iRet;
}
void CMixParam::SetParams(SONAR_MIXER_STRIP eMixerStrip, DWORD dwStripNum,
							SONAR_MIXER_PARAM eMixerParam, DWORD dwParamNum)
{
	if (m_bHasBinding == false ||
		m_eMixerStrip != eMixerStrip || m_dwStripNum != dwStripNum ||
		m_eMixerParam != eMixerParam || m_dwParamNum != dwParamNum)
	{
		bool bWasTouched = m_bTouched;

		if (bWasTouched)
			Touch(false);

		SetMetering(false);

		m_eMixerStrip = eMixerStrip;
		m_dwStripNum = dwStripNum;
		m_eMixerParam = eMixerParam;
		m_dwParamNum = dwParamNum;

		if (bWasTouched)
			Touch(true);

		m_bHasBinding = true;
	}

	m_szAlternateLabel[0] = 0;
	m_bDisableWhilePlaying = false;
	m_bAllowFineResolution = true;

	// Remember if it was a MIDI track
	m_bWasMIDI = IsMIDITrack();
}
Beispiel #3
0
//return -1: user break;
//return 0: no error
//return 1: lpPath is invalid
//return 2: can not create lpPath
int CPathDialog::MakeSurePathExists(LPCTSTR lpPath)
{
	INXString strMsg;
	int iRet;
	try
	{
		//validate path
		iRet=Touch(lpPath, TRUE);
		if(iRet!=0)
		{
			throw iRet;
		}

		if(_taccess(lpPath, 0)==0)
		{
			return (int)0;
		}

		strMsg.Format(c_FolderDoesNotExist, lpPath);
		if(AfxMessageBox(strMsg, MB_YESNO|MB_ICONQUESTION) != IDYES)
		{
			return (int)-1;
		}

		//create path
		iRet=Touch(lpPath, FALSE);
		if(iRet!=0)
		{
			throw iRet; 
		}

		return 0;
	}
	catch(int nErrCode)
	{
		switch(nErrCode)
		{
		case 1:
			strMsg.Format(c_szErrInvalidPath, lpPath);
			break;
		case 2:
		default:
			strMsg.Format(c_szErrCreatePath, lpPath);
			break;
		}

		AfxMessageBox(strMsg, MB_OK|MB_ICONEXCLAMATION);

	}

	return iRet;
}
Beispiel #4
0
void down(){
    Touch();
    //while(Touch_ret==0)
    while1:
    asm("lda %b",Touch_ret);
    asm("bne %g",endwhile1);
        //PosY--;
        asm("dec %b",PosY);
        Touch();
    asm("jmp %g",while1);
    endwhile1:
    TouchDo();
}
Beispiel #5
0
/* EXPORT->GoNextState: move to next unseen state */
Boolean GoNextState(HMMScanState *hss, Boolean noSkip)
{
   Boolean stepping = FALSE, ok = TRUE;
   int M;

   while (IsSeen(hss->si->nUse) && ok){
      if (hss->i < hss->N-1) {
         ++hss->i; ++hss->se; stepping = TRUE;
         hss->si = hss->se->info;
      } else if (noSkip)
         return FALSE;
      else{
         stepping = FALSE;
         ok = GoNextHMM(hss);
      }
   }
   if (ok) {
      Touch(&hss->si->nUse);
      if (stepping){
         hss->ste = hss->si->pdf+1; hss->s=1;
         M = hss->ste->nMix;
         hss->M = (M<0)?-M:M; hss->m=1;
         if (hss->isCont){
            hss->me = hss->ste->spdf.cpdf+1;
            hss->mp = hss->me->mpdf;
         }
      }
      return TRUE;
   }
   hss->se = NULL;
   return FALSE;
}
Beispiel #6
0
	size_t DataFileDB::KeyLookup(const Data& key,bool& already_exist) const
	{
//		Dump("DataFileDB::KeyLookup(const Data&,bool","key look up for ",key);
		
		if(dbtype==DBNone)
			throw LangErr("DataFileDB::KeyLookup(const Data&,bool&)","cannot do key lookup on database type DBNone");
		else if(dbtype==DBSingleFile)
		{
			return Data::KeyLookup(key,already_exist);
		}
		else if(dbtype==DBStringKeys)
		{
			if(!key.IsString())
				throw LangErr("DataFileDB::KeyLookup(const Data&,bool&)","invalid key type "+type_of(key).String()+" for DBStringKeys");

			size_t pos=Data::KeyLookup(key,already_exist);

			if(already_exist)
				Touch(pos);
			
			return pos;
		}
		else
			throw Error::NotYetImplemented("DataFileDB::KeyLookup(const Data&,bool&)");
			
	}
Beispiel #7
0
void csTerrainCell::UnlockMaterialMap ()
{
  Touch();

  terrain->GetRenderer ()->OnMaterialMaskUpdate (this, lockedMaterialMapRect, 
    materialmap.GetArray (), materialMapWidth);

  /*
  for (unsigned int i = 0; i < terrain->GetMaterialPalette ().GetSize (); ++i)
  {
    for (int y = 0; y < lockedMaterialMapRect.Height (); ++y)
    {
      for (int x = 0; x < lockedMaterialMapRect.Width (); ++x)
      {
        size_t idx = y * lockedMaterialMapRect.Width () + x;
        unsigned char p = materialmap[idx];
        alpha[idx] = (p == i) ? 255 : 0;
      }
    }
    
    //@@TODO! Send update to renderer   
  }*/

  if (!materialMapPersistent) 
    materialmap.DeleteAll ();
}
Beispiel #8
0
int
main(int argc, char **argv)
{
	int		i, nloop, contpipe[2], datapipe[2];
	pid_t	childpid;

	if (argc != 4)
		err_quit("usage: bw_pipe <#loops> <#mbytes> <#bytes/write>");
	nloop = atoi(argv[1]);
	totalnbytes = atoi(argv[2]) * 1024 * 1024;
	xfersize = atoi(argv[3]);

	buf = Valloc(xfersize);
	Touch(buf, xfersize);

	Pipe(contpipe);
	Pipe(datapipe);

	if ( (childpid = Fork()) == 0) {
		writer(contpipe[0], datapipe[1]);	/* child */
		exit(0);
	}
		/* 4parent */
	Start_time();
	for (i = 0; i < nloop; i++)
		reader(contpipe[1], datapipe[0], totalnbytes);
	printf("bandwidth: %.3f MB/sec\n",
		   totalnbytes / Stop_time() * nloop);
	kill(childpid, SIGTERM);
	exit(0);
}
Beispiel #9
0
	bool DataFileDB::SaveCache(int index) const
	{
		if(index < 0 || (size_t)index >= status.size())
			throw Error::Invalid("DataFileDB::SaveCache","invalid index "+ToString(index));

		if(dbtype==DBStringKeys)
		{
			if(status[index].ondisk)
				return false;

			Dump("DataFileDB::SaveCache(int)","saving entry "+ToString(index)+": "+tostr(vec[index][0]).String());
		
			Touch(index);

			string filename=FileName(vec[index][0].String());
			security.WriteFile(filename);
		
			ofstream F(filename.c_str());
			if(!F)
				throw Error::IO("DataFileDB::SaveCache(int)","unable to write "+filename);
			PrettySave(F,vec[index][1]);
			F.close();

			status[index].ondisk=true;
			vec[index][1]=Null;
		}
		else
			throw Error::NotYetImplemented("DataFileDB::SaveCache()");
		
		return true;
	}
Beispiel #10
0
int GDALRasterBlock::TakeLock()
{
    const int nLockVal = AddLock();
    CPLAssert(nLockVal >= 0);
    if( bSleepsForBockCacheDebug )
        CPLSleep(CPLAtof(
            CPLGetConfigOption("GDAL_RB_TRYGET_SLEEP_AFTER_TAKE_LOCK", "0")));
    if( nLockVal == 0 )
    {
#ifdef DEBUG
        CPLDebug(
            "GDAL",
            "TakeLock(%p): Block(%d,%d,%p) is being evicted while trying to "
            "reacquire it.",
            reinterpret_cast<void *>(CPLGetPID()), nXOff, nYOff, poBand );
#endif
        // The block is being evicted by GDALRasterBlock::Internalize()
        // or FlushCacheBlock(), so wait for this to be done before trying
        // again.
        DropLock();

        // wait for the block having been unreferenced
        TAKE_LOCK;

        return FALSE;
    }
    Touch();
    return TRUE;
}
Beispiel #11
0
/* EXPORT->GoNextStream: move to next unseen stream */
Boolean GoNextStream(HMMScanState *hss, Boolean noSkip)
{
   Boolean stepping = FALSE, ok = TRUE;
   int M;

   while (IsSeen(hss->ste->nMix) && ok){
      if (hss->s < hss->S) {
         ++hss->s; ++hss->ste; stepping = TRUE;
      } else if (noSkip)
         return FALSE;
      else{
         stepping = FALSE;
         ok = GoNextState(hss,FALSE);
      }
   }
   if (ok) {
      Touch(&hss->ste->nMix);
      if (stepping) {
         M = hss->ste->nMix;
         hss->M = (M<0)?-M:M; hss->m=1;
         if (hss->isCont){
            hss->me = hss->ste->spdf.cpdf+1;
            hss->mp = hss->me->mpdf;
         }
      }
      return TRUE;
   }
   hss->ste = NULL;
   return FALSE;
}
Beispiel #12
0
void slowdown(){
	if(Touch()==1)
	{
		TouchDo();
	}
	PosY--;
}
Beispiel #13
0
void down(){
	while(Touch()!=1)
	{
		PosY--;
	}
	TouchDo();
}
Beispiel #14
0
void TouchTracker::clear()
{
	for (int i=0; i<kMaxTouches; i++)
	{
		mTouches[i] = Touch();
	}
}
Beispiel #15
0
int
main(int argc, char **argv)
{
	int		i, nloop, contpipe[2], msqid;
	pid_t	childpid;

	if (argc != 4)
		err_quit("usage: bw_svmsg <#loops> <#mbytes> <#bytes/write>");
	nloop = atoi(argv[1]);
	totalnbytes = atoi(argv[2]) * 1024 * 1024;
	xfersize = atoi(argv[3]);

	buf = Valloc(xfersize);
	Touch(buf, xfersize);
	buf->mtype = 1;

	Pipe(contpipe);
	msqid = Msgget(IPC_PRIVATE, IPC_CREAT | SVMSG_MODE);

	if ( (childpid = Fork()) == 0) {
		writer(contpipe[0], msqid);		/* child */
		exit(0);
	}
	Start_time();
	for (i = 0; i < nloop; i++)
		reader(contpipe[1], msqid, totalnbytes);
	printf("bandwidth: %.3f MB/sec\n",
		   totalnbytes / Stop_time() * nloop);

	kill(childpid, SIGTERM);
	Msgctl(msqid, IPC_RMID, NULL);
	exit(0);
}
Beispiel #16
0
/* EXPORT->GoNextMix: move to next unseen mixture component */
Boolean GoNextMix(HMMScanState *hss, Boolean noSkip)
{
   Boolean ok = TRUE;

   if (hss->isCont){
      while (IsSeen(hss->mp->nUse) && ok){
         if (hss->m < hss->M) {
            ++hss->m; ++hss->me;
            hss->mp = hss->me->mpdf;
         } else if (noSkip)
            return FALSE;
         else
            ok = GoNextStream(hss,FALSE);
      }
      if (ok) {
         Touch(&hss->mp->nUse);
         return TRUE;
      }
   } else {
      if (hss->m < hss->M) {
         ++hss->m;
      } else if (noSkip)
         return FALSE;
      else
         ok = GoNextStream(hss,FALSE);
      if (ok) return TRUE;
   }
   hss->me = NULL;
   return FALSE;
}
Beispiel #17
0
	void DataFileDB::LoadCache(int index) const
	{
		if(index < 0 || (size_t)index >= status.size())
			throw Error::Invalid("DataFileDB::LoadCache","invalid index "+ToString(index));
		
		if(dbtype==DBStringKeys)
		{
			Touch(index);
		
			if(!status[index].ondisk)
				return;

			Dump("DataFileDB::LoadCache(int)","loading entry "+ToString(index)+": "+tostr(vec[index][0]).String());
				
			string filename=FileName(vec[index][0].String());
			security.ReadFile(filename);
			ifstream F(filename.c_str());
			if(!F)
				throw Error::IO("DataFileDB::LoadCache(int)","unable to read "+filename);
		
			string buffer;
			while(F)
				buffer+=readline(F);
			F.close();
		
			status[index].ondisk=false;
			vec[index][1]=toval(buffer);
		}
		else
			throw Error::NotYetImplemented("DataFileDB::LoadCache()");
	}
//-----------------------------------------------------------------------------
// Purpose: Grenades aren't solid to players, so players don't get stuck on
//			them when they're lying on the ground. We still want thrown grenades
//			to bounce of players though, so manually trace ahead and see if we'd
//			hit something that we'd like the grenade to "collide" with.
//-----------------------------------------------------------------------------
void CTFWeaponBaseGrenadeProj::VPhysicsUpdate( IPhysicsObject *pPhysics )
{
	BaseClass::VPhysicsUpdate( pPhysics );

	Vector vel;
	AngularImpulse angVel;
	pPhysics->GetVelocity( &vel, &angVel );

	Vector start = GetAbsOrigin();

	// find all entities that my collision group wouldn't hit, but COLLISION_GROUP_NONE would and bounce off of them as a ray cast
	CTraceFilterCollisionGrenades filter( this, GetThrower() );
	trace_t tr;

	UTIL_TraceLine( start, start + vel * gpGlobals->frametime, CONTENTS_HITBOX|CONTENTS_MONSTER|CONTENTS_SOLID, &filter, &tr );

	bool bHitEnemy = false;

	if ( tr.m_pEnt && tr.m_pEnt->GetTeamNumber() != GetTeamNumber() )
	{
		bHitEnemy = true;
	}

	if ( tr.startsolid )
	{
		if ( (m_bInSolid == false && m_bCollideWithTeammates == true) || ( m_bInSolid == false  && bHitEnemy == true ) )
		{
			// UNDONE: Do a better contact solution that uses relative velocity?
			vel *= -GRENADE_COEFFICIENT_OF_RESTITUTION; // bounce backwards
			pPhysics->SetVelocity( &vel, NULL );
		}
		m_bInSolid = true;
		return;
	}

	m_bInSolid = false;

	if ( tr.DidHit() )
	{
		Touch( tr.m_pEnt );
		
		if ( m_bCollideWithTeammates == true || bHitEnemy == true )
		{
			// reflect velocity around normal
			vel = -2.0f * tr.plane.normal * DotProduct(vel,tr.plane.normal) + vel;

			// absorb 80% in impact
			vel *= GetElasticity();

			if ( bHitEnemy == true )
			{
				vel *= 0.5f;
			}

			angVel *= -0.5f;
			pPhysics->SetVelocity( &vel, &angVel );
		}
	}
}
Beispiel #19
0
	bool Document::Update()
	{
		bool rc = true;
		bool scrolling = false;

		if(Touch(0).Pressed())
		{
			mTouchPosition = Vec2(Touch(0).mPosition);
			mCurrentLink = GetLinkRectangle(Touch(0).mPosition);
			mGrabbed = true;
			rc = false;
		}
		else if(mGrabbed)
		{
			if(Touch(0).Held())
			{
				Vec2 vel (Touch(0).mPosition - Touch(0).mPreviousPosition);
				if(vel.x != 0 || vel.y != 0)
				{
					mScrollVelocity = vel;
					scrolling = true;
				}

				if(mCurrentLink != GetLinkRectangle(Touch(0).mPosition))
				{
					mCurrentLink = null;
				}
			}
			else if(Touch(0).Released())
			{
				mGrabbed = false;
				scrolling = true;
				if(mCurrentLink != null)
				{
					if(mLinkClickCallback != null)
					{
						mLinkClickCallback(mCurrentLink);
					}
				}
				mCurrentLink = null;
			}
			else
			{
				scrolling = true;
			}
		}

		if(scrolling)
		{
			mScrollPosition -= mScrollVelocity;
			mScrollPosition = Min(Max(Vec2::zero, mScrollPosition), MaxOffset());
		}
		mScrollVelocity *= 0.95f;
		return rc;
	}
void TouchTracker::clear()
{
	for (int i=0; i<mMaxTouchesPerFrame; i++)	
	{
		mTouches[i] = Touch();	
	}
	mBackgroundFilter.clear();
	mNeedsClear = true;
}
Beispiel #21
0
Touch& Input_Engine::GetTouch(int _id)
{
    for(int i = 0; i < m_touches.size(); ++i)
    {
        if(m_touches[i].ID == _id)
            return m_touches[i];
    }
    m_touches.push_back(Touch(_id));
    return m_touches.back();
}
Beispiel #22
0
void csTerrainCell::SetAlphaMask (iMaterialWrapper* material, iImage* alphaMap)
{
  Touch();

  // Make sure we have a true color image
  csRef<iImage> image;
  image.AttachNew (new csImageMemory (alphaMap, 
    CS_IMGFMT_TRUECOLOR | (alphaMap->GetFormat () & ~CS_IMGFMT_MASK)));

  terrain->GetRenderer ()->OnAlphaMapUpdate (this, material, image);
}
//-----------------------------------------------------------------------------
// Purpose: Called each frame when two entities are touching each other.
//-----------------------------------------------------------------------------
void CBaseEntity::OnCollide( CBaseEntity *pOther )
{
	if ( !pOther )
		return;

	// If either ents are marked for deletion they can't touch each other.
	if ( IsMarkedForDeletion() || pOther->IsMarkedForDeletion() )
		return;

	pOther->Touch( this );
	Touch( pOther );
}
Beispiel #24
0
void slowdown(){
    Touch();
    //if(Touch_ret)
    asm("lda %b",Touch_ret);
    asm("beq %g",else1);
        TouchDo();
        asm("rts");
    else1:
        //PosY--;
        asm("dec %b",PosY);
        DrawShape();
}
CPLErr GDALRasterBlock::Internalize()

{
    CPLMutexHolderD(&hRBMutex);
    void    *pNewData;
    int     nSizeInBytes;
    GIntBig nCurCacheMax = GDALGetCacheMax64();

    /* No risk of overflow as it is checked in GDALRasterBand::InitBlockInfo() */
    nSizeInBytes = nXSize * nYSize * (GDALGetDataTypeSize(eType) / 8);

    pNewData = VSIMalloc(nSizeInBytes);
    if (pNewData == NULL)
    {
        CPLError(CE_Failure, CPLE_OutOfMemory,
                 "GDALRasterBlock::Internalize : Out of memory allocating %d bytes.",
                 nSizeInBytes);
        return(CE_Failure);
    }

    if (pData != NULL)
        memcpy(pNewData, pData, nSizeInBytes);

    pData = pNewData;

/* -------------------------------------------------------------------- */
/*      Flush old blocks if we are nearing our memory limit.            */
/* -------------------------------------------------------------------- */
    AddLock(); /* don't flush this block! */

    nCacheUsed += nSizeInBytes;

    while (nCacheUsed > nCurCacheMax)
    {
        GIntBig nOldCacheUsed = nCacheUsed;

        GDALFlushCacheBlock();

        if (nCacheUsed == nOldCacheUsed)
            break;
    }

/* -------------------------------------------------------------------- */
/*      Add this block to the list.                                     */
/* -------------------------------------------------------------------- */
    Touch();
    DropLock();

    return(CE_None);
}
Beispiel #26
0
void Grenade::Update()
{
    short CenterSX = g_graphics->GetCenterX() - 16,
          CenterSY = g_graphics->GetCenterY() - 16;
    short MeX = (short)(g_game->m_me->GetX() - CenterSX),
          MeY = (short)(g_game->m_me->GetY() - CenterSY);
    int ExX = 0, ExY = 0, d, j = 0;
    m_dist += m_speed * 1.5 * g_game->GetGameSpeed ();
    ExX = (short)(cos ( m_angle * DIV360MULTPI ) * m_dist + m_X);
    ExY = (short)(sin ( m_angle * DIV360MULTPI ) * m_dist + m_Y);
    int maxDist = max(g_graphics->GetScreenHeight(),g_graphics->GetScreenWidth());
    if ( ExX - MeX > -maxDist && ExY - MeY > -maxDist &&
         ExX - MeX < maxDist &&
         ExY - MeY < maxDist )
    {
        if ( m_dist > m_dest )
        {
            d = Touch ( ExX, ExY );
            if ( d >= 0 && d <= 2 )
            {
                g_interface->ExplodeShrapnel ( m_player, ExX, ExY, 3.5, 700, 0, 12 );
                g_interface->ExplodeGrenade ( ExX, ExY );
            }
            m_expired = true;
        }
        double si = (m_dest - m_dist) / m_dest;
        if ( si > 0.9 ) j = 0;
        else if ( si > 0.8 ) j = 1;
        else if ( si > 0.7 ) j = 2;
        else if ( si > 0.6 ) j = 3;
        else if ( si > 0.5 ) j = 4;
        else if ( si > 0.4 ) j = 4;
        else if ( si > 0.3 ) j = 3;
        else if ( si > 0.2 ) j = 2;
        else if ( si > 0.1 ) j = 1;
        SDL_Rect rWeapon, rDest;
        memcpy ( &rWeapon, &rBomb[j], sizeof(SDL_Rect) );
        m_smokeTick.Stop();
        if ( m_smokeTick.Elapsed () > 0.1 && m_dist > 24 )
        {
            g_interface->GrenadeSmokeTrail ( ExX, ExY, m_player->GetTeam () );
            m_smokeTick.Start();
        }
        rDest.x = ExX - MeX - ( rBomb[j].w / 2 );
        rDest.y = ExY - MeY - ( rBomb[j].h / 2 );

        // TODO: Move this stuff to ::Render!
        g_graphics->Blit ( g_interface->GetTuna1SurfaceID(), &rWeapon, g_graphics->GetScreen(), &rDest );
    }
}
Beispiel #27
0
void
Simulator::Process(NMEAInfo &basic)
{
  assert(is_simulator());

  Touch(basic);

  basic.location = FindLatitudeLongitude(basic.location, basic.track,
                                         basic.ground_speed);

  // use this to test FLARM parsing/display
  if (IsDebug() && !IsAltair())
    GenerateFLARMTraffic(basic);
}
Beispiel #28
0
void OGRFMECacheIndex::Reference( CPLXMLNode *psDSNode )

{
    if( psDSNode == NULL || !EQUAL(psDSNode->pszValue,"DataSource") )
        return;

    char szNewRefCount[32];

    sprintf( szNewRefCount, "%d", 
             atoi(CPLGetXMLValue(psDSNode, "RefCount", "0")) + 1 );

    CPLSetXMLValue( psDSNode, "RefCount", szNewRefCount );

    Touch( psDSNode );
}
Beispiel #29
0
void csTerrainCell::SetMaterialMask (unsigned int material, iImage* image)
{
  if (image->GetFormat () != CS_IMGFMT_PALETTED8) 
    return;

  Touch();
  
  if (image->GetWidth () != materialMapWidth || 
    image->GetHeight () != materialMapHeight)
  {
    image = csImageManipulate::Rescale (image, materialMapWidth,
      materialMapHeight);
  }
    
  terrain->GetRenderer ()->OnMaterialMaskUpdate (this, material,
    csRect(0, 0, image->GetWidth (), image->GetHeight ()),
    (const unsigned char*)image->GetImageData (), image->GetWidth ());
}
    MyApplication(int argc, char **argv)
        : Application(argc, argv, "timed_event", false)
    {
        // Touch
        Touch();
        m_controllerInThread.Touch();

        // Run thread
        m_thread.Run();
        m_controllerInThread.SwitchToThread(&m_thread);

        // Emit thread timed events
        m_controllerInThread.DPL::ControllerEventHandler<SecondEvent>::PostTimedEvent(SecondEvent(), 3);
        m_controllerInThread.DPL::ControllerEventHandler<FirstEvent>::PostTimedEvent(FirstEvent(), 2);

        // Emit framework timed quit event
        DPL::ControllerEventHandler<QuitEvent>::PostTimedEvent(QuitEvent(), 5);
    }