#### Brief overview of PR changes/additions
Saving a map at format <= 19 was leaking internal `system.fallback_*`
keys into the live map's user-visible userData, permanently. A format-19
save polluted room userData; a save at format < 19 tainted map userData
forever.
- The first commit serialises a locally-augmented copy, so saves never
mutate the live map. Old-format **file** output stays byte-identical, so
older Mudlets still receive their compatibility keys.
- The second commit strips stale leaked keys on format >= 19 loads, so
already-tainted maps self-clean.
#### Motivation for adding to Mudlet
Users' maps were silently accumulating internal keys they never set, and
those keys survived across save/load cycles. This stops new pollution
and cleans up existing damage.
#### Other info (issues closed, discussion etc)
Stacked on top of #9468 (base branch `add-persistence-roundtrip-tests`);
GitHub will auto-retarget to `development` once that PR merges. Please
merge after #9468. These are the two bugs the round-trip tests caught,
so this PR also flips their `QEXPECT_FAIL` markers to hard assertions.
Human build/test pending; DCO sign-off to be added at squash time.
https://github.com/user-attachments/assets/3931edb7-4daf-4277-bac4-0c6680d5bfe3
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Remove unnecessary else/else-if after return, break, continue, and throw
statements - and in places where fixing them is more trouble than its
worth, added NOLINT.
#### Motivation for adding to Mudlet
https://clang.llvm.org/extra/clang-tidy/checks/readability/else-after-return.html,
so it doesn't pop up in PR reviews.
#### Other info (issues closed, discussion etc)
---------
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
The map audit stripped exit locks from any direction without a real
exit, so locks set on stub exits never survived a save/load cycle. Keep
locks on stubs (including exits the audit itself converts to stubs) and
only remove them when there is neither an exit nor a stub. Also
round-trip stub locks through the JSON map format.
#### Motivation for adding to Mudlet
Follow-up to #9352
#### Other info (issues closed, discussion etc)
#### Brief overview of PR changes/additions
Fixes a use-after-free in `TRoom::setArea` (`src/TRoom.cpp`).
The function held a file-local `static QSet<TArea*> dirtyAreas` that
accumulated raw area pointers across calls when
`deferAreaRecalculations=true` and flushed them via `pArea->clean()` on
the next non-deferred call. If a `TArea` got freed in between
(`TRoomDB::clearMapDB()` → `deleteMap()`, profile close, map reload) the
pointers dangled and the next flush crashed in
`TArea::determineAreaExits()` while iterating the freed area's `rooms`
`QSet<int>`.
The fix switches the static set to `QSet<int> dirtyAreaIds`, re-resolves
each `TArea*` via `mpRoomDB->getArea(aid)` right before `clean()`
(silently skipping IDs that no longer exist), and swaps the set out
before iterating so reentrant `setArea` calls from inside
`clean()`/`determineAreaExits()` (e.g. via Lua event handlers) don't
mutate the container being walked.
#### Motivation for adding to Mudlet
Real-world crash on Mudlet 4.20.1 (macOS arm64, Qt 6.9):
```
EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS at 0x7080000008f50019
Thread 0 Crashed (com.apple.main-thread):
QHashPrivate::Span<Node<int, QHashDummyValue>>::hasNode
QSet<int>::constBegin
TArea::determineAreaExits (+48)
TArea::clean (+44)
TRoom::setArea(int, bool) (+924)
TMap::setRoomArea(int, int, bool)
TLuaInterpreter::setRoomArea
TLuaInterpreter::callEventHandler
Host::raiseEvent
TLuaInterpreter::parseJSON
cTelnet::setGMCPVariables
…
```
##### Deterministic reproduction
Paste into the Lua input line of any Mudlet profile (no MUD connection
required). Prefix with `lua ` if running directly from the input line.
```lua
-- Mudlet 4.20.1 setRoomArea use-after-free repro.
-- Before patch: process crashes in the final setRoomArea (TArea::determineAreaExits).
-- After patch: prints "repro finished without crash".
local function banner(s) echo("\n=== " .. s .. " ===\n") end
banner("Step 1: seed static dirtyAreas with TArea* for areas that will be freed")
-- Lua addRoom() calls TMap::setRoomArea(..., defer=true) with no matching flush,
-- so each call stashes a TArea* in the file-local static in TRoom::setArea.
local seedID = addAreaName("repro_Seed")
for i = 19001, 19010 do addRoom(i, seedID) end
banner("Step 2: deleteMap() - frees every TArea, static set now holds dangling pointers")
deleteMap()
banner("Step 3: create a fresh area + rooms (more entries accumulate in the static set)")
local freshID = addAreaName("repro_Fresh")
for i = 20001, 20005 do addRoom(i, freshID) end
banner("Step 4: single-room setRoomArea triggers defer=false flush -> iterates stale pointers")
local otherID = addAreaName("repro_Other")
setRoomArea(20001, otherID) -- boom on buggy builds
banner("repro finished without crash")
```
#### Other info (issues closed, discussion etc)
- The Lua `addRoom` binding (`TLuaInterpreterMapper.cpp:585`) always
calls `setRoomArea(..., defer=true)` with no matching flush, which is
what seeds the static set for later crashes. This PR only fixes the UAF
— the deferred-entries-leak-across-calls issue is a separate
architectural concern (the static also leaks between `TMap` instances in
multi-profile setups). Natural follow-up: move the dirty set onto
`TRoomDB` as a member with an explicit `flushDirtyAreas()` method, call
it from `TRoomDB::clearMapDB()` and from Lua bindings that batch edits,
and share the implementation with `T2DMap.cpp` /
`RoomMoveDragHandler.cpp` which already use the ID-based pattern
locally.
- No behaviour change for healthy call sequences: IDs resolve to the
same `TArea*` they would have been.
#### Brief overview of PR changes/additions
Revise the text of some map related error messages that get shown in the
Editor's error window. Including marking one of them for translation
when it wasn't before. Also make translatable the `"[MAP ERROR:] "` text
prepended to such texts and put in a space that was missing in the
Engineering English for that.
#### Motivation for adding to Mudlet
Better constructed (and more localised) map error messages.
#### Other info (issues closed, discussion etc)
`(void) TMap::logError(const QString& msg)` uses the
`TConsole::print(const QString&, const QColor, const QColor)` method to
put error messages into the "Errors" window in the editor and that is
also used in other places to insert other messages however many of them
are constructed from fragments of text in different colours such that
some parts are NOT put through the translation system but others are -
and that isn't even consistent for different messages in the same form.
Whilst it might look colourful and pretty - it makes things virtually
impossible to translate them properly IMHO.
IIRC it is considered that text to be translated should not be broken up
into anything less than whole sentences.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
#### Brief overview of PR changes/additions
Adds a fall-back mechanism to store the hidden room detail in binary map
formats less than 22.
#### Motivation for adding to Mudlet
Improve the handling of the newly added ability to hide rooms.
#### Other info (issues closed, discussion etc)
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Zooka <136661366+ZookaOnGit@users.noreply.github.com>
#### Brief overview of PR changes/additions
Checks for the `hidden` flag of a room to actually be changed before
flagging the map as needed to be resaved.
#### Motivation for adding to Mudlet
Eliminate pointless saves of a map.
#### Other info (issues closed, discussion etc)
Split off from #8930 to reduced the cognative load for reviewers.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Brief overview of PR changes/additions
- Remove duplicate `roomRemapping.value(exitRoomId)` line in
`TRoom::auditExit()` that caused the already-remapped exit ID to be
looked up a second time, returning 0 and silently destroying the exit
#### Motivation for adding to Mudlet
Maps loaded from older formats with negative room IDs had their exits
silently corrupted to point nowhere, losing connections between rooms.
#### Other info (issues closed, discussion etc)
Bug has existed since 2017 (commit f2aa9d3786) — a merge artifact that
duplicated the remapping line. Validated with a functional test that
confirmed exits were corrupted to 0 before the fix and correctly
remapped after.
**Test case:** Load a map file containing rooms with negative IDs that
have exits pointing to other negative-ID rooms. After loading, verify
the exits point to the correct remapped positive IDs rather than being
lost.
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add hidden rooms as a feature, so the mapper can be aware of a room but
not necessarily draw it.
#### Motivation for adding to Mudlet
Closes#783
#### Other info (issues closed, discussion etc)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Zooka <136661366+ZookaOnGit@users.noreply.github.com>
#### Brief overview of PR changes/additions
Ran clang-format on all 134 CPP files in src/ using the project's
.clang-format config
#### Motivation for adding to Mudlet
Ensures consistent code formatting across the codebase.
#### Other info (issues closed, discussion etc)
None
**Test case:** Build the project and verify it compiles successfully.
#### Brief overview of PR changes/additions
Adds per-room border color and thickness settings for the 2D mapper.
Rooms can now have custom borders to visually distinguish them (e.g.,
indoor vs outdoor).
New Lua functions:
- `setRoomBorderColor(roomID, r, g, b[, a])` / `getRoomBorderColor()` /
`clearRoomBorderColor()`
- `setRoomBorderThickness(roomID, thickness)` /
`getRoomBorderThickness()` / `clearRoomBorderThickness()`
UI controls added to the room properties dialog.
#### Motivation for adding to Mudlet
[User
request](https://discord.com/channels/283581582550237184/792073945922142259/1457314371184365569)
to visually distinguish room types on maps, previously only possible in
CMUD.
#### Other info (issues closed, discussion etc)
**Test case:**
1. Open a map with rooms
2. Run: `setRoomBorderColor(1, 255, 0, 0)` and
`setRoomBorderThickness(1, 3)`
3. Room 1 should display with a thick red border
4. Run: `clearRoomBorderColor(1)` - border returns to global default
color
5. Right-click a room → Properties → Border section allows setting
color/thickness via UI
https://github.com/user-attachments/assets/1261b84f-0ba1-4719-9f56-1870ba51e4d1
I looked into bumping the map format to 21 and storing the data
natively, not using userdata - but then my map grew from 7.9MB to 8.7MB
without me having changed any room's data at all! Just the extra
structures, now empty, per room, added this might weight. In the end,
going with a "sparse" storage solution of using room userdata is more
space-efficient and less of an issue for backwards compatibility.
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce Mudlet build times
#### Motivation for adding to Mudlet
Address #6765, and give developers a better experience.
#### Other info (issues closed, discussion etc)
Benchmark Results
=== Testing: development (before) (development) ===
Run 1 of 3...
Time: 226.071397436s
Run 2 of 3...
Time: 216.059263209s
Run 3 of 3...
Time: 221.592760908s
=== Testing: PR #8403 (after) (pr-8403) ===
Run 1 of 3...
Time: 191.112400957s
Run 2 of 3...
Time: 193.975717783s
Run 3 of 3...
Time: 196.569316252s
[benchmark-mudlet-build.sh](https://github.com/user-attachments/files/24466717/benchmark-mudlet-build.sh)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
New Lua API: setRoomBorderColor, getRoomBorderColor, clearRoomBorderColor,
setRoomBorderThickness, getRoomBorderThickness, clearRoomBorderThickness
Adds UI controls in room properties dialog. Rooms without custom
borders fall back to global settings. Map format version bumped to 21.
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Remove unnecessary else blocks following return statements throughout
the codebase.
#### Motivation for adding to Mudlet
Better code readability
#### Other info (issues closed, discussion etc)
Other anti patterns are visible in this PR thanks to this, but let's
keep this PR focused on one pattern only.
---------
Co-authored-by: Claude <noreply@anthropic.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Consolidated 14 sets of duplicate warning/info messages into single
versions in map audit messages
#### Motivation for adding to Mudlet
Fix#1970
#### Other info (issues closed, discussion etc)
Co-authored-by: Claude <noreply@anthropic.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Remove support for leak detection using MSVC - this functionality hasn't
been in use in a decade, and we're switching to to using
[LeakSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer)
instead.
#### Motivation for adding to Mudlet
Cleaner code.
#### Other info (issues closed, discussion etc)
---------
Co-authored-by: Claude <noreply@anthropic.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Fixed maps not being removed from memory when profile is closed, which
would increase memory use if you opened maps & profiles and then closed
them while keeping Mudlet running. Now, closing a profile will properly
remove the map data from memory as well.
#### Motivation for adding to Mudlet
Removes a memory leak, fixes#5897.
#### Other info (issues closed, discussion etc)
Unlike other fixes which significantly slowed down profile shutdown,
this one is instant.
In addition to this, loading another map while playing is also quicker!
Memory leak verified gone by looking at the AddressSanitizer.
/claim #5897
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Zooka <136661366+ZookaOnGit@users.noreply.github.com>
#### Brief overview of PR changes/additions
No functional change, just internal refactoring
#### Motivation for adding to Mudlet
Easier to read, clearer style
#### Other info (issues closed, discussion etc)
#### Brief overview of PR changes/additions
Revised codebase to compile with latest Qt version which modified the
QChar constructors such that some casts are needed now to keep things
working. This also revealed a bug in:
`(void) TRoom::auditExits(const QHash<int, int>)` where there was a
missing `10` as a number base argument which was silently being
mishandled in prior versions of Qt.
#### Motivation for adding to Mudlet
Immediately needed for Windows x64 builds but will eventually be needed
for all builds to compile.
#### Other info (issues closed, discussion etc)
Has only come to notice in the last 24 hours but is **HIGH** priority/
urgent.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Apply fixes from clazy - mostly add const and references.
#### Motivation for adding to Mudlet
Better code quality and a potentially quicker Mudlet!
#### Other info (issues closed, discussion etc)
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
#### Summary of PR Changes/Additions
Makes the coordinate members of the `TRoom` class private so that access
to them can be tracked via methods to set and get them.
#### Motivation for Adding to Mudlet
This is so that the setters can then subsequently include any extra code
that needs to be aware when the room is moved. I intend to improve the
detection of rooms being placed in the same position but realised this
would be a good preliminary step.
#### Additional Information (related issues, discussions, etc.)
Removes some dead code setting but not using `(int) quads` and `(int)
verts` in `(void) GLWidget::paintGL()`
Also using the mouse to drag and thus move selected rooms when those
rooms were on different levels would squash them all down to be on the
same z-coordinate as the "highlighted centre of the selection" room.
This is not as helpful it might seem and instead increased the
likelihood of causing room collisions - so now each room will retain
it's z coordinate if it is not on the same level as the centre of the
multiple room selection.
Also move code that likely needs to be run whenever rooms are
added/removed/moved within an area to a common block of code (`(void)
TArea::clean()`) to help keep things DRY. I intend to put code to update
a per area record of rooms that are in the same place within that block
in the future - so that the record can be reused without having to be
repeatedly recalculated, especially in the paint event for the 2D
mapper.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Speed up bulk room creation so people can make million-map rooms
quickly:
* addRoom now accepts the area to place the room in right away
* setRoomArea accepts an optional table of rooms instead of one room to
work in bulk
* setRoomArea will no longer update the mapper view automatically - but
this is fixed by https://github.com/Mudlet/Mudlet/pull/7187
#### Motivation for adding to Mudlet
https://discord.com/channels/283581582550237184/1215109133150199889/1217359192835358741
#### Other info (issues closed, discussion etc)
Somewhere along the line we forgot that
https://wiki.mudlet.org/w/Manual:Mapper_Functions#updateMap needs to be
called from scripts to update the map for this very reason - performance
#### Brief overview of PR changes/additions
This PR tries to put all `const`s before the type (class).
#### Motivation for adding to Mudlet
There is a mix of positioning of `const`s where it is used to indicate
that a variable is not to be modified by program code, we tend to put it
before the type but a prior PR (which looks to have been done with an
automated tool) has resulted in a mix of cases some with the const
adjacent to the variable. This lack of consistency can be confusing.
#### Other info (issues closed, discussion etc)
It looks like this came about in #6843.
This will upset the Danger detector because of the number of files
modified but it should be fairly straightforward to review.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Make it so you can do `QDebug() << myRoom` and the room name, area, and
exits will get printed to debug output
#### Motivation for adding to Mudlet
Desired by developer
https://github.com/Mudlet/Mudlet/pull/6767#discussion_r1186354273
#### Other info (issues closed, discussion etc)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Mark read-only variables as const - that is, not intended to change
after they've been declared
#### Motivation for adding to Mudlet
So we don't change them by accident later on, and also to clearly state
intentions for the variables
#### Other info (issues closed, discussion etc)
This is also recommended by the [C++ Core
Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es25-declare-an-object-const-or-constexpr-unless-you-want-to-modify-its-value-later-on)
These will last only for the duration of a session and will NOT be saved
into a binary or JSON format map file later. As far as possible the
creation, modification or deletion of such a label will also NOT cause
Mudlets's map "auto-save" functionality to be activated.
This should provide an alternative way to work around and close#6265.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
#### Brief overview of PR changes/additions
Refactored some code, removed whitespace from texts for translation.
#### Motivation for adding to Mudlet
Translators don't need to worry matching a number of empty lines at the
edge of a translated text.
#### Other info (issues closed, discussion etc)
Fix#3466
#### Brief overview of PR changes/additions
Add a map autosave feature to prevent large losses of work when Mudlet/computer shut down unexpectedly.
#### Motivation for adding to Mudlet
Better player experience.
#### Other info (issues closed, discussion etc)
Closes https://github.com/Mudlet/Mudlet/issues/2121.
Works just like profile autosave which has been very successful since its introduction - autosaves the map every 2min if any changes have been done to it. Hopefully this won't be an issue for enormous maps - if it is, we'll need to look into making the save process hog the main thread less.
Adding this revealed that the internal mapper API is messy - ideally the 'mDirtyMap' flag should never be set within TLuaInterpreter.cpp!
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
This PR will also allow colors for open/closed/locked doors to be
customised in the future (by adjusting the new `T2DMap` `QColor`
members: `mOpenDoorColor`, `mClosedDoorColor` and `mLockedDoorColor`.
Moved the `QMap<int, QPoint> mAreaExitsList` member out of the class header
- it is now a local `areaExitsList` value held in the `paintEvent(...)`
method and passed by reference to a couple of paint helper methods.
Revise the code that painted exit stubs as the formulas being used to work
out the inner and outer points on the line were wrong - and as they were
dependent on the room size the stubs changed as the room size did. Since
we may now be painting a door marker on them it is easier if the length is
constant and does not depend on the room size.
Since we are now able to show door markings on custom exit lines (including
on special exits) and stub exits the tool-tips in the room exits control
panel is updated to now reflect this.
This will close#499 and close#668 and address an issue that Fuligin
raised in the Discord # help channel on 2021/01/08 .
BugFix - revise handling of area exits with doors:
This actually doubles the amount that area exits stick out from the
starting room and revises the drawing code so that it is not so dependent
on the room size (which modified the `exitWidth` local that the code was
using). The particular detail that required this commit was that the way
that the underlying line was drawn that was used to derive the door symbol
from had the start and end points the opposite way around to that which I
had developed the code for!
Whilst cleaning things up I spotted that there was a redundant conversion
from a `QPointF` to a `QPoint` and then back to a `QPointF` when handling
the area exit click location - that is used to record when an area exit is
(double) clicked upon to initiate a speedwalk to the room in the adjacent
area.
Revised - provide "pair of doors" representation for doors on 2D Map
As requested during review.
Revised - tweak some aspects of the door markings
Make them a bit (150%) thicker and a little longer.
Revised - use QLineF/QPointF instead of QLine/QPoint to pacify clang-tidy Bot
It seemed to be unhappy about "narrowing conversions" of `double`s to
`int`s. when a local line and point with integer coordinates are created
- and which are then used to create others which have floating point
values.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: try and make connectExitStub(...) work as per the API
This PR should enable connectExitStub(...) to work as close to the existing
published API as possible:
* connectExitStub((integer) fromRoomID, (integer)toRoomID,
(integer or string) direction)
where direction is the initial(s) or full, lower-case, un-hypenated ENGLISH
word for one of the 12 normal exit directions - this will make a two way
exit between the given direction of the fromRoomID room to the toRoomID
room AND the corresponding reverse direction exit from the toRoomID room.
The rooms need not be the same Area but they must BOTH have stub exits in
the required direction.
* `connectExitStub((integer) fromRoomID, (integer) toRoomID)` - this will
make a two way exit between the fromRoomID room to the toRoomID room AND
the corresponding reverse direction exit from the toRoomID room. The rooms
need not be the same Area but the fromRoomID must have only ONE stub exit
with an opposite (reverse) direction one in the toRoomID one - either room
can have other stub exits. Should there be more than one pair of stub exits
a nil + error message will be produced listing the choices for the
direction that can be passed to the three argument function call to make
the exits wanted.
* `connectExitStub((integer) fromRoomID, (integer or string) dirction)`
- this will make a two way exit between the stub exit in the fromRoomID
room to the NEAREST other room IN THE SAME AREA which has a stub exit in
the reverse direction and which lies in the correct relative position
(except for the `in`/`out` directions where this is not relevant). Should
the direction be given as an integer in the range 1 to 12 this will be
rejected (via a nil + error message) because it is ambiguous then whether
the number represents a direction or a toRoomID. Potentially unlike the
prior code, this version properly detects whether a string or number is
supplied as the direction argument.
Also:
* to allow the reporting of the direction as a number and a string in error
messages the `(QString) TRoom::dirCodeToString(const int)` method has been
made `static` so that it can be used in the `TLuaInterpreter` class.
* as indirectly mentioned above
`(int) TLuaInterpreter::dirToNumber(lua_State*, int)` has been revised to
check for a string or integer argument being examined - the prior code
may not work as anticipated because it used `lua_isxxxx(...)` functions
which can coerce the value they are dealing with (a number can be coerced
into a string) - which messes with the logic.
* in places in the revised methods the integer constant values have been
replaced with the `DIR_XXXXX` values defined in the `TRoom` class header
file.
* to simplify (!) the coding the three different forms of the Lua API are
implemented in three separate `(QString) TMap::connectExitStubByXxxx(...)
methods which collectively replace the original
`(void) TMap::connectExitStub(...)` one. They are responsible for
generating most of the Lua API error messages for this function and they
indicate success by returning an empty string.
This should close#2386.
Revise: add a suggestion to the user on how to proceed on a message
Signed-off by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
This should close#5295 by providing the code that is missing from
`(void) TRoom::readJsonSymbol(...)` - I think it was omitted because the
person who coded the ability to colourise the room symbol text was working
on that whilst I was coding the JSON map handling.
It also fixes:
* a Qt advisory (warning) to use a const reference when using a C++ `for`
loop to iterate through a QJsonArray of custom environements (colors).
* a failure to update the player room indicator when it is changed by
loading a Json Map file.
* a comment in `(void) Host::getPlayerRoomStyleDetails(...)` that is
redundant since we previously removed the mutex for accessors.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
A coding error meant the current file formats that retained the previous
storage of the special exit lock status as a `1` or `0` prefix on the
name/command for the special exit was not being corrected inserted into the
recently added separate container to store the lock status of special
exits - this meant they were effectively lost.
This will close#4999.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This is so that a crowd sourced map might be edited in a collaborative
manner. The first stage is to make sufficient of the entire map details
be exported/imported in a modular (by area) fashion.
Include Lua functions `exportJsonMap(pathFileName)` and
`importJsonMap(pathFileName)` to perform the whole map export and
import functions.
Also, rename `(QMultiMap<int, QPair<int, int>>) TArea::exits` to:
`TArea::mAreaExits` because the old name was such a common word in our
source code it was hard to find the uses of this member.
This format has been constructed so as to not mention the most common, or
default values for some items - so as to minimise details that have to be
included on the basis they can be assumed when reconstructing them on the
other end.
On the other hand the whole file is compressible so for storage (but not for
diff/git work) archiving / compressing the file is recommended! For
instance a binary map file I have is 18.6MB which produced a 25.8MB JSON
file which I was able to compress down to 2.9MB - obviously this is *very*
content dependent, so other's Miles-May-Vary...
As the export process is not that fast include a progress dialogue that
shows how many areas, map labels and rooms have been processed into the
JSON format. For a 20K room map with 40 odd areas and around 800 map labels
(which are awkward to convert to a text-like form) this can take 30
seconds on my 1.8GHz 4 Core PC!
CodeFactor had a recommendation about a constant that I was using to
set the dimension of a `char[]` (array) - it felt a compile time `constexpr` was
a better thing to use.
Revised to make Cancel button work in big areas:
Although the existing code would abort at the end of an area, for some
humongous maps with a few very large areas it is also a good idea to check
for the cancel button being pressed each time the progress bar is updated.
Renamed `(QMap<int, int>) TMap::envColors` to `TMap::mEnvColors`
and `(QMap<int, QColor>) Tmap::customEnvColors` to `TMap::mCustomEnvColors`
so that it is clearer that they are members of the `TMap` class.
Add alpha component to end of list of (now four) 0 to 255 integer values
returned by `getCustomEnvColorTable()` - as the corresponding setter does
allow one to be provided.
Move initialisers for TMap, TRoomDB, TRoom and TArea to header file where
possible. As per Issue #4578.
Move the default and unnamed area names from TRoomDB to TMap - as it made
setting them up easier (though one of them does need to be initialised
before the normal TRoomDB instance associated with the TMap is itself
initialised. This meant putting these private members near the top of the
header file even though we normally put private ones down the bottom.
Refactor: move JSON colour writing/reading code from TArea/TRoom to TMap
The code is common to all three classes so can be shared. At the same time
make it explicit in the key as to whether there is an alpha component so
the colour is a 24Bit opaque one or a 32Bit one with transparency.
Revise: peer-review items and other tweaks
Note that this revises the format version to be 1.000 (ready for release)
so, although the format has not changed, any recent files produced during
evaluation will need to be hand edited to change the line:
"formatVersion": 0.003,
to:
"formatVersion": 1.000,
in order to read them now.
Switch to "range based" for-loops for some of the JSON additions.
Fixup: ensure partially built new TRoomDB is destroyed if reading aborted
Not doing this would cause a resource leak if the abort button was clicked
during importation of a Json map file.
Revise: disable writing out Room highlighting details
It has been pointed out that the binary map format does not save the room
highlighting details either - so replicate that behaviour for the moment.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
Retitled from:
"BugFix: correctly evaluate room m(in|ax)(x|y) values in all cases"
We previously set them all to be 0.0 when there is no custom lines but
technically, since they are supposed to be extremes of the room and it's
custom exit lines they should be initialised to the room's own coordinates.
Not doing this meant that in some cases they were being used but they
did not hold sensible values.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* add way to color room characters
* accept new translations
* fix qmake build
* addSymbolToPixmapCache improve
* cr corrections
* Modernize design
* remove accidental hints
* remove not needed variable
* minor fixes
* room not exists will not throw error in room char color functions
* remove properties with auto suggestion
* remove not neede assignment
* prevent spawning multiple symbol char dialogs at once
* fix room symbol selection issues
Co-authored-by: Piotr Wilczynski <piotr.wilczynski@bisnode.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
Since #4526 was merged into the development branch 4 days ago reading of
old maps (formats before 8) built from Mudlet prior to
8e0f9dba7f (merged on 2011/01/24) will chop
the first character from the name/command of every special exit...
This was caused by a copy-paste error in the code that converted the older
style of storing the special exits and their locked status that was used
prior to that PR.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This will enable some simplification of code.
During development it became clear that the Lua API `getSpecialExits(...)`
function was a bit defective and did not behave as documented in the Wiki:
it was only showing one special exit at random that led to a particular
exit room in the (admittedly unlikely) event of there being more than one.
It also used the special exit name/command as a key in a sub-table with the
special exit lock status of that exit as a "0" or "1" string value.
This PR repairs the above function by adding an optional boolean argument
that:
* if omitted or false, replicates the previous behaviour but if there is
more than one special exit to the same room it always picks one with the
lowest exit weight that is unlocked or if there is none it picks one with
the lowest weight that is locked. This will be compatible with old scripts.
* if true, returns ALL the exits in the sub-table that lead to the
particular room id that is the key in the main table, again those exit
commands are the keys with a value being a "0" or "1" depending on whether
the exit is unlocked or locked respectively.
For the record, the original implementation of special exits was introduced
in commit:
e0ba28d472 and that was supported by the
addition of map format version 6. Locking of Special Exits was added in
somewhere between:
19f8563b47
and:
070912ea7c
(which revised the map format to 11).
Also:
* use a couple of `const QString`s as templates in the `dlgRoomExit.cpp`
file to remove 95 duplicated `QStringLiterals` from the read-only code
segment of the compile object file.
* add `const` where relevant to some `TRoom` methods.
* work harder to ensure than when a special exit is deleted from a `TRoom`
then elements that were related to it are also cleaned up.
* prepare to save the new `TRoom` data structures in the next Mudlet map
file format (21) when it is enabled. In the meantime a workaround to
convert the in-game data to the current format is utilised for all current
map formats Mudlet can currently use. This will impact a little on the
save/loading speeds but that is the cost of simplifying the code that works
with special exits elsewhere in the application.
* revise and extend the error handling for the room special exit functions
generally so that they confirm to our throwing an error on argument type
issue (and reporting the faulty argument) and returning `nil` plus an error
message for a run-time value problem.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
This was causing messages of the form:
"QRegularExpressionPrivate::doMatch(): called on an invalid
QRegularExpression object" whenever a colour trigger was saved. It was due
to an error in the regular expression defined in:
QStringList XMLexport::remapAnsiToColorNumber(const QStringList&,
const QList<int>&)
Also remove unneeded #include <QRegularExpression> in classes that do
not need it.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
The `insertMulti` method is implicit on a multi-map and is deprecated now.
(As is using it on `QMap`s as well - those should be converted TO
`QMultiMaps` - and the same for `QHash`/`QMultiHash`es!!!)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Also removes unused:
* (bool) Host::mAutoReconnect
* (QString) Host::mBufferIncomingData
* (QPushButton*) Host::uninstallButton
* (QListWidget*) Host::packageList
* (QListWidget*) Host::moduleList
* (QPushButton*) Host::moduleUninstallButton
* (QPushButton*) Host::moduleInstallButton
* (bool) TConsole::mWindowIsHidden
Also add some initialisers, particularly for pointers and booleans.
I have spotted in a lot of the new TMxpXxx classes that:
* the include guards are not right at the top of the file
* private members and methods are declared first in the header files rather
than the public ones which are odd as the latter are more likely to be of
interest to anyone wishing to examine the details of the API that the
latter document
* in header files that include another header file the inclusion of that
file is done twice - once before and once after the class members and
methods are documented. Given the use of inclusion guards the second is
pointless - and if there were not such guards the second inclusion would
(I believe) break things...
I have only included fixing this in the TMxpSendTagHandler class in this
PR but there are others that also need the above matters attended to...
For me this reduces the warning count from 662 to 502.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Using `Q_UNUSED` will silence the warnings that CMake gives us, though
we have disabled them for ages in the QMake build process.
Also remove some unused methods and variables.
Unlike the previous attempt in PR #4383 that had to be reverted by PR #4404
this does NOT remove a pair of methods from the `TTreeWidget` class that
did not seem to be being called - it turns out that they override methods
in the base `QTreeWidget` class and as such they will be called by Qt
library code when certain things happen to the class.
This reduces the warnings count (if they are shown by the compiler) from a
starting point of about 2718 down to around 696.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>