mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:17:02 +02:00
try to avoid negative roll-over when moving to or from server time
This commit is contained in:
parent
7d9b566d0a
commit
4c64da9ce5
1 changed files with 16 additions and 2 deletions
|
@ -247,15 +247,29 @@ bool ObjectAction::lifetimeIsOver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 ObjectAction::localTimeToServerTime(quint64 timeValue) const {
|
quint64 ObjectAction::localTimeToServerTime(quint64 timeValue) const {
|
||||||
|
// 0 indicates no expiration
|
||||||
if (timeValue == 0) {
|
if (timeValue == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return timeValue + getEntityServerClockSkew();
|
|
||||||
|
int serverClockSkew = getEntityServerClockSkew();
|
||||||
|
if (serverClockSkew < 0 && timeValue <= (quint64)(-serverClockSkew)) {
|
||||||
|
return 1; // non-zero but long-expired value to avoid negative roll-over
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeValue + serverClockSkew;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 ObjectAction::serverTimeToLocalTime(quint64 timeValue) const {
|
quint64 ObjectAction::serverTimeToLocalTime(quint64 timeValue) const {
|
||||||
|
// 0 indicates no expiration
|
||||||
if (timeValue == 0) {
|
if (timeValue == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return timeValue - getEntityServerClockSkew();
|
|
||||||
|
int serverClockSkew = getEntityServerClockSkew();
|
||||||
|
if (serverClockSkew > 0 && timeValue <= (quint64)serverClockSkew) {
|
||||||
|
return 1; // non-zero but long-expired value to avoid negative roll-over
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeValue - serverClockSkew;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue