Merge pull request #10464 from zfox23/fixIdentityUpdatedAt_FINAL_REAL_V2

Implement PR10462 correctly & fix identity packet bugs again
This commit is contained in:
Andrew Meadows 2017-05-15 17:50:58 -07:00 committed by GitHub
commit 9a4b624029

View file

@ -1496,13 +1496,18 @@ QUrl AvatarData::cannonicalSkeletonModelURL(const QUrl& emptyURL) const {
}
void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityChanged, bool& displayNameChanged, const qint64 clockSkew) {
quint64 identityPacketUpdatedAt = identity.updatedAt;
if (identityPacketUpdatedAt <= (uint64_t)(abs(clockSkew))) { // Incoming timestamp is bad - compute our own timestamp
identityPacketUpdatedAt = usecTimestampNow() + clockSkew;
}
// Consider the case where this packet is being processed on Client A, and Client A is connected to Sandbox B.
// If Client A's system clock is *ahead of* Sandbox B's system clock, "clockSkew" will be *negative*.
// If Client A's system clock is *behind* Sandbox B's system clock, "clockSkew" will be *positive*.
if ((_identityUpdatedAt > identity.updatedAt - clockSkew) && (_identityUpdatedAt != 0)) {
if ((_identityUpdatedAt > identityPacketUpdatedAt - clockSkew) && (_identityUpdatedAt != 0)) {
qCDebug(avatars) << "Ignoring late identity packet for avatar " << getSessionUUID()
<< "_identityUpdatedAt (" << _identityUpdatedAt << ") is greater than identity.updatedAt - clockSkew (" << identity.updatedAt << "-" << clockSkew << ")";
<< "_identityUpdatedAt (" << _identityUpdatedAt << ") is greater than identityPacketUpdatedAt - clockSkew (" << identityPacketUpdatedAt << "-" << clockSkew << ")";
return;
}
@ -1538,14 +1543,7 @@ void AvatarData::processAvatarIdentity(const Identity& identity, bool& identityC
// use the timestamp from this identity, since we want to honor the updated times in "server clock"
// this will overwrite any changes we made locally to this AvatarData's _identityUpdatedAt
// Additionally, ensure that the timestamp that we try to record isn't negative, as
// "_identityUpdatedAt" is an *unsigned* 64-bit integer. Furthermore, negative timestamps
// wouldn't make sense.
if (identity.updatedAt > clockSkew) {
_identityUpdatedAt = identity.updatedAt - clockSkew;
} else {
_identityUpdatedAt = 0;
}
_identityUpdatedAt = identityPacketUpdatedAt - clockSkew;
}
QByteArray AvatarData::identityByteArray() const {