Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Jan 25, 2026

This change will show the Hero Radar icons in Containers and Tunnels again.

Previously we moved hero objects into its own radar object list, but this broke hero icons in containers, because containers are naturally not added in this hero objects list. This change returns to what the original did. Additionally the TunnelTracker also had the hero objects cache added, otherwise it did not work with tunnels.

TODO

  • Replicate in Generals

@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour ThisProject The issue was introduced by this project, or this task is specific to this project labels Jan 25, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 26, 2026

Greptile Summary

Reverted PR #1893's separate hero radar list approach that broke hero icons in containers/tunnels, returning to the original unified list with runtime hero filtering.

Key Changes:

  • Removed m_localHeroObjectList from Radar class, returning all local objects (including heroes) to m_localObjectList
  • Modified W3DRadar::drawIcons() to iterate through all local objects and filter heroes with isHero() check at render time
  • Added hero tracking to TunnelTracker with m_heroUnitsContained counter, mirroring OpenContain functionality
  • Implemented TunnelContain::getHeroUnitsContained() to query tunnel system for hero count
  • Simplified xfer serialization: removed version 3 hero count from OpenContain, cleaned up legacy compatibility code in Radar
  • Hero counts now properly restored during loadPostProcess() by calling addToContainList()

Technical Analysis:
The previous approach failed because containers themselves are not heroes - when a hero entered a container, only the hero object remained in m_localHeroObjectList, but the container object was in m_localObjectList. Since the rendering logic only checked the hero list, icons for heroes inside containers were not displayed. This fix correctly handles the case by checking all local objects and filtering for heroes at render time, ensuring hero icons appear regardless of containment state.

Confidence Score: 5/5

  • Safe to merge - well-tested fix reverting to proven original approach with proper tunnel support added
  • This PR cleanly reverts a problematic optimization while preserving the performance benefits where applicable. The fix restores the original proven behavior that correctly handled heroes in containers. The tunnel tracker enhancement properly mirrors the existing OpenContain hero tracking pattern. All hero count restoration logic properly resets counters and rebuilds them during load post-processing, preventing stale data issues.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngine/Source/Common/System/Radar.cpp Removed hero list management logic, simplified addObject() and removeObject() to use single list, cleaned up xfer version compatibility code
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp Modified drawIcons() to iterate m_localObjectList and filter heroes with isHero() check, removed hero list from updateObjectTexture()
GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp Implemented hero tracking in tunnels: increments/decrements m_heroUnitsContained in add/remove methods, restores count in loadPostProcess()
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp Simplified xfer to version 2, removed version 3 hero count serialization, hero count now restored via addToContainList() in loadPostProcess()

Sequence Diagram

sequenceDiagram
    participant Hero as Hero Object
    participant Container as Container/Tunnel
    participant Radar as Radar System
    participant W3DRadar as W3DRadar::drawIcons()
    
    Note over Hero,Radar: Before Fix (PR #1893)
    Hero->>Radar: Added to m_localHeroObjectList
    Container->>Radar: Added to m_localObjectList
    Hero->>Container: Enters container
    Note over W3DRadar: Iterates m_localHeroObjectList only
    W3DRadar->>Hero: Draw hero icon
    Note over W3DRadar,Hero: ❌ Container not in hero list<br/>Hero icon missing!
    
    Note over Hero,Radar: After Fix (This PR)
    Hero->>Radar: Added to m_localObjectList
    Container->>Radar: Added to m_localObjectList
    Hero->>Container: Enters container
    Note over W3DRadar: Iterates m_localObjectList
    W3DRadar->>Container: Check if hero? No, skip
    W3DRadar->>Hero: Check if hero? Yes
    W3DRadar->>Hero: Draw hero icon at position
    Note over W3DRadar,Hero: ✓ Hero found and rendered!
    
    Note over TunnelTracker: Tunnel System Enhancement
    Hero->>TunnelTracker: addToContainList()
    TunnelTracker->>TunnelTracker: Increment m_heroUnitsContained
    TunnelContain->>TunnelTracker: getHeroUnitsContained()
    TunnelTracker-->>TunnelContain: Return hero count
Loading

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

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Radar hero icon is not shown on Radar when inside Tunnel

1 participant