void Jumper::setHelmet(engine::IClump* clump, unsigned int helmetId, Jumper* jumper) { assert( helmetId < getNumHelmets( clump ) ); unsigned int flags; for( unsigned int i=0; i<getNumHelmets(clump); i++ ) { flags = 0; if( i == helmetId ) { flags = engine::afRender | engine::afCollision; if( jumper && jumper->isPlayer() ) { int shadows = atoi( Gameplay::iGameplay->getConfigElement( "video" )->Attribute( "shadows" ) ); if( shadows ) flags = flags | engine::afCastShadow; } } getHelmet( clump, i )->setFlags( flags ); } }
void Bluetooth::onReadyRead(void) { qDebug() << "Ready read..." << "request:" << m_request; if (!m_socket) return; while (m_socket->canReadLine()) { QByteArray data = m_socket->readLine(); QString line = QString::fromUtf8(data.constData(), data.length()).trimmed(); if (line.length() > 0) { qDebug() << "Received:" << line << "request:" << m_request; if (m_timer->isActive()) { m_timer->stop(); } switch (m_request) { case REQUEST_BATTERY: if (line.contains(BLUETOOTH_CMD_BATTERY)) { line.remove(BLUETOOTH_CMD_BATTERY + QString(": ")); line.remove(QChar('%')); unsigned int capacity = line.toInt(); m_request = REQUEST_NO_REQUEST; emit battery(capacity); } else { // FIXME: ERROR } break; case REQUEST_EYES: if (line.contains(BLUETOOTH_CMD_EYES)) { PowerState state; if (line.contains(BLUETOOTH_PARAM_ON)) { state = PowerOn; } else { state = PowerOff; } m_request = REQUEST_NO_REQUEST; emit eyes(state); } else { getEyes(); } break; case REQUEST_HELMET: if (line.contains(BLUETOOTH_CMD_HELMET)) { HelmetState state; if (line.contains(BLUETOOTH_PARAM_CLOSE)) { state = HelmetClose; } else { state = HelmetOpen; } m_request = REQUEST_NO_REQUEST; emit helmet(state); } else { getHelmet(); } break; case REQUEST_INTENSITY: if (line.contains(BLUETOOTH_CMD_INTENSITY)) { line.remove(BLUETOOTH_CMD_INTENSITY + QString(": ")); PowerIntensity value = (PowerIntensity) line.toInt(); m_request = REQUEST_NO_REQUEST; emit intensity(m_intensityDevice, value); } else { getIntensity(m_intensityDevice); } break; case REQUEST_QUOTE: if (line.contains("OK")) { m_request = REQUEST_NO_REQUEST; emit quoteFinished(); } else { // FIXME: ERROR } break; case REQUEST_REPULSOR: if (line.contains("OK")) { emit repulsorBlastGenerated(m_repulsor); } m_request = REQUEST_NO_REQUEST; break; case REQUEST_REPULSORS: if (line.contains(BLUETOOTH_CMD_REPULSORS)) { PowerState state; if (line.contains(BLUETOOTH_PARAM_ON)) { state = PowerOn; } else { state = PowerOff; } m_request = REQUEST_NO_REQUEST; emit repulsors(state); } else { getRepulsors(); } break; case REQUEST_UNIBEAM: if (line.contains(BLUETOOTH_CMD_UNIBEAM)) { PowerState state; if (line.contains(BLUETOOTH_PARAM_ON)) { state = PowerOn; } else { state = PowerOff; } m_request = REQUEST_NO_REQUEST; emit unibeam(state); } else { getUnibeam(); } break; case REQUEST_VERSION: if (m_revision.isEmpty()) { m_revision = line; } else if (m_build.isEmpty()) { m_build = line; m_request = REQUEST_NO_REQUEST; emit version(m_revision, m_build); } break; case REQUEST_VOLUME: if (line.contains(BLUETOOTH_CMD_VOLUME)) { line.remove(BLUETOOTH_CMD_VOLUME + QString(": ")); VolumeLevel level = (VolumeLevel) line.toInt(); emit volume(level); m_request = REQUEST_NO_REQUEST; } else { getVolume(); } break; default: break; } } } }