Example #1
0
void
JXApplication::PerformUrgentTasks()
{
	if (!itsUrgentTasks->IsEmpty())
		{
		// clear out itsUrgentTasks so new ones can safely be added

		JPtrArray<JXUrgentTask> taskList(*itsUrgentTasks, JPtrArrayT::kDeleteAll);
		itsUrgentTasks->RemoveAll();

		// perform each task

		const JSize count = taskList.GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			(taskList.NthElement(i))->Perform();
			}
		}

	JXDisplay::CheckForXErrors();

	// We check in this order so CheckForSignals() can broadcast even
	// if the app is suspended.

	if (!itsHasBlockingWindowFlag && JThisProcess::CheckForSignals() &&
		!IsSuspended())
		{
		Quit();
		}
}
void VideoGrabber::startPreview()
{
	PWaitAndSignal locker( mutex );
//	if( state == SPreview ) return;

	PTRACE( 6, "VideoGrabber::startSPreview" );

	state = SPreview;
	preparing = true;
	if( IsSuspended() ) Resume();
}
void VideoGrabber::startCall()
{
	PWaitAndSignal locker( mutex );
//	if( state == SCall ) return;

	PTRACE( 6, "VideoGrabber::startCall" );

	state = SCall;
	preparing = true;
	if( IsSuspended() ) Resume();
}
Example #4
0
nsresult
nsDOMWorkerTimeout::Start()
{
  if (IsSuspended()) {
    NS_ASSERTION(mSuspendedBeforeStart, "Bad state!");
    return NS_OK;
  }

  nsresult rv = mTimer->InitWithCallback(this, mInterval,
                                         nsITimer::TYPE_ONE_SHOT);
  NS_ENSURE_SUCCESS(rv, rv);

  mStarted = PR_TRUE;
  return NS_OK;
}
Example #5
0
void doop(struct user *user, char *tail)
{
  unsigned char flags;
  struct reggedchannel *chanptr;
  char *channel;

  channel = tail;
  SeperateWord(tail);

  if (channel == NULL) {
    NoticeToUser(user, "Usage: op #channel");
    return;
  }

  if ((chanptr = GetChannelPointer(channel)) == NULL) {
    NoticeToUser(user, "Unknown channel %s.", channel);
    return;
  }

  flags = GetChannelFlags(user->authedas, chanptr);

  /* Check for OP or MASTER or OWNER flag */
  if (!(flags & (CFLAG_OP | CFLAG_MASTER | CFLAG_OWNER)) || IsSuspended(chanptr)) {
    /* No flags -- perhaps they are an oper? */
    if (!((user->oper) && (user->authedas->authlevel > 200))) {
      /* Nope, not an oper either */
      NoticeToUser(user, "Sorry, you need the +o flag on %s to get ops.", channel);
      return;
    }
  }

  /* Do the actual op */
  OpUser(chanptr, user->numeric);

  /* Update lastused timestamp on channel */
  chanptr->lastused = time(NULL);

  NoticeToUser(user, "Done.");
}
Example #6
0
void docleanupdb2(struct user *usr_ptr, char *tail)
{
  char *option;
  struct user *target;
  int i;
  struct reggedchannel *chan;

  if (!usr_ptr->oper) {
    NoticeToUser(usr_ptr, "You are not an operator");
    return;
  }

  if (!CheckAuthLevel(usr_ptr, 255))
    return;

  option = tail;
  SeperateWord(tail);
  if (!option) {
    NoticeToUser(usr_ptr, "Usage: cleanupdb2 nick");
    return;
  }

  if ((target = FindUserByNick(option)) == NULL) {
    NoticeToUser(usr_ptr, "Can't find nick: %s", option);
  }

  Log("Cleanupdb2: %s (%s) requested cleanupdb2 %s", usr_ptr->nick, usr_ptr->authedas->authname, option);

  for (i = 0; i < HASHMAX; i++) {
    for (chan = channelhashtable[i]; chan; chan = chan->nextbychannelname) {
      if (!IsSuspended(chan)) {
        MessageToUser(target, "expirecheck %s", chan->channelname);
      }
    }
  }

  NoticeToUser(usr_ptr, "Done.");
}
Example #7
0
//an internal update functionality that must be called at the start of each effect's update
//function. This does not return any value so it does not need to be checked
void CBaseFX::BaseUpdate(float fTimeInterval)
{
	LTASSERT(IsActive() && !IsSuspended(), "Error: Updated an effect that was either suspended or inactive");

	//update the elapsed time
	m_tmElapsed += fTimeInterval;

	//handle updating the additional rotation of this object for this frame
	if(GetProps()->m_bUpdateRotation)
	{
		LTVector vAngles = GetProps()->m_vfcRotation.GetValue(GetUnitLifetime());
		LTRotation rRotation(	MATH_DEGREES_TO_RADIANS(vAngles.x) * fTimeInterval,
								MATH_DEGREES_TO_RADIANS(vAngles.y) * fTimeInterval,
								MATH_DEGREES_TO_RADIANS(vAngles.z) * fTimeInterval);
		m_rAdditional = rRotation * m_rAdditional;
	}

	//update our parent transformation as long as we aren't fixed, and actually have a parent
	if((m_hParentObject || m_hParentRigidBody) && (GetProps()->m_eFollowType != eFXFollowType_Fixed))
	{
		UpdateParentTransform();
	}
}
Example #8
0
bool CFallingStuffFX::Update(float tmFrameTime)
{
    // Base class update first

    m_vLastPos = m_vPos;

    if (!CBaseFX::Update(tmFrameTime))
        return false;

    //increment our emission time by the elapsed frame time
    m_tmElapsedEmission += tmFrameTime;

    if (!IsShuttingDown() && !IsSuspended() && (m_tmElapsedEmission > GetProps()->m_tmFallingStuffFXEmission))
    {
        ObjectCreateStruct ocs;
        INIT_OBJECTCREATESTRUCT(ocs);

        LTVector vScale;
        vScale.Init(m_scale, m_scale, m_scale);

        LTVector vInterp;
        LTVector vInterpCur  = m_vPos;

        // Calculate interpolant for particle system

        if (GetProps()->m_nFallingStuffFXEmission)
        {
            vInterp = m_vPos - m_vLastPos;
            vInterp /= (float)GetProps()->m_nFallingStuffFXEmission;
        }

        for (uint32 i = 0; i < GetProps()->m_nFallingStuffFXEmission; i ++)
        {
            ocs.m_ObjectType		= OT_SPRITE;
            ocs.m_Flags				= FLAG_VISIBLE | FLAG_NOLIGHT | FLAG_ROTATABLESPRITE;

            // Compute the initial position

            float xRand = GetProps()->m_fRadius * ((-10000.0f + (rand() % 20000)) / 10000.0f);
            float zRand = GetProps()->m_fRadius * ((-10000.0f + (rand() % 20000)) / 10000.0f);

            ocs.m_Pos = m_vPos + (m_vRight * xRand) + (m_vUp * zRand);

            ocs.m_Scale				= vScale;
            strcpy(ocs.m_Filename, GetProps()->m_sSpriteName);

            // Move the start point

            vInterpCur += vInterp;

            HLOCALOBJ hNewSprite = m_pLTClient->CreateObject(&ocs);

            if (hNewSprite)
            {
                // Create a new sprite

                FALLING_THING *pNewSprite = debug_new( FALLING_THING );

                if (GetProps()->m_nImpactCreate)
                {
                    if (g_dwSplash > (uint32)GetProps()->m_nImpactCreate)
                    {
                        pNewSprite->m_bSplash = true;
                        g_dwSplash = 0;
                    }
                    else
                    {
                        pNewSprite->m_bSplash = false;
                    }
                }
                else
                {
                    pNewSprite->m_bSplash = false;
                }

                g_dwSplash ++;

                if (pNewSprite)
                {
                    LTVector v;

                    // Compute the initial velocity

                    v = m_vPlaneDir * GetProps()->m_fVel;

                    pNewSprite->m_hObject	= hNewSprite;
                    pNewSprite->m_vVel		= v;
                    pNewSprite->m_tmElapsed	= 0.0f;
                    pNewSprite->m_vPos		= ocs.m_Pos;
                    pNewSprite->m_vLastPos	= ocs.m_Pos;

                    m_collSprites.AddTail(pNewSprite);
                }
            }
        }

        m_tmElapsedEmission = 0.0f;

        // And store the last position

        m_vLastPos = m_vPos;
    }

    LTMatrix mSpin;

    if (GetProps()->m_bUseSpin)
    {
        // Setup rotation

        LTMatrix vRight;
        LTMatrix vUp;
        LTMatrix vForward;
        LTMatrix vTmp;

        Mat_SetupRot(&vRight, &m_vRight, m_xRot);
        Mat_SetupRot(&vUp, &m_vUp, m_yRot);
        Mat_SetupRot(&vForward, &m_vPlaneDir, m_zRot);

        MatMul(&vTmp, &vRight, &vUp);
        MatMul(&mSpin, &vTmp, &vForward);

        m_xRot += GetProps()->m_vRotAdd.x * tmFrameTime;
        m_yRot += GetProps()->m_vRotAdd.y * tmFrameTime;
        m_zRot += GetProps()->m_vRotAdd.z * tmFrameTime;
    }

    // Get the camera rotation

    LTRotation orient;
    m_pLTClient->GetObjectRotation(m_hCamera, &orient);

    LTRotation dRot(orient);

    LTVector vF = orient.Forward();

    float rot = (float)atan2(vF.x, vF.z);

    // Update the sprites....

    CLinkListNode<FALLING_THING *> *pNode = m_collSprites.GetHead();
    CLinkListNode<FALLING_THING *> *pDelNode;

    while (pNode)
    {
        pDelNode = NULL;

        FALLING_THING *pSprite = pNode->m_Data;

        //adjust our elapsed time
        pSprite->m_tmElapsed += tmFrameTime;

        // Check for expiration

        if (pSprite->m_tmElapsed > GetProps()->m_tmSpriteLifespan)
        {
            // Destroy this object

            m_pLTClient->RemoveObject(pSprite->m_hObject);

            pDelNode = pNode;
        }
        else
        {
            // Update !!

            pSprite->m_vLastPos = pSprite->m_vPos;

            pSprite->m_vPos += (pSprite->m_vVel * tmFrameTime);

            // Rotate if neccessary

            TVector3<float> vPos = pSprite->m_vPos;

            if (GetProps()->m_bUseSpin)
            {
                MatVMul_InPlace(&mSpin, &vPos);
            }

            // Add in wind

            vPos += (GetProps()->m_vWind * GetProps()->m_fWindAmount) * tmFrameTime;

            // Setup the new sprite position

            LTVector vPos2 = vPos;
            m_pLTClient->SetObjectPos(pSprite->m_hObject, &vPos2);


            // Setup the colour

            float r, g, b, a;

            m_pLTClient->GetObjectColor(pSprite->m_hObject, &r, &g, &b, &a);
            CalcColour(pSprite->m_tmElapsed, GetProps()->m_tmSpriteLifespan, &r, &g, &b, &a);
            m_pLTClient->SetObjectColor(pSprite->m_hObject, r, g, b, a);

            // Setup the scale

            float scale = 0.1f;

            CalcScale(pSprite->m_tmElapsed, GetProps()->m_tmSpriteLifespan, &scale);

            LTVector vScale;
            vScale.Init(scale, scale * GetProps()->m_fStretchMul, scale);
            m_pLTClient->SetObjectScale(pSprite->m_hObject, &vScale);

            // Setup the rotation

            dRot = LTRotation(0, 0, 0, 1);
            LTRotation orient(dRot);

            orient.Rotate( orient.Up(), rot );

            m_pLTClient->SetObjectRotation(pSprite->m_hObject, &orient);

            // Check to see if we need to start a splash sprite

            if (pSprite->m_bSplash)
            {
                ClientIntersectQuery ciq;
                ClientIntersectInfo  cii;

                ciq.m_From		= pSprite->m_vLastPos;
                ciq.m_To		= pSprite->m_vPos;

                if ((GetProps()->m_sImpactSpriteName[0]) && (m_pLTClient->IntersectSegment(&ciq, &cii)))
                {
                    // Create a splash sprite

                    SPLASH *pSplash = debug_new( SPLASH );

                    ObjectCreateStruct ocs;
                    INIT_OBJECTCREATESTRUCT(ocs);

                    LTVector vScale;
                    vScale.Init(0.0f, 0.0f, 0.0f);

                    ocs.m_ObjectType = OT_SPRITE;
                    ocs.m_Flags		 = FLAG_VISIBLE | FLAG_ROTATABLESPRITE | FLAG_NOLIGHT;
                    ocs.m_Pos		 = cii.m_Point + (cii.m_Plane.m_Normal * 2.0f);
                    ocs.m_Scale		 = vScale;

                    LTRotation dOrient( cii.m_Plane.m_Normal, LTVector(0.0f, 1.0f, 0.0f) );

                    strcpy(ocs.m_Filename, GetProps()->m_sImpactSpriteName);

                    pSplash->m_hObject = m_pLTClient->CreateObject(&ocs);
                    pSplash->m_scale = 0.0f;

                    LTRotation orient(dRot);
                    m_pLTClient->SetObjectRotation(pSplash->m_hObject, &orient);

                    pSplash->m_tmElapsed = 0.0f;

                    m_collSplashes.AddTail(pSplash);

                    // Destroy this object

                    m_pLTClient->RemoveObject(pSprite->m_hObject);

                    // Delete the sprite

                    pDelNode = pNode;
                }
            }
        }

        pNode = pNode->m_pNext;

        if (pDelNode) m_collSprites.Remove(pDelNode);
    }

    // Update our splashes

    CLinkListNode<SPLASH *> *pSplashNode = m_collSplashes.GetHead();

    while (pSplashNode)
    {
        CLinkListNode<SPLASH *> *pDelNode = NULL;

        SPLASH *pSplash = pSplashNode->m_Data;

        //update the elapsed time on the splash
        pSplash->m_tmElapsed += tmFrameTime;

        // Calculate the new scale

        float scale = GetProps()->m_fImpactScale1 + ((GetProps()->m_fImpactScale2 - GetProps()->m_fImpactScale1) * (pSplash->m_tmElapsed / GetProps()->m_tmImpactLifespan));

        LTVector vScale(scale, scale, scale);
        m_pLTClient->SetObjectScale(pSplash->m_hObject, &vScale);

        float r, g, b, a;

        m_pLTClient->GetObjectColor(pSplash->m_hObject, &r, &g, &b, &a);

        a = (float)(int)(pSplash->m_tmElapsed / GetProps()->m_tmImpactLifespan);
        if (a < 0.0f) a = 0.0f;
        if (a > 1.0f) a = 1.0f;

        m_pLTClient->SetObjectColor(pSplash->m_hObject, r, g, b, a);

        if (pSplash->m_tmElapsed > GetProps()->m_tmImpactLifespan)
        {
            m_pLTClient->RemoveObject(pSplash->m_hObject);
            pDelNode = pSplashNode;
        }

        pSplashNode = pSplashNode->m_pNext;

        if (pDelNode) m_collSplashes.Remove(pDelNode);
    }

    // Success !!

    return true;
}
void VideoGrabber::close()
{
	PWaitAndSignal lock ( mutex );
	run = false;
	if( IsSuspended() ) Resume();
}
Example #10
0
void dodeopall(struct user *user, char *tail)
{
  unsigned char flags;
  struct reggedchannel *chanptr;
  char *channel;

#if defined(HORRIBLE_DEOPALL_HACK) || defined(HAVE_CLEARMODE)
  char buf[512];
#endif /* HORRIBLE_DEOPALL_HACK */

  channel = tail;
  SeperateWord(tail);

  if (channel == NULL) {
    NoticeToUser(user, "Usage: deopall #channel");
    return;
  }

  if ((chanptr = GetChannelPointer(channel)) == NULL) {
    NoticeToUser(user, "Unknown channel %s.", channel);
    return;
  }

  flags = GetChannelFlags(user->authedas, chanptr);

  /* Check for MASTER or OWNER flag */
  if (!(flags & (CFLAG_MASTER | CFLAG_OWNER)) || IsSuspended(chanptr)) {
    /* No flags -- perhaps they are an oper? */
    if (!((user->oper) && (user->authedas->authlevel > 200))) {
      /* Nope, not an oper either */
      NoticeToUser(user, "Sorry, you need the +m or +n flag on %s to use deopall.", channel);
      return;
    }
  }

  /* Do the actual deopall */
  /* erm, how? */

/*
  sprintf(buf,"%s GL * +%s 0 :Clearing channel\r\n",my_numeric,channel);
  SendLine(buf);
*/

#ifdef HAVE_CLEARMODE
  sprintf(buf, "%sAAA CM %s o\r\n", my_numeric, channel);
  SendLine(buf);
  sprintf(buf, "%s M %s +o %sAAA\r\n", my_numeric, channel, my_numeric);
  SendLine(buf);
#else /* !HAVE_CLEARMODE */
# ifdef HORRIBLE_DEOPALL_HACK
  if (chanptr->timestamp > 0) {
    chanptr->timestamp--;
#  ifdef SIT_ON_CHANNELS
    /* If we're sitting on the channel, we can just rejoin it with a new timestamp... */
    if (IsJoined(chanptr)) {
      sprintf(buf, "%sAAA L %s\r\n", my_numeric, channel);
      SendLine(buf);
    }
    SetJoined(chanptr);
    sprintf(buf, "%s B %s %ld %sAAA:o\r\n", my_numeric, channel, chanptr->timestamp, my_numeric);
#  else /* !SIT_ON_CHANNELS */
    /* We're not sitting on the channel, so we send a burst with a _fake_ user */
    sprintf(buf, "%s B %s %ld %sAAB:o\r\n", my_numeric, channel, chanptr->timestamp, my_numeric);
#  endif /* SIT_ON_CHANNELS */
    SendLine(buf);
  } else {
    NoticeToUser(user, "Sorry, cannot deopall on %s at this time.", channel);
    return;
  }
# else /* !HORRIBLE_DEOPALL_HACK */
  if (NULL == Optr) {
    NoticeToUser(user, "Sorry, cannot deopall on %s at this time.", channel);
    return;
  } else {
    MessageToUser(Optr, "deopall -l %s", channel);
/*** This is no longer required
    MessageToUser(Optr, "opchan %s %s", channel, my_nick); */
  }
# endif /* HORRIBLE_DEOPALL_HACK */
#endif /* HAVE_CLEARMODE */

  Log("DeopAll: %s (%s) requested deopall in %s", user->nick, user->authedas->authname, channel);
  NoticeToUser(user, "Done.");
}
Example #11
0
void DoJoins(char *numeric, char *channellist, time_t timestamp)
{
  char *currentchan;
  char *nextchan = channellist;
  struct reggedchannel *chanptr;
  struct user *user_ptr;
  int automodes;

  /* Right then.  First up, let's see if it's 0 being joined here */
  /* If so, we need to do all the work of a part (i.e. nothing) for each channel */

  if (!strncmp(channellist, "0", 1))
    return;

  user_ptr = usertablepointer[getserverindex(numeric)][getclientindex(numeric)];

  while (*nextchan) {
    currentchan = nextchan;

    /* The next two blocks are going to turn currentchan into a pointer 
     * to a well-formed string.
     * nextchan will point to the first char of the next channel name, if any
     * or NULL if this is the last one */

    for (; *nextchan != ',' && *nextchan != '\0'; nextchan++);  /* Look for the next comma, or end of list */

    /* If we stopped on a comma, change to a NUL and advance nextchan
     * Otherwise, it was a NUL already, and we leave nextchan there so 
     * the loop will stop next time round */
    if (*nextchan == ',') {
      *nextchan = '\0';
      nextchan++;
    }

    chanptr = GetChannelPointer(currentchan);
    if (chanptr == NULL)        /* It's not a channel we care about, carry on with the next one */
      continue;

    if (IsSuspended(chanptr))   /* Same as above, we dont really care about this channel */
      continue;

    /* Check the timestamp */
    if (timestamp > 0)
      SyncTimestamp(chanptr, timestamp);

    if (chanptr->welcome)
      NoticeToUser(user_ptr, "[%s] %s", chanptr->channelname, chanptr->welcome);

    automodes = AutoModes(numeric, currentchan);

    /* Update lastused timestamp on channel if user is known on it. */
    if (automodes > 0) {
      chanptr->lastused = time(NULL);
    }

    switch (automodes) {

    case AUTOMODE_NOAUTOFLAGS:
      /* User is known, but shouldnt have voice nor op automatically. */
      /* Do the same as for AUTOMODE_NOTHING (it could be a voice user). */
    case AUTOMODE_NOTHING:
      /* It's a registered channel, which the user has no modes on */
      /* We need to deop them if it's a create */
      /* If the channel is inviteonly and it's a create, */
      /* then kick their ass if they're unknown. */
      /* We rely on the channel to be +i at all times after a createa */
      /* if we have inviteonly set as chanflag. */
      if (timestamp > 0) {
        if (!IsInviteOnly(chanptr)) { /* Channel is a normal channel */
          DeopUser(chanptr, numeric);
        } else {                /* Channel is invite only. */
          if (automodes == AUTOMODE_NOAUTOFLAGS) {
            DeopUser(chanptr, numeric); /* User has flags, so shouldnt be kicked. */
          } else {              /* Must be a AUTOMODE_NOTHING, so no flags, and therefore not known on the channel. */
            KickUser(chanptr, user_ptr->numeric, "Channel is invite only");
          }
        }
      }
      break;

    case AUTOMODE_OP:
      /* It's a registered channel, which the user has ops on */
      /* We need to op them if and only if it's NOT a create */

      if (timestamp == 0)
        OpUser(chanptr, numeric);
      else
        CheckJoined(chanptr);
      break;

    case AUTOMODE_VOICE:
      /* It's a registered channel, the user has autovoice */
      /* If it's a create, deop-and-voice, 
       * if it's a join, just voice */

      if (timestamp == 0) {
        VoiceUser(chanptr, numeric);
      } else {
        CheckJoined(chanptr);
        VoiceAndDeopUser(chanptr, numeric);
      }
      break;

    default:
      /* It's an unregistered channel, do nothing */
      /* Note that with the continue above we shouldn't get here any more */
      break;
    }
  }
}