Mudlet/Mudlet — pull request #219 by SlySven (2014-10-22 03:32:15+00:00)
Title: BugFix: Fix original coding errors creating data in TArea::exits member

The specification for this member is:
```
QMultiMap\ > exits
```
and it is a record of the rooms that are on border on the TArea instance.
The outer QMultiMap key is the room id of the in_area room, and the value
pair is:
```
first=out_of_area room id
second=direction code
```
The original direction codes were defined at the start of the TArea.cpp
class file but there did not appear to be any logic to the values used:
N=12, NE=1, E=3, SE=4, S=6, SW=7, W=9, NW=10, UP=13, DOWN=14, IN=15,
OUT=16, OTHER=17. Other than a lua function getAreaExits(areaId) which was
supposed to return just a list of unique keys via a TArea::getAreaExits()
method - i.e. a list of rooms in the given area which were exits to another
area, no other use was made of this data. I propose to replace this list
of values with the better known list stored in the TRoom class header file
but as that does not currently have a value for "other" {a.k.a. Special}
exits I had added a new define: #DEFINE DIR_OTHER with the value 13.

The data IS stored in the map file but is not changed except by calls to:
```
* (void)TArea::ausgaengeBestimmen() called from:
(void)TRoomDB::initAreasForOldMaps()
* (void)TArea::fast_ausgaengeBestimmen(int id) called from:
(bool)TMap::setExit(int from, int to, int dir)
(void)TRoom::setArea(int _areaID)
(void)TRoom::setSpecialExit(int to, const QString & cmd)
(void)TRoom::removeAllSpecialExitsToRoom(int _id)
(void)dlgRoomExits::save()
* (void)TArea::removeRoom(int room) called from:
(void)TRoom::setArea(int _areaID)
(bool)TRoomDB::__removeRoom(int id)
```
The bugs are that the code in both "ausgaengeBestimmen" methods (with
and without the "fast_" prefix) used the FROM room Id as the first member
of the value pair rather than the TO (a.k.a. exit) room Id for Normal
exits and use the room ID of the TO (a.k.a. exit) room Id as the key for
Special exits (i.e. stores a room that is NOT in the relevant area as a
room IN the area that is an exit from THAT area!) Additionally, even if
the code was correct the existing flawed data would not be corrected when
the map is loaded by running TArea::ausgaengeBestimmen() again because that
is only called at the end of TRoomDB::initAreasForOldMaps() which was
called only for old pre-version 15 map file formats (and we are currently
on 16 - though I have plans in pipeline for something that would require an
increment on that). To further stir the faulty data up previous faulty
code that introduced problems when moving a room from one area to another
may also have contributed to errors with the TArea::exits data.

However:

tl;dr;

running the lua command "auditAreas()" runs TRoomDB::initAreasForOldMaps()
which will fix-up existing maps after this commit has been committed...!

This fixes ["getAreaExits is broken (bug 1380822)"](http://bugs.launchpad.net/mudlet/+bug/1380822) 8-)

Signed-off-by: Stephen Lyons