2009-02-06 03:39:14 +01:00
/***************************************************************************
2014-08-15 02:11:43 -07:00
* Copyright ( C ) 2008 - 2013 by Heiko Koehn - KoehnHeiko @ googlemail . com *
* Copyright ( C ) 2014 by Ahmed Charles - acharles @ outlook . com *
2024-07-15 09:08:35 +02:00
* Copyright ( C ) 2016 - 2023 by Stephen Lyons - slysven @ virginmedia . com *
2017-10-10 23:03:57 -04:00
* Copyright ( C ) 2016 - 2017 by Ian Adkins - ieadkins @ gmail . com *
2009-03-01 13:51:33 +01:00
* *
2009-02-06 03:39:14 +01:00
* This program is free software ; you can redistribute it and / or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation ; either version 2 of the License , or *
* ( at your option ) any later version . *
* *
* This program is distributed in the hope that it will be useful , *
* but WITHOUT ANY WARRANTY ; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the *
* GNU General Public License for more details . *
* *
* You should have received a copy of the GNU General Public License *
* along with this program ; if not , write to the *
* Free Software Foundation , Inc . , *
* 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "XMLimport.h"
2014-08-15 02:11:43 -07:00
2017-10-10 23:03:57 -04:00
2021-04-02 19:10:16 +01:00
# include "dlgMapper.h"
2014-08-15 02:11:43 -07:00
# include "LuaInterface.h"
Improve: Secure credential management with system keychain integration and legacy migration (#7956)
#### Brief overview of PR changes/additions
This pull request implements secure credential management for Mudlet
with system keychain integration and encrypted fallback storage:
**Core Components:**
- **CredentialManager**: High-level API for secure credential storage
with QtKeychain integration
- **SecureStringUtils**: Qt-based cryptographic utilities for encrypted
file storage
- **Legacy Migration**: Automatic detection and migration of existing
plaintext passwords
**Key Features:**
- **System Keychain Integration**: Primary storage in macOS Keychain,
Windows Credential Store, and Linux Secret Service via QtKeychain
- **Encrypted File Fallback**: Qt crypto-based AES encryption for
portable mode and keychain unavailability
- **Seamless Migration**: Automatic detection and upgrade of legacy
password storage formats
- **Profile Isolation**: Per-profile encryption keys prevent
cross-profile credential access
- **Portable Mode Support**: Automatic detection and secure file-based
storage for portable installations
#### Motivation for adding to Mudlet
**Security Enhancement:**
- Eliminates plaintext password storage in profile XML files
- Provides industry-standard system keychain integration for credential
security
- Implements authenticated encryption for fallback scenarios
**User Experience:**
- Zero configuration required - works automatically across all platforms
- Seamless migration from existing plaintext passwords to secure storage
- Native system integration provides familiar credential management
experience
**Future-Proofing:**
- Extensible architecture supports additional credential types (API
keys, tokens, etc.)
- Robust fallback ensures functionality in all deployment scenarios
- Prepares foundation for OAuth and external service integrations
#### Other info (issues closed, discussion etc)
**Security Architecture:**
- **Keychain-First Strategy**: Prefers system keychain with automatic
encrypted file fallback
- **Legacy Format Detection**: Automatically migrates passwords from
development branch keychain format
- **Memory Security**: Secure string clearing and controlled credential
lifecycle management
- **Input Validation**: Path traversal protection and service name
sanitization
**Implementation Highlights:**
- **Async Operations**: Non-blocking keychain operations with timeout
protection
- **Thread Safety**: Event-driven architecture prevents UI blocking and
race conditions
- **Comprehensive Testing**: Full test coverage for encryption,
migration, and fallback scenarios
- **Cross-Platform**: Unified API across Windows, macOS, and Linux with
platform-specific optimizations
**Version Compatibility & Migration:**
- **Mudlet 4.19.x Compatibility**: Preserves existing plaintext password
storage to ensure compatibility when switching between 4.19.x stable and
development builds
- **Mudlet 4.20.x Migration**: Post-4.20.0 release, automatic migration
begins converting plaintext passwords to secure storage
- **Bidirectional Safety**: Users can safely run both 4.19.x and
development versions without losing access to their passwords during the
transition period
- **Legacy Format Support**: Automatically detects and migrates
passwords from the original development branch keychain format
(`service="Mudlet profile"`) to the new secure format
# Credential Management Workflows
## 1. Credential Storage Strategy
```mermaid
flowchart TD
A[Store Password Request] --> B{Portable Mode?}
B -->|Yes| C[Encrypt & Store in Profile File]
B -->|No| D[Store in System Keychain]
D --> E{Keychain Success?}
E -->|Yes| F[Remove Encrypted Fallback File]
E -->|No| G[Fallback to Encrypted File]
F --> H[Success]
G --> I{Encryption Success?}
I -->|Yes| H
I -->|No| J[Failure]
C --> I
classDef primary fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef decision fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef result fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class D,F primary
class C,G fallback
class B,E,I decision
class H,J result
```
## 2. Legacy Migration Workflow
```mermaid
flowchart TD
A[Retrieve Password Request] --> B[Try New Keychain Format]
B --> C{Password Found?}
C -->|Yes| D[Return Password]
C -->|No| E[Check Legacy Keychain Format]
E --> F{Legacy Found?}
F -->|Yes| G[Migrate to New Format]
G --> H[Store in New Format]
H --> I[Remove Legacy Entry]
I --> J[Return Migrated Password]
F -->|No| K[Try Encrypted File]
K --> L{File Found?}
L -->|Yes| M[Decrypt & Return]
L -->|No| N[Return Empty - No Password Stored]
classDef newformat fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef legacy fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef migration fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
classDef fallback fill:#607D8B,stroke:#263238,stroke-width:2px,color:#fff
classDef result fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
class B,H newformat
class E,I legacy
class G migration
class K fallback
class D,J,M,N result
```
## 3. Cross-Platform Keychain Integration
```mermaid
flowchart TD
A[QtKeychain Request] --> B{Platform Detection}
B -->|macOS| C[Access Keychain Services]
B -->|Windows| D[Access Credential Store]
B -->|Linux| E[Access Secret Service]
C --> F[Store/Retrieve Credential]
D --> F
E --> F
F --> G{Operation Success?}
G -->|Yes| H[Return Result]
G -->|No| I[Log Error & Fallback]
I --> J[Use Encrypted File Storage]
J --> K[AES Encryption with Profile Key]
K --> L[Store in Profile Directory]
classDef platform fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef keychain fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef crypto fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class C,D,E platform
class F,H keychain
class I,J fallback
class K,L crypto
```
This implementation provides a comprehensive, secure, and user-friendly
credential management system that seamlessly upgrades existing Mudlet
installations while providing robust security for future credential
storage needs.
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-17 06:44:38 -04:00
# include "CredentialManager.h"
# include "SecureStringUtils.h"
2019-03-08 09:28:55 +01:00
# include "TConsole.h"
2014-08-15 02:11:43 -07:00
# include "TMap.h"
# include "TRoomDB.h"
2022-04-25 21:31:02 +01:00
# include "TRoom.h"
2014-08-15 02:11:43 -07:00
# include "VarUnit.h"
2017-02-27 03:56:18 +00:00
# include "mudlet.h"
2014-08-15 02:11:43 -07:00
2018-06-07 00:07:32 +01:00
# include <QBuffer>
infrastructure: decouple the mapper engine from UI dialogs (#9513)
#### Brief overview of PR changes/additions
- Removes all raw Qt Widgets usage from the map engine: `TMap.{h,cpp}`
no longer owns a `QProgressDialog` (and drops a dead `QFileDialog`
include), and `XMLimport.{h,cpp}` no longer pulls in `QApplication` (the
clipboard read now uses `QGuiApplication::clipboard()`, which lives in
Qt Gui).
- The standalone map-progress dialog (shown when the mapper is not
visible, for map download / XML import and JSON export/import) is now
driven by Qt signals carrying pre-translated payloads; the frontend
(`TMainConsole`) owns the actual `QProgressDialog`, and a user cancel
returns to the engine through `TMap::slot_mapProgressDialogCancelled()`.
- Adds `MapProgressDialogSeamTest` covering the transfer-progress state
machine, a JSON export/import round trip driving the new signals, a
mid-import cancel delivered through the seam (the highest-risk change,
since the JSON reader used to poll `QProgressDialog::wasCanceled()`
synchronously), and an XML map import re-entered from inside a running
JSON operation.
#### Motivation for adding to Mudlet
Second concrete step of the re-scoped libmudlet plan (a Qt-Widgets-free
`mudlet_core` for headless use, testability and WASM). It copies the
seam template established in #9507: core emits a pre-translated payload
-> frontend owns the widget -> a callback slot returns the answer. The
Qt Widgets dependency audit (`cmake/audit-core-widgets.sh`) drops from
**151 to 147** offending files; `TMap.cpp`, `TMap.h`, `XMLimport.cpp`
and `XMLimport.h` are all now clean. The mapper-owned inline progress
path (`dlgMapper`/`T2DMap`, Mudlet's own widgets) is deliberately
untouched here - those move wholesale in the later target-split phase.
#### Other info (issues closed, discussion etc)
Part of #8681 / #9011. Existing translations are unaffected: every
progress string keeps its `TMap` `tr()` context, so current translations
carry straight over. Two new strings do arrive, both with `//:`
translator comments - the warnings shown when a map download or an XML
map import is refused because a JSON import/export is already running.
The JSON dialog stays non-modal and the download/import dialog keeps its
modeless styling, each applied by the frontend. The engine keeps its own
`mMapProgressStandalone` / `mMapProgressCancelRequested` /
`mMapProgressStandaloneMaximum` state to replace the widget read-backs
it used to do (`!= nullptr`, `wasCanceled()`, `maximum()`). If a map
operation ever reaches the engine before a console is wired (checked via
`isSignalConnected`), `TMap::warnIfMapProgressUnwired()` logs a loud
`qWarning` rather than silently running with no progress UI.
It also closes a latent null-dereference that exists on `development`
today. With the mapper visible a map download takes the inline-progress
path, leaving `mpProgressDialog` null - so a JSON export started
meanwhile sails past the `if (mpProgressDialog)` "already in progress"
check and creates a dialog of its own. When the download then finishes
inside the `processEvents()` pump the export is running,
`clearTransferProgress()` deletes and nulls *that* dialog, and the
export's next `incrementJsonProgressDialog()` dereferences null. The
engine now records whose dialog is up (`mMapProgressIsTransfer`) so a
transfer only ever closes its own, and `importMap()` refuses to start
while a JSON operation holds the progress - the mirror of the guard
`downloadMap()` has.
Two review-driven details worth flagging: the frontend only wires the
dialog's cancel to the engine when the operation is actually cancelable,
so a non-cancelable local XML import no longer turns a window-close into
a spurious "Map download was canceled" message; and the standalone
download/import dialog is now parented to the console (like the JSON one
always was, and like #9507's package-download dialog), so it centres on
and dies with the profile window. The three `#include <QApplication>`
additions to `Host.cpp` / `dlgTriggerEditor.cpp` /
`dlgConnectionProfiles.cpp` replace the transitive include they used to
get from `XMLimport.h`; all three are already Qt Widgets consumers, so
the audit count is unaffected.
Assisted-by: Claude:claude-opus-4-8
Assisted-by: Claude:claude-opus-5
**Test case:** With a mapper window open, use a game that supports map
download (or call `downloadMap()`) and confirm the progress dialog
shows, updates, and its Abort cancels the download. Then with the mapper
window closed, run `exportJsonMap()` and `importJsonMap()` on a large
map and confirm the non-modal JSON progress dialog appears, updates its
Areas/Rooms/Labels counts, and that clicking Abort during an import
stops it with an "aborted by user" result. Load a local XML map
(Settings -> Map -> load) and confirm closing its progress window does
not print a "Map download was canceled" line. Everything should behave
exactly as on `development`.
#### Demo (before & after)
https://github.com/user-attachments/assets/f1c62580-2d03-4e5b-a6ee-f6e2b78d113d
2026-08-02 15:33:07 +02:00
# include <QClipboard>
# include <QGuiApplication>
2018-06-07 00:07:32 +01:00
# include <QtMath>
Improve: Secure credential management with system keychain integration and legacy migration (#7956)
#### Brief overview of PR changes/additions
This pull request implements secure credential management for Mudlet
with system keychain integration and encrypted fallback storage:
**Core Components:**
- **CredentialManager**: High-level API for secure credential storage
with QtKeychain integration
- **SecureStringUtils**: Qt-based cryptographic utilities for encrypted
file storage
- **Legacy Migration**: Automatic detection and migration of existing
plaintext passwords
**Key Features:**
- **System Keychain Integration**: Primary storage in macOS Keychain,
Windows Credential Store, and Linux Secret Service via QtKeychain
- **Encrypted File Fallback**: Qt crypto-based AES encryption for
portable mode and keychain unavailability
- **Seamless Migration**: Automatic detection and upgrade of legacy
password storage formats
- **Profile Isolation**: Per-profile encryption keys prevent
cross-profile credential access
- **Portable Mode Support**: Automatic detection and secure file-based
storage for portable installations
#### Motivation for adding to Mudlet
**Security Enhancement:**
- Eliminates plaintext password storage in profile XML files
- Provides industry-standard system keychain integration for credential
security
- Implements authenticated encryption for fallback scenarios
**User Experience:**
- Zero configuration required - works automatically across all platforms
- Seamless migration from existing plaintext passwords to secure storage
- Native system integration provides familiar credential management
experience
**Future-Proofing:**
- Extensible architecture supports additional credential types (API
keys, tokens, etc.)
- Robust fallback ensures functionality in all deployment scenarios
- Prepares foundation for OAuth and external service integrations
#### Other info (issues closed, discussion etc)
**Security Architecture:**
- **Keychain-First Strategy**: Prefers system keychain with automatic
encrypted file fallback
- **Legacy Format Detection**: Automatically migrates passwords from
development branch keychain format
- **Memory Security**: Secure string clearing and controlled credential
lifecycle management
- **Input Validation**: Path traversal protection and service name
sanitization
**Implementation Highlights:**
- **Async Operations**: Non-blocking keychain operations with timeout
protection
- **Thread Safety**: Event-driven architecture prevents UI blocking and
race conditions
- **Comprehensive Testing**: Full test coverage for encryption,
migration, and fallback scenarios
- **Cross-Platform**: Unified API across Windows, macOS, and Linux with
platform-specific optimizations
**Version Compatibility & Migration:**
- **Mudlet 4.19.x Compatibility**: Preserves existing plaintext password
storage to ensure compatibility when switching between 4.19.x stable and
development builds
- **Mudlet 4.20.x Migration**: Post-4.20.0 release, automatic migration
begins converting plaintext passwords to secure storage
- **Bidirectional Safety**: Users can safely run both 4.19.x and
development versions without losing access to their passwords during the
transition period
- **Legacy Format Support**: Automatically detects and migrates
passwords from the original development branch keychain format
(`service="Mudlet profile"`) to the new secure format
# Credential Management Workflows
## 1. Credential Storage Strategy
```mermaid
flowchart TD
A[Store Password Request] --> B{Portable Mode?}
B -->|Yes| C[Encrypt & Store in Profile File]
B -->|No| D[Store in System Keychain]
D --> E{Keychain Success?}
E -->|Yes| F[Remove Encrypted Fallback File]
E -->|No| G[Fallback to Encrypted File]
F --> H[Success]
G --> I{Encryption Success?}
I -->|Yes| H
I -->|No| J[Failure]
C --> I
classDef primary fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef decision fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef result fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class D,F primary
class C,G fallback
class B,E,I decision
class H,J result
```
## 2. Legacy Migration Workflow
```mermaid
flowchart TD
A[Retrieve Password Request] --> B[Try New Keychain Format]
B --> C{Password Found?}
C -->|Yes| D[Return Password]
C -->|No| E[Check Legacy Keychain Format]
E --> F{Legacy Found?}
F -->|Yes| G[Migrate to New Format]
G --> H[Store in New Format]
H --> I[Remove Legacy Entry]
I --> J[Return Migrated Password]
F -->|No| K[Try Encrypted File]
K --> L{File Found?}
L -->|Yes| M[Decrypt & Return]
L -->|No| N[Return Empty - No Password Stored]
classDef newformat fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef legacy fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef migration fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
classDef fallback fill:#607D8B,stroke:#263238,stroke-width:2px,color:#fff
classDef result fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
class B,H newformat
class E,I legacy
class G migration
class K fallback
class D,J,M,N result
```
## 3. Cross-Platform Keychain Integration
```mermaid
flowchart TD
A[QtKeychain Request] --> B{Platform Detection}
B -->|macOS| C[Access Keychain Services]
B -->|Windows| D[Access Credential Store]
B -->|Linux| E[Access Secret Service]
C --> F[Store/Retrieve Credential]
D --> F
E --> F
F --> G{Operation Success?}
G -->|Yes| H[Return Result]
G -->|No| I[Log Error & Fallback]
I --> J[Use Encrypted File Storage]
J --> K[AES Encryption with Profile Key]
K --> L[Store in Profile Directory]
classDef platform fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef keychain fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef crypto fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class C,D,E platform
class F,H keychain
class I,J fallback
class K,L crypto
```
This implementation provides a comprehensive, secure, and user-friendly
credential management system that seamlessly upgrades existing Mudlet
installations while providing robust security for future credential
storage needs.
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-17 06:44:38 -04:00
# include <QVersionNumber>
2018-06-07 00:07:32 +01:00
improve: improve memory safety by using smart pointers (#9239)
### Refactor: replace raw pointer ownership with smart pointers across
core subsystems
#### Brief overview of PR changes/additions
Replaces raw pointer ownership patterns with `std::unique_ptr` and
`std::map`
across several core subsystems:
- **Host**: `mStopWatchMap` (`QMap<int, stopWatch*>` → `std::map<int,
unique_ptr<stopWatch>>`), `profileShortcuts` (`QMap<QString,
QKeySequence*>` → `std::map<QString, unique_ptr<QKeySequence>>`).
Removes `qDeleteAll` in destructor and `delete mMMCPServer`.
- **TMap**: `mpRoomDB` raw pointer → `unique_ptr`
- **VarUnit**: `base` raw pointer → `unique_ptr`
- **TTrigger**: condition map storage converted to `unique_ptr`,
destructor simplified
- **discord**: handler and presence maps converted from raw pointer
`QMap` to `unique_ptr` + `std::map`
- **Updater**: `mFeed` and `mUpdateDialog` converted to `unique_ptr`
#### Motivation for adding to Mudlet
These patterns were identified as sources of memory leaks and potential
use-after-free bugs. Using smart pointers makes ownership explicit,
eliminates manual cleanup code, and ensures correct destruction even on
early-exit paths.
#### Other info (issues closed, discussion etc)
sorry this one is still pretty big, but most of the changes are the same
for each thing so reviewing them together probably makes sense. sadly
there isn't much to see here other than no slow uptick of heap size :-[
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:42:09 +12:00
# include <memory>
2017-02-27 03:56:18 +00:00
XMLimport : : XMLimport ( Host * pH )
2017-04-19 15:27:12 -07:00
: mpHost ( pH )
2009-02-06 03:39:14 +01:00
{
}
2023-04-27 19:50:32 +02:00
std : : pair < bool , QString > XMLimport : : importPackage ( QFile * pfile , QString packName , int moduleFlag , QString * pVersionString )
2009-02-06 03:39:14 +01:00
{
2011-05-28 02:13:53 +02:00
mPackageName = packName ;
2017-04-11 22:58:14 +01:00
setDevice ( pfile ) ;
2009-03-01 13:51:33 +01:00
2011-10-11 04:09:28 +02:00
module = moduleFlag ;
2011-05-28 02:13:53 +02:00
2017-02-27 03:56:18 +00:00
if ( ! packName . isEmpty ( ) ) {
2017-08-03 08:46:00 +02:00
mpKey = new TKey ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpKey - > mModuleMasterFolder = true ;
mpKey - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpKey - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpKey - > setIsActive ( true ) ;
mpKey - > setName ( mPackageName ) ;
mpKey - > setIsFolder ( true ) ;
2017-08-03 08:46:00 +02:00
mpTrigger = new TTrigger ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpTrigger - > mModuleMasterFolder = true ;
mpTrigger - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpTrigger - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpTrigger - > setIsActive ( true ) ;
mpTrigger - > setName ( mPackageName ) ;
mpTrigger - > setIsFolder ( true ) ;
2017-08-03 08:46:00 +02:00
mpTimer = new TTimer ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpTimer - > mModuleMasterFolder = true ;
mpTimer - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpTimer - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpTimer - > setIsActive ( true ) ;
mpTimer - > setName ( mPackageName ) ;
mpTimer - > setIsFolder ( true ) ;
2017-08-03 08:46:00 +02:00
mpAlias = new TAlias ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpAlias - > mModuleMasterFolder = true ;
mpAlias - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpAlias - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpAlias - > setIsActive ( true ) ;
mpAlias - > setName ( mPackageName ) ;
mpAlias - > setScript ( QString ( ) ) ;
mpAlias - > setRegexCode ( QString ( ) ) ;
mpAlias - > setIsFolder ( true ) ;
2017-08-03 08:46:00 +02:00
mpAction = new TAction ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpAction - > mModuleMasterFolder = true ;
mpAction - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpAction - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpAction - > setIsActive ( true ) ;
mpAction - > setName ( mPackageName ) ;
mpAction - > setIsFolder ( true ) ;
2017-08-03 08:46:00 +02:00
mpScript = new TScript ( nullptr , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
mpScript - > mModuleMasterFolder = true ;
mpScript - > mModuleMember = true ;
}
Improve: add ancestors functions (#6726)
#### Brief overview of PR changes/additions and motivation for adding
Provides two Lua functions:
* `isAncestorsActive(itemID, "type")` - returns a boolean which is
`true` if all (if any) of the parents of the given item are set as
active and `false` if any are not. It makes use of an internal template
function that already exists but makes it available to the Lua
sub-system. If the item does not have any ancestors this function will
return `true`.
* `ancestors(itemID, "type")` - returns a table containing a sub-table
for each successively distance ancestor (if any) of the given item;
within each sub-table are details of the ancestor, specifically:
* its ID as a number
* its name as a string
* whether it is active as a boolean
* its "node" (type), one of "item", "group" (folder) or "package"
(module)
***ALSO: adds a third, optional, boolean argument to `isActive(...)`
which if provided and `true` will only includes items in the count whose
parents are all enabled/active - if omitted it will be treated as if it
is `false` so that it behaves as the current version. Script-writers
should check for the presence of one of the other two functions to
determine if this third argument is handled.***
#### Other info (issues closed, discussion etc)
The first function will be enough to close #6724, specifically when it
is combined with `isActive(...)` as follows, it will enable a script to
determine whether an item (in this example a trigger with an ID number
stored as `myTriggerID`) will operate or not:
```lua
if isAncestorsActive(myTriggerID, "trigger") and isActive(myTriggerID, "trigger") > 0 then
-- Okay the aforesaid trigger will run!
end
```
Note that these two new functions ONLY work with the ID number of an
item - this is because a unique identifier is required and Mudlet allows
for duplicate names so that cannot be used to reliably identify an item.
It had now been made a bit easier to determine the ID number of an
existing item the `findItems("name", "type")` function that has also been
implemented as#6742.
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-17 03:54:36 +00:00
mpScript - > mPackageName = mPackageName ;
2017-02-27 03:56:18 +00:00
mpScript - > setIsActive ( true ) ;
mpScript - > setName ( mPackageName ) ;
mpScript - > setIsFolder ( true ) ;
mpHost - > getTriggerUnit ( ) - > registerTrigger ( mpTrigger ) ;
mpHost - > getTimerUnit ( ) - > registerTimer ( mpTimer ) ;
mpHost - > getAliasUnit ( ) - > registerAlias ( mpAlias ) ;
mpHost - > getActionUnit ( ) - > registerAction ( mpAction ) ;
mpHost - > getKeyUnit ( ) - > registerKey ( mpKey ) ;
mpHost - > getScriptUnit ( ) - > registerScript ( mpScript ) ;
}
while ( ! atEnd ( ) ) {
2009-02-06 03:39:14 +01:00
readNext ( ) ;
2009-03-01 13:51:33 +01:00
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2021-12-07 06:21:39 +01:00
if ( name ( ) = = qsl ( " MudletPackage " ) ) {
2017-04-11 19:37:13 +01:00
QString versionString ;
2021-12-07 06:21:39 +01:00
if ( attributes ( ) . hasAttribute ( qsl ( " version " ) ) ) {
versionString = attributes ( ) . value ( qsl ( " version " ) ) . toString ( ) ;
2017-04-11 19:37:13 +01:00
if ( ! versionString . isEmpty ( ) ) {
bool isOk = false ;
2023-05-14 15:06:15 +02:00
const float versionNumber = versionString . toFloat ( & isOk ) ;
2017-04-11 19:37:13 +01:00
if ( isOk ) {
mVersionMajor = qFloor ( versionNumber ) ;
mVersionMinor = qRound ( 1000.0 * versionNumber ) - ( 1000 * mVersionMajor ) ;
}
if ( pVersionString ) {
* pVersionString = versionString ;
}
}
}
if ( mVersionMajor > 1
/*||(mVersionMajor==1&&mVersionMinor)*/ ) {
// Minor check is not currently relevant, just abort on 2.000f or more
2023-05-14 15:06:15 +02:00
const QString moanMsg = tr ( " [ ALERT ] - Sorry, the file being read: \n "
2017-04-11 22:58:14 +01:00
" \" %1 \" \n "
2017-04-12 17:09:58 +01:00
" reports it has a version (%2) it must have come from a later Mudlet version, \n "
" and this one cannot read it, you need a newer Mudlet! " )
2017-06-26 16:46:54 +02:00
. arg ( pfile - > fileName ( ) , versionString ) ;
2017-04-11 19:37:13 +01:00
mpHost - > postMessage ( moanMsg ) ;
2023-04-27 19:50:32 +02:00
return { false , moanMsg } ;
2017-04-11 19:37:13 +01:00
}
2009-02-06 03:39:14 +01:00
readPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " map " ) ) {
2026-04-08 07:55:00 +02:00
if ( ! packName . isEmpty ( ) ) {
qWarning ( ) < < " XMLimport::importPackage(...) WARNING: ignoring unexpected <map> element "
" - map data should not be present in package XML files " ;
} else {
readMap ( ) ;
mpHost - > mpMap - > audit ( ) ;
if ( mpHost - > mpMap - > mpMapper ) {
mpHost - > mpMap - > mpMapper - > mp2dMap - > init ( ) ;
mpHost - > mpMap - > mpMapper - > updateAreaComboBox ( ) ;
mpHost - > mpMap - > mpMapper - > resetAreaComboBoxToPlayerRoomArea ( ) ;
mpHost - > mpMap - > mpMapper - > show ( ) ;
}
}
2017-02-27 03:56:18 +00:00
} else {
qDebug ( ) . nospace ( ) < < " XMLimport::importPackage(...) ERROR: "
" unrecognised element with name: "
< < name ( ) . toString ( ) < < " and content: " < < text ( ) . toString ( ) ;
2009-02-06 03:39:14 +01:00
}
}
}
2012-04-19 15:40:40 +02:00
2017-02-27 03:56:18 +00:00
if ( ! packName . isEmpty ( ) ) {
if ( ! gotTrigger ) {
mpHost - > getTriggerUnit ( ) - > unregisterTrigger ( mpTrigger ) ;
2014-09-27 02:36:11 -07:00
delete mpTrigger ;
2017-02-27 03:56:18 +00:00
}
if ( gotTimer ) { // packName is NOT empty for modules...!
mpTimer - > setIsActive ( true ) ;
mpTimer - > enableTimer ( mpTimer - > getID ( ) ) ;
} else {
mpHost - > getTimerUnit ( ) - > unregisterTimer ( mpTimer ) ;
2014-09-27 02:36:11 -07:00
delete mpTimer ;
2017-02-27 03:56:18 +00:00
}
if ( gotAlias ) {
mpAlias - > setIsActive ( true ) ;
} else {
mpHost - > getAliasUnit ( ) - > unregisterAlias ( mpAlias ) ;
2014-09-27 02:36:11 -07:00
delete mpAlias ;
2017-02-27 03:56:18 +00:00
}
if ( gotAction ) {
2026-06-27 00:25:01 +00:00
mpHost - > getActionUnit ( ) - > updateAllToolbars ( ) ;
2017-02-27 03:56:18 +00:00
} else {
mpHost - > getActionUnit ( ) - > unregisterAction ( mpAction ) ;
2014-09-27 02:36:11 -07:00
delete mpAction ;
2017-02-27 03:56:18 +00:00
}
if ( ! gotKey ) {
mpHost - > getKeyUnit ( ) - > unregisterKey ( mpKey ) ;
2014-09-27 02:36:11 -07:00
delete mpKey ;
2017-02-27 03:56:18 +00:00
}
if ( ! gotScript ) {
mpHost - > getScriptUnit ( ) - > unregisterScript ( mpScript ) ;
2014-09-27 02:36:11 -07:00
delete mpScript ;
2017-02-27 03:56:18 +00:00
}
2011-05-29 00:59:56 +02:00
}
2017-02-27 03:56:18 +00:00
2023-04-27 19:50:32 +02:00
return { ! hasError ( ) , errorString ( ) } ;
2009-02-06 03:39:14 +01:00
}
2017-10-10 23:03:57 -04:00
// returns the type of item and ID of the first (root) element
2025-12-11 09:50:15 +05:00
std : : pair < EditorViewType , int > XMLimport : : importFromClipboard ( )
2017-10-10 23:03:57 -04:00
{
QString xml ;
infrastructure: decouple the mapper engine from UI dialogs (#9513)
#### Brief overview of PR changes/additions
- Removes all raw Qt Widgets usage from the map engine: `TMap.{h,cpp}`
no longer owns a `QProgressDialog` (and drops a dead `QFileDialog`
include), and `XMLimport.{h,cpp}` no longer pulls in `QApplication` (the
clipboard read now uses `QGuiApplication::clipboard()`, which lives in
Qt Gui).
- The standalone map-progress dialog (shown when the mapper is not
visible, for map download / XML import and JSON export/import) is now
driven by Qt signals carrying pre-translated payloads; the frontend
(`TMainConsole`) owns the actual `QProgressDialog`, and a user cancel
returns to the engine through `TMap::slot_mapProgressDialogCancelled()`.
- Adds `MapProgressDialogSeamTest` covering the transfer-progress state
machine, a JSON export/import round trip driving the new signals, a
mid-import cancel delivered through the seam (the highest-risk change,
since the JSON reader used to poll `QProgressDialog::wasCanceled()`
synchronously), and an XML map import re-entered from inside a running
JSON operation.
#### Motivation for adding to Mudlet
Second concrete step of the re-scoped libmudlet plan (a Qt-Widgets-free
`mudlet_core` for headless use, testability and WASM). It copies the
seam template established in #9507: core emits a pre-translated payload
-> frontend owns the widget -> a callback slot returns the answer. The
Qt Widgets dependency audit (`cmake/audit-core-widgets.sh`) drops from
**151 to 147** offending files; `TMap.cpp`, `TMap.h`, `XMLimport.cpp`
and `XMLimport.h` are all now clean. The mapper-owned inline progress
path (`dlgMapper`/`T2DMap`, Mudlet's own widgets) is deliberately
untouched here - those move wholesale in the later target-split phase.
#### Other info (issues closed, discussion etc)
Part of #8681 / #9011. Existing translations are unaffected: every
progress string keeps its `TMap` `tr()` context, so current translations
carry straight over. Two new strings do arrive, both with `//:`
translator comments - the warnings shown when a map download or an XML
map import is refused because a JSON import/export is already running.
The JSON dialog stays non-modal and the download/import dialog keeps its
modeless styling, each applied by the frontend. The engine keeps its own
`mMapProgressStandalone` / `mMapProgressCancelRequested` /
`mMapProgressStandaloneMaximum` state to replace the widget read-backs
it used to do (`!= nullptr`, `wasCanceled()`, `maximum()`). If a map
operation ever reaches the engine before a console is wired (checked via
`isSignalConnected`), `TMap::warnIfMapProgressUnwired()` logs a loud
`qWarning` rather than silently running with no progress UI.
It also closes a latent null-dereference that exists on `development`
today. With the mapper visible a map download takes the inline-progress
path, leaving `mpProgressDialog` null - so a JSON export started
meanwhile sails past the `if (mpProgressDialog)` "already in progress"
check and creates a dialog of its own. When the download then finishes
inside the `processEvents()` pump the export is running,
`clearTransferProgress()` deletes and nulls *that* dialog, and the
export's next `incrementJsonProgressDialog()` dereferences null. The
engine now records whose dialog is up (`mMapProgressIsTransfer`) so a
transfer only ever closes its own, and `importMap()` refuses to start
while a JSON operation holds the progress - the mirror of the guard
`downloadMap()` has.
Two review-driven details worth flagging: the frontend only wires the
dialog's cancel to the engine when the operation is actually cancelable,
so a non-cancelable local XML import no longer turns a window-close into
a spurious "Map download was canceled" message; and the standalone
download/import dialog is now parented to the console (like the JSON one
always was, and like #9507's package-download dialog), so it centres on
and dies with the profile window. The three `#include <QApplication>`
additions to `Host.cpp` / `dlgTriggerEditor.cpp` /
`dlgConnectionProfiles.cpp` replace the transitive include they used to
get from `XMLimport.h`; all three are already Qt Widgets consumers, so
the audit count is unaffected.
Assisted-by: Claude:claude-opus-4-8
Assisted-by: Claude:claude-opus-5
**Test case:** With a mapper window open, use a game that supports map
download (or call `downloadMap()`) and confirm the progress dialog
shows, updates, and its Abort cancels the download. Then with the mapper
window closed, run `exportJsonMap()` and `importJsonMap()` on a large
map and confirm the non-modal JSON progress dialog appears, updates its
Areas/Rooms/Labels counts, and that clicking Abort during an import
stops it with an "aborted by user" result. Load a local XML map
(Settings -> Map -> load) and confirm closing its progress window does
not print a "Map download was canceled" line. Everything should behave
exactly as on `development`.
#### Demo (before & after)
https://github.com/user-attachments/assets/f1c62580-2d03-4e5b-a6ee-f6e2b78d113d
2026-08-02 15:33:07 +02:00
QClipboard * clipboard = QGuiApplication : : clipboard ( ) ;
2025-12-11 09:50:15 +05:00
std : : pair < EditorViewType , int > result ;
2017-10-10 23:03:57 -04:00
xml = clipboard - > text ( QClipboard : : Clipboard ) ;
QByteArray ba = xml . toUtf8 ( ) ;
QBuffer xmlBuffer ( & ba ) ;
setDevice ( & xmlBuffer ) ;
2025-12-24 09:50:24 +00:00
if ( ! xmlBuffer . open ( QIODevice : : ReadOnly ) ) {
qWarning ( ) < < " XMLimport::importFromClipboard() ERROR: failed to open XML buffer for reading " ;
return { EditorViewType : : cmUnknownView , 0 } ;
}
2017-10-10 23:03:57 -04:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " MudletPackage " ) ) {
2017-10-10 23:03:57 -04:00
result = readPackage ( ) ;
} else {
qDebug ( ) < < " ERROR:name= " < < name ( ) . toString ( ) < < " text: " < < text ( ) . toString ( ) ;
}
}
}
return result ;
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
void XMLimport : : readVariable ( TVar * pParent )
2013-06-09 12:25:52 -04:00
{
2017-04-09 19:49:02 +02:00
auto var = new TVar ( pParent ) ;
2013-06-09 12:25:52 -04:00
2017-02-27 03:56:18 +00:00
LuaInterface * lI = mpHost - > getLuaInterface ( ) ;
VarUnit * vu = lI - > getVarUnit ( ) ;
2013-06-09 12:25:52 -04:00
QString keyName , value ;
2013-08-19 12:25:26 +02:00
int keyType = 0 ;
int valueType ;
2017-02-27 03:56:18 +00:00
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2013-06-09 12:25:52 -04:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
}
2013-06-09 12:25:52 -04:00
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2013-06-09 12:25:52 -04:00
keyName = readElementText ( ) ;
continue ;
2026-07-18 18:39:57 +02:00
} else if ( name ( ) = = qsl ( " value " ) ) { // NOLINT(readability-else-after-return)
2013-06-09 12:25:52 -04:00
value = readElementText ( ) ;
continue ;
2026-07-18 18:39:57 +02:00
} else if ( name ( ) = = qsl ( " keyType " ) ) { // NOLINT(readability-else-after-return)
2017-02-27 03:56:18 +00:00
keyType = readElementText ( ) . toInt ( ) ;
2013-06-09 12:25:52 -04:00
continue ;
2026-07-18 18:39:57 +02:00
} else if ( name ( ) = = qsl ( " valueType " ) ) { // NOLINT(readability-else-after-return)
2013-06-09 12:25:52 -04:00
valueType = readElementText ( ) . toInt ( ) ;
2017-02-27 03:56:18 +00:00
var - > setName ( keyName , keyType ) ;
var - > setValue ( value , valueType ) ;
vu - > addSavedVar ( var ) ;
lI - > setValue ( var ) ;
2013-06-09 12:25:52 -04:00
continue ;
2026-07-18 18:39:57 +02:00
} else if ( name ( ) = = qsl ( " VariableGroup " ) | | name ( ) = = qsl ( " Variable " ) ) { // NOLINT(readability-else-after-return)
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readVariable ( var ) ;
} else {
readUnknownElement ( what ) ;
2013-06-09 12:25:52 -04:00
}
}
}
2017-04-03 06:31:42 +02:00
delete var ;
2013-06-09 12:25:52 -04:00
}
2013-06-16 22:26:27 -04:00
void XMLimport : : readHiddenVariables ( )
{
2017-02-27 03:56:18 +00:00
LuaInterface * lI = mpHost - > getLuaInterface ( ) ;
VarUnit * vu = lI - > getVarUnit ( ) ;
while ( ! atEnd ( ) ) {
2013-06-16 22:26:27 -04:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
}
2013-06-16 22:26:27 -04:00
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2023-05-14 15:06:15 +02:00
const QString var = readElementText ( ) ;
2017-02-27 03:56:18 +00:00
vu - > addHidden ( var ) ;
2013-06-16 22:26:27 -04:00
continue ;
}
}
}
}
2013-06-09 12:25:52 -04:00
void XMLimport : : readVariablePackage ( )
{
2017-02-27 03:56:18 +00:00
LuaInterface * lI = mpHost - > getLuaInterface ( ) ;
VarUnit * vu = lI - > getVarUnit ( ) ;
2013-06-09 12:25:52 -04:00
mpVar = vu - > getBase ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2013-06-09 12:25:52 -04:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " VariableGroup " ) | | name ( ) = = qsl ( " Variable " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readVariable ( mpVar ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " HiddenVariables " ) ) {
2017-02-27 03:56:18 +00:00
readHiddenVariables ( ) ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
} else {
readUnknownElement ( qsl ( " VariablePackage " ) ) ;
2013-06-16 22:26:27 -04:00
}
2013-06-09 12:25:52 -04:00
}
}
}
2010-01-22 01:45:34 +01:00
void XMLimport : : readMap ( )
{
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
QMultiHash < int , int > tempAreaRoomsHash ; // Keys: area id, Values: a room id in that area
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-08-25 00:41:43 +02:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " areas " ) ) {
2013-03-22 12:47:58 +01:00
mpHost - > mpMap - > mpRoomDB - > clearMapDB ( ) ;
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportStringToProgressDialog ( tr ( " Parsing area data... " ) ) ;
mpHost - > mpMap - > reportProgressToProgressDialog ( 0 , 3 ) ;
2010-08-25 00:41:43 +02:00
readAreas ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " rooms " ) ) {
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportStringToProgressDialog ( tr ( " Parsing room data... " ) ) ;
mpHost - > mpMap - > reportProgressToProgressDialog ( 1 , 3 ) ;
readRooms ( tempAreaRoomsHash ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " environments " ) ) {
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportStringToProgressDialog ( tr ( " Parsing environment data... " ) ) ;
mpHost - > mpMap - > reportProgressToProgressDialog ( 2 , 3 ) ;
2010-08-25 00:41:43 +02:00
readEnvColors ( ) ;
}
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportProgressToProgressDialog ( 3 , 3 ) ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
}
}
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportStringToProgressDialog ( tr ( " Assigning rooms to their areas... " ) ) ;
2023-05-14 15:06:15 +02:00
const int roomTotal = tempAreaRoomsHash . count ( ) ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
int currentRoomCount = 0 ;
2017-02-27 03:56:18 +00:00
QListIterator < int > itAreaWithRooms ( tempAreaRoomsHash . uniqueKeys ( ) ) ;
while ( itAreaWithRooms . hasNext ( ) ) {
2023-05-14 15:06:15 +02:00
const int areaId = itAreaWithRooms . next ( ) ;
2020-06-13 19:30:08 +02:00
auto values = tempAreaRoomsHash . values ( areaId ) ;
2023-05-14 15:06:15 +02:00
QSet < int > const areaRoomsSet { values . begin ( ) , values . end ( ) } ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
2017-02-27 03:56:18 +00:00
if ( ! mpHost - > mpMap - > mpRoomDB - > areas . contains ( areaId ) ) {
// It is known for map files to have rooms with area Ids that are
// not in the listed areas - this cures that:
mpHost - > mpMap - > mpRoomDB - > addArea ( areaId ) ;
Enhance: fix map downloading code, add manual XML map importing (#329)
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of time to actually parse an XML map file I have enhanced the
progress dialog that was originally used to track the map file download.
It is now retained until the file is completely imported and shows more
information about the process - importantly it shows during the
XMLimport::readRoom(...) a count of 100's of rooms processed. This dialog is now
also used during the other routes that involve reading an XML file and there
is now a bit of consistence with the on-screen messages. However errors for
the XML map file importing process as initiated from the Lua command are
generally returned to that command rather than plastered onto the main profile
console.
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 08:03:42 +01:00
}
2017-03-27 08:06:47 +02:00
mpHost - > mpMap - > mpRoomDB - > setAreaRooms ( areaId , areaRoomsSet ) ;
currentRoomCount + = areaRoomsSet . count ( ) ;
mpHost - > mpMap - > reportProgressToProgressDialog ( currentRoomCount , roomTotal ) ;
Enhance: fix map downloading code, add manual XML map importing (#329)
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of time to actually parse an XML map file I have enhanced the
progress dialog that was originally used to track the map file download.
It is now retained until the file is completely imported and shows more
information about the process - importantly it shows during the
XMLimport::readRoom(...) a count of 100's of rooms processed. This dialog is now
also used during the other routes that involve reading an XML file and there
is now a bit of consistence with the on-screen messages. However errors for
the XML map file importing process as initiated from the Lua command are
generally returned to that command rather than plastered onto the main profile
console.
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 08:03:42 +01:00
}
2010-08-25 00:41:43 +02:00
}
void XMLimport : : readEnvColors ( )
{
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-08-25 00:41:43 +02:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " environment " ) ) {
2010-08-25 00:41:43 +02:00
readEnvColor ( ) ;
}
}
}
void XMLimport : : readEnvColor ( )
{
2023-05-14 15:06:15 +02:00
const int id = attributes ( ) . value ( qsl ( " id " ) ) . toString ( ) . toInt ( ) ;
const int color = attributes ( ) . value ( qsl ( " color " ) ) . toString ( ) . toInt ( ) ;
2017-02-27 03:56:18 +00:00
Enhance: import/export map as JSON (#4546)
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>
2021-02-14 23:44:55 +00:00
mpHost - > mpMap - > mEnvColors [ id ] = color ;
2010-08-25 00:41:43 +02:00
}
void XMLimport : : readAreas ( )
{
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-08-25 00:41:43 +02:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " areas " ) ) {
2010-08-25 00:41:43 +02:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( name ( ) = = qsl ( " area " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
readArea ( ) ;
2010-08-25 00:41:43 +02:00
}
}
}
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
void XMLimport : : readArea ( )
2010-08-25 00:41:43 +02:00
{
2021-12-07 06:21:39 +01:00
if ( attributes ( ) . hasAttribute ( qsl ( " id " ) ) ) {
2023-05-14 15:06:15 +02:00
const int id = attributes ( ) . value ( qsl ( " id " ) ) . toString ( ) . toInt ( ) ;
const QString name = attributes ( ) . value ( qsl ( " name " ) ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
2021-03-30 23:57:10 +01:00
mpHost - > mpMap - > mpRoomDB - > addArea ( id , name ) ;
}
2010-08-25 00:41:43 +02:00
}
2017-02-27 03:56:18 +00:00
void XMLimport : : readRooms ( QMultiHash < int , int > & areaRoomsHash )
2010-08-25 00:41:43 +02:00
{
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
unsigned int roomCount = 0 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-01-22 01:45:34 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( Q_LIKELY ( isStartElement ( ) ) ) {
2021-12-07 06:21:39 +01:00
if ( Q_LIKELY ( name ( ) = = qsl ( " room " ) ) ) {
2017-02-27 03:56:18 +00:00
readRoom ( areaRoomsHash , & roomCount ) ;
} else {
2010-08-25 00:41:43 +02:00
readUnknownMapElement ( ) ;
2010-03-15 09:37:16 +01:00
}
2022-04-25 21:31:02 +01:00
} else if ( isEndElement ( ) & & name ( ) = = qsl ( " rooms " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
break ;
}
2010-08-25 00:41:43 +02:00
}
2010-01-22 01:45:34 +01:00
}
2022-04-25 21:31:02 +01:00
void XMLimport : : readRoomFeatures ( TRoom * pR )
{
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( Q_LIKELY ( isStartElement ( ) ) ) {
if ( name ( ) = = qsl ( " features " ) ) {
continue ;
2026-07-18 18:39:57 +02:00
}
if ( Q_LIKELY ( name ( ) = = qsl ( " feature " ) ) ) {
2022-04-25 21:31:02 +01:00
readRoomFeature ( pR ) ;
}
} else if ( isEndElement ( ) & & name ( ) = = qsl ( " features " ) ) {
break ;
}
}
}
void XMLimport : : readRoomFeature ( TRoom * pR )
{
if ( Q_LIKELY ( attributes ( ) . hasAttribute ( qsl ( " type " ) ) ) ) {
pR - > userData . insert ( qsl ( " feature-%1 " ) . arg ( attributes ( ) . value ( qsl ( " type " ) ) ) , qsl ( " true " ) ) ;
}
}
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
// This is a CPU/Time hog without the non-default (true) third argument to
// TRoomDB::addRoom(...)
2017-02-27 03:56:18 +00:00
void XMLimport : : readRoom ( QMultiHash < int , int > & areamRoomMultiHash , unsigned int * roomCount )
2010-01-22 01:45:34 +01:00
{
improve: improve memory safety by using smart pointers (#9239)
### Refactor: replace raw pointer ownership with smart pointers across
core subsystems
#### Brief overview of PR changes/additions
Replaces raw pointer ownership patterns with `std::unique_ptr` and
`std::map`
across several core subsystems:
- **Host**: `mStopWatchMap` (`QMap<int, stopWatch*>` → `std::map<int,
unique_ptr<stopWatch>>`), `profileShortcuts` (`QMap<QString,
QKeySequence*>` → `std::map<QString, unique_ptr<QKeySequence>>`).
Removes `qDeleteAll` in destructor and `delete mMMCPServer`.
- **TMap**: `mpRoomDB` raw pointer → `unique_ptr`
- **VarUnit**: `base` raw pointer → `unique_ptr`
- **TTrigger**: condition map storage converted to `unique_ptr`,
destructor simplified
- **discord**: handler and presence maps converted from raw pointer
`QMap` to `unique_ptr` + `std::map`
- **Updater**: `mFeed` and `mUpdateDialog` converted to `unique_ptr`
#### Motivation for adding to Mudlet
These patterns were identified as sources of memory leaks and potential
use-after-free bugs. Using smart pointers makes ownership explicit,
eliminates manual cleanup code, and ensures correct destruction even on
early-exit paths.
#### Other info (issues closed, discussion etc)
sorry this one is still pretty big, but most of the changes are the same
for each thing so reviewing them together probably makes sense. sadly
there isn't much to see here other than no slow uptick of heap size :-[
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:42:09 +12:00
auto pT = new TRoom ( mpHost - > mpMap - > mpRoomDB . get ( ) ) ;
2017-02-27 03:56:18 +00:00
2021-12-07 06:21:39 +01:00
pT - > id = attributes ( ) . value ( qsl ( " id " ) ) . toString ( ) . toInt ( ) ;
pT - > area = attributes ( ) . value ( qsl ( " area " ) ) . toString ( ) . toInt ( ) ;
pT - > name = attributes ( ) . value ( qsl ( " title " ) ) . toString ( ) ;
pT - > environment = attributes ( ) . value ( qsl ( " environment " ) ) . toString ( ) . toInt ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-01-22 01:45:34 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( Q_UNLIKELY ( pT - > id < 1 ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
continue ; // Skip further tests on exits as we'd have to throw away
2017-02-27 03:56:18 +00:00
// this invalid room and it would mess up the
// entranceMultiHash
2026-07-18 18:39:57 +02:00
}
if ( Q_LIKELY ( name ( ) = = qsl ( " exit " ) ) ) {
2021-12-07 06:21:39 +01:00
QString dir = attributes ( ) . value ( qsl ( " direction " ) ) . toString ( ) ;
2023-05-14 15:06:15 +02:00
const int e = attributes ( ) . value ( qsl ( " target " ) ) . toString ( ) . toInt ( ) ;
2022-04-25 21:31:02 +01:00
// If there is a "hidden" exit mark it as a locked door, otherwise
// if there is a "door" mark it as an open/closed/locked door
// depending on the value (I.R.E. MUD maps always uses "1" for "door"
// and/or "hidden" - though the latter does not always appear with
// former):
2023-05-14 15:06:15 +02:00
const int door = ( attributes ( ) . hasAttribute ( qsl ( " hidden " ) ) & & attributes ( ) . value ( qsl ( " hidden " ) ) . toString ( ) . toInt ( ) = = 1 ) ? 3
2022-04-25 21:31:02 +01:00
: ( attributes ( ) . hasAttribute ( qsl ( " door " ) ) & & attributes ( ) . value ( qsl ( " door " ) ) . toString ( ) . toInt ( ) > = 0 & & attributes ( ) . value ( qsl ( " door " ) ) . toString ( ) . toInt ( ) < = 3 )
? attributes ( ) . value ( qsl ( " door " ) ) . toString ( ) . toInt ( )
: 0 ;
2017-02-27 03:56:18 +00:00
if ( dir . isEmpty ( ) ) {
2022-04-25 21:31:02 +01:00
if ( attributes ( ) . value ( qsl ( " special " ) ) . toString ( ) . toInt ( ) = = 1 & & ! attributes ( ) . value ( qsl ( " command " ) ) . toString ( ) . isEmpty ( ) ) {
// This is how IRE XML maps mark special exits, rather than
// by just using a different string for the direction!
dir = attributes ( ) . value ( qsl ( " command " ) ) . toString ( ) ;
pT - > setSpecialExit ( e , dir ) ;
pT - > setDoor ( dir , door ) ;
} else {
continue ;
}
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " north " ) ) {
2010-08-25 00:41:43 +02:00
pT - > north = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " n " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " east " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > east = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " e " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " south " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > south = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " s " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " west " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > west = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " w " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " up " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > up = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " up " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " down " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > down = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " down " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " northeast " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > northeast = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " ne " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " southwest " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > southwest = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " sw " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " southeast " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > southeast = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " se " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " northwest " ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
pT - > northwest = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " nw " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " in " ) ) {
2010-08-25 00:41:43 +02:00
pT - > in = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " in " ) , door ) ;
2021-12-07 06:21:39 +01:00
} else if ( dir = = qsl ( " out " ) ) {
2010-08-25 00:41:43 +02:00
pT - > out = e ;
2022-04-25 21:31:02 +01:00
pT - > setDoor ( qsl ( " out " ) , door ) ;
2017-03-27 08:06:47 +02:00
}
2021-12-07 06:21:39 +01:00
} else if ( name ( ) = = qsl ( " coord " ) ) {
if ( attributes ( ) . value ( qsl ( " x " ) ) . toString ( ) . isEmpty ( ) ) {
2017-03-27 08:06:47 +02:00
continue ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
}
2024-12-09 14:29:13 +00:00
pT - > setCoordinates ( attributes ( ) . value ( qsl ( " x " ) ) . toString ( ) . toInt ( ) , attributes ( ) . value ( qsl ( " y " ) ) . toString ( ) . toInt ( ) , attributes ( ) . value ( qsl ( " z " ) ) . toString ( ) . toInt ( ) ) ;
Enhance: fix map downloading code, add manual XML map importing (#329)
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of time to actually parse an XML map file I have enhanced the
progress dialog that was originally used to track the map file download.
It is now retained until the file is completely imported and shows more
information about the process - importantly it shows during the
XMLimport::readRoom(...) a count of 100's of rooms processed. This dialog is now
also used during the other routes that involve reading an XML file and there
is now a bit of consistence with the on-screen messages. However errors for
the XML map file importing process as initiated from the Lua command are
generally returned to that command rather than plastered onto the main profile
console.
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 08:03:42 +01:00
continue ;
2022-04-25 21:31:02 +01:00
} else if ( name ( ) = = qsl ( " features " ) ) {
readRoomFeatures ( pT ) ;
2017-02-27 03:56:18 +00:00
} else if ( Q_UNLIKELY ( name ( ) . isEmpty ( ) ) ) {
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
continue ;
}
2022-04-25 21:31:02 +01:00
if ( isEndElement ( ) & & name ( ) = = qsl ( " room " ) ) {
2010-08-25 00:41:43 +02:00
break ;
}
}
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
2017-02-27 03:56:18 +00:00
if ( pT - > id > 0 ) {
2019-03-22 13:12:03 +01:00
if ( + + ( * roomCount ) % 100 = = 0 ) {
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > reportStringToProgressDialog ( tr ( " Parsing room data [count: %1]... " ) . arg ( * roomCount ) ) ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
}
2017-02-27 03:56:18 +00:00
areamRoomMultiHash . insert ( pT - > area , pT - > id ) ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
// We are loading a map so can make some optimisation by setting the
// third argument as true:
2017-02-27 03:56:18 +00:00
mpHost - > mpMap - > mpRoomDB - > addRoom ( pT - > id , pT , true ) ;
mMaxRoomId = qMax ( mMaxRoomId , pT - > id ) ; // Wasn't used but now maintains max Room Id
} else {
2010-08-25 00:41:43 +02:00
delete pT ;
Enhance: fix map downloading code, add manual XML map importing (#326)
* Enhance: fix map downloading code, add manual XML map importing
A recent move by I.R.E. to using SSL for their public MUD map URLs broke
the ability for Mudlet to download those XML format files. This commit
addresses this issue (as mentioned in, but not the original problem
referred to in https://bugs.launchpad.net/mudlet/+bug/1427364) the revision
to the code does now use "https://www.<MUD URL>/maps/map.xml" as a default
name for the I.R.E. MUDS - however the method that initiates the download
which was moved to TMap class from the dlgMapper one (see below) is now:
(bool) TMap::downloadMap( const QString * remoteUrl = Q_NULLPTR,
const QString * localFileName = Q_NULLPTR )
which if not supplied with any arguments behaves as before. However the
remoteUrl argument may be given as a full QString including the scheme (the
bit of the URL at the beginning before the ':') to override that and a
second argument may be used to provide a different name to use for the
local file name which if is a RELATIVE pathFileName will be resolved in
relation to the profile directory. At present no use is made of this
additional functionality but it may be useful for use with other MUDs if
they should choose to provide XML map files with other remote locations
and scripts using a different local filename.
As a long-standing thing that needed doing I have finally provided a means
to import a map XML file that - for instance - has already been download.
It had been noted that there was no way to read those I.R.E. map files even
if they had been obtained from a web browser able to correctly handle
https: URLs - now both the TLuaInterpreter::loadMap() and the
dlgProfilePreference "loadMap" button {NOT the IRE only "map download" one}
will both handle files ending in ".xml" (not case sensitive so it'll work
MacOS platforms as well!} For the loadMap case it will be necessary to
change the filetype filter on the File Selection dialog to select "xml"
files.
During testing it became clear to me that it was possible to try and read
one or more XML files via several mechanisms simultaneously with
"unhelpful" consequences. As well as hitting the dlgProfilePreferences
IRE "map download" multiple times, the TLuaInterpreter::loadMap() does NOT
block until the map has been loaded and as the import time {running of
XMLinport::readPackage(...)} is of significant duration for a large map (a
debug, without optimisation, build on my 1.8GHz Quad-core took over two
minutes to process the current Achaea map file) it is very possible to
get conditions where the same profile will try to run
XMLinport::readPackage(...) asynchronously - given that a profile only
supports ONE map at a time it was necessary to fit a QMutex to prevent
the part of the XMLinport class relating to XML Map files being called from
different places in the map related code. This means that if a map
download is started further downloads and any local map imports will fail
until that first download has completed or aborted. Similarly a local
import will prevent a download being started. As a side effect this cures:
https://bugs.launchpad.net/mudlet/+bug/852861 - "Map download button starts
another download thread if one is already going"
The previous XML import code was not adding the rooms that it parsed to the
relevant TArea::rooms member - although this would be picked-up and fixed
by TMap::audit() later on, this would be accompanied by an error message
about every single room. The code now builds up this information while
parsing the rooms' details and inserts it so that this does not cause
report-able problems during the TMap::audit() execution - the data gathered
also allows missing areas to be spotted so that if a room claimed to belong
to an area that was not included in the preceding areas' data an unnamed
area is created for it.
As a consequence of the long time to actually parse an XML map file I have
enhanced the progress dialog that was originally used to track the map file
download. It is now retained until the file is completely imported and
shows more information about the process - importantly it shows during the
XMLimport::readRoom(...) the room id being processed - and THAT method is
the time/cpu hog so seeing something happening during the time that Mudlet
otherwise appears to hang is useful feedback even if it adds a few seconds
to the overall duration (may be more than a minute). This dialog is now
also used during the other routes that involve reading an XML file and
there is now a bit of consistence with the on-screen messages.
Whilst inspecting XMLimport class I found there was some uncertain
initialisation which I have tidied up.
In summary:
Added:
* (bool) TConsole::importMap(const QString & location)
* (void) TRoomDB::setAreaRooms(const int areaId, const QSet<int> & roomIds)
* image file mudlet_map_download.png used as icon for download/import
progress dialog
* (bool) TMap::importMap(QFile & file)
* (bool) TMap::readXmlMapFile(QFile & file)
* (void) TMap::slot_downloadError(QNetworkReply::NetworkError error)
* (void) TMap::reportStringToProgressDialog(const QString text)
* (void) TMap::reportProgressToProgressDialog(const int current,
const int maximum)
Revised:
* (int)TLuaInterpreter::loadMap( lua_State * )
* Moved XML map download code from dlgMapper class to the TMap one:
+ (void) dlgMapper::downloadMap() ==>
(bool) TMap::downloadMap(const QString * remoteUrl,
const QString * localFileName)
+ (void) dlgMapper::setDownloadProgress(qint64, qint64) ==>
(void) TMap::slot_setDownloadProgress(qint64,qint64)
+ (void) dlgMapper::cancel() ==> (void) TMap::slot_downloadCancel()
+ (void) dlgMapper::replyFinished(QNetworkReply *) ==>
(void) TMap::slot_replyFinished(QNetworkReply *)
* Enhanced download progress indication to also include parsing which can
take even more time than download!
* Provide means to import local XML map file
* Prevent trying to import/download more than one map at a time
Renamed:
* (void) XMLimport::readAreaNames() ==> XMLimport::readArea() - for
consistency with related functions
Commented out unused:
* (void) XMLimport::readUnknownRoomElement()
Note the movement of the map file download code to the TMap class does
require making the latter a class with the Q_OBJECT macro (which removes
the need for Q_DECLARE_TR_FUNCTIONS as a side-effect!) - though as
another side-effect the TMap header needed a boost name specifier added to
one identifier as that identifier ("property") exists in both boost and
QObject classes!!! YOU MAY NEED TO RUN QMAKE ON THE PROJECT IF THE
BUILD SYSTEM DOES NOT PICK UP THE ADDITION OF "Q_OBJECT" TO TMAP CLASS.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: Include missing #include, remove unused return value
The absence of this was causing build errors on the Travis C.I. platform!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: move TMap.h to mudlet_MOC_HDRS to fix CMake build issue
As we have made TMap inherit from QOject - to have signal/slot
functionality that class needs to be run through Qt's MOC - and to do that
with the CMake project/build system it needs to be included in the files
included in the projects *_MOC_HDRS {and removed from the *_HDRS} variable.
Also spotted a trivial error in that specifying a const return value from
method is ineffective and pointless - so removed it from:
TMap::retrieveMapFileStats(QString,QString *,int *,int *,int *,int *)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: clean up TMap initialisation/clearing actions
Now restores the customEnvColors set up on initialisation but that was
cleared when the map replaced with another one that is loaded {which
subsequently replaces that element anyway} or imported {which merely
writes over it, replacing any matching keys}. Initialises elements that
when inspected on the entry to the constructor proper previously were not
being set to a consistent value {booleans/ints/floats}.
NOTE: This will now clear the map user data member when the map is cleared
if the date is required to be saved when one map is loaded OR IMPORTED over
an existing one then the data will need to be saved outside of the map - as
is already need for areas and rooms user data!
Also comment out or remove unused members/methods:
* (void) TMap::getConnectedNodesGreaterThanX(int, int)
* (void) TMap::getConnectedNodesSmallerThanX(int, int)
* (void) TMap::getConnectedNodesGreaterThanY(int, int)
* (void) TMap::getConnectedNodesSmallerThanY(int, int)
* (void) TMap::astBreitenAnpassung(int, int)
* (void) TMap::astHoehenAnpassung(int, int)
* (void) TMap::exportMapToDatabase()
* (void) TMap::importMapFromDatabase()
* (QVector3D) TMap::span
* (int) TMap::mViewArea
* (QMap<QString, int>) TMap::pixNameTable
* (QMap<int, QPixmap>) TMap::pixTable
* (bool) TMap::isToDisplayAuditErrorsToConsole
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* ImplimentationFixes: activate a valid optimisation & remove redundant code
Adding a true as a non-default 3rd argument to TRoomDB::addRoom(...) call
in XMLimport::readRoom(...) enables a significant optimisation (skips a
computationally expensive step when ADDING a room to new map) which
dramatically reduces the time to parse an XML map file. It also pointed
to the fact that the TRoomDB::entranceMap was already correctly being
handled and didn't need to be regenerated in XMLimport::readRoom(...) so
the code that was added in a previous commit was redundant and could be
removed.
A code error in TMap::slot_setDownloadProgress(...) that caused an issue
that a reviewer found on test has been fixed - the total download filesize
that was being sent by the Qt system signal that is connected to this slot
was a -1 value (as IS DOCUMENTED) when the Qt system does NOT know the
size of a QNetworkReply in advance of reaching the end of the download was
incorrectly handled in a previous commit in this change set.
Also found during testing that there is no need for an error message for
the QNetworkReply::OperationCanceledError case in
TMap::slot_replayFinished(...) as it is already handled in the
TMap::slot_downloadCancel() slot.
Changed the text put up onto the progress widget during the XML room
parsing to be a room count - which is likely more useful and to only do it
for every hundredth room - which reduces any delay "wasted" in writing to
the display - combined, the effects seem satisfactory IMHO.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: provide error messages for TLuaInterpreter::loadMap(...)
Errors for the XML map file importing process as initiated from the Lua
command should be returned to that command rather than plastered onto the
main profile console - this commit attempts to perform that effect.
In testing found that there was no error handling for failure to find or
open the nominated file so messages for that have been added as well.
Due to the previous program logic the action of creating a mapper widget
using the main toolbar button automatically loaded the "default" (the
newest Mudlet Map file format file from the currently active profile's map
sub-directory). Under some previous situations it looked as though a map
might be loaded twice as mudlet::slot_mapper() was called both directly and
via signal/slot action. These were resolved by turning that slot into a
wrapper that now calls the body of code formerly within to a new method
mudlet::createMapper( bool isToLoadDefaultMapFile = true ) with a
the default value as an argument. This allows other usages of the body of
code to be called directly with a suitable argument, which for the
TConsole::loadMap() & TConsole::importMap() and the
dlgProfilePreferences::downloadMap() cases is false as they are all do not
want the "default" map!
Also:
* spotted a word "area" missing from an advisory text in
TRoom::auditRooms(...).
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Tweak: fix minor bug, correct a spelling, undo a few capitalisations
Under certain, unanticipated (error with no error message) conditions
TLuaInterpreter::loadMap(...) would push both a nil and then a false value
onto the stack for return {wrong} but only indicate one value {correct}.
The textual matters were found during peer review.
off-by: Stephen Lyons <slysven@virginmedia.com>
2016-10-13 09:18:48 +01:00
}
2010-01-22 01:45:34 +01:00
}
void XMLimport : : readUnknownMapElement ( )
{
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2010-01-22 01:45:34 +01:00
readNext ( ) ;
2010-08-25 00:41:43 +02:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2010-08-25 00:41:43 +02:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownMapElement ( ) ;
2010-08-25 00:41:43 +02:00
}
}
}
2017-10-10 23:03:57 -04:00
// returns the type of item and ID of the first (root) element
2025-12-11 09:50:15 +05:00
std : : pair < EditorViewType , int > XMLimport : : readPackage ( )
2009-02-06 03:39:14 +01:00
{
2025-12-11 09:50:15 +05:00
EditorViewType objectType = EditorViewType : : cmUnknownView ;
2017-10-10 23:03:57 -04:00
int rootItemID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-06 03:39:14 +01:00
readNext ( ) ;
2009-03-01 13:51:33 +01:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " HostPackage " ) ) {
2009-02-08 06:30:23 +01:00
readHostPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " TriggerPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmTriggerView ;
2017-10-10 23:03:57 -04:00
rootItemID = readTriggerPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " TimerPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmTimerView ;
2017-10-10 23:03:57 -04:00
rootItemID = readTimerPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " AliasPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmAliasView ;
2017-10-10 23:03:57 -04:00
rootItemID = readAliasPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " ActionPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmActionView ;
2017-10-10 23:03:57 -04:00
rootItemID = readActionPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " ScriptPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmScriptView ;
2017-10-10 23:03:57 -04:00
rootItemID = readScriptPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " KeyPackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmKeysView ;
2017-10-10 23:03:57 -04:00
rootItemID = readKeyPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " HelpPackage " ) ) {
2012-12-29 02:31:53 +01:00
readHelpPackage ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " VariablePackage " ) ) {
2025-12-11 09:50:15 +05:00
objectType = EditorViewType : : cmVarsView ;
2013-06-09 12:25:52 -04:00
readVariablePackage ( ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " MudletPackage " ) ) ;
2009-02-06 03:39:14 +01:00
}
}
}
2021-02-22 08:06:06 +01:00
return { objectType , rootItemID } ;
2009-02-06 03:39:14 +01:00
}
2017-02-27 03:56:18 +00:00
void XMLimport : : readHelpPackage ( )
{
while ( ! atEnd ( ) ) {
2012-12-29 02:31:53 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2012-12-29 02:31:53 +01:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " helpURL " ) ) {
2023-05-14 15:06:15 +02:00
const QString contents = readElementText ( ) ;
2012-12-29 02:31:53 +01:00
mpHost - > moduleHelp [ mPackageName ] . insert ( " helpURL " , contents ) ;
}
}
}
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
// Will be on a startElement on entry, and on the matching endElement
// at exit:
void XMLimport : : readUnknownElement ( const QString & what )
2009-02-06 03:39:14 +01:00
{
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
if ( ! atEnd ( ) ) {
qDebug ( ) . nospace ( ) . noquote ( ) < < " XMLimport::readUnknownElement( \" " < < what < < " \" ) ERROR - UNKNOWN Package Element name: \" " < < name ( ) . toString ( ) < < " \" . " ;
qDebug ( ) . nospace ( ) . noquote ( ) < < " This is at byte offset: " < < characterOffset ( ) < < " , which is (line:column): " < < lineNumber ( ) < < " : " < < columnNumber ( ) < < " . " ;
# if !defined(QT_STRICT_ITERATORS)
if ( attributes ( ) . isEmpty ( ) ) {
qDebug ( ) . nospace ( ) . noquote ( ) < < " It has no attributes. " ;
} else {
// This can fail if QT_STRICT_ITERATORS is defined.
// See https://bugreports.qt.io/browse/QTBUG-45368
QVectorIterator < QXmlStreamAttribute > itAttribute ( attributes ( ) ) ;
qDebug ( ) . nospace ( ) . noquote ( ) < < " It has the following attributes: " ;
while ( itAttribute . hasNext ( ) ) {
const auto attribute = itAttribute . next ( ) ;
qDebug ( ) . nospace ( ) . noquote ( ) < < " name: \" " < < attribute . name ( ) < < " \" , value: \" " < < attribute . value ( ) < < " \" . " ;
}
2009-02-08 06:30:23 +01:00
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
# endif
// The argument to readElementText(...) is required otherwise it stops
// if a child element is encountered, the third alternative
// "IncludeChildElements" is not so helpful as it might seem as it only
// includes some of the intervening content from sub-elements. As it is
// this should advance the current position to the EndElement of the
// unexpected startElement:
qDebug ( ) . nospace ( ) . noquote ( ) < < " The (text) content is: \" " < < readElementText ( QXmlStreamReader : : SkipChildElements ) < < " \" " ;
2009-02-08 06:30:23 +01:00
}
}
2017-02-27 03:56:18 +00:00
void XMLimport : : readHostPackage ( )
{
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " Host " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readHost ( mpHost ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " HostPackage " ) ) ;
2017-02-27 03:56:18 +00:00
}
}
}
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
void XMLimport : : readHost ( Host * pHost )
2017-02-27 03:56:18 +00:00
{
2025-07-02 07:59:22 -04:00
// This is an inline helper function to get a boolean value from a legacy attribute
// or return a default value. It also allows for inverting the result which is useful
// for attributes that have been negated in the past (e.g., mFORCE_MXP_NEGOTIATION_OFF
Improve: Move CHARSET and NEW-ENVIRON protocol settings to General tab (#8365)
#### Brief overview of PR changes/additions
Moved the CHARSET and NEW-ENVIRON protocol checkboxes from the Special
Options tab to the General tab's protocol menu, alongside other protocol
settings like GMCP, MSDP, and MXP. Protocol menu items are now sorted
alphabetically for easier navigation.
#### Motivation for adding to Mudlet
This change improves consistency in the UI by grouping all protocol
settings together in one location. Users can now find and manage all
telnet protocol options (CHARSET, NEW-ENVIRON, GMCP, MSDP, MSSP, MSP,
MXP, MTTS, MNES) in a single, organized dropdown menu on the General
tab.
The migration follows the same pattern established in PRs #7862 and
#7916, ensuring backward compatibility with existing profiles and Lua
scripts.
#### Other info (issues closed, discussion etc)
- Follows the migration pattern from PRs #7862 (MXP) and #7916
- Maintains full backward compatibility with existing profiles
(automatic XML migration)
- Lua API compatibility preserved for scripts using old config keys
- All protocols now appear alphabetically in the UI menu
<img width="518" height="234" alt="Screenshot 2025-10-18 at 8 05 37 AM"
src="https://github.com/user-attachments/assets/34ca0cac-f15b-4908-8471-a964dfd64c22"
/>
2025-10-21 05:01:24 -04:00
// which is now mEnableMXP, mFORCE_CHARSET_NEGOTIATION_OFF which is now mEnableCHARSET,
// and forceNewEnvironNegotiationOff which is now mEnableNEWENVIRON).
2025-07-02 07:59:22 -04:00
auto getBoolValueFromLegacyAttributeOrDefault = [ & ] ( const QString & legacyAttribute , const bool defaultsTo , bool invert = false ) - > bool {
if ( attributes ( ) . hasAttribute ( legacyAttribute ) ) {
bool value = attributes ( ) . value ( legacyAttribute ) = = YES ;
return invert ? ! value : value ;
}
2025-11-25 18:10:28 +01:00
return defaultsTo ;
2025-07-02 07:59:22 -04:00
} ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
auto setBoolAttributeWithDefault = [ & ] ( const QString & attribute , bool & target , const bool defaultsTo ) {
target = attributes ( ) . hasAttribute ( attribute ) ? attributes ( ) . value ( attribute ) = = YES : defaultsTo ;
} ;
auto setBoolAttribute = [ & ] ( const QString & attribute , bool & target ) {
target = attributes ( ) . value ( attribute ) = = YES ;
} ;
setBoolAttributeWithDefault ( qsl ( " announceIncomingText " ) , pHost - > mAnnounceIncomingText , true ) ;
setBoolAttributeWithDefault ( qsl ( " advertiseScreenReader " ) , pHost - > mAdvertiseScreenReader , false ) ;
improve: OSC 8 hyperlink handling, and a setting to turn it off (#9731)
#### Brief overview of PR changes/additions
- Hardens how OSC 8 link payloads and link text are handled before they
are run or displayed; link commands are no longer built by
string-formatting remote text into Lua source.
- Adds a per-profile setting (General → Game protocols) to turn OSC 8
hyperlinks off, which also reports `0` for every `OSC_HYPERLINKS*`
NEW-ENVIRON variable and sends an INFO update if toggled mid-session.
- Fixes `selected=` callbacks on `send:` links, which never fired, and
keeps emoji and Persian/Arabic/Indic text intact in tooltips and menu
labels.
#### Motivation for adding to Mudlet
Inspired by
[conversation](https://discord.com/channels/279748146316312576/1416447642472284261/1535109010066251890)
on the MUD Discord and updates to terminal emulators.
OSC 8 sequences arrive from the game server — and often from another
player whose say/tell text the server relays — so they have to be
treated as untrusted input rather than as content the user chose to
load.
#### Other info (issues closed, discussion etc)
New unit tests: `LuaLiteralTest` (28 cases, including an exhaustive
sweep over the bracket alphabet, each evaluated in a real Lua 5.1 state)
and `UntrustedTextTest` (26 cases covering emoji sequences, non-Latin
shaping and the two sanitization policies). There is no automated
NEW-ENVIRON coverage anywhere in the repo, so that path was verified
manually against a live server instead.
**Test case:**
1. `say !osc8-docs` — every documented feature still works.
2. Send a link whose command ends in `]`, e.g. `send:say [OOC]` —
clicking sends the literal text (previously the click silently did
nothing).
3. Settings → General → Game protocols → uncheck "Enable OSC 8
hyperlinks from the server" — links stop rendering and the server is
told without a reconnect; re-check and they return.
4. Send a tooltip or menu label containing a multi-part emoji such as
👨🍳 — it renders normally, not as its component parts.
---------
Signed-off-by: Michael Conley <sousesider@gmail.com>
2026-08-08 04:09:32 -04:00
setBoolAttributeWithDefault ( qsl ( " enableOSC8Hyperlinks " ) , pHost - > mEnableOSC8Hyperlinks , true ) ;
2025-05-13 05:55:43 -04:00
setBoolAttributeWithDefault ( qsl ( " enableClosedCaption " ) , pHost - > mEnableClosedCaption , false ) ;
Improve: New Environ and MNES Support (#7058)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
To enhance player experience and simplify the onboarding of accessible
users by sharing more client supported detail, support for two protocols
are requested to be added to Mudlet. In particular, knowing through
information exchange that a client supports UTF-8, TRUECOLOR, and an
opt-in indicator of screen reader use, may ease initial setup and
increase the stay rate for new gaming community members.
[Mudlet Area 51
Reference](https://wiki.mudlet.org/w/Area_51#NEW-ENVIRON.2C_PR_.237058)
##### Implemented [Telnet New-Environ
Option](https://www.rfc-editor.org/rfc/rfc1572.txt) (39):
* Added `Force NEW_ENVIRON Negotiation Off` to the Special Options menu
* Negotiate `NEW_ENVIRON` when prompted by the server
* Enable servers to request `SEND` updates, individually or in bulk for:
* Well-know variables: ~~`SYSTEMTYPE`, `USER`~~
* User variables: `CHARSET`, `CLIENT_NAME`, `CLIENT_VERSION`, `MTTS`,
`TERMINAL_TYPE`, `IPADDRESS`, `ANSI`, `VT100`, `256_COLORS`,
`MOUSE_TRACKING`, `UTF-8`, `OSC_COLOR_PALETTE`, `SCREEN_READER`,
`PROXY`, `TRUECOLOR`, `TLS`, ~~`LANGUAGE`, `FONT`, `FONT_SIZE`,~~
`WORD_WRAP`
* Enable servers to receive `INFO` updates for known variables,
previously replied with an `IS` and not undefined:
* `CHARSET` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `MTTS` changes status (see CHARSET and SCREEN_READER)
* `UTF-8` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `SCREEN_READER` changes status (Accessibility menu)
* ~~`LANGUAGE` changes (General menu)~~
* ~~`FONT` and `FONT_SIZE` changes (Main display menu)~~
* `WORD_WRAP` changes (Main display menu)
##### Implemented [Mud New Environment
Standard](https://tintin.mudhalla.net/protocols/mnes/) (39 as MNES):
* Added `Enable MNES` to the General menu (defaults disabled)
* Removed `Force MTTS Negotiation Off` from the Special Options menu
* Added `Enable MTTS` to the General menu (defaults enabled, still)
* Negotiate `NEW_ENVIRON (MNES)` when prompted by the server
* Enable servers to request `SEND` updates, individually or in bulk for:
* MNES variables: `CHARSET`, `CLIENT_NAME`, `CLIENT_VERSION`, `MTTS`,
`TERMINAL_TYPE`, `IPADDRESS`
* Enable servers to receive `INFO` updates for known variables,
previously replied with an `IS` and not undefined:
* `CHARSET` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `MTTS` changes status (General menu, Accessibility menu, and see
CHARSET)
Example of **Telnet New-Environ Option** requests from game servers:
```
IAC SB NEW_ENVIRON SEND VAR "UTF-8" IAC SE // Request one USERVAR variable
IAC SB NEW_ENVIRON SEND USERVAR "CHARSET" VAR "UTF-8" IAC SE // Request multiple variables
IAC SB NEW_ENVIRON SEND "CHARSET" USERVAR IAC SE // Request CHARSET and all of the well-known USERVAR variables (see a duplicate CHARSET, this is per the RFC)
IAC SB NEW_ENVIRON SEND USERVAR IAC SE // Request all the USERVAR variables (a large list like above)
IAC SB NEW_ENVIRON SEND VAR USERVAR IAC SE // Request all the variables
IAC SB NEW_ENVIRON SEND IAC SE // Request all the variables
```
High level example of **Telnet New-Environ Option** data from Mudlet:
```
VAR `SYSTEMTYPE` VAL `MACOS`
VAR `USER` VAL `tamarindo`
USERVAR `256_COLORS` VAL `1`
USERVAR `ANSI` VAL `1`
USERVAR `CHARSET` VAL `UTF-8`
USERVAR `CLIENT_NAME` VAL `MUDLET`
USERVAR `CLIENT_VERSION` VAL `4/17/2-DEV`
USERVAR `MTTS` VAL `2349`
USERVAR `OSC_COLOR_PALETTE` VAL `1`
USERVAR `SCREEN_READER` VAL `0`
USERVAR `TERMINAL_TYPE` VAL `ANSI-TRUECOLOR`
USERVAR `TLS` VAL `1`
USERVAR `TRUECOLOR` VAL `1`
USERVAR `UTF-8` VAL `1`
USERVAR `VT100` VAL `0`
USERVAR `WORD_WRAP` VAL `100`
```
Example of **Mud New Environment Standard** requests from game servers:
```
IAC SB NEW_ENVIRON SEND VAR "CHARSET" IAC SE // Request one variable
IAC SB NEW_ENVIRON SEND VAR "CHARSET" VAR "MTTS" IAC SE // Request more than one variable
IAC SB NEW_ENVIRON SEND VAR IAC SE // Request all variables
IAC SB NEW_ENVIRON SEND IAC SE // Request all variables
```
High level example of **Mud New Environment Standard** data from Mudlet:
```
VAR `CHARSET` VAL `UTF-8`
VAR `CLIENT_NAME` VAL `MUDLET`
VAR `CLIENT_VERSION` VAL `4/17/2-DEV`
VAR `MTTS` VAL `2861`
VAR `TERMINAL_TYPE` VAL `ANSI-TRUECOLOR`
```
#### Motivation for adding to Mudlet
Get updates that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, SCREEN_READER)
#### Other info (issues closed, discussion etc)
[Mudlet Area 51
Reference](https://wiki.mudlet.org/w/Area_51#NEW-ENVIRON.2C_PR_.237058)
---------
Co-authored-by: Marco Fontani <mfontani@cpan.org>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2024-01-05 09:31:56 -05:00
setBoolAttributeWithDefault ( qsl ( " mEnableMTTS " ) , pHost - > mEnableMTTS , true ) ;
setBoolAttributeWithDefault ( qsl ( " mEnableMNES " ) , pHost - > mEnableMNES , false ) ;
2025-07-02 07:59:22 -04:00
setBoolAttributeWithDefault ( qsl ( " mEnableMXP " ) , pHost - > mEnableMXP , getBoolValueFromLegacyAttributeOrDefault ( qsl ( " mFORCE_MXP_NEGOTIATION_OFF " ) , true , true ) ) ;
2025-12-29 02:57:45 -05:00
setBoolAttributeWithDefault ( qsl ( " mEnableNAWS " ) , pHost - > mEnableNAWS , true ) ;
add option to undo the game's own line wrapping (#9455)
https://github.com/user-attachments/assets/49e8a176-899c-43fd-a931-6e04ab5b5efb
#### Brief overview of PR changes/additions
New opt-in profile option that rejoins lines the game hard-wrapped
itself, so triggers see the whole logical line and Mudlet's own wrapping
handles display. Enable in Settings → Main display, or
`setConfig("undoServerWrap", true)`. Prompts, blank lines, MXP `<br>`
and script-fed text never join, and prose/indentation gates keep ASCII
art, menus and tables intact. A one-time callout points the option out,
and games that look like they wrap raise a one-time hint with a
click-to-enable link.
#### Motivation for adding to Mudlet
On games that can't disable server-side wrapping, triggers need fragile
multiline patterns. This fixes it client-side - as far as we know, a
first among MUD clients.
#### Other info (issues closed, discussion etc)
Tests added.
---------
Signed-off-by: Vadim Peretokin <vadim.peretokin@mudlet.org>
2026-07-20 22:45:10 +02:00
setBoolAttributeWithDefault ( qsl ( " mUndoServerWrap " ) , pHost - > mUndoServerWrap , false ) ;
setBoolAttributeWithDefault ( qsl ( " mServerWrapHintShown " ) , pHost - > mServerWrapHintShown , false ) ;
Improve: Move CHARSET and NEW-ENVIRON protocol settings to General tab (#8365)
#### Brief overview of PR changes/additions
Moved the CHARSET and NEW-ENVIRON protocol checkboxes from the Special
Options tab to the General tab's protocol menu, alongside other protocol
settings like GMCP, MSDP, and MXP. Protocol menu items are now sorted
alphabetically for easier navigation.
#### Motivation for adding to Mudlet
This change improves consistency in the UI by grouping all protocol
settings together in one location. Users can now find and manage all
telnet protocol options (CHARSET, NEW-ENVIRON, GMCP, MSDP, MSSP, MSP,
MXP, MTTS, MNES) in a single, organized dropdown menu on the General
tab.
The migration follows the same pattern established in PRs #7862 and
#7916, ensuring backward compatibility with existing profiles and Lua
scripts.
#### Other info (issues closed, discussion etc)
- Follows the migration pattern from PRs #7862 (MXP) and #7916
- Maintains full backward compatibility with existing profiles
(automatic XML migration)
- Lua API compatibility preserved for scripts using old config keys
- All protocols now appear alphabetically in the UI menu
<img width="518" height="234" alt="Screenshot 2025-10-18 at 8 05 37 AM"
src="https://github.com/user-attachments/assets/34ca0cac-f15b-4908-8471-a964dfd64c22"
/>
2025-10-21 05:01:24 -04:00
setBoolAttributeWithDefault ( qsl ( " mEnableCHARSET " ) , pHost - > mEnableCHARSET , getBoolValueFromLegacyAttributeOrDefault ( qsl ( " mFORCE_CHARSET_NEGOTIATION_OFF " ) , true , true ) ) ;
setBoolAttributeWithDefault ( qsl ( " mEnableNEWENVIRON " ) , pHost - > mEnableNEWENVIRON , getBoolValueFromLegacyAttributeOrDefault ( qsl ( " forceNewEnvironNegotiationOff " ) , true , true ) ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " autoClearCommandLineAfterSend " ) , pHost - > mAutoClearCommandLineAfterSend ) ;
2025-10-19 07:43:58 -04:00
setBoolAttributeWithDefault ( qsl ( " disablePasswordMasking " ) , pHost - > mDisablePasswordMasking , false ) ;
2025-10-21 15:11:09 +01:00
Fix: Show sent commands -> Always / Script Controlled / Never (#7881)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This PR enhances the "Show the text you sent" setting from a simple
boolean checkbox to a tri-state system, providing more granular control
over command echoing behavior while maintaining complete backward
compatibility.
**New Options:**
- **Never**: Commands are never shown on screen, regardless of script
settings
- **Script controlled** (Default): Scripts can control visibility using
`send(cmd, true/false)`
- **Always**: Commands are always shown on screen, regardless of script
settings
**Key Changes:**
- Replaced `bool mPrintCommand` with `enum class CommandEchoMode`
(Never=0, ScriptControl=1, Always=2)
- Enhanced `send()` function logic to respect the new tri-state mode
- Updated UI from checkbox to combo box with descriptive tooltips
- Implemented automatic migration from legacy boolean settings
- Enhanced Lua API with dual-mode backward compatibility

#### Motivation for adding to Mudlet
Resolves the inconsistent behavior reported in #6919 where `send(cmd,
false)` could suppress echo regardless of the global setting, but
`send(cmd, true)` could not show text if the global setting was
disabled.
**Problems Solved:**
1. **API Consistency**: Both `true` and `false` parameters to `send()`
now properly override global settings when appropriate
2. **User Control**: Users can choose between three clear modes instead
of confusing boolean behavior
3. **Script Safety**: Packages can provide critical feedback to users
even when global echo is disabled
4. **Backward Compatibility**: All existing scripts and profiles
continue to work unchanged
**Use Cases Addressed:**
- Users who never want to see commands (accessibility, clean interface)
- Users who want full script control (current behavior, new default)
- Users who always want to see commands (debugging, transparency)
- Package authors who need to ensure important messages are visible
#### Other info (issues closed, discussion etc)
**Closes:** #6919
**Backward Compatibility Strategy:**
- Legacy profile files: `printCommand="yes"` → ScriptControl,
`printCommand="no"` → Never
- Legacy Lua API: `getConfig("showSentText")` returns boolean
(true/false) for existing scripts
- Enhanced Lua API: `getConfig("showSentText", true)` returns string
("never"/"script"/"always") for new scripts
- Universal `setConfig()`: Accepts both boolean and string values with
automatic conversion
**Migration Path:**
- Existing scripts work unchanged - no breaking changes
- Profile settings automatically converted on load using
`getBoolValueFromLegacyAttributeOrDefault`
- XML export includes both new and legacy attributes for compatibility
**Implementation Details:**
- Uses existing `getBoolValueFromLegacyAttributeOrDefault` helper for
seamless profile migration
- Maintains all existing `send()` behavior in ScriptControl mode (new
default)
- Command line echo logic updated to respect tri-state mode
- Complete test coverage for all three modes and migration scenarios
**Testing:**
- All existing functionality preserved and tested
- New tri-state behavior verified for each mode
- Legacy profile migration tested with real profile files
- Lua API backward compatibility confirmed with existing script patterns
This hybrid approach addresses all concerns raised in the original PR
discussion while providing a clear upgrade path that satisfies both user
control advocates and script compatibility requirements.
---
### Show sent commands: Never
| Command | Displays |
| --- | --- |
| `send("smile", true)` | You smile 😄 |
| `send("smile", false)` | You smile 😄 |
### Show sent commands: Script controlled
| Command | Displays |
| --- | --- |
| `send("smile", true)` | smile |
| | You smile 😄 |
| `send("smile", false)` | You smile 😄 |
### Show sent commands: Always
| Command | Displays |
| --- | --- |
| `send("smile", true)` | smile |
| | You smile 😄 |
| `send("smile", false)` | smile |
| | You smile 😄 |
---
https://github.com/user-attachments/assets/f747329a-e9e2-4cff-b87a-333acca031ca
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-15 07:46:51 -04:00
// Handle command echo mode with backward compatibility
if ( attributes ( ) . hasAttribute ( qsl ( " commandEchoMode " ) ) ) {
// New tri-state attribute
int echoMode = attributes ( ) . value ( qsl ( " commandEchoMode " ) ) . toInt ( ) ;
pHost - > mCommandEchoMode = static_cast < Host : : CommandEchoMode > ( qBound ( 0 , echoMode , 2 ) ) ;
} else {
// Legacy boolean attribute - convert to new enum
bool legacyPrintCommand = getBoolValueFromLegacyAttributeOrDefault ( qsl ( " printCommand " ) , true ) ;
pHost - > mCommandEchoMode = legacyPrintCommand ? Host : : CommandEchoMode : : ScriptControl : Host : : CommandEchoMode : : Never ;
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " mUSE_FORCE_LF_AFTER_PROMPT " ) , pHost - > mUSE_FORCE_LF_AFTER_PROMPT ) ;
setBoolAttribute ( qsl ( " mUSE_UNIX_EOL " ) , pHost - > mUSE_UNIX_EOL ) ;
setBoolAttribute ( qsl ( " runAllKeyMatches " ) , pHost - > getKeyUnit ( ) - > mRunAllKeyMatches ) ;
setBoolAttribute ( qsl ( " mNoAntiAlias " ) , pHost - > mNoAntiAlias ) ;
setBoolAttribute ( qsl ( " mEchoLuaErrors " ) , pHost - > mEchoLuaErrors ) ;
setBoolAttribute ( qsl ( " mRawStreamDump " ) , pHost - > mIsNextLogFileInHtmlFormat ) ;
setBoolAttribute ( qsl ( " mIsLoggingTimestamps " ) , pHost - > mIsLoggingTimestamps ) ;
setBoolAttribute ( qsl ( " mAlertOnNewData " ) , pHost - > mAlertOnNewData ) ;
setBoolAttribute ( qsl ( " mFORCE_NO_COMPRESSION " ) , pHost - > mFORCE_NO_COMPRESSION ) ;
setBoolAttribute ( qsl ( " mFORCE_GA_OFF " ) , pHost - > mFORCE_GA_OFF ) ;
setBoolAttribute ( qsl ( " mEnableGMCP " ) , pHost - > mEnableGMCP ) ;
setBoolAttribute ( qsl ( " mEnableMSSP " ) , pHost - > mEnableMSSP ) ;
Improve: New Environ and MNES Support (#7058)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
To enhance player experience and simplify the onboarding of accessible
users by sharing more client supported detail, support for two protocols
are requested to be added to Mudlet. In particular, knowing through
information exchange that a client supports UTF-8, TRUECOLOR, and an
opt-in indicator of screen reader use, may ease initial setup and
increase the stay rate for new gaming community members.
[Mudlet Area 51
Reference](https://wiki.mudlet.org/w/Area_51#NEW-ENVIRON.2C_PR_.237058)
##### Implemented [Telnet New-Environ
Option](https://www.rfc-editor.org/rfc/rfc1572.txt) (39):
* Added `Force NEW_ENVIRON Negotiation Off` to the Special Options menu
* Negotiate `NEW_ENVIRON` when prompted by the server
* Enable servers to request `SEND` updates, individually or in bulk for:
* Well-know variables: ~~`SYSTEMTYPE`, `USER`~~
* User variables: `CHARSET`, `CLIENT_NAME`, `CLIENT_VERSION`, `MTTS`,
`TERMINAL_TYPE`, `IPADDRESS`, `ANSI`, `VT100`, `256_COLORS`,
`MOUSE_TRACKING`, `UTF-8`, `OSC_COLOR_PALETTE`, `SCREEN_READER`,
`PROXY`, `TRUECOLOR`, `TLS`, ~~`LANGUAGE`, `FONT`, `FONT_SIZE`,~~
`WORD_WRAP`
* Enable servers to receive `INFO` updates for known variables,
previously replied with an `IS` and not undefined:
* `CHARSET` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `MTTS` changes status (see CHARSET and SCREEN_READER)
* `UTF-8` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `SCREEN_READER` changes status (Accessibility menu)
* ~~`LANGUAGE` changes (General menu)~~
* ~~`FONT` and `FONT_SIZE` changes (Main display menu)~~
* `WORD_WRAP` changes (Main display menu)
##### Implemented [Mud New Environment
Standard](https://tintin.mudhalla.net/protocols/mnes/) (39 as MNES):
* Added `Enable MNES` to the General menu (defaults disabled)
* Removed `Force MTTS Negotiation Off` from the Special Options menu
* Added `Enable MTTS` to the General menu (defaults enabled, still)
* Negotiate `NEW_ENVIRON (MNES)` when prompted by the server
* Enable servers to request `SEND` updates, individually or in bulk for:
* MNES variables: `CHARSET`, `CLIENT_NAME`, `CLIENT_VERSION`, `MTTS`,
`TERMINAL_TYPE`, `IPADDRESS`
* Enable servers to receive `INFO` updates for known variables,
previously replied with an `IS` and not undefined:
* `CHARSET` changes status (General menu or [Telnet Charset
Option](https://wiki.mudlet.org/w/Manual:Supported_Protocols#Encoding))
* `MTTS` changes status (General menu, Accessibility menu, and see
CHARSET)
Example of **Telnet New-Environ Option** requests from game servers:
```
IAC SB NEW_ENVIRON SEND VAR "UTF-8" IAC SE // Request one USERVAR variable
IAC SB NEW_ENVIRON SEND USERVAR "CHARSET" VAR "UTF-8" IAC SE // Request multiple variables
IAC SB NEW_ENVIRON SEND "CHARSET" USERVAR IAC SE // Request CHARSET and all of the well-known USERVAR variables (see a duplicate CHARSET, this is per the RFC)
IAC SB NEW_ENVIRON SEND USERVAR IAC SE // Request all the USERVAR variables (a large list like above)
IAC SB NEW_ENVIRON SEND VAR USERVAR IAC SE // Request all the variables
IAC SB NEW_ENVIRON SEND IAC SE // Request all the variables
```
High level example of **Telnet New-Environ Option** data from Mudlet:
```
VAR `SYSTEMTYPE` VAL `MACOS`
VAR `USER` VAL `tamarindo`
USERVAR `256_COLORS` VAL `1`
USERVAR `ANSI` VAL `1`
USERVAR `CHARSET` VAL `UTF-8`
USERVAR `CLIENT_NAME` VAL `MUDLET`
USERVAR `CLIENT_VERSION` VAL `4/17/2-DEV`
USERVAR `MTTS` VAL `2349`
USERVAR `OSC_COLOR_PALETTE` VAL `1`
USERVAR `SCREEN_READER` VAL `0`
USERVAR `TERMINAL_TYPE` VAL `ANSI-TRUECOLOR`
USERVAR `TLS` VAL `1`
USERVAR `TRUECOLOR` VAL `1`
USERVAR `UTF-8` VAL `1`
USERVAR `VT100` VAL `0`
USERVAR `WORD_WRAP` VAL `100`
```
Example of **Mud New Environment Standard** requests from game servers:
```
IAC SB NEW_ENVIRON SEND VAR "CHARSET" IAC SE // Request one variable
IAC SB NEW_ENVIRON SEND VAR "CHARSET" VAR "MTTS" IAC SE // Request more than one variable
IAC SB NEW_ENVIRON SEND VAR IAC SE // Request all variables
IAC SB NEW_ENVIRON SEND IAC SE // Request all variables
```
High level example of **Mud New Environment Standard** data from Mudlet:
```
VAR `CHARSET` VAL `UTF-8`
VAR `CLIENT_NAME` VAL `MUDLET`
VAR `CLIENT_VERSION` VAL `4/17/2-DEV`
VAR `MTTS` VAL `2861`
VAR `TERMINAL_TYPE` VAL `ANSI-TRUECOLOR`
```
#### Motivation for adding to Mudlet
Get updates that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, SCREEN_READER)
#### Other info (issues closed, discussion etc)
[Mudlet Area 51
Reference](https://wiki.mudlet.org/w/Area_51#NEW-ENVIRON.2C_PR_.237058)
---------
Co-authored-by: Marco Fontani <mfontani@cpan.org>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2024-01-05 09:31:56 -05:00
setBoolAttribute ( qsl ( " mEnableMSDP " ) , pHost - > mEnableMSDP ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " mEnableMSP " ) , pHost - > mEnableMSP ) ;
setBoolAttribute ( qsl ( " mMapStrongHighlight " ) , pHost - > mMapStrongHighlight ) ;
setBoolAttribute ( qsl ( " mEnableSpellCheck " ) , pHost - > mEnableSpellCheck ) ;
fix: map info "Short" always re-added on profile load (#8963)
#### Brief overview of PR changes/additions
- Fix map info contributors not persisting correctly across profile
saves - "Short" was always re-added on load regardless of user settings
- Move the default `{"Short"}` from an in-class initializer on
`mMapInfoContributors` to explicit initialization for new profiles only
in `loadProfile()`
- Add `getMapInfo()` Lua function and `getConfig("mapInfo")` key to
query map info contributor state
#### Motivation for adding to Mudlet
Map info checkbox settings should persist exactly as the user configured
them, and scripts should be able to query which map info contributors
are active.
#### Other info (issues closed, discussion etc)
**Root cause:** `Host.h` initialized `mMapInfoContributors` with
`{"Short"}`. On profile load, XML import *inserted* saved values into
this set without clearing it first, so the default "Short" survived and
merged with whatever was actually saved. The `mShowInfo="no"`
conditional clear only handled the empty case, not "Full only" or other
combinations.
**The fix** removes the in-class default (set starts empty), sets
`{"Short"}` explicitly for brand-new profiles in `loadProfile()`, and
removes the now-unnecessary conditional clear from `XMLimport`. Loaded
profiles get exactly what was saved.
**New Lua API - `getMapInfo()`:**
Returns a table of all registered map info contributors mapped to their
enabled/disabled state. Complements the existing
`enableMapInfo()`/`disableMapInfo()` pair.
```lua
-- returns e.g. { Short = true, Full = false }
local info = getMapInfo()
for name, enabled in pairs(info) do
print(name .. " is " .. (enabled and "enabled" or "disabled"))
end
```
**New `getConfig("mapInfo")` key:**
Returns the currently enabled contributors as an array of strings.
```lua
-- returns e.g. {"Short"} or {"Short", "Full"} or {}
local enabled = getConfig("mapInfo")
```
**Test case:**
1. Open an existing profile, set map info to "Full" only (uncheck
"Short"), close and reopen - verify only "Full" is checked
2. Set no checkboxes at all, close and reopen - verify none are checked
3. Create a brand-new profile - verify "Short" is enabled by default
4. Run `lua getMapInfo()` - verify it returns the correct table of
contributors with their states
5. Run `lua getConfig("mapInfo")` - verify it returns the enabled
contributors as an array
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Zooka <136661366+ZookaOnGit@users.noreply.github.com>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2026-03-22 13:39:57 +01:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mShowInfo " ) ) ) {
// Old - pre Map Info versions of Mudlet (those before
// https://github.com/Mudlet/Mudlet/pull/4718) used the above
// setting to control the showing of what is now the "Full"
// map info display. So treat it as that to reproduce that
// behaviour:
if ( attributes ( ) . value ( qsl ( " mShowInfo " ) ) . toString ( ) = = YES ) {
mpHost - > mMapInfoContributors . insert ( qsl ( " Full " ) ) ;
}
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " mAcceptServerGUI " ) , pHost - > mAcceptServerGUI ) ;
setBoolAttribute ( qsl ( " mAcceptServerMedia " ) , pHost - > mAcceptServerMedia ) ;
setBoolAttribute ( qsl ( " mMapperUseAntiAlias " ) , pHost - > mMapperUseAntiAlias ) ;
2025-11-13 08:32:26 +01:00
setBoolAttribute ( qsl ( " mMapperShowGrid " ) , pHost - > mMapperShowGrid ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " mEditorAutoComplete " ) , pHost - > mEditorAutoComplete ) ;
Add: Enable Special Option for Version Number in TTYPE for Compatibility (#7888)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This PR addresses [#7826](https://github.com/Mudlet/Mudlet/issues/7826),
where some MUD servers using KaVir’s protocol snippet [
[1](https://github.com/Xavious/MSDP_Protocol_Handler/blob/master/protocol.c)
] [
[2](https://github.com/scandum/msdp_protocol_snippet_by_kavir/blob/master/protocol.c)
] [
[3](https://github.com/halimcme/worldofpain/blob/master/protocol.cpp) ]
expect both the client name and a numeric version (i.e., `MUDLET
4.19.1`) during Telnet TTYPE negotiation. This change allows users to
optionally include the version number in the terminal type, restoring
compatibility for the servers running this legacy script.
* A `Send Mudlet version in terminal type` checkbox was added to the
Special Options tab of Settings, which is disabled by default.
* To streamline the process of applying the checkbox where needed,
Mudlet will detect KaVir protocol snippet's standard pattern of 8
negotiations occuring in a specific order, responding with a *one-time*
prompt for a user choice to automatically mark the checkbox and
reconnect to obtain the 256 color setting within their game.
* Also available via the Lua API:
* `getConfig("versionInTTYPE")`
* `setConfig("versionInTTYPE", option)`
* `getConfig("promptForVersionInTTYPE")`
* `setConfig("promptForVersionInTTYPE", option)`
#### Motivation for adding to Mudlet
To improve compatibility with MUD servers that require a version number
in TTYPE for enhanced color support, without violating protocol
standards.
Since 2024 ([#7103](https://github.com/Mudlet/Mudlet/issues/7826)),
Mudlet stopped sending the version number by default, because 1) it is
not required by RFCs and 2) MTTS, New-Environ, and MNES were added to
Mudlet. However, servers relying on this version information via KaVir's
snippet started assuming Mudlet was version 1.0 or earlier and defaulted
color support to 16 colors instead of 256-color mode.
#### Other info (issues closed, discussion etc)
Closes #7826.
Restores expected behavior for servers using KaVir’s protocol snippet.
No impact on servers that do not require the version number.
---
New Special Option
<img width="1010" alt="Screenshot 2025-06-02 at 8 20 02 AM"
src="https://github.com/user-attachments/assets/65a78f8a-aa93-4073-ae48-fe4a59f2da60"
/>
---
Evidence of Appending Version Number with the Special Option
<img width="969" alt="Screenshot 2025-06-02 at 8 19 40 AM"
src="https://github.com/user-attachments/assets/1909af0b-bb1d-413d-ad6e-019b9942fa02"
/>
---
Detecting the Legacy Script and Prompting Special Option Activation
<img width="1080" alt="Screenshot 2025-06-08 at 10 29 12 PM"
src="https://github.com/user-attachments/assets/b84f5917-a4cd-467e-b1eb-be5087b4da3c"
/>
---
Confirming Application of the Special Option and Reconnecting
<img width="907" alt="Screenshot 2025-06-08 at 10 29 41 PM"
src="https://github.com/user-attachments/assets/3a26409a-958e-4735-bba2-5485f09045af"
/>
---------
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2025-06-14 08:37:53 -04:00
setBoolAttribute ( qsl ( " mVersionInTTYPE " ) , pHost - > mVersionInTTYPE ) ;
setBoolAttribute ( qsl ( " mPromptedForVersionInTTYPE " ) , pHost - > mPromptedForVersionInTTYPE ) ;
2025-07-02 07:59:22 -04:00
setBoolAttribute ( qsl ( " mPromptedForMXPProcessorOn " ) , pHost - > mPromptedForMXPProcessorOn ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " enableTextAnalyzer " ) , pHost - > mEnableTextAnalyzer ) ;
setBoolAttribute ( qsl ( " mBubbleMode " ) , pHost - > mBubbleMode ) ;
setBoolAttribute ( qsl ( " mMapViewOnly " ) , pHost - > mMapViewOnly ) ;
setBoolAttribute ( qsl ( " mShowRoomIDs " ) , pHost - > mShowRoomID ) ;
setBoolAttribute ( qsl ( " mShowPanel " ) , pHost - > mShowPanel ) ;
2025-08-28 13:01:15 +02:00
setBoolAttribute ( qsl ( " mShow3DView " ) , pHost - > mShow3DView ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
setBoolAttribute ( qsl ( " mHaveMapperScript " ) , pHost - > mHaveMapperScript ) ;
setBoolAttribute ( qsl ( " mSslTsl " ) , pHost - > mSslTsl ) ;
setBoolAttribute ( qsl ( " mSslIgnoreExpired " ) , pHost - > mSslIgnoreExpired ) ;
setBoolAttribute ( qsl ( " mSslIgnoreSelfSigned " ) , pHost - > mSslIgnoreSelfSigned ) ;
setBoolAttribute ( qsl ( " mSslIgnoreAll " ) , pHost - > mSslIgnoreAll ) ;
setBoolAttribute ( qsl ( " mAskTlsAvailable " ) , pHost - > mAskTlsAvailable ) ;
setBoolAttribute ( qsl ( " mUseProxy " ) , pHost - > mUseProxy ) ;
2025-06-05 15:30:01 -04:00
setBoolAttribute ( qsl ( " f3SearchEnabled " ) , pHost - > mF3SearchEnabled ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2025-07-02 07:59:22 -04:00
pHost - > setForceMXPProcessorOn ( attributes ( ) . value ( qsl ( " mForceMXPProcessorOn " ) ) = = YES ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
pHost - > mProxyAddress = attributes ( ) . value ( qsl ( " mProxyAddress " ) ) . toString ( ) ;
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mProxyPort " ) ) ) {
pHost - > mProxyPort = attributes ( ) . value ( qsl ( " mProxyPort " ) ) . toInt ( ) ;
} else {
pHost - > mProxyPort = 0 ;
}
pHost - > mProxyUsername = attributes ( ) . value ( qsl ( " mProxyUsername " ) ) . toString ( ) ;
2025-10-21 15:11:09 +01:00
Improve: Secure credential management with system keychain integration and legacy migration (#7956)
#### Brief overview of PR changes/additions
This pull request implements secure credential management for Mudlet
with system keychain integration and encrypted fallback storage:
**Core Components:**
- **CredentialManager**: High-level API for secure credential storage
with QtKeychain integration
- **SecureStringUtils**: Qt-based cryptographic utilities for encrypted
file storage
- **Legacy Migration**: Automatic detection and migration of existing
plaintext passwords
**Key Features:**
- **System Keychain Integration**: Primary storage in macOS Keychain,
Windows Credential Store, and Linux Secret Service via QtKeychain
- **Encrypted File Fallback**: Qt crypto-based AES encryption for
portable mode and keychain unavailability
- **Seamless Migration**: Automatic detection and upgrade of legacy
password storage formats
- **Profile Isolation**: Per-profile encryption keys prevent
cross-profile credential access
- **Portable Mode Support**: Automatic detection and secure file-based
storage for portable installations
#### Motivation for adding to Mudlet
**Security Enhancement:**
- Eliminates plaintext password storage in profile XML files
- Provides industry-standard system keychain integration for credential
security
- Implements authenticated encryption for fallback scenarios
**User Experience:**
- Zero configuration required - works automatically across all platforms
- Seamless migration from existing plaintext passwords to secure storage
- Native system integration provides familiar credential management
experience
**Future-Proofing:**
- Extensible architecture supports additional credential types (API
keys, tokens, etc.)
- Robust fallback ensures functionality in all deployment scenarios
- Prepares foundation for OAuth and external service integrations
#### Other info (issues closed, discussion etc)
**Security Architecture:**
- **Keychain-First Strategy**: Prefers system keychain with automatic
encrypted file fallback
- **Legacy Format Detection**: Automatically migrates passwords from
development branch keychain format
- **Memory Security**: Secure string clearing and controlled credential
lifecycle management
- **Input Validation**: Path traversal protection and service name
sanitization
**Implementation Highlights:**
- **Async Operations**: Non-blocking keychain operations with timeout
protection
- **Thread Safety**: Event-driven architecture prevents UI blocking and
race conditions
- **Comprehensive Testing**: Full test coverage for encryption,
migration, and fallback scenarios
- **Cross-Platform**: Unified API across Windows, macOS, and Linux with
platform-specific optimizations
**Version Compatibility & Migration:**
- **Mudlet 4.19.x Compatibility**: Preserves existing plaintext password
storage to ensure compatibility when switching between 4.19.x stable and
development builds
- **Mudlet 4.20.x Migration**: Post-4.20.0 release, automatic migration
begins converting plaintext passwords to secure storage
- **Bidirectional Safety**: Users can safely run both 4.19.x and
development versions without losing access to their passwords during the
transition period
- **Legacy Format Support**: Automatically detects and migrates
passwords from the original development branch keychain format
(`service="Mudlet profile"`) to the new secure format
# Credential Management Workflows
## 1. Credential Storage Strategy
```mermaid
flowchart TD
A[Store Password Request] --> B{Portable Mode?}
B -->|Yes| C[Encrypt & Store in Profile File]
B -->|No| D[Store in System Keychain]
D --> E{Keychain Success?}
E -->|Yes| F[Remove Encrypted Fallback File]
E -->|No| G[Fallback to Encrypted File]
F --> H[Success]
G --> I{Encryption Success?}
I -->|Yes| H
I -->|No| J[Failure]
C --> I
classDef primary fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef decision fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef result fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class D,F primary
class C,G fallback
class B,E,I decision
class H,J result
```
## 2. Legacy Migration Workflow
```mermaid
flowchart TD
A[Retrieve Password Request] --> B[Try New Keychain Format]
B --> C{Password Found?}
C -->|Yes| D[Return Password]
C -->|No| E[Check Legacy Keychain Format]
E --> F{Legacy Found?}
F -->|Yes| G[Migrate to New Format]
G --> H[Store in New Format]
H --> I[Remove Legacy Entry]
I --> J[Return Migrated Password]
F -->|No| K[Try Encrypted File]
K --> L{File Found?}
L -->|Yes| M[Decrypt & Return]
L -->|No| N[Return Empty - No Password Stored]
classDef newformat fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef legacy fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef migration fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
classDef fallback fill:#607D8B,stroke:#263238,stroke-width:2px,color:#fff
classDef result fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
class B,H newformat
class E,I legacy
class G migration
class K fallback
class D,J,M,N result
```
## 3. Cross-Platform Keychain Integration
```mermaid
flowchart TD
A[QtKeychain Request] --> B{Platform Detection}
B -->|macOS| C[Access Keychain Services]
B -->|Windows| D[Access Credential Store]
B -->|Linux| E[Access Secret Service]
C --> F[Store/Retrieve Credential]
D --> F
E --> F
F --> G{Operation Success?}
G -->|Yes| H[Return Result]
G -->|No| I[Log Error & Fallback]
I --> J[Use Encrypted File Storage]
J --> K[AES Encryption with Profile Key]
K --> L[Store in Profile Directory]
classDef platform fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef keychain fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef crypto fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class C,D,E platform
class F,H keychain
class I,J fallback
class K,L crypto
```
This implementation provides a comprehensive, secure, and user-friendly
credential management system that seamlessly upgrades existing Mudlet
installations while providing robust security for future credential
storage needs.
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-17 06:44:38 -04:00
// Handle backward compatibility based on application version, not profile version
QString storedProxyPassword = attributes ( ) . value ( qsl ( " mProxyPassword " ) ) . toString ( ) ;
2025-10-21 15:11:09 +01:00
Improve: Secure credential management with system keychain integration and legacy migration (#7956)
#### Brief overview of PR changes/additions
This pull request implements secure credential management for Mudlet
with system keychain integration and encrypted fallback storage:
**Core Components:**
- **CredentialManager**: High-level API for secure credential storage
with QtKeychain integration
- **SecureStringUtils**: Qt-based cryptographic utilities for encrypted
file storage
- **Legacy Migration**: Automatic detection and migration of existing
plaintext passwords
**Key Features:**
- **System Keychain Integration**: Primary storage in macOS Keychain,
Windows Credential Store, and Linux Secret Service via QtKeychain
- **Encrypted File Fallback**: Qt crypto-based AES encryption for
portable mode and keychain unavailability
- **Seamless Migration**: Automatic detection and upgrade of legacy
password storage formats
- **Profile Isolation**: Per-profile encryption keys prevent
cross-profile credential access
- **Portable Mode Support**: Automatic detection and secure file-based
storage for portable installations
#### Motivation for adding to Mudlet
**Security Enhancement:**
- Eliminates plaintext password storage in profile XML files
- Provides industry-standard system keychain integration for credential
security
- Implements authenticated encryption for fallback scenarios
**User Experience:**
- Zero configuration required - works automatically across all platforms
- Seamless migration from existing plaintext passwords to secure storage
- Native system integration provides familiar credential management
experience
**Future-Proofing:**
- Extensible architecture supports additional credential types (API
keys, tokens, etc.)
- Robust fallback ensures functionality in all deployment scenarios
- Prepares foundation for OAuth and external service integrations
#### Other info (issues closed, discussion etc)
**Security Architecture:**
- **Keychain-First Strategy**: Prefers system keychain with automatic
encrypted file fallback
- **Legacy Format Detection**: Automatically migrates passwords from
development branch keychain format
- **Memory Security**: Secure string clearing and controlled credential
lifecycle management
- **Input Validation**: Path traversal protection and service name
sanitization
**Implementation Highlights:**
- **Async Operations**: Non-blocking keychain operations with timeout
protection
- **Thread Safety**: Event-driven architecture prevents UI blocking and
race conditions
- **Comprehensive Testing**: Full test coverage for encryption,
migration, and fallback scenarios
- **Cross-Platform**: Unified API across Windows, macOS, and Linux with
platform-specific optimizations
**Version Compatibility & Migration:**
- **Mudlet 4.19.x Compatibility**: Preserves existing plaintext password
storage to ensure compatibility when switching between 4.19.x stable and
development builds
- **Mudlet 4.20.x Migration**: Post-4.20.0 release, automatic migration
begins converting plaintext passwords to secure storage
- **Bidirectional Safety**: Users can safely run both 4.19.x and
development versions without losing access to their passwords during the
transition period
- **Legacy Format Support**: Automatically detects and migrates
passwords from the original development branch keychain format
(`service="Mudlet profile"`) to the new secure format
# Credential Management Workflows
## 1. Credential Storage Strategy
```mermaid
flowchart TD
A[Store Password Request] --> B{Portable Mode?}
B -->|Yes| C[Encrypt & Store in Profile File]
B -->|No| D[Store in System Keychain]
D --> E{Keychain Success?}
E -->|Yes| F[Remove Encrypted Fallback File]
E -->|No| G[Fallback to Encrypted File]
F --> H[Success]
G --> I{Encryption Success?}
I -->|Yes| H
I -->|No| J[Failure]
C --> I
classDef primary fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef decision fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef result fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class D,F primary
class C,G fallback
class B,E,I decision
class H,J result
```
## 2. Legacy Migration Workflow
```mermaid
flowchart TD
A[Retrieve Password Request] --> B[Try New Keychain Format]
B --> C{Password Found?}
C -->|Yes| D[Return Password]
C -->|No| E[Check Legacy Keychain Format]
E --> F{Legacy Found?}
F -->|Yes| G[Migrate to New Format]
G --> H[Store in New Format]
H --> I[Remove Legacy Entry]
I --> J[Return Migrated Password]
F -->|No| K[Try Encrypted File]
K --> L{File Found?}
L -->|Yes| M[Decrypt & Return]
L -->|No| N[Return Empty - No Password Stored]
classDef newformat fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef legacy fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef migration fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
classDef fallback fill:#607D8B,stroke:#263238,stroke-width:2px,color:#fff
classDef result fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
class B,H newformat
class E,I legacy
class G migration
class K fallback
class D,J,M,N result
```
## 3. Cross-Platform Keychain Integration
```mermaid
flowchart TD
A[QtKeychain Request] --> B{Platform Detection}
B -->|macOS| C[Access Keychain Services]
B -->|Windows| D[Access Credential Store]
B -->|Linux| E[Access Secret Service]
C --> F[Store/Retrieve Credential]
D --> F
E --> F
F --> G{Operation Success?}
G -->|Yes| H[Return Result]
G -->|No| I[Log Error & Fallback]
I --> J[Use Encrypted File Storage]
J --> K[AES Encryption with Profile Key]
K --> L[Store in Profile Directory]
classDef platform fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef keychain fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef crypto fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class C,D,E platform
class F,H keychain
class I,J fallback
class K,L crypto
```
This implementation provides a comprehensive, secure, and user-friendly
credential management system that seamlessly upgrades existing Mudlet
installations while providing robust security for future credential
storage needs.
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-17 06:44:38 -04:00
// For version 4.20.0+, use secure storage; for older versions, maintain plaintext in XML
// Use current application version for consistency with XMLexport behavior
const QString currentAppVersion = QString ( APP_VERSION ) ;
const QVersionNumber appVersion = QVersionNumber : : fromString ( currentAppVersion ) ;
const QVersionNumber secureStorageVersion = QVersionNumber ( 4 , 20 , 0 ) ;
const bool useSecureStorage = appVersion > = secureStorageVersion ;
2025-10-21 15:11:09 +01:00
Improve: Secure credential management with system keychain integration and legacy migration (#7956)
#### Brief overview of PR changes/additions
This pull request implements secure credential management for Mudlet
with system keychain integration and encrypted fallback storage:
**Core Components:**
- **CredentialManager**: High-level API for secure credential storage
with QtKeychain integration
- **SecureStringUtils**: Qt-based cryptographic utilities for encrypted
file storage
- **Legacy Migration**: Automatic detection and migration of existing
plaintext passwords
**Key Features:**
- **System Keychain Integration**: Primary storage in macOS Keychain,
Windows Credential Store, and Linux Secret Service via QtKeychain
- **Encrypted File Fallback**: Qt crypto-based AES encryption for
portable mode and keychain unavailability
- **Seamless Migration**: Automatic detection and upgrade of legacy
password storage formats
- **Profile Isolation**: Per-profile encryption keys prevent
cross-profile credential access
- **Portable Mode Support**: Automatic detection and secure file-based
storage for portable installations
#### Motivation for adding to Mudlet
**Security Enhancement:**
- Eliminates plaintext password storage in profile XML files
- Provides industry-standard system keychain integration for credential
security
- Implements authenticated encryption for fallback scenarios
**User Experience:**
- Zero configuration required - works automatically across all platforms
- Seamless migration from existing plaintext passwords to secure storage
- Native system integration provides familiar credential management
experience
**Future-Proofing:**
- Extensible architecture supports additional credential types (API
keys, tokens, etc.)
- Robust fallback ensures functionality in all deployment scenarios
- Prepares foundation for OAuth and external service integrations
#### Other info (issues closed, discussion etc)
**Security Architecture:**
- **Keychain-First Strategy**: Prefers system keychain with automatic
encrypted file fallback
- **Legacy Format Detection**: Automatically migrates passwords from
development branch keychain format
- **Memory Security**: Secure string clearing and controlled credential
lifecycle management
- **Input Validation**: Path traversal protection and service name
sanitization
**Implementation Highlights:**
- **Async Operations**: Non-blocking keychain operations with timeout
protection
- **Thread Safety**: Event-driven architecture prevents UI blocking and
race conditions
- **Comprehensive Testing**: Full test coverage for encryption,
migration, and fallback scenarios
- **Cross-Platform**: Unified API across Windows, macOS, and Linux with
platform-specific optimizations
**Version Compatibility & Migration:**
- **Mudlet 4.19.x Compatibility**: Preserves existing plaintext password
storage to ensure compatibility when switching between 4.19.x stable and
development builds
- **Mudlet 4.20.x Migration**: Post-4.20.0 release, automatic migration
begins converting plaintext passwords to secure storage
- **Bidirectional Safety**: Users can safely run both 4.19.x and
development versions without losing access to their passwords during the
transition period
- **Legacy Format Support**: Automatically detects and migrates
passwords from the original development branch keychain format
(`service="Mudlet profile"`) to the new secure format
# Credential Management Workflows
## 1. Credential Storage Strategy
```mermaid
flowchart TD
A[Store Password Request] --> B{Portable Mode?}
B -->|Yes| C[Encrypt & Store in Profile File]
B -->|No| D[Store in System Keychain]
D --> E{Keychain Success?}
E -->|Yes| F[Remove Encrypted Fallback File]
E -->|No| G[Fallback to Encrypted File]
F --> H[Success]
G --> I{Encryption Success?}
I -->|Yes| H
I -->|No| J[Failure]
C --> I
classDef primary fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef decision fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef result fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class D,F primary
class C,G fallback
class B,E,I decision
class H,J result
```
## 2. Legacy Migration Workflow
```mermaid
flowchart TD
A[Retrieve Password Request] --> B[Try New Keychain Format]
B --> C{Password Found?}
C -->|Yes| D[Return Password]
C -->|No| E[Check Legacy Keychain Format]
E --> F{Legacy Found?}
F -->|Yes| G[Migrate to New Format]
G --> H[Store in New Format]
H --> I[Remove Legacy Entry]
I --> J[Return Migrated Password]
F -->|No| K[Try Encrypted File]
K --> L{File Found?}
L -->|Yes| M[Decrypt & Return]
L -->|No| N[Return Empty - No Password Stored]
classDef newformat fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef legacy fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef migration fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
classDef fallback fill:#607D8B,stroke:#263238,stroke-width:2px,color:#fff
classDef result fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
class B,H newformat
class E,I legacy
class G migration
class K fallback
class D,J,M,N result
```
## 3. Cross-Platform Keychain Integration
```mermaid
flowchart TD
A[QtKeychain Request] --> B{Platform Detection}
B -->|macOS| C[Access Keychain Services]
B -->|Windows| D[Access Credential Store]
B -->|Linux| E[Access Secret Service]
C --> F[Store/Retrieve Credential]
D --> F
E --> F
F --> G{Operation Success?}
G -->|Yes| H[Return Result]
G -->|No| I[Log Error & Fallback]
I --> J[Use Encrypted File Storage]
J --> K[AES Encryption with Profile Key]
K --> L[Store in Profile Directory]
classDef platform fill:#2196F3,stroke:#0D47A1,stroke-width:2px,color:#fff
classDef keychain fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#000
classDef fallback fill:#FF9800,stroke:#E65100,stroke-width:2px,color:#000
classDef crypto fill:#9C27B0,stroke:#4A148C,stroke-width:2px,color:#fff
class C,D,E platform
class F,H keychain
class I,J fallback
class K,L crypto
```
This implementation provides a comprehensive, secure, and user-friendly
credential management system that seamlessly upgrades existing Mudlet
installations while providing robust security for future credential
storage needs.
---------
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2025-08-17 06:44:38 -04:00
if ( ! storedProxyPassword . isEmpty ( ) ) {
if ( useSecureStorage ) {
// Modern application: migrate plaintext password to secure storage and clear from XML
CredentialManager : : storeCredential ( pHost - > getName ( ) , " proxy " , storedProxyPassword ) ;
pHost - > mProxyPassword = storedProxyPassword ;
SecureStringUtils : : secureStringClear ( storedProxyPassword ) ; // Clear after migration
} else {
// Legacy application: keep plaintext password for backward compatibility
pHost - > mProxyPassword = storedProxyPassword ;
}
} else if ( useSecureStorage ) {
// Modern application: load from secure storage if available
pHost - > mProxyPassword = CredentialManager : : retrieveCredential ( pHost - > getName ( ) , " proxy " ) ;
}
2021-12-07 06:21:39 +01:00
pHost - > set_USE_IRE_DRIVER_BUGFIX ( attributes ( ) . value ( qsl ( " USE_IRE_DRIVER_BUGFIX " ) ) = = YES ) ;
pHost - > mHighlightHistory = readDefaultTrueBool ( qsl ( " HighlightHistory " ) ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
pHost - > mLogDir = attributes ( ) . value ( qsl ( " logDirectory " ) ) . toString ( ) ;
pHost - > mFORCE_SAVE_ON_EXIT = readDefaultTrueBool ( qsl ( " mFORCE_SAVE_ON_EXIT " ) ) ;
const bool enableUserDictionary = attributes ( ) . value ( qsl ( " mEnableUserDictionary " ) ) = = YES ;
const bool useSharedDictionary = attributes ( ) . value ( qsl ( " mUseSharedDictionary " ) ) = = YES ;
pHost - > setUserDictionaryOptions ( enableUserDictionary , useSharedDictionary ) ;
pHost - > mMapperShowRoomBorders = readDefaultTrueBool ( qsl ( " mMapperShowRoomBorders " ) ) ;
pHost - > mEditorTheme = attributes ( ) . value ( QLatin1String ( " mEditorTheme " ) ) . toString ( ) ;
pHost - > mEditorThemeFile = attributes ( ) . value ( QLatin1String ( " mEditorThemeFile " ) ) . toString ( ) ;
2024-12-15 20:25:21 +01:00
if ( pHost - > mEditorTheme . isEmpty ( ) | | pHost - > mEditorThemeFile . isEmpty ( ) ) {
pHost - > mEditorTheme = qsl ( " Mudlet " ) ;
pHost - > mEditorThemeFile = qsl ( " Mudlet.tmTheme " ) ;
}
2026-04-16 07:43:22 +02:00
pHost - > mEditorThemeDark = attributes ( ) . value ( QLatin1String ( " mEditorThemeDark " ) ) . toString ( ) ;
pHost - > mEditorThemeFileDark = attributes ( ) . value ( QLatin1String ( " mEditorThemeFileDark " ) ) . toString ( ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
pHost - > mThemePreviewItemID = attributes ( ) . value ( QLatin1String ( " mThemePreviewItemID " ) ) . toInt ( ) ;
pHost - > mThemePreviewType = attributes ( ) . value ( QLatin1String ( " mThemePreviewType " ) ) . toString ( ) ;
pHost - > setHaveColorSpaceId ( attributes ( ) . value ( QLatin1String ( " mSGRCodeHasColSpaceId " ) ) . toString ( ) = = QLatin1String ( " yes " ) ) ;
pHost - > setMayRedefineColors ( attributes ( ) . value ( QLatin1String ( " mServerMayRedefineColors " ) ) . toString ( ) = = QLatin1String ( " yes " ) ) ;
2018-05-22 22:33:22 +01:00
if ( attributes ( ) . hasAttribute ( " AmbigousWidthGlyphsToBeWide " ) ) {
2025-08-18 15:30:37 +02:00
const QStringView ambiguousWidthSetting ( attributes ( ) . value ( qsl ( " AmbigousWidthGlyphsToBeWide " ) ) ) ;
if ( ambiguousWidthSetting = = YES ) {
pHost - > setWideAmbiguousEAsianGlyphs ( Qt : : Checked ) ;
} else if ( ambiguousWidthSetting = = qsl ( " auto " ) ) {
pHost - > setWideAmbiguousEAsianGlyphs ( Qt : : PartiallyChecked ) ;
} else {
pHost - > setWideAmbiguousEAsianGlyphs ( Qt : : Unchecked ) ;
}
} else {
// The encoding setting is stored as part of the profile details and NOT
// in the save file - probably because it is needed before the
// connection to the Server is initiated so it will already be in place
// which is just as well as it is needed for the automatic case...
pHost - > setWideAmbiguousEAsianGlyphs ( Qt : : PartiallyChecked ) ;
2018-05-22 22:33:22 +01:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2026-03-24 07:30:08 -04:00
pHost - > setEnableBlinkText ( attributes ( ) . value ( qsl ( " mEnableBlinkText " ) ) = = qsl ( " yes " ) ) ;
Add: blinking/flashing text support (#8983)
## Summary
Adds support for SGR codes 5 (slow blink) and 6 (rapid blink/flash) text
attributes.
## Implementation Details
### Blink Timer Architecture
- Global blink timer in `mudlet` singleton runs at 200ms interval (2.5
Hz, WCAG 2.3.1 compliant - under 3 Hz limit)
- TTextEdit widgets register/unregister as blink clients
- Timer only runs when at least one client needs it
- Uses 4-state counter per ISO/IEC 8613-6:1994 to create two speeds:
- **Slow blink (SGR 5)**: < 150 cycles/min (~1.25 Hz)
- **Fast blink (SGR 6)**: > 150 cycles/min (~2.5 Hz)
### Text Attributes
- New `TChar::AttributeFlags`: `Blink` and `FastBlink`
- SGR 5 sets `Blink`, SGR 6 sets `FastBlink`
- SGR 25 clears both flags
### Rendering
- `TTextEdit::drawBackground()` skips drawing background for hidden
blink text
- `TTextEdit::drawForeground()` skips drawing foreground for hidden
blink text
- When blinking is disabled, blink text renders as italics instead
### User Preference
- Per-profile `enableBlinkText` setting (disabled by default for
accessibility)
- Checkbox in Settings → Accessibility tab
- Lua API: `getConfig("enableBlinkText")` /
`setConfig("enableBlinkText", bool)`
- Saved/loaded in profile XML
### Lua API
- `getTextFormat()` reports blinking as `"none"`, `"slow"`, or `"fast"`
- `setTextFormat()` accepts optional blink parameter: `"none"`,
`"slow"`, or `"fast"`
## Testing
To test blinking text, connect to a game that sends SGR 5/6 codes, or
use:
```lua
echo("\27[5mSlow blink\27[0m \27[6mFast blink\27[0m\n")
```
## Checklist
- [x] Blink timer starts/stops based on client registration
- [x] Slow and fast blink speeds are visually distinct
- [x] Preference toggles blinking on/off per profile
- [x] Fallback to italics when blinking disabled
- [x] WCAG 2.3.1 compliant (2.5 Hz, under 3 Hz limit)
- [x] Default is disabled for accessibility considerations
- [x]
[`setTextFormat()`](https://wiki.mudlet.org/w/Area_51#setTextFormat.2C_PR_.238983)
supports blink mode parameter
---
https://github.com/user-attachments/assets/25f63605-7b90-40c3-963f-53889e41328d
---------
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2026-03-04 08:04:45 -05:00
2018-07-15 17:33:08 +01:00
if ( attributes ( ) . hasAttribute ( " logFileNameFormat " ) ) {
// We previously mixed "yyyy-MM-dd{#|T}hh-MM-ss" with "yyyy-MM-dd{#|T}HH-MM-ss"
// which is slightly different {always use 24-hour clock even if AM/PM is
// present (it isn't)} and that broke some code that requires an exact
// string to work with - now always change it to "HH":
2021-12-07 06:21:39 +01:00
pHost - > mLogFileNameFormat = attributes ( ) . value ( qsl ( " logFileNameFormat " ) ) . toString ( ) . replace ( QLatin1String ( " hh " ) , QLatin1String ( " HH " ) , Qt : : CaseSensitive ) ;
pHost - > mLogFileName = attributes ( ) . value ( qsl ( " logFileName " ) ) . toString ( ) ;
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2022-02-08 11:38:44 +00:00
if ( attributes ( ) . hasAttribute ( " mEditorShowBidi " ) ) {
pHost - > setEditorShowBidi ( attributes ( ) . value ( qsl ( " mEditorShowBidi " ) ) = = YES ) ;
} else {
pHost - > setEditorShowBidi ( true ) ;
2021-11-15 21:15:02 +01:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2022-07-30 07:58:47 +02:00
if ( attributes ( ) . hasAttribute ( " caretShortcut " ) ) {
2023-03-20 07:18:24 +01:00
const QStringView caretShortcut ( attributes ( ) . value ( qsl ( " caretShortcut " ) ) ) ;
2022-07-30 07:58:47 +02:00
if ( caretShortcut = = qsl ( " None " ) ) {
pHost - > mCaretShortcut = Host : : CaretShortcut : : None ;
} else if ( caretShortcut = = qsl ( " Tab " ) ) {
pHost - > mCaretShortcut = Host : : CaretShortcut : : Tab ;
} else if ( caretShortcut = = qsl ( " CtrlTab " ) ) {
pHost - > mCaretShortcut = Host : : CaretShortcut : : CtrlTab ;
} else if ( caretShortcut = = qsl ( " F6 " ) ) {
pHost - > mCaretShortcut = Host : : CaretShortcut : : F6 ;
}
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2022-07-28 09:23:04 +02:00
if ( attributes ( ) . hasAttribute ( " blankLineBehaviour " ) ) {
2023-03-20 07:18:24 +01:00
const QStringView blankLineBehaviour ( attributes ( ) . value ( qsl ( " blankLineBehaviour " ) ) ) ;
2022-07-28 09:23:04 +02:00
if ( blankLineBehaviour = = qsl ( " Hide " ) ) {
pHost - > mBlankLineBehaviour = Host : : BlankLineBehaviour : : Hide ;
} else if ( blankLineBehaviour = = qsl ( " Show " ) ) {
pHost - > mBlankLineBehaviour = Host : : BlankLineBehaviour : : Show ;
} else if ( blankLineBehaviour = = qsl ( " ReplaceWithSpace " ) ) {
pHost - > mBlankLineBehaviour = Host : : BlankLineBehaviour : : ReplaceWithSpace ;
}
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2018-05-08 12:27:07 +08:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mSearchEngineName " ) ) ) {
2017-11-02 14:51:51 +01:00
pHost - > mSearchEngineName = attributes ( ) . value ( QLatin1String ( " mSearchEngineName " ) ) . toString ( ) ;
2018-05-08 12:27:07 +08:00
} else {
2017-11-02 14:51:51 +01:00
pHost - > mSearchEngineName = QString ( " Google " ) ;
2017-10-20 06:36:03 +02:00
}
2018-10-25 23:28:36 +01:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mTimerSupressionInterval " ) ) ) {
pHost - > mTimerDebugOutputSuppressionInterval = QTime : : fromString ( attributes ( ) . value ( QLatin1String ( " mTimerSupressionInterval " ) ) . toString ( ) , QLatin1String ( " hh:mm:ss.zzz " ) ) ;
} else {
pHost - > mTimerDebugOutputSuppressionInterval = QTime ( ) ;
}
2019-07-25 15:22:14 +02:00
2018-10-07 05:49:15 +02:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mDiscordAccessFlags " ) ) ) {
2021-12-07 06:21:39 +01:00
pHost - > mDiscordAccessFlags = static_cast < Host : : DiscordOptionFlags > ( attributes ( ) . value ( qsl ( " mDiscordAccessFlags " ) ) . toString ( ) . toInt ( ) ) ;
2018-10-05 06:25:57 +02:00
}
improve: Give players full control over Discord Rich Presence (#9116)
## Summary
Players had no clear way to control what Discord shows about their
Mudlet activity. The old checkbox in the connection pane only gated
server GMCP data but didn't prevent Discord from showing "Playing
Mudlet", and the privacy controls were confusing. This PR replaces all
of that with three straightforward modes via radio buttons in Profile
Preferences > Chat:
- **Show full game details (if supported)** - full game integration with
server-provided presence (default)
- **Show Mudlet only** - only shows "playing Mudlet", game server is not
told about Discord
- **Disabled** - Discord shows nothing about Mudlet
Players pick the mode that matches their comfort level, and the existing
privacy checkboxes (hide detail, hide state, etc.) remain available in
Game details mode for finer control.
### What changed
- **Three-mode radio buttons** in Profile Preferences > Chat with a
two-column layout (modes on the left, privacy controls on the right),
replacing the old connection-pane checkbox
- **Server-origin tracking** so privacy checkboxes only gate data sent
by the game server - Lua API calls always pass through (only Disabled
mode blocks Lua entirely)
- **Mid-session mode switching** via dynamic GMCP negotiation
(Core.Supports.Add/Remove + External.Discord.Hello/Get)
- **Deferred RPC init** - Discord RPC now starts when a profile loads,
not on app launch
- **Username restriction improvements** - takes effect immediately,
case-insensitive (Discord usernames are lowercase-only since 2023),
shuts down RPC when mismatched
- **Shows logged-in Discord user** in preferences next to the
restriction field, with a tooltip explaining the desktop app requirement
when not connected
- **Presence fix** - empty string fields now send nullptr so Discord
hides them instead of showing blanks
- **Memory leak fix** - presence allocations are now freed in the
destructor regardless of RPC state
### Cleanup
- Removed obsolete discriminator field
(`mRequiredDiscordUserDiscriminator`) - Discord removed discriminators
in 2023
- Removed dead code (`getDiscordUserDetails()`, never called)
- Restored `Discord_ClearPresence` function pointer for potential future
use
- Use proper `Host::DiscordOptionFlags` types instead of raw `int`
(thanks @SlySven)
### Known quirks
- The "Hide timer" checkbox correctly omits timestamps from presence
data, but Discord's client starts its own activity timer for any
presence without a timestamp - this is Discord client behavior outside
our control.
- The "Hide large icon" setting clears the image key, but some Discord
clients fall back to the application's default icon instead of hiding it
entirely.
### Test plan
- [ ] Open Profile Preferences > Chat tab
- [ ] Switch between the three radio button modes and verify Discord
presence updates accordingly
- [ ] In Game details mode, toggle privacy checkboxes and verify fields
are hidden/shown
- [ ] Use Lua API (e.g. `setDiscordDetail("test")`) in Mudlet only mode
- should work. Try in Disabled mode - should fail with error
- [ ] Set a username restriction and verify presence clears immediately
if mismatched
- [ ] Run unit tests: `cd build && ./test/DiscordTest`
- [ ] Run functional tests: `cd build && ctest -R TDiscordModeTest -V`
Closes #6967. Supersedes #7438.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: SlySven <slysven@virginmedia.com>
2026-04-08 13:33:09 +02:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mDiscordMode " ) ) ) {
const int modeInt = attributes ( ) . value ( qsl ( " mDiscordMode " ) ) . toString ( ) . toInt ( ) ;
if ( modeInt > = Host : : DiscordDisabled & & modeInt < = Host : : DiscordShowGameDetails ) {
pHost - > mDiscordMode = static_cast < Host : : DiscordMode > ( modeInt ) ;
}
}
2018-10-07 05:49:15 +02:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " mRequiredDiscordUserName " ) ) ) {
pHost - > mRequiredDiscordUserName = attributes ( ) . value ( QLatin1String ( " mRequiredDiscordUserName " ) ) . toString ( ) ;
2018-10-05 06:25:57 +02:00
} else {
pHost - > mRequiredDiscordUserName . clear ( ) ;
}
2019-12-01 14:36:39 +00:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " playerRoomStyle " ) ) ) {
quint8 styleCode = 0 ;
quint8 outerDiameterPercentage = 0 ;
quint8 innerDiameterPercentage = 0 ;
QColor outerColor ;
QColor innerColor ;
// Retrieve current (possibly default) settings:
pHost - > getPlayerRoomStyleDetails ( styleCode , outerDiameterPercentage , innerDiameterPercentage , outerColor , innerColor ) ;
// Gather values from file:
styleCode = static_cast < quint8 > ( qBound ( 0 , attributes ( ) . value ( QLatin1String ( " playerRoomStyle " ) ) . toInt ( ) , 255 ) ) ;
outerDiameterPercentage = static_cast < quint8 > ( qBound ( 0 , attributes ( ) . value ( QLatin1String ( " playerRoomOuterDiameter " ) ) . toInt ( ) , 255 ) ) ;
innerDiameterPercentage = static_cast < quint8 > ( qBound ( 0 , attributes ( ) . value ( QLatin1String ( " playerRoomInnerDiameter " ) ) . toInt ( ) , 255 ) ) ;
Fix: correct warnings/errors found whilst working on Windows CI (#7224)
#### Brief overview of PR changes/additions
Whilst working on getting the Windows CI process to run in a
MSYS2+Mingw-w64 environment on AppVeyor in both Qt 5 and 6 and both
32-bits and 64-bits (Qt6 only supports 64-Bit builds). I ran into a
number of warnings, some of them about things deprecated in Qt 6.0 or
later. This PR should eliminate all of them for our code (though there
are a couple in upstream things).
#### Motivation for adding to Mudlet
Make the build process cleaner all around, especially with moving
forward to Qt 6.
#### Other info (issues closed, discussion etc)
The use of `std::as_const(...)` requires C++17 but we have already
mandated that. `qAsConst(...)` is deprecated in Qt 6.
Some of the places where the above was being done also were missing the
use of a `const` reference rather than the making of a constant copy of
the iterated values; these have been fixed as well.
A couple of Mudlet classes that I haven't yet cleaned up to move as much
of the class initialisation to the header as possible were reporting
initialisation ordering issue (`Host` and `TTimer`). I have fixed those
but only in the region of the issues, more work there is desirable to
clean up every remaining class - but I'm not allowed to leave "TODO:"
comments around nowadays! :grinning:
`(void) zip_error_to_str(char*, size_t, int, int))` has been obsoleted
for a long time now, and I've finally put in something in a couple of
places that will use the recommended replacement
`(zip_error_t*) zip_get_error(zip*)` and dump the error message out to
the OS console - which was not happening in the past.
`(QString) QString::fromUtf16(...)` has been obsoleted and alternatives
are suggested within the Qt documentation. I've used
`QString::fromWCharArray(...)`. Whilst this compiles ***I am not 100%
sure I have this correct and a second opinion on this change in
`./src/mudlet.cpp` is desirable!***
Qt is renaming in Qt6 a few methods that otherwise function as before:
* `(Qt::KeyboardModifiers) QDragEnterEvent::keyboardModifiers()` ==>
`QDragEnterEvent::modifiers()`
* `(Qt::KeyboardModifiers) QDragMoveEvent::keyboardModifiers()` ==>
`QDragMoveEvent::modifiers()`
* `(bool) QColor::isValidColor(const QString&)` ==> `(bool)
QColor::isValidColorName(QAnyStringView)`
* `(void) QColor::setNamedColor(const QString&)` ==> `(QColor)
QColor::fromString(QAnyStringView)`
* `(QString) QLocale::countryToString(Country)` ==> `(QString)
QLocale::territoryToString(Territory)`
Windows NTFS permissions checking was being done with a really low-level
procedure which has been deprecated in Qt 6.6 and replaced with a
slightly better (but also low-level) pair of functions:
* `(bool) qEnableNtfsPermissionChecks()`
* `(bool) qEnableNtfsPermissionChecks()`
to do the same thing in almost the same way with a lesser risk of a
"race-condition". There is a higher-level procedure involving the use of
a new class `QNtfsPermissionCheckGuard` but that is a different way of
doing things that is not a drop-in replacement AFAICT.
There was an unhandled `case` (for `QTextToSpeech::State::Synthesizing`)
in `(void) TLuaInterpreter::ttsStateChanged(QTextToSpeech::State)` -
I've put in something to report that state but it is not clear that
this, seemingly, transient state, needs anything extra than that. For
instance, given that it looks to be associated with preparing a text to
be spoken it might be reasonable to report the text involved as the
`Speaking` state does... The point at which it was introduced is also
unclear as that isn't documented!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2024-05-20 19:00:51 +00:00
outerColor = QColor : : fromString ( attributes ( ) . value ( QLatin1String ( " playerRoomPrimaryColor " ) ) . toString ( ) ) ;
innerColor = QColor : : fromString ( attributes ( ) . value ( QLatin1String ( " playerRoomSecondaryColor " ) ) . toString ( ) ) ;
2019-12-01 14:36:39 +00:00
// Store all the settings in the Host instance:
pHost - > setPlayerRoomStyleDetails ( styleCode , outerDiameterPercentage , innerDiameterPercentage , outerColor , innerColor ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2019-12-01 14:36:39 +00:00
if ( pHost - > mpMap ) {
// And the TMap instance:
pHost - > mpMap - > mPlayerRoomStyle = styleCode ;
pHost - > mpMap - > mPlayerRoomOuterDiameterPercentage = outerDiameterPercentage ;
pHost - > mpMap - > mPlayerRoomInnerDiameterPercentage = innerDiameterPercentage ;
pHost - > mpMap - > mPlayerRoomOuterColor = outerColor ;
pHost - > mpMap - > mPlayerRoomInnerColor = innerColor ;
}
}
2021-12-07 06:21:39 +01:00
pHost - > mRoomSize = attributes ( ) . value ( qsl ( " mRoomSize " ) ) . toString ( ) . toDouble ( ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2017-02-27 03:56:18 +00:00
if ( qFuzzyCompare ( 1.0 + pHost - > mRoomSize , 1.0 ) ) {
// The value is a float/double and the prior code using "== 0" is a BAD
// THING to do with non-integer number types!
2021-08-22 08:01:05 +02:00
pHost - > mRoomSize = 0.5 ; // Same value as is in Host class initializer list
2017-02-27 03:56:18 +00:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2021-12-07 06:21:39 +01:00
pHost - > mLineSize = attributes ( ) . value ( qsl ( " mLineSize " ) ) . toString ( ) . toDouble ( ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2017-02-27 03:56:18 +00:00
if ( qFuzzyCompare ( 1.0 + pHost - > mLineSize , 1.0 ) ) {
2021-08-22 08:01:05 +02:00
pHost - > mLineSize = 10.0 ; // Same value as is in Host class initializer list
2017-02-27 03:56:18 +00:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
add: separate border size control and player room marker improvements (#8975)
#### Brief overview of PR changes/additions
Closes #8857
This is a larger PR than I actually wanted it to be, but I could not
make it all work, independently. Either it was one large PR, or several
with dependencies to each other.
I think this makes more sense as a single large one, as it's all related
to the same settings window for the mapper.
This is the window with all the changes:
<img width="1116" height="1025" alt="Screenshot 2026-02-20 at 20 15 53"
src="https://github.com/user-attachments/assets/b5a7aa04-5db2-434c-b1a2-9763a96e00ff"
/>
- Separate border size from exit line size with independent spinner
controls, all rescaled to 1-11 range matching room size. The UI spinners
use a simple reciprocal mapping (`mLineSize = 50 / spinner`) to convert
the engine's inverse size representation into a "higher = thicker" scale
<img width="613" height="74" alt="Screenshot 2026-02-20 at 20 08 21"
src="https://github.com/user-attachments/assets/ffc6f141-38d2-457d-8e1e-35e042ad6be2"
/>
<img width="300" height="418" alt="Screenshot 2026-02-20 at 20 09 51"
src="https://github.com/user-attachments/assets/a55b4aa4-7b83-48e7-82c4-de3cbcab490a"
/>
<img width="300" height="412" alt="Screenshot 2026-02-20 at 20 10 05"
src="https://github.com/user-attachments/assets/8bdaccab-3e38-419f-ba4e-4c974856d66d"
/>
- Fix player room settings (style, colors) being lost when the mapper is
opened after changing them, by syncing Host and TMap copies
- Fix color swatch buttons showing stale icon alongside new color
- Player room marker radius now accounts for room size, border width,
and diagonal so 100% fully covers the room
<img width="956" height="149" alt="Screenshot 2026-02-20 at 20 11 52"
src="https://github.com/user-attachments/assets/0077c528-343a-46e1-afd5-4a3e3c31489b"
/>
- Add live-update connections for room borders, anti-alias, upper/lower
levels, and symbol scaling factor
- Extract gradient stop generation into a shared
`T2DMap::buildPlayerRoomGradientStops()` static method used by both the
map renderer and the preferences dialog
- Cache invalidation for room size changes uses per-instance member
variables instead of static locals, so multiple map views work correctly
- Fix grid line width spinner having no visible effect - grid pen now
scales with room dimensions like exits and borders, and includes the
`setCosmetic()` call that all other map pens use
#### Motivation for adding to Mudlet
The exit size control also affected border width with no way to adjust
them independently. The player room marker settings also had several
persistence bugs where values would be lost when opening the mapper.
#### Other info (issues closed, discussion etc)
None
**Test case:**
1. Open Profile Preferences > Mapper tab > Player room marker section
2. Change room size, exit size, and border size spinners independently -
verify each affects only its respective element on the map
3. Change marker colors, switch to main Mudlet window, open the mapper,
switch back to preferences and touch other controls - verify colors are
not reset
4. If using multiple map views, verify each view's symbol/label caches
invalidate independently when resized
5. Change the grid width spinner - verify grid line thickness changes
visibly on the map at any zoom level
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Zooka <136661366+ZookaOnGit@users.noreply.github.com>
2026-03-27 15:57:55 +01:00
pHost - > mRoomBorderSize = attributes ( ) . value ( qsl ( " mRoomBorderSize " ) ) . toString ( ) . toDouble ( ) ;
if ( qFuzzyCompare ( 1.0 + pHost - > mRoomBorderSize , 1.0 ) ) {
// For old profiles without border size, use mLineSize to preserve
// the previous behavior where border and exit shared the same size
pHost - > mRoomBorderSize = pHost - > mLineSize ;
}
2025-11-13 08:32:26 +01:00
pHost - > mMapGridLineSize = attributes ( ) . value ( qsl ( " mMapGridLineSize " ) ) . toString ( ) . toDouble ( ) ;
if ( qFuzzyCompare ( 1.0 + pHost - > mMapGridLineSize , 1.0 ) ) {
pHost - > mMapGridLineSize = 0.5 ; // Same value as is in Host class initializer list
}
2024-03-11 15:40:56 +00:00
const QStringView ignore ( attributes ( ) . value ( qsl ( " mDoubleClickIgnore " ) ) ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2017-04-13 03:08:31 +02:00
for ( auto character : ignore ) {
pHost - > mDoubleClickIgnore . insert ( character ) ;
2017-02-27 03:56:18 +00:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2020-03-31 01:10:28 -04:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " EditorSearchOptions " ) ) ) {
2021-12-07 06:21:39 +01:00
pHost - > setSearchOptions ( static_cast < dlgTriggerEditor : : SearchOptions > ( attributes ( ) . value ( qsl ( " EditorSearchOptions " ) ) . toInt ( ) ) ) ;
2020-10-02 16:49:19 +01:00
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2021-12-07 06:21:39 +01:00
pHost - > setDebugShowAllProblemCodepoints ( attributes ( ) . value ( qsl ( " DebugShowAllProblemCodepoints " ) ) = = YES ) ;
2019-07-25 15:22:14 +02:00
2023-05-14 15:06:15 +02:00
const bool compactInputLine = attributes ( ) . value ( QLatin1String ( " CompactInputLine " ) ) = = YES ;
2020-06-19 05:57:20 +01:00
pHost - > setCompactInputLine ( compactInputLine ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2020-06-19 05:57:20 +01:00
if ( mudlet : : self ( ) - > mpCurrentActiveHost = = pHost ) {
mudlet : : self ( ) - > dactionInputLine - > setChecked ( compactInputLine ) ;
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
Add persistent command history (#6767)
#### Brief overview of PR changes/additions
Saves each command line's history when a profile is closed and restores
the data the next time the profile is opened. Each command line is
handled separately.
#### Motivation for adding to Mudlet
It is a bounty item!
#### Other info (issues closed, discussion etc)
This works for command lines of all types, and saves them all separately
in the profile's base directory.
This should close https://github.com/Mudlet/Mudlet/issues/2007.
We'll avoid using the names for the extra command lines as part of a
filename by instead storing them in a `QSettings` per profile
`profile.ini` format file.
Using such a file to store per-profile details is something that has
been on my TODO list for years (I prototyped code to do it at least as
far back as 2016 I think) - so I have added two functions to the Host
class that hopefully can eventually replace the existing
`readProfileData(...)` and `writeProfileData(...)`.
Also added code to fix a corner case where a TCommandLine has a name
containing '/' or '\'.
Also added a limit to the number of command line history entries to
save. Otherwise it will grow indefinitely large as every single entry is
retained. A knob for this has been provided on the profile preferences
and it is saved with the profile's XML game save file (not in the base
directory of the profile). It covers the range of 0 to 10,000 entries
with a default of 500 and a logarithmic step size (1, 2, 5, 10) for each
multiple of 10. This value is applied to ALL command lines in a profile.
Note that this limit is only applied when the commend history is saved,
it can still grow to be larger than the limit whilst the profile is
active!
A pair of lua API functions are added:
* `setSaveCommandHistory([commandLineName,] save)` to enable
(`true`) or disable (`false`) the main, or if specified, any other
command-line
* `getSaveCommandHistory([commandLineName])` returns two values
first a boolean indicating whether the main, or if specified, any other
command-line will save its history (to a specified number set separately)
or not, between sessions and secondly a text message which either
reports that the history will be saved and how many entries or that it
will not and the reason why.
Also the `setConfig(...)`/`getConfig(...)` general settings functions gain
a new option `commandLineHistorySaveSize` which sets the number
of most recent commands stored for ALL command-lines in the given
profile for which saving is enabled . The setter accepts a number of
values - which are duplicates of the values available on a new "knob"
in the Profile Preferences and the getter will report which of those
has been set. Setting the 'none' or '0' option will disable saving for
ALL command-lines so that they behave as they would before this
feature is introduced.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-05-31 01:54:20 +01:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " CommandLineHistorySaveSize " ) ) ) {
pHost - > setCommandLineHistorySaveSize ( attributes ( ) . value ( QLatin1String ( " CommandLineHistorySaveSize " ) ) . toInt ( ) ) ;
} else {
// This is the default value, though prior to the introduction of this
// it would have effectively been zero:
pHost - > setCommandLineHistorySaveSize ( 500 ) ;
}
2020-06-19 05:57:20 +01:00
2021-09-26 17:01:34 +01:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " NetworkPacketTimeout " ) ) ) {
// These limits are also hard coded into the QSpinBox used to adjust
// this setting in the preferences:
pHost - > mTelnet . setPostingTimeout ( qBound ( 10 , attributes ( ) . value ( QLatin1String ( " NetworkPacketTimeout " ) ) . toInt ( ) , 500 ) ) ;
} else {
// The default value, also used up to Mudlet 4.12.0:
pHost - > mTelnet . setPostingTimeout ( 300 ) ;
}
2022-01-16 08:24:52 +00:00
if ( attributes ( ) . hasAttribute ( QLatin1String ( " ControlCharacterHandling " ) ) ) {
switch ( attributes ( ) . value ( QLatin1String ( " ControlCharacterHandling " ) ) . toInt ( ) ) {
case 1 :
2022-04-05 14:47:00 +02:00
pHost - > setControlCharacterMode ( ControlCharacterMode : : Picture ) ;
2022-01-16 08:24:52 +00:00
break ;
case 2 :
2022-04-05 14:47:00 +02:00
pHost - > setControlCharacterMode ( ControlCharacterMode : : OEM ) ;
2022-01-16 08:24:52 +00:00
break ;
case 0 :
[[fallthrough]] ;
default :
2022-04-05 14:47:00 +02:00
pHost - > setControlCharacterMode ( ControlCharacterMode : : AsIs ) ;
2022-01-16 08:24:52 +00:00
}
} else {
// The default value, also used up to Mudlet 4.14.1:
2022-04-05 14:47:00 +02:00
pHost - > setControlCharacterMode ( ControlCharacterMode : : AsIs ) ;
2022-01-16 08:24:52 +00:00
}
2023-07-30 13:48:12 +01:00
if ( attributes ( ) . hasAttribute ( qsl ( " ShowIDsInEditor " ) ) ) {
pHost - > setShowIdsInEditor ( attributes ( ) . value ( qsl ( " ShowIDsInEditor " ) ) = = YES ) ;
} else {
// The default (and for profile files from before 4.18.0):
pHost - > setShowIdsInEditor ( false ) ;
}
2022-02-08 12:36:30 +00:00
if ( attributes ( ) . hasAttribute ( qsl ( " Large2DMapAreaExitArrows " ) ) ) {
pHost - > setLargeAreaExitArrows ( attributes ( ) . value ( qsl ( " Large2DMapAreaExitArrows " ) ) = = YES ) ;
} else {
// The default (and for map/profile files from before 4.15.0):
pHost - > setLargeAreaExitArrows ( false ) ;
}
2023-03-11 00:08:28 +00:00
QMargins borders ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2022-01-24 12:19:18 +01:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2023-04-01 19:38:17 +01:00
// Only read this detail into a backup location so that it can
// be imported without changing the main setting unless it is
// needed (intended for use when importing a profile but not
// otherwise). In fact this detail is normally stored outside of
// the game save in the profile base directory:
pHost - > mBackupHostName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mInstalledModules " ) ) {
2017-02-27 03:56:18 +00:00
QMap < QString , QStringList > entry ;
readModulesDetailsMap ( entry ) ;
2009-02-08 06:30:23 +01:00
2017-02-27 03:56:18 +00:00
QMapIterator < QString , QStringList > it ( entry ) ;
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2017-02-27 03:56:18 +00:00
while ( it . hasNext ( ) ) {
it . next ( ) ;
QStringList moduleList ;
2023-05-14 15:06:15 +02:00
const QStringList entryList = it . value ( ) ;
2017-02-27 03:56:18 +00:00
moduleList < < entryList . at ( 0 ) ;
moduleList < < entryList . at ( 1 ) ;
pHost - > mInstalledModules [ it . key ( ) ] = moduleList ;
pHost - > mModulePriorities [ it . key ( ) ] = entryList . at ( 2 ) . toInt ( ) ;
2025-08-21 09:58:38 +05:30
// Also add to active modules list to match runtime state
if ( ! pHost - > mActiveModules . contains ( it . key ( ) ) ) {
pHost - > mActiveModules . append ( it . key ( ) ) ;
}
2017-02-27 03:56:18 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mInstalledPackages " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readStringList ( pHost - > mInstalledPackages , qsl ( " Host " ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " url " ) ) {
2023-04-01 19:38:17 +01:00
// Only read this detail into a backup location so that it can
// be imported without changing the main setting unless it is
// needed (intended for use when importing a profile but not
// otherwise). In fact this detail is normally stored outside of
// the game save in the profile base directory:
pHost - > mBackupUrl = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " serverPackageName " ) ) {
2017-02-27 03:56:18 +00:00
pHost - > mServerGUI_Package_name = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " serverPackageVersion " ) ) {
2018-12-28 08:16:09 -05:00
pHost - > mServerGUI_Package_version = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " port " ) ) {
2023-04-01 19:38:17 +01:00
// Only read this detail into a backup location so that it can
// be imported without changing the main setting unless it is
// needed (intended for use when importing a profile but not
// otherwise). In fact this detail is normally stored outside of
// the game save in the profile base directory:
pHost - > mBackupPort = readElementText ( ) . toInt ( ) ;
2026-01-06 14:32:09 +01:00
} else if ( readHostBorderElement ( borders , name ( ) ) ) {
// Handled by helper
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " commandLineMinimumHeight " ) ) {
2023-03-11 00:08:28 +00:00
pHost - > commandLineMinimumHeight = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " wrapAt " ) ) {
2026-08-05 06:50:01 +02:00
// toInt() yields 0 for anything unparseable, and a profile that
// wraps at zero columns can show no text at all
pHost - > mWrapAt = qMax ( 1 , readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " wrapIndentCount " ) ) {
2017-02-27 03:56:18 +00:00
pHost - > mWrapIndentCount = readElementText ( ) . toInt ( ) ;
2025-02-05 11:54:47 +03:30
} else if ( name ( ) = = qsl ( " wrapHangingIndentCount " ) ) {
pHost - > mWrapHangingIndentCount = readElementText ( ) . toInt ( ) ;
add option to undo the game's own line wrapping (#9455)
https://github.com/user-attachments/assets/49e8a176-899c-43fd-a931-6e04ab5b5efb
#### Brief overview of PR changes/additions
New opt-in profile option that rejoins lines the game hard-wrapped
itself, so triggers see the whole logical line and Mudlet's own wrapping
handles display. Enable in Settings → Main display, or
`setConfig("undoServerWrap", true)`. Prompts, blank lines, MXP `<br>`
and script-fed text never join, and prose/indentation gates keep ASCII
art, menus and tables intact. A one-time callout points the option out,
and games that look like they wrap raise a one-time hint with a
click-to-enable link.
#### Motivation for adding to Mudlet
On games that can't disable server-side wrapping, triggers need fragile
multiline patterns. This fixes it client-side - as far as we know, a
first among MUD clients.
#### Other info (issues closed, discussion etc)
Tests added.
---------
Signed-off-by: Vadim Peretokin <vadim.peretokin@mudlet.org>
2026-07-20 22:45:10 +02:00
} else if ( name ( ) = = qsl ( " undoServerWrapWidth " ) ) {
pHost - > mUndoServerWrapWidth = qBound ( 20 , readElementText ( ) . toInt ( ) , 500 ) ;
Add UI option for setting buffer size, increase default to 100,000 (#8222)
<!-- 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 UI option for setting buffer size:
[Screencast from 2025-09-15
08-10-18.webm](https://github.com/user-attachments/assets/e5c0ec57-d7e1-4014-95d5-f57403717489)
#### Motivation for adding to Mudlet
Requested by players in the [2025 player
survey](https://www.mudlet.org/2025/09/mudlet-2025-survey-responses/).
Closes https://github.com/Mudlet/Mudlet/issues/8145. The logic is
straightforward: options players ask for should be added, options
players aren't asking for should not be added.
#### Other info (issues closed, discussion etc)
The 'use maximum size possible' option, which sets the buffer to the
maximum amount of lines RAM can handle, is something that has been in
the code for a while. It isalso mirrored to the Lua script for
consistency to UI. That does present a problem however - if you have
more than 1 console set to maximum size, you will use more memory than
your system can handle, which some folks have done in the past and
complained about it. This could use solving - with a global maximum on
the entire Mudlet instance, perhaps? Ideas welcome.
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-09-17 09:25:07 +02:00
} else if ( name ( ) = = qsl ( " consoleBufferSize " ) ) {
pHost - > mConsoleBufferSize = readElementText ( ) . toInt ( ) ;
} else if ( name ( ) = = qsl ( " useMaxConsoleBufferSize " ) ) {
pHost - > mUseMaxConsoleBufferSize = ( readElementText ( ) = = qsl ( " yes " ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mCommandSeparator " ) ) {
2017-02-27 03:56:18 +00:00
pHost - > mCommandSeparator = readElementText ( ) ;
2026-01-06 14:32:09 +01:00
} else if ( readHostColorElement ( pHost , name ( ) ) ) {
// Handled by helper
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mDisplayFont " ) ) {
2019-08-23 07:30:54 +02:00
pHost - > setDisplayFontFromString ( readElementText ( ) ) ;
2025-02-12 06:16:42 +00:00
# if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
2025-08-24 09:18:54 +02:00
# if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
2025-02-12 06:16:42 +00:00
// On GNU/Linux and FreeBSD ensure that emojis are displayed in
// colour even if this font doesn't support it:
2025-07-06 16:47:25 +01:00
QFont : : insertSubstitution ( pHost - > getDisplayFont ( ) . family ( ) , qsl ( " Noto Color Emoji " ) ) ;
2025-08-24 09:18:54 +02:00
# endif
// For Qt 6.9+, emoji font support is handled globally in FontManager::addEmojiFont()
2020-03-24 23:23:35 +00:00
# endif
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mCommandLineFont " ) ) {
2025-07-06 16:47:25 +01:00
// We use the same font as the main console now so discard this
// one silently:
Q_UNUSED ( readElementText ( ) )
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " commandSeperator " ) ) {
2017-02-27 03:56:18 +00:00
// Ignore this misspelled duplicate, it has been removed from
// the Xml format but will appear in older files and trip the
// QDebug() error reporting associated with the following
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
// readUnknownElement(...) for "anything not otherwise parsed"
2023-04-01 19:38:17 +01:00
Q_UNUSED ( readElementText ( ) )
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mSpellDic " ) ) {
2019-03-08 09:28:55 +01:00
pHost - > setSpellDic ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mLineSize " ) | | name ( ) = = qsl ( " mRoomSize " ) ) {
2017-02-27 03:56:18 +00:00
// These two have been dropped from the Xml format as these are
// duplicates of attributes that were being incorrected read in
// the parent <Host ...> element as integers {they are stored as
// decimals but for the first one at least, it is a decimal
// number n, where 0.1 <= n <= 1.1 so was being read as "0" for
// all but the greatest 2 values where it was read as "1"!}
// We still check for them so that we avoid falling into the
// QDebug() error reporting associated with the following
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
// readUnknownElement(...) for "anything not otherwise parsed"
2025-04-27 18:48:34 +01:00
Q_UNUSED ( readElementText ( ) )
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mMapInfoContributors " ) ) {
2022-01-24 12:19:18 +01:00
readLegacyMapInfoContributors ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mapInfoContributor " ) ) {
2022-01-24 12:19:18 +01:00
readMapInfoContributor ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " profileShortcut " ) ) {
2022-01-24 12:19:18 +01:00
readProfileShortcut ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " stopwatches " ) ) {
2019-11-30 16:43:26 +00:00
readStopWatchMap ( ) ;
2026-03-06 12:24:16 -05:00
} else if ( name ( ) = = qsl ( " MMCP " ) ) {
readMMCPOptions ( ) ;
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
} else if ( name ( ) = = qsl ( " experiment " ) ) {
QString key = attributes ( ) . value ( qsl ( " key " ) ) . toString ( ) ;
bool enabled = attributes ( ) . value ( qsl ( " enabled " ) ) = = YES ;
if ( enabled & & ! key . isEmpty ( ) ) {
mpHost - > setExperimentEnabled ( key , true ) ;
}
readElementText ( ) ; // consume the element
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " Host " ) ) ;
2017-02-27 03:56:18 +00:00
}
}
}
Improve: Support Mud Terminal Type Standard (MTTS) (#7036)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Implemented [Mud Terminal Type
Standard](https://tintin.mudhalla.net/protocols/mtts/) (MTTS):
* Added "Advertise screen reader use to games supporting MTTS" to the
Accessibility menu
* Added "Force MTTS Negotiation Off" to the Special Options menu
* Negotiate MTTS when prompted by the server, telling servers that
* Client supports all common ANSI color codes.
* Client supports all common VT100 codes (we don't, I think?).
* Client is using UTF-8 character encoding.
* Client supports all 256 color codes.
* Client supports xterm mouse tracking (we don't, I think?).
* Client supports the OSC color palette.
* Client is using a screen reader (opt-in required, not advertised by
default)
* Client is a proxy allowing different users to connect from the same IP
address
* Client supports truecolor codes using semicolon notation.
* Client supports the Mud New Environment Standard for information
exchange (we don't, yet).
* Client supports the Mud Server Link Protocol for clickable link
handling (we don't, yet).
* Client supports SSL for data encryption, preferably TLS 1.3 or higher.
#### Motivation for adding to Mudlet
Advertise that Mudlet supports many of the above items (particularly
UTF-8, TRUECOLOR, Screen Reader)
#### Other info (issues closed, discussion etc)
Closes #1208
Out of scope: Initiating another negotiation if supported standards
change during session
---------
Co-authored-by: Michael Conley <mconley@michaels-mbp.lan>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-12-24 06:13:19 -05:00
2026-03-09 09:26:29 +01:00
pHost - > setUserBorders ( borders ) ;
2023-03-11 00:08:28 +00:00
pHost - > loadPackageInfo ( ) ;
2020-12-29 08:50:58 +01:00
}
2019-01-06 06:29:16 -05:00
2026-01-06 14:32:09 +01:00
bool XMLimport : : readHostColorElement ( Host * pHost , QStringView elementName )
{
// Simple colors (no alpha channel)
static const QHash < QString , QColor Host : : * > simpleColors = {
{ qsl ( " mCommandLineFgColor " ) , & Host : : mCommandLineFgColor } ,
{ qsl ( " mCommandLineBgColor " ) , & Host : : mCommandLineBgColor } ,
{ qsl ( " mFgColor " ) , & Host : : mFgColor } ,
{ qsl ( " mCommandFgColor " ) , & Host : : mCommandFgColor } ,
{ qsl ( " mCommandBgColor " ) , & Host : : mCommandBgColor } ,
{ qsl ( " mBlack " ) , & Host : : mBlack } ,
{ qsl ( " mLightBlack " ) , & Host : : mLightBlack } ,
{ qsl ( " mRed " ) , & Host : : mRed } ,
{ qsl ( " mLightRed " ) , & Host : : mLightRed } ,
{ qsl ( " mBlue " ) , & Host : : mBlue } ,
{ qsl ( " mLightBlue " ) , & Host : : mLightBlue } ,
{ qsl ( " mGreen " ) , & Host : : mGreen } ,
{ qsl ( " mLightGreen " ) , & Host : : mLightGreen } ,
{ qsl ( " mYellow " ) , & Host : : mYellow } ,
{ qsl ( " mLightYellow " ) , & Host : : mLightYellow } ,
{ qsl ( " mCyan " ) , & Host : : mCyan } ,
{ qsl ( " mLightCyan " ) , & Host : : mLightCyan } ,
{ qsl ( " mMagenta " ) , & Host : : mMagenta } ,
{ qsl ( " mLightMagenta " ) , & Host : : mLightMagenta } ,
{ qsl ( " mWhite " ) , & Host : : mWhite } ,
{ qsl ( " mLightWhite " ) , & Host : : mLightWhite } ,
{ qsl ( " mFgColor2 " ) , & Host : : mFgColor_2 } ,
{ qsl ( " mLowerLevelColor " ) , & Host : : mLowerLevelColor } ,
{ qsl ( " mUpperLevelColor " ) , & Host : : mUpperLevelColor } ,
{ qsl ( " mRoomBorderColor " ) , & Host : : mRoomBorderColor } ,
{ qsl ( " mRoomCollisionBorderColor " ) , & Host : : mRoomCollisionBorderColor } ,
{ qsl ( " mBlack2 " ) , & Host : : mBlack_2 } ,
{ qsl ( " mLightBlack2 " ) , & Host : : mLightBlack_2 } ,
{ qsl ( " mRed2 " ) , & Host : : mRed_2 } ,
{ qsl ( " mLightRed2 " ) , & Host : : mLightRed_2 } ,
{ qsl ( " mBlue2 " ) , & Host : : mBlue_2 } ,
{ qsl ( " mLightBlue2 " ) , & Host : : mLightBlue_2 } ,
{ qsl ( " mGreen2 " ) , & Host : : mGreen_2 } ,
{ qsl ( " mLightGreen2 " ) , & Host : : mLightGreen_2 } ,
{ qsl ( " mYellow2 " ) , & Host : : mYellow_2 } ,
{ qsl ( " mLightYellow2 " ) , & Host : : mLightYellow_2 } ,
{ qsl ( " mCyan2 " ) , & Host : : mCyan_2 } ,
{ qsl ( " mLightCyan2 " ) , & Host : : mLightCyan_2 } ,
{ qsl ( " mMagenta2 " ) , & Host : : mMagenta_2 } ,
{ qsl ( " mLightMagenta2 " ) , & Host : : mLightMagenta_2 } ,
{ qsl ( " mWhite2 " ) , & Host : : mWhite_2 } ,
{ qsl ( " mLightWhite2 " ) , & Host : : mLightWhite_2 } ,
} ;
// Colors that support alpha channel
static const QHash < QString , QColor Host : : * > alphaColors = {
2026-02-05 03:15:10 -08:00
{ qsl ( " mBgColor " ) , & Host : : mBgColor } ,
2026-01-06 14:32:09 +01:00
{ qsl ( " mBgColor2 " ) , & Host : : mBgColor_2 } ,
{ qsl ( " mMapGridColor " ) , & Host : : mMapGridColor } ,
{ qsl ( " mMapInfoBg " ) , & Host : : mMapInfoBg } ,
} ;
const QString elemName = elementName . toString ( ) ;
if ( auto it = simpleColors . find ( elemName ) ; it ! = simpleColors . end ( ) ) {
pHost - > * it . value ( ) = QColor : : fromString ( readElementText ( ) ) ;
return true ;
}
if ( auto it = alphaColors . find ( elemName ) ; it ! = alphaColors . end ( ) ) {
const int alpha = attributes ( ) . hasAttribute ( qsl ( " alpha " ) ) ? attributes ( ) . value ( qsl ( " alpha " ) ) . toInt ( ) : 255 ;
pHost - > * it . value ( ) = QColor : : fromString ( readElementText ( ) ) ;
( pHost - > * it . value ( ) ) . setAlpha ( alpha ) ;
return true ;
}
return false ;
}
bool XMLimport : : readHostBorderElement ( QMargins & borders , QStringView elementName )
{
if ( elementName = = qsl ( " borderTopHeight " ) ) {
borders . setTop ( readElementText ( ) . toInt ( ) ) ;
return true ;
}
if ( elementName = = qsl ( " borderBottomHeight " ) ) {
borders . setBottom ( readElementText ( ) . toInt ( ) ) ;
return true ;
}
if ( elementName = = qsl ( " borderLeftWidth " ) ) {
borders . setLeft ( readElementText ( ) . toInt ( ) ) ;
return true ;
}
if ( elementName = = qsl ( " borderRightWidth " ) ) {
borders . setRight ( readElementText ( ) . toInt ( ) ) ;
return true ;
}
return false ;
}
2025-04-17 02:22:26 +01:00
bool XMLimport : : readDefaultTrueBool ( QString name )
{
2020-12-29 08:50:58 +01:00
return attributes ( ) . value ( name ) = = YES | | ! attributes ( ) . hasAttribute ( name ) ;
2017-02-27 03:56:18 +00:00
}
2009-02-08 06:30:23 +01:00
2017-10-10 23:03:57 -04:00
// returns the ID of the root imported trigger/group
int XMLimport : : readTriggerPackage ( )
2009-02-06 03:39:14 +01:00
{
2017-10-10 23:03:57 -04:00
int parentItemID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-06 03:39:14 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2009-02-06 03:39:14 +01:00
break ;
}
2009-03-01 13:51:33 +01:00
2017-02-27 03:56:18 +00:00
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " TriggerGroup " ) | | name ( ) = = qsl ( " Trigger " ) ) {
2011-05-28 02:13:53 +02:00
gotTrigger = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
parentItemID = readTrigger ( mPackageName . isEmpty ( ) ? nullptr : mpTrigger ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " TriggerPackage " ) ) ;
2009-02-06 03:39:14 +01:00
}
2017-02-27 03:56:18 +00:00
}
}
2017-10-10 23:03:57 -04:00
return parentItemID ;
2017-02-27 03:56:18 +00:00
}
2017-10-10 23:03:57 -04:00
// imports a trigger and returns its ID - in case of a group, returns the ID
// of the top-level trigger group.
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readTrigger ( TTrigger * pParent )
2017-02-27 03:56:18 +00:00
{
2017-04-09 19:49:02 +02:00
auto pT = new TTrigger ( pParent , mpHost ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
pT - > mModuleMember = true ;
}
mpHost - > getTriggerUnit ( ) - > registerTrigger ( pT ) ;
2021-12-07 06:21:39 +01:00
pT - > setIsActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
pT - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
pT - > setTemporary ( attributes ( ) . value ( qsl ( " isTempTrigger " ) ) = = YES ) ;
pT - > mIsMultiline = attributes ( ) . value ( qsl ( " isMultiline " ) ) = = YES ;
pT - > mPerlSlashGOption = attributes ( ) . value ( qsl ( " isPerlSlashGOption " ) ) = = YES ;
pT - > mIsColorizerTrigger = attributes ( ) . value ( qsl ( " isColorizerTrigger " ) ) = = YES ;
pT - > mFilterTrigger = attributes ( ) . value ( qsl ( " isFilterTrigger " ) ) = = YES ;
pT - > mSoundTrigger = attributes ( ) . value ( qsl ( " isSoundTrigger " ) ) = = YES ;
pT - > mColorTrigger = attributes ( ) . value ( qsl ( " isColorTrigger " ) ) = = YES ;
2017-02-27 03:56:18 +00:00
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
// Is this a "TriggerGroup" or a "Trigger"
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2017-02-27 03:56:18 +00:00
pT - > setName ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2017-03-12 19:19:45 +00:00
if ( ! pT - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readTrigger(...): ERROR: can not compile trigger's lua code for: " < < pT - > getName ( ) ;
2017-03-12 19:19:45 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " triggerType " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mTriggerType = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " conditonLineDelta " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mConditionLineDelta = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mStayOpen " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mStayOpen = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mCommand " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mCommand = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mFgColor " ) ) {
Fix: correct warnings/errors found whilst working on Windows CI (#7224)
#### Brief overview of PR changes/additions
Whilst working on getting the Windows CI process to run in a
MSYS2+Mingw-w64 environment on AppVeyor in both Qt 5 and 6 and both
32-bits and 64-bits (Qt6 only supports 64-Bit builds). I ran into a
number of warnings, some of them about things deprecated in Qt 6.0 or
later. This PR should eliminate all of them for our code (though there
are a couple in upstream things).
#### Motivation for adding to Mudlet
Make the build process cleaner all around, especially with moving
forward to Qt 6.
#### Other info (issues closed, discussion etc)
The use of `std::as_const(...)` requires C++17 but we have already
mandated that. `qAsConst(...)` is deprecated in Qt 6.
Some of the places where the above was being done also were missing the
use of a `const` reference rather than the making of a constant copy of
the iterated values; these have been fixed as well.
A couple of Mudlet classes that I haven't yet cleaned up to move as much
of the class initialisation to the header as possible were reporting
initialisation ordering issue (`Host` and `TTimer`). I have fixed those
but only in the region of the issues, more work there is desirable to
clean up every remaining class - but I'm not allowed to leave "TODO:"
comments around nowadays! :grinning:
`(void) zip_error_to_str(char*, size_t, int, int))` has been obsoleted
for a long time now, and I've finally put in something in a couple of
places that will use the recommended replacement
`(zip_error_t*) zip_get_error(zip*)` and dump the error message out to
the OS console - which was not happening in the past.
`(QString) QString::fromUtf16(...)` has been obsoleted and alternatives
are suggested within the Qt documentation. I've used
`QString::fromWCharArray(...)`. Whilst this compiles ***I am not 100%
sure I have this correct and a second opinion on this change in
`./src/mudlet.cpp` is desirable!***
Qt is renaming in Qt6 a few methods that otherwise function as before:
* `(Qt::KeyboardModifiers) QDragEnterEvent::keyboardModifiers()` ==>
`QDragEnterEvent::modifiers()`
* `(Qt::KeyboardModifiers) QDragMoveEvent::keyboardModifiers()` ==>
`QDragMoveEvent::modifiers()`
* `(bool) QColor::isValidColor(const QString&)` ==> `(bool)
QColor::isValidColorName(QAnyStringView)`
* `(void) QColor::setNamedColor(const QString&)` ==> `(QColor)
QColor::fromString(QAnyStringView)`
* `(QString) QLocale::countryToString(Country)` ==> `(QString)
QLocale::territoryToString(Territory)`
Windows NTFS permissions checking was being done with a really low-level
procedure which has been deprecated in Qt 6.6 and replaced with a
slightly better (but also low-level) pair of functions:
* `(bool) qEnableNtfsPermissionChecks()`
* `(bool) qEnableNtfsPermissionChecks()`
to do the same thing in almost the same way with a lesser risk of a
"race-condition". There is a higher-level procedure involving the use of
a new class `QNtfsPermissionCheckGuard` but that is a different way of
doing things that is not a drop-in replacement AFAICT.
There was an unhandled `case` (for `QTextToSpeech::State::Synthesizing`)
in `(void) TLuaInterpreter::ttsStateChanged(QTextToSpeech::State)` -
I've put in something to report that state but it is not clear that
this, seemingly, transient state, needs anything extra than that. For
instance, given that it looks to be associated with preparing a text to
be spoken it might be reasonable to report the text involved as the
`Speaking` state does... The point at which it was introduced is also
unclear as that isn't documented!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2024-05-20 19:00:51 +00:00
# if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
2017-02-27 03:56:18 +00:00
pT - > mFgColor . setNamedColor ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mBgColor " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mBgColor . setNamedColor ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " colorTriggerFgColor " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mColorTriggerFgColor . setNamedColor ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " colorTriggerBgColor " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mColorTriggerBgColor . setNamedColor ( readElementText ( ) ) ;
Fix: correct warnings/errors found whilst working on Windows CI (#7224)
#### Brief overview of PR changes/additions
Whilst working on getting the Windows CI process to run in a
MSYS2+Mingw-w64 environment on AppVeyor in both Qt 5 and 6 and both
32-bits and 64-bits (Qt6 only supports 64-Bit builds). I ran into a
number of warnings, some of them about things deprecated in Qt 6.0 or
later. This PR should eliminate all of them for our code (though there
are a couple in upstream things).
#### Motivation for adding to Mudlet
Make the build process cleaner all around, especially with moving
forward to Qt 6.
#### Other info (issues closed, discussion etc)
The use of `std::as_const(...)` requires C++17 but we have already
mandated that. `qAsConst(...)` is deprecated in Qt 6.
Some of the places where the above was being done also were missing the
use of a `const` reference rather than the making of a constant copy of
the iterated values; these have been fixed as well.
A couple of Mudlet classes that I haven't yet cleaned up to move as much
of the class initialisation to the header as possible were reporting
initialisation ordering issue (`Host` and `TTimer`). I have fixed those
but only in the region of the issues, more work there is desirable to
clean up every remaining class - but I'm not allowed to leave "TODO:"
comments around nowadays! :grinning:
`(void) zip_error_to_str(char*, size_t, int, int))` has been obsoleted
for a long time now, and I've finally put in something in a couple of
places that will use the recommended replacement
`(zip_error_t*) zip_get_error(zip*)` and dump the error message out to
the OS console - which was not happening in the past.
`(QString) QString::fromUtf16(...)` has been obsoleted and alternatives
are suggested within the Qt documentation. I've used
`QString::fromWCharArray(...)`. Whilst this compiles ***I am not 100%
sure I have this correct and a second opinion on this change in
`./src/mudlet.cpp` is desirable!***
Qt is renaming in Qt6 a few methods that otherwise function as before:
* `(Qt::KeyboardModifiers) QDragEnterEvent::keyboardModifiers()` ==>
`QDragEnterEvent::modifiers()`
* `(Qt::KeyboardModifiers) QDragMoveEvent::keyboardModifiers()` ==>
`QDragMoveEvent::modifiers()`
* `(bool) QColor::isValidColor(const QString&)` ==> `(bool)
QColor::isValidColorName(QAnyStringView)`
* `(void) QColor::setNamedColor(const QString&)` ==> `(QColor)
QColor::fromString(QAnyStringView)`
* `(QString) QLocale::countryToString(Country)` ==> `(QString)
QLocale::territoryToString(Territory)`
Windows NTFS permissions checking was being done with a really low-level
procedure which has been deprecated in Qt 6.6 and replaced with a
slightly better (but also low-level) pair of functions:
* `(bool) qEnableNtfsPermissionChecks()`
* `(bool) qEnableNtfsPermissionChecks()`
to do the same thing in almost the same way with a lesser risk of a
"race-condition". There is a higher-level procedure involving the use of
a new class `QNtfsPermissionCheckGuard` but that is a different way of
doing things that is not a drop-in replacement AFAICT.
There was an unhandled `case` (for `QTextToSpeech::State::Synthesizing`)
in `(void) TLuaInterpreter::ttsStateChanged(QTextToSpeech::State)` -
I've put in something to report that state but it is not clear that
this, seemingly, transient state, needs anything extra than that. For
instance, given that it looks to be associated with preparing a text to
be spoken it might be reasonable to report the text involved as the
`Speaking` state does... The point at which it was introduced is also
unclear as that isn't documented!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
2024-05-20 19:00:51 +00:00
# else
pT - > mFgColor = QColor : : fromString ( readElementText ( ) ) ;
} else if ( name ( ) = = qsl ( " mBgColor " ) ) {
pT - > mBgColor = QColor : : fromString ( readElementText ( ) ) ;
} else if ( name ( ) = = qsl ( " colorTriggerFgColor " ) ) {
pT - > mColorTriggerFgColor = QColor : : fromString ( readElementText ( ) ) ;
} else if ( name ( ) = = qsl ( " colorTriggerBgColor " ) ) {
pT - > mColorTriggerBgColor = QColor : : fromString ( readElementText ( ) ) ;
# endif
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mSoundFile " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mSoundFile = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " regexCodeList " ) ) {
2017-03-12 19:19:45 +00:00
// This and the next one ought to be combined into a single element
// in the next revision - sample code for "RegexCode" elements
2022-01-15 11:34:56 +01:00
// inside a "patterns" container (with a "size" attribute) is
2017-03-12 19:19:45 +00:00
// commented out in the XMLexporter class.
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readStringList ( pT - > mPatterns , what ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " regexCodePropertyList " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readIntegerList ( pT - > mPatternKinds , pT - > getName ( ) , what ) ;
2022-01-15 11:34:56 +01:00
if ( Q_UNLIKELY ( pT - > mPatterns . count ( ) ! = pT - > mPatternKinds . count ( ) ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qWarning ( ) . nospace ( ) < < " XMLimport::readTrigger(...) ERROR: "
2021-08-22 08:01:05 +02:00
" mismatch in regexCode details for Trigger: "
2022-01-15 11:34:56 +01:00
< < pT - > getName ( ) < < " there were " < < pT - > mPatterns . count ( ) < < " 'regexCodeList' sub-elements and " < < pT - > mPatternKinds . count ( )
2017-02-27 03:56:18 +00:00
< < " 'regexCodePropertyList' sub-elements so "
" something is broken! " ;
}
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
// Fixup the first 16 incorrect ANSI colour numbers from old
// code if there are any
2022-01-15 11:34:56 +01:00
if ( ! pT - > mPatterns . isEmpty ( ) ) {
remapColorsToAnsiNumber ( pT - > mPatterns , pT - > mPatternKinds ) ;
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " TriggerGroup " ) | | name ( ) = = qsl ( " Trigger " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readTrigger ( pT ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2009-02-06 03:39:14 +01:00
}
}
}
2017-02-27 03:56:18 +00:00
2022-01-15 11:34:56 +01:00
if ( ! pT - > setRegexCodeList ( pT - > mPatterns , pT - > mPatternKinds ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readTrigger(...): ERROR: can not "
2017-02-27 03:56:18 +00:00
" initialize pattern list for trigger: "
< < pT - > getName ( ) ;
}
2017-10-10 23:03:57 -04:00
return pT - > getID ( ) ;
2009-02-06 03:39:14 +01:00
}
2017-10-10 23:03:57 -04:00
int XMLimport : : readTimerPackage ( )
2009-02-08 06:30:23 +01:00
{
2017-10-10 23:03:57 -04:00
int lastImportedTimerID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2009-02-08 06:30:23 +01:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " TimerGroup " ) | | name ( ) = = qsl ( " Timer " ) ) {
2017-02-27 03:56:18 +00:00
gotTimer = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
lastImportedTimerID = readTimer ( mPackageName . isEmpty ( ) ? nullptr : mpTimer ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " TimerPackage " ) ) ;
2017-02-27 03:56:18 +00:00
}
2009-02-08 06:30:23 +01:00
}
2017-02-27 03:56:18 +00:00
}
2017-10-10 23:03:57 -04:00
return lastImportedTimerID ;
2017-02-27 03:56:18 +00:00
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readTimer ( TTimer * pParent )
2017-02-27 03:56:18 +00:00
{
2017-04-09 19:49:02 +02:00
auto pT = new TTimer ( pParent , mpHost ) ;
2017-02-27 03:56:18 +00:00
2021-12-07 06:21:39 +01:00
pT - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
2019-04-12 21:49:22 +01:00
// This should not ever be set here as, by definition, temporary timers
// are not saved:
2021-12-07 06:21:39 +01:00
pT - > setTemporary ( attributes ( ) . value ( qsl ( " isTempTimer " ) ) = = YES ) ;
2017-02-27 03:56:18 +00:00
2019-04-12 21:49:22 +01:00
// This clears the Tree<TTimer>::mUserActiveState flag so MUST be done
// BEFORE that flag is parsed:
2017-02-27 03:56:18 +00:00
mpHost - > getTimerUnit ( ) - > registerTimer ( pT ) ;
2019-04-12 21:49:22 +01:00
2021-12-07 06:21:39 +01:00
pT - > setShouldBeActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
pT - > mModuleMember = true ;
}
2009-03-01 13:51:33 +01:00
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2017-02-27 03:56:18 +00:00
pT - > setName ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2017-03-12 19:19:45 +00:00
if ( ! pT - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readTimer(...): ERROR: can not compile timer's lua code for: " < < pT - > getName ( ) ;
2017-03-12 19:19:45 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " command " ) ) {
2017-02-27 03:56:18 +00:00
pT - > mCommand = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " time " ) ) {
2017-02-27 03:56:18 +00:00
pT - > setTime ( QTime : : fromString ( readElementText ( ) , " hh:mm:ss.zzz " ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " TimerGroup " ) | | name ( ) = = qsl ( " Timer " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readTimer ( pT ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2017-03-27 19:19:32 +01:00
}
}
}
if ( ! pT - > mpParent & & pT - > shouldBeActive ( ) ) {
pT - > setIsActive ( true ) ;
pT - > enableTimer ( pT - > getID ( ) ) ;
}
2017-10-10 23:03:57 -04:00
return pT - > getID ( ) ;
2017-03-27 19:19:32 +01:00
}
2017-10-10 23:03:57 -04:00
int XMLimport : : readAliasPackage ( )
2017-02-27 03:56:18 +00:00
{
2017-10-10 23:03:57 -04:00
int lastImportedAliasID = - 1 ;
2017-03-27 19:19:32 +01:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " AliasGroup " ) | | name ( ) = = qsl ( " Alias " ) ) {
2017-03-27 19:19:32 +01:00
gotAlias = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
lastImportedAliasID = readAlias ( mPackageName . isEmpty ( ) ? nullptr : mpAlias ) ;
2017-03-27 19:19:32 +01:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " AliasPackage " ) ) ;
2017-03-27 19:19:32 +01:00
}
}
2009-02-08 06:30:23 +01:00
}
2017-10-10 23:03:57 -04:00
return lastImportedAliasID ;
2017-03-27 19:19:32 +01:00
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readAlias ( TAlias * pParent )
2017-03-27 19:19:32 +01:00
{
2017-04-09 19:49:02 +02:00
auto pT = new TAlias ( pParent , mpHost ) ;
2017-03-27 19:19:32 +01:00
mpHost - > getAliasUnit ( ) - > registerAlias ( pT ) ;
2021-12-07 06:21:39 +01:00
pT - > setIsActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
pT - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
2017-03-27 19:19:32 +01:00
if ( module ) {
pT - > mModuleMember = true ;
2017-02-27 03:56:18 +00:00
}
2017-03-27 19:19:32 +01:00
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-03-27 19:19:32 +01:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2017-03-27 19:19:32 +01:00
pT - > setName ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2017-03-27 19:19:32 +01:00
pT - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2017-03-27 19:19:32 +01:00
if ( ! pT - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readAlias(...): ERROR: can not compile alias's lua code for: " < < pT - > getName ( ) ;
2017-03-27 19:19:32 +01:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " command " ) ) {
2017-03-27 19:19:32 +01:00
pT - > mCommand = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " regex " ) ) {
2017-03-27 19:19:32 +01:00
pT - > setRegexCode ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " AliasGroup " ) | | name ( ) = = qsl ( " Alias " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readAlias ( pT ) ;
2017-03-27 19:19:32 +01:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2017-03-27 19:19:32 +01:00
}
}
2017-02-27 03:56:18 +00:00
}
2017-10-10 23:03:57 -04:00
return pT - > getID ( ) ;
2017-03-27 19:19:32 +01:00
}
2009-02-06 03:39:14 +01:00
2017-10-10 23:03:57 -04:00
int XMLimport : : readActionPackage ( )
2017-03-27 19:19:32 +01:00
{
2017-10-10 23:03:57 -04:00
int lastImportedActionID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-06 03:39:14 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2009-02-08 06:30:23 +01:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " ActionGroup " ) | | name ( ) = = qsl ( " Action " ) ) {
2017-03-27 19:19:32 +01:00
gotAction = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
lastImportedActionID = readAction ( mPackageName . isEmpty ( ) ? nullptr : mpAction ) ;
2017-03-27 19:19:32 +01:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " ActionPackage " ) ) ;
2017-03-27 19:19:32 +01:00
}
2009-02-08 06:30:23 +01:00
}
2017-03-27 19:19:32 +01:00
}
2017-10-10 23:03:57 -04:00
return lastImportedActionID ;
2017-03-27 19:19:32 +01:00
}
2009-03-01 13:51:33 +01:00
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readAction ( TAction * pParent )
2017-03-27 19:19:32 +01:00
{
2017-04-09 19:49:02 +02:00
auto pT = new TAction ( pParent , mpHost ) ;
2017-03-27 19:19:32 +01:00
2021-12-07 06:21:39 +01:00
pT - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
2026-08-04 23:18:32 +01:00
pT - > setIsPushDownButton ( attributes ( ) . value ( qsl ( " isPushButton " ) ) = = YES ) ;
pT - > setButtonFlat ( attributes ( ) . value ( qsl ( " isFlatButton " ) ) = = YES ) ;
2021-12-07 06:21:39 +01:00
pT - > mUseCustomLayout = attributes ( ) . value ( qsl ( " useCustomLayout " ) ) = = YES ;
2017-03-27 19:19:32 +01:00
mpHost - > getActionUnit ( ) - > registerAction ( pT ) ;
2021-12-07 06:21:39 +01:00
pT - > setIsActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
2017-03-27 19:19:32 +01:00
if ( module ) {
pT - > mModuleMember = true ;
}
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-03-27 19:19:32 +01:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setName ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2011-05-28 23:04:59 +02:00
pT - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2017-03-12 19:19:45 +00:00
if ( ! pT - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readAction(...): ERROR: can not compile action's lua code for: " < < pT - > getName ( ) ;
2017-03-12 19:19:45 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " css " ) ) {
2009-03-11 01:31:30 +01:00
pT - > css = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " commandButtonUp " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setCommandButtonUp ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " commandButtonDown " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setCommandButtonDown ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " icon " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setIcon ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " orientation " ) ) {
2009-02-20 13:21:26 +01:00
pT - > mOrientation = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " location " ) ) {
2009-02-20 13:21:26 +01:00
pT - > mLocation = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " buttonRotation " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setButtonRotation ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " sizeX " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setSizeX ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " sizeY " ) ) {
2026-08-04 23:18:32 +01:00
pT - > setSizeY ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " mButtonState " ) ) {
2017-03-23 14:15:09 +00:00
// We now use a boolean but file must use original "1" (false)
// or "2" (true) for backward compatibility
2017-04-11 19:37:13 +01:00
pT - > mButtonState = ( readElementText ( ) . toInt ( ) = = 2 ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " buttonColor " ) ) {
2022-06-27 20:36:51 +01:00
// Not longer present/used, skip over it if it is still in file:
skipCurrentElement ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " buttonColumn " ) ) {
2026-08-04 23:18:32 +01:00
// The above ought to have been plural!
pT - > setButtonColumns ( readElementText ( ) . toInt ( ) ) ;
} else if ( name ( ) = = qsl ( " buttonFillerOffset " ) ) {
pT - > setButtonFillerOffset ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " posX " ) ) {
2009-02-20 13:21:26 +01:00
pT - > mPosX = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " posY " ) ) {
2009-02-20 13:21:26 +01:00
pT - > mPosY = readElementText ( ) . toInt ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " ActionGroup " ) | | name ( ) = = qsl ( " Action " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readAction ( pT ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2009-02-08 06:30:23 +01:00
}
}
}
2017-10-10 23:03:57 -04:00
return pT - > getID ( ) ;
2009-02-08 06:30:23 +01:00
}
2017-10-10 23:03:57 -04:00
int XMLimport : : readScriptPackage ( )
2009-02-08 06:30:23 +01:00
{
2017-10-10 23:03:57 -04:00
int lastImportedScriptID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2009-02-08 06:30:23 +01:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " ScriptGroup " ) | | name ( ) = = qsl ( " Script " ) ) {
2011-05-28 02:13:53 +02:00
gotScript = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
lastImportedScriptID = readScript ( mPackageName . isEmpty ( ) ? nullptr : mpScript ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " ScriptPackage " ) ) ;
2009-02-08 06:30:23 +01:00
}
}
}
2017-10-10 23:03:57 -04:00
return lastImportedScriptID ;
2009-02-08 06:30:23 +01:00
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readScript ( TScript * pParent )
2009-02-08 06:30:23 +01:00
{
2021-09-30 09:56:03 +02:00
auto script = new TScript ( pParent , mpHost ) ;
2017-02-27 03:56:18 +00:00
2021-12-07 06:21:39 +01:00
script - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
2021-09-30 09:56:03 +02:00
mpHost - > getScriptUnit ( ) - > registerScript ( script ) ;
2021-12-07 06:21:39 +01:00
script - > setIsActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
2021-09-30 09:56:03 +02:00
script - > mModuleMember = true ;
2017-02-27 03:56:18 +00:00
}
2009-03-01 13:51:33 +01:00
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2021-09-30 09:56:03 +02:00
script - > mName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2021-09-30 09:56:03 +02:00
script - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2021-09-30 09:56:03 +02:00
if ( ! script - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) . noquote ( ) < < " XMLimport::readScript(...) ERROR - can not compile script's lua code for \" " < < script - > getName ( ) < < " \" ; reason: " < < script - > getError ( ) < < " . " ;
2017-03-12 19:19:45 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " eventHandlerList " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readStringList ( script - > mEventHandlerList , what ) ;
2021-09-30 09:56:03 +02:00
script - > setEventHandlerList ( script - > mEventHandlerList ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " ScriptGroup " ) | | name ( ) = = qsl ( " Script " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readScript ( script ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2009-02-08 06:30:23 +01:00
}
}
}
2017-10-10 23:03:57 -04:00
2021-09-30 09:56:03 +02:00
return script - > getID ( ) ;
2009-02-08 06:30:23 +01:00
}
2017-10-10 23:03:57 -04:00
int XMLimport : : readKeyPackage ( )
2009-02-08 06:30:23 +01:00
{
2017-10-10 23:03:57 -04:00
int lastImportedKeyID = - 1 ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
2009-02-08 06:30:23 +01:00
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " KeyGroup " ) | | name ( ) = = qsl ( " Key " ) ) {
2011-05-28 02:13:53 +02:00
gotKey = true ;
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
lastImportedKeyID = readKey ( mPackageName . isEmpty ( ) ? nullptr : mpKey ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " KeyPackage " ) ) ;
2009-02-08 06:30:23 +01:00
}
}
}
2017-10-10 23:03:57 -04:00
return lastImportedKeyID ;
2009-02-08 06:30:23 +01:00
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
int XMLimport : : readKey ( TKey * pParent )
2009-02-08 06:30:23 +01:00
{
2017-04-09 19:49:02 +02:00
auto pT = new TKey ( pParent , mpHost ) ;
2017-02-27 03:56:18 +00:00
mpHost - > getKeyUnit ( ) - > registerKey ( pT ) ;
2021-12-07 06:21:39 +01:00
pT - > setIsActive ( attributes ( ) . value ( qsl ( " isActive " ) ) = = YES ) ;
pT - > setIsFolder ( attributes ( ) . value ( qsl ( " isFolder " ) ) = = YES ) ;
2017-02-27 03:56:18 +00:00
if ( module ) {
2011-10-11 04:09:28 +02:00
pT - > mModuleMember = true ;
2017-02-27 03:56:18 +00:00
}
2009-03-01 13:51:33 +01:00
2023-05-14 15:06:15 +02:00
const QString what = name ( ) . toString ( ) ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2017-06-04 03:36:49 -04:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " name " ) ) {
2017-06-04 03:36:49 -04:00
pT - > setName ( readElementText ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " packageName " ) ) {
2011-05-28 23:04:59 +02:00
pT - > mPackageName = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " script " ) ) {
2023-05-14 15:06:15 +02:00
const QString tempScript = readScriptElement ( ) ;
2017-03-12 19:19:45 +00:00
if ( ! pT - > setScript ( tempScript ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
qDebug ( ) . nospace ( ) < < " XMLimport::readKey(...): ERROR: can not compile key's lua code for: " < < pT - > getName ( ) ;
2017-03-12 19:19:45 +00:00
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " command " ) ) {
2009-02-08 06:30:23 +01:00
pT - > mCommand = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " keyCode " ) ) {
2020-12-23 17:26:57 +00:00
pT - > setKeyCode ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " keyModifier " ) ) {
2020-12-23 17:26:57 +00:00
pT - > setKeyModifiers ( readElementText ( ) . toInt ( ) ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " KeyGroup " ) | | name ( ) = = qsl ( " Key " ) ) {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readKey ( pT ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( what ) ;
2009-02-08 06:30:23 +01:00
}
}
}
2017-10-10 23:03:57 -04:00
return pT - > getID ( ) ;
2009-02-08 06:30:23 +01:00
}
2017-02-27 03:56:18 +00:00
void XMLimport : : readModulesDetailsMap ( QMap < QString , QStringList > & map )
2011-10-11 04:09:28 +02:00
{
QString key ;
QStringList entry ;
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
readNext ( ) ;
2011-10-11 04:09:28 +02:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " key " ) ) {
2011-10-11 04:09:28 +02:00
key = readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " filepath " ) ) {
2011-10-11 04:09:28 +02:00
entry < < readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " zipSync " ) ) {
2011-10-11 04:09:28 +02:00
entry < < readElementText ( ) ;
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " globalSave " ) ) {
2021-11-07 22:15:20 +01:00
if ( entry . size ( ) < 2 ) {
entry < < readElementText ( ) ;
} else {
skipCurrentElement ( ) ;
}
2023-03-20 07:18:24 +01:00
} else if ( name ( ) = = qsl ( " priority " ) ) {
2017-02-27 03:56:18 +00:00
// The last expected detail for the entry - so store this
// completed entry into the QMap
2011-10-11 04:09:28 +02:00
entry < < readElementText ( ) ;
map [ key ] = entry ;
entry . clear ( ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( qsl ( " ModulesDetailsMap " ) ) ;
2011-10-11 04:09:28 +02:00
}
}
}
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
void XMLimport : : readStringList ( QStringList & list , const QString & whatIsParent )
2009-02-08 06:30:23 +01:00
{
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2009-03-01 13:51:33 +01:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " string " ) ) {
2009-02-08 06:30:23 +01:00
list < < readElementText ( ) ;
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( whatIsParent ) ;
2009-02-06 03:39:14 +01:00
}
}
}
}
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
void XMLimport : : readIntegerList ( QList < int > & list , const QString & parentName , const QString & whatIsParent )
2009-02-08 06:30:23 +01:00
{
2017-02-27 03:56:18 +00:00
while ( ! atEnd ( ) ) {
2009-02-08 06:30:23 +01:00
readNext ( ) ;
2009-03-01 13:51:33 +01:00
2017-02-27 03:56:18 +00:00
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " integer " ) ) {
2023-05-14 15:06:15 +02:00
const QString numberText = readElementText ( ) ;
2009-05-19 13:06:39 +02:00
bool ok = false ;
2023-05-14 15:06:15 +02:00
const int num = numberText . toInt ( & ok , 10 ) ;
2017-02-27 03:56:18 +00:00
if ( Q_LIKELY ( ! numberText . isEmpty ( ) & & ok ) ) {
2022-10-04 23:32:50 +02:00
switch ( num ) {
case REGEX_SUBSTRING :
[[fallthrough]] ;
case REGEX_PERL :
[[fallthrough]] ;
case REGEX_BEGIN_OF_LINE_SUBSTRING :
[[fallthrough]] ;
case REGEX_EXACT_MATCH :
[[fallthrough]] ;
case REGEX_LUA_CODE :
[[fallthrough]] ;
case REGEX_LINE_SPACER :
[[fallthrough]] ;
case REGEX_COLOR_PATTERN :
[[fallthrough]] ;
case REGEX_PROMPT :
list < < num ;
break ;
default :
mpHost - > postMessage (
qsl ( " [ ERROR ] - \" %1 \" as a number when reading the 'regexCodePropertyList' element of the 'Trigger' or 'TriggerGroup' element \" %2 \" cannot be understood by this "
" version of Mudlet, is it from a later version? Converting it to a SUBSTRING type so the data can be shown but it will probably not work as expected. " )
. arg ( numberText , parentName ) ) ;
list < < REGEX_SUBSTRING ; //Set it to the default type
2023-05-14 15:06:15 +02:00
}
2022-10-04 23:32:50 +02:00
2017-02-27 03:56:18 +00:00
} else {
2022-10-04 23:32:50 +02:00
qWarning (
R " (XMLimport::readIntegerList(...) ERROR: unable to convert: " % s " to a number when reading the 'regexCodePropertyList' element of the 'Trigger' or 'TriggerGroup' element " % s " !) " ,
2017-04-12 19:09:47 -07:00
numberText . toUtf8 ( ) . constData ( ) ,
parentName . toUtf8 ( ) . constData ( ) ) ;
2022-10-04 23:32:50 +02:00
mpHost - > postMessage ( qsl ( " [ ERROR ] - Unable to convert: \" %1 \" to a number when reading the 'regexCodePropertyList' element of the 'Trigger' or 'TriggerGroup' element \" %2 \" ! " )
. arg ( numberText , parentName ) ) ;
list < < REGEX_SUBSTRING ; //Just assume most common one
2009-05-19 13:06:39 +02:00
}
2017-02-27 03:56:18 +00:00
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( whatIsParent ) ;
2009-02-08 06:30:23 +01:00
}
}
}
}
2017-04-11 19:37:13 +01:00
// This will be a string representation of a decimal float with three places of
// decimals
void XMLimport : : getVersionString ( QString & versionString )
{
versionString = QString : : number ( ( mVersionMajor * 1000 + mVersionMinor ) / 1000.0 , ' f ' , 3 ) ;
}
BugFix: allows most ASCII control characters to be used/saved in Lua Code (#995)
* BugFix: allows most ASCII control characters to be used/saved in Lua code
We use XML to save Mudlet game data including the scripts that contain
Lua code for all of the Mudlet item {Alias|Button|Key|Timer|Script|Trigger}
but because the former (at version 1.0 which is all that the Qt library
code handles) prohibits all but Horizontal Tab, Carriage Return and Line
Feed out of the range of ASCII control codes it means that a user trying to
embed a raw string containing, say, the ESC code (0x1b) will either lose
their code for just the item containing that code OR everything that
follows it in the file that it is being loaded from. As that could be the
game save data this may will cause data loss.
This commit allows all but the ASCII NULL (`\0`) character code to be
stored as it replaces the remaining control codes with a pair of other
Unicode code-points that can be safely stored, that is (U+FFFC) the Unicode
Object Replacement Character code-point followed by one of the code-points
from the Control Picture Symbol range. The former is not a visible
character in normal circumstances but the latter (if present in a font) is
typically a two or three letters in a diagonal line in a single grapheme
that has the same two or three letters used to abbreviate an ASCII Control
code in, say, visible table representations. The chances of the Object
Replacement Character occurring in ANY document is virtually zero so the
use for this purpose should be "safe" in this context and using the Control
Picture Character does have the nice feature in that viewing a saved file
with them in does suggest which character is being used - and the chances
of them being used in, even a Mudlet script, otherwise is vanishingly small
in my opinion.
Note that NO attempt is made to handle the ASCII NUL character as that is
also, symbolically the end of a C/C++ string normally and it would be
confusing to the Lua interpreter even though the Qt QString text handling
system could tolerate having such characters in positions other than at the
end of a QString.
During the development of this system to "Escape" these codes I did
experiment with the use of "XML Entities" to represent them - such as
"&ESC;" to stand in for the ASCII 0x1B character. However the Qt process
to insert such elements into the required a costly splitting the script
text up into fragments without any of the codes to be escaped so that each
code could then be injected into the QXmlStreamWriter stream interleaved
with the text fragments that surrounds them and whilst this proved to be
possible I then found that the process that then took the entities and
substituted in the original ASCII control codes when the script data was
read with the QXmlStreamReader failed to work because the
QXmlStreamEntityResolver applied the same character code restrictions onto
the replacement text - which is exactly not what was wanted!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Revise: fix wrong symbol used for DEL control code
I used the code for U+2471 {CIRCLED NUMBER EIGHTEEN} instead of U+2421
{SYMBOL FOR DELETE} to encode the ASCII Delete code (0x7F, 127) - this fix
does mean that any files saved using the code of the Pull Request before
it is applied will not convert any of the DEL codes in a saved XML file
back to the correct value automatically but I do not anticipate this will
cause significant issues...!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2017-05-14 09:44:44 +01:00
QString XMLimport : : readScriptElement ( )
{
QString localScript = readElementText ( ) ;
if ( Error ( ) ! = NoError ) {
2017-06-26 16:46:54 +02:00
qDebug ( ) < < " XMLimport::readScriptElement() ERROR: " < < errorString ( ) ;
BugFix: allows most ASCII control characters to be used/saved in Lua Code (#995)
* BugFix: allows most ASCII control characters to be used/saved in Lua code
We use XML to save Mudlet game data including the scripts that contain
Lua code for all of the Mudlet item {Alias|Button|Key|Timer|Script|Trigger}
but because the former (at version 1.0 which is all that the Qt library
code handles) prohibits all but Horizontal Tab, Carriage Return and Line
Feed out of the range of ASCII control codes it means that a user trying to
embed a raw string containing, say, the ESC code (0x1b) will either lose
their code for just the item containing that code OR everything that
follows it in the file that it is being loaded from. As that could be the
game save data this may will cause data loss.
This commit allows all but the ASCII NULL (`\0`) character code to be
stored as it replaces the remaining control codes with a pair of other
Unicode code-points that can be safely stored, that is (U+FFFC) the Unicode
Object Replacement Character code-point followed by one of the code-points
from the Control Picture Symbol range. The former is not a visible
character in normal circumstances but the latter (if present in a font) is
typically a two or three letters in a diagonal line in a single grapheme
that has the same two or three letters used to abbreviate an ASCII Control
code in, say, visible table representations. The chances of the Object
Replacement Character occurring in ANY document is virtually zero so the
use for this purpose should be "safe" in this context and using the Control
Picture Character does have the nice feature in that viewing a saved file
with them in does suggest which character is being used - and the chances
of them being used in, even a Mudlet script, otherwise is vanishingly small
in my opinion.
Note that NO attempt is made to handle the ASCII NUL character as that is
also, symbolically the end of a C/C++ string normally and it would be
confusing to the Lua interpreter even though the Qt QString text handling
system could tolerate having such characters in positions other than at the
end of a QString.
During the development of this system to "Escape" these codes I did
experiment with the use of "XML Entities" to represent them - such as
"&ESC;" to stand in for the ASCII 0x1B character. However the Qt process
to insert such elements into the required a costly splitting the script
text up into fragments without any of the codes to be escaped so that each
code could then be injected into the QXmlStreamWriter stream interleaved
with the text fragments that surrounds them and whilst this proved to be
possible I then found that the process that then took the entities and
substituted in the original ASCII control codes when the script data was
read with the QXmlStreamReader failed to work because the
QXmlStreamEntityResolver applied the same character code restrictions onto
the replacement text - which is exactly not what was wanted!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Revise: fix wrong symbol used for DEL control code
I used the code for U+2471 {CIRCLED NUMBER EIGHTEEN} instead of U+2421
{SYMBOL FOR DELETE} to encode the ASCII Delete code (0x7F, 127) - this fix
does mean that any files saved using the code of the Pull Request before
it is applied will not convert any of the DEL codes in a saved XML file
back to the correct value automatically but I do not anticipate this will
cause significant issues...!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2017-05-14 09:44:44 +01:00
}
2017-06-26 16:46:54 +02:00
if ( mVersionMajor > 1 | | ( mVersionMajor = = 1 & & mVersionMinor > 0 ) ) {
BugFix: allows most ASCII control characters to be used/saved in Lua Code (#995)
* BugFix: allows most ASCII control characters to be used/saved in Lua code
We use XML to save Mudlet game data including the scripts that contain
Lua code for all of the Mudlet item {Alias|Button|Key|Timer|Script|Trigger}
but because the former (at version 1.0 which is all that the Qt library
code handles) prohibits all but Horizontal Tab, Carriage Return and Line
Feed out of the range of ASCII control codes it means that a user trying to
embed a raw string containing, say, the ESC code (0x1b) will either lose
their code for just the item containing that code OR everything that
follows it in the file that it is being loaded from. As that could be the
game save data this may will cause data loss.
This commit allows all but the ASCII NULL (`\0`) character code to be
stored as it replaces the remaining control codes with a pair of other
Unicode code-points that can be safely stored, that is (U+FFFC) the Unicode
Object Replacement Character code-point followed by one of the code-points
from the Control Picture Symbol range. The former is not a visible
character in normal circumstances but the latter (if present in a font) is
typically a two or three letters in a diagonal line in a single grapheme
that has the same two or three letters used to abbreviate an ASCII Control
code in, say, visible table representations. The chances of the Object
Replacement Character occurring in ANY document is virtually zero so the
use for this purpose should be "safe" in this context and using the Control
Picture Character does have the nice feature in that viewing a saved file
with them in does suggest which character is being used - and the chances
of them being used in, even a Mudlet script, otherwise is vanishingly small
in my opinion.
Note that NO attempt is made to handle the ASCII NUL character as that is
also, symbolically the end of a C/C++ string normally and it would be
confusing to the Lua interpreter even though the Qt QString text handling
system could tolerate having such characters in positions other than at the
end of a QString.
During the development of this system to "Escape" these codes I did
experiment with the use of "XML Entities" to represent them - such as
"&ESC;" to stand in for the ASCII 0x1B character. However the Qt process
to insert such elements into the required a costly splitting the script
text up into fragments without any of the codes to be escaped so that each
code could then be injected into the QXmlStreamWriter stream interleaved
with the text fragments that surrounds them and whilst this proved to be
possible I then found that the process that then took the entities and
substituted in the original ASCII control codes when the script data was
read with the QXmlStreamReader failed to work because the
QXmlStreamEntityResolver applied the same character code restrictions onto
the replacement text - which is exactly not what was wanted!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Revise: fix wrong symbol used for DEL control code
I used the code for U+2471 {CIRCLED NUMBER EIGHTEEN} instead of U+2421
{SYMBOL FOR DELETE} to encode the ASCII Delete code (0x7F, 127) - this fix
does mean that any files saved using the code of the Pull Request before
it is applied will not convert any of the DEL codes in a saved XML file
back to the correct value automatically but I do not anticipate this will
cause significant issues...!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2017-05-14 09:44:44 +01:00
// This is NOT the original version, so it will have control characters
// encoded up using Object Replacement and Control Symbol (for relevant ASCII control code) code-points
2021-12-07 06:21:39 +01:00
localScript . replace ( qsl ( " \xFFFC \x2401 " ) , QChar ( ' \x01 ' ) ) ; // SOH
localScript . replace ( qsl ( " \xFFFC \x2402 " ) , QChar ( ' \x02 ' ) ) ; // STX
localScript . replace ( qsl ( " \xFFFC \x2403 " ) , QChar ( ' \x03 ' ) ) ; // ETX
localScript . replace ( qsl ( " \xFFFC \x2404 " ) , QChar ( ' \x04 ' ) ) ; // EOT
localScript . replace ( qsl ( " \xFFFC \x2405 " ) , QChar ( ' \x05 ' ) ) ; // ENQ
localScript . replace ( qsl ( " \xFFFC \x2406 " ) , QChar ( ' \x06 ' ) ) ; // ACK
localScript . replace ( qsl ( " \xFFFC \x2407 " ) , QChar ( ' \x07 ' ) ) ; // BEL
localScript . replace ( qsl ( " \xFFFC \x2408 " ) , QChar ( ' \x08 ' ) ) ; // BS
localScript . replace ( qsl ( " \xFFFC \x240B " ) , QChar ( ' \x0B ' ) ) ; // VT
localScript . replace ( qsl ( " \xFFFC \x240C " ) , QChar ( ' \x0C ' ) ) ; // FF
localScript . replace ( qsl ( " \xFFFC \x240E " ) , QChar ( ' \x0E ' ) ) ; // SS
localScript . replace ( qsl ( " \xFFFC \x240F " ) , QChar ( ' \x0F ' ) ) ; // SI
localScript . replace ( qsl ( " \xFFFC \x2410 " ) , QChar ( ' \x10 ' ) ) ; // DLE
localScript . replace ( qsl ( " \xFFFC \x2411 " ) , QChar ( ' \x11 ' ) ) ; // DC1
localScript . replace ( qsl ( " \xFFFC \x2412 " ) , QChar ( ' \x12 ' ) ) ; // DC2
localScript . replace ( qsl ( " \xFFFC \x2413 " ) , QChar ( ' \x13 ' ) ) ; // DC3
localScript . replace ( qsl ( " \xFFFC \x2414 " ) , QChar ( ' \x14 ' ) ) ; // DC4
localScript . replace ( qsl ( " \xFFFC \x2415 " ) , QChar ( ' \x15 ' ) ) ; // NAK
localScript . replace ( qsl ( " \xFFFC \x2416 " ) , QChar ( ' \x16 ' ) ) ; // SYN
localScript . replace ( qsl ( " \xFFFC \x2417 " ) , QChar ( ' \x17 ' ) ) ; // ETB
localScript . replace ( qsl ( " \xFFFC \x2418 " ) , QChar ( ' \x18 ' ) ) ; // CAN
localScript . replace ( qsl ( " \xFFFC \x2419 " ) , QChar ( ' \x19 ' ) ) ; // EM
localScript . replace ( qsl ( " \xFFFC \x241A " ) , QChar ( ' \x1A ' ) ) ; // SUB
localScript . replace ( qsl ( " \xFFFC \x241B " ) , QChar ( ' \x1B ' ) ) ; // ESC
localScript . replace ( qsl ( " \xFFFC \x241C " ) , QChar ( ' \x1C ' ) ) ; // FS
localScript . replace ( qsl ( " \xFFFC \x241D " ) , QChar ( ' \x1D ' ) ) ; // GS
localScript . replace ( qsl ( " \xFFFC \x241E " ) , QChar ( ' \x1E ' ) ) ; // RS
localScript . replace ( qsl ( " \xFFFC \x241F " ) , QChar ( ' \x1F ' ) ) ; // US
localScript . replace ( qsl ( " \xFFFC \x2421 " ) , QChar ( ' \x7F ' ) ) ; // DEL
BugFix: allows most ASCII control characters to be used/saved in Lua Code (#995)
* BugFix: allows most ASCII control characters to be used/saved in Lua code
We use XML to save Mudlet game data including the scripts that contain
Lua code for all of the Mudlet item {Alias|Button|Key|Timer|Script|Trigger}
but because the former (at version 1.0 which is all that the Qt library
code handles) prohibits all but Horizontal Tab, Carriage Return and Line
Feed out of the range of ASCII control codes it means that a user trying to
embed a raw string containing, say, the ESC code (0x1b) will either lose
their code for just the item containing that code OR everything that
follows it in the file that it is being loaded from. As that could be the
game save data this may will cause data loss.
This commit allows all but the ASCII NULL (`\0`) character code to be
stored as it replaces the remaining control codes with a pair of other
Unicode code-points that can be safely stored, that is (U+FFFC) the Unicode
Object Replacement Character code-point followed by one of the code-points
from the Control Picture Symbol range. The former is not a visible
character in normal circumstances but the latter (if present in a font) is
typically a two or three letters in a diagonal line in a single grapheme
that has the same two or three letters used to abbreviate an ASCII Control
code in, say, visible table representations. The chances of the Object
Replacement Character occurring in ANY document is virtually zero so the
use for this purpose should be "safe" in this context and using the Control
Picture Character does have the nice feature in that viewing a saved file
with them in does suggest which character is being used - and the chances
of them being used in, even a Mudlet script, otherwise is vanishingly small
in my opinion.
Note that NO attempt is made to handle the ASCII NUL character as that is
also, symbolically the end of a C/C++ string normally and it would be
confusing to the Lua interpreter even though the Qt QString text handling
system could tolerate having such characters in positions other than at the
end of a QString.
During the development of this system to "Escape" these codes I did
experiment with the use of "XML Entities" to represent them - such as
"&ESC;" to stand in for the ASCII 0x1B character. However the Qt process
to insert such elements into the required a costly splitting the script
text up into fragments without any of the codes to be escaped so that each
code could then be injected into the QXmlStreamWriter stream interleaved
with the text fragments that surrounds them and whilst this proved to be
possible I then found that the process that then took the entities and
substituted in the original ASCII control codes when the script data was
read with the QXmlStreamReader failed to work because the
QXmlStreamEntityResolver applied the same character code restrictions onto
the replacement text - which is exactly not what was wanted!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Revise: fix wrong symbol used for DEL control code
I used the code for U+2471 {CIRCLED NUMBER EIGHTEEN} instead of U+2421
{SYMBOL FOR DELETE} to encode the ASCII Delete code (0x7F, 127) - this fix
does mean that any files saved using the code of the Pull Request before
it is applied will not convert any of the DEL codes in a saved XML file
back to the correct value automatically but I do not anticipate this will
cause significant issues...!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2017-05-14 09:44:44 +01:00
}
return localScript ;
}
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
// Unlike the reverse operation in the XMLexport this can modify the supplied patternList:
void XMLimport : : remapColorsToAnsiNumber ( QStringList & patternList , const QList < int > & typeList )
{
// The regexp is slightly modified compared to the one we once used to allow
// it to capture a '-' sign as part of the color numbers as we use -2 for
// ignored which was/is/will not handled by code before Mudlet 3.17.x (and
// we might have more negative numbers in the future!)
2024-03-11 15:40:56 +00:00
const QRegularExpression regex = QRegularExpression ( qsl ( " FG(-? \\ d+)BG(-? \\ d+) " ) ) ;
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
QMutableStringListIterator itPattern ( patternList ) ;
QListIterator < int > itType ( typeList ) ;
while ( itPattern . hasNext ( ) & & itType . hasNext ( ) ) {
if ( itType . next ( ) = = REGEX_COLOR_PATTERN ) {
2024-03-11 15:40:56 +00:00
const QRegularExpressionMatch match = regex . match ( itPattern . next ( ) ) ;
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
// Although we define two '('...')' capture groups the count/size is
// 3 (0 is the whole string)!
if ( match . capturedTexts ( ) . size ( ) = = 3 ) {
bool isFgOk = false ;
bool isBgOk = false ;
int ansifg = TTrigger : : scmIgnored ;
int ansibg = TTrigger : : scmIgnored ;
int fg = match . captured ( 1 ) . toInt ( & isFgOk ) ;
if ( ! isFgOk ) {
qDebug ( ) < < " XMLimport::remapColorsToAnsiNumber(...) ERROR - failed to extract FG color code from pattern text: " < < itPattern . peekPrevious ( )
< < " setting colour to default foreground " ;
fg = TTrigger : : scmDefault ;
} else {
// clang-format off
switch ( fg ) {
case - 2 : ansifg = TTrigger : : scmIgnored ; break ; // Ignored colour - not handled by old code
case 0 : ansifg = TTrigger : : scmDefault ; break ; // Default colour
case 1 : ansifg = 8 ; break ; // Light black (dark gray)
case 2 : ansifg = 0 ; break ; // Black
case 3 : ansifg = 9 ; break ; // Light red
case 4 : ansifg = 1 ; break ; // Red
case 5 : ansifg = 10 ; break ; // Light green
case 6 : ansifg = 2 ; break ; // Green
case 7 : ansifg = 11 ; break ; // Light yellow
case 8 : ansifg = 3 ; break ; // Yellow
case 9 : ansifg = 12 ; break ; // Light blue
case 10 : ansifg = 4 ; break ; // Blue
case 11 : ansifg = 13 ; break ; // Light magenta
case 12 : ansifg = 5 ; break ; // Magenta
case 13 : ansifg = 14 ; break ; // Light cyan
case 14 : ansifg = 6 ; break ; // Cyan
case 15 : ansifg = 15 ; break ; // Light white
case 16 : ansifg = 7 ; break ; // White (light gray)
default :
ansifg = fg ;
}
// clang-format on
}
int bg = match . captured ( 2 ) . toInt ( & isBgOk ) ;
if ( ! isBgOk ) {
qDebug ( ) < < " XMLimport::remapColorsToAnsiNumber(...) ERROR - failed to extract BG color code from pattern text: " < < itPattern . peekPrevious ( )
< < " setting colour to default background " ;
bg = TTrigger : : scmDefault ;
} else {
// clang-format off
switch ( bg ) {
case - 2 : ansibg = TTrigger : : scmIgnored ; break ; // Ignored colour - not handled by old code
case 0 : ansibg = TTrigger : : scmDefault ; break ; // Default colour
case 1 : ansibg = 8 ; break ; // Light black (dark gray)
case 2 : ansibg = 0 ; break ; // Black
case 3 : ansibg = 9 ; break ; // Light red
case 4 : ansibg = 1 ; break ; // Red
case 5 : ansibg = 10 ; break ; // Light green
case 6 : ansibg = 2 ; break ; // Green
case 7 : ansibg = 11 ; break ; // Light yellow
case 8 : ansibg = 3 ; break ; // Yellow
case 9 : ansibg = 12 ; break ; // Light blue
case 10 : ansibg = 4 ; break ; // Blue
case 11 : ansibg = 13 ; break ; // Light magenta
case 12 : ansibg = 5 ; break ; // Magenta
case 13 : ansibg = 14 ; break ; // Light cyan
case 14 : ansibg = 6 ; break ; // Cyan
case 15 : ansibg = 15 ; break ; // Light white
case 16 : ansibg = 7 ; break ; // White (light gray)
default :
ansibg = bg ;
}
// clang-format on
}
// Use a different string than before so that we can be certain
// we have fixed up all cases where it is used - and it is more
// understandable if it gets revealed in the Editor!
itPattern . setValue ( TTrigger : : createColorPatternText ( ansifg , ansibg ) ) ;
}
} else {
2021-08-22 08:01:05 +02:00
// Must advance the pattern iterator if it isn't a colour pattern
Refactor: clean up TBuffer text format aspects (#1840)
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>
2019-01-28 23:23:53 +00:00
itPattern . next ( ) ;
}
}
}
2019-11-30 16:43:26 +00:00
void XMLimport : : readStopWatchMap ( )
{
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2026-07-18 18:39:57 +02:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " stopwatch " ) ) {
2023-05-14 15:06:15 +02:00
const int watchId = attributes ( ) . value ( qsl ( " id " ) ) . toInt ( ) ;
improve: improve memory safety by using smart pointers (#9239)
### Refactor: replace raw pointer ownership with smart pointers across
core subsystems
#### Brief overview of PR changes/additions
Replaces raw pointer ownership patterns with `std::unique_ptr` and
`std::map`
across several core subsystems:
- **Host**: `mStopWatchMap` (`QMap<int, stopWatch*>` → `std::map<int,
unique_ptr<stopWatch>>`), `profileShortcuts` (`QMap<QString,
QKeySequence*>` → `std::map<QString, unique_ptr<QKeySequence>>`).
Removes `qDeleteAll` in destructor and `delete mMMCPServer`.
- **TMap**: `mpRoomDB` raw pointer → `unique_ptr`
- **VarUnit**: `base` raw pointer → `unique_ptr`
- **TTrigger**: condition map storage converted to `unique_ptr`,
destructor simplified
- **discord**: handler and presence maps converted from raw pointer
`QMap` to `unique_ptr` + `std::map`
- **Updater**: `mFeed` and `mUpdateDialog` converted to `unique_ptr`
#### Motivation for adding to Mudlet
These patterns were identified as sources of memory leaks and potential
use-after-free bugs. Using smart pointers makes ownership explicit,
eliminates manual cleanup code, and ensures correct destruction even on
early-exit paths.
#### Other info (issues closed, discussion etc)
sorry this one is still pretty big, but most of the changes are the same
for each thing so reviewing them together probably makes sense. sadly
there isn't much to see here other than no slow uptick of heap size :-[
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:42:09 +12:00
auto pStopWatch = std : : make_unique < stopWatch > ( ) ;
2021-12-07 06:21:39 +01:00
pStopWatch - > setName ( attributes ( ) . value ( qsl ( " name " ) ) . toString ( ) ) ;
2019-11-30 16:43:26 +00:00
pStopWatch - > mIsPersistent = true ;
pStopWatch - > mIsInitialised = true ;
2021-12-07 06:21:39 +01:00
if ( attributes ( ) . value ( qsl ( " running " ) ) = = YES ) {
2019-11-30 16:43:26 +00:00
pStopWatch - > mIsRunning = true ;
// The stored value is the point in epoch time that the
// stopwatch appears to have been started so we need to
// make that into a QDateTime that is the equivalent:
2021-12-07 06:21:39 +01:00
pStopWatch - > mEffectiveStartDateTime . setMSecsSinceEpoch ( attributes ( ) . value ( qsl ( " effectiveStartDateTimeEpochMSecs " ) ) . toLongLong ( ) ) ;
2019-11-30 16:43:26 +00:00
} else {
pStopWatch - > mIsRunning = false ;
2021-12-07 06:21:39 +01:00
pStopWatch - > mElapsedTime = attributes ( ) . value ( qsl ( " elapsedDateTimeMSecs " ) ) . toLongLong ( ) ;
2019-11-30 16:43:26 +00:00
}
improve: improve memory safety by using smart pointers (#9239)
### Refactor: replace raw pointer ownership with smart pointers across
core subsystems
#### Brief overview of PR changes/additions
Replaces raw pointer ownership patterns with `std::unique_ptr` and
`std::map`
across several core subsystems:
- **Host**: `mStopWatchMap` (`QMap<int, stopWatch*>` → `std::map<int,
unique_ptr<stopWatch>>`), `profileShortcuts` (`QMap<QString,
QKeySequence*>` → `std::map<QString, unique_ptr<QKeySequence>>`).
Removes `qDeleteAll` in destructor and `delete mMMCPServer`.
- **TMap**: `mpRoomDB` raw pointer → `unique_ptr`
- **VarUnit**: `base` raw pointer → `unique_ptr`
- **TTrigger**: condition map storage converted to `unique_ptr`,
destructor simplified
- **discord**: handler and presence maps converted from raw pointer
`QMap` to `unique_ptr` + `std::map`
- **Updater**: `mFeed` and `mUpdateDialog` converted to `unique_ptr`
#### Motivation for adding to Mudlet
These patterns were identified as sources of memory leaks and potential
use-after-free bugs. Using smart pointers makes ownership explicit,
eliminates manual cleanup code, and ensures correct destruction even on
early-exit paths.
#### Other info (issues closed, discussion etc)
sorry this one is still pretty big, but most of the changes are the same
for each thing so reviewing them together probably makes sense. sadly
there isn't much to see here other than no slow uptick of heap size :-[
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:42:09 +12:00
mpHost - > mStopWatchMap [ watchId ] = std : : move ( pStopWatch ) ;
2019-11-30 16:43:26 +00:00
// A dummy read as there should not be any text for this element:
readElementText ( ) ;
} else {
Fix: Unknown nested elements in XML packages elements (like Host etc.) will cause erasure of settings (#5895)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Having unknown elements in XML, might cause clearing of already properly
set elements. This shouldn't happen, as we're flattening Host package,
but still good to fix that issue.
Example:
```xml
<Host autoClearCommandLineAfterSend="no" HighlightHistory="yes" printCommand="yes" USE_IRE_DRIVER_BUGFIX="no" mUSE_FORCE_LF_AFTER_PROMPT="no" mUSE_UNIX_EOL="no" mNoAntiAlias="no" mEchoLuaErrors="yes" runAllKeyMatches="no" AmbigousWidthGlyphsToBeWide="auto" mRawStreamDump="yes" mIsLoggingTimestamps="no" ...>
<name>Test</name>
<mInstalledPackages />
...
<unknowns>
<unknown>1</unknown>
<unknown>2</unknown>
</unknowns>
<stopwatches />
</Host>
```
initially will set all values correctly in Host object, second run will
happen, like those values are never set, because it will treat
`unknowns` node just like it was `Host` node.
#### Motivation for adding to Mudlet
Fixing
#### Other info (issues closed, discussion etc)
Same applies to other elements, like Triggers, Aliases etc.
#### Release post highlight
<!--
Use this space if you wish to write a short statement or example for
inclusion
in the release post for the next release.
-->
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-02-16 12:08:34 +01:00
readUnknownElement ( " stopwatches " ) ;
2019-11-30 16:43:26 +00:00
}
}
}
2021-02-11 18:05:40 +01:00
}
2026-03-09 09:26:29 +01:00
void XMLimport : : readMMCPOptions ( )
{
2026-03-06 12:24:16 -05:00
mpHost - > mMMCPChatName = attributes ( ) . value ( qsl ( " chatName " ) ) . toString ( ) ;
mpHost - > mMMCPChatPort = attributes ( ) . value ( qsl ( " chatPort " ) ) . toUShort ( ) ;
mpHost - > mMMCPChatPrefix = attributes ( ) . value ( qsl ( " chatPrefix " ) ) . toString ( ) ;
mpHost - > mMMCPAutostartServer = attributes ( ) . value ( qsl ( " autostartServer " ) ) = = YES ;
mpHost - > mMMCPAllowPeekRequests = attributes ( ) . value ( qsl ( " allowPeekRequests " ) ) = = YES ;
mpHost - > mMMCPPrefixEmotes = attributes ( ) . value ( qsl ( " prefixEmotes " ) ) = = YES ;
mpHost - > mMMCPAddChatMessageNewline = attributes ( ) . value ( qsl ( " chatMessageNewline " ) ) = = YES ;
mpHost - > mMMCPAutoAcceptCalls = attributes ( ) . value ( qsl ( " autoAcceptCalls " ) ) = = YES ;
mpHost - > mMMCPShowSnoopInMainConsole = attributes ( ) . value ( qsl ( " snoopInMain " ) ) = = YES ;
// MMCP is a self-closing tag, need to call readNext to move along..
readNext ( ) ;
}
2022-01-24 12:19:18 +01:00
void XMLimport : : readMapInfoContributor ( )
{
mpHost - > mMapInfoContributors . insert ( readElementText ( ) ) ;
}
void XMLimport : : readLegacyMapInfoContributors ( )
2021-02-11 18:05:40 +01:00
{
while ( ! atEnd ( ) ) {
readNext ( ) ;
if ( isEndElement ( ) ) {
break ;
2021-11-30 16:16:00 +01:00
}
if ( isStartElement ( ) ) {
2023-03-20 07:18:24 +01:00
if ( name ( ) = = qsl ( " mapInfoContributor " ) ) {
2021-02-11 18:05:40 +01:00
mpHost - > mMapInfoContributors . insert ( readElementText ( ) ) ;
}
}
}
2019-11-30 16:43:26 +00:00
}
2021-11-30 16:16:00 +01:00
2022-01-24 12:19:18 +01:00
void XMLimport : : readProfileShortcut ( )
{
auto key = attributes ( ) . value ( qsl ( " key " ) ) ;
auto sequenceString = readElementText ( ) ;
improve: improve memory safety by using smart pointers (#9239)
### Refactor: replace raw pointer ownership with smart pointers across
core subsystems
#### Brief overview of PR changes/additions
Replaces raw pointer ownership patterns with `std::unique_ptr` and
`std::map`
across several core subsystems:
- **Host**: `mStopWatchMap` (`QMap<int, stopWatch*>` → `std::map<int,
unique_ptr<stopWatch>>`), `profileShortcuts` (`QMap<QString,
QKeySequence*>` → `std::map<QString, unique_ptr<QKeySequence>>`).
Removes `qDeleteAll` in destructor and `delete mMMCPServer`.
- **TMap**: `mpRoomDB` raw pointer → `unique_ptr`
- **VarUnit**: `base` raw pointer → `unique_ptr`
- **TTrigger**: condition map storage converted to `unique_ptr`,
destructor simplified
- **discord**: handler and presence maps converted from raw pointer
`QMap` to `unique_ptr` + `std::map`
- **Updater**: `mFeed` and `mUpdateDialog` converted to `unique_ptr`
#### Motivation for adding to Mudlet
These patterns were identified as sources of memory leaks and potential
use-after-free bugs. Using smart pointers makes ownership explicit,
eliminates manual cleanup code, and ensures correct destruction even on
early-exit paths.
#### Other info (issues closed, discussion etc)
sorry this one is still pretty big, but most of the changes are the same
for each thing so reviewing them together probably makes sense. sadly
there isn't much to see here other than no slow uptick of heap size :-[
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:42:09 +12:00
if ( auto it = mpHost - > profileShortcuts . find ( key . toString ( ) ) ; it ! = mpHost - > profileShortcuts . end ( ) ) {
QKeySequence sequence = ! sequenceString . isEmpty ( ) ? QKeySequence ( sequenceString ) : QKeySequence ( ) ;
it - > second - > swap ( sequence ) ;
2021-11-30 16:16:00 +01:00
}
}