summaryrefslogtreecommitdiffhomepage
path: root/Stars45/Ship.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-08 19:33:59 +0100
committerAki <please@ignore.pl>2022-03-08 19:33:59 +0100
commite472d9537ee7919630e5f6039f8425b06f6c4213 (patch)
treec146d59b532ec1ae248727faa182102cab6365e2 /Stars45/Ship.cpp
parentb563a07d9fcaa58514eeb3ec78438db56ecf2e63 (diff)
downloadstarshatter-e472d9537ee7919630e5f6039f8425b06f6c4213.zip
starshatter-e472d9537ee7919630e5f6039f8425b06f6c4213.tar.gz
starshatter-e472d9537ee7919630e5f6039f8425b06f6c4213.tar.bz2
Replaced time funcs from Game with Clock equivalents
This excludes time compression stuff, as it will need some more attention due to casting. I don't quite like the long invocations that go through game instance first then get the clock. It looks bad. I'll need to rethink how modules are being made available in the codebase.
Diffstat (limited to 'Stars45/Ship.cpp')
-rw-r--r--Stars45/Ship.cpp34
1 files changed, 17 insertions, 17 deletions
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;
}