Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2019-03-16 01:37:38 +01:00
35 changed files with 2328 additions and 1740 deletions

View File

@@ -126,7 +126,7 @@ scenario_time::update( double const Deltatime ) {
}
m_time.wHour -= 24;
}
int leap { ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 ) };
int leap { is_leap( m_time.wYear ) };
while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) {
m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ];
@@ -135,7 +135,7 @@ scenario_time::update( double const Deltatime ) {
if( m_time.wMonth > 12 ) {
++m_time.wYear;
leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 );
leap = is_leap( m_time.wYear );
m_time.wMonth -= 12;
}
}
@@ -149,7 +149,7 @@ scenario_time::year_day( int Day, const int Month, const int Year ) const {
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) };
int const leap { is_leap( Year ) };
for( int i = 1; i < Month; ++i )
Day += daytab[ leap ][ i ];
@@ -164,7 +164,7 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) };
int const leap { is_leap( Year ) };
WORD idx = 1;
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
@@ -227,7 +227,7 @@ scenario_time::day_of_month( int const Week, int const Weekday, int const Month,
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) };
int const leap { is_leap( Year ) };
while( day > daytab[ leap ][ Month ] ) {
day -= 7;
@@ -252,3 +252,11 @@ scenario_time::convert_transition_time( SYSTEMTIME &Time ) const {
// NOTE: windows uses 0-6 range for days of week numbering, our methods use 1-7
Time.wDay = day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear );
}
bool
scenario_time::is_leap( int const Year ) const {
return ( ( Year % 4 == 0 ) && ( ( Year % 100 != 0 ) || ( Year % 400 == 0 ) ) );
}
//---------------------------------------------------------------------------