Skip to content

Commit

Permalink
Check early for slams
Browse files Browse the repository at this point in the history
  • Loading branch information
ASleepyCat committed May 23, 2021
1 parent 0e97f96 commit 3d674b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Main/include/Scoring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ enum class TickFlags : uint8
Slam = 0x20,

// Used to make hit effects appear correctly for holds
Ignore = 0x40
Ignore = 0x40,

Processed = 0x80
};
TickFlags operator|(const TickFlags& a, const TickFlags& b);
TickFlags operator&(const TickFlags& a, const TickFlags& b);
Expand Down
21 changes: 15 additions & 6 deletions Main/src/Scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,15 @@ void Scoring::m_UpdateTicks()
}
else if (tick->HasFlag(TickFlags::Laser))
{
LaserObjectState* laserObject = (LaserObjectState*)tick->object;
auto* laserObject = (LaserObjectState*)tick->object;
if (tick->HasFlag(TickFlags::Slam))
{
// Check if slam hit
float dirSign = Math::Sign(laserObject->GetDirection());
float inputSign = Math::Sign(m_input->GetInputLaserDir(buttonCode - 6));
if (autoplayInfo.autoplay || (dirSign == inputSign && delta <= hitWindow.slam))

if (autoplayInfo.autoplay || (dirSign == inputSign && delta <= hitWindow.slam / 2)
|| tick->HasFlag(TickFlags::Processed))
{
m_TickHit(tick, buttonCode);
HitStat* stat = new HitStat(tick->object);
Expand Down Expand Up @@ -792,6 +794,14 @@ void Scoring::m_UpdateTicks()
}
}
}
else if (tick->HasFlag(TickFlags::Slam))
{
auto* laserObject = (LaserObjectState*)tick->object;
float dirSign = Math::Sign(laserObject->GetDirection());
float inputSign = Math::Sign(m_input->GetInputLaserDir(buttonCode - 6));
if (dirSign == inputSign && std::abs(delta) <= hitWindow.slam / 2)
tick->SetFlag(TickFlags::Processed);
}

bool miss = (tick->HasFlag(TickFlags::Slam) && delta > hitWindow.slam)
|| (!tick->HasFlag(TickFlags::Slam) && delta > hitWindow.good);
Expand Down Expand Up @@ -998,7 +1008,6 @@ void Scoring::m_UpdateGauges(ScoreHitRating rating, TickFlags flags)
}
}


while (m_gaugeStack.size() > 1 && m_gaugeStack.back()->FailOut())
{
Gauge* lostGauge = m_gaugeStack.back();
Expand All @@ -1019,11 +1028,11 @@ void Scoring::m_UpdateGaugeSamples()

void Scoring::m_CleanupTicks()
{
for (uint32 i = 0; i < 8; i++)
for (auto & m_tick : m_ticks)
{
for (ScoreTick* tick : m_ticks[i])
for (ScoreTick* tick : m_tick)
delete tick;
m_ticks[i].clear();
m_tick.clear();
}
}

Expand Down

0 comments on commit 3d674b7

Please sign in to comment.