Skip to content

Additional unoccupied sync validity checks

Nexius edited this page Nov 4, 2020 · 11 revisions
const UNOCCUPIED_SYNC = 209;

IPacket:UNOCCUPIED_SYNC(playerid, BitStream:bs)
{
    new unoccupiedData[PR_UnoccupiedSync];
 
    BS_IgnoreBits(bs, 8); // ignore packetid (byte)
    BS_ReadUnoccupiedSync(bs, unoccupiedData);
 
    if ((unoccupiedData[PR_roll][0] == unoccupiedData[PR_direction][0] &&
        unoccupiedData[PR_roll][1] == unoccupiedData[PR_direction][1] &&
        unoccupiedData[PR_roll][2] == unoccupiedData[PR_direction][2]) ||
        (unoccupiedData[PR_roll][0] == unoccupiedData[PR_roll][1] &&
        unoccupiedData[PR_roll][1] == unoccupiedData[PR_roll][2]) ||
        (unoccupiedData[PR_direction][0] == unoccupiedData[PR_direction][1] &&
        unoccupiedData[PR_direction][1] == unoccupiedData[PR_direction][2])
    ) {
        return 0; // ignore bad packet
    }

    return 1;
}