reset the setting if is under 0

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-10-15 16:24:23 +03:00
parent b075711be0
commit 52c94eb568
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

View File

@ -64,6 +64,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_settings->registerSetting("lastLaunchTime", 0);
m_settings->registerSetting("totalTimePlayed", 0);
if (m_settings->get("totalTimePlayed").toLongLong() < 0)
m_settings->set("totalTimePlayed", 0);
m_settings->registerSetting("lastTimePlayed", 0);
m_settings->registerSetting("linkedInstances", "[]");
@ -278,8 +280,6 @@ void BaseInstance::setRunning(bool running)
QDateTime timeEnded = QDateTime::currentDateTime();
qint64 current = settings()->get("totalTimePlayed").toLongLong();
if (current < 0)
current = 0;
settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
@ -292,8 +292,6 @@ void BaseInstance::setRunning(bool running)
int64_t BaseInstance::totalTimePlayed() const
{
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
if (current < 0)
current = 0;
if (m_isRunning) {
QDateTime timeNow = QDateTime::currentDateTime();
return current + m_timeStarted.secsTo(timeNow);