diff options
author | Aki <please@ignore.pl> | 2024-04-01 05:16:14 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-04-01 05:21:16 +0200 |
commit | 3be3bfaa17773550a696ed2b756136debfe79ae2 (patch) | |
tree | db55a420e43ddaa4a72140d2795892757c1672d3 /StarsEx/Sim.cpp | |
parent | 0a3451f251f360267e2927d8320787d59148eadd (diff) | |
download | starshatter-3be3bfaa17773550a696ed2b756136debfe79ae2.zip starshatter-3be3bfaa17773550a696ed2b756136debfe79ae2.tar.gz starshatter-3be3bfaa17773550a696ed2b756136debfe79ae2.tar.bz2 |
Fixed date and time consistency across Campaigns and Missions
This fixes campaign mission generation mostly, but a full playthrough
will be needed. Missions now serialize and accept stardate setting a
bit better. Thanks to this, date is propagated over multiplayer, too.
This seems to break points system?
Code-wise, this does not workaround the problems from before namely
over-reliance on side-effects. Stardate class is at least one small
step into good direction. Now, it'd be nice to attach clocks to
simulation and campaign and whatever else that needs them.
Diffstat (limited to 'StarsEx/Sim.cpp')
-rw-r--r-- | StarsEx/Sim.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/StarsEx/Sim.cpp b/StarsEx/Sim.cpp index bdf843b..f938b7a 100644 --- a/StarsEx/Sim.cpp +++ b/StarsEx/Sim.cpp @@ -71,6 +71,7 @@ #include "Solid.h" #include "Sound.h" #include "Sprite.h" +#include "Stardate.h" #include "Starshatter.h" #include "StarSystem.h" #include "Terrain.h" @@ -122,8 +123,7 @@ Sim* Sim::sim = 0; Sim::Sim(MotionController* c) : ctrl(c), test_mode(false), grid_shown(false), dust(0), - star_system(0), active_region(0), mission(0), netgame(0), - start_time(0) + star_system(0), active_region(0), mission(0), netgame(0) { Drive::Initialize(); Explosion::Initialize(); @@ -206,7 +206,7 @@ Sim::CommitMission() if (s->IsPlayer()) { Player* p = Player::GetCurrentPlayer(); - p->ProcessStats(s, start_time); + p->ProcessStats(s, starshatter::engine::MissionTime()); if (mission && mission->Type() == Mission::TRAINING && s->GetDeaths() == 0 && s->GetColls() == 0) @@ -368,8 +368,10 @@ Sim::ExecMission() if (cam_dir) cam_dir->Reset(); - if (mission->Stardate() > 0) - StarSystem::SetBaseTime(mission->Stardate(), true); + if (mission->Stardate() > 0.0l) + starshatter::engine::SetOperationStart(mission->Stardate()); + starshatter::engine::SetMissionStart(mission->Start()); + Clock::GetInstance()->ResetGameTime(); star_system = mission->GetStarSystem(); star_system->Activate(scene); @@ -395,7 +397,6 @@ Sim::ExecMission() } first_frame = true; - start_time = Clock::GetInstance()->GameTime(); AudioConfig::SetTraining(mission->Type() == Mission::TRAINING); } @@ -1896,7 +1897,7 @@ Sim::ProcessEventTrigger(int type, int event_id, const char* ship, int param) double Sim::MissionClock() const { - return (Clock::GetInstance()->GameTime() - start_time) / 1000.0; + return starshatter::engine::MissionTime(); } // +--------------------------------------------------------------------+ @@ -1931,7 +1932,7 @@ Sim::SkipCutscene() } } - double skip_time = end_time - MissionClock(); + const auto skip_time = end_time - MissionClock(); if (skip_time > 0) { Clock::GetInstance()->SkipGameTime(skip_time); } |