Esempio n. 1
0
static void
setReadState (tr_handshake * handshake, handshake_state_t state)
{
  setState (handshake, state);
}
Esempio n. 2
0
File: c++.cpp Progetto: abbrev/xs
void StateChanger::onOff() {
  setState(1);
  sleep(1);
  setState(0);
  sleep(1);
}
Esempio n. 3
0
void PlayField::placeBoat()
{
  setState(BOAT);
}
Esempio n. 4
0
void UpdateStateRow::onDownloading(qint64 ready, qint64 total) {
	setState(State::Download);
	setDownloadProgress(ready, total);
}
Esempio n. 5
0
void UpdateStateRow::onFailed() {
	setState(State::Fail);
}
Esempio n. 6
0
void DetailsWidget::setExpanded(bool expanded)
{
    setState(expanded ? Expanded : Collapsed);
}
Esempio n. 7
0
void UpdateStateRow::onChecking() {
	setState(State::Check);
}
/*!
* Handle changes in RProperty values of keylock state and battery status.
* @param uid Category uid of the changed property.
* @param key Integer key of the changed property.
* @param value New value of the changed property.
*/
void CxuiApplicationFrameworkMonitorPrivate::handlePropertyEvent(long int uid, unsigned long int key, QVariant value)
{
    CX_DEBUG_ENTER_FUNCTION();

    if (uid == KPSUidAvkonDomain.iUid && key == KAknKeyguardStatus) {
        CX_DEBUG(("CxuiApplicationFrameworkMonitor - keylock status changed: %d -> %d", mKeyLockState, value.toInt()));

        // Check if the keylock value has actually changed
        const int newKeyLockState = value.toInt();
        if (newKeyLockState != mKeyLockState) {
            mKeyLockState = newKeyLockState;
            // Set foreground state based on keylock status and focused application info.
            setState(getCurrentState());
        }
    } else if (uid == KPSUidHWRMPowerState.iUid && key == KHWRMBatteryStatus ) {
        CX_DEBUG(("CxuiApplicationFrameworkMonitor - battery status changed: %d -> %d", mBatteryStatus, value.toInt() ));

        // If status changed, check if battery is going empty.
        const int newBatteryStatus = value.toInt();
        if (newBatteryStatus != mBatteryStatus) {
            mBatteryStatus = newBatteryStatus;

            // Notify that battery is almost empty,
            // need to stop any recordings etc.
            if(mBatteryStatus == EBatteryStatusEmpty) {
                emit q->batteryEmpty();
            }
        }
    } else if (uid == KPSUidUsbWatcher.iUid && key == KUsbWatcherSelectedPersonality) {
        CX_DEBUG(("CxuiApplicationFrameworkMonitor - usb personality changed: %d -> %d", mUsbPersonality, value.toInt()));

        const int newUsbPersonality(value.toInt());
        if (newUsbPersonality != mUsbPersonality) {
            // Check before saving the new state if mass memory mode was active,
            // so we know when to emit the unactivated signal.
            const bool wasUsbMassMemoryModeActive(isUsbMassMemoryModeActive());
            // Store new state.
            mUsbPersonality = newUsbPersonality;

            // Save state to log.
            if (mEventLog) {
                mEventLog->append(EVENT_USB, QString::number(mUsbPersonality));
            }

            // Check if mass memory mode activity changed.
            if (wasUsbMassMemoryModeActive != isUsbMassMemoryModeActive()) {

                // If the massmemory mode switched from on to off,
                // the signal is emitted immediately.
                // If the switch is from off to on, we need to use a timer
                // as a workaround because  plugging in the USB charger
                // sends a mass memory mode change event.
                if (wasUsbMassMemoryModeActive) {
                    emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive());
                } else {
                    // (Re)starting the timer
                    mUsbModeCheckTimer.stop();
                    mUsbModeCheckTimer.start();
                }

            }
        }
    } else if (uid == TsProperty::KCategory.iUid && key == TsProperty::KVisibilityKey) {
        CX_DEBUG(("CxuiApplicationFrameworkMonitor - Task Manager visibility: %d -> %d", mTaskManagerVisibility, value.toBool()));
        const bool newTsVisibility(value.toBool());

        // If the task switcher state is changed, then emit signal to inform client(s).
        if (mTaskManagerVisibility != newTsVisibility) {
            mTaskManagerVisibility = newTsVisibility;
            emit q->taskSwitcherStateChanged(mTaskManagerVisibility);
        }
    }

    CX_DEBUG_EXIT_FUNCTION();
}
 inline void bind() { setState(STATE_GRAPHICS_BOUND); }
Esempio n. 10
0
static int
readIA (tr_handshake    * handshake,
        struct evbuffer * inbuf)
{
  const size_t needlen = handshake->ia_len;
  struct evbuffer * outbuf;
  uint32_t crypto_select;

  dbgmsg (handshake, "reading IA... have %zu, need %zu",
          evbuffer_get_length (inbuf), needlen);
  if (evbuffer_get_length (inbuf) < needlen)
    return READ_LATER;

  /**
  ***  B->A: ENCRYPT (VC, crypto_select, len (padD), padD), ENCRYPT2 (Payload Stream)
  **/

  tr_cryptoEncryptInit (handshake->crypto);
  outbuf = evbuffer_new ();

  {
    /* send VC */
    uint8_t vc[VC_LENGTH];
    memset (vc, 0, VC_LENGTH);
    evbuffer_add (outbuf, vc, VC_LENGTH);
    dbgmsg (handshake, "sending vc");
  }

  /* send crypto_select */
  crypto_select = getCryptoSelect (handshake, handshake->crypto_provide);
  if (crypto_select)
    {
      dbgmsg (handshake, "selecting crypto mode '%d'", (int)crypto_select);
      evbuffer_add_uint32 (outbuf, crypto_select);
    }
  else
    {
      dbgmsg (handshake, "peer didn't offer an encryption mode we like.");
      evbuffer_free (outbuf);
      return tr_handshakeDone (handshake, false);
    }

  dbgmsg (handshake, "sending pad d");
  /* ENCRYPT (VC, crypto_provide, len (PadD), PadD
   * PadD is reserved for future extensions to the handshake...
   * standard practice at this time is for it to be zero-length */
  {
    const uint16_t len = 0;
    evbuffer_add_uint16 (outbuf, len);
  }

  /* maybe de-encrypt our connection */
  if (crypto_select == CRYPTO_PROVIDE_PLAINTEXT)
    {
      tr_peerIoWriteBuf (handshake->io, outbuf, false);
      tr_peerIoSetEncryption (handshake->io, PEER_ENCRYPTION_NONE);
    }

  dbgmsg (handshake, "sending handshake");
  /* send our handshake */
  {
    uint8_t msg[HANDSHAKE_SIZE];
    if (!buildHandshakeMessage (handshake, msg))
      return tr_handshakeDone (handshake, false);

    evbuffer_add (outbuf, msg, sizeof (msg));
    handshake->haveSentBitTorrentHandshake = 1;
  }

  /* send it out */
  tr_peerIoWriteBuf (handshake->io, outbuf, false);
  evbuffer_free (outbuf);

  /* now await the handshake */
  setState (handshake, AWAITING_PAYLOAD_STREAM);
  return READ_NOW;
}
Esempio n. 11
0
void VtolBrakeFSM::Activate()
{
    memset(mBrakeData, 0, sizeof(VtolBrakeFSMData_T));
    mBrakeData->currentState = BRAKE_STATE_INACTIVE;
    setState(BRAKE_STATE_BRAKE, FSMBRAKESTATUS_STATEEXITREASON_NONE);
}
Esempio n. 12
0
static int
readCryptoProvide (tr_handshake    * handshake,
                   struct evbuffer * inbuf)
{
  /* HASH ('req2', SKEY) xor HASH ('req3', S), ENCRYPT (VC, crypto_provide, len (PadC)) */

  int i;
  uint8_t vc_in[VC_LENGTH];
  uint8_t req2[SHA_DIGEST_LENGTH];
  uint8_t req3[SHA_DIGEST_LENGTH];
  uint8_t obfuscatedTorrentHash[SHA_DIGEST_LENGTH];
  uint16_t padc_len = 0;
  uint32_t crypto_provide = 0;
  tr_torrent * tor;
  const size_t needlen = SHA_DIGEST_LENGTH /* HASH ('req1',s) */
                       + SHA_DIGEST_LENGTH /* HASH ('req2', SKEY) xor HASH ('req3', S) */
                       + VC_LENGTH
                       + sizeof (crypto_provide)
                       + sizeof (padc_len);

  if (evbuffer_get_length (inbuf) < needlen)
    return READ_LATER;

  /* TODO: confirm they sent HASH ('req1',S) here? */
  evbuffer_drain (inbuf, SHA_DIGEST_LENGTH);

  /* This next piece is HASH ('req2', SKEY) xor HASH ('req3', S) ...
   * we can get the first half of that (the obufscatedTorrentHash)
   * by building the latter and xor'ing it with what the peer sent us */
  dbgmsg (handshake, "reading obfuscated torrent hash...");
  evbuffer_remove (inbuf, req2, SHA_DIGEST_LENGTH);
  tr_sha1 (req3, "req3", 4, handshake->mySecret, KEY_LEN, NULL);
  for (i=0; i<SHA_DIGEST_LENGTH; ++i)
    obfuscatedTorrentHash[i] = req2[i] ^ req3[i];
  if ((tor = tr_torrentFindFromObfuscatedHash (handshake->session, obfuscatedTorrentHash)))
    {
      const bool clientIsSeed = tr_torrentIsSeed (tor);
      const bool peerIsSeed = tr_peerMgrPeerIsSeed (tor, tr_peerIoGetAddress (handshake->io, NULL));
      dbgmsg (handshake, "got INCOMING connection's encrypted handshake for torrent [%s]", tr_torrentName (tor));
      tr_peerIoSetTorrentHash (handshake->io, tor->info.hash);

      if (clientIsSeed && peerIsSeed)
        {
          dbgmsg (handshake, "another seed tried to reconnect to us!");
          return tr_handshakeDone (handshake, false);
        }
    }
  else
    {
      dbgmsg (handshake, "can't find that torrent...");
      return tr_handshakeDone (handshake, false);
    }

  /* next part: ENCRYPT (VC, crypto_provide, len (PadC), */

  tr_cryptoDecryptInit (handshake->crypto);

  tr_peerIoReadBytes (handshake->io, inbuf, vc_in, VC_LENGTH);

  tr_peerIoReadUint32 (handshake->io, inbuf, &crypto_provide);
  handshake->crypto_provide = crypto_provide;
  dbgmsg (handshake, "crypto_provide is %d", (int)crypto_provide);

  tr_peerIoReadUint16 (handshake->io, inbuf, &padc_len);
  dbgmsg (handshake, "padc is %d", (int)padc_len);
  handshake->pad_c_len = padc_len;
  setState (handshake, AWAITING_PAD_C);
  return READ_NOW;
}
Esempio n. 13
0
static int
readHandshake (tr_handshake    * handshake,
               struct evbuffer * inbuf)
{
  uint8_t pstrlen;
  uint8_t pstr[20];
  uint8_t reserved[HANDSHAKE_FLAGS_LEN];
  uint8_t hash[SHA_DIGEST_LENGTH];

  dbgmsg (handshake, "payload: need %d, got %zu",
          INCOMING_HANDSHAKE_LEN, evbuffer_get_length (inbuf));

  if (evbuffer_get_length (inbuf) < INCOMING_HANDSHAKE_LEN)
    return READ_LATER;

  handshake->haveReadAnythingFromPeer = true;

  pstrlen = evbuffer_pullup (inbuf, 1)[0]; /* peek, don't read. We may be
                                              handing inbuf to AWAITING_YA */

  if (pstrlen == 19) /* unencrypted */
    {
      tr_peerIoSetEncryption (handshake->io, PEER_ENCRYPTION_NONE);

      if (handshake->encryptionMode == TR_ENCRYPTION_REQUIRED)
        {
          dbgmsg (handshake, "peer is unencrypted, and we're disallowing that");
          return tr_handshakeDone (handshake, false);
        }
    }
  else /* encrypted or corrupt */
    {
      tr_peerIoSetEncryption (handshake->io, PEER_ENCRYPTION_RC4);

      if (tr_peerIoIsIncoming (handshake->io))
        {
          dbgmsg (handshake, "I think peer is sending us an encrypted handshake...");
          setState (handshake, AWAITING_YA);
          return READ_NOW;
        }

      tr_cryptoDecrypt (handshake->crypto, 1, &pstrlen, &pstrlen);

      if (pstrlen != 19)
        {
          dbgmsg (handshake, "I think peer has sent us a corrupt handshake...");
          return tr_handshakeDone (handshake, false);
        }
    }

  evbuffer_drain (inbuf, 1);

  /* pstr (BitTorrent) */
  assert (pstrlen == 19);
  tr_peerIoReadBytes (handshake->io, inbuf, pstr, pstrlen);
  pstr[pstrlen] = '\0';
  if (memcmp (pstr, "BitTorrent protocol", 19))
    return tr_handshakeDone (handshake, false);

  /* reserved bytes */
  tr_peerIoReadBytes (handshake->io, inbuf, reserved, sizeof (reserved));

  /**
  *** Extensions
  **/

  tr_peerIoEnableDHT  (handshake->io, HANDSHAKE_HAS_DHT     (reserved));
  tr_peerIoEnableLTEP (handshake->io, HANDSHAKE_HAS_LTEP    (reserved));
  tr_peerIoEnableFEXT (handshake->io, HANDSHAKE_HAS_FASTEXT (reserved));

  /* torrent hash */
  tr_peerIoReadBytes (handshake->io, inbuf, hash, sizeof (hash));
  if (tr_peerIoIsIncoming (handshake->io))
    {
      if (!tr_torrentExists (handshake->session, hash))
        {
          dbgmsg (handshake, "peer is trying to connect to us for a torrent we don't have.");
          return tr_handshakeDone (handshake, false);
        }
      else
        {
          assert (!tr_peerIoHasTorrentHash (handshake->io));
          tr_peerIoSetTorrentHash (handshake->io, hash);
        }
    }
  else /* outgoing */
    {
      assert (tr_peerIoHasTorrentHash (handshake->io));

      if (memcmp (hash, tr_peerIoGetTorrentHash (handshake->io), SHA_DIGEST_LENGTH))
        {
          dbgmsg (handshake, "peer returned the wrong hash. wtf?");
          return tr_handshakeDone (handshake, false);
        }
    }

  /**
  ***  If it's an incoming message, we need to send a response handshake
  **/

  if (!handshake->haveSentBitTorrentHandshake)
    {
      uint8_t msg[HANDSHAKE_SIZE];
      if (!buildHandshakeMessage (handshake, msg))
        return tr_handshakeDone (handshake, false);
      tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
      handshake->haveSentBitTorrentHandshake = 1;
    }

  setReadState (handshake, AWAITING_PEER_ID);
  return READ_NOW;
}
Esempio n. 14
0
static int
readYb (tr_handshake * handshake, struct evbuffer * inbuf)
{
  int isEncrypted;
  const uint8_t * secret;
  uint8_t yb[KEY_LEN];
  struct evbuffer * outbuf;
  size_t needlen = HANDSHAKE_NAME_LEN;

  if (evbuffer_get_length (inbuf) < needlen)
    return READ_LATER;

  isEncrypted = memcmp (evbuffer_pullup (inbuf, HANDSHAKE_NAME_LEN), HANDSHAKE_NAME, HANDSHAKE_NAME_LEN);
  if (isEncrypted)
    {
      needlen = KEY_LEN;

      if (evbuffer_get_length (inbuf) < needlen)
        return READ_LATER;
    }

  dbgmsg (handshake, "got an %s handshake", (isEncrypted ? "encrypted" : "plain"));

  tr_peerIoSetEncryption (handshake->io, isEncrypted ? PEER_ENCRYPTION_RC4
                                                     : PEER_ENCRYPTION_NONE);
  if (!isEncrypted)
    {
      setState (handshake, AWAITING_HANDSHAKE);
      return READ_NOW;
    }

  handshake->haveReadAnythingFromPeer = true;

  /* compute the secret */
  evbuffer_remove (inbuf, yb, KEY_LEN);
  secret = tr_cryptoComputeSecret (handshake->crypto, yb);
  memcpy (handshake->mySecret, secret, KEY_LEN);

  /* now send these: HASH ('req1', S), HASH ('req2', SKEY) xor HASH ('req3', S),
   * ENCRYPT (VC, crypto_provide, len (PadC), PadC, len (IA)), ENCRYPT (IA) */
  outbuf = evbuffer_new ();

  /* HASH ('req1', S) */
  {
    uint8_t req1[SHA_DIGEST_LENGTH];
    tr_sha1 (req1, "req1", 4, secret, KEY_LEN, NULL);
    evbuffer_add (outbuf, req1, SHA_DIGEST_LENGTH);
  }

  /* HASH ('req2', SKEY) xor HASH ('req3', S) */
  {
    int i;
    uint8_t req2[SHA_DIGEST_LENGTH];
    uint8_t req3[SHA_DIGEST_LENGTH];
    uint8_t buf[SHA_DIGEST_LENGTH];

    tr_sha1 (req2, "req2", 4, tr_cryptoGetTorrentHash (handshake->crypto), SHA_DIGEST_LENGTH, NULL);
    tr_sha1 (req3, "req3", 4, secret, KEY_LEN, NULL);

    for (i=0; i<SHA_DIGEST_LENGTH; ++i)
      buf[i] = req2[i] ^ req3[i];

    evbuffer_add (outbuf, buf, SHA_DIGEST_LENGTH);
  }

  /* ENCRYPT (VC, crypto_provide, len (PadC), PadC
   * PadC is reserved for future extensions to the handshake...
   * standard practice at this time is for it to be zero-length */
  {
    uint8_t vc[VC_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0 };

    tr_peerIoWriteBuf (handshake->io, outbuf, false);
    tr_cryptoEncryptInit (handshake->crypto);
    tr_peerIoSetEncryption (handshake->io, PEER_ENCRYPTION_RC4);

    evbuffer_add        (outbuf, vc, VC_LENGTH);
    evbuffer_add_uint32 (outbuf, getCryptoProvide (handshake));
    evbuffer_add_uint16 (outbuf, 0);
  }

  /* ENCRYPT len (IA)), ENCRYPT (IA) */
  {
    uint8_t msg[HANDSHAKE_SIZE];
    if (!buildHandshakeMessage (handshake, msg))
      return tr_handshakeDone (handshake, false);

    evbuffer_add_uint16 (outbuf, sizeof (msg));
    evbuffer_add        (outbuf, msg, sizeof (msg));

    handshake->haveSentBitTorrentHandshake = 1;
  }

  /* send it */
  tr_cryptoDecryptInit (handshake->crypto);
  setReadState (handshake, AWAITING_VC);
  tr_peerIoWriteBuf (handshake->io, outbuf, false);

  /* cleanup */
  evbuffer_free (outbuf);
  return READ_LATER;
}
Esempio n. 15
0
	void Button::updateButtonState()
	{
		if (mIsStateCheck) {
			if (!mEnabled) { if (!setState("disabled_checked")) setState("disabled"); }
			else if (mIsMousePressed) { if (!setState("pushed_checked")) setState("pushed"); }
			else if (mIsMouseFocus) { if (!setState("highlighted_checked")) setState("pushed"); }
			else setState("normal_checked");
		}
		else {
			if (!mEnabled) setState("disabled");
			else if (mIsMousePressed) setState("pushed");
			else if (mIsMouseFocus) setState("highlighted");
			else setState("normal");
		}
	}
 inline void connect() { setState(STATE_CUDA_MAPPED); }
Esempio n. 17
0
	void Player::logic(Room *room)
	{
		//std::cout << "HP:" << getHealth() << " MP:" << getMana() << "/" << getMaximumMana() << " Couter:" << mRegenerateManaCounter << std::endl;
		mStateCounter++;		

		if (mInvincibleCounter > 0) {
			mInvincibleCounter--;
		}

		if (getState() == DEAD) {
			return;
		}

		regenerateMana();
		
		const KeyState &keys = room->getKeyState();
		TileMap *tileMap = room->getTileMap();

		bool onIce = isOnIce(tileMap);

		int acceleration = AIR_ACCELERATION;
		if (getState() == GROUND) {
			if (onIce) {
				acceleration = ICE_ACCELERATION;
			} else {
				acceleration = GROUND_ACCELERATION;
			}
		}

		if (keys.isLeftHeld() && !keys.isRightHeld() && !mHurt) {
			mDX -= acceleration;
			if (mDX < -RUN_SPEED) {
				mDX = -RUN_SPEED;
			}
			mRunFrame += onIce && mDX > -20 ? 3 : 2;
			mFacingLeft = true;
			mRunning = true;
		} else if (!keys.isLeftHeld() && keys.isRightHeld() && !mHurt) {
			mDX += acceleration;
			if (mDX > RUN_SPEED) {
				mDX = RUN_SPEED;
			}
			mRunFrame += onIce && mDX < 20 ? 3 : 2;
			mFacingLeft = false;
			mRunning = true;
		} else if (mDX > 0 && !mHurt) {
			mDX -= onIce ? 1 : 4;
			if (mDX < 0) {
				mDX = 0;
			}
			mRunning = false;
		} else if (mDX < 0 && !mHurt) {
			mDX += onIce ? 1 : 4;
			if (mDX > 0) {
				mDX = 0;
			}
			mRunning = false;
		} else {
			mRunning = false;
		}

		// Crouching
		if (!mRunning && keys.isDownHeld() && getState() == GROUND) {
			if (!mCrouching) {
				mCrouching = true;
				mY += CROUCH_SHRINK;
				mH -= CROUCH_SHRINK;
			}
		} else if (mCrouching) {
			mCrouching = false;
			mY -= CROUCH_SHRINK;
			mH += CROUCH_SHRINK;
		}
		

		if (mDX == 0 || getState() != GROUND) {
			mRunFrame = 0;
		}

		// Interrupting jumping
		if (!keys.isJumpHeld() && getState() == AIR_UP && mDY > JUMP_CONTROL && !mHurt) {
			mDY = JUMP_CONTROL;
		}

		if (!keys.isJumpHeld() && (getState() == AIR_UP || getState() == AIR_DOWN)) {
			mJumpKeyHeld = false;
		}

		// Jumping
		if (keys.isJumpPressed() && getState() == GROUND && !keys.isDownHeld()) {
			mDY = JUMP_STRENGTH;
			setState(AIR_UP);
			mJumpKeyHeld = true;
			mJumpY = getCenterY();
		}
		// Drop off platform
		if (keys.isJumpPressed() && mOnPlatform && keys.isDownHeld()) {
			mDY = 1;
			mY++;
			setState(AIR_DOWN);
			mJumpKeyHeld = true;
			mJumpY = getCenterY();
		}

		// Sideways movement
		if (onIce) {
			if (mDX < 0) {
				mX += (mDX - 7) / 8;
			} else {
				mX += (mDX + 7) / 8;
			}
		} else {
			mX += mDX / 8;
		}
		

		// Left Wall
        int solidLeftOffset;
		if (mDX < 0 && solidLeft(room, solidLeftOffset)) 
        {
			// Align player to solid object
			mX += solidLeftOffset;
            
            mDX = 0;
		}

		// Right Wall
        int solidRightOffset;
		if (mDX > 0 && solidRight(room, solidRightOffset)) 
        {
			// Align player to solid object
			mX -= solidRightOffset;
			mDX = 0;
		}

		// Vertical movement
		if (getState() == AIR_DOWN) {
			mY += mDY > MAX_AIR_SPEED ? MAX_AIR_SPEED : mDY;
		} else if (getState() == AIR_UP) {
			mY -= mDY > MAX_AIR_SPEED ? MAX_AIR_SPEED : mDY;
		}

		// Falling, acceleration
		if (getState() == AIR_DOWN) {
			mDY += 1;
		}

		// Raising, deacceleration
		if (getState() == AIR_UP) {
			mDY--;
			if (mDY < 0) {
				setState(AIR_DOWN);
				mDY = 0;
			}
		}

		// Ceiling bouncing
        int solidAboveOffset;
		if (getState() == AIR_UP && solidAbove(room, solidAboveOffset)) 
        {
			setState(AIR_DOWN);
			mDY = 0;
			// Align player to solid object
			mY += solidAboveOffset;
		}

		// Ground bouncing / landing
        int groundOffset;
		if (getState() == AIR_DOWN && isOnGround(room, groundOffset)) {
			if (keys.isJumpHeld() && !mJumpKeyHeld && !keys.isDownHeld()) {
				// Rejump
				mDY = JUMP_STRENGTH;
				setState(AIR_UP);
				mJumpKeyHeld = true;
			} else {
				// Land
				setState(GROUND);
				mDY = 0;				
			}
			mHurt = false;

			// Align to tile
			mY -= groundOffset;
			mJumpY = getCenterY();
		}

		// Falling
        int fallingOffset;
		if (getState() == GROUND && !isOnGround(room, fallingOffset)) {
			setState(AIR_DOWN);
			mDY = 0;
		}

		// Shooting
		if (keys.isFirePressed())	{
			if (mShotCounter >= SHOT_DELAY) {
				mShotCounter = 0;
				room->addEntity(createShot());
				mShootAfterDelay = false;
			} else {
				mShootAfterDelay = true;
			}
		}
		if (mShotCounter >= SHOT_DELAY && mShootAfterDelay) {
			mShotCounter = 0;
			room->addEntity(createShot());
			mShootAfterDelay = false;
		}
		
		mShotCounter++;


		if (keys.isSpecialPressed()) 
        {
		    if (mShotType == NORMAL)
            {
                mShotType = ICE;
            }
            else if (mShotType == ICE)
            {
                mShotType = FIRE;
            }
            else
            {
                mShotType = NORMAL;
            }
        }
	}
 inline void disconnect() { setState(STATE_UNUSED); }
Esempio n. 19
0
    connect(_mediaPlayer->osd(), SIGNAL(playClicked()), ui->actionPlay, SLOT(trigger()));
    connect(_mediaPlayer->osd(), SIGNAL(recordNowClicked()), ui->actionRecordNow, SLOT(trigger()));
    connect(_mediaPlayer->osd(), SIGNAL(snapshotClicked()), ui->actionSnapshot, SLOT(trigger()));
    connect(_mediaPlayer->osd(), SIGNAL(stopClicked()), ui->actionStop, SLOT(trigger()));

    connect(_xmltv, SIGNAL(current(QStringList)), _mediaPlayer->osd(), SLOT(setEpg(QStringList)));
    connect(_xmltv, SIGNAL(schedule(QString, XmltvProgrammeModel *)), _scheduleTab, SLOT(setEpg(QString, XmltvProgrammeModel *)));
    connect(_scheduleTab, SIGNAL(requestEpg(QString)), _xmltv, SLOT(request(QString)));
    connect(_scheduleTab, SIGNAL(itemSelected(QString)), _xmltv, SLOT(requestProgramme(QString)));
    connect(_xmltv, SIGNAL(programme(XmltvProgramme *)), _showInfoTab, SLOT(display(XmltvProgramme *)));
    connect(_mediaPlayer->osd(), SIGNAL(openLink(QString)), _xmltv, SLOT(requestProgramme(QString)));
    connect(_showInfoTab, SIGNAL(requestNext(QString, QString)), _xmltv, SLOT(requestProgrammeNext(QString, QString)));
    connect(_showInfoTab, SIGNAL(requestPrevious(QString, QString)), _xmltv, SLOT(requestProgrammePrevious(QString, QString)));
    connect(_playlistTab->playlist(), SIGNAL(scheduleRequested(Channel *)), _scheduleTab, SLOT(channel(Channel *)));

    connect(_mediaPlayer, SIGNAL(stateChanged(Vlc::State)), this, SLOT(setState(Vlc::State)));
    connect(_mediaPlayer, SIGNAL(vout(int)), this, SLOT(showVideo(int)));
    connect(_mediaPlayer, SIGNAL(sessionChannel(int)), _playlistTab->playlist(), SLOT(channelSelected(int)));

    connect(ui->actionRecorder, SIGNAL(triggered(bool)), this, SLOT(showRecorder()));
    connect(ui->actionRecordNow, SIGNAL(toggled(bool)), this, SLOT(recordNow(bool)));
    connect(ui->actionSnapshot, SIGNAL(triggered()), _mediaPlayer, SLOT(takeSnapshot()));

    connect(_showInfoTab, SIGNAL(requestRecord(QString)), _xmltv, SLOT(requestProgrammeRecord(QString)));
    connect(_scheduleTab, SIGNAL(requestRecord(QString)), _xmltv, SLOT(requestProgrammeRecord(QString)));
    connect(_xmltv, SIGNAL(programmeRecord(XmltvProgramme *)), this, SLOT(recordProgramme(XmltvProgramme *)));

    connect(ui->actionRecordQuick, SIGNAL(triggered()), _recorder, SLOT(quickRecord()));
    connect(ui->actionRecordTimer, SIGNAL(triggered()), _recorder, SLOT(newTimer()));
    connect(_recorder, SIGNAL(play(Timer *)), this, SLOT(playRecording(Timer *)));
 virtual ~Resource()
 {
   setState(STATE_UNUSED);
 }
Esempio n. 21
0
void UpdateStateRow::onLatest() {
	setState(State::Latest);
}
Esempio n. 22
0
void EntityTypeCase::_setState(bool state)
{
  setState(state);
}
Esempio n. 23
0
void UpdateStateRow::onReady() {
	setState(State::Ready);
}
void QmlProfilerModelManager::prepareForWriting()
{
    setState(QmlProfilerDataState::AcquiringData);
}
Esempio n. 25
0
void updateBattle(int key)
{
	if(inBattle && !battleDialogue)
	{
		switch(key)
		{
			case KEY_UP:
				if(batOptIndex > BAT_ATTACK) batOptIndex--;
				break;
			case KEY_DOWN:
				if(batOptIndex < BAT_FLEE) batOptIndex++;
				break;
			case KEY_LEFT:
				if(batOptIndex > BAT_DEFEND) batOptIndex -=2;
				break;
			case KEY_RIGHT:
				if(batOptIndex < BAT_ITEMS) batOptIndex +=2;
				break;
			case 'z':
				chooseBatOption();
				break;
			case 'x':
				setState(GAME);
				break;
			default:
				break;
		}
	}
	else if(inBattle && battleDialogue)
	{
		switch(key)
		{
			case 'z':
			case 'x':
				if(battleDialogue == BAT_VICTORY)
				{
					chad.experience += currEnemy.experience;
					chad.money += currEnemy.money;
					if(chad.level < calcLevel(chad.experience))
					{
						chad.level = calcLevel(chad.experience);
						chad.maxhp = chad.hp = calcHP(chad.level);
						battleDialogue = BAT_LVL_UP;
					}
					else
					{
						setState(getPrevState());
						battleDialogue = 0;
					}
				} 
				else if(battleDialogue == BAT_LVL_UP)
				{
					setState(getPrevState());
					battleDialogue = 0;
				} 
				else battleDialogue = 0;
				break;
			default: 
				break;
		}
	}
	else
	{
		setState(getPrevState());
	}
}
Esempio n. 26
0
void InitNodes(CO_Data* d, UNS32 id)
{
    setNodeId(&master_Data,0x7f);
    setState(&master_Data, Initialisation);
    setState(&master_Data, Operational);
}
Esempio n. 27
0
WINNER Board::checkResult() {
	int res_x = 0;
	int res_o = 0;
	int x = 0;
	int y = 0;
	bool free = false;
	State s = State::END_OF_STATES;
	for (y = 0; y <= MAX_Y_CORDINATE; ++y) {
		for (x = 0; x <= MAX_X_CORDINATE; ++x) {
			s = getState(x, y);
			if (s == State::CIRCLE_OFF || s == State::CIRCLE_ON)
				++res_o;
			else if (s == State::CROSS_OFF || s == State::CROSS_ON)
				++res_x;
		}
		if (x > MAX_X_CORDINATE) --x;
		if (res_x == xFieldsNum) {
			setState(x, y, State::CROSS_ON);
			setState(x - 1, y, State::CROSS_ON);
			setState(x - 2, y, State::CROSS_ON);
			return WINNER::PLUS;
		}
		else if (res_o == xFieldsNum) {
			setState(x, y, State::CIRCLE_ON);
			setState(x - 1, y, State::CIRCLE_ON);
			setState(x - 2, y, State::CIRCLE_ON);
			return WINNER::CIRC;
		}
		res_o = res_x = 0;
	}
	res_x = res_o = x = y = 0;
	for (y = 0; y <= MAX_Y_CORDINATE; ++y) {
		for (x = 0; x <= MAX_X_CORDINATE; ++x) {
			s = getState(y, x);
			if (s == State::CIRCLE_OFF || s == State::CIRCLE_ON)
				++res_o;
			else if (s == State::CROSS_OFF || s == State::CROSS_ON)
				++res_x;
			else
				free = true;
		}
		if (x > MAX_X_CORDINATE) --x;
		if (res_x == xFieldsNum) {
			setState(y, x, State::CROSS_ON);
			setState(y, x - 1, State::CROSS_ON);
			setState(y, x - 2, State::CROSS_ON);
			return WINNER::PLUS;
		}
		else if (res_o == xFieldsNum) {
			setState(y, x, State::CIRCLE_ON);
			setState(y, x - 1, State::CIRCLE_ON);
			setState(y, x - 2, State::CIRCLE_ON);
			return WINNER::CIRC;
		}
		res_o = res_x = 0;
	}
	res_o = res_x = 0;
	for (x = 0; x <= MAX_X_CORDINATE; ++x) {
		State s = getState(x, x);
		if (s == State::CIRCLE_OFF || s == State::CIRCLE_ON)
			res_o++;
		else if (s == State::CROSS_OFF || s == State::CROSS_ON)
			res_x++;
	}
	if (x > MAX_X_CORDINATE) --x;
	if (res_x == xFieldsNum) {
		setState(x, x, State::CROSS_ON);
		setState(x - 1, x - 1, State::CROSS_ON);
		setState(x - 2, x - 2, State::CROSS_ON);
		return WINNER::PLUS;
	}
	else if (res_o == xFieldsNum) {
		setState(x, x, State::CIRCLE_ON);
		setState(x - 1, x - 1, State::CIRCLE_ON);
		setState(x - 2, x - 2, State::CIRCLE_ON);
		return WINNER::CIRC;
	}

	res_x = res_o = 0;
	if ((getState(2, 0) == State::CIRCLE_ON ||
		getState(2, 0) == State::CIRCLE_OFF) &&
		(getState(1, 1) == State::CIRCLE_ON ||
			getState(1, 1) == State::CIRCLE_OFF) &&
		(getState(0, 2) == State::CIRCLE_ON ||
			getState(0, 2) == State::CIRCLE_OFF)) {
		setState(2, 0, State::CIRCLE_ON);
		setState(1, 1, State::CIRCLE_ON);
		setState(0, 2, State::CIRCLE_ON);
		return WINNER::CIRC;
	}
	else if ((getState(2, 0) == State::CROSS_ON ||
		getState(2, 0) == State::CROSS_OFF) &&
		(getState(1, 1) == State::CROSS_ON ||
			getState(1, 1) == State::CROSS_OFF) &&
		(getState(0, 2) == State::CROSS_ON ||
			getState(0, 2) == State::CROSS_OFF)) {
		setState(2, 0, State::CROSS_ON);
		setState(1, 1, State::CROSS_ON);
		setState(0, 2, State::CROSS_ON);
		return WINNER::PLUS;
	}
	if (free)
		return WINNER::NOT_FINISHED;
	else
		return WINNER::NONE;
}
Esempio n. 28
0
void Exit(CO_Data* d, UNS32 id)
{
//    masterSendNMTstateChange (&master_Data, 0x01, NMT_Stop_Node);
    setState(&master_Data, Stopped);
}
Esempio n. 29
0
void QSanSkillButton::setSkill(const Skill* skill)
{
     Q_ASSERT(skill != NULL);
     _m_skill = skill;
     // This is a nasty trick because the server side decides to choose a nasty design
     // such that sometimes the actual viewas skill is nested inside a trigger skill.
     // Since the trigger skill is not relevant, we flatten it before we create the button.
     _m_viewAsSkill = ViewAsSkill::parseViewAsSkill(_m_skill);
     if (skill == NULL) skill = _m_skill;

     Skill::Frequency freq = skill->getFrequency();
     if (freq == Skill::Frequent || (freq == Skill::NotFrequent &&
         skill->inherits("TriggerSkill") && !skill->inherits("WeaponSkill")
         && !skill->inherits("ArmorSkill") && _m_viewAsSkill == NULL)) {            
         setStyle(QSanButton::S_STYLE_TOGGLE);
         if (freq == Skill::Frequent)
            setState(QSanButton::S_STATE_DOWN);
         else
            setState(QSanButton::S_STATE_UP);
         _setSkillType(QSanInvokeSkillButton::S_SKILL_FREQUENT);
         _m_emitActivateSignal = false;
         _m_emitDeactivateSignal = false;
         _m_canEnable = true;
         _m_canDisable = false;
     } else if (freq == Skill::Limited || freq == Skill::NotFrequent) {
         setState(QSanButton::S_STATE_DISABLED);            
         if (freq == Skill::Limited)
             _setSkillType(QSanInvokeSkillButton::S_SKILL_ONEOFF_SPELL);
         else
             _setSkillType(QSanInvokeSkillButton::S_SKILL_PROACTIVE);

         setStyle(QSanButton::S_STYLE_TOGGLE);

         _m_emitDeactivateSignal = true;

         _m_emitActivateSignal = true;
         _m_canEnable = true;
         _m_canDisable = true;
     } else if (freq == Skill::Wake) {
         setState(QSanButton::S_STATE_DISABLED);
         setStyle(QSanButton::S_STYLE_PUSH);
         _setSkillType(QSanInvokeSkillButton::S_SKILL_AWAKEN);
         _m_emitActivateSignal = false;
         _m_emitDeactivateSignal = false;
         _m_canEnable = true;
         _m_canDisable = true;
     } else if (freq == Skill::Compulsory) {
         setState(QSanButton::S_STATE_DISABLED);
         setStyle(QSanButton::S_STYLE_PUSH);
         _setSkillType(QSanInvokeSkillButton::S_SKILL_COMPULSORY);
         _m_emitActivateSignal = false;
         _m_emitDeactivateSignal = false;
         _m_canEnable = false;
         _m_canDisable = true;
     } else Q_ASSERT(false);
     setToolTip(skill->getDescription());

     Q_ASSERT((int)_m_skillType <= 5 && _m_state <= 3);
     _repaint();

    // @todo: add an icon for lord
    // if(skill->isLordSkill())
    //     button->setIcon(QIcon("image/system/roles/lord.png"));
}
Esempio n. 30
0
void CGameView::h_actionWin(EventParm pdadta)
{
    setState(STATE_WIN);
}