mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
maintenance: minor code tweaks
This commit is contained in:
@@ -2298,6 +2298,8 @@ void TDynamicObject::LoadExchange( int const Disembark, int const Embark, int co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
if( Platform == 0 ) { return; } // edge case, if there's no accessible platforms discard the request
|
||||||
|
|
||||||
m_exchange.unload_count += Disembark;
|
m_exchange.unload_count += Disembark;
|
||||||
m_exchange.load_count += Embark;
|
m_exchange.load_count += Embark;
|
||||||
m_exchange.platforms = Platform;
|
m_exchange.platforms = Platform;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ scenario_time::update( double const Deltatime ) {
|
|||||||
}
|
}
|
||||||
m_time.wHour -= 24;
|
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 ] ) {
|
while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) {
|
||||||
|
|
||||||
m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ];
|
m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ];
|
||||||
@@ -130,7 +130,7 @@ scenario_time::update( double const Deltatime ) {
|
|||||||
if( m_time.wMonth > 12 ) {
|
if( m_time.wMonth > 12 ) {
|
||||||
|
|
||||||
++m_time.wYear;
|
++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;
|
m_time.wMonth -= 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,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 }
|
{ 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 )
|
for( int i = 1; i < Month; ++i )
|
||||||
Day += daytab[ leap ][ i ];
|
Day += daytab[ leap ][ i ];
|
||||||
|
|
||||||
@@ -159,7 +159,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 }
|
{ 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;
|
WORD idx = 1;
|
||||||
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
|
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
|
||||||
|
|
||||||
@@ -222,7 +222,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, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||||
{ 0, 31, 29, 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 ] ) {
|
while( day > daytab[ leap ][ Month ] ) {
|
||||||
day -= 7;
|
day -= 7;
|
||||||
@@ -248,4 +248,10 @@ scenario_time::convert_transition_time( SYSTEMTIME &Time ) const {
|
|||||||
Time.wDay = day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear );
|
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 ) ) );
|
||||||
|
|
||||||
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ private:
|
|||||||
// returns number of days between specified days of week
|
// returns number of days between specified days of week
|
||||||
int
|
int
|
||||||
weekdays( int const First, int const Second ) const;
|
weekdays( int const First, int const Second ) const;
|
||||||
|
// returns true if specified year is a leap year, false otherwise
|
||||||
|
bool
|
||||||
|
is_leap( int const Year ) const;
|
||||||
|
|
||||||
SYSTEMTIME m_time;
|
SYSTEMTIME m_time;
|
||||||
double m_milliseconds{ 0.0 };
|
double m_milliseconds{ 0.0 };
|
||||||
|
|||||||
14
sun.cpp
14
sun.cpp
@@ -185,17 +185,11 @@ void cSun::move() {
|
|||||||
|
|
||||||
m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) );
|
m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) );
|
||||||
|
|
||||||
// Greenwich mean sidereal time
|
// Greenwich mean sidereal time (hours)
|
||||||
m_observer.gmst = 6.697375 + 0.0657098242 * daynumber + m_observer.utime;
|
m_observer.gmst = clamp_circular( 6.697375 + 0.0657098242 * daynumber + m_observer.utime, 24.0 );
|
||||||
|
|
||||||
m_observer.gmst -= 24.0 * (int)( m_observer.gmst / 24.0 );
|
// local mean sidereal time (deg)
|
||||||
if( m_observer.gmst < 0.0 ) m_observer.gmst += 24.0;
|
m_observer.lmst = clamp_circular( m_observer.gmst * 15.0 + m_observer.longitude );
|
||||||
|
|
||||||
// local mean sidereal time
|
|
||||||
m_observer.lmst = m_observer.gmst * 15.0 + m_observer.longitude;
|
|
||||||
|
|
||||||
m_observer.lmst -= 360.0 * (int)( m_observer.lmst / 360.0 );
|
|
||||||
if( m_observer.lmst < 0.0 ) m_observer.lmst += 360.0;
|
|
||||||
|
|
||||||
// hour angle
|
// hour angle
|
||||||
m_body.hrang = m_observer.lmst - m_body.rascen;
|
m_body.hrang = m_observer.lmst - m_body.rascen;
|
||||||
|
|||||||
Reference in New Issue
Block a user