Skip to content

MapNotify: color codes in item names render as visible ÿ in message log notifications #84

@danielcase-man

Description

@danielcase-man

Bug Description

Item names modified by loot filter rules containing ÿc color codes display raw ÿ characters in the message log (Item Drop Notifications / Item Close Notifications), even though the same names render correctly as ground labels.

For example, a Sol rune with decorated filter output like:

%DARK_GREEN%*%GREEN%*  Sol %GREEN%12  %GREEN%*%DARK_GREEN%*

Shows correctly on the ground (colored asterisk borders), but in the message log appears as:

ÿ*ÿ*  Sol ÿ12  ÿ*ÿ*

Root Cause

In MapNotify.cpp (~line 98), the trim regex only strips leading and trailing color codes:

regex trimName("^\s*(?:(?:\s*?)(ÿc[0123456789;:]))*\s*(.*?\S)\s*(?:ÿc[0123456789;:])*\s*$");
itemName = regex_replace(itemName, trimName, "$1$2");

This has two problems:

  1. Interior color codes are never stripped. The regex only matches leading/trailing ÿcX sequences. Color codes embedded within the item name text (e.g., between decorative asterisks and the item name) pass through untouched.

  2. MultiByteToWideChar mangles the escape byte. When the name is converted from Windows-1252 to Unicode, the 0xFF color escape byte becomes U+00FF (ÿ), which the message log text renderer does not recognize as a color escape. Every surviving interior ÿcX sequence renders as a visible ÿ glyph.

Suggested Fix

Replace the current leading/trailing-only trim with a global strip of all color codes from the notification text:

// Strip ALL color codes from notification text
std::regex colorCodes("\xFFc[0-9;:\x01-\x1F]");
itemName = std::regex_replace(itemName, colorCodes, "");

Note: the character class [\x01-\x1F] covers the Glide-mode control-character color codes (\x02, \x06, \x07, \x09, \x0C) used by ReplaceGlideDependentColor. The existing ItemDisplay.cpp length-calculation regex at line ~1791 already uses this broader class:

std::regex color_reg("ÿc[0-9;:\x01-\x1F]", std::regex_constants::ECMAScript);

This would strip all color formatting from notification text while leaving ground labels completely unaffected (they use the original name string, not the notification-processed one).

Reproduction

  1. Use any loot filter with color codes in item display rules (e.g., %GREEN%, %DARK_GREEN%, %PURPLE%)
  2. Enable Item Drop Notifications: True and/or Item Close Notifications: True in ProjectDiablo.cfg
  3. Drop or walk near any item whose filter rule embeds color codes in the display name
  4. Observe ÿ characters in the message log notification text

Environment

  • Project Diablo 2 (Season of Ennui / Hell Unleashed)
  • Non-Glide renderer (D2GL)
  • Filter: Kassahi-HiimMark S12 Build #178 (affects any filter using color codes in display names)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions