Commit graph

4 commits

Author SHA1 Message Date
Mike Conley
a7fbe7f9d3
fix: clickable links could show the wrong colours and styling after heavy output (#9406)
#### Brief overview of PR changes/additions
- Clear a recycled link id's stale styling and selection-group index
entry in `TLinkStore::addLinks()` when the id counter wraps around
- Add unit test `testStylingClearedOnIdReuse` covering the wraparound
case

#### Motivation for adding to Mudlet
When a game has produced more than 20,000 clickable links, recycled link
ids kept the previous link's OSC 8 styling (colours, decorations,
selection group) until the new link happened to set its own - so plain
MXP/echoLink links could render with another link's styling and respond
to the wrong selection group.

#### Other info (issues closed, discussion etc)
Closes #9404. Mirrors the bookkeeping `removeLinkById()` already
performs; `addLinks()` previously cleaned up only the expire-name
mapping on id reuse.

**Test case:** `TLinkStoreTest` covers it (new test fails without the
fix). Manually: on a profile with a small link store this needs 20k+
links to trigger; the unit test exercises the wraparound directly.

---------

Signed-off-by: Michael Conley <sousesider@gmail.com>
2026-07-12 20:45:24 +02:00
Vadim Peretokin
ef36bf136f
Infrastructure: speed up compilation of Mudlet by 25% (#9021)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Before: Each of the 16 unit test executables compiled its own copy of
the source files it needed. For example, 10 MXP tests each compiled the
same TMxpTagParser.cpp, MxpTag.cpp, TEntityResolver.cpp, etc- now they
get compiled just once.
After: The source files are compiled once into mudlet_core (which was
already being built), and each test just links against that library.
#### Motivation for adding to Mudlet
1. Faster test builds - source files aren't recompiled per-test. The 16
test executables now only need to compile their own single .cpp test
file and link.
2. Tests exercise the real code - previously, tests could diverge from
the production build. The LinkStore_Test define was a concrete example:
it compiled a stripped-down TLinkStore without styling support
or Lua reference freeing. Now the test links against the exact same
compiled code that ships in the application.
3. No maintenance burden for test build config - previously, adding a
new compile flag, dependency, or include path to src/CMakeLists.txt
required mirroring it in test/CMakeLists.txt. Now the tests inherit
   everything transitively through the library target.
4. Simpler CMake - 114 lines reduced to 42. Adding a new test is one
line (add the name to the list) instead of writing a custom
add_executable with all its source file dependencies.
#### Other info (issues closed, discussion etc)
Compiling Mudlet plus test before - 120s, after - 90s.

Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2026-03-09 09:24:52 +01:00
Mike Conley
b2660d1da5
Improve: Memory management for console hyperlinks (#8725)
#### Brief overview of PR changes/additions

Implements automatic cleanup of hyperlink data when links are no longer
visible in console windows. When text containing links (created via
`echoLink()`, `insertLink()`, or OSC 8 sequences) scrolls out of view or
windows are cleared, the associated link data is now automatically
removed.

#### Motivation for adding to Mudlet

While the existing link storage system worked correctly, it retained
link data indefinitely even after the text was no longer visible. This
change adopts a more efficient approach by tracking which links are
currently referenced and cleaning up unreferenced data during normal
buffer maintenance operations. This is particularly beneficial for
long-running sessions with heavy link usage.

#### Other info (issues closed, discussion etc)

- Adds reference tracking to identify active links in buffer content
- Cleanup occurs automatically during `clearWindow()` and buffer shrink
operations
- Includes comprehensive unit tests covering selective cleanup scenarios
- All existing tests pass
- Follows Qt6/C++20 best practices for memory management
2026-01-04 17:34:57 +01:00
Gustavo Sousa
102491a743
Refactoring/reimplementation of MXP support (#3625)
Refactoring/reimplementation of MXP protocol
        Extracts MXP support from TBuffer
        Separates input parsing from protocol processing: input is parsed into MxpTag objects by the MxpNodeBuilder and are passed to be handled by the MxpTagProcessor
        Class hierarchy of MxpTagHandler for implementing support for each tag: allows for a clear separation of the implementation of each tag and makes it easier for adding support for new tags
        Defines a clear interface (MxpClient) separating the MXP implementation from other parts of the code
        Solves some limitations of previous implementation such as supporting element definitions not only for<SEND> tags, interpolating named and positional attributes and interpolating &text; placeholder by tag content
        Includes support for COLOR tag
        Handles FONT, U, I, B, VAR and !ENTITY tags, but so far no defined behavior (can be implemented in MxpMudlet)
        Attributes that hold MXP state are now in the Host class to avoid needless copies when TBuffer is copied around
        Introduces QtTests for some of the classes
    Other refactorings intended to simplify TBuffer class, extracting responbilities that aren't directly related to the buffer mgmt
        Extracted TEncodingTable from TBuffer, this class is responsible for mapping encoding names to tables. It also removes some bloat from TBuffer.
        TLinkStore to manage links and associated hints to be displayed.
        TEntityResolver to map character entities, such as &gt; &#32; &#x20; to their associated string values; supports interpolating strings replacing the entity placeholders by their values
2020-05-03 19:09:42 +02:00