From bb5ea1f8649f57b429dce3eca0fd92ccec57e08b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 13 Oct 2004 02:11:01 +0000 Subject: [PATCH] fix leap year --- stepmania/src/Bookkeeper.cpp | 6 ++++++ stepmania/src/DateTime.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stepmania/src/Bookkeeper.cpp b/stepmania/src/Bookkeeper.cpp index 0f20ead8fc..e49243380d 100644 --- a/stepmania/src/Bookkeeper.cpp +++ b/stepmania/src/Bookkeeper.cpp @@ -111,11 +111,17 @@ void Bookkeeper::UpdateLastSeenTime() CLAMP( tOld.tm_year, tNew.tm_year-1, tNew.tm_year ); + int cnt = 0; while( tOld.tm_year != tNew.tm_year || tOld.tm_yday != tNew.tm_yday || tOld.tm_hour != tNew.tm_hour ) { + /* Paranoia: break out in case our loop doesn't end for some reason. */ + ++cnt; + if( cnt > 1000 ) + break; + tOld.tm_hour++; if( tOld.tm_hour == HOURS_IN_DAY ) { diff --git a/stepmania/src/DateTime.h b/stepmania/src/DateTime.h index 3d5051ffc9..e93af4617d 100644 --- a/stepmania/src/DateTime.h +++ b/stepmania/src/DateTime.h @@ -5,7 +5,7 @@ const int NUM_LAST_DAYS = 7; const int NUM_LAST_WEEKS = 52; -const int DAYS_IN_YEAR = 365; +const int DAYS_IN_YEAR = 366; // maximum (leap years) const int HOURS_IN_DAY = 24; const int DAYS_IN_WEEK = 7; const int MONTHS_IN_YEAR = 12;