当前位置: 首页>>代码示例>>C++>>正文


C++ EventData::getFlagStatus方法代码示例

本文整理汇总了C++中EventData::getFlagStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ EventData::getFlagStatus方法的具体用法?C++ EventData::getFlagStatus怎么用?C++ EventData::getFlagStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventData的用法示例。


在下文中一共展示了EventData::getFlagStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addRaceLap

void DriverData::addRaceLap(const EventData &ed)
{
    //ok, this looks a bit complicated, but since the LT server doesn't give us the actuall lap number for every driver during the race we have to find another way to gather laps:
    //- first of all - don't append laps if driver has retired (it's rather obvious)
    //- don't add empty lap time, except for the first lap of the race - it's always empty
    //- if this lap is in-lap - add it, if no - add it only if we have the sector 3 time
    //- if the lapData array is empty - check if lapNum is greater than 0
    //- don't add the out lap - "OUT",
    //- finally - check if we don't try to add the same lap again, we use the gap, interval and lap time info for this
    if (!retired && ed.getCompletedLaps() > 0 && (lastLap.lapTime.toString() != "" || lastLap.lapNum == 1) &&
//        ((lastLap.lapTime.toString() != "IN PIT" && lastLap.sector3.toString() != "") || lastLap.lapTime.toString() == "IN PIT") &&
            ((lastLap.lapNum > 0 && lapData.isEmpty()) ||
             (!lapData.isEmpty() &&
//          (lastLap.numLap > lapData.last().numLap) &&
              (lastLap.lapTime.toString() != "OUT" /*&& !(lastLap.sector3.toString() == "STOP" && lapData.last().sector3.toString() == "STOP")*/) &&
              !(lapData.last().gap == lastLap.gap && lapData.last().interval == lastLap.interval && lapData.last().lapTime == lastLap.lapTime)
             )))
    {
        //this is tricky - if driver goes to the pits, we get this info before he crosses the finish line, but not always...
        //therefore, we don't correct the lap number, assuming that everything is ok, and the lap number is last lap + 1
        if ((lastLap.lapTime.toString() != "IN PIT" && !lapData.isEmpty()) || (lapData.isEmpty() && lastLap.lapTime.toString() == "OUT"))
            correctNumLap(ed.getCompletedLaps());

        //1st lap is always empty (excluding situations when driver goes to pit or retires), so if we got a valid time on the first lap
        //it means that LT server has sent us some junk (probably time from quali)
        if (lastLap.lapNum == 1 && lastLap.lapTime.isValid())
            lastLap.lapTime = LapTime();

        //if this is RETIRED lap, update only the lap time
        if (lastLap.lapTime.toString() == "RETIRED" && !lapData.isEmpty())
        {
            lapData.last().lapTime = lastLap.lapTime;
            return;
        }

        if (lastLap.lapTime.toString() == "IN PIT")
            lastLap.raceLapExtraData.pitLap = true;
        else
            lastLap.raceLapExtraData.pitLap = false;

        //if we get "IN PIT" before driver crossed the line, we get it again after he croses, in that case update only gap and interval
        if (!lapData.empty() && lastLap.lapTime.toString() == "IN PIT" && lapData.last().lapTime.toString() == "IN PIT" && !releasedFromPits)
        {
            lapData.last().gap = lastLap.gap;
            lapData.last().interval = lastLap.interval;
            return;
        }
        //when connected to LT during the race and driver was going out of the pits we save this lap as PIT lap
        if (lastLap.lapTime.toString() == "OUT")
            lastLap.lapTime = LapTime("IN PIT");

        lastLap.carID = carID;

        if (!lapData.empty() && lapData.last().lapNum >= lastLap.lapNum)
            lapData.last() = lastLap;

        else
        {
            lapData.append(lastLap);
            posHistory.append(lastLap.pos);
        }

        releasedFromPits = false;

        if (lastLap < sessionRecords.bestLap)
            sessionRecords.bestLap = lastLap;

        //best sectors
//            if (colorData[LTPackets::RACE_SECTOR_1] == LTPackets::GREEN || colorData[LTPackets::RACE_SECTOR_1] == LTPackets::VIOLET)
//            {
//                bestSectors[0].first = lapData.last().sector1;
//                bestSectors[0].second = lapData.last().numLap;
//            }
//            if (colorData[LTPackets::RACE_SECTOR_2] == LTPackets::GREEN || colorData[LTPackets::RACE_SECTOR_2] == LTPackets::VIOLET)
//            {
//                bestSectors[1].first = lapData.last().sector2;
//                bestSectors[1].second = lapData.last().numLap;
//            }

        updateSectorRecords();

        if (ed.getFlagStatus() == LTPackets::SAFETY_CAR_DEPLOYED || ed.getFlagStatus() == LTPackets::RED_FLAG)
            lapData.last().raceLapExtraData.scLap = true;

        else
            lapData.last().raceLapExtraData.scLap = false;

    }

    //driver was set out from the pits, if he pits again on the next lap we will add it
    if (lastLap.lapTime.toString() == "OUT")
        releasedFromPits = true;
}
开发者ID:primijos,项目名称:f1lt,代码行数:93,代码来源:driverdata.cpp


注:本文中的EventData::getFlagStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。