Skip to content

fix(smudge): Fix minor errors in W3DSmudge#2483

Open
xezon wants to merge 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/fix-smudge-code
Open

fix(smudge): Fix minor errors in W3DSmudge#2483
xezon wants to merge 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/fix-smudge-code

Conversation

@xezon
Copy link

@xezon xezon commented Mar 22, 2026

This change adds a few minor fixes to W3DSmudge.

  1. The static assert turns the comment to a compile guarantee.

  2. The smudge offset Y is now used correctly, but visually appears to have no obvious impact.

  3. The vb_access buffer in W3DSmudgeManager::render is no longer forwarded to rendering before the lock is lifted.

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Rendering Is Rendering related Fix Is fixing something, but is not user facing labels Mar 22, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 22, 2026

Greptile Summary

This PR applies three focused correctness fixes to W3DSmudgeManager in W3DSmudge.cpp:

  • Static assert replaces a stale (and numerically incorrect) comment. The original guard checked SMUDGE_DRAW_SIZE * 12, which counted index-buffer entries rather than the maximum vertex index; the new static_assert(SMUDGE_DRAW_SIZE * 5 < 0x10000, ...) correctly bounds the 16-bit vertex index to the allocated 5-vertices-per-smudge layout.
  • UV Y-offset copy-paste fix corrects verts[4].uv.Y being computed with smudge->m_offset.X instead of smudge->m_offset.Y, ensuring the center vertex is properly offset in both axes.
  • Vertex buffer lock fix moves the flushSmudges: label outside the DynamicVBAccessClass::WriteLockClass scope so DX8Wrapper::Set_Vertex_Buffer and Draw_Triangles are called only after the write lock is released; C++ RAII guarantees the lock destructor fires on goto-induced scope exit.

Additional cleanup: long tab-separated assignment pairs in testHardwareSupport are split onto separate lines, and an inlined if/else chain for coordinate clamping is collapsed into a single || condition.

Confidence Score: 5/5

  • This PR is safe to merge — all three fixes are straightforward, well-scoped, and each targets a clearly demonstrable bug.
  • The UV copy-paste fix is a clear one-liner correction. The lock-ordering fix is mechanically correct (C++ RAII guarantees the destructor fires on goto-induced scope exit, so there is no double-unlock risk). The static_assert change fixes an arithmetically incorrect guard. No new logic is introduced, and the formatting cleanups are non-functional.
  • No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp Three targeted bug fixes: static_assert replaces an incorrect comment guard (changes multiplier from 12 to 5), a copy-paste bug using m_offset.X instead of m_offset.Y for the center UV Y coordinate is corrected, and the DX8 vertex buffer is now set only after the WriteLockClass RAII lock goes out of scope. Formatting cleanups accompany the logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[W3DSmudgeManager::render] --> B[Compute smudge UV coords]
    B --> C{UV out of bounds?}
    C -- "X or Y outside 0..texClamp" --> D[Zero m_offset.X / m_offset.Y]
    C -- in bounds --> E[Compute center vertex UV]
    D --> E
    E --> F["verts[4].uv.Y = base + uvSpanY*(0.5 + m_offset.Y)  ✔️ (was .X)"]
    F --> G[Outer render batch loop]
    G --> H["DynamicVBAccessClass vb_access(count*5 verts)"]
    H --> I["WriteLockClass lock{vb_access}  — lock acquired"]
    I --> J[Fill vertex data into locked buffer]
    J --> K{Batch full?}
    K -- yes --> L[goto flushSmudges — scope exits, lock RAII destructor called]
    K -- no --> M[Continue filling]
    M --> N{All smudges done?}
    N -- no --> J
    N -- yes --> O[Exit lock scope — destructor called]
    O --> P["flushSmudges: Set_Vertex_Buffer + Draw_Triangles  ✔️ (lock released)"]
    L --> P
    P --> Q{smudgesRemaining > 0?}
    Q -- yes --> H
    Q -- no --> R[Restore render states / done]
Loading

Reviews (1): Last reviewed commit: "fix(smudge): Fix minor errors in W3DSmud..." | Re-trigger Greptile

Copy link

@Mauller Mauller left a comment

Choose a reason for hiding this comment

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

Looks smudged

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

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants