* add more information to return table from getMapLabel (colors and base64 encoded image)
* correct name of method
* correct method calls
* correct brace
* pass reference
* fix missing QBuffer
* const corrections
make base64EncodePixmap return QByteArray
Co-authored-by: Piotr Wilczynski <piotr.wilczynski@bisnode.com>
The map file format stuff won't take effect until the next map version is
enabled.
Remove unused:
* `(QPointF) TMapLabel::pointer` completely.
* `(QVector3D) TRoom::v` completely.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Eliminate a couple of empty functions.
Handle some warnings about some comparisions of signed verses unsigned
integers.
Use `(QList<T>) QSet<T>::values()` in favour of depricated
`(QList<T>) QSet<T>::toList()` .
Use a replacement for `QNetworkReply::error(...)` which has been deprecated
in Qt **5.15**.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Drop all locks.
Exception: The map import lock is actually necessary, but we're not
doing any multithreading *or* scoped unlocking here. Thus a simple
boolean flag works just as well.
* restore Discord::getDiscordUserDetails code
* ... and remove the locking.
* Map: Add an option to show room names below their IDs.
This is a fairly straightforward extension.
TODO: use a separate font.
* basic support for a separate font for room names
* Use black room names on light background
* Room name display and font sizing fixes
Room name display is now independent of room number display.
The cut-off for the font size is lower (4 instead of 7).
Room names are scaled as if the number 88 would be printed in the room
box, which works for all practical purposes.
Font size discovery is now done in floating point, and by scaling with
factors 1.2 (up) and 1.05 (down) which is faster *and* looks way better.
* Don't show room names in grid mode
* Tweak font size calculation
Ensure that we start with a reasonable font size
* Added functions to get/set a room name's offset
float x/y, relative to the room rectangle (and in its units).
TODO: document in the wiki:
getRoomNameOffset(id)
setRoomNameOffset(id, x_offset, y_offset)
* Save file version updated to 21
Added:
* global: room name font + size adjustment
* per room: label offset
* remove LayoutDirection directives
* Re-sorted the grid layout items in ui/profile_prefs
* Fix room name placement
directly under the room's rectangle, no strange offset
* Add userdata flag "room.ui_showName" indicating whether to show room name
* Move room label position to userdata
* Cleanup
The flag whether to display room labels (both globally and per-room)
is now stored in userdata.
Reverted:
ad6d3 Re-sorted the grid layout items in ui/profile_prefs
76834 remove LayoutDirection directives
5d81e Save file version updated to 21
TODO: flipping the global flag crashes for no good reason.
* Crash workaround
Not inlining "setUserDataBool" triggers a double-free bug
(Debian amd64, Qt 5.14.2-3, gcc 10.2.0-9).
I'm investigating this; in the meantime, this patch should be an
acceptable workaround.
* Update src/mudlet-lua/lua/GUIUtils.lua
* Appease codefactor
* Hide showRoomNames checkbox if no room name infrastructure exists
as exhibited by map userData "room.ui_showName" not being present at all
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
Classed as "High Impact":
CID Type Detail
1492499 "Uninitialized scalar variable (UNINIT) "5. uninit_use: Using
uninitialized value error."
1485860 "No virtual destructor" "A1. dtor_in_derived:
Class `XMLimport` has a compiler-generated destructor. It is non-empty
because of its field `mpHost`. A pointer to class `XMLimport` is upcast to
class `QXmlStreamReader` which doesn't have a virtual destructor."
Classed as "Medium Impact":
1492834 "Uninitialized scalar field (UNINIT_CTOR)" "2. uninit_member:
Non-static class member `mIsEndTag` is not initialized in this constructor
nor in any functions that it calls.
4. uninit_member: Non-static class member `mIsEmptyTag` is not initialized
in this constructor nor in any functions that it calls.
6. uninit_member: Non-static class member `mReadingAttrValue` is not
initialized in this constructor nor in any functions that it calls.
8. uninit_member: Non-static class member `mOpeningQuote` is not
initialized in this constructor nor in any functions that it calls."
1488910 "Uninitialized scalar field (UNINIT_CTOR)" "2. uninit_member:
Non-static class member `mPlayerRoomStyle` is not initialized in this
constructor nor in any functions that it calls."
"4. uninit_member: Non-static class member
`mPlayerRoomOuterDiameterPercentage` is not initialized in this
constructor nor in any functions that it calls."
"6. uninit_member: Non-static class member
`mPlayerRoomInnerDiameterPercentage` is not initialized in this
constructor nor in any functions that it calls."
1478854 "Uninitialized pointer field (UNINIT_CTOR)" "4. uninit_member:
Non-static class member `mpOutOfBandDataIncomingCodec` is not initialized
in this constructor nor in any functions that it calls."
1468478 "Unchecked return value (CHECKED_RETURN)" "10. check_return:
Calling `luaL_loadstring` without checking return value (as is done
elsewhere 17 out of 21 times)."
1468477 "Unchecked return value (CHECKED_RETURN)" "14. check_return:
Calling `luaL_loadstring` without checking return value (as is done
elsewhere 17 out of 21 times)."
1468474 "Unchecked return value (CHECKED_RETURN)" "16. check_return:
Calling `luaL_loadstring` without checking return value (as is done
elsewhere 17 out of 21 times)." - x 2
1468468 "Logically dead code (DEADCODE)" "dead_error_line:
Execution cannot reach this statement: `return 1;`"
1415097 "Dereference null return value (NULL_RETURNS)" "8. dereference:
Dereferencing timer, which is known to be `nullptr`"
1415092 "Identical code for different branches (IDENTICAL_BRANCHES)"
"identical_branches: The same code is executed regardless of whether
`areaExit` is true, because the 'then' and 'else' branches are identical.
Should one of the branches be modified, or the entire 'if' statement
replaced?"
1415023 "Dereference null return value (NULL_RETURNS)" "26. dereference:
Dereferencing a pointer that might be `nullptr` `pR->name` when calling
`QString`.
1414989 "Explicit null dereferenced (FORWARD_NULL)" "81. var_deref_op:
Dereferencing null pointer
`this->originalExits.value(dirCode, TExit * const(NULL))`." x 11
1414977 "Logically dead code (DEADCODE)" "dead_error_line:
Execution cannot reach this statement: `return false;`."
Also removed unused:
* (int) cTelnet::curX & curY,
* (double) cTelnet::networkLatencyMin & networkLatencyMax
* (QMutex) TimerUnit::mTimerUnitLock
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Refactor: convert from Qt foreach to C++ range-based for loops
Refactor: add/remove spaces in function calls, conditionals & init. lists
Refactor: reorganise a pair of multi-conditions if/elseifs
Simplifies the conditions into a single four alternative
if/elseif/elseif/else, whilst it does mean some of the conditionally
executed lines have to be duplicated into some of the alternatives
it is a little clearer to deduce which lines are used by each alternative.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
The `QPainter::renderHint` of `QPainter::NonCosmeticDefaultPen` is obsolete
as default pens are now non-cosmetic implicitly.
`QLineF.intersect(...)` has been renamed to `QLineF.intersects(...)` in
Qt 5.14.
Since Qt 5.14, range constructors are available for Qt's generic
container classes and should be used in place of:
`QSet<T>::toList()` and `QList<T>::toSet()`
Since Qt 5.13, `QTreeWidget<T>::sortByColumn(int)` has been deprecated in
favour of `QTreeWidget<T>::sortByColumn(int, Qt::SortOrder)` although
checking back even to Qt 4.8 I cannot find the one argument case even
documented!?
Since Qt 5.11, `QFontMetrics::width(QChar)` has been deprecated in favour
of `QFontMetrics::horizontalAdvance(QChar)`.
From Qt 6.0, `QMediaContent::canonicalUrl()` will be deprecated - however
Qt 5.14 is already marking it as obsolete and recommends replacing it with
`QMediaContent::request().url()` which was introduce in that version.
Also remove our suppression of deprecation and other details in the QMake
project file - it was only hiding the above sort of issues from us...
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* When downloading a map (either via gmcp map request or via the download
option in preferences, ensure the map directory exists.
* Remove unneeded guard
* Load Mudlet maps from Client.Map as well
* Close dialog properly in Mudlet maps
* Invert wrong 'if' check
* Save downloaded map in correct format
Not always as XML
* Don't unlock mutex twice
* BugFix ameliorate Qt changes to binary formats for QDataStream
In other words - fix https://github.com/Mudlet/Mudlet/issues/3088 ...!
This forces the binary file format to be that which is used for Qt 5.12 if
the run-time version of the Qt libraries are Qt 5.13 or later. This is
needed to handle a change in the format that QFonts are saved/loaded in
a binary form in a QDataStream but it also clamps the binary format to
be equivalent to QDataStream::Qt_5_12 everywhere I could see it used so
that future Mudlet versions do not suffer further issues going forward when
Qt revise the QDataStream format for the classes it handles.
This should also close https://github.com/Mudlet/Mudlet/issues/785 !
NOTE: THIS WILL BREAK THINGS TEMPORARILY FOR USERS OF MUDLET VERSIONS AFTER
4.0.1 OR THOSE WHO HAVE MANUALLY SET THE FILE FORMAT ON THEIR MAP TO BE
VERSION 19 OR HIGHER AND HAVE MOVED BETWEEN A MUDLET USING A RUN-TIME QT
VERSION LESS THAN QT 5.13 AND ONE USING THAT OR LATER. IT WILL LIKELY CAUSE
EXISTING MAP FILE CONTENTS TO BECOME GARBAGE WHEN READ BY A MUDLET
VERSION INCLUDING THIS PULL-REQUEST - SO IT IS NECESSARY TO OPEN ANY WANTED
VERSION 19 OR LATER MAP FILES IN THE CURRENT (BUGGY) QT 5.13 OR LATER USING
MUDLET AND RESAVE IT IN MUDLET FILE FORMAT 18 BEFORE UPGRADING TO A MUDLET
WITH THIS PULL-REQUEST INCLUDED. ONCE THE MAP IS THEN LOADED IN THE NEWER
MUDLET IT CAN BE RESET TO THE LATEST MAP FORMAT - and we should avoid
similar Qt library change induced problems in the future.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This PR removes support for saving in the binary map file format of Mudlet
2.1 - i.e. format **16** (retaining the ability to read it) and adjusts the
format for new map files to be **20** by default - up from the previous
default of **18**. This should speed up map loading a little - as it will
remove the need to convert the data to the current forms used internally as
well as making some details more robust. It also allows the removal of some
warning code that would have fired if area or map user data features were
used and format *16* was selected for saving.
#### History of recent (last six years) changes to Map File Format:
* dfce0f01ad (PR #2106) - **20** Improved way
that custom exit line data was held internally (so that the keys are now
the same as the other exit details that are keyed by a string {doors, exit
weight}. The custom exit line style is stored as the shorter and easier to
code with `Qt::PenStyle enum` instead of a English `QString` and the
custom exit line as a `QColor` instead of a `QList<int>` with 3 elements -
(so the custom exit line could have a alpha component in the future!) Code
is in place to support a workaround to work within map formats back to
include version 17.
* 91a08c33f2 (PR #1543) - **19** Added support
for more than one of any grapheme for the 2D map room symbol. Code is
in place to support a workaround to work within map formats back to include
version 17.
* 94dd41bfb7 (associated with PR #301) - **18**
Added support for multiple user rooms in map file copied to other profiles
- so that the original player room (in the other profile) is retained in a
map copied over. Also revised the `TArea::rooms` from being a `QList` to a
faster to look up in `QSet`. Code in place to support saving in previous
formats.
* fb79c62381 (associated with PR #280) - **17**
Added support for area and map user data features. Warnings are issued
should these be actually used and a lower map format is specified to save
the map in **as that data will then be lost from the map file**.
* 88ef6491e0 - **16** Map format of Mudlet 2.1
dating back to 2013-01-02 .
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Add compile variable for 3D mapper
* Move 3D mapper creation out from .ui into code
* Implement compile-time toggle
* Revert ccache comment
* Add CMake toggle
* Fix 3D widget from getting created underneath toggle buttons
* Fix copy/paste error
* Don't link against GLU if not using 3D mapper
* Don't link to opengl
* Split and renamed TRoomDB hashTable.
This will speed up roomID to hash lookups, as well as room
deletions. Added logic to keep them in sync and avoid duplicates.
* Update according to code review.
* Cleaned up error reporting in setRoomIDbyHash.
* Code review requests.
* clang-format on changes.
This will enable them to establish the identity of their related `Host`
instance without the need to call `Host::getName()` which involves a
mutex in the latter class. This makes things a bit faster and less likely
to cause deadlocks in odd places.
The `Host::setName(const QString&)` method has been revised to ensure that
changes are passed across to the other three classes on change. This will
close https://github.com/Mudlet/Mudlet/issues/2357 - with the exception
that changing the name of the profile whilst it is active will need some
further jiggery-pokery in the HostManager and mudlet classes.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This is the edited summary of a squash and merge of 14 commits:
Adds support for SGR Reverse (swap foreground and background colours)
"7"/"27" for On/Off and SGR Overline "53"/"55" for On/Off
Remove unused cruft:
* (void) TTextEdit::drawFrame(QPainter&, const QRect&)
* (void) TTextEdit::updateLastLine
* const QChar cLF & cSPACE in TBuffer (as it happens they are completely
unused and redundant as the enum QChar::SpecialCharacter provides
QChar::LineFeed and QChar::Space to provide the same constants)
* (QTime) TBuffer::mTime
* (void) TConsole::echoUserWindow(const QString&)
* (QPoint) TBuffer::insert(QPoint&, const QString&, int, int, int,
int, int, int, bool, bool, bool, bool)
* (void) TConsole::printDebug(...) functionally the same as one type of
(void) TConsole::print(...) just with a different order of arguments.
Convert #define constants TCHAR_BOLD etc. into a QFLag/enum
TChar::AttributeFlags which is declared and capable of QFlag OR operations.
Refactor a number of methods that take lots of bools and ints as individual
formatting options and colour components to take single
TChar::AttributeFlags and one or two QColors instead.
Remove a large number of (int) colour value component values as member
variables in TBuffer as they are not needed.
Convert highly repetitive intermediate methods to setBold, setItalics etc.
to take a (combinations allowed) TChar::Attribute flag value instead.
Convert 2x3 int as colour components (r,g,b) in TColorTable defined in
TTrigger class to a pair of QColors.
Remove unused QString argument from:
* (void) mudlet::setLink(...)
* (void) TConsole::setLink(...)
Remove unused QColor argument from:
* (inline void) TTextEdit::drawCharacters(...)
Refactor arguments in:
*(QString) TBuffer::bufferToHtml(QPoint P1, QPoint P2,
bool allowedTimestamps, int spacePadding = 0)
to:
(QString) TBuffer::bufferToHtml(const bool showTimeStamp = false,
const int row = -1, const int endColumn = -1,
const int startColumn = 0, int spacePadding = 0)
Convert to const references some method arguments.
Add TBuffer::set[BF]gColor(...) overloads that take a QColor argument.
Add selection state methods select()/deselect()/isSelected() const methods
to TChar class to hide/separate the selection process from the formatting
effect. (TChar::Reverse tracks the ANSI SGR reverse colour attribute and
its effect is EX-ORed with the (bool) TChar::mIsSelected flag).
Add a new tempAnsiColorTrigger lua function that, unlike tempColorTrigger
uses the correct ANSIcolors in the range 0-15 - although the original also
handles the 256 colour range in the 16-255 correctly those first 16 values
are miss-mapped and it is not possible to change them without breakage.
Adds 256-color support to Editor GUI for color triggers - and allows
choosing the default (unmodified) fore or background colors to match one
(the previous did not) and also allows one of the fore or background color
to be ignored so only the other is considered. The ignored color case is
saved in the profile data and can exported but MAY not work in previous
Mudlet versions which cannot handle the value used! It is also reported as
an error to have a color trigger with both fore and background ignored in
both the lua functions and in the GUI.
Also:
Fixed a code structure issue in TLuaInterpreter::debug() which would not
work correctly if there was more than one value on the lua stack to print
out.
This will close issues #477 and #703.
Converted some `QObject::connect` calls to the new Qt5 compile time
version.
Removed an unused `TTrigger*` argument from
`dlgColorTrigger::setupBasicButtons(...)`.
Removed an unused flag:
* `(bool) TConsole::mSaveLayoutRequested
Also spotted some dead code from abandoned attempt to support blinking,
some reordering that a new version of Qt spotted as needed in the TBuffer
and TChar constructor initialisation lists, and a operator precedence item
that could be clarified with an addition pair of `(`...`)`s.
A previous error in the prior PR that this one is attempting to replace
had a problem in HTML generation that I reproduced here and which needed
the same fix (a missing escaped `"` mark).
An upgraded Qt Creator pointed out to me some initiliser list issues in
`TBuffer` and `TConsole`; and some C-style casts in some font settings in
the latter class.
Remove a debugging output line that is not useful now and will be spammy.
Modernise a triplet of QObject::connect(...) calls that will otherwise
clash harder when merged into development after "upgrade-to-qt5-connect"
PR has also been merged into the main branch.
Also:
* add some explanation/help text to the dlgColorTrigger dialog.
* revise the text explaining the formula (232 + grey scale value 0..23)
used for colours from the 24 grey-scale part of the 256 colour range.
* add some tool-tips to parts of the dlgColorTrigger dialog.
* add a generic static method to the mudlet class to provide a consistent
and re-usable "HTML" wrapper around text - which will be particularly
useful for tool-tip generation.
Revise: change colour trigger UI to hide colours 16-255 by default
This follows a suggestion from a peer in the review process.
Update: add Wiki documentation link comment
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Fixes TMap::restore updated mSaveVersion to mDefaultVersion as originally intended
* saveMap allows to specify which format to use to save.
* saveMap reflects the lua interpreter saveVersion argument
* Fixes redifinition of default argument in TArea
* serialize() serializing with a higher version than mMaxVersion gives an error
* saveMap() better arguments handling and error messages.
return lua_error is used across the whole Interpreter.
* Restore versioned saveMap()
* Remove uppercasing
* Fix typos
* Update TMap.cpp
This includes some unimplemented and commented out instances.
It does not include a usage of `QSignalMapper` which has been declared
obsolete and is not supported by the new, compile-time checking, system.
It also does not include usages in the third parties libraries,
particularly the edbee-lib editor widget and the communi IRC libraries.
Only the:
`[static] int QHostInfo::lookupHost(const QString& name, QObject* receiver,
const char* member)`
form is supported in older versions of Qt so we have to retain one SLOT(...)
instance when the Qt version is less than 5.9.0 LTS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Changes the TRoom class to store the detail about the style of line as the
Qt::PenStyle enum that is used when it is actually drawn (saves a few
bytes per custom exit line)! Concurrently change the 2D map UI that
adjusts this setting on both new custom exit lines being drawn and existing
lines selected by the UI to separate the text used to describe the style
from this value so that the text can be translated for other GUI languages
without breaking the code. Enhance the control (a `QComboBox`) used for
this so that it has icons with a visual representation of each style!
Revise the Lua function `addCustomLine` to bring the error reporting up to
current UI style - including detection some error conditions that were not
previously reported (included whether there was the exit that the custom
line was to be added to show). Also the target room who's location was used
as the end-point for a single segment line was not being checked to confirm
that it existed and was in the same area as the room that the exit line was
being drawn from. Alternatively, when a table of tables of coordinate
triplets {x, y, z} was provided there was previously no proper validation
that they all existed and were numbers to be used as coordinates...
I also discovered that TLuaInterpreter::dirToString was not producing the
right `QString`s necessary for numeric arguments for the normal exit
direction to work in the two lua functions that used it (`addCustomLine`
and `setExitWeight`) I have corrected it and updated the callers of it to
now return the right normal exit strings needed for each of them.
To validate whether there is actually an exit in the direction that the
lua addCustomLine function is told is a little complicated so I have added
a `(bool) TRoom::hasExitOrSpecialExit(const QString&, const bool) const`
method that does this so that addCustomLine can return a run-time error
(nil + error message) if the given exit does not already exist.
In some places in the TLuaInterpreter custom line functions and the
`T2DMap::paintEvent()` method non-const method were being used to access
the details of the custom exit lines - as this takes longer and runs the
risk of changing the data when it should not be being changed I have
switched to using the read only or constant `at(...)`/`value(...)` methods
rather than the read/write or non-constant `operator[...]` method where
practical.
I have also made each custom exit line be drawn as a polyline rather than
a series of single segments - this is more effiecent I think and it means
that the dotted/dashed pattern effect "goes around" each corner rather than
restarting on each segment which looks better IMHO - draw a multi-segment
line and move one of the vertexes towards the end and you will see the
differences. 8-)
This should close#2095 !
Revised to make addCustomLine & setExitWeight not case sensitive for exit dir
In fact have converted the TRoom custom exit line data members use a lower
case key for "Normal" exit directions and go through all the places where
those keys were used. Also make the change in the binary map data format
20 (and above). As it was convenient to do so, I have also changed it so
that the custom line colour is stored as a `QColor` instead of a
`QList<int>` of RGB components.
The addCustomLine and setExitWeight lua functions now treat a wider range
of strings as being for "Normal" exit directions in a case insensitive
manner - there is a small possibility that this may clash with strings used
for "Special" exits if they use a full English word for the exit direction
(with or without hyphens for diagonal exits)...
In testing the lua addCustomLine command I found that adding a new line to
a room that did not previously have one produced a weirdly visible line
that only showed up at some zoom levels and was very thin. It turned out
that this is because there was not a call to TRoom::calcRoomDimensions()
after adding the line and the TRoom::{min|max}_{x|y} members (which are
updated by that) are used during the T2DMap::paintEvent().
Whilst I was working in this area of code I decided I could also provide
the missing lua function `removeCustomLine`...
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Brief overview of PR changes/additions
Mudlet is still called Mudlet, but the texts shown to user will no longer talk about "MUDs", instead about "games"
#### Motivation for adding to Mudlet
People use Mudlet for more than MUDs. For example MOOs, etc. Game is just more approachable for newbies too.
If "MUD" is used within the name, "Mudlet the MUD client" is ok - as it's hard to imagine what would it be without it.
#### Other info (issues closed, discussion etc)
Adresses #1801 issue 3
Enhance #1949
* Upgrade a few classes to newer connect style
* Revise: update a lot more QObject::{dis|}connect(...) usages
Include those that need a qOverload<...>(...) wrapper to disambigute
overloaded signal sources.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
I think there may have been an issue with stale files not being removed
from a cache or pre-compiled headers because since
https://github.com/Mudlet/Mudlet/pull/1703
I seem to be missing "#include" entries in various files which I think has
been masked by stale files in the typical build environment when switching
around the git repository - I'm guessing but perhaps the cached build
header files are not cleaned out when a different branch is selected so
that there are `#include` entries in the cached files that had been taken
out of the actual code but not removed from the cached copy so a test
build succeeds but a build on a "make clean"ed setup will fail because the
cached files are purged...
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>