BugFix: repair special exits in speedwalks with corrupt names#4722
Conversation
This is an error that slipped in as a result of Mudlet#4526 and resulted in the exit room id being stored as the special exit name in the BGL graph that is built for the A* search algorithm to work on. Consquently if that route was used in a path the special exit command produced for that step was garbage which also tripped off warnings about invalid characters being sent to the MUD as an exit direction. Thanks to @ryanstadther for bringing this to my attention! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
This kind of bug would have been prevented if we could do |
Which have their own peculiarities to trap the unwary. What caused this bug to slip through was multiple compilers not spotting that I was assigning an |
|
It was bad semantics, I believe, which the If you look at this diff, you have no idea what the key and value change is: Because the names mean absolutely nothing. You have to dig further to find their meaning. Meanwhile, if we gave them meaningful names, it will be much easier to work with it so consider pseudocode: for (auto [exit, roomid] : getSpecialExits())) {
if (pSourceR->hasSpecialExitLock(exit)) {
continue; // Is a locked exit so forget it...
}Instead of: QMapIterator<QString, int> itSpecialExit(pSourceR->getSpecialExits());
while (itSpecialExit.hasNext()) {
itSpecialExit.next();
if (pSourceR->hasSpecialExitLock(itSpecialExit.key())) {
continue; // Is a locked exit so forget it...
}I believe the former is far more understandable and less bugs will happen. |
|
The bug was no less likely to happen IMNSHO if, when the changes (from - for (auto [roomid, exit] : getOtherMap())) {
+ for (auto [exit, roomid] : getSpecialExits())) {and I cannot see that I would have immediate been more likely to have spotted the issue there than in the existing code. Probably less so because of the lesser exposure to using To be perfectly frank it would have been equally valid to have had a local reference/copy of the value to the element concerned like I already had for the room id (as -target = itSpecialExit.key();
-const QString exitName = itSpecialExit.value();
+target = itSpecialExit.value();
+const QString exitName = itSpecialExit.key();which was indeed done in some other places and made the change over much simpler in those cases - however with only two uses of that item it was marginal as to whether it would have been worth it. |
|
Now we know that it was, since a bug was caused without it. |
…#4722) This is an error that slipped in as a result of Mudlet#4526 and resulted in the exit room id being stored as the special exit name in the BGL graph that is built for the A* search algorithm to work on. Consquently if that route was used in a path the special exit command produced for that step was garbage which also tripped off warnings about invalid characters being sent to the MUD as an exit direction. Thanks to @ryanstadther for bringing this to my attention! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

This is an error that slipped in as a result of #4526 and resulted in the exit room id being stored as the special exit name in the BGL graph that is built for the A* search algorithm to work on. Consquently if that route was used in a path the special exit command produced for that step was garbage which also tripped off warnings about invalid characters being sent to the MUD as an exit direction.
Thanks to @ryanstadther for bringing this to my attention!
Signed-off-by: Stephen Lyons slysven@virginmedia.com