diff options
53 files changed, 164 insertions, 209 deletions
diff --git a/Stars45/Campaign.cpp b/Stars45/Campaign.cpp index 7572ea5..e41b24a 100644 --- a/Stars45/Campaign.cpp +++ b/Stars45/Campaign.cpp @@ -409,7 +409,7 @@ Campaign::Unload() { SetStatus(CAMPAIGN_INIT); - Game::GetInstance()->ResetGameTime(); + Game::GetInstance()->GetClock()->ResetGameTime(); StarSystem::SetBaseTime(0); startTime = Stardate(); @@ -1942,7 +1942,7 @@ Campaign::ExecFrame() else time += 20 * 3600; - StarSystem::SetBaseTime(startTime + time - Game::GetInstance()->GameTime()/1000.0); + StarSystem::SetBaseTime(startTime + time - Game::GetInstance()->GetClock()->GameTime()/1000.0); } else { m.reset(); @@ -2044,7 +2044,7 @@ Campaign::StartMission() ::Print("\n\nCampaign Start Mission - %d. '%s'\n", m->Identity(), m->Name()); if (!scripted) { - long double gtime = (long double) Game::GetInstance()->GameTime() / 1000.0; + long double gtime = (long double) Game::GetInstance()->GetClock()->GameTime() / 1000.0; long double base = startTime + m->Start() - 15 - gtime; StarSystem::SetBaseTime(base); @@ -2071,7 +2071,7 @@ Campaign::RollbackMission() if (m) { if (!scripted) { - long double gtime = (long double) Game::GetInstance()->GameTime() / 1000.0; + long double gtime = (long double) Game::GetInstance()->GetClock()->GameTime() / 1000.0; long double base = startTime + m->Start() - 60 - gtime; StarSystem::SetBaseTime(base); diff --git a/Stars45/CarrierAI.cpp b/Stars45/CarrierAI.cpp index d7194a4..235a073 100644 --- a/Stars45/CarrierAI.cpp +++ b/Stars45/CarrierAI.cpp @@ -49,7 +49,7 @@ CarrierAI::CarrierAI(Ship* s, int level) if (ship) flight_planner = new(__FILE__,__LINE__) FlightPlanner(ship); - hold_time = (int) Game::GetInstance()->GameTime(); + hold_time = (int) Game::GetInstance()->GetClock()->GameTime(); } } @@ -69,13 +69,13 @@ CarrierAI::ExecFrame(double secs) if (!sim || !ship || !hangar) return; - if (((int) Game::GetInstance()->GameTime() - hold_time >= INIT_HOLD) && - ((int) Game::GetInstance()->GameTime() - exec_time > EXEC_PERIOD)) { + if (((int) Game::GetInstance()->GetClock()->GameTime() - hold_time >= INIT_HOLD) && + ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > EXEC_PERIOD)) { CheckHostileElements(); CheckPatrolCoverage(); - exec_time = (int) Game::GetInstance()->GameTime(); + exec_time = (int) Game::GetInstance()->GetClock()->GameTime(); } } @@ -132,7 +132,7 @@ CarrierAI::CheckPatrolCoverage() } } - else if (Game::GetInstance()->GameTime() - hangar->GetLastPatrolLaunch() > PATROL_PERIOD || + else if (Game::GetInstance()->GetClock()->GameTime() - hangar->GetLastPatrolLaunch() > PATROL_PERIOD || hangar->GetLastPatrolLaunch() == 0) { Element* patrol = CreatePackage(0, 2, Mission::PATROL, 0, "ACM Medium Range"); if (patrol) { @@ -141,7 +141,7 @@ CarrierAI::CheckPatrolCoverage() if (flight_planner) flight_planner->CreatePatrolRoute(patrol, i); - hangar->SetLastPatrolLaunch(Game::GetInstance()->GameTime()); + hangar->SetLastPatrolLaunch(Game::GetInstance()->GetClock()->GameTime()); return true; } } @@ -194,7 +194,7 @@ CarrierAI::CheckHostileElements() // nobody is assigned yet, create an attack package if (!found && CreateStrike(elem)) { - hold_time = (int) Game::GetInstance()->GameTime() + 30000; + hold_time = (int) Game::GetInstance()->GetClock()->GameTime() + 30000; return true; } } diff --git a/Stars45/CmpLoadDlg.cpp b/Stars45/CmpLoadDlg.cpp index 29ba421..7f2fb1f 100644 --- a/Stars45/CmpLoadDlg.cpp +++ b/Stars45/CmpLoadDlg.cpp @@ -68,7 +68,7 @@ CmpLoadDlg::Show() lbl_title->SetText(campaign->Name()); } - show_time = Game::GetInstance()->RealTime(); + show_time = Game::GetInstance()->GetClock()->RealTime(); } // +--------------------------------------------------------------------+ @@ -110,7 +110,7 @@ CmpLoadDlg::MoveTo(const Rect& r) bool CmpLoadDlg::IsDone() { - if (Game::GetInstance()->RealTime() - show_time < 5000) + if (Game::GetInstance()->GetClock()->RealTime() - show_time < 5000) return false; return true; diff --git a/Stars45/CmpSceneDlg.cpp b/Stars45/CmpSceneDlg.cpp index 96c317e..725d756 100644 --- a/Stars45/CmpSceneDlg.cpp +++ b/Stars45/CmpSceneDlg.cpp @@ -163,7 +163,7 @@ CmpSceneDlg::ExecFrame() if (begin_scene && end_scene) { double total_time = end_scene->Time() - begin_scene->Time(); subtitles_delay = total_time / nlines; - subtitles_time = Game::GetInstance()->RealTime() / 1000.0 + subtitles_delay; + subtitles_time = Game::GetInstance()->GetClock()->RealTime() / 1000.0 + subtitles_delay; } else { subtitles_delay = -1; @@ -171,7 +171,7 @@ CmpSceneDlg::ExecFrame() } if (subtitles_delay > 0) { - double seconds = Game::GetInstance()->RealTime() / 1000.0; + double seconds = Game::GetInstance()->GetClock()->RealTime() / 1000.0; if (subtitles_time <= seconds) { subtitles_time = seconds + subtitles_delay; diff --git a/Stars45/CmpSelectDlg.cpp b/Stars45/CmpSelectDlg.cpp index 4e21257..2ceacd9 100644 --- a/Stars45/CmpSelectDlg.cpp +++ b/Stars45/CmpSelectDlg.cpp @@ -496,7 +496,7 @@ CmpSelectDlg::OnAccept(AWEvent* event) if (btn_new->GetButtonState()) Campaign::GetCampaign()->Load(); else - Game::GetInstance()->ResetGameTime(); + Game::GetInstance()->GetClock()->ResetGameTime(); Mouse::Show(false); stars->SetGameMode(Starshatter::CLOD_MODE); diff --git a/Stars45/Contact.cpp b/Stars45/Contact.cpp index 97cba6a..a2912cb 100644 --- a/Stars45/Contact.cpp +++ b/Stars45/Contact.cpp @@ -34,14 +34,14 @@ Contact::Contact() : ship(0), shot(0), d_pas(0.0f), d_act(0.0f), track(0), ntrack(0), time(0), track_time(0), probe(false) { - acquire_time = Game::GetInstance()->GameTime(); + acquire_time = Game::GetInstance()->GetClock()->GameTime(); } Contact::Contact(Ship* s, float p, float a) : ship(s), shot(0), d_pas(p), d_act(a), track(0), ntrack(0), time(0), track_time(0), probe(false) { - acquire_time = Game::GetInstance()->GameTime(); + acquire_time = Game::GetInstance()->GetClock()->GameTime(); Observe(ship); } @@ -49,7 +49,7 @@ Contact::Contact(Shot* s, float p, float a) : ship(0), shot(s), d_pas(p), d_act(a), track(0), ntrack(0), time(0), track_time(0), probe(false) { - acquire_time = Game::GetInstance()->GameTime(); + acquire_time = Game::GetInstance()->GetClock()->GameTime(); Observe(shot); } @@ -116,7 +116,7 @@ Contact::Age() const if (!ship && !shot) return age; - double seconds = (Game::GetInstance()->GameTime() - time) / 1000.0; + double seconds = (Game::GetInstance()->GetClock()->GameTime() - time) / 1000.0; age = 1.0 - seconds/DEFAULT_TRACK_AGE; @@ -295,7 +295,7 @@ Contact::Reset() { if (Game::GetInstance()->Paused()) return; - float step_down = (float) (Game::GetInstance()->FrameTime() / 10); + float step_down = (float) (Game::GetInstance()->GetClock()->Delta() / 10); if (d_pas > 0) d_pas -= step_down; @@ -327,7 +327,7 @@ Contact::ClearTrack() void Contact::UpdateTrack() { - time = Game::GetInstance()->GameTime(); + time = Game::GetInstance()->GetClock()->GameTime(); if (shot || (ship && ship->IsGroundUnit())) return; diff --git a/Stars45/CtlDlg.cpp b/Stars45/CtlDlg.cpp index 33f4e1e..8203147 100644 --- a/Stars45/CtlDlg.cpp +++ b/Stars45/CtlDlg.cpp @@ -318,7 +318,7 @@ CtlDlg::OnCommand(AWEvent* event) int list_index = commands->GetListIndex(); // double-click: - if (list_index == command_index && Game::GetInstance()->RealTime() - command_click_time < 350) { + if (list_index == command_index && Game::GetInstance()->GetClock()->RealTime() - command_click_time < 350) { KeyDlg* key_dlg = 0; if (manager) @@ -332,7 +332,7 @@ CtlDlg::OnCommand(AWEvent* event) manager->ShowKeyDlg(); } - command_click_time = Game::GetInstance()->RealTime(); + command_click_time = Game::GetInstance()->GetClock()->RealTime(); command_index = list_index; } diff --git a/Stars45/Debris.cpp b/Stars45/Debris.cpp index 680d314..083b714 100644 --- a/Stars45/Debris.cpp +++ b/Stars45/Debris.cpp @@ -148,7 +148,7 @@ Debris::HitBy(Shot* shot, Point& impact) double effective_damage = shot->Damage() * dscale; if (shot->IsBeam()) { - effective_damage *= Game::GetInstance()->FrameTime(); + effective_damage *= Game::GetInstance()->GetClock()->Delta(); } else { ApplyTorque(shot->Velocity() * (float) effective_damage * 1e-6f); diff --git a/Stars45/DisplayView.cpp b/Stars45/DisplayView.cpp index 2c55cb6..5a758c8 100644 --- a/Stars45/DisplayView.cpp +++ b/Stars45/DisplayView.cpp @@ -157,7 +157,7 @@ DisplayView::Refresh() void DisplayView::ExecFrame() { - double seconds = Game::GetInstance()->GUITime(); + double seconds = Game::GetInstance()->GetClock()->GuiDelta(); ListIter<DisplayElement> iter = elements; while (++iter) { diff --git a/Stars45/Drone.cpp b/Stars45/Drone.cpp index ff32d23..68cb384 100644 --- a/Stars45/Drone.cpp +++ b/Stars45/Drone.cpp @@ -181,7 +181,7 @@ Drone::HitBy(Shot* shot, Point& impact) double effective_damage = shot->Damage() * dscale; if (shot->IsBeam()) { - effective_damage *= Game::GetInstance()->FrameTime(); + effective_damage *= Game::GetInstance()->GetClock()->Delta(); } else { ApplyTorque(shot->Velocity() * (float) effective_damage * 1e-6f); diff --git a/Stars45/ExitDlg.cpp b/Stars45/ExitDlg.cpp index 548d1cb..66aab6b 100644 --- a/Stars45/ExitDlg.cpp +++ b/Stars45/ExitDlg.cpp @@ -65,7 +65,7 @@ void ExitDlg::ExecFrame() { if (credits && credits->GetLineCount() > 0) { - credits->SmoothScroll(ScrollWindow::SCROLL_DOWN, Game::GetInstance()->GUITime()); + credits->SmoothScroll(ScrollWindow::SCROLL_DOWN, Game::GetInstance()->GetClock()->GuiDelta()); if (credits->GetTopIndex() >= credits->GetLineCount()-1) { credits->ScrollTo(0); diff --git a/Stars45/FadeView.cpp b/Stars45/FadeView.cpp index 16575b9..1f6207e 100644 --- a/Stars45/FadeView.cpp +++ b/Stars45/FadeView.cpp @@ -55,10 +55,10 @@ FadeView::Refresh() double msec = 0; if (state == StateStart) { - time = Game::GetInstance()->RealTime(); + time = Game::GetInstance()->GetClock()->RealTime(); } else if (state != StateDone) { - double new_time = Game::GetInstance()->RealTime(); + double new_time = Game::GetInstance()->GetClock()->RealTime(); msec = new_time - time; time = new_time; } diff --git a/Stars45/FighterAI.cpp b/Stars45/FighterAI.cpp index 029b928..12f1746 100644 --- a/Stars45/FighterAI.cpp +++ b/Stars45/FighterAI.cpp @@ -1563,8 +1563,8 @@ FighterAI::EvadeThreat() // jink for one second: else { - if (Game::GetInstance()->GameTime() - jink_time > 1500) { - jink_time = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - jink_time > 1500) { + jink_time = Game::GetInstance()->GetClock()->GameTime(); jink = Point(rand() - 16384, rand() - 16384, rand() - 16384) * 15e3; @@ -1587,8 +1587,8 @@ FighterAI::EvadeThreat() // jink for one second: else { - if (Game::GetInstance()->GameTime() - jink_time > 1000) { - jink_time = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - jink_time > 1000) { + jink_time = Game::GetInstance()->GetClock()->GameTime(); jink = Point(rand() - 16384, rand() - 16384, rand() - 16384); @@ -1647,8 +1647,8 @@ FighterAI::EvadeThreat() if (!target) { DWORD jink_rate = 400 + 200 * (3-ai_level); - if (Game::GetInstance()->GameTime() - jink_time > jink_rate) { - jink_time = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - jink_time > jink_rate) { + jink_time = Game::GetInstance()->GetClock()->GameTime(); jink = Point(rand() - 16384, rand() - 16384, rand() - 16384) * 2000; @@ -1777,7 +1777,7 @@ FighterAI::FireControl() if (ship->FireSecondary()) { missile_time = secondary->Design()->salvo_delay + extra_time; - if (Game::GetInstance()->GameTime() - last_call_time > 6000) { + if (Game::GetInstance()->GetClock()->GameTime() - last_call_time > 6000) { // call fox: int call = RadioMessage::FOX_3; // A2A @@ -1788,7 +1788,7 @@ FighterAI::FireControl() call = RadioMessage::FOX_2; RadioTraffic::SendQuickMessage(ship, call); - last_call_time = Game::GetInstance()->GameTime(); + last_call_time = Game::GetInstance()->GetClock()->GameTime(); } } } diff --git a/Stars45/FighterTacticalAI.cpp b/Stars45/FighterTacticalAI.cpp index be40e6e..9cd5839 100644 --- a/Stars45/FighterTacticalAI.cpp +++ b/Stars45/FighterTacticalAI.cpp @@ -154,9 +154,9 @@ FighterTacticalAI::SelectTarget() SimObject* target = ship_ai->GetTarget(); if (target && (target->Type() == SimObject::SIM_SHIP) && - (Game::GetInstance()->GameTime() - secondary_selection_time) > THREAT_REACTION_TIME) { + (Game::GetInstance()->GetClock()->GameTime() - secondary_selection_time) > THREAT_REACTION_TIME) { SelectSecondaryForTarget((Ship*) target); - secondary_selection_time = Game::GetInstance()->GameTime(); + secondary_selection_time = Game::GetInstance()->GetClock()->GameTime(); } } @@ -475,7 +475,7 @@ FighterTacticalAI::FindThreat() Contact* contact = c_iter.value(); if (contact->Threat(ship) && - (Game::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { + (Game::GetInstance()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { double rng = contact->Range(ship); diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index 97de488..5dfd828 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -182,24 +182,6 @@ Game::FrameRate() return 0; } -double -Game::FrameTime() -{ - if (game) - return game->GetClock()->Delta(); - - return 0; -} - -double -Game::GUITime() -{ - if (game) - return game->GetClock()->GuiDelta(); - - return 0; -} - // +--------------------------------------------------------------------+ bool @@ -1244,16 +1226,6 @@ Game::GetClock() return &clock; } -DWORD Game::RealTime() -{ - return clock.RealTime(); -} - -DWORD Game::GameTime() -{ - return clock.GameTime(); -} - DWORD Game::TimeCompression() { return clock.TimeCompression(); @@ -1269,14 +1241,3 @@ DWORD Game::Frame() { return frame_number; } - -void Game::ResetGameTime() -{ - clock.ResetGameTime(); -} - -void Game::SkipGameTime(double seconds) -{ - if (seconds > 0) - clock.SkipGameTime(seconds); -} diff --git a/Stars45/Game.h b/Stars45/Game.h index d9054e9..7ecb198 100644 --- a/Stars45/Game.h +++ b/Stars45/Game.h @@ -77,17 +77,11 @@ public: void SetMaxTexSize(int n); Clock* GetClock(); - DWORD RealTime(); - DWORD GameTime(); DWORD TimeCompression(); void SetTimeCompression(DWORD comp); DWORD Frame(); - void ResetGameTime(); - void SkipGameTime(double seconds); double FrameRate(); - double FrameTime(); - double GUITime(); void SetMaxFrameLength(double seconds) { max_frame_length = seconds; } double GetMaxFrameLength() { return max_frame_length; } diff --git a/Stars45/GroundAI.cpp b/Stars45/GroundAI.cpp index 5c9150d..c355eba 100644 --- a/Stars45/GroundAI.cpp +++ b/Stars45/GroundAI.cpp @@ -161,8 +161,8 @@ GroundAI::ExecFrame(double secs) { const int exec_period = 1000; - if ((int) Game::GetInstance()->GameTime() - exec_time > exec_period) { - exec_time = (int) Game::GetInstance()->GameTime(); + if ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > exec_period) { + exec_time = (int) Game::GetInstance()->GetClock()->GameTime(); SelectTarget(); } diff --git a/Stars45/HUDView.cpp b/Stars45/HUDView.cpp index 2ca3bf4..2f0ec20 100644 --- a/Stars45/HUDView.cpp +++ b/Stars45/HUDView.cpp @@ -863,7 +863,7 @@ HUDView::MarkerColor(Contact* contact) c = Ship::IFFColor(c_iff) * contact->Age(); if (contact->GetShot() && contact->Threat(ship)) { - if ((Game::GetInstance()->RealTime()/500) & 1) + if ((Game::GetInstance()->GetClock()->RealTime()/500) & 1) c = c * 2; else c = c * 0.5; @@ -1463,7 +1463,7 @@ HUDView::DrawBars() else if (threat > 1) { threat_warn = ContentBundle::GetInstance()->GetText("HUDView.missile-warn"); - show_msg = ((Game::GetInstance()->RealTime()/500) & 1) != 0; + show_msg = ((Game::GetInstance()->GetClock()->RealTime()/500) & 1) != 0; } if (show_msg) { @@ -2115,9 +2115,9 @@ HUDView::DrawTarget() System* sys = ship->GetSubTarget(); if (sys) { Color stat = hud_color; - static DWORD blink = Game::GetInstance()->RealTime(); + static DWORD blink = Game::GetInstance()->GetClock()->RealTime(); - int blink_delta = Game::GetInstance()->RealTime() - blink; + int blink_delta = Game::GetInstance()->GetClock()->RealTime() - blink; sprintf_s(txt, "%s %03d", sys->Abbreviation(), (int) sys->Availability()); switch (sys->Status()) { @@ -2131,7 +2131,7 @@ HUDView::DrawTarget() } if (blink_delta > 500) - blink = Game::GetInstance()->RealTime(); + blink = Game::GetInstance()->GetClock()->RealTime(); range_rect.y += 10; DrawHUDText(TXT_TARGET_SUB, txt, range_rect, DT_RIGHT); @@ -2657,7 +2657,7 @@ HUDView::DrawWarningPanel() int y = cockpit_hud_texture ? 410 : height-97; int c = cockpit_hud_texture ? 3 : 4; - static DWORD blink = Game::GetInstance()->RealTime(); + static DWORD blink = Game::GetInstance()->GetClock()->RealTime(); for (int index = 0; index < 12; index++) { int stat = -1; @@ -2698,7 +2698,7 @@ HUDView::DrawWarningPanel() Color tc = status_color; if (stat != System::NOMINAL) { - if (Game::GetInstance()->RealTime() - blink < 250) { + if (Game::GetInstance()->GetClock()->RealTime() - blink < 250) { tc = cockpit_hud_texture ? txt_color : Color(8,8,8); } } @@ -2740,8 +2740,8 @@ HUDView::DrawWarningPanel() } } - if (Game::GetInstance()->RealTime() - blink > 500) - blink = Game::GetInstance()->RealTime(); + if (Game::GetInstance()->GetClock()->RealTime() - blink > 500) + blink = Game::GetInstance()->GetClock()->RealTime(); // reset for next time SetStatusColor(System::NOMINAL); @@ -2876,7 +2876,7 @@ HUDView::DrawMessages() // age messages: for (int i = 0; i < MAX_MSG; i++) { if (msg_time[i] > 0) { - msg_time[i] -= Game::GetInstance()->GUITime(); + msg_time[i] -= Game::GetInstance()->GetClock()->GuiDelta(); if (msg_time[i] <= 0) { msg_time[i] = 0; diff --git a/Stars45/MenuView.cpp b/Stars45/MenuView.cpp index 6a261a9..00f2dae 100644 --- a/Stars45/MenuView.cpp +++ b/Stars45/MenuView.cpp @@ -78,13 +78,13 @@ MenuView::DoMouseFrame() if (Mouse::RButton()) { MouseController* mouse_con = MouseController::GetInstance(); if (!right_down && (!mouse_con || !mouse_con->Active())) { - rbutton_latch = Game::GetInstance()->RealTime(); + rbutton_latch = Game::GetInstance()->GetClock()->RealTime(); right_down = true; show_menu = false; } } else { - if (right_down && (Game::GetInstance()->RealTime() - rbutton_latch < 250)) { + if (right_down && (Game::GetInstance()->GetClock()->RealTime() - rbutton_latch < 250)) { right_start.x = Mouse::X() - offset.x; right_start.y = Mouse::Y() - offset.y; show_menu = true; diff --git a/Stars45/Mfd.cpp b/Stars45/Mfd.cpp index 6dc4822..37aece0 100644 --- a/Stars45/Mfd.cpp +++ b/Stars45/Mfd.cpp @@ -1106,9 +1106,9 @@ MFD::DrawGameMFD() if (lines <= 2) return; - int hours = (Game::GetInstance()->GameTime() / 3600000) ; - int minutes = (Game::GetInstance()->GameTime() / 60000) % 60; - int seconds = (Game::GetInstance()->GameTime() / 1000) % 60; + int hours = (Game::GetInstance()->GetClock()->GameTime() / 3600000) ; + int minutes = (Game::GetInstance()->GetClock()->GameTime() / 60000) % 60; + int seconds = (Game::GetInstance()->GetClock()->GameTime() / 1000) % 60; if (ship) { DWORD clock = ship->MissionClock(); @@ -1282,7 +1282,7 @@ MFD::DrawStatusMFD() sprintf_s(txt, "%s %d", ContentBundle::GetInstance()->GetText("MFD.status.MODE").data(), ship->GetEMCON()); if (!sensor->IsPowerOn() || sensor->GetEnergy() == 0) { - if (!Game::GetInstance()->Paused() && (Game::GetInstance()->RealTime()/1000) & 2) + if (!Game::GetInstance()->Paused() && (Game::GetInstance()->GetClock()->RealTime()/1000) & 2) strcpy_s(txt, ContentBundle::GetInstance()->GetText("MFD.status.SENSOR-OFF").data()); } diff --git a/Stars45/ModDlg.cpp b/Stars45/ModDlg.cpp index 71eb368..76d0e7e 100644 --- a/Stars45/ModDlg.cpp +++ b/Stars45/ModDlg.cpp @@ -212,7 +212,7 @@ ModDlg::OnSelectEnabled(AWEvent* event) btn_decrease->SetEnabled(lst_enabled->GetSelection() < lst_enabled->NumItems() - 1); // double-click: - if (Game::GetInstance()->RealTime() - click_time < 350) { + if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) { if (lst_enabled->GetSelCount() == 1) { int index = lst_enabled->GetSelection(); Text mod_name = lst_enabled->GetItemText(index); @@ -227,7 +227,7 @@ ModDlg::OnSelectEnabled(AWEvent* event) } } - click_time = Game::GetInstance()->RealTime(); + click_time = Game::GetInstance()->GetClock()->RealTime(); } void diff --git a/Stars45/MouseController.cpp b/Stars45/MouseController.cpp index 1cd9504..3234dfe 100644 --- a/Stars45/MouseController.cpp +++ b/Stars45/MouseController.cpp @@ -117,11 +117,11 @@ MouseController::Acquire() roll_enable = 1; if (!rbutton_latch) - rbutton_latch = Game::GetInstance()->RealTime(); + rbutton_latch = Game::GetInstance()->GetClock()->RealTime(); } else { if (rbutton_latch) { - rbutton_latch = Game::GetInstance()->RealTime() - rbutton_latch; + rbutton_latch = Game::GetInstance()->GetClock()->RealTime() - rbutton_latch; if (rbutton_latch < 250) action[1] = 1; } @@ -131,7 +131,7 @@ MouseController::Acquire() if (Mouse::MButton()) { if (!mbutton_latch) - mbutton_latch = Game::GetInstance()->RealTime(); + mbutton_latch = Game::GetInstance()->GetClock()->RealTime(); } else { if (mbutton_latch) { @@ -187,7 +187,7 @@ MouseController::Acquire() if (select == 1) { ::SetCursorPos(cx, cy); - double drain = cx * 4 * Game::GetInstance()->FrameTime(); + double drain = cx * 4 * Game::GetInstance()->GetClock()->Delta(); if (dx > drain) { dx -= drain; diff --git a/Stars45/MsnEditDlg.cpp b/Stars45/MsnEditDlg.cpp index 527c451..120eb07 100644 --- a/Stars45/MsnEditDlg.cpp +++ b/Stars45/MsnEditDlg.cpp @@ -637,7 +637,7 @@ MsnEditDlg::OnElemSelect(AWEvent* event) btn_elem_dec->SetEnabled(selection >= 0 && selection < lst_elem->NumItems() - 1); // double-click: - if (Game::GetInstance()->RealTime() - click_time < 350) { + if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) { if (lst_elem->GetSelCount() == 1) { int index = lst_elem->GetSelection(); MissionElement* elem = mission->GetElements().at(index); @@ -653,7 +653,7 @@ MsnEditDlg::OnElemSelect(AWEvent* event) } } - click_time = Game::GetInstance()->RealTime(); + click_time = Game::GetInstance()->GetClock()->RealTime(); } void @@ -765,7 +765,7 @@ MsnEditDlg::OnEventSelect(AWEvent* event) btn_event_dec->SetEnabled(selection >= 0 && selection < lst_event->NumItems() - 1); // double-click: - if (Game::GetInstance()->RealTime() - click_time < 350) { + if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) { if (lst_event->GetSelCount() == 1) { int index = lst_event->GetSelection(); MissionEvent* event = mission->GetEvents().at(index); @@ -781,7 +781,7 @@ MsnEditDlg::OnEventSelect(AWEvent* event) } } - click_time = Game::GetInstance()->RealTime(); + click_time = Game::GetInstance()->GetClock()->RealTime(); } void diff --git a/Stars45/MusicTrack.cpp b/Stars45/MusicTrack.cpp index 0454b11..956d0b5 100644 --- a/Stars45/MusicTrack.cpp +++ b/Stars45/MusicTrack.cpp @@ -135,7 +135,7 @@ MusicTrack::ExecFrame() } if (fade > 0) - fade -= Game::GetInstance()->GUITime(); + fade -= Game::GetInstance()->GetClock()->GuiDelta(); if (fade < 0) fade = 0; diff --git a/Stars45/NavDlg.cpp b/Stars45/NavDlg.cpp index 662f185..bbc4d86 100644 --- a/Stars45/NavDlg.cpp +++ b/Stars45/NavDlg.cpp @@ -1046,7 +1046,7 @@ NavDlg::OnMapClick(AWEvent* event) CoordinateSelection(); // double-click: - if (Game::GetInstance()->RealTime() - click_time < 350) { + if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) { MissionElement* elem = star_map->GetSelectedElem(); MsnElemDlg* msn_elem_dlg = manager->GetMsnElemDlg(); @@ -1057,7 +1057,7 @@ NavDlg::OnMapClick(AWEvent* event) } } - click_time = Game::GetInstance()->RealTime(); + click_time = Game::GetInstance()->GetClock()->RealTime(); } void diff --git a/Stars45/NavLight.cpp b/Stars45/NavLight.cpp index 63712ac..48bd826 100644 --- a/Stars45/NavLight.cpp +++ b/Stars45/NavLight.cpp @@ -100,7 +100,7 @@ void NavLight::ExecFrame(double seconds) { if (enable && power_on) { - double t = (Game::GetInstance()->GameTime()+offset) / 1000.0; + double t = (Game::GetInstance()->GetClock()->GameTime()+offset) / 1000.0; DWORD n = (int) (fmod(t, period) * 32 / period); DWORD code = 1 << n; diff --git a/Stars45/NetGameClient.cpp b/Stars45/NetGameClient.cpp index 4d9d5ae..89e1ff0 100644 --- a/Stars45/NetGameClient.cpp +++ b/Stars45/NetGameClient.cpp @@ -936,7 +936,7 @@ NetGameClient::DoSelfDestruct(NetMsg* msg) void NetGameClient::Send() { - DWORD time = Game::GetInstance()->GameTime(); + DWORD time = Game::GetInstance()->GetClock()->GameTime(); // don't flood the network... if (time - last_send_time < MIN_NET_FRAME) diff --git a/Stars45/NetGameServer.cpp b/Stars45/NetGameServer.cpp index 76bd4ff..fe53515 100644 --- a/Stars45/NetGameServer.cpp +++ b/Stars45/NetGameServer.cpp @@ -141,9 +141,9 @@ NetGameServer::ExecFrame() static DWORD time_mark = 0; - if (!time_mark) time_mark = Game::GetInstance()->RealTime(); - else if (Game::GetInstance()->RealTime() - time_mark > 60000) { - time_mark = Game::GetInstance()->RealTime(); + if (!time_mark) time_mark = Game::GetInstance()->GetClock()->RealTime(); + else if (Game::GetInstance()->GetClock()->RealTime() - time_mark > 60000) { + time_mark = Game::GetInstance()->GetClock()->RealTime(); if (link && players.size() > 0) { Print("Server Stats\n-------------\n"); @@ -1009,7 +1009,7 @@ NetGameServer::Send() if (players.isEmpty()) return; - DWORD time = Game::GetInstance()->GameTime(); + DWORD time = Game::GetInstance()->GetClock()->GameTime(); // don't flood the network... if (time - last_send_time < MIN_NET_FRAME) diff --git a/Stars45/NetLobbyServer.cpp b/Stars45/NetLobbyServer.cpp index eecb5c5..5cac691 100644 --- a/Stars45/NetLobbyServer.cpp +++ b/Stars45/NetLobbyServer.cpp @@ -256,9 +256,9 @@ NetLobbyServer::ExecFrame() { NetLobby::ExecFrame(); - if (announce_time == 0 || Game::GetInstance()->RealTime() - announce_time > 200000) { + if (announce_time == 0 || Game::GetInstance()->GetClock()->RealTime() - announce_time > 200000) { GameOn(); - announce_time = Game::GetInstance()->RealTime(); + announce_time = Game::GetInstance()->GetClock()->RealTime(); } if (GetStatus() == NetServerInfo::BRIEFING) { @@ -377,7 +377,7 @@ NetLobbyServer::CheckSessions() // announce drop: char timestr[64]; - FormatTime(timestr, Game::GetInstance()->RealTime()/1000); + FormatTime(timestr, Game::GetInstance()->GetClock()->RealTime()/1000); Print("NetLobbyServer: Dropped inactive connection '%s' %s\n", u->Name().data(), timestr); diff --git a/Stars45/NetUnitDlg.cpp b/Stars45/NetUnitDlg.cpp index 61b9bcd..1df2311 100644 --- a/Stars45/NetUnitDlg.cpp +++ b/Stars45/NetUnitDlg.cpp @@ -497,11 +497,11 @@ NetUnitDlg::OnUnit(AWEvent* event) int list_index = lst_units->GetListIndex(); // double-click: - if (list_index == unit_index && Game::GetInstance()->RealTime() - unit_click_time < 350) { + if (list_index == unit_index && Game::GetInstance()->GetClock()->RealTime() - unit_click_time < 350) { OnSelect(0); } - unit_click_time = Game::GetInstance()->RealTime(); + unit_click_time = Game::GetInstance()->GetClock()->RealTime(); unit_index = list_index; } diff --git a/Stars45/Particles.cpp b/Stars45/Particles.cpp index 50642f0..5b5c02f 100644 --- a/Stars45/Particles.cpp +++ b/Stars45/Particles.cpp @@ -57,7 +57,7 @@ blend(a), extra(0.0f), point_sprite(0), emitting(true) for (int i = 0; i < nverts; i++) { intensity[i] = 1.0f; - timestamp[i] = (float) (Game::GetInstance()->GameTime() / 1000.0); + timestamp[i] = (float) (Game::GetInstance()->GetClock()->GameTime() / 1000.0); scale[i] = (float) (min_scale); angle[i] = (float) (Random(0, 2*PI)); frame[i] = 0; @@ -143,7 +143,7 @@ void Particles::ExecFrame(double seconds) intensity[i] -= (float) (decay * seconds); if (point_sprite->NumFrames() > 1) { - double age = Game::GetInstance()->GameTime()/1000.0 - timestamp[i]; + double age = Game::GetInstance()->GetClock()->GameTime()/1000.0 - timestamp[i]; int n = (int) (age * point_sprite->FrameRate()); if (n >= point_sprite->NumFrames()) @@ -167,7 +167,7 @@ void Particles::ExecFrame(double seconds) for (int i = nv; i < nverts; i++) { intensity[i] = 1; - timestamp[i] = (float) (Game::GetInstance()->GameTime() / 1000.0); + timestamp[i] = (float) (Game::GetInstance()->GetClock()->GameTime() / 1000.0); scale[i] = (float) (min_scale); angle[i] = (float) (Random(0, 2*PI)); frame[i] = 0; @@ -189,7 +189,7 @@ void Particles::ExecFrame(double seconds) release[i] = ref_loc; intensity[i] = 1; - timestamp[i] = (float) (Game::GetInstance()->GameTime() / 1000.0); + timestamp[i] = (float) (Game::GetInstance()->GetClock()->GameTime() / 1000.0); scale[i] = (float) (min_scale); angle[i] = (float) (PI * rand() / 16384.0); frame[i] = 0; diff --git a/Stars45/Player.cpp b/Stars45/Player.cpp index 9ba5c35..e4944e6 100644 --- a/Stars45/Player.cpp +++ b/Stars45/Player.cpp @@ -641,7 +641,7 @@ Player::GetMissionPoints(ShipStats* s, DWORD start_time) if (s) { result = s->GetPoints(); - int flight_time = (Game::GetInstance()->GameTime() - start_time) / 1000; + int flight_time = (Game::GetInstance()->GetClock()->GameTime() - start_time) / 1000; // if player survived mission, award one experience point // for each minute of action, in ten point blocks: @@ -682,7 +682,7 @@ Player::ProcessStats(ShipStats* s, DWORD start_time) AddLosses(s->GetDeaths()); AddLosses(s->GetColls()); AddMissions(1); - AddFlightTime((Game::GetInstance()->GameTime() - start_time) / 1000); + AddFlightTime((Game::GetInstance()->GetClock()->GameTime() - start_time) / 1000); int rank = Rank(); diff --git a/Stars45/QuantumView.cpp b/Stars45/QuantumView.cpp index 67d67d2..889457e 100644 --- a/Stars45/QuantumView.cpp +++ b/Stars45/QuantumView.cpp @@ -169,7 +169,7 @@ QuantumView::ExecFrame() static double time_til_change = 0; if (time_til_change > 0) - time_til_change -= Game::GetInstance()->GUITime(); + time_til_change -= Game::GetInstance()->GetClock()->GuiDelta(); if (time_til_change <= 0) { time_til_change = 0; diff --git a/Stars45/RadioView.cpp b/Stars45/RadioView.cpp index feb696a..315218b 100644 --- a/Stars45/RadioView.cpp +++ b/Stars45/RadioView.cpp @@ -280,7 +280,7 @@ RadioView::Refresh() // age messages: for (int i = 0; i < MAX_MSG; i++) { if (msg_time[i] > 0) { - msg_time[i] -= Game::GetInstance()->GUITime(); + msg_time[i] -= Game::GetInstance()->GetClock()->GuiDelta(); if (msg_time[i] <= 0) { msg_time[i] = 0; diff --git a/Stars45/SeekerAI.cpp b/Stars45/SeekerAI.cpp index 472c419..173e5b8 100644 --- a/Stars45/SeekerAI.cpp +++ b/Stars45/SeekerAI.cpp @@ -61,7 +61,7 @@ void SeekerAI::Navigator() { if (delay > 0) { - delay -= Game::GetInstance()->FrameTime(); + delay -= Game::GetInstance()->GetClock()->Delta(); } else { Steer s = SeekTarget(); diff --git a/Stars45/Ship.cpp b/Stars45/Ship.cpp index 45c4c92..3ac957e 100644 --- a/Stars45/Ship.cpp +++ b/Stars45/Ship.cpp @@ -1043,7 +1043,7 @@ Ship::ClearTrack() track[0] = Location(); ntrack = 1; - track_time = Game::GetInstance()->GameTime(); + track_time = Game::GetInstance()->GetClock()->GameTime(); } void @@ -1052,7 +1052,7 @@ Ship::UpdateTrack() const int DEFAULT_TRACK_UPDATE = 500; // milliseconds const int DEFAULT_TRACK_LENGTH = 20; // 10 seconds - DWORD time = Game::GetInstance()->GameTime(); + DWORD time = Game::GetInstance()->GetClock()->GameTime(); if (!track) { track = new(__FILE__,__LINE__) Point[DEFAULT_TRACK_LENGTH]; @@ -1323,7 +1323,7 @@ void Ship::SetFlightPhase(OP_MODE phase) { if (phase == ACTIVE && !launch_time) { - launch_time = Game::GetInstance()->GameTime() + 1; + launch_time = Game::GetInstance()->GetClock()->GameTime() + 1; dock = 0; if (element) @@ -1643,8 +1643,8 @@ Ship::HitBy(Shot* shot, Point& impact) RadioMessage* warn = new(__FILE__,__LINE__) RadioMessage(s, this, RadioMessage::DECLARE_ROGUE); RadioTraffic::Transmit(warn); } - else if (!s->IsRogue() && (Game::GetInstance()->GameTime() - ff_warn_time) > 5000) { - ff_warn_time = Game::GetInstance()->GameTime(); + else if (!s->IsRogue() && (Game::GetInstance()->GetClock()->GameTime() - ff_warn_time) > 5000) { + ff_warn_time = Game::GetInstance()->GetClock()->GameTime(); RadioMessage* warn = 0; if (s->GetTarget() == this) @@ -1956,7 +1956,7 @@ Ship::CheckFriendlyFire() return; // only check once each second - if (Game::GetInstance()->GameTime() - friendly_fire_time < 1000) + if (Game::GetInstance()->GetClock()->GameTime() - friendly_fire_time < 1000) return; List<Weapon> w_list; @@ -2013,7 +2013,7 @@ Ship::CheckFriendlyFire() } } - friendly_fire_time = Game::GetInstance()->GameTime() + (DWORD) Random(0, 500); + friendly_fire_time = Game::GetInstance()->GetClock()->GameTime() + (DWORD) Random(0, 500); } // +----------------------------------------------------------------------+ @@ -2613,10 +2613,10 @@ Ship::ExecEvalFrame(double seconds) static DWORD last_eval_frame = 0; // one ship per game frame if (element && element->NumObjectives() > 0 && - Game::GetInstance()->GameTime() - last_eval_time > EVAL_FREQUENCY && + Game::GetInstance()->GetClock()->GameTime() - last_eval_time > EVAL_FREQUENCY && last_eval_frame != Game::GetInstance()->Frame()) { - last_eval_time = Game::GetInstance()->GameTime(); + last_eval_time = Game::GetInstance()->GetClock()->GameTime(); last_eval_frame = Game::GetInstance()->Frame(); for (int i = 0; i < element->NumObjectives(); i++) { @@ -3027,7 +3027,7 @@ Ship::StatFrame(double seconds) { if (flight_phase != ACTIVE) { flight_phase = ACTIVE; - launch_time = Game::GetInstance()->GameTime() + 1; + launch_time = Game::GetInstance()->GetClock()->GameTime() + 1; if (element) element->SetLaunchTime(launch_time); @@ -4516,26 +4516,26 @@ Ship::InflictDamage(double damage, Shot* shot, int hit_type, Point impact) if (shot) { if (shot->IsBeam()) { if (design->beam_hit_sound_resource) { - if (Game::GetInstance()->RealTime() - last_beam_time > 400) { + if (Game::GetInstance()->GetClock()->RealTime() - last_beam_time > 400) { Sound* s = design->beam_hit_sound_resource->Duplicate(); s->SetLocation(impact); s->SetVolume(AudioConfig::EfxVolume()); s->Play(); - last_beam_time = Game::GetInstance()->RealTime(); + last_beam_time = Game::GetInstance()->GetClock()->RealTime(); } } } else { if (design->bolt_hit_sound_resource) { - if (Game::GetInstance()->RealTime() - last_bolt_time > 400) { + if (Game::GetInstance()->GetClock()->RealTime() - last_bolt_time > 400) { Sound* s = design->bolt_hit_sound_resource->Duplicate(); s->SetLocation(impact); s->SetVolume(AudioConfig::EfxVolume()); s->Play(); - last_bolt_time = Game::GetInstance()->RealTime(); + last_bolt_time = Game::GetInstance()->GetClock()->RealTime(); } } } @@ -4814,10 +4814,10 @@ Ship::ExecMaintFrame(double seconds) static DWORD last_repair_frame = 0; // one ship per game frame if (auto_repair && - Game::GetInstance()->GameTime() - last_repair_time > REPAIR_FREQUENCY && + Game::GetInstance()->GetClock()->GameTime() - last_repair_time > REPAIR_FREQUENCY && last_repair_frame != Game::GetInstance()->Frame()) { - last_repair_time = Game::GetInstance()->GameTime(); + last_repair_time = Game::GetInstance()->GetClock()->GameTime(); last_repair_frame = Game::GetInstance()->Frame(); ListIter<System> iter = systems; @@ -5199,7 +5199,7 @@ DWORD Ship::MissionClock() const { if (launch_time > 0) - return Game::GetInstance()->GameTime() + 1 - launch_time; + return Game::GetInstance()->GetClock()->GameTime() + 1 - launch_time; return 0; } diff --git a/Stars45/ShipAI.cpp b/Stars45/ShipAI.cpp index 892f41e..c3d5a3a 100644 --- a/Stars45/ShipAI.cpp +++ b/Stars45/ShipAI.cpp @@ -279,12 +279,12 @@ ShipAI::ExecFrame(double secs) if (target == ship->GetTarget() && target->Type() == SimObject::SIM_SHIP) { // if this isn't the same ship we last called out: - if (target->Identity() != engaged_ship_id && Game::GetInstance()->GameTime() - last_call_time > 10000) { + if (target->Identity() != engaged_ship_id && Game::GetInstance()->GetClock()->GameTime() - last_call_time > 10000) { // call engaging: RadioMessage* msg = new(__FILE__,__LINE__) RadioMessage(ship->GetElement(), ship, RadioMessage::CALL_ENGAGING); msg->AddTarget(target); RadioTraffic::Transmit(msg); - last_call_time = Game::GetInstance()->GameTime(); + last_call_time = Game::GetInstance()->GetClock()->GameTime(); engaged_ship_id = target->Identity(); } @@ -1047,7 +1047,7 @@ ShipAI::AvoidCollision() last_avoid_time = 0; // check for a new obstacle immediately } - if (!other && Game::GetInstance()->GameTime() - last_avoid_time < 500) + if (!other && Game::GetInstance()->GetClock()->GameTime() - last_avoid_time < 500) return avoid; brake = 0; @@ -1124,7 +1124,7 @@ ShipAI::AvoidCollision() } } - last_avoid_time = Game::GetInstance()->GameTime(); + last_avoid_time = Game::GetInstance()->GetClock()->GameTime(); return avoid; } diff --git a/Stars45/ShipCtrl.cpp b/Stars45/ShipCtrl.cpp index 0dcb0b9..8273ec1 100644 --- a/Stars45/ShipCtrl.cpp +++ b/Stars45/ShipCtrl.cpp @@ -62,8 +62,8 @@ ShipCtrl::Toggled(int action) static double last_toggle_time = 0; if (KeyDown(action)) { - if ((Game::GetInstance()->RealTime() - last_toggle_time) > 250) { - last_toggle_time = Game::GetInstance()->RealTime(); + if ((Game::GetInstance()->GetClock()->RealTime() - last_toggle_time) > 250) { + last_toggle_time = Game::GetInstance()->GetClock()->RealTime(); return 1; } } diff --git a/Stars45/Shot.cpp b/Stars45/Shot.cpp index 7878569..4628615 100644 --- a/Stars45/Shot.cpp +++ b/Stars45/Shot.cpp @@ -504,7 +504,7 @@ Shot::Damage() const fade = (design->length - len) / (design->length - design->min_range); } - damage = base_damage * charge * fade * Game::GetInstance()->FrameTime(); + damage = base_damage * charge * fade * Game::GetInstance()->GetClock()->Delta(); } // energy wep damage based on time: diff --git a/Stars45/Sim.cpp b/Stars45/Sim.cpp index cd2fb87..3933855 100644 --- a/Stars45/Sim.cpp +++ b/Stars45/Sim.cpp @@ -395,7 +395,7 @@ Sim::ExecMission() } first_frame = true; - start_time = Game::GetInstance()->GameTime(); + start_time = Game::GetInstance()->GetClock()->GameTime(); AudioConfig::SetTraining(mission->Type() == Mission::TRAINING); } @@ -1896,7 +1896,7 @@ Sim::ProcessEventTrigger(int type, int event_id, const char* ship, int param) double Sim::MissionClock() const { - return (Game::GetInstance()->GameTime() - start_time) / 1000.0; + return (Game::GetInstance()->GetClock()->GameTime() - start_time) / 1000.0; } // +--------------------------------------------------------------------+ @@ -1933,7 +1933,7 @@ Sim::SkipCutscene() double skip_time = end_time - MissionClock(); if (skip_time > 0) { - Game::GetInstance()->SkipGameTime(skip_time); + Game::GetInstance()->GetClock()->SkipGameTime(skip_time); } } } @@ -1987,7 +1987,7 @@ Sim::ResolveTimeSkip(double seconds) player_ship->SetControls(0); } - Game::GetInstance()->SkipGameTime(skipped); + Game::GetInstance()->GetClock()->SkipGameTime(skipped); CameraDirector::SetCameraMode(CameraDirector::MODE_COCKPIT); } @@ -2510,7 +2510,7 @@ SimRegion::ExecFrame(double secs) // DON'T REALLY KNOW WHAT PURPOSE THIS SERVES.... if (!active) { double max_frame = 3 * Game::GetInstance()->GetMaxFrameLength(); - long new_time = Game::GetInstance()->GameTime(); + long new_time = Game::GetInstance()->GetClock()->GameTime(); double delta = new_time - sim_time; seconds = delta / 1000.0; @@ -2518,7 +2518,7 @@ SimRegion::ExecFrame(double secs) seconds = max_frame; } - sim_time = Game::GetInstance()->GameTime(); + sim_time = Game::GetInstance()->GetClock()->GameTime(); if (orbital_region) location = orbital_region->Location(); @@ -3798,7 +3798,7 @@ const char* FormatGameTime() { static char txt[64]; - int t = Game::GetInstance()->GameTime(); + int t = Game::GetInstance()->GetClock()->GameTime(); int h = ( t / 3600000); int m = ((t - h*3600000) / 60000); diff --git a/Stars45/SimEvent.cpp b/Stars45/SimEvent.cpp index 60d254d..fc4cc7f 100644 --- a/Stars45/SimEvent.cpp +++ b/Stars45/SimEvent.cpp @@ -31,7 +31,7 @@ SimEvent::SimEvent(int e, const char* t, const char* i) time = (int) sim->MissionClock(); } else { - time = (int) (Game::GetInstance()->GameTime()/1000); + time = (int) (Game::GetInstance()->GetClock()->GameTime()/1000); } SetTarget(t); diff --git a/Stars45/Sprite.cpp b/Stars45/Sprite.cpp index f519bb3..295833f 100644 --- a/Stars45/Sprite.cpp +++ b/Stars45/Sprite.cpp @@ -169,7 +169,7 @@ Sprite::SetAnimation(Bitmap* animation, int length, int repeat, int share) life = nframes; } - last_time = Game::GetInstance()->RealTime() - frame_time; + last_time = Game::GetInstance()->GetClock()->RealTime() - frame_time; } } @@ -362,7 +362,7 @@ void Sprite::Update() { if (life > 0 || loop) { - DWORD time = Game::GetInstance()->RealTime(); + DWORD time = Game::GetInstance()->GetClock()->RealTime(); while (time - last_time > frame_time) { life--; frame_index++; diff --git a/Stars45/StarServer.cpp b/Stars45/StarServer.cpp index 34eb77f..25d4dd9 100644 --- a/Stars45/StarServer.cpp +++ b/Stars45/StarServer.cpp @@ -168,7 +168,7 @@ StarServer::InitGame() Shot::Initialize(); RadioTraffic::Initialize(); - time_mark = Game::GetInstance()->GameTime(); + time_mark = Game::GetInstance()->GetClock()->GameTime(); minutes = 0; NetServerConfig* server_config = NetServerConfig::GetInstance(); @@ -339,8 +339,8 @@ StarServer::UpdateWorld() } static DWORD refresh_time = 0; - if (RealTime() - refresh_time > 1000) { - refresh_time = RealTime(); + if (clock.RealTime() - refresh_time > 1000) { + refresh_time = clock.RealTime(); RedrawWindow(hwnd, 0, 0, RDW_ERASE|RDW_INVALIDATE); } } @@ -369,8 +369,8 @@ StarServer::GameState() } else if (game_mode == PLAY_MODE) { - if (Game::GetInstance()->GameTime() - time_mark > 60000) { - time_mark = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - time_mark > 60000) { + time_mark = Game::GetInstance()->GetClock()->GameTime(); minutes++; if (minutes > 60) Print(" TIME %2d:%02d:00\n", minutes/60, minutes%60); diff --git a/Stars45/StarSystem.cpp b/Stars45/StarSystem.cpp index 77d92c1..e78d970 100644 --- a/Stars45/StarSystem.cpp +++ b/Stars45/StarSystem.cpp @@ -69,7 +69,7 @@ void StarSystem::CalcStardate() base_time += epoch; } - long double gtime = (long double) Game::GetInstance()->GameTime() / 1000.0; + long double gtime = (long double) Game::GetInstance()->GetClock()->GameTime() / 1000.0; long double sdate = gtime + base_time + epoch; stardate = sdate; diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp index eb971e8..6c48e32 100644 --- a/Stars45/Starshatter.cpp +++ b/Stars45/Starshatter.cpp @@ -457,7 +457,7 @@ Starshatter::InitGame() SetupSplash(); } - time_mark = Game::GetInstance()->GameTime(); + time_mark = Game::GetInstance()->GetClock()->GameTime(); minutes = 0; return true; @@ -1089,7 +1089,7 @@ Starshatter::GameState() } if (game_mode == EXIT_MODE) { - exit_time -= Game::GetInstance()->GUITime(); + exit_time -= Game::GetInstance()->GetClock()->GuiDelta(); if (exit_time <= 0) Game::Exit(); @@ -1115,7 +1115,7 @@ Starshatter::DoMenuScreenFrame() } if (time_til_change > 0) - time_til_change -= Game::GetInstance()->GUITime(); + time_til_change -= Game::GetInstance()->GetClock()->GuiDelta(); if (!menuscreen) return; @@ -1177,7 +1177,7 @@ Starshatter::DoPlanScreenFrame() Mouse::SetCursor(Mouse::ARROW); if (time_til_change > 0) - time_til_change -= Game::GetInstance()->GUITime(); + time_til_change -= Game::GetInstance()->GetClock()->GuiDelta(); if (KeyDown(KEY_EXIT)) { if (time_til_change <= 0) { @@ -1210,7 +1210,7 @@ Starshatter::DoCmpnScreenFrame() Mouse::SetCursor(Mouse::ARROW); if (time_til_change > 0) - time_til_change -= Game::GetInstance()->GUITime(); + time_til_change -= Game::GetInstance()->GetClock()->GuiDelta(); exit_latch = KeyDown(KEY_EXIT) ? true : false; @@ -1504,7 +1504,7 @@ Starshatter::DoGameScreenFrame() } if (time_til_change > 0) - time_til_change -= Game::GetInstance()->GUITime(); + time_til_change -= Game::GetInstance()->GetClock()->GuiDelta(); if (exit_latch && !KeyDown(KEY_EXIT)) exit_latch = false; @@ -1572,8 +1572,8 @@ Starshatter::DoGameScreenFrame() gamescreen->FrameRate(frame_rate); gamescreen->ExecFrame(); - if (Game::GetInstance()->GameTime() - time_mark > 60000) { - time_mark = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - time_mark > 60000) { + time_mark = Game::GetInstance()->GetClock()->GameTime(); minutes++; if (minutes > 60) Print(" TIME %2d:%02d:00\n", minutes/60, minutes%60); @@ -1829,7 +1829,7 @@ Starshatter::DoGameKeys() } if (cam_dir) { - double spin = (PI/2) * Game::GetInstance()->FrameTime(); // Game::GetInstance()->GUITime(); + double spin = (PI/2) * Game::GetInstance()->GetClock()->Delta(); // Game::GetInstance()->GetClock()->GuiDelta(); if (KeyDown(KEY_CAM_EXT_PLUS_AZ)) cam_dir->ExternalAzimuth(spin); @@ -1857,13 +1857,13 @@ Starshatter::DoGameKeys() if (KeyDown(KEY_CAM_EXT_PLUS_RANGE)){ if (!gamescreen->IsNavShown()) { - cam_dir->ExternalRange((float) (1 + 1.5 * Game::GetInstance()->FrameTime())); // 1.1f); + cam_dir->ExternalRange((float) (1 + 1.5 * Game::GetInstance()->GetClock()->Delta())); // 1.1f); } } else if (KeyDown(KEY_CAM_EXT_MINUS_RANGE)) { if (!gamescreen->IsNavShown()) { - cam_dir->ExternalRange((float) (1 - 1.5 * Game::GetInstance()->FrameTime())); // 0.9f); + cam_dir->ExternalRange((float) (1 - 1.5 * Game::GetInstance()->GetClock()->Delta())); // 0.9f); } } diff --git a/Stars45/StarshipAI.cpp b/Stars45/StarshipAI.cpp index 3057f1d..5a32391 100644 --- a/Stars45/StarshipAI.cpp +++ b/Stars45/StarshipAI.cpp @@ -66,7 +66,7 @@ StarshipAI::StarshipAI(SimObject* s) tactical = new(__FILE__,__LINE__) StarshipTacticalAI(this); } - sub_select_time = Game::GetInstance()->GameTime() + (DWORD) Random(0, 2000); + sub_select_time = Game::GetInstance()->GetClock()->GameTime() + (DWORD) Random(0, 2000); point_defense_time = sub_select_time; } @@ -639,7 +639,7 @@ StarshipAI::FireControl() System* StarshipAI::SelectSubtarget() { - if (Game::GetInstance()->GameTime() - sub_select_time < 2345) + if (Game::GetInstance()->GetClock()->GameTime() - sub_select_time < 2345) return subtarget; subtarget = 0; @@ -656,7 +656,7 @@ StarshipAI::SelectSubtarget() double dist = 50e3; Point svec = ship->Location() - tgt_ship->Location(); - sub_select_time = Game::GetInstance()->GameTime(); + sub_select_time = Game::GetInstance()->GetClock()->GameTime(); // first pass: turrets ListIter<WeaponGroup> g_iter = tgt_ship->Weapons(); @@ -727,7 +727,7 @@ StarshipAI::SelectSubtarget() bool StarshipAI::AssessTargetPointDefense() { - if (Game::GetInstance()->GameTime() - point_defense_time < 3500) + if (Game::GetInstance()->GetClock()->GameTime() - point_defense_time < 3500) return tgt_point_defense; tgt_point_defense = false; @@ -743,7 +743,7 @@ StarshipAI::AssessTargetPointDefense() Weapon* subtgt = 0; Point svec = ship->Location() - tgt_ship->Location(); - point_defense_time = Game::GetInstance()->GameTime(); + point_defense_time = Game::GetInstance()->GetClock()->GameTime(); // first pass: turrets ListIter<WeaponGroup> g_iter = tgt_ship->Weapons(); diff --git a/Stars45/StarshipTacticalAI.cpp b/Stars45/StarshipTacticalAI.cpp index 241a06f..1a7db8c 100644 --- a/Stars45/StarshipTacticalAI.cpp +++ b/Stars45/StarshipTacticalAI.cpp @@ -124,7 +124,7 @@ StarshipTacticalAI::FindThreat() } if (contact->Threat(ship) && - (Game::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { + (Game::GetInstance()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { if (c_shot) { threat_missile = c_shot; diff --git a/Stars45/SteerAI.cpp b/Stars45/SteerAI.cpp index 8d95b73..441773a 100644 --- a/Stars45/SteerAI.cpp +++ b/Stars45/SteerAI.cpp @@ -429,8 +429,8 @@ SteerAI::Evade(const Point& point, const Point& vel) { Steer evade; - if (Game::GetInstance()->GameTime() - evade_time > 1250) { - evade_time = Game::GetInstance()->GameTime(); + if (Game::GetInstance()->GetClock()->GameTime() - evade_time > 1250) { + evade_time = Game::GetInstance()->GetClock()->GameTime(); int direction = (rand()>>9) & 0x07; diff --git a/Stars45/TacticalAI.cpp b/Stars45/TacticalAI.cpp index b2ad350..8a8b155 100644 --- a/Stars45/TacticalAI.cpp +++ b/Stars45/TacticalAI.cpp @@ -80,7 +80,7 @@ TacticalAI::ExecFrame(double secs) navpt = ship->GetNextNavPoint(); orders = ship->GetRadioOrders(); - if ((int) Game::GetInstance()->GameTime() - exec_time > exec_period) { + if ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > exec_period) { element_index = ship->GetElementIndex(); CheckOrders(); @@ -833,7 +833,7 @@ TacticalAI::FindThreat() Contact* contact = iter.value(); if (contact->Threat(ship) && - (Game::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { + (Game::GetInstance()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) { if (contact->GetShot()) { threat_missile = contact->GetShot(); diff --git a/Stars45/TacticalView.cpp b/Stars45/TacticalView.cpp index 9fe4b87..4bd458c 100644 --- a/Stars45/TacticalView.cpp +++ b/Stars45/TacticalView.cpp @@ -549,12 +549,12 @@ TacticalView::DoMouseFrame() if (Mouse::RButton()) { MouseController* mouse_con = MouseController::GetInstance(); if (!right_down && (!mouse_con || !mouse_con->Active())) { - rbutton_latch = Game::GetInstance()->RealTime(); + rbutton_latch = Game::GetInstance()->GetClock()->RealTime(); right_down = true; } } else { - if (sim && right_down && (Game::GetInstance()->RealTime() - rbutton_latch < 250)) { + if (sim && right_down && (Game::GetInstance()->GetClock()->RealTime() - rbutton_latch < 250)) { Ship* seln = WillSelectAt(Mouse::X(), Mouse::Y()); if (seln && sim->IsSelected(seln) && @@ -656,10 +656,10 @@ TacticalView::DoMouseFrame() if (dx < 3 && dy < 3) { bool hit = SelectAt(mouse_x, mouse_y); - if (ship->IsStarship() && Game::GetInstance()->RealTime() - click_time < 350) + if (ship->IsStarship() && Game::GetInstance()->GetClock()->RealTime() - click_time < 350) SetHelm(hit); - click_time = Game::GetInstance()->RealTime(); + click_time = Game::GetInstance()->GetClock()->RealTime(); } } } @@ -1433,7 +1433,7 @@ TacticalView::DrawAction() } if (tgt && r) { - if ((Game::GetInstance()->RealTime()/200) & 1) + if ((Game::GetInstance()->GetClock()->RealTime()/200) & 1) r = 20; else r = 15; diff --git a/Stars45/Trail.cpp b/Stars45/Trail.cpp index 97e6666..71f224f 100644 --- a/Stars45/Trail.cpp +++ b/Stars45/Trail.cpp @@ -141,7 +141,7 @@ Trail::AddPoint(const Point& v) { if (ntrail >= maxtrail-1) return; - double real_time = Game::GetInstance()->RealTime() / 1000.0; + double real_time = Game::GetInstance()->GetClock()->RealTime() / 1000.0; if (ntrail == 0) { radius = 1000; diff --git a/Stars45/Weapon.cpp b/Stars45/Weapon.cpp index 4d3eaa5..2e35157 100644 --- a/Stars45/Weapon.cpp +++ b/Stars45/Weapon.cpp @@ -1145,7 +1145,7 @@ Weapon::CanLockPoint(const Point& test, double& az, double& el, Point* obj) void Weapon::AimTurret(double az, double el) { - double seconds = (Game::GetInstance()->GameTime() - aim_time) / 1000.0; + double seconds = (Game::GetInstance()->GetClock()->GameTime() - aim_time) / 1000.0; // don't let the weapon turn faster than turret slew rate: double max_turn = design->slew_rate * seconds; @@ -1170,7 +1170,7 @@ Weapon::AimTurret(double az, double el) old_azimuth = (float) az; old_elevation = (float) el; - aim_time = Game::GetInstance()->GameTime(); + aim_time = Game::GetInstance()->GetClock()->GameTime(); } void diff --git a/Stars45/WepView.cpp b/Stars45/WepView.cpp index 03363b1..508d269 100644 --- a/Stars45/WepView.cpp +++ b/Stars45/WepView.cpp @@ -387,11 +387,11 @@ WepView::DrawOverlay() Text subtxt; Color stat = hud_color; - static DWORD blink = Game::GetInstance()->RealTime(); + static DWORD blink = Game::GetInstance()->GetClock()->RealTime(); if (ship->GetTarget()) { if (ship->GetSubTarget()) { - int blink_delta = Game::GetInstance()->RealTime() - blink; + int blink_delta = Game::GetInstance()->GetClock()->RealTime() - blink; System* sys = ship->GetSubTarget(); subtxt = sys->Abbreviation(); @@ -406,7 +406,7 @@ WepView::DrawOverlay() } if (blink_delta > 500) - blink = Game::GetInstance()->RealTime(); + blink = Game::GetInstance()->GetClock()->RealTime(); } else |