Skip to content

Commit d93677d

Browse files
committed
common: Cleanup UpdatePacifier
1 parent e8ba679 commit d93677d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

utils/common/pacifier.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@ void StartPacifier(char const *pPrefix) {
2323
}
2424

2525
void UpdatePacifier(float flPercent) {
26-
int iCur = (int)(flPercent * 40.0f);
27-
iCur = std::clamp(iCur, g_LastPacifierDrawn, 40);
26+
constexpr int forty = 40;
2827

29-
if (iCur != g_LastPacifierDrawn && !g_bPacifierSuppressed) {
30-
for (int i = g_LastPacifierDrawn + 1; i <= iCur; i++) {
31-
if (!(i % 4)) {
32-
Msg("%d", i / 4);
28+
const int it = std::clamp(static_cast<int>(flPercent * forty),
29+
g_LastPacifierDrawn, forty);
30+
31+
if (it != g_LastPacifierDrawn && !g_bPacifierSuppressed) {
32+
for (int i = g_LastPacifierDrawn + 1; i <= it; i++) {
33+
const auto dv = div(i, 4);
34+
35+
if (dv.rem == 0) {
36+
Msg("%d", dv.quot);
3337
} else {
34-
if (i != 40) {
35-
Msg(".");
36-
}
38+
if (i != forty) Msg(".");
3739
}
3840
}
3941

40-
g_LastPacifierDrawn = iCur;
42+
g_LastPacifierDrawn = it;
4143
}
4244
}
4345

0 commit comments

Comments
 (0)