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/CampaignSaveGame.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/CampaignSaveGame.cpp')
-rw-r--r-- | StarsEx/CampaignSaveGame.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/StarsEx/CampaignSaveGame.cpp b/StarsEx/CampaignSaveGame.cpp index b959f01..62f8438 100644 --- a/StarsEx/CampaignSaveGame.cpp +++ b/StarsEx/CampaignSaveGame.cpp @@ -13,22 +13,24 @@ */ #include "CampaignSaveGame.h" + #include "Campaign.h" -#include "Combatant.h" +#include "Clock.h" #include "CombatAction.h" +#include "Combatant.h" #include "CombatEvent.h" #include "CombatGroup.h" #include "CombatUnit.h" #include "CombatZone.h" +#include "DataLoader.h" +#include "FormatUtil.h" #include "Galaxy.h" -#include "Mission.h" -#include "StarSystem.h" -#include "Player.h" - #include "Game.h" -#include "DataLoader.h" +#include "Mission.h" #include "ParseUtil.h" -#include "FormatUtil.h" +#include "Player.h" +#include "Stardate.h" +#include "StarSystem.h" static const char* SAVE_DIR = "SaveGame"; @@ -190,8 +192,8 @@ CampaignSaveGame::Load(const char* filename) int grp_type = 0; int grp_id = 0; int status = 0; - double baseTime = 0; - double time = 0; + long double baseTime = 0; + long double time = 0; Text unit; Text sitrep; Text orders; @@ -470,8 +472,7 @@ CampaignSaveGame::Load(const char* filename) campaign->SetStatus(status); if (sitrep.length()) campaign->SetSituation(sitrep); if (orders.length()) campaign->SetOrders(orders); - campaign->SetStartTime(baseTime); - campaign->SetLoadTime(baseTime + time); + campaign->SetLoadTime(time); campaign->LockoutEvents(3600); campaign->Start(); @@ -567,9 +568,6 @@ CampaignSaveGame::Save(const char* name) fopen_s(&f, s, "wb"); if (f) { - char timestr[32]; - FormatDayTime(timestr, campaign->GetTime()); - CombatGroup* player_group = campaign->GetPlayerGroup(); CombatUnit* player_unit = campaign->GetPlayerUnit(); @@ -582,10 +580,10 @@ CampaignSaveGame::Save(const char* name) fprintf(f, "unit: \"%s\"\n", player_unit->Name().data()); fprintf(f, "status: %d\n", (int) campaign->GetStatus()); - fprintf(f, "basetime: %Lf\n", campaign->GetStartTime()); - fprintf(f, "time: %Lf // %s\n\n", - campaign->GetTime(), - timestr); + fprintf(f, "basetime: %.1Lf\n", starshatter::engine::OperationStart()); + const auto operation_time = starshatter::engine::OperationTime(); + const auto formatted_time = operation_time.Format(); + fprintf(f, "time: %.1Lf // %s\n\n", operation_time.value, formatted_time.data()); fprintf(f, "sitrep: \"%s\"\n", campaign->Situation()); fprintf(f, "orders: \"%s\"\n\n", campaign->Orders()); |