public bool IsOutOfOrder(ushort id) { if (Constants.UseKumoQueues) { return(Overflow.le(id, Overflow.sub(LastTickIdRead, bufferSize))); } return(Overflow.le(id, LastTickIdRead)); }
public int Compare(ushort x, ushort y) { // Handle equality as x > y if (x == y) { return(1); } if (Overflow.le(x, y)) { return(-1); } return(1); }
public bool resolve(PacketReader packet, ushort blockId) { // Check if this is an older block id if (Overflow.le(blockId, oldestResolutionBlockId)) { ResetResolutionTable(blockId); //client->flag_desync(); return(false); } // Otherwise, it might be newer ushort diff = Overflow.sub(blockId, oldestResolutionBlockId); ushort idx = (ushort)(Overflow.add(oldestResolutionPosition, diff) % ResolutionTableSize); if (diff >= ResolutionTableSize) { // We have to move oldest so that newest points to blockId ushort move_amount = Overflow.sub(diff, ResolutionTableDiff); oldestResolutionBlockId = Overflow.add(oldestResolutionBlockId, move_amount); oldestResolutionPosition = (ushort)(Overflow.add(oldestResolutionPosition, move_amount) % ResolutionTableSize); // Fix diff so we don't overrun the new position idx = (ushort)(Overflow.add(oldestResolutionPosition, Overflow.sub(diff, move_amount)) % ResolutionTableSize); // Clean position, as it is a newer packet that hasn't been parsed yet resolutionTable[idx] = 0; } // Compute packet mask ulong mask = (ulong)(1) << packet.getCounter(); // Get blockId position, bitmask, and compute if ((resolutionTable[idx] & mask) != 0) { // The packet is already in return(false); } resolutionTable[idx] |= mask; return(true); }