diff options
Diffstat (limited to 'StarsEx/StarSystem.cpp')
-rw-r--r-- | StarsEx/StarSystem.cpp | 75 |
1 files changed, 16 insertions, 59 deletions
diff --git a/StarsEx/StarSystem.cpp b/StarsEx/StarSystem.cpp index b8340f6..6641b63 100644 --- a/StarsEx/StarSystem.cpp +++ b/StarsEx/StarSystem.cpp @@ -12,71 +12,31 @@ */ #include "StarSystem.h" -#include "Galaxy.h" -#include "Sky.h" -#include "Starshatter.h" -#include "TerrainRegion.h" -#include "TerrainHaze.h" -#include "Weather.h" +#include "Bitmap.h" +#include "Clock.h" +#include "DataLoader.h" +#include "Galaxy.h" #include "Game.h" #include "GameWinDX9.h" -#include "Clock.h" -#include "Sound.h" -#include "Solid.h" #include "Light.h" -#include "Bitmap.h" -#include "DataLoader.h" -#include "Scene.h" #include "ParseUtil.h" +#include "Scene.h" +#include "Sky.h" +#include "Solid.h" +#include "Sound.h" +#include "Stardate.h" +#include "Starshatter.h" +#include "TerrainHaze.h" +#include "TerrainRegion.h" #include "Video.h" - -const long double epoch = 0.5e9; -long double StarSystem::stardate = 0; +#include "Weather.h" // +====================================================================+ -static long double base_time = 0; static WORD oldcw = 0; static WORD fpcw = 0; -void StarSystem::SetBaseTime(long double t, bool absolute) -{ - if (absolute) { - base_time = t; - CalcStardate(); - } - - else if (t > 0) { - if (t > epoch) t -= epoch; - base_time = t; - CalcStardate(); - } -} - -long double StarSystem::GetBaseTime() -{ - return base_time; -} - -void StarSystem::CalcStardate() -{ - if (base_time < 1) { - time_t clock_seconds; - time(&clock_seconds); - - base_time = clock_seconds; - - while (base_time < 0) - base_time += epoch; - } - - long double gtime = Clock::GetInstance()->GameTime<long double>() / 1000.0; - long double sdate = gtime + base_time + epoch; - - stardate = sdate; -} - static const double GRAV = 6.673e-11; static const int NAMELEN = 64; @@ -119,7 +79,6 @@ static OrbitalBody* primary_moon = 0; void StarSystem::Load() { - CalcStardate(); active_region = 0; BYTE* block = 0; @@ -1386,8 +1345,6 @@ static BYTE min3(BYTE a, BYTE b, BYTE c) void StarSystem::ExecFrame() { - CalcStardate(); - ListIter<OrbitalBody> star = bodies; while (++star) star->Update(); @@ -1843,7 +1800,7 @@ Orbital::Update() double grade = (retro) ? -1 : 1; // orbits are counter clockwise: - phase = -2 * PI * grade * StarSystem::Stardate() / period; + phase = PI * -2.0 * grade * starshatter::engine::CurrentTime() / period; loc = primary->Location() + Point((double) (orbit * cos(phase)), (double) (orbit * sin(phase)), @@ -1871,7 +1828,7 @@ Orbital::PredictLocation(double delta_t) double grade = (retro) ? -1 : 1; // orbits are(?) counter clockwise: - double predicted_phase = (double) (-2 * PI * grade * (StarSystem::Stardate()+delta_t) / period); + const auto predicted_phase = PI * -2.0 * grade * (starshatter::engine::CurrentTime() + delta_t) / period; predicted_loc += Point((double) (orbit * cos(predicted_phase)), (double) (orbit * sin(predicted_phase)), @@ -1917,7 +1874,7 @@ OrbitalBody::Update() theta = 0; if (rotation > 0) - theta = -2 * PI * StarSystem::Stardate() / rotation; + theta = PI * -2.0 * starshatter::engine::CurrentTime() / rotation; ListIter<OrbitalBody> body = satellites; while (++body) |