Skip to content

Fix igt 24h rounding issue#10

Open
krios2146 wants to merge 2 commits intosoarqin:masterfrom
krios2146:igt-display-fix
Open

Fix igt 24h rounding issue#10
krios2146 wants to merge 2 commits intosoarqin:masterfrom
krios2146:igt-display-fix

Conversation

@krios2146
Copy link

@krios2146 krios2146 commented Dec 19, 2025

Fixed issue when igt was rounding to 24h because of the "{igt:.0%H:%M:%S}" pattern

Fixed IGT vs original IGT % 24 (208 % 24 = 16)
image

Summary by CodeRabbit

  • Refactor
    • Streamlined time display formatting by consolidating duplicate time format variants into a unified formatting system, improving code maintainability.
    • Time values are now consistently formatted using a single standardized method, replacing multiple format variants.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 19, 2025

Walkthrough

The changes consolidate time formatting logic in the renderer by replacing templated time placeholders with a single runtime function. A new format_time() method replaces multiple per-hour text variants and handles time injection via token substitution instead of argument preprocessing.

Changes

Cohort / File(s) Summary
Time Formatting Refactor
src/boss/render.hpp, src/boss/render.cpp
Added public format_time() method that computes and returns formatted time as HH:MM:SS or MM:SS. Removed per-hour text variants (killTextHour_, challengeTextHour_). Replaced templated time placeholders with post-format token substitution using "$igt" token instead of preprocessed argument injection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through time's refrain, 🐰
Where templated placeholders once did reign.
Now format_time() simplifies the way,
With hours and minutes arranged per display.
Hours shorten the code, the logic runs plain! ⏰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix igt 24h rounding issue' directly and clearly describes the primary change: fixing an IGT (in-game time) 24-hour rounding issue mentioned in the PR objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/boss/render.cpp (1)

95-96: Consider extracting the repeated format-and-replace pattern.

The pattern of fmt::vformat() followed by util::replaceAll(..., "$igt", format_time()) is repeated four times. While not critical, extracting this into a helper method would reduce duplication.

Possible refactor

Add a private helper method in the class:

std::string format_with_time(const std::string& template_text) const {
    auto text = fmt::vformat(template_text, args_);
    util::replaceAll(text, std::string("$igt"), format_time());
    return text;
}

Then simplify the call sites:

// Instead of:
auto text = fmt::vformat(challengeText_, args_);
util::replaceAll(text, std::string("$igt"), format_time());

// Use:
auto text = format_with_time(challengeText_);

Also applies to: 99-100, 120-121, 124-125

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4471ec and c286299.

📒 Files selected for processing (2)
  • src/boss/render.cpp (4 hunks)
  • src/boss/render.hpp (2 hunks)
🔇 Additional comments (4)
src/boss/render.hpp (2)

24-24: LGTM! Clean method declaration.

The new format_time() method declaration is well-placed and appropriately marked as const.


37-38: Good consolidation of format strings.

Removing the hour-specific variants (killTextHour_ and challengeTextHour_) in favor of a single dynamic format is cleaner and eliminates duplication.

src/boss/render.cpp (2)

30-35: LGTM! Smart placeholder approach.

Replacing {igt} with $igt prevents fmt from attempting to format it as a chrono type, allowing for manual post-processing with the correctly formatted time string. This effectively sidesteps the modulo-24 limitation of %H.


193-205: Excellent fix! This correctly resolves the 24-hour rounding issue.

The manual calculation of hours without applying modulo 24 is the key improvement. Previously, the %H chrono format specifier would wrap at 24 hours (e.g., 208 hours → 16:00:00), but this implementation correctly displays the full hour count (208:00:00).

The logic is sound:

  • Hours: total_seconds / 3600 (no modulo)
  • Minutes: (total_seconds / 60) % 60
  • Seconds: total_seconds % 60

The conditional format (showing hours only when > 0) is also a nice touch for readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant