summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-23 22:57:42 +0100
committerAki <please@ignore.pl>2022-03-23 22:57:42 +0100
commit6b2a17a2ccb1a0d45489208f7f23b9d6a65b110d (patch)
tree0c0c86871cdd51462617a946a9f35fe3501bd6a7
parent9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4 (diff)
downloadstarshatter-6b2a17a2ccb1a0d45489208f7f23b9d6a65b110d.zip
starshatter-6b2a17a2ccb1a0d45489208f7f23b9d6a65b110d.tar.gz
starshatter-6b2a17a2ccb1a0d45489208f7f23b9d6a65b110d.tar.bz2
Removed Clock from Game for now
While testing waters around exporting things out from Game to GameWinDX9 I noticed that if both ContentBundle and Clock (primarily) are removed from it, then the WinDX9 will be almost equivalent to base. This is worrying mainly because I'm only fortified in seeing deep relationships between various classes sadly including Video.
-rw-r--r--Stars45/Bitmap.cpp40
-rw-r--r--Stars45/Campaign.cpp10
-rw-r--r--Stars45/CarrierAI.cpp16
-rw-r--r--Stars45/Clock.cpp30
-rw-r--r--Stars45/Clock.h9
-rw-r--r--Stars45/CmpLoadDlg.cpp6
-rw-r--r--Stars45/CmpSceneDlg.cpp6
-rw-r--r--Stars45/CmpSelectDlg.cpp4
-rw-r--r--Stars45/Contact.cpp13
-rw-r--r--Stars45/CtlDlg.cpp5
-rw-r--r--Stars45/DebriefDlg.cpp4
-rw-r--r--Stars45/Debris.cpp4
-rw-r--r--Stars45/DisplayView.cpp4
-rw-r--r--Stars45/Drone.cpp4
-rw-r--r--Stars45/ExitDlg.cpp4
-rw-r--r--Stars45/FadeView.cpp4
-rw-r--r--Stars45/FighterAI.cpp18
-rw-r--r--Stars45/FighterTacticalAI.cpp8
-rw-r--r--Stars45/Font.cpp3
-rw-r--r--Stars45/Game.cpp20
-rw-r--r--Stars45/Game.h6
-rw-r--r--Stars45/GroundAI.cpp6
-rw-r--r--Stars45/HUDView.cpp21
-rw-r--r--Stars45/MenuView.cpp6
-rw-r--r--Stars45/Mfd.cpp15
-rw-r--r--Stars45/ModDlg.cpp6
-rw-r--r--Stars45/MouseController.cpp10
-rw-r--r--Stars45/MsnEditDlg.cpp10
-rw-r--r--Stars45/MusicTrack.cpp3
-rw-r--r--Stars45/NavDlg.cpp6
-rw-r--r--Stars45/NavLight.cpp4
-rw-r--r--Stars45/NetGameClient.cpp4
-rw-r--r--Stars45/NetGameServer.cpp9
-rw-r--r--Stars45/NetLobbyServer.cpp8
-rw-r--r--Stars45/NetUnitDlg.cpp5
-rw-r--r--Stars45/Particles.cpp10
-rw-r--r--Stars45/Player.cpp6
-rw-r--r--Stars45/QuantumView.cpp4
-rw-r--r--Stars45/QuitView.cpp5
-rw-r--r--Stars45/RadioView.cpp4
-rw-r--r--Stars45/ScrollWindow.cpp3
-rw-r--r--Stars45/SeekerAI.cpp4
-rw-r--r--Stars45/Ship.cpp37
-rw-r--r--Stars45/ShipAI.cpp10
-rw-r--r--Stars45/ShipCtrl.cpp6
-rw-r--r--Stars45/Shot.cpp3
-rw-r--r--Stars45/Sim.cpp15
-rw-r--r--Stars45/SimEvent.cpp4
-rw-r--r--Stars45/Sky.cpp4
-rw-r--r--Stars45/Sprite.cpp6
-rw-r--r--Stars45/StarServer.cpp15
-rw-r--r--Stars45/StarSystem.cpp3
-rw-r--r--Stars45/Starshatter.cpp55
-rw-r--r--Stars45/StarshipAI.cpp12
-rw-r--r--Stars45/StarshipTacticalAI.cpp4
-rw-r--r--Stars45/SteerAI.cpp6
-rw-r--r--Stars45/TacticalAI.cpp6
-rw-r--r--Stars45/TacticalView.cpp12
-rw-r--r--Stars45/Trail.cpp5
-rw-r--r--Stars45/Weapon.cpp5
-rw-r--r--Stars45/WepView.cpp8
61 files changed, 312 insertions, 271 deletions
diff --git a/Stars45/Bitmap.cpp b/Stars45/Bitmap.cpp
index 865b726..e5b8811 100644
--- a/Stars45/Bitmap.cpp
+++ b/Stars45/Bitmap.cpp
@@ -13,9 +13,9 @@
#include "MemDebug.h"
#include "Bitmap.h"
+#include "Clock.h"
#include "Video.h"
#include "Color.h"
-#include "Game.h"
#include "GameWinDX9.h"
// +--------------------------------------------------------------------+
@@ -72,7 +72,7 @@ Bitmap::Bitmap(int w, int h, ColorIndex* p, int t)
: type(t), width(w), height(h),
ownpix(false), alpha_loaded(false), texture(false),
pix(p), hipix(0), mapsize(w*h),
- last_modified(Game::GetInstance()->GetClock()->RealTime())
+ last_modified(Clock::GetInstance()->RealTime())
{
sprintf_s(filename, "Bitmap(%d, %d, index, type=%d)", w, h, (int) t);
}
@@ -81,7 +81,7 @@ Bitmap::Bitmap(int w, int h, Color* p, int t)
: type(t), width(w), height(h),
ownpix(false), alpha_loaded(false), texture(false),
pix(0), hipix(p), mapsize(w*h),
- last_modified(Game::GetInstance()->GetClock()->RealTime())
+ last_modified(Clock::GetInstance()->RealTime())
{
sprintf_s(filename, "Bitmap(%d, %d, hicolor, type=%d)", w, h, (int) t);
}
@@ -238,7 +238,7 @@ Bitmap::BitBlt(int x, int y, const Bitmap& srcBmp, int sx, int sy, int w, int h,
}
alpha_loaded = srcBmp.alpha_loaded;
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -290,7 +290,7 @@ Bitmap::CopyBitmap(const Bitmap& rhs)
}
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -312,7 +312,7 @@ Bitmap::ClearImage()
ownpix = false;
texture = false;
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -347,7 +347,7 @@ Bitmap::CopyImage(int w, int h, BYTE* p, int t)
memcpy(pix, p, mapsize);
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -382,7 +382,7 @@ Bitmap::CopyHighColorImage(int w, int h, DWORD* p, int t)
memcpy(hipix, p, mapsize*sizeof(DWORD));
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -404,7 +404,7 @@ Bitmap::CopyAlphaImage(int w, int h, BYTE* a)
a++;
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
void
@@ -424,7 +424,7 @@ Bitmap::CopyAlphaRedChannel(int w, int h, DWORD* a)
a++;
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -450,7 +450,7 @@ Bitmap::AutoMask(DWORD mask)
p++;
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -479,7 +479,7 @@ Bitmap::FillColor(Color c)
}
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -749,7 +749,7 @@ Bitmap::SetIndex(int x, int y, ColorIndex c)
*(hipix + y*width + x) = c.Index();
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -767,7 +767,7 @@ Bitmap::SetColor(int x, int y, Color c)
*(hipix + y*width + x) = c;
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -1023,7 +1023,7 @@ Bitmap::DrawLine(int x1, int y1, int x2, int y2, Color color)
if (!s) return;
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
// vertical lines:
if (x1==x2) {
@@ -1301,7 +1301,7 @@ Bitmap::DrawRect(int x1, int y1, int x2, int y2, Color color)
if (top) draw_strip(s, pitch, pixsize, x1, y1, fw, color);
if (bottom) draw_strip(s, pitch, pixsize, x1, y2, fw, color);
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -1332,7 +1332,7 @@ Bitmap::DrawRect(const Rect& r, Color color)
if (top) draw_strip(s, pitch, pixsize, x1, y1, r.w, color);
if (bottom) draw_strip(s, pitch, pixsize, x1, y2, r.w, color);
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -1359,7 +1359,7 @@ Bitmap::FillRect(int x1, int y1, int x2, int y2, Color color)
for (int i = 0; i < fh; i++)
draw_strip(s, pitch, pixsize, x1, y1+i, fw, color);
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -1391,7 +1391,7 @@ Bitmap::FillRect(const Rect& r, Color color)
for (int i = 0; i < fh; i++)
draw_strip(s, pitch, pixsize, x1, y1+i, fw, color);
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -1472,7 +1472,7 @@ Bitmap::DrawEllipse(int x1, int y1, int x2, int y2, Color color, BYTE quad)
DrawEllipsePoints(x0,y0,x,y,color,quad);
}
- last_modified = Game::GetInstance()->GetClock()->RealTime();
+ last_modified = Clock::GetInstance()->RealTime();
}
void
diff --git a/Stars45/Campaign.cpp b/Stars45/Campaign.cpp
index e41b24a..d6e4fb1 100644
--- a/Stars45/Campaign.cpp
+++ b/Stars45/Campaign.cpp
@@ -34,8 +34,8 @@
#include "Player.h"
#include "ContentBundle.h"
-#include "Game.h"
#include "Bitmap.h"
+#include "Clock.h"
#include "DataLoader.h"
#include "ParseUtil.h"
#include "Random.h"
@@ -409,7 +409,7 @@ Campaign::Unload()
{
SetStatus(CAMPAIGN_INIT);
- Game::GetInstance()->GetClock()->ResetGameTime();
+ Clock::GetInstance()->ResetGameTime();
StarSystem::SetBaseTime(0);
startTime = Stardate();
@@ -1942,7 +1942,7 @@ Campaign::ExecFrame()
else
time += 20 * 3600;
- StarSystem::SetBaseTime(startTime + time - Game::GetInstance()->GetClock()->GameTime()/1000.0);
+ StarSystem::SetBaseTime(startTime + time - Clock::GetInstance()->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()->GetClock()->GameTime() / 1000.0;
+ long double gtime = (long double) Clock::GetInstance()->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()->GetClock()->GameTime() / 1000.0;
+ long double gtime = (long double) Clock::GetInstance()->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 235a073..dc55dc5 100644
--- a/Stars45/CarrierAI.cpp
+++ b/Stars45/CarrierAI.cpp
@@ -30,7 +30,7 @@
#include "Callsign.h"
#include "NetUtil.h"
-#include "Game.h"
+#include "Clock.h"
#include "Random.h"
// +----------------------------------------------------------------------+
@@ -49,7 +49,7 @@ CarrierAI::CarrierAI(Ship* s, int level)
if (ship)
flight_planner = new(__FILE__,__LINE__) FlightPlanner(ship);
- hold_time = (int) Game::GetInstance()->GetClock()->GameTime();
+ hold_time = (int) Clock::GetInstance()->GameTime();
}
}
@@ -69,13 +69,13 @@ CarrierAI::ExecFrame(double secs)
if (!sim || !ship || !hangar)
return;
- if (((int) Game::GetInstance()->GetClock()->GameTime() - hold_time >= INIT_HOLD) &&
- ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > EXEC_PERIOD)) {
+ if (((int) Clock::GetInstance()->GameTime() - hold_time >= INIT_HOLD) &&
+ ((int) Clock::GetInstance()->GameTime() - exec_time > EXEC_PERIOD)) {
CheckHostileElements();
CheckPatrolCoverage();
- exec_time = (int) Game::GetInstance()->GetClock()->GameTime();
+ exec_time = (int) Clock::GetInstance()->GameTime();
}
}
@@ -132,7 +132,7 @@ CarrierAI::CheckPatrolCoverage()
}
}
- else if (Game::GetInstance()->GetClock()->GameTime() - hangar->GetLastPatrolLaunch() > PATROL_PERIOD ||
+ else if (Clock::GetInstance()->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()->GetClock()->GameTime());
+ hangar->SetLastPatrolLaunch(Clock::GetInstance()->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()->GetClock()->GameTime() + 30000;
+ hold_time = (int) Clock::GetInstance()->GameTime() + 30000;
return true;
}
}
diff --git a/Stars45/Clock.cpp b/Stars45/Clock.cpp
index 03c2771..e5db6c3 100644
--- a/Stars45/Clock.cpp
+++ b/Stars45/Clock.cpp
@@ -11,6 +11,36 @@
static constexpr double NO_COMPRESSION {1.0};
static constexpr double STARTING_DELTA {1.0 / 60.0};
+Clock* Clock::instance = nullptr;
+
+
+Clock*
+Clock::GetInstance()
+{
+ return instance;
+}
+
+
+bool
+Clock::Init()
+{
+ if (instance == nullptr) {
+ instance = new Clock();
+ return instance != nullptr;
+ }
+ return false;
+}
+
+
+void
+Clock::Close()
+{
+ if (instance != nullptr) {
+ delete instance;
+ instance = nullptr;
+ }
+}
+
Clock::Clock() :
m_point {inner_clock::now()},
diff --git a/Stars45/Clock.h b/Stars45/Clock.h
index 512ee0f..4f51330 100644
--- a/Stars45/Clock.h
+++ b/Stars45/Clock.h
@@ -17,7 +17,9 @@ public:
using elapsed_duration = std::chrono::milliseconds;
using count_type = elapsed_duration::rep;
- Clock();
+ static Clock* GetInstance();
+ static bool Init();
+ static void Close();
void Set();
double Step();
@@ -34,6 +36,8 @@ public:
void SetTimeCompression(double compression);
protected:
+ Clock();
+
inner_clock::time_point m_point;
inner_clock::duration m_game_elapsed;
inner_clock::duration m_real_elapsed;
@@ -41,6 +45,9 @@ protected:
double m_delta;
double m_gui_delta;
double m_rate;
+
+private:
+ static Clock* instance;
};
diff --git a/Stars45/CmpLoadDlg.cpp b/Stars45/CmpLoadDlg.cpp
index 7f2fb1f..96c4f45 100644
--- a/Stars45/CmpLoadDlg.cpp
+++ b/Stars45/CmpLoadDlg.cpp
@@ -16,7 +16,7 @@
#include "Starshatter.h"
#include "FormatUtil.h"
-#include "Game.h"
+#include "Clock.h"
#include "DataLoader.h"
#include "Video.h"
#include "Keyboard.h"
@@ -68,7 +68,7 @@ CmpLoadDlg::Show()
lbl_title->SetText(campaign->Name());
}
- show_time = Game::GetInstance()->GetClock()->RealTime();
+ show_time = Clock::GetInstance()->RealTime();
}
// +--------------------------------------------------------------------+
@@ -110,7 +110,7 @@ CmpLoadDlg::MoveTo(const Rect& r)
bool
CmpLoadDlg::IsDone()
{
- if (Game::GetInstance()->GetClock()->RealTime() - show_time < 5000)
+ if (Clock::GetInstance()->RealTime() - show_time < 5000)
return false;
return true;
diff --git a/Stars45/CmpSceneDlg.cpp b/Stars45/CmpSceneDlg.cpp
index 725d756..72e92e7 100644
--- a/Stars45/CmpSceneDlg.cpp
+++ b/Stars45/CmpSceneDlg.cpp
@@ -22,7 +22,7 @@
#include "Mission.h"
#include "MissionEvent.h"
-#include "Game.h"
+#include "Clock.h"
#include "DataLoader.h"
#include "Video.h"
#include "Keyboard.h"
@@ -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()->GetClock()->RealTime() / 1000.0 + subtitles_delay;
+ subtitles_time = Clock::GetInstance()->RealTime() / 1000.0 + subtitles_delay;
}
else {
subtitles_delay = -1;
@@ -171,7 +171,7 @@ CmpSceneDlg::ExecFrame()
}
if (subtitles_delay > 0) {
- double seconds = Game::GetInstance()->GetClock()->RealTime() / 1000.0;
+ double seconds = Clock::GetInstance()->RealTime() / 1000.0;
if (subtitles_time <= seconds) {
subtitles_time = seconds + subtitles_delay;
diff --git a/Stars45/CmpSelectDlg.cpp b/Stars45/CmpSelectDlg.cpp
index 2ceacd9..8df1fd5 100644
--- a/Stars45/CmpSelectDlg.cpp
+++ b/Stars45/CmpSelectDlg.cpp
@@ -22,7 +22,7 @@
#include "ShipDesign.h"
#include "Player.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "DataLoader.h"
#include "Button.h"
@@ -496,7 +496,7 @@ CmpSelectDlg::OnAccept(AWEvent* event)
if (btn_new->GetButtonState())
Campaign::GetCampaign()->Load();
else
- Game::GetInstance()->GetClock()->ResetGameTime();
+ Clock::GetInstance()->ResetGameTime();
Mouse::Show(false);
stars->SetGameMode(Starshatter::CLOD_MODE);
diff --git a/Stars45/Contact.cpp b/Stars45/Contact.cpp
index a2912cb..cde6bcf 100644
--- a/Stars45/Contact.cpp
+++ b/Stars45/Contact.cpp
@@ -20,6 +20,7 @@
#include "WeaponDesign.h"
#include "Game.h"
+#include "Clock.h"
// +----------------------------------------------------------------------+
@@ -34,14 +35,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()->GetClock()->GameTime();
+ acquire_time = Clock::GetInstance()->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()->GetClock()->GameTime();
+ acquire_time = Clock::GetInstance()->GameTime();
Observe(ship);
}
@@ -49,7 +50,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()->GetClock()->GameTime();
+ acquire_time = Clock::GetInstance()->GameTime();
Observe(shot);
}
@@ -116,7 +117,7 @@ Contact::Age() const
if (!ship && !shot)
return age;
- double seconds = (Game::GetInstance()->GetClock()->GameTime() - time) / 1000.0;
+ double seconds = (Clock::GetInstance()->GameTime() - time) / 1000.0;
age = 1.0 - seconds/DEFAULT_TRACK_AGE;
@@ -295,7 +296,7 @@ Contact::Reset()
{
if (Game::GetInstance()->Paused()) return;
- float step_down = (float) (Game::GetInstance()->GetClock()->Delta() / 10);
+ float step_down = (float) (Clock::GetInstance()->Delta() / 10);
if (d_pas > 0)
d_pas -= step_down;
@@ -327,7 +328,7 @@ Contact::ClearTrack()
void
Contact::UpdateTrack()
{
- time = Game::GetInstance()->GetClock()->GameTime();
+ time = Clock::GetInstance()->GameTime();
if (shot || (ship && ship->IsGroundUnit()))
return;
diff --git a/Stars45/CtlDlg.cpp b/Stars45/CtlDlg.cpp
index 8203147..73f3ce0 100644
--- a/Stars45/CtlDlg.cpp
+++ b/Stars45/CtlDlg.cpp
@@ -27,6 +27,7 @@
#include "Keyboard.h"
#include "Joystick.h"
#include "MachineInfo.h"
+#include "Clock.h"
// +--------------------------------------------------------------------+
// DECLARE MAPPING FUNCTIONS:
@@ -318,7 +319,7 @@ CtlDlg::OnCommand(AWEvent* event)
int list_index = commands->GetListIndex();
// double-click:
- if (list_index == command_index && Game::GetInstance()->GetClock()->RealTime() - command_click_time < 350) {
+ if (list_index == command_index && Clock::GetInstance()->RealTime() - command_click_time < 350) {
KeyDlg* key_dlg = 0;
if (manager)
@@ -332,7 +333,7 @@ CtlDlg::OnCommand(AWEvent* event)
manager->ShowKeyDlg();
}
- command_click_time = Game::GetInstance()->GetClock()->RealTime();
+ command_click_time = Clock::GetInstance()->RealTime();
command_index = list_index;
}
diff --git a/Stars45/DebriefDlg.cpp b/Stars45/DebriefDlg.cpp
index bc1ec23..c8b08b4 100644
--- a/Stars45/DebriefDlg.cpp
+++ b/Stars45/DebriefDlg.cpp
@@ -31,7 +31,7 @@
#include "NetLobby.h"
#include "HttpServer.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Keyboard.h"
#include "Mouse.h"
@@ -98,7 +98,7 @@ void
DebriefDlg::Show()
{
FormWindow::Show();
- Game::GetInstance()->GetClock()->SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
mission = 0;
campaign = Campaign::GetCampaign();
diff --git a/Stars45/Debris.cpp b/Stars45/Debris.cpp
index 083b714..b90d88c 100644
--- a/Stars45/Debris.cpp
+++ b/Stars45/Debris.cpp
@@ -22,7 +22,7 @@
#include "Solid.h"
#include "Bitmap.h"
#include "DataLoader.h"
-#include "Game.h"
+#include "Clock.h"
#include "Random.h"
// +--------------------------------------------------------------------+
@@ -148,7 +148,7 @@ Debris::HitBy(Shot* shot, Point& impact)
double effective_damage = shot->Damage() * dscale;
if (shot->IsBeam()) {
- effective_damage *= Game::GetInstance()->GetClock()->Delta();
+ effective_damage *= Clock::GetInstance()->Delta();
}
else {
ApplyTorque(shot->Velocity() * (float) effective_damage * 1e-6f);
diff --git a/Stars45/DisplayView.cpp b/Stars45/DisplayView.cpp
index 5a758c8..f1d70df 100644
--- a/Stars45/DisplayView.cpp
+++ b/Stars45/DisplayView.cpp
@@ -31,7 +31,7 @@
#include "FontMgr.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
+#include "Clock.h"
#include "Menu.h"
// +====================================================================+
@@ -157,7 +157,7 @@ DisplayView::Refresh()
void
DisplayView::ExecFrame()
{
- double seconds = Game::GetInstance()->GetClock()->GuiDelta();
+ double seconds = Clock::GetInstance()->GuiDelta();
ListIter<DisplayElement> iter = elements;
while (++iter) {
diff --git a/Stars45/Drone.cpp b/Stars45/Drone.cpp
index 68cb384..f4116e3 100644
--- a/Stars45/Drone.cpp
+++ b/Stars45/Drone.cpp
@@ -18,7 +18,7 @@
#include "Sim.h"
#include "Explosion.h"
-#include "Game.h"
+#include "Clock.h"
#include "Bolt.h"
#include "Sprite.h"
#include "Solid.h"
@@ -181,7 +181,7 @@ Drone::HitBy(Shot* shot, Point& impact)
double effective_damage = shot->Damage() * dscale;
if (shot->IsBeam()) {
- effective_damage *= Game::GetInstance()->GetClock()->Delta();
+ effective_damage *= Clock::GetInstance()->Delta();
}
else {
ApplyTorque(shot->Velocity() * (float) effective_damage * 1e-6f);
diff --git a/Stars45/ExitDlg.cpp b/Stars45/ExitDlg.cpp
index 66aab6b..d175b79 100644
--- a/Stars45/ExitDlg.cpp
+++ b/Stars45/ExitDlg.cpp
@@ -17,7 +17,7 @@
#include "Starshatter.h"
#include "FormatUtil.h"
-#include "Game.h"
+#include "Clock.h"
#include "Keyboard.h"
#include "Button.h"
#include "RichTextBox.h"
@@ -65,7 +65,7 @@ void
ExitDlg::ExecFrame()
{
if (credits && credits->GetLineCount() > 0) {
- credits->SmoothScroll(ScrollWindow::SCROLL_DOWN, Game::GetInstance()->GetClock()->GuiDelta());
+ credits->SmoothScroll(ScrollWindow::SCROLL_DOWN, Clock::GetInstance()->GuiDelta());
if (credits->GetTopIndex() >= credits->GetLineCount()-1) {
credits->ScrollTo(0);
diff --git a/Stars45/FadeView.cpp b/Stars45/FadeView.cpp
index cf879fc..0dbb302 100644
--- a/Stars45/FadeView.cpp
+++ b/Stars45/FadeView.cpp
@@ -17,7 +17,7 @@
#include "Window.h"
#include "Video.h"
#include "Screen.h"
-#include "Game.h"
+#include "Clock.h"
// +--------------------------------------------------------------------+
@@ -51,7 +51,7 @@ void FadeView::StopHold()
void
FadeView::Refresh()
{
- double msec = Game::GetInstance()->GetClock()->GuiDelta();
+ double msec = Clock::GetInstance()->GuiDelta();
switch (state) {
case StateStart:
diff --git a/Stars45/FighterAI.cpp b/Stars45/FighterAI.cpp
index 12f1746..c394cca 100644
--- a/Stars45/FighterAI.cpp
+++ b/Stars45/FighterAI.cpp
@@ -33,7 +33,7 @@
#include "RadioMessage.h"
#include "RadioTraffic.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
static const double TIME_TO_DOCK = 30;
@@ -1563,8 +1563,8 @@ FighterAI::EvadeThreat()
// jink for one second:
else {
- if (Game::GetInstance()->GetClock()->GameTime() - jink_time > 1500) {
- jink_time = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - jink_time > 1500) {
+ jink_time = Clock::GetInstance()->GameTime();
jink = Point(rand() - 16384,
rand() - 16384,
rand() - 16384) * 15e3;
@@ -1587,8 +1587,8 @@ FighterAI::EvadeThreat()
// jink for one second:
else {
- if (Game::GetInstance()->GetClock()->GameTime() - jink_time > 1000) {
- jink_time = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - jink_time > 1000) {
+ jink_time = Clock::GetInstance()->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()->GetClock()->GameTime() - jink_time > jink_rate) {
- jink_time = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - jink_time > jink_rate) {
+ jink_time = Clock::GetInstance()->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()->GetClock()->GameTime() - last_call_time > 6000) {
+ if (Clock::GetInstance()->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()->GetClock()->GameTime();
+ last_call_time = Clock::GetInstance()->GameTime();
}
}
}
diff --git a/Stars45/FighterTacticalAI.cpp b/Stars45/FighterTacticalAI.cpp
index 9cd5839..2ad916d 100644
--- a/Stars45/FighterTacticalAI.cpp
+++ b/Stars45/FighterTacticalAI.cpp
@@ -27,7 +27,7 @@
#include "Sim.h"
#include "StarSystem.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
// +----------------------------------------------------------------------+
@@ -154,9 +154,9 @@ FighterTacticalAI::SelectTarget()
SimObject* target = ship_ai->GetTarget();
if (target && (target->Type() == SimObject::SIM_SHIP) &&
- (Game::GetInstance()->GetClock()->GameTime() - secondary_selection_time) > THREAT_REACTION_TIME) {
+ (Clock::GetInstance()->GameTime() - secondary_selection_time) > THREAT_REACTION_TIME) {
SelectSecondaryForTarget((Ship*) target);
- secondary_selection_time = Game::GetInstance()->GetClock()->GameTime();
+ secondary_selection_time = Clock::GetInstance()->GameTime();
}
}
@@ -475,7 +475,7 @@ FighterTacticalAI::FindThreat()
Contact* contact = c_iter.value();
if (contact->Threat(ship) &&
- (Game::GetInstance()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
+ (Clock::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
double rng = contact->Range(ship);
diff --git a/Stars45/Font.cpp b/Stars45/Font.cpp
index 3d30d29..fdb710c 100644
--- a/Stars45/Font.cpp
+++ b/Stars45/Font.cpp
@@ -18,7 +18,6 @@
#include "DataLoader.h"
#include "ParseUtil.h"
#include "Video.h"
-#include "Game.h"
#include "Clock.h"
// +--------------------------------------------------------------------+
@@ -643,7 +642,7 @@ Font::DrawText(const char* text, int count, Rect& text_rect, DWORD flags, Bitmap
// otherwise, draw caret if requested:
else if (caret_index >= 0 && caret_y >= text_rect.y && caret_y <= text_rect.y + text_rect.h) {//caret_y + height < text_rect.y + text_rect.h) {
Video* video = Video::GetInstance();
- Clock* clock = Game::GetInstance()->GetClock();
+ Clock* clock = Clock::GetInstance();
if (video && (clock->RealTime() / 500) & 1) {
float v[4];
diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp
index 62d1e69..5c93e6f 100644
--- a/Stars45/Game.cpp
+++ b/Stars45/Game.cpp
@@ -38,6 +38,7 @@ Game::Game()
hInst(0), hwnd(0),
status(Game::OK), exit_code(0), window_style(0)
{
+ Clock::Init();
if (!game) {
game = this;
@@ -60,6 +61,8 @@ Game::~Game()
if (game == this)
game = 0;
+ Clock::Close();
+
delete world;
delete screen;
delete video_factory;
@@ -136,7 +139,7 @@ Game::Run()
Print("+====================================================================+\n");
// Polling messages from event queue until quit
- clock.Set();
+ Clock::GetInstance()->Set();
while (status < EXIT && !Panic::Panicked()) {
if (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
@@ -221,7 +224,7 @@ Game::GameLoop()
Pause(false);
}
- clock.Step();
+ Clock::GetInstance()->Step();
frame_number++;
Mouse::w = 0;
return wait_for_windows_events;
@@ -233,7 +236,7 @@ void
Game::UpdateWorld()
{
if (world)
- world->ExecFrame(clock.Delta());
+ world->ExecFrame(Clock::GetInstance()->Delta());
}
// +--------------------------------------------------------------------+
@@ -271,7 +274,7 @@ Game::GetInstance()
void
Game::CollectStats()
{
- if (!totaltime) totaltime = clock.RealTime();
+ if (!totaltime) totaltime = Clock::GetInstance()->RealTime();
if (video) {
stats.nframe = video->GetStats().nframe;
@@ -293,7 +296,7 @@ Game::ShowStats()
{
if (server) return;
- totaltime = clock.RealTime() - totaltime;
+ totaltime = Clock::GetInstance()->RealTime() - totaltime;
Print("\n");
Print("Performance Data:\n");
@@ -322,13 +325,6 @@ Game::ShowStats()
// +====================================================================+
-Clock*
-Game::GetClock()
-{
- return &clock;
-}
-
-
DWORD Game::Frame()
{
return frame_number;
diff --git a/Stars45/Game.h b/Stars45/Game.h
index d0d5841..518789c 100644
--- a/Stars45/Game.h
+++ b/Stars45/Game.h
@@ -10,7 +10,6 @@
#ifndef Game_h
#define Game_h
-#include "Clock.h"
#include "Types.h"
#include "Screen.h"
#include "Video.h"
@@ -58,7 +57,6 @@ public:
static Game* GetInstance();
- Clock* GetClock();
DWORD Frame();
void SetMaxFrameLength(double seconds) { max_frame_length = seconds; }
@@ -107,8 +105,6 @@ protected:
RECT bounds_rect; // Saved window bounds for mode switches
RECT client_rect; // Saved client area size for mode switches
- Clock clock;
-
int status;
int exit_code;
@@ -124,5 +120,3 @@ protected:
// +--------------------------------------------------------------------+
#endif // Game_h
-
-
diff --git a/Stars45/GroundAI.cpp b/Stars45/GroundAI.cpp
index c355eba..805d375 100644
--- a/Stars45/GroundAI.cpp
+++ b/Stars45/GroundAI.cpp
@@ -25,7 +25,7 @@
#include "Weapon.h"
#include "WeaponGroup.h"
-#include "Game.h"
+#include "Clock.h"
#include "Physical.h"
// +----------------------------------------------------------------------+
@@ -161,8 +161,8 @@ GroundAI::ExecFrame(double secs)
{
const int exec_period = 1000;
- if ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > exec_period) {
- exec_time = (int) Game::GetInstance()->GetClock()->GameTime();
+ if ((int) Clock::GetInstance()->GameTime() - exec_time > exec_period) {
+ exec_time = (int) Clock::GetInstance()->GameTime();
SelectTarget();
}
diff --git a/Stars45/HUDView.cpp b/Stars45/HUDView.cpp
index f2b4b02..6846b09 100644
--- a/Stars45/HUDView.cpp
+++ b/Stars45/HUDView.cpp
@@ -62,6 +62,7 @@
#include "Polygon.h"
#include "Sound.h"
#include "Game.h"
+#include "Clock.h"
#include "GameWinDX9.h"
#include "ContentBundle.h"
#include "Window.h"
@@ -864,7 +865,7 @@ HUDView::MarkerColor(Contact* contact)
c = Ship::IFFColor(c_iff) * contact->Age();
if (contact->GetShot() && contact->Threat(ship)) {
- if ((Game::GetInstance()->GetClock()->RealTime()/500) & 1)
+ if ((Clock::GetInstance()->RealTime()/500) & 1)
c = c * 2;
else
c = c * 0.5;
@@ -1464,7 +1465,7 @@ HUDView::DrawBars()
else if (threat > 1) {
threat_warn = ContentBundle::GetInstance()->GetText("HUDView.missile-warn");
- show_msg = ((Game::GetInstance()->GetClock()->RealTime()/500) & 1) != 0;
+ show_msg = ((Clock::GetInstance()->RealTime()/500) & 1) != 0;
}
if (show_msg) {
@@ -2116,9 +2117,9 @@ HUDView::DrawTarget()
System* sys = ship->GetSubTarget();
if (sys) {
Color stat = hud_color;
- static DWORD blink = Game::GetInstance()->GetClock()->RealTime();
+ static DWORD blink = Clock::GetInstance()->RealTime();
- int blink_delta = Game::GetInstance()->GetClock()->RealTime() - blink;
+ int blink_delta = Clock::GetInstance()->RealTime() - blink;
sprintf_s(txt, "%s %03d", sys->Abbreviation(), (int) sys->Availability());
switch (sys->Status()) {
@@ -2132,7 +2133,7 @@ HUDView::DrawTarget()
}
if (blink_delta > 500)
- blink = Game::GetInstance()->GetClock()->RealTime();
+ blink = Clock::GetInstance()->RealTime();
range_rect.y += 10;
DrawHUDText(TXT_TARGET_SUB, txt, range_rect, DT_RIGHT);
@@ -2658,7 +2659,7 @@ HUDView::DrawWarningPanel()
int y = cockpit_hud_texture ? 410 : height-97;
int c = cockpit_hud_texture ? 3 : 4;
- static DWORD blink = Game::GetInstance()->GetClock()->RealTime();
+ static DWORD blink = Clock::GetInstance()->RealTime();
for (int index = 0; index < 12; index++) {
int stat = -1;
@@ -2699,7 +2700,7 @@ HUDView::DrawWarningPanel()
Color tc = status_color;
if (stat != System::NOMINAL) {
- if (Game::GetInstance()->GetClock()->RealTime() - blink < 250) {
+ if (Clock::GetInstance()->RealTime() - blink < 250) {
tc = cockpit_hud_texture ? txt_color : Color(8,8,8);
}
}
@@ -2741,8 +2742,8 @@ HUDView::DrawWarningPanel()
}
}
- if (Game::GetInstance()->GetClock()->RealTime() - blink > 500)
- blink = Game::GetInstance()->GetClock()->RealTime();
+ if (Clock::GetInstance()->RealTime() - blink > 500)
+ blink = Clock::GetInstance()->RealTime();
// reset for next time
SetStatusColor(System::NOMINAL);
@@ -2877,7 +2878,7 @@ HUDView::DrawMessages()
// age messages:
for (int i = 0; i < MAX_MSG; i++) {
if (msg_time[i] > 0) {
- msg_time[i] -= Game::GetInstance()->GetClock()->GuiDelta();
+ msg_time[i] -= Clock::GetInstance()->GuiDelta();
if (msg_time[i] <= 0) {
msg_time[i] = 0;
diff --git a/Stars45/MenuView.cpp b/Stars45/MenuView.cpp
index 00f2dae..fc32fa6 100644
--- a/Stars45/MenuView.cpp
+++ b/Stars45/MenuView.cpp
@@ -25,7 +25,7 @@
#include "MouseController.h"
#include "Menu.h"
#include "Button.h"
-#include "Game.h"
+#include "Clock.h"
#include "FormatUtil.h"
// +--------------------------------------------------------------------+
@@ -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()->GetClock()->RealTime();
+ rbutton_latch = Clock::GetInstance()->RealTime();
right_down = true;
show_menu = false;
}
}
else {
- if (right_down && (Game::GetInstance()->GetClock()->RealTime() - rbutton_latch < 250)) {
+ if (right_down && (Clock::GetInstance()->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 cf50bd9..849c151 100644
--- a/Stars45/Mfd.cpp
+++ b/Stars45/Mfd.cpp
@@ -48,6 +48,7 @@
#include "Keyboard.h"
#include "Mouse.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
static Bitmap sensor_fov;
@@ -1087,7 +1088,7 @@ MFD::DrawGameMFD()
int t = 0;
if (!HUDView::IsArcade() && HUDView::ShowFPS()) {
- sprintf_s(txt, "FPS: %6.2f", Game::GetInstance()->GetClock()->Rate());
+ sprintf_s(txt, "FPS: %6.2f", Clock::GetInstance()->Rate());
DrawMFDText(t++, txt, txt_rect, DT_LEFT);
txt_rect.y += 10;
@@ -1106,9 +1107,9 @@ MFD::DrawGameMFD()
if (lines <= 2) return;
- int hours = (Game::GetInstance()->GetClock()->GameTime() / 3600000) ;
- int minutes = (Game::GetInstance()->GetClock()->GameTime() / 60000) % 60;
- int seconds = (Game::GetInstance()->GetClock()->GameTime() / 1000) % 60;
+ int hours = (Clock::GetInstance()->GameTime() / 3600000) ;
+ int minutes = (Clock::GetInstance()->GameTime() / 60000) % 60;
+ int seconds = (Clock::GetInstance()->GameTime() / 1000) % 60;
if (ship) {
DWORD clock = ship->MissionClock();
@@ -1118,8 +1119,8 @@ MFD::DrawGameMFD()
seconds = (clock / 1000) % 60;
}
- if (static_cast<int>(Game::GetInstance()->GetClock()->TimeCompression()) != 1)
- sprintf_s(txt, "%02d:%02d:%02d x%.1f", hours, minutes, seconds, Game::GetInstance()->GetClock()->TimeCompression()); //-V576
+ if (static_cast<int>(Clock::GetInstance()->TimeCompression()) != 1)
+ sprintf_s(txt, "%02d:%02d:%02d x%.1f", hours, minutes, seconds, Clock::GetInstance()->TimeCompression()); //-V576
else
sprintf_s(txt, "%02d:%02d:%02d", hours, minutes, seconds);
@@ -1282,7 +1283,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()->GetClock()->RealTime()/1000) & 2)
+ if (!Game::GetInstance()->Paused() && (Clock::GetInstance()->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 76d0e7e..dc24f09 100644
--- a/Stars45/ModDlg.cpp
+++ b/Stars45/ModDlg.cpp
@@ -17,7 +17,7 @@
#include "BaseScreen.h"
#include "ModConfig.h"
-#include "Game.h"
+#include "Clock.h"
#include "DataLoader.h"
#include "Button.h"
#include "ListBox.h"
@@ -212,7 +212,7 @@ ModDlg::OnSelectEnabled(AWEvent* event)
btn_decrease->SetEnabled(lst_enabled->GetSelection() < lst_enabled->NumItems() - 1);
// double-click:
- if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ click_time = Clock::GetInstance()->RealTime();
}
void
diff --git a/Stars45/MouseController.cpp b/Stars45/MouseController.cpp
index 3234dfe..e4ab97d 100644
--- a/Stars45/MouseController.cpp
+++ b/Stars45/MouseController.cpp
@@ -15,7 +15,7 @@
#include "MouseController.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
+#include "Clock.h"
#include "Video.h"
// +--------------------------------------------------------------------+
@@ -117,11 +117,11 @@ MouseController::Acquire()
roll_enable = 1;
if (!rbutton_latch)
- rbutton_latch = Game::GetInstance()->GetClock()->RealTime();
+ rbutton_latch = Clock::GetInstance()->RealTime();
}
else {
if (rbutton_latch) {
- rbutton_latch = Game::GetInstance()->GetClock()->RealTime() - rbutton_latch;
+ rbutton_latch = Clock::GetInstance()->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()->GetClock()->RealTime();
+ mbutton_latch = Clock::GetInstance()->RealTime();
}
else {
if (mbutton_latch) {
@@ -187,7 +187,7 @@ MouseController::Acquire()
if (select == 1) {
::SetCursorPos(cx, cy);
- double drain = cx * 4 * Game::GetInstance()->GetClock()->Delta();
+ double drain = cx * 4 * Clock::GetInstance()->Delta();
if (dx > drain) {
dx -= drain;
diff --git a/Stars45/MsnEditDlg.cpp b/Stars45/MsnEditDlg.cpp
index 120eb07..838ac59 100644
--- a/Stars45/MsnEditDlg.cpp
+++ b/Stars45/MsnEditDlg.cpp
@@ -25,7 +25,7 @@
#include "StarSystem.h"
#include "Galaxy.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "DataLoader.h"
#include "Button.h"
@@ -637,7 +637,7 @@ MsnEditDlg::OnElemSelect(AWEvent* event)
btn_elem_dec->SetEnabled(selection >= 0 && selection < lst_elem->NumItems() - 1);
// double-click:
- if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ click_time = Clock::GetInstance()->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()->GetClock()->RealTime() - click_time < 350) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ click_time = Clock::GetInstance()->RealTime();
}
void
diff --git a/Stars45/MusicTrack.cpp b/Stars45/MusicTrack.cpp
index 956d0b5..fef2b73 100644
--- a/Stars45/MusicTrack.cpp
+++ b/Stars45/MusicTrack.cpp
@@ -20,6 +20,7 @@
#include "AudioConfig.h"
#include "Game.h"
+#include "Clock.h"
#include "Sound.h"
// +-------------------------------------------------------------------+
@@ -135,7 +136,7 @@ MusicTrack::ExecFrame()
}
if (fade > 0)
- fade -= Game::GetInstance()->GetClock()->GuiDelta();
+ fade -= Clock::GetInstance()->GuiDelta();
if (fade < 0)
fade = 0;
diff --git a/Stars45/NavDlg.cpp b/Stars45/NavDlg.cpp
index bbc4d86..d5494c1 100644
--- a/Stars45/NavDlg.cpp
+++ b/Stars45/NavDlg.cpp
@@ -28,7 +28,7 @@
#include "Contact.h"
#include "Mission.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Keyboard.h"
#include "Mouse.h"
@@ -1046,7 +1046,7 @@ NavDlg::OnMapClick(AWEvent* event)
CoordinateSelection();
// double-click:
- if (Game::GetInstance()->GetClock()->RealTime() - click_time < 350) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ click_time = Clock::GetInstance()->RealTime();
}
void
diff --git a/Stars45/NavLight.cpp b/Stars45/NavLight.cpp
index 48bd826..dc19e37 100644
--- a/Stars45/NavLight.cpp
+++ b/Stars45/NavLight.cpp
@@ -14,7 +14,7 @@
#include "MemDebug.h"
#include "NavLight.h"
-#include "Game.h"
+#include "Clock.h"
#include "Bitmap.h"
#include "DataLoader.h"
#include "ContentBundle.h"
@@ -100,7 +100,7 @@ void
NavLight::ExecFrame(double seconds)
{
if (enable && power_on) {
- double t = (Game::GetInstance()->GetClock()->GameTime()+offset) / 1000.0;
+ double t = (Clock::GetInstance()->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 89e1ff0..c333547 100644
--- a/Stars45/NetGameClient.cpp
+++ b/Stars45/NetGameClient.cpp
@@ -39,7 +39,7 @@
#include "NetLayer.h"
#include "NetPeer.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Light.h"
@@ -936,7 +936,7 @@ NetGameClient::DoSelfDestruct(NetMsg* msg)
void
NetGameClient::Send()
{
- DWORD time = Game::GetInstance()->GetClock()->GameTime();
+ DWORD time = Clock::GetInstance()->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 9170a46..84a199d 100644
--- a/Stars45/NetGameServer.cpp
+++ b/Stars45/NetGameServer.cpp
@@ -39,6 +39,7 @@
#include "NetPeer.h"
#include "NetUtil.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Light.h"
@@ -140,9 +141,9 @@ NetGameServer::ExecFrame()
static DWORD time_mark = 0;
- 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 (!time_mark) time_mark = Clock::GetInstance()->RealTime();
+ else if (Clock::GetInstance()->RealTime() - time_mark > 60000) {
+ time_mark = Clock::GetInstance()->RealTime();
if (link && players.size() > 0) {
Print("Server Stats\n-------------\n");
@@ -1008,7 +1009,7 @@ NetGameServer::Send()
if (players.isEmpty())
return;
- DWORD time = Game::GetInstance()->GetClock()->GameTime();
+ DWORD time = Clock::GetInstance()->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 5cac691..0520f96 100644
--- a/Stars45/NetLobbyServer.cpp
+++ b/Stars45/NetLobbyServer.cpp
@@ -41,7 +41,7 @@
#include "NetMsg.h"
#include "MachineInfo.h"
-#include "Game.h"
+#include "Clock.h"
#include "FormatUtil.h"
#include "VersionInfo.h"
@@ -256,9 +256,9 @@ NetLobbyServer::ExecFrame()
{
NetLobby::ExecFrame();
- if (announce_time == 0 || Game::GetInstance()->GetClock()->RealTime() - announce_time > 200000) {
+ if (announce_time == 0 || Clock::GetInstance()->RealTime() - announce_time > 200000) {
GameOn();
- announce_time = Game::GetInstance()->GetClock()->RealTime();
+ announce_time = Clock::GetInstance()->RealTime();
}
if (GetStatus() == NetServerInfo::BRIEFING) {
@@ -377,7 +377,7 @@ NetLobbyServer::CheckSessions()
// announce drop:
char timestr[64];
- FormatTime(timestr, Game::GetInstance()->GetClock()->RealTime()/1000);
+ FormatTime(timestr, Clock::GetInstance()->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 1df2311..9499ad5 100644
--- a/Stars45/NetUnitDlg.cpp
+++ b/Stars45/NetUnitDlg.cpp
@@ -35,6 +35,7 @@
#include "Video.h"
#include "Keyboard.h"
#include "MachineInfo.h"
+#include "Clock.h"
// +--------------------------------------------------------------------+
// DECLARE MAPPING FUNCTIONS:
@@ -497,11 +498,11 @@ NetUnitDlg::OnUnit(AWEvent* event)
int list_index = lst_units->GetListIndex();
// double-click:
- if (list_index == unit_index && Game::GetInstance()->GetClock()->RealTime() - unit_click_time < 350) {
+ if (list_index == unit_index && Clock::GetInstance()->RealTime() - unit_click_time < 350) {
OnSelect(0);
}
- unit_click_time = Game::GetInstance()->GetClock()->RealTime();
+ unit_click_time = Clock::GetInstance()->RealTime();
unit_index = list_index;
}
diff --git a/Stars45/Particles.cpp b/Stars45/Particles.cpp
index 5b5c02f..436f568 100644
--- a/Stars45/Particles.cpp
+++ b/Stars45/Particles.cpp
@@ -16,7 +16,7 @@
#include "Projector.h"
#include "Light.h"
#include "Bitmap.h"
-#include "Game.h"
+#include "Clock.h"
#include "Random.h"
// +--------------------------------------------------------------------+
@@ -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()->GetClock()->GameTime() / 1000.0);
+ timestamp[i] = (float) (Clock::GetInstance()->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()->GetClock()->GameTime()/1000.0 - timestamp[i];
+ double age = Clock::GetInstance()->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()->GetClock()->GameTime() / 1000.0);
+ timestamp[i] = (float) (Clock::GetInstance()->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()->GetClock()->GameTime() / 1000.0);
+ timestamp[i] = (float) (Clock::GetInstance()->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 e4944e6..8639187 100644
--- a/Stars45/Player.cpp
+++ b/Stars45/Player.cpp
@@ -29,7 +29,7 @@
#include "ParseUtil.h"
#include "FormatUtil.h"
#include "Bitmap.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
// +-------------------------------------------------------------------+
@@ -641,7 +641,7 @@ Player::GetMissionPoints(ShipStats* s, DWORD start_time)
if (s) {
result = s->GetPoints();
- int flight_time = (Game::GetInstance()->GetClock()->GameTime() - start_time) / 1000;
+ int flight_time = (Clock::GetInstance()->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()->GetClock()->GameTime() - start_time) / 1000);
+ AddFlightTime((Clock::GetInstance()->GameTime() - start_time) / 1000);
int rank = Rank();
diff --git a/Stars45/QuantumView.cpp b/Stars45/QuantumView.cpp
index 889457e..fa2905d 100644
--- a/Stars45/QuantumView.cpp
+++ b/Stars45/QuantumView.cpp
@@ -31,7 +31,7 @@
#include "FontMgr.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Menu.h"
@@ -169,7 +169,7 @@ QuantumView::ExecFrame()
static double time_til_change = 0;
if (time_til_change > 0)
- time_til_change -= Game::GetInstance()->GetClock()->GuiDelta();
+ time_til_change -= Clock::GetInstance()->GuiDelta();
if (time_til_change <= 0) {
time_til_change = 0;
diff --git a/Stars45/QuitView.cpp b/Stars45/QuitView.cpp
index eaebce5..f0af6a3 100644
--- a/Stars45/QuitView.cpp
+++ b/Stars45/QuitView.cpp
@@ -36,6 +36,7 @@
#include "Mouse.h"
#include "MouseController.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Menu.h"
@@ -163,7 +164,7 @@ QuitView::ExecFrame()
// exit and accept:
if (action == 1) {
CloseMenu();
- Game::GetInstance()->GetClock()->SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
Starshatter* stars = Starshatter::GetInstance();
stars->SetGameMode(Starshatter::PLAN_MODE);
@@ -172,7 +173,7 @@ QuitView::ExecFrame()
// quit and discard results:
else if (action == 2) {
CloseMenu();
- Game::GetInstance()->GetClock()->SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
Starshatter* stars = Starshatter::GetInstance();
Campaign* campaign = Campaign::GetCampaign();
diff --git a/Stars45/RadioView.cpp b/Stars45/RadioView.cpp
index 315218b..43d4fff 100644
--- a/Stars45/RadioView.cpp
+++ b/Stars45/RadioView.cpp
@@ -33,7 +33,7 @@
#include "FormatUtil.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Menu.h"
@@ -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()->GetClock()->GuiDelta();
+ msg_time[i] -= Clock::GetInstance()->GuiDelta();
if (msg_time[i] <= 0) {
msg_time[i] = 0;
diff --git a/Stars45/ScrollWindow.cpp b/Stars45/ScrollWindow.cpp
index 0490da6..a7d9a41 100644
--- a/Stars45/ScrollWindow.cpp
+++ b/Stars45/ScrollWindow.cpp
@@ -20,7 +20,6 @@
#include "Font.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
#include "Clock.h"
// +--------------------------------------------------------------------+
@@ -552,7 +551,7 @@ int ScrollWindow::OnMouseWheel(int wheel)
if (GetLineCount() > 0) {
static double scroll_time = 0;
- Clock* clock = Game::GetInstance()->GetClock();
+ Clock* clock = Clock::GetInstance();
if (clock->RealTime() - scroll_time > 0.5) {
scroll_time = clock->RealTime();
diff --git a/Stars45/SeekerAI.cpp b/Stars45/SeekerAI.cpp
index 173e5b8..cc6c253 100644
--- a/Stars45/SeekerAI.cpp
+++ b/Stars45/SeekerAI.cpp
@@ -18,7 +18,7 @@
#include "System.h"
#include "WeaponDesign.h"
-#include "Game.h"
+#include "Clock.h"
// +----------------------------------------------------------------------+
@@ -61,7 +61,7 @@ void
SeekerAI::Navigator()
{
if (delay > 0) {
- delay -= Game::GetInstance()->GetClock()->Delta();
+ delay -= Clock::GetInstance()->Delta();
}
else {
Steer s = SeekTarget();
diff --git a/Stars45/Ship.cpp b/Stars45/Ship.cpp
index 12b9b7c..89b582f 100644
--- a/Stars45/Ship.cpp
+++ b/Stars45/Ship.cpp
@@ -73,6 +73,7 @@
#include "Joystick.h"
#include "Bolt.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Solid.h"
#include "Shadow.h"
@@ -1043,7 +1044,7 @@ Ship::ClearTrack()
track[0] = Location();
ntrack = 1;
- track_time = Game::GetInstance()->GetClock()->GameTime();
+ track_time = Clock::GetInstance()->GameTime();
}
void
@@ -1052,7 +1053,7 @@ Ship::UpdateTrack()
const int DEFAULT_TRACK_UPDATE = 500; // milliseconds
const int DEFAULT_TRACK_LENGTH = 20; // 10 seconds
- DWORD time = Game::GetInstance()->GetClock()->GameTime();
+ DWORD time = Clock::GetInstance()->GameTime();
if (!track) {
track = new(__FILE__,__LINE__) Point[DEFAULT_TRACK_LENGTH];
@@ -1323,7 +1324,7 @@ void
Ship::SetFlightPhase(OP_MODE phase)
{
if (phase == ACTIVE && !launch_time) {
- launch_time = Game::GetInstance()->GetClock()->GameTime() + 1;
+ launch_time = Clock::GetInstance()->GameTime() + 1;
dock = 0;
if (element)
@@ -1643,8 +1644,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()->GetClock()->GameTime() - ff_warn_time) > 5000) {
- ff_warn_time = Game::GetInstance()->GetClock()->GameTime();
+ else if (!s->IsRogue() && (Clock::GetInstance()->GameTime() - ff_warn_time) > 5000) {
+ ff_warn_time = Clock::GetInstance()->GameTime();
RadioMessage* warn = 0;
if (s->GetTarget() == this)
@@ -1956,7 +1957,7 @@ Ship::CheckFriendlyFire()
return;
// only check once each second
- if (Game::GetInstance()->GetClock()->GameTime() - friendly_fire_time < 1000)
+ if (Clock::GetInstance()->GameTime() - friendly_fire_time < 1000)
return;
List<Weapon> w_list;
@@ -2013,7 +2014,7 @@ Ship::CheckFriendlyFire()
}
}
- friendly_fire_time = Game::GetInstance()->GetClock()->GameTime() + (DWORD) Random(0, 500);
+ friendly_fire_time = Clock::GetInstance()->GameTime() + (DWORD) Random(0, 500);
}
// +----------------------------------------------------------------------+
@@ -2613,10 +2614,10 @@ Ship::ExecEvalFrame(double seconds)
static DWORD last_eval_frame = 0; // one ship per game frame
if (element && element->NumObjectives() > 0 &&
- Game::GetInstance()->GetClock()->GameTime() - last_eval_time > EVAL_FREQUENCY &&
+ Clock::GetInstance()->GameTime() - last_eval_time > EVAL_FREQUENCY &&
last_eval_frame != Game::GetInstance()->Frame()) {
- last_eval_time = Game::GetInstance()->GetClock()->GameTime();
+ last_eval_time = Clock::GetInstance()->GameTime();
last_eval_frame = Game::GetInstance()->Frame();
for (int i = 0; i < element->NumObjectives(); i++) {
@@ -3027,7 +3028,7 @@ Ship::StatFrame(double seconds)
{
if (flight_phase != ACTIVE) {
flight_phase = ACTIVE;
- launch_time = Game::GetInstance()->GetClock()->GameTime() + 1;
+ launch_time = Clock::GetInstance()->GameTime() + 1;
if (element)
element->SetLaunchTime(launch_time);
@@ -3585,7 +3586,7 @@ Ship::TimeSkip()
{
if (CanTimeSkip()) {
// go back to regular time before performing the skip:
- Game::GetInstance()->GetClock()->SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
transition_time = 7.5f;
transition_type = TRANSITION_TIME_SKIP;
@@ -4516,26 +4517,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()->GetClock()->RealTime() - last_beam_time > 400) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ last_beam_time = Clock::GetInstance()->RealTime();
}
}
}
else {
if (design->bolt_hit_sound_resource) {
- if (Game::GetInstance()->GetClock()->RealTime() - last_bolt_time > 400) {
+ if (Clock::GetInstance()->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()->GetClock()->RealTime();
+ last_bolt_time = Clock::GetInstance()->RealTime();
}
}
}
@@ -4814,10 +4815,10 @@ Ship::ExecMaintFrame(double seconds)
static DWORD last_repair_frame = 0; // one ship per game frame
if (auto_repair &&
- Game::GetInstance()->GetClock()->GameTime() - last_repair_time > REPAIR_FREQUENCY &&
+ Clock::GetInstance()->GameTime() - last_repair_time > REPAIR_FREQUENCY &&
last_repair_frame != Game::GetInstance()->Frame()) {
- last_repair_time = Game::GetInstance()->GetClock()->GameTime();
+ last_repair_time = Clock::GetInstance()->GameTime();
last_repair_frame = Game::GetInstance()->Frame();
ListIter<System> iter = systems;
@@ -5199,7 +5200,7 @@ DWORD
Ship::MissionClock() const
{
if (launch_time > 0)
- return Game::GetInstance()->GetClock()->GameTime() + 1 - launch_time;
+ return Clock::GetInstance()->GameTime() + 1 - launch_time;
return 0;
}
diff --git a/Stars45/ShipAI.cpp b/Stars45/ShipAI.cpp
index c3d5a3a..43c34d9 100644
--- a/Stars45/ShipAI.cpp
+++ b/Stars45/ShipAI.cpp
@@ -35,7 +35,7 @@
#include "Debris.h"
#include "Asteroid.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Random.h"
@@ -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()->GetClock()->GameTime() - last_call_time > 10000) {
+ if (target->Identity() != engaged_ship_id && Clock::GetInstance()->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()->GetClock()->GameTime();
+ last_call_time = Clock::GetInstance()->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()->GetClock()->GameTime() - last_avoid_time < 500)
+ if (!other && Clock::GetInstance()->GameTime() - last_avoid_time < 500)
return avoid;
brake = 0;
@@ -1124,7 +1124,7 @@ ShipAI::AvoidCollision()
}
}
- last_avoid_time = Game::GetInstance()->GetClock()->GameTime();
+ last_avoid_time = Clock::GetInstance()->GameTime();
return avoid;
}
diff --git a/Stars45/ShipCtrl.cpp b/Stars45/ShipCtrl.cpp
index 8273ec1..800f927 100644
--- a/Stars45/ShipCtrl.cpp
+++ b/Stars45/ShipCtrl.cpp
@@ -32,7 +32,7 @@
#include "MouseController.h"
#include "Keyboard.h"
#include "Joystick.h"
-#include "Game.h"
+#include "Clock.h"
#include "DataLoader.h"
// +--------------------------------------------------------------------+
@@ -62,8 +62,8 @@ ShipCtrl::Toggled(int action)
static double last_toggle_time = 0;
if (KeyDown(action)) {
- if ((Game::GetInstance()->GetClock()->RealTime() - last_toggle_time) > 250) {
- last_toggle_time = Game::GetInstance()->GetClock()->RealTime();
+ if ((Clock::GetInstance()->RealTime() - last_toggle_time) > 250) {
+ last_toggle_time = Clock::GetInstance()->RealTime();
return 1;
}
}
diff --git a/Stars45/Shot.cpp b/Stars45/Shot.cpp
index 4628615..da516b8 100644
--- a/Stars45/Shot.cpp
+++ b/Stars45/Shot.cpp
@@ -25,6 +25,7 @@
#include "Terrain.h"
#include "Game.h"
+#include "Clock.h"
#include "Bolt.h"
#include "Sprite.h"
#include "Solid.h"
@@ -504,7 +505,7 @@ Shot::Damage() const
fade = (design->length - len) / (design->length - design->min_range);
}
- damage = base_damage * charge * fade * Game::GetInstance()->GetClock()->Delta();
+ damage = base_damage * charge * fade * Clock::GetInstance()->Delta();
}
// energy wep damage based on time:
diff --git a/Stars45/Sim.cpp b/Stars45/Sim.cpp
index 910a778..ccfab62 100644
--- a/Stars45/Sim.cpp
+++ b/Stars45/Sim.cpp
@@ -65,6 +65,7 @@
#include "NetData.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Sound.h"
#include "Bolt.h"
@@ -395,7 +396,7 @@ Sim::ExecMission()
}
first_frame = true;
- start_time = Game::GetInstance()->GetClock()->GameTime();
+ 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 (Game::GetInstance()->GetClock()->GameTime() - start_time) / 1000.0;
+ return (Clock::GetInstance()->GameTime() - start_time) / 1000.0;
}
// +--------------------------------------------------------------------+
@@ -1933,7 +1934,7 @@ Sim::SkipCutscene()
double skip_time = end_time - MissionClock();
if (skip_time > 0) {
- Game::GetInstance()->GetClock()->SkipGameTime(skip_time);
+ Clock::GetInstance()->SkipGameTime(skip_time);
}
}
}
@@ -1987,7 +1988,7 @@ Sim::ResolveTimeSkip(double seconds)
player_ship->SetControls(0);
}
- Game::GetInstance()->GetClock()->SkipGameTime(skipped);
+ Clock::GetInstance()->SkipGameTime(skipped);
CameraDirector::SetCameraMode(CameraDirector::MODE_COCKPIT);
}
@@ -2510,7 +2511,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()->GetClock()->GameTime();
+ long new_time = Clock::GetInstance()->GameTime();
double delta = new_time - sim_time;
seconds = delta / 1000.0;
@@ -2518,7 +2519,7 @@ SimRegion::ExecFrame(double secs)
seconds = max_frame;
}
- sim_time = Game::GetInstance()->GetClock()->GameTime();
+ sim_time = Clock::GetInstance()->GameTime();
if (orbital_region)
location = orbital_region->Location();
@@ -3798,7 +3799,7 @@ const char* FormatGameTime()
{
static char txt[64];
- int t = Game::GetInstance()->GetClock()->GameTime();
+ int t = Clock::GetInstance()->GameTime();
int h = ( t / 3600000);
int m = ((t - h*3600000) / 60000);
diff --git a/Stars45/SimEvent.cpp b/Stars45/SimEvent.cpp
index fc4cc7f..731f090 100644
--- a/Stars45/SimEvent.cpp
+++ b/Stars45/SimEvent.cpp
@@ -14,7 +14,7 @@
#include "MemDebug.h"
#include "SimEvent.h"
#include "Sim.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
// +====================================================================+
@@ -31,7 +31,7 @@ SimEvent::SimEvent(int e, const char* t, const char* i)
time = (int) sim->MissionClock();
}
else {
- time = (int) (Game::GetInstance()->GetClock()->GameTime()/1000);
+ time = (int) (Clock::GetInstance()->GameTime()/1000);
}
SetTarget(t);
diff --git a/Stars45/Sky.cpp b/Stars45/Sky.cpp
index 8f475f6..f65b39e 100644
--- a/Stars45/Sky.cpp
+++ b/Stars45/Sky.cpp
@@ -15,7 +15,7 @@
#include "Sky.h"
#include "StarSystem.h"
-#include "Game.h"
+#include "Clock.h"
#include "Bitmap.h"
#include "DataLoader.h"
#include "Light.h"
@@ -132,7 +132,7 @@ Dust::Reset(const Point& ref)
void
Dust::ExecFrame(double factor, const Point& ref)
{
- if (Game::GetInstance()->GetClock()->TimeCompression() > 4.0) {
+ if (Clock::GetInstance()->TimeCompression() > 4.0) {
Hide();
return;
}
diff --git a/Stars45/Sprite.cpp b/Stars45/Sprite.cpp
index 295833f..9cf6f37 100644
--- a/Stars45/Sprite.cpp
+++ b/Stars45/Sprite.cpp
@@ -17,7 +17,7 @@
#include "Camera.h"
#include "Polygon.h"
#include "Video.h"
-#include "Game.h"
+#include "Clock.h"
// +--------------------------------------------------------------------+
@@ -169,7 +169,7 @@ Sprite::SetAnimation(Bitmap* animation, int length, int repeat, int share)
life = nframes;
}
- last_time = Game::GetInstance()->GetClock()->RealTime() - frame_time;
+ last_time = Clock::GetInstance()->RealTime() - frame_time;
}
}
@@ -362,7 +362,7 @@ void
Sprite::Update()
{
if (life > 0 || loop) {
- DWORD time = Game::GetInstance()->GetClock()->RealTime();
+ DWORD time = Clock::GetInstance()->RealTime();
while (time - last_time > frame_time) {
life--;
frame_index++;
diff --git a/Stars45/StarServer.cpp b/Stars45/StarServer.cpp
index 98b1287..5385a6b 100644
--- a/Stars45/StarServer.cpp
+++ b/Stars45/StarServer.cpp
@@ -45,6 +45,7 @@
#include "MachineInfo.h"
#include "Game.h"
#include "GameWinDX9.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Keyboard.h"
#include "Mouse.h"
@@ -169,7 +170,7 @@ StarServer::InitGame()
Shot::Initialize();
RadioTraffic::Initialize();
- time_mark = Game::GetInstance()->GetClock()->GameTime();
+ time_mark = Clock::GetInstance()->GameTime();
minutes = 0;
NetServerConfig* server_config = NetServerConfig::GetInstance();
@@ -221,7 +222,7 @@ StarServer::SetGameMode(int m)
// stand alone server should wait for players to connect
// before unpausing the simulation...
- clock.SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
Pause(true);
}
@@ -336,12 +337,12 @@ StarServer::UpdateWorld()
Drive::StartFrame();
if (world)
- world->ExecFrame(clock.Delta());
+ world->ExecFrame(Clock::GetInstance()->Delta());
}
static DWORD refresh_time = 0;
- if (clock.RealTime() - refresh_time > 1000) {
- refresh_time = clock.RealTime();
+ if (Clock::GetInstance()->RealTime() - refresh_time > 1000) {
+ refresh_time = Clock::GetInstance()->RealTime();
RedrawWindow(hwnd, 0, 0, RDW_ERASE|RDW_INVALIDATE);
}
}
@@ -370,8 +371,8 @@ StarServer::GameState()
}
else if (game_mode == PLAY_MODE) {
- if (Game::GetInstance()->GetClock()->GameTime() - time_mark > 60000) {
- time_mark = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - time_mark > 60000) {
+ time_mark = Clock::GetInstance()->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 8bf1348..d1558d7 100644
--- a/Stars45/StarSystem.cpp
+++ b/Stars45/StarSystem.cpp
@@ -22,6 +22,7 @@
#include "Game.h"
#include "GameWinDX9.h"
+#include "Clock.h"
#include "Sound.h"
#include "Solid.h"
#include "Light.h"
@@ -70,7 +71,7 @@ void StarSystem::CalcStardate()
base_time += epoch;
}
- long double gtime = (long double) Game::GetInstance()->GetClock()->GameTime() / 1000.0;
+ long double gtime = (long double) Clock::GetInstance()->GameTime() / 1000.0;
long double sdate = gtime + base_time + epoch;
stardate = sdate;
diff --git a/Stars45/Starshatter.cpp b/Stars45/Starshatter.cpp
index d1602b2..b49fbc4 100644
--- a/Stars45/Starshatter.cpp
+++ b/Stars45/Starshatter.cpp
@@ -85,6 +85,7 @@
#include "MachineInfo.h"
#include "Game.h"
#include "GameWinDX9.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "VideoFactory.h"
#include "Screen.h"
@@ -456,7 +457,7 @@ Starshatter::InitGame()
SetupSplash();
}
- time_mark = Game::GetInstance()->GetClock()->GameTime();
+ time_mark = Clock::GetInstance()->GameTime();
minutes = 0;
return true;
@@ -617,7 +618,7 @@ Starshatter::SetGameMode(int m)
HUDView::ClearMessages();
RadioView::ClearMessages();
- clock.SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
Pause(false);
Print(" Stardate: %.1f\n", StarSystem::GetBaseTime());
@@ -855,7 +856,7 @@ Starshatter::UpdateWorld()
Drive::StartFrame();
if (world)
- world->ExecFrame(clock.Delta());
+ world->ExecFrame(Clock::GetInstance()->Delta());
}
if (game_mode == PLAY_MODE || InCutscene()) {
@@ -866,7 +867,7 @@ Starshatter::UpdateWorld()
cam_dir->VirtualHeadOffset(head_tracker->GetX(), head_tracker->GetY(), head_tracker->GetZ());
}
- cam_dir->ExecFrame(clock.GuiDelta());
+ cam_dir->ExecFrame(Clock::GetInstance()->GuiDelta());
}
Sim* sim = Sim::GetSim();
@@ -876,7 +877,7 @@ Starshatter::UpdateWorld()
ListIter<Ship> iter = rgn->Ships();
while (++iter) {
Ship* s = iter.value();
- s->SelectDetail(clock.Delta());
+ s->SelectDetail(Clock::GetInstance()->Delta());
}
}
}
@@ -1068,7 +1069,7 @@ Starshatter::GameState()
}
if (game_mode == EXIT_MODE) {
- exit_time -= Game::GetInstance()->GetClock()->GuiDelta();
+ exit_time -= Clock::GetInstance()->GuiDelta();
if (exit_time <= 0)
Game::Exit();
@@ -1094,7 +1095,7 @@ Starshatter::DoMenuScreenFrame()
}
if (time_til_change > 0)
- time_til_change -= Game::GetInstance()->GetClock()->GuiDelta();
+ time_til_change -= Clock::GetInstance()->GuiDelta();
if (!menuscreen)
return;
@@ -1156,7 +1157,7 @@ Starshatter::DoPlanScreenFrame()
Mouse::SetCursor(Mouse::ARROW);
if (time_til_change > 0)
- time_til_change -= Game::GetInstance()->GetClock()->GuiDelta();
+ time_til_change -= Clock::GetInstance()->GuiDelta();
if (KeyDown(KEY_EXIT)) {
if (time_til_change <= 0) {
@@ -1189,7 +1190,7 @@ Starshatter::DoCmpnScreenFrame()
Mouse::SetCursor(Mouse::ARROW);
if (time_til_change > 0)
- time_til_change -= Game::GetInstance()->GetClock()->GuiDelta();
+ time_til_change -= Clock::GetInstance()->GuiDelta();
exit_latch = KeyDown(KEY_EXIT) ? true : false;
@@ -1233,18 +1234,18 @@ Starshatter::DoCmpnScreenFrame()
else if (KeyDown(KEY_TIME_COMPRESS)) {
time_til_change = 1;
- double compression = clock.TimeCompression() * 2;
+ double compression = Clock::GetInstance()->TimeCompression() * 2;
if (compression > 8.0)
compression = 8.0;
- clock.SetTimeCompression(compression);
+ Clock::GetInstance()->SetTimeCompression(compression);
}
else if (KeyDown(KEY_TIME_EXPAND)) {
time_til_change = 1;
- double compression = clock.TimeCompression() / 2;
+ double compression = Clock::GetInstance()->TimeCompression() / 2;
if (compression < 0.5)
compression = 0.5;
- clock.SetTimeCompression(compression);
+ Clock::GetInstance()->SetTimeCompression(compression);
}
}
}
@@ -1464,7 +1465,7 @@ Starshatter::DoGameScreenFrame()
}
}
- gamescreen->FrameRate(Game::GetInstance()->GetClock()->Rate());
+ gamescreen->FrameRate(Clock::GetInstance()->Rate());
gamescreen->ExecFrame();
if (KeyDown(KEY_EXIT)) {
@@ -1479,7 +1480,7 @@ Starshatter::DoGameScreenFrame()
}
if (time_til_change > 0)
- time_til_change -= Game::GetInstance()->GetClock()->GuiDelta();
+ time_til_change -= Clock::GetInstance()->GuiDelta();
if (exit_latch && !KeyDown(KEY_EXIT))
exit_latch = false;
@@ -1544,11 +1545,11 @@ Starshatter::DoGameScreenFrame()
DoGameKeys();
}
- gamescreen->FrameRate(Game::GetInstance()->GetClock()->Rate());
+ gamescreen->FrameRate(Clock::GetInstance()->Rate());
gamescreen->ExecFrame();
- if (Game::GetInstance()->GetClock()->GameTime() - time_mark > 60000) {
- time_mark = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - time_mark > 60000) {
+ time_mark = Clock::GetInstance()->GameTime();
minutes++;
if (minutes > 60)
Print(" TIME %2d:%02d:00\n", minutes/60, minutes%60);
@@ -1633,12 +1634,12 @@ Starshatter::DoGameKeys()
else if (KeyDown(KEY_TIME_COMPRESS)) {
time_til_change = 0.5;
if (NetGame::IsNetGame())
- clock.SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
else {
- double compression = clock.TimeCompression() * 2;
+ double compression = Clock::GetInstance()->TimeCompression() * 2;
if (compression > 4.0)
compression = 4.0;
- clock.SetTimeCompression(compression);
+ Clock::GetInstance()->SetTimeCompression(compression);
}
}
@@ -1646,12 +1647,12 @@ Starshatter::DoGameKeys()
time_til_change = 0.5;
if (NetGame::IsNetGame())
- clock.SetTimeCompression(1.0);
+ Clock::GetInstance()->SetTimeCompression(1.0);
else {
- double compression = clock.TimeCompression() / 2;
+ double compression = Clock::GetInstance()->TimeCompression() / 2;
if (compression < 0.5)
compression = 0.5;
- clock.SetTimeCompression(compression);
+ Clock::GetInstance()->SetTimeCompression(compression);
}
}
@@ -1806,7 +1807,7 @@ Starshatter::DoGameKeys()
}
if (cam_dir) {
- double spin = (PI/2) * Game::GetInstance()->GetClock()->Delta(); // Game::GetInstance()->GetClock()->GuiDelta();
+ double spin = (PI/2) * Clock::GetInstance()->Delta(); // Game::GetInstance()->GetClock()->GuiDelta();
if (KeyDown(KEY_CAM_EXT_PLUS_AZ))
cam_dir->ExternalAzimuth(spin);
@@ -1834,13 +1835,13 @@ Starshatter::DoGameKeys()
if (KeyDown(KEY_CAM_EXT_PLUS_RANGE)){
if (!gamescreen->IsNavShown()) {
- cam_dir->ExternalRange((float) (1 + 1.5 * Game::GetInstance()->GetClock()->Delta())); // 1.1f);
+ cam_dir->ExternalRange((float) (1 + 1.5 * Clock::GetInstance()->Delta())); // 1.1f);
}
}
else if (KeyDown(KEY_CAM_EXT_MINUS_RANGE)) {
if (!gamescreen->IsNavShown()) {
- cam_dir->ExternalRange((float) (1 - 1.5 * Game::GetInstance()->GetClock()->Delta())); // 0.9f);
+ cam_dir->ExternalRange((float) (1 - 1.5 * Clock::GetInstance()->Delta())); // 0.9f);
}
}
diff --git a/Stars45/StarshipAI.cpp b/Stars45/StarshipAI.cpp
index 5a32391..5b6b697 100644
--- a/Stars45/StarshipAI.cpp
+++ b/Stars45/StarshipAI.cpp
@@ -29,7 +29,7 @@
#include "Farcaster.h"
#include "QuantumDrive.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Random.h"
@@ -66,7 +66,7 @@ StarshipAI::StarshipAI(SimObject* s)
tactical = new(__FILE__,__LINE__) StarshipTacticalAI(this);
}
- sub_select_time = Game::GetInstance()->GetClock()->GameTime() + (DWORD) Random(0, 2000);
+ sub_select_time = Clock::GetInstance()->GameTime() + (DWORD) Random(0, 2000);
point_defense_time = sub_select_time;
}
@@ -639,7 +639,7 @@ StarshipAI::FireControl()
System*
StarshipAI::SelectSubtarget()
{
- if (Game::GetInstance()->GetClock()->GameTime() - sub_select_time < 2345)
+ if (Clock::GetInstance()->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()->GetClock()->GameTime();
+ sub_select_time = Clock::GetInstance()->GameTime();
// first pass: turrets
ListIter<WeaponGroup> g_iter = tgt_ship->Weapons();
@@ -727,7 +727,7 @@ StarshipAI::SelectSubtarget()
bool
StarshipAI::AssessTargetPointDefense()
{
- if (Game::GetInstance()->GetClock()->GameTime() - point_defense_time < 3500)
+ if (Clock::GetInstance()->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()->GetClock()->GameTime();
+ point_defense_time = Clock::GetInstance()->GameTime();
// first pass: turrets
ListIter<WeaponGroup> g_iter = tgt_ship->Weapons();
diff --git a/Stars45/StarshipTacticalAI.cpp b/Stars45/StarshipTacticalAI.cpp
index 1a7db8c..1e59b79 100644
--- a/Stars45/StarshipTacticalAI.cpp
+++ b/Stars45/StarshipTacticalAI.cpp
@@ -36,7 +36,7 @@
#include "Starshatter.h"
#include "Random.h"
-#include "Game.h"
+#include "Clock.h"
const double STARSHIP_TACTICAL_DROP_TIME = 15;
@@ -124,7 +124,7 @@ StarshipTacticalAI::FindThreat()
}
if (contact->Threat(ship) &&
- (Game::GetInstance()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
+ (Clock::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
if (c_shot) {
threat_missile = c_shot;
diff --git a/Stars45/SteerAI.cpp b/Stars45/SteerAI.cpp
index 441773a..5573b95 100644
--- a/Stars45/SteerAI.cpp
+++ b/Stars45/SteerAI.cpp
@@ -19,7 +19,7 @@
#include "GroundAI.h"
#include "System.h"
-#include "Game.h"
+#include "Clock.h"
#include "Physical.h"
// +----------------------------------------------------------------------+
@@ -429,8 +429,8 @@ SteerAI::Evade(const Point& point, const Point& vel)
{
Steer evade;
- if (Game::GetInstance()->GetClock()->GameTime() - evade_time > 1250) {
- evade_time = Game::GetInstance()->GetClock()->GameTime();
+ if (Clock::GetInstance()->GameTime() - evade_time > 1250) {
+ evade_time = Clock::GetInstance()->GameTime();
int direction = (rand()>>9) & 0x07;
diff --git a/Stars45/TacticalAI.cpp b/Stars45/TacticalAI.cpp
index 8a8b155..82385f3 100644
--- a/Stars45/TacticalAI.cpp
+++ b/Stars45/TacticalAI.cpp
@@ -30,7 +30,7 @@
#include "Drone.h"
#include "StarSystem.h"
-#include "Game.h"
+#include "Clock.h"
#include "Random.h"
// +----------------------------------------------------------------------+
@@ -80,7 +80,7 @@ TacticalAI::ExecFrame(double secs)
navpt = ship->GetNextNavPoint();
orders = ship->GetRadioOrders();
- if ((int) Game::GetInstance()->GetClock()->GameTime() - exec_time > exec_period) {
+ if ((int) Clock::GetInstance()->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()->GetClock()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
+ (Clock::GetInstance()->GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
if (contact->GetShot()) {
threat_missile = contact->GetShot();
diff --git a/Stars45/TacticalView.cpp b/Stars45/TacticalView.cpp
index 4bd458c..0f59619 100644
--- a/Stars45/TacticalView.cpp
+++ b/Stars45/TacticalView.cpp
@@ -45,7 +45,7 @@
#include "Mouse.h"
#include "MouseController.h"
#include "Menu.h"
-#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "FormatUtil.h"
@@ -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()->GetClock()->RealTime();
+ rbutton_latch = Clock::GetInstance()->RealTime();
right_down = true;
}
}
else {
- if (sim && right_down && (Game::GetInstance()->GetClock()->RealTime() - rbutton_latch < 250)) {
+ if (sim && right_down && (Clock::GetInstance()->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()->GetClock()->RealTime() - click_time < 350)
+ if (ship->IsStarship() && Clock::GetInstance()->RealTime() - click_time < 350)
SetHelm(hit);
- click_time = Game::GetInstance()->GetClock()->RealTime();
+ click_time = Clock::GetInstance()->RealTime();
}
}
}
@@ -1433,7 +1433,7 @@ TacticalView::DrawAction()
}
if (tgt && r) {
- if ((Game::GetInstance()->GetClock()->RealTime()/200) & 1)
+ if ((Clock::GetInstance()->RealTime()/200) & 1)
r = 20;
else
r = 15;
diff --git a/Stars45/Trail.cpp b/Stars45/Trail.cpp
index 71f224f..80735d2 100644
--- a/Stars45/Trail.cpp
+++ b/Stars45/Trail.cpp
@@ -16,11 +16,12 @@
#include "Weapon.h"
#include "Sim.h"
-#include "Game.h"
+#include "Clock.h"
#include "Light.h"
#include "Bitmap.h"
#include "DataLoader.h"
#include "Sound.h"
+#include "Video.h"
// +--------------------------------------------------------------------+
@@ -141,7 +142,7 @@ Trail::AddPoint(const Point& v)
{
if (ntrail >= maxtrail-1) return;
- double real_time = Game::GetInstance()->GetClock()->RealTime() / 1000.0;
+ double real_time = Clock::GetInstance()->RealTime() / 1000.0;
if (ntrail == 0) {
radius = 1000;
diff --git a/Stars45/Weapon.cpp b/Stars45/Weapon.cpp
index 2e35157..33a3238 100644
--- a/Stars45/Weapon.cpp
+++ b/Stars45/Weapon.cpp
@@ -25,6 +25,7 @@
#include "NetUtil.h"
#include "Game.h"
+#include "Clock.h"
#include "ContentBundle.h"
#include "Solid.h"
@@ -1145,7 +1146,7 @@ Weapon::CanLockPoint(const Point& test, double& az, double& el, Point* obj)
void
Weapon::AimTurret(double az, double el)
{
- double seconds = (Game::GetInstance()->GetClock()->GameTime() - aim_time) / 1000.0;
+ double seconds = (Clock::GetInstance()->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 +1171,7 @@ Weapon::AimTurret(double az, double el)
old_azimuth = (float) az;
old_elevation = (float) el;
- aim_time = Game::GetInstance()->GetClock()->GameTime();
+ aim_time = Clock::GetInstance()->GameTime();
}
void
diff --git a/Stars45/WepView.cpp b/Stars45/WepView.cpp
index 508d269..bd9a1cb 100644
--- a/Stars45/WepView.cpp
+++ b/Stars45/WepView.cpp
@@ -41,7 +41,7 @@
#include "Graphic.h"
#include "Keyboard.h"
#include "Mouse.h"
-#include "Game.h"
+#include "Clock.h"
#include "FormatUtil.h"
static Bitmap tac_left;
@@ -387,11 +387,11 @@ WepView::DrawOverlay()
Text subtxt;
Color stat = hud_color;
- static DWORD blink = Game::GetInstance()->GetClock()->RealTime();
+ static DWORD blink = Clock::GetInstance()->RealTime();
if (ship->GetTarget()) {
if (ship->GetSubTarget()) {
- int blink_delta = Game::GetInstance()->GetClock()->RealTime() - blink;
+ int blink_delta = Clock::GetInstance()->RealTime() - blink;
System* sys = ship->GetSubTarget();
subtxt = sys->Abbreviation();
@@ -406,7 +406,7 @@ WepView::DrawOverlay()
}
if (blink_delta > 500)
- blink = Game::GetInstance()->GetClock()->RealTime();
+ blink = Clock::GetInstance()->RealTime();
}
else