示例#1
0
cEvent::cEvent(tEventID EventID)
{
  schedule = NULL;
  eventID = EventID;
  tableID = 0;
  version = 0xFF; // actual version numbers are 0..31
  runningStatus = SI::RunningStatusUndefined;
  title = NULL;
  shortText = NULL;
  description = NULL;
  components = NULL;
  startTime = 0;
  duration = 0;
  vps = 0;
  SetSeen();
}
示例#2
0
文件: epg.c 项目: piotrasd/vdr
cEvent::cEvent(tEventID EventID)
{
  schedule = NULL;
  eventID = EventID;
  tableID = 0xFF; // actual table ids are 0x4E..0x60
  version = 0xFF; // actual version numbers are 0..31
  runningStatus = SI::RunningStatusUndefined;
  title = NULL;
  shortText = NULL;
  description = NULL;
  components = NULL;
  memset(contents, 0, sizeof(contents));
  parentalRating = 0;
  startTime = 0;
  duration = 0;
  vps = 0;
  SetSeen();
}
示例#3
0
文件: client.cpp 项目: bakwc/Epsilon5
void TClient::OnDataReceived(const QByteArray &data)
{
    EPacketType packetType;
    quint16 packedDataSize;
    quint16 originDataSize;
    QByteArray content;
    QByteArray receivedPacket = data;
    const int midSize = sizeof(quint16);
    const int posOrigin = sizeof(char);
    const int posPacked = posOrigin + midSize;
    const int posContent = posPacked + midSize;

    try {
        while (receivedPacket.size() > 0) {
            packetType = (EPacketType)(char)(receivedPacket[0]);
            originDataSize = qFromBigEndian<quint16>(
                (const uchar*)receivedPacket.mid(posOrigin, midSize).constData());
            packedDataSize = qFromBigEndian<quint16>(
                (const uchar*)receivedPacket.mid(posPacked, midSize).constData());
            content = qUncompress(receivedPacket.mid(posContent, packedDataSize));

            if( content.isEmpty() && (originDataSize || packedDataSize) )
                throw UException("Wrong packet: cannot unpack data");

            // Retrieve another packet from current.
            // We can receive more than one packet at once
            receivedPacket = receivedPacket.mid(
                packedDataSize + sizeof(char) + 2*midSize);

            switch (packetType) {
            case PT_Control: {
            if (!(PlayerStatus == PS_Spawned || PlayerStatus == PS_Dead)) {
                    throw UException("Player not spawned!");
                }
                Epsilon5::Control control;

                if (control.ParseFromArray(content.data(), content.size())) {
                    size_t currentPacket = control.packet_number();
                    if (control.has_need_full()) {
                        if (control.need_full()) {
                            Server()->NeedFullPacket(Id);
                        }
                    }
                    Server()->Application()->GetWorld()->SetPingForPlayer(Id, currentPacket);
                    SetSeen();
                    emit ControlReceived(control);
                } else {
                    throw UException("Parse error: control packet");
                }
            }
                break;
            case PT_PlayerAuth: {
                if (PlayerStatus != PS_AuthWait) {
                    throw UException("Player not waiting for auth!");
                }
                Epsilon5::Auth auth;
                if (auth.ParseFromArray(content.data(), content.size())) {
                    try {
                        SetSeen();
                        NickName = auth.name().c_str();
                        SendPlayerInfo();

                        QTime dieTime= QTime::currentTime().addSecs(1);
                        while( QTime::currentTime() < dieTime ) {
                            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
                        }

                    qDebug() << "Player " << NickName << "("
                             << Addr.toString() << ") connected";

                    Team = rand() % 2 == 1 ? T_One : T_Second; // throw to random team
                    ETeam NewTeam = Server()->AutoBalance();
                    if (NewTeam != T_Neutral) {
                        Team = NewTeam;
                    }

                    emit PlayerConnected();
                    ReSpawn(true);

                    } catch (const std::exception& e){
                    qDebug() << "Exceptiong: " << Q_FUNC_INFO
                             << ": Error spawning player: " << e.what();
                    }
                } else {
                    throw UException("Parse error: auth packet");
                }
            }
                break;
            default:
                throw UException("Unknown packet type!");
                break;
            }
        }
    } catch (const UException& e) {
        qDebug() << "Exceptiong: " << Q_FUNC_INFO << ": " << e.what();
    }
}