示例#1
0
// Checks if relativeIndex is draining.  If not, returns the corresponding
// absolute index.  Otherwise, attempt to duplicate.  If duplication is
// successful, and vulnerable references are allowed, return absolute index of
// the duplicate.  If duplication is unsuccessful, or vulnerable references are
// not allowed, return 0.
std::pair<bool, uint32_t> QPACKHeaderTable::maybeDuplicate(
      uint32_t relativeIndex,
      bool allowVulnerable) {
  if (relativeIndex == UNACKED) {
    return {false, 0};
  }
  DCHECK(isValid(relativeIndex));
  uint32_t absIndex = relativeToAbsolute(relativeIndex);
  DCHECK(!isVulnerable(absIndex) || allowVulnerable);
  if (absIndex < minUsable_) {
    // draining
    const HPACKHeader& header = getHeader(relativeIndex);
    if (canIndex(header)) {
      CHECK(add(header.copy()));
      if (allowVulnerable) {
        return {true, insertCount_};
      } else {
        return {true, 0};
      }
    } else {
      return {false, 0};
    }
  }
  return {false, absIndex};
}
示例#2
0
文件: Hero.cpp 项目: jatemack/hikari
    void Hero::handleCollision(Movable& body, CollisionInfo& info) {
        if(info.isCollisionY && info.directionY == Directions::Down) {
            isAirborn = false;
        }

        //
        // Check if we hit spikes; if we did then we're dead!
        //
        if(isVulnerable()) {
            if(TileAttribute::hasAttribute(info.tileType, TileAttribute::SPIKE)
                || TileAttribute::hasAttribute(info.tileType, TileAttribute::ABYSS)) {
                kill();
            }
        }
    }