Mapper: Road Distance

Posted by Isolgrac on Tue 12 May 2020 09:21 AM — 7 posts, 24,292 views.

#0
I'm trying to get a mapper working on the mud I have just started playing, and along with all the usual issues I am also seeing an issue with differing road distances.

For example, a house with two rooms and a road round the outside might look like this:


[ ]--[ ]-------[ ]
 |              |
[ ]  [ ]--[ ]  [ ]
 |    |         |
[ ]--[ ]-------[ ]


Of course the mapper can't draw it cos the eastern road and the room need to draw in the same place.

Is there a way to tell the mapper to draw certain roads longer than others?

Thanks
USA Global Moderator #1
No
Australia Forum Administrator #2
The mapper doesn't have any concept of road distances because the MUD doesn't supply that information.
#3
Yes, indeed the distances have to be supplied manually, which is a bit tedious the first time round, but if you do it as you explore it's not too bad.

I've made some simple tweaks to mapper.lua which allow for different distances and it seems to work reasonably well.

Changes, for those who are interested, based on version 2.7 dated 1st Feb 2020

In function draw_room():

Line 548
Replace

  for dir, exit_uid in pairs (room.exits) do

with

  for dir, exit_data in pairs (room.exits) do
    local exit_uid
    local exit_distance
    if type(exit_data) == "table" then
      exit_uid = exit_data.touid
      exit_distance = exit_data.distance
    else
      exit_uid = exit_data
      exit_distance = 1
    end


Lines 599,600:
Replace

      local next_x = x + exit_info.at [1] * (ROOM_SIZE + DISTANCE_TO_NEXT_ROOM)
      local next_y = y + exit_info.at [2] * (ROOM_SIZE + DISTANCE_TO_NEXT_ROOM)

with

      local next_x = x + exit_info.at [1] * (ROOM_SIZE + DISTANCE_TO_NEXT_ROOM) * exit_distance
      local next_y = y + exit_info.at [2] * (ROOM_SIZE + DISTANCE_TO_NEXT_ROOM) * exit_distance



Line 657:
Replace

        if dest.exits [inverse_direction [dir]] ~= uid then

with

        local inv_exit_data = dest.exits [inverse_direction [dir]]
        local inv_uid
        if type(inv_exit_data) == "table" then
          inv_uid = inv_exit_data.touid
        else
          inv_uid = inv_exit_data
        end
        if inv_uid ~= uid then
Amended on Wed 13 May 2020 01:39 PM by Isolgrac
USA Global Moderator #4
I don't think that code will do much without also having a way to set, store, and load the desired distances.
Amended on Wed 13 May 2020 01:49 PM by Fiendish
#5
Well yes, obviously.

The client mapper code is responsible for sourcing the data and persisting it as required. Clearly you can't draw data you don't have. However, once I had obtained that data, I needed a way to draw it. What I have shown here is simply the changes I made to the publicly available drawing code in order to support this. If anyone else was having a similar problem, maybe this could help.

I don't have a way to automatically determine the distances, these I have to calculate and enter manually into my DB.

I forgot to mention, to use the distance drawing, you just have to define the exit as a table rather than just a string:
Instead of:

  room.exit[d] = uid

use:

  room.exit[d] = { touid = uid, distance = dist}


My changed version of mapper.lua is backwardly compatible and so would correctly handle either of the above
Australia Forum Administrator #6
Very good, thanks for sharing.