Skip to content

fix WeatherParticleMesh assertion failure on high precipitation settings - #561

Merged
nschimme merged 4 commits into
MUME:masterfrom
nschimme:jules-fix-weather-intensity-assert-17226212354979737261
Oct 1, 2026
Merged

nschimme merged 4 commits into
MUME:masterfrom
nschimme:jules-fix-weather-intensity-assert-17226212354979737261

Conversation

@nschimme

@nschimme nschimme commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Prevent debug assertion failures for precipitation intensity values above 50 while keeping particle rendering within the available particle buffer.

Summary by Sourcery

Bug Fixes:

  • Prevent precipitation intensity values above 50 from triggering debug assertions while keeping rendered particle counts within the available buffer.

nschimme and others added 3 commits September 14, 2026 14:49
- Create docs/web.md as a landing page for MMapper Web matching desktop platforms.
- Provide direct link to launch MMapper Web and a collapsible Web Beta section.
- Add PWA installation instructions for iOS (Safari) and Android (Chrome).
- Update homepage (docs/index.md) Web platform link to point to /web.html.
In Debug builds, setting Precipitation Intensity in Preferences above 50
(up to 100) caused an assertion crash in WeatherParticleMesh::setIntensity()
because target intensities were calculated up to 2.0 (setting / 50.0).

Updated WeatherParticleMesh::setIntensity() to assert non-negativity instead
of clamping to 1.0f, and clamped the particle instance count in
virt_render() to m_numParticles (512) to ensure buffer safety.
@sourcery-ai

sourcery-ai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR fixes high-precipitation assertion failures by accepting nonnegative intensity values above 1.0 and bounding the resulting rendered particle count to the allocated particle buffer.

Flow diagram for bounded weather particle rendering

flowchart TD
    A[setIntensity intensity] --> B{intensity >= 0}
    B -->|No| C[Assertion failure]
    B -->|Yes| D[m_intensity = max 0 intensity]
    D --> E{m_intensity > 0}
    E -->|Yes| F[count = clamp intensity times maxCount between 1 and maxCount]
    F --> G[Render bounded particle instances]
    E -->|No| H[Skip particle rendering]
Loading

File-Level Changes

Change Details Files
Allow precipitation intensities above the normalized range without exceeding the particle buffer during rendering.
  • Relaxed the setter assertion to reject only negative values.
  • Clamped stored intensity to a nonnegative value while preserving high positive inputs.
  • Clamped the computed instance count between one and the available particle count.
src/opengl/legacy/WeatherMeshes.cpp

Possibly linked issues

  • #unknown: The PR removes the upper intensity assertion and clamps particle counts, directly fixing the reported high-precipitation crash.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/opengl/legacy/WeatherMeshes.cpp" line_range="178-179" />
<code_context>
-                                             static_cast<GLsizei>(m_intensity
-                                                                  * static_cast<float>(maxCount)));
+        const auto count = std::clamp<GLsizei>(static_cast<GLsizei>(m_intensity
+                                                                    * static_cast<float>(maxCount)),
+                                               1,
+                                               maxCount);

</code_context>
<issue_to_address>
**issue (bug_risk):** The particle count is converted to `GLsizei` before it is clamped. A finite intensity large enough that `intensity * maxCount` exceeds `GLsizei`'s range causes an out-of-range floating-to-integer conversion, which has undefined behavior instead of safely selecting `maxCount`.

**Triggers:** When `setIntensity()` is called with a finite value greater than approximately 4.2 million for the current 512-particle buffer, including a future caller that bypasses the preferences' 0–100 limit.

**Suggested fix:** Clamp the intensity or the floating-point count before converting it to `GLsizei`, or handle `m_intensity >= 1.0f` by assigning `maxCount` directly.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/opengl/legacy/WeatherMeshes.cpp:179


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/opengl/legacy/WeatherMeshes.cpp Outdated
In Debug builds, setting Precipitation Intensity in Preferences above 50
(up to 100) caused an assertion crash in WeatherParticleMesh::setIntensity()
because target intensities were calculated up to 2.0 (setting / 50.0).

Updated WeatherParticleMesh::setIntensity() to assert non-negativity instead
of clamping to 1.0f, and updated virt_render() to assign maxCount directly
when m_intensity >= 1.0f to avoid float overflow prior to integer casting.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@nschimme
nschimme merged commit 6a0ae0e into MUME:master Oct 1, 2026
19 checks passed
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.91%. Comparing base (cca5ea3) to head (b343f2d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/opengl/legacy/WeatherMeshes.cpp 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #561      +/-   ##
==========================================
- Coverage   27.91%   27.91%   -0.01%     
==========================================
  Files         563      563              
  Lines       46169    46171       +2     
  Branches     4884     4884              
==========================================
  Hits        12889    12889              
- Misses      33280    33282       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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