Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Displaying doors on Mapper, and drawing images for room (for shops, forges, etc)

Displaying doors on Mapper, and drawing images for room (for shops, forges, etc)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 4  

Posted by Death   (55 posts)  Bio
Date Reply #30 on Thu 28 Mar 2019 02:36 AM (UTC)
Message
Hey all,
here is the client folder. Just download and place on your desktop and you're all golden. You'll probably get a few errors about the location of demonclient.mcl, because as far as I can tell theres no way to set the load location vaguely, only specifically (user specific)

https://www.dropbox.com/sh/24lv7wl9i52vvmj/AADv7Z5a0D9RolpuTYUflvh4a?dl=0


You can just load demonclient.mcl, and you should be set. Look will get you started.
Please contact in game named "Demon" about getting you off the newbie islands, since I didn't map it and have no plans to map it. (There are too many instanced areas with variable vnums)

Alternatively, you can ask on the newbie or gossip channel for someone to help you get to Ralnoth, which is on the mainland.

Let me know if you have any questions, and thanks for helping me find this crash bug!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #31 on Thu 28 Mar 2019 04:00 AM (UTC)
Message
This sort of thing:


elseif string.match (room.info, "magetrainer") then
  special_room = true
  WindowDrawImage (win, "magetrainer", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
  WindowCircleOp (win, miniwin.circle_rectangle, left-2-room.borderpenwidth, top-2-room.borderpenwidth,
    right+2+room.borderpenwidth, bottom+2+room.borderpenwidth,MAGE_TRAINER_FILL_COLOUR.colour,
    room.borderpen, room.borderpenwidth,-1,miniwin.brush_null)
elseif string.match (room.info, "necromancertrainer") then
  special_room = true
  WindowDrawImage (win, "necromancertrainer", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
  WindowCircleOp (win, miniwin.circle_rectangle, left-2-room.borderpenwidth, top-2-room.borderpenwidth,
    right+2+room.borderpenwidth, bottom+2+room.borderpenwidth,NECRO_TRAINER_FILL_COLOUR.colour,
    room.borderpen, room.borderpenwidth,-1,miniwin.brush_null)			
elseif string.match (room.info, "rangertrainer") then
  special_room = true
  WindowDrawImage (win, "rangertrainer", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
  WindowCircleOp (win, miniwin.circle_rectangle, left-2-room.borderpenwidth, top-2-room.borderpenwidth,
    right+2+room.borderpenwidth, bottom+2+room.borderpenwidth,RANGER_TRAINER_FILL_COLOUR.colour,
    room.borderpen, room.borderpenwidth,-1,miniwin.brush_null)


Can be easily simplified to something like this:


special_room_info = {
  magetrainer         =  MAGE_TRAINER_FILL_COLOUR.colour,
  necromancertrainer  =  NECRO_TRAINER_FILL_COLOUR.colour,
  rangertrainer       =  RANGER_TRAINER_FILL_COLOUR.colour,
  -- and so on
  }

if special_room_info [room.info] then -- if a special room
  special_room = true
  WindowDrawImage (win, room.info, left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
  WindowCircleOp (win, miniwin.circle_rectangle, left - 2 - room.borderpenwidth, top - 2 - room.borderpenwidth,
                  right + 2 + room.borderpenwidth, bottom + 2 + room.borderpenwidth,
                  special_room_info [room.info],  -- colour from table
                  room.borderpen, room.borderpenwidth, -1, miniwin.brush_null)
end -- if special room



Your dozens of lines of code condense down into one simple table and a single couple of functions to do the drawing.

Try to make consistent indentation. Having indents for no reason is just confusing.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #32 on Thu 28 Mar 2019 03:23 PM (UTC)

Amended on Thu 28 Mar 2019 03:46 PM (UTC) by Fiendish

Message
Ooooooh, it's based on the Aardwolf package, I see. One bit of advice if you don't mind my saying so, almost black on black is a very difficult color scheme to use. The contrast is so low I can barely make out any of the details. Also, if you become wildly successful and make a million dollars from it, please think of the little guy (lol).

The first message I see when logging in is

Quote:

Run-time error
Plugin: DemonMUSH_Mapper (called from world: Demonclient)
Immediate execution
Z:\Users\fiendish\Downloads\DemonMUSH\lua\altermapper.lua:1236: attempt to index local 'areaname' (a number value)
stack traceback:
Z:\Users\ fiendish\Downloads\DemonMUSH\lua\altermapper.lua:1236: in function 'draw'
[string "Plugin: DemonMUSH_Mapper"]:311: in function 'process_exits'
[string "Trigger: Exits_Line"]:1: in main chunk



I also see a lot of messages like
Quote:
Speedwalk failed! Expected to be in '-666' but ended up in '50048'.

When clicking on rooms to move between them.

I don't see you online, so I'll try again later.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #33 on Thu 28 Mar 2019 11:20 PM (UTC)

Amended on Thu 28 Mar 2019 11:22 PM (UTC) by Death

Message
Hey fiendish,


(client isn't for sale, lol, and I suck! Nobody is getting rich off of this xD)

Yeah, I'm still looking for that areaname error, it's causing issues for sure.

I haven't got a speedwalk failure in a very long time, so I'm not sure what the issue there is. -666 is an unexplored room, so I'm not sure how it would expect to be elsewhere while walking to an unexplored room.

What exactly were you doing? Maybe theres some other weird issue going on there. Did you place the folder on the desktop, or run as admin? Sometimes that causes weird issues if you don't do that.

I'm also not sure what you mean by black on black. If there are any rooms that are black, there's an issue with that room. (Sometimes room 0 on unholy has this issue because it's room 0) I'm still trying to find where thats happening, because I fixed it by making unknown rooms -666 (vnum -1 is also possible) and then the problem came back again.

I'd ignore the speedwalk via clicking thing, because I don't think that's an issue unless your "Unholy Temple of Dentin" turned black. Some code is causing vnum 0 to become nothing when I start the client, but not when I reinstall the mapper.

I'll try to catch you online. I'll be on for the next 8 hours or so probably.

If you see a black room, hover over it to get the vnum and do "mapper delete room <vnum>
In this case, mapper delete room 0 to delete unholy temple.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #34 on Fri 29 Mar 2019 12:29 AM (UTC)
Message
Quote:

I'm also not sure what you mean by black on black.

By almost black on black I mean this:
https://imgur.com/a/f7g3EOu
and this
https://imgur.com/a/YCMI9K5

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #35 on Fri 29 Mar 2019 01:53 AM (UTC)

Amended on Fri 29 Mar 2019 01:54 AM (UTC) by Death

Message
Fiendish said:

Quote:

I'm also not sure what you mean by black on black.

By almost black on black I mean this:
https://imgur.com/a/f7g3EOu
and this
https://imgur.com/a/YCMI9K5


Oh thanks for that.
I have a few different themes, I just prefer the darker one. My favorite is called "purple pony".

https://www.dropbox.com/s/6wcgp7bcobioiem/Screenshot%20%28294%29.png?dl=0
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #36 on Fri 29 Mar 2019 04:10 AM (UTC)
Message
Master Vivi said:

-666 is an unexplored room ...


The Number of the Beast - very appropriate!

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Death   (55 posts)  Bio
Date Reply #37 on Sun 31 Mar 2019 10:08 PM (UTC)

Amended on Mon 01 Apr 2019 12:45 AM (UTC) by Death

Message
Hey Nick,

I'm having huge issues with lag on my mapper because its drawing too many rooms when my map is zoomed out.


Fiendish explained it in a way that the mapper loads rooms in an outward spiral, and said there's a way to pause the loading process, but that he didn't remember how.


I don't want it to redraw the entire map every time I move, maybe only the closer rooms.

I'm sure this would help TONS with lag.

Any idea? Or maybe only redraw rooms in XX range.

We also couldn't find a repeatable crash bug, but I did get my client to crash 4 times by zooming all the way into the map, or all of the way out of the map, and reinstalling the mapper. I couldn't get it to happen repeatedly though.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #38 on Mon 01 Apr 2019 08:15 AM (UTC)
Message
You can configure the redraw range, see this video:

Another Aardwolf mapper example

Near the start you see me changing the depth (number of rooms from the start) to draw.




Also see this Aardwolf mapper example which shows something like 475 rooms being drawn at once without any slow down.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Death   (55 posts)  Bio
Date Reply #39 on Mon 01 Apr 2019 10:07 AM (UTC)

Amended on Mon 01 Apr 2019 10:08 AM (UTC) by Death

Message
Nick Gammon said:

You can configure the redraw range, see this video:

[url=https://vimeo.com/80318832]Another Aardwolf mapper example[/url]

Near the start you see me changing the depth (number of rooms from the start) to draw.

-----

Also see this [url=https://vimeo.com/80305761]Aardwolf mapper example[/url] which shows something like 475 rooms being drawn at once without any slow down.



Hey friend, don't forget I'm loading images, not just the rooms. It was completely fine without the images, which is why I'm looking for the fix. And this is drawing somewhere between 8000-13000 rooms at once. AARD is too small and separated for that to happen. Max capacity I'm looking to draw will be somewhere in the range of double the entire amount of rooms in aardwolf, but we're starting small here with around 13-15k rooms in the current map.

I also want to be able to view all rooms on the map at once if I zoom all of the way out.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #40 on Mon 01 Apr 2019 03:14 PM (UTC)

Amended on Mon 01 Apr 2019 03:42 PM (UTC) by Fiendish

Message
I believe this requires batching the rooms to be drawn and deferring display of each next batch of rooms until a check can be performed to make sure that the player has not moved before continuing to draw.

Nick, I couldn't remember if you'd shown someone an example of doing this at some point. I know that the Aardwolf mapper doesn't currently do it because the areas are small enough that it never needed to (I just reduce the depth while running like shown in your video).

A while ago I was experimenting with adding something like this to the Aardwolf mapper[0] as part of a bigger set of changes (including drawing the entire world instead of just the current area) and just didn't finish implementing everything I wanted to and then I forgot about it for a while and would probably have to start over to be able to get something merged into my current code. But basically I did the above batched by search depth and also didn't draw any hotspots until the very end (on the premise that rooms in rapid flux don't need to be clickable).

[0] - See the "draw_next_batch_of_rooms" function in https://github.com/fiendish/aardwolfclientpackage/blob/905df5b79046be9351d8f2a300d7ba1c8a7b1d52/MUSHclient/lua/aardmapper.lua#L1024

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #41 on Tue 02 Apr 2019 05:23 AM (UTC)
Message
Master Vivi said:

I don't want it to redraw the entire map every time I move, maybe only the closer rooms.

...

And this is drawing somewhere between 8000-13000 rooms at once.


That's why I suggested dropping the redraw distance. Drawing 13000 images may well slow things down. I'm not sure why you are resistant to implementing this.

The mapper was not really intended to show thousands of rooms (hence the depth parameter) however I am pleased to hear that, without adding images, it can cope with 13000 rooms.

Even if drawing one room takes 100 µs (which is not very long), that will still be 1.3 seconds to draw 13000 rooms.

You must have a big screen if you can perceive the graphics of 13000 rooms shown all at once (as images). Perhaps change it to not draw images if you zoom right out.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Death   (55 posts)  Bio
Date Reply #42 on Tue 02 Apr 2019 09:26 AM (UTC)
Message
Hey Nick,

Zooming out really helps you understand the layout of the map, and actually when its zoomed out that's actually when the map is most enjoyable: it looks like an actual world. There are forests, rivers, etc etc. It looks GREAT!! Lowering the depth would just make it so that rooms will not be shown at all, lol.

There are no issues while zoomed in normally, and by default its quite zoomed in.

Again, when you want to see the entire world map, it's okay. The fix is just don't travel when you're zoomed all of the way out, which is fine, but I was looking for some optimization, not a band-aid fix.

I appreciate your help.

What I'm saying is that maybe it doesn't have to redraw every single room every single time when zoomed out. Maybe it can only redraw the nearest rooms, or something like that? That's what fiendish is talking about as well.

I'd appreciate any insight into this idea, otherwise I'll just deal with it.

I'll continue working on finding the crash bug as well.

Cheers.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #43 on Wed 03 Apr 2019 03:26 AM (UTC)

Amended on Wed 03 Apr 2019 03:28 AM (UTC) by Nick Gammon

Message
One approach you can use is to utilize Lua's coroutine feature to pause the drawing at each level. This requires only fairly minor changes (in bold):


-- draw our map starting at room: uid

function real_draw (uid)

  if not uid then
    maperror "Cannot draw map right now, I don't know where you are - try: LOOK"
    return
  end -- if

  if current_room and current_room ~= uid then
    changed_room (uid)
  end -- if

  current_room = uid -- remember where we are

  -- timing
  local start_time = utils.timer ()

  -- start with initial room
  rooms = { [uid] = get_room (uid) }

  -- lookup current room
  local room = rooms [uid]

  room = room or { name = "<Unknown room>", area = "<Unknown area>" }
  last_visited [uid] = os.time ()

  current_area = room.area

  -- we are recreating the window so any mouse-over is not valid any more
  if WindowInfo (win, 19) and WindowInfo (win, 19) ~= "" then
    if type (room_cancelmouseover) == "function" then
      room_cancelmouseover (WindowInfo (win, 19), 0)  -- cancelled mouse over
    end -- if
  end -- have a hotspot

  WindowDeleteAllHotspots (win)

  WindowCreate (win,
                 windowinfo.window_left,
                 windowinfo.window_top,
                 config.WINDOW.width,
                 config.WINDOW.height,
                 windowinfo.window_mode,   -- top right
                 windowinfo.window_flags,
                 config.BACKGROUND_COLOUR.colour)

  -- let them move it around
  movewindow.add_drag_handler (win, 0, 0, 0, font_height + 4)

  -- for zooming
  WindowAddHotspot(win,
                   "zzz_zoom",
                   0, 0, 0, 0,
                   "", "", "", "", "",
                   "",  -- hint
                   miniwin.cursor_arrow, 0)

  WindowScrollwheelHandler (win, "zzz_zoom", "mapper.zoom_map")

 -- 3D box around whole thing

  draw_3d_box (win, 0, 0, config.WINDOW.width, config.WINDOW.height)

  -- make sure window visible
  WindowShow (win, not hidden)

  -- set up for initial room, in middle
  drawn, drawn_coords, rooms_to_be_drawn, speedwalks, plan_to_draw, area_exits = {}, {}, {}, {}, {}, {}
  depth = 0

  -- insert initial room
  table.insert (rooms_to_be_drawn, add_another_room (uid, {}, config.WINDOW.width / 2, config.WINDOW.height / 2))

  while #rooms_to_be_drawn > 0 and depth < config.SCAN.depth do
    local old_generation = rooms_to_be_drawn
    rooms_to_be_drawn = {}  -- new generation
    for i, part in ipairs (old_generation) do
      draw_room (part.uid, part.path, part.x, part.y)
    end -- for each existing room
    depth = depth + 1
    Redraw ()
    coroutine.yield ()  -- stop for a moment
  end -- while all rooms_to_be_drawn

  for area, zone_exit in pairs (area_exits) do
    draw_zone_exit (zone_exit)
  end -- for

  local room_name = room.name
  local name_width = WindowTextWidth (win, FONT_ID, room_name, true)
  local add_dots = false

  -- truncate name if too long
  while name_width > (config.WINDOW.width - 10) do
    -- get rid of last word
    local s = string.match (" " .. room_name .. "...", "(%s%S*)$")
    if not s or #s == 0 then break end
    room_name = room_name:sub (1, - (#s - 2))  -- except the last 3 dots but add the space
    name_width = WindowTextWidth (win, FONT_ID, room_name .. " ...", true)
    add_dots = true
  end -- while

  if add_dots then
    room_name = room_name .. " ..."
  end -- if

  -- room name

  draw_text_box (win, FONT_ID,
                 (config.WINDOW.width - WindowTextWidth (win, FONT_ID, room_name, true)) / 2,   -- left
                 3,    -- top
                 room_name, true,             -- what to draw, utf8
                 config.ROOM_NAME_TEXT.colour,   -- text colour
                 config.ROOM_NAME_FILL.colour,   -- fill colour
                 config.ROOM_NAME_BORDER.colour)     -- border colour

  -- area name

  local areaname = room.area

  if areaname then
    draw_text_box (win, FONT_ID,
                   (config.WINDOW.width - WindowTextWidth (win, FONT_ID, areaname, true)) / 2,   -- left
                   config.WINDOW.height - 6 - font_height,    -- top
                   areaname, true,              -- what to draw, utf8
                   config.AREA_NAME_TEXT.colour,   -- text colour
                   config.AREA_NAME_FILL.colour,   -- fill colour
                   config.AREA_NAME_BORDER.colour)     -- border colour
  end -- if area known

  -- configure?

  if draw_configure_box then
    draw_configuration ()
  else

    local x = 5
    local y = config.WINDOW.height - 6 - font_height
    local width = draw_text_box (win, FONT_ID,
                   x,   -- left
                   y,   -- top (ie. at bottom)
                   "*", true,                   -- what to draw, utf8
                   config.AREA_NAME_TEXT.colour,   -- text colour
                   config.AREA_NAME_FILL.colour,   -- fill colour
                   config.AREA_NAME_BORDER.colour)     -- border colour

    WindowAddHotspot(win, "<configure>",
                   x, y, x + width, y + font_height,   -- rectangle
                   "",  -- mouseover
                   "",  -- cancelmouseover
                   "",  -- mousedown
                   "",  -- cancelmousedown
                   "mapper.mouseup_configure",  -- mouseup
                   "Click to configure map",
                   miniwin.cursor_hand, 0)  -- hand cursor
  end -- if

  if type (show_help) == "function" then
    local x = config.WINDOW.width - WindowTextWidth (win, FONT_ID, "?", true) - 5
    local y = config.WINDOW.height - 6 - font_height
    local width = draw_text_box (win, FONT_ID,
                   x,   -- left
                   y,   -- top (ie. at bottom)
                   "?", true,                   -- what to draw, utf8
                   config.AREA_NAME_TEXT.colour,   -- text colour
                   config.AREA_NAME_FILL.colour,   -- fill colour
                   config.AREA_NAME_BORDER.colour)     -- border colour

    WindowAddHotspot(win, "<help>",
                   x, y, x + width, y + font_height,   -- rectangle
                   "",  -- mouseover
                   "",  -- cancelmouseover
                   "",  -- mousedown
                   "",  -- cancelmousedown
                   "mapper.show_help",  -- mouseup
                   "Click for help",
                   miniwin.cursor_hand, 0)  -- hand cursor
  end -- if

  -- 3D box around whole thing

  draw_3d_box (win, 0, 0, config.WINDOW.width, config.WINDOW.height)

  -- make sure window visible
  WindowShow (win, not hidden)

  last_drawn = uid  -- last room number we drew (for zooming)

  local end_time = utils.timer ()

  -- timing stuff
  if timing then
    local count= 0
    for k in pairs (drawn) do
      count = count + 1
    end
    print (string.format ("Time to draw %i rooms = %0.3f seconds, search depth = %i", count, end_time - start_time, depth))

    total_times_drawn = total_times_drawn + 1
    total_time_taken = total_time_taken + end_time - start_time

    print (string.format ("Total times map drawn = %i, average time to draw = %0.3f seconds",
                          total_times_drawn,
                          total_time_taken / total_times_drawn))
  end -- if

  thread = nil  -- don't need to call coroutine any more
end -- real_draw

function draw (uid)
  thread = coroutine.create (real_draw)    -- thread will run function real_draw
  assert (coroutine.resume (thread, uid))  -- start thread, passing argument uid
end -- draw

function keep_drawing ()
  if thread then
    coroutine.resume (thread)
  end -- if
end -- keep_drawing



What I have basically done here is:


  • Renamed the draw function as real_draw (so I can make it a coroutine)
  • Added a coroutine.yield inside the loop which draws all the room levels
  • Forced a screen refresh before yielding
  • Made a new draw() function which makes a coroutine (using read_draw) and starts it
  • Make a function designed to resume the drawing (coroutine.resume)
  • When the drawing is done for the whole lot of rooms, set the thread variable to nil which will cause that thread to be garbage-collected eventually


Then in the main mapper plugin you need to call this resuming function periodically, by adding this to the end of the script in the plugin:


function OnPluginTick ()
  mapper.keep_drawing ()
end -- OnPluginTick



What this effectively does is break up the drawing into one pass per level, then handing back control to the client (eg. to process further input). The OnPluginTick timer kicks in 25 times a second to keep drawing that map if required, so that it draws fairly quickly, but can be interrupted if you move. This GIF shows the idea (the pausing is fairly subtle):


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #44 on Wed 03 Apr 2019 03:34 AM (UTC)
Message
If you move the yield into the inner loop it becomes much more obvious, as it yields for each room:


 while #rooms_to_be_drawn > 0 and depth < config.SCAN.depth do
    local old_generation = rooms_to_be_drawn
    rooms_to_be_drawn = {}  -- new generation
    for i, part in ipairs (old_generation) do
      draw_room (part.uid, part.path, part.x, part.y)
      Redraw ()
      coroutine.yield ()  -- stop for a moment
    end -- for each existing room
    depth = depth + 1
  end -- while all rooms_to_be_drawn


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


117,953 views.

This is page 3, subject is 4 pages long:  [Previous page]  1  2  3 4  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.