From 00c70278c838c1d187948e75ecdc46b68a1e6fc4 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 26 Mar 2018 15:03:10 -0700 Subject: [PATCH] Add getCreatedAgo() --- assignment-client/src/entities/EntityServer.cpp | 3 +-- libraries/entities/src/EntityItem.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index a6c35390cc..1862287b6d 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -489,10 +489,9 @@ void EntityServer::startDynamicDomainVerification() { if (networkReply->error() == QNetworkReply::NoError) { if (jsonObject["domain_id"].toString() != thisDomainID) { - if (QDateTime::currentMSecsSinceEpoch() - entity->getProperties().getCreated()/1000 > _MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS) { + if (entity->getCreatedAgo() > (_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS/1000)) { qCDebug(entities) << "Entity's cert's domain ID" << jsonObject["domain_id"].toString() << "doesn't match the current Domain ID" << thisDomainID << "; deleting entity" << i.value(); - qCDebug(entities) << "Time since rez (seconds):" << (QDateTime::currentMSecsSinceEpoch() - entity->getProperties().getCreated() / 1000) / 1000; tree->deleteEntity(i.value(), true); } else { qCDebug(entities) << "Entity failed dynamic domain verification, but was created too recently to necessitate deletion:" << i.value(); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 0303964e18..962babb558 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -222,6 +222,10 @@ public: quint64 getCreated() const; /// get the created-time in useconds for the entity void setCreated(quint64 value); /// set the created-time in useconds for the entity + float getCreatedAgo() const /// Elapsed seconds since this entity was created + { + return (float)(usecTimestampNow() - getCreated()) / (float)USECS_PER_SECOND; + } /// is this entity immortal, in that it has no lifetime set, and will exist until manually deleted bool isImmortal() const { return getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME; }