From 28aed657b326bae291c30c0809a5aab9ef092efb Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Thu, 19 Feb 2015 12:45:33 +0100 Subject: [PATCH] Fixed 5+ hour issue for new games The problem was converting a negative int to an unsigned int. This was resulting in a value of: (2^32) - n. Meaning that the room age was extreamly old. After 48s the delay from the server will catch up and the time diff will be 0 rather than negative, which is why after 48s the room will change from 5+ hours to <1 min. --- cockatrice/src/gamesmodel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 7f207ff3..8f6e0e4f 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -11,8 +11,8 @@ enum GameListColumn {ROOM, CREATED, DESCRIPTION, CREATOR, GAME_TYPE, RESTRICTIONS, PLAYERS, SPECTATORS}; namespace { - const unsigned SECS_PER_MIN = 60; - const unsigned SECS_PER_HOUR = 60 * 60; + const int SECS_PER_MIN = 60; + const int SECS_PER_HOUR = 60 * 60; /** * Pretty print an integer number of seconds ago. Accurate to only one unit, @@ -26,7 +26,7 @@ namespace { * 91-300 minutes will return "Xhr ago" * 300+ minutes will return "5+ hr ago" */ - QString prettyPrintSecsAgo(unsigned int secs) { + QString prettyPrintSecsAgo(int secs) { if (secs < SECS_PER_MIN) { return QObject::tr("<1m ago"); } @@ -91,7 +91,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const case CREATED: { QDateTime then; then.setTime_t(g.start_time()); - unsigned int secs = then.secsTo(QDateTime::currentDateTime()); + int secs = then.secsTo(QDateTime::currentDateTime()); switch (role) { case Qt::DisplayRole: return prettyPrintSecsAgo(secs);