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 Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #15 on Sun 24 Mar 2019 02:46 PM (UTC)

Amended on Sun 24 Mar 2019 02:52 PM (UTC) by Fiendish

Message
I only see you calling WindowCircleOp for regular rooms. Where do you call it for special rooms? If you could link to the current version of your file and say which line numbers you're looking at, it will help give better context.

Quote:
Also, according to the second image do you think this is too much for the client to handle?


It shouldn't be.


Quote:
Sometimes when I zoom out my map all of the way it just instantly crashes the entire MushClient.

That's definitely not supposed to happen! Can you make a self-contained demonstration of the crash for debugging?

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

Posted by Death   (55 posts)  Bio
Date Reply #16 on Mon 25 Mar 2019 12:53 AM (UTC)
Message
Hey fiendish, here is what I've got.

Drawing images starts at line 733, and special rooms start at line 777. I've made it pretty to look at, for easy reading.

Here is the lua file.

https://www.dropbox.com/s/w0rg2rn890f9p11/altermapper.lua?dl=0


You can see at the bottom (line 857) where I've tried to differentiate special rooms and non-special rooms.

Currently, I've got the special room tiles drawing OVER the existing room.fillcolour tiles. Might this cause an issue with memory, because its technically drawing double the rooms? I intend to remove the fillcolours asap and ONLY draw the tiles, but it's a whole to-do, so I haven't done it yet. I might still need it to draw those underlying rooms, so I can draw doors on the borders, but I might be able to use WindowCircleOp to draw a border outside of the rooms and show doors that way (though I think that would slow the HELL out of the client, because I tried it one time and it was nightmarish when I zoomed out)
Currently, I just photoshopped the room borders onto my tiles, LOL.

Also to note, my mapper database has 13,000 rooms in it so far, I'm not sure if this would contribute to the slowing down, since I can view most of them at once if I zoom out all of the way. There's HUGE lag if I try to walk somewhere while zoomed out, but there's really no need to walk places while zoomed out (except clicking on a room to walk there) so I can just refrain from that for now.



As for the crashing, I'll try to get a screen recording of it happening. When the MUSHCLIENT crashes, it's instant, it doesn't even give me any kind of failure message.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #17 on Mon 25 Mar 2019 03:12 AM (UTC)
Message
Possibly you are overflowing the Lua stack. A sudden crash like that is probably somewhere in Lua.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #18 on Mon 25 Mar 2019 03:46 AM (UTC)

Amended on Mon 25 Mar 2019 04:01 AM (UTC) by Death

Message
Nick Gammon said:

Possibly you are overflowing the Lua stack. A sudden crash like that is probably somewhere in Lua.



How can I fix this?

Do I have too much code in my lua file that needs to move to my mapper plugin instead?
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #19 on Mon 25 Mar 2019 04:28 AM (UTC)

Amended on Mon 25 Mar 2019 04:34 AM (UTC) by Fiendish

Message
Quote:
Currently, I've got the special room tiles drawing OVER the existing room.fillcolour tiles. Might this cause an issue with memory, because its technically drawing double the rooms?

Performance issue yes, memory issue no.

Quote:
my mapper database has 13,000 rooms in it so far, I'm not sure if this would contribute to the slowing down, since I can view most of them at once if I zoom out all of the way. There's HUGE lag if I try to walk somewhere while zoomed out

Yep. Rapidly drawing that many rooms will take some significant rework to how and when the rooms get drawn. The mapper code wasn't designed for that.

Quote:
Do I have too much code in my lua file that needs to move to my mapper plugin instead?

No. That's not what overflowing the stack means. Basically Nick is talking about programming an infinite loop of function calls. If a function calls itself, then calling it will result in it being called over and over and over again infinitely, each time adding another layer to the "call stack".

I'll take a look at your code tomorrow and see if anything stands out.

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

Posted by Death   (55 posts)  Bio
Date Reply #20 on Mon 25 Mar 2019 04:42 AM (UTC)

Amended on Mon 25 Mar 2019 04:44 AM (UTC) by Death

Message
Quote:
Yep. Rapidly drawing that many rooms will take some significant rework to how and when the rooms get drawn. The mapper code wasn't designed for that.

On Nick's help page, He says
Quote:
The intention of allowing sub-images was so that you could make up a map by having lots of small images (eg. houses, trees, rocks). Now instead of having to load hundreds of tiny image files into memory, which would doubtless take a while to open all those files, you open a single, larger, file in which the various sub-images are "tiled". For example, you might allocate a 32 x 32 pixel square for each image. Now by selecting the appropriate tile you can copy the sub-image from the main image.


Maybe this many rooms weren't intended though..


Would putting the images in an sql database help somehow?
I read something about that in the thread below.

I'd love to retain high speed on the client and not slow it down to hell.


Quote:
No. That's not what overflowing the stack means. Basically Nick is talking about programming an infinite loop of function calls. If a function calls itself, then calling it will result in it being called over and over and over again infinitely, each time adding another layer to the "call stack".

I'll take a look at your code tomorrow and see if anything stands out.

Thanks for teaching me about that. I don't see what I would've done that would cause a loop, but I appreciate the help SO greatly!
Would be lovely to know what causes the issue, so I can avoid it in the future.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #21 on Mon 25 Mar 2019 05:37 AM (UTC)

Amended on Mon 25 Mar 2019 05:40 AM (UTC) by Fiendish

Message
Quote:
Would putting the images in an sql database help somehow?

Very unlikely, but I haven't looked at your code yet. Remember that part where I said "don't load your image every time you look up a room. That's wildly inefficient. You only need to load the image file once ever." and then you made a change to follow my advice? That should already solve any issues with image loading speed. The problem is the amount of time it takes to complete each room drawing operation and hotspot creation multiplied by trying do many thousands of them.

Quote:
I don't see what I would've done that would cause a loop

You may not have. Nick was just speculating about one kind of issue that could cause a crash like you're experiencing.

I'm going to bed now though and will be back around tomorrow to take a look at the code you posted.

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

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #22 on Mon 25 Mar 2019 12:41 PM (UTC)

Amended on Mon 25 Mar 2019 12:48 PM (UTC) by Fiendish

Message
A passing thought on my way to work...

Quote:
The problem is the amount of time it takes to complete each room drawing operation and hotspot creation

What version of MUSHclient are you using by the way? 5.02 fixed a performance problem when adding thousands of hotspots. (I was doing the same huge map drawing that you're doing now)

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=13688

If you're not using it already, grab the 5.06 pre-release executable from https://github.com/nickgammon/mushclient/releases/download/latest_commit/MUSHclient.exe

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

Posted by Death   (55 posts)  Bio
Date Reply #23 on Mon 25 Mar 2019 07:29 PM (UTC)
Message
Fiendish said:

A passing thought on my way to work...

Quote:
The problem is the amount of time it takes to complete each room drawing operation and hotspot creation

What version of MUSHclient are you using by the way? 5.02 fixed a performance problem when adding thousands of hotspots. (I was doing the same huge map drawing that you're doing now)

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=13688

If you're not using it already, grab the 5.06 pre-release executable from https://github.com/nickgammon/mushclient/releases/download/latest_commit/MUSHclient.exe


Hey Fiendish, I'm using 5.06, thanks. :)
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #24 on Tue 26 Mar 2019 02:28 AM (UTC)

Amended on Tue 26 Mar 2019 02:38 AM (UTC) by Fiendish

Message
First, not completely related to the problem you're having and yet at the same time a reasonable way to prevent similar problems from happening in the first place, a few pieces of advice on making it easier to follow what's happening in your code...

1. Don't use string.match in places where you can just use a double equal sign. == is far more idiomatic and probably more efficient. It will also save you the pain of accidentally stumbling face first into "patterns" ( https://www.lua.org/pil/20.2.html ).

2. Fix your whitespace and indentation levels. Consistent indentation is one of the most important guides your brain has for making sense of complex logic.

3. If you find yourself writing almost identical lines of code over and over and over again, there's almost certainly a better way that is more compact and less overwhelming to look at at. Lookup tables can be a great help with this. As an example, I would replace your DRAW MAP IMAGES section that looks like this...

if string.match (room.fillcolour, "9109504") then
    WindowDrawImage (win, "ocean", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
elseif string.match (room.fillcolour, "9465920") then
    WindowDrawImage (win, "town", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
elseif string.match (room.fillcolour, "61680") then
    WindowDrawImage (win, "stream", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill

-- et cetera

with something like this instead...

color_to_image = {
    ["9109504"] = "ocean",
    ["9465920"] = "town",
    ["61680"] = "stream",
    -- et cetera
}

WindowDrawImage(win, color_to_image[room.fillcolour], left, top, right, bottom, miniwin.image_stretch)

It accomplishes the same thing with less room for accidental copy/paste errors.


Now on to your border drawing problem...

Your lines 858 and 859 accomplish nothing. To discover why, search in your file for every instance of "room.bordercolour". It appears in 3 places. 2 of those places set it, and one of those places use it. Look at where it gets used relative to where it gets set. Is it before or after? Is there any way for the code to get from where you set it to where you use it without violating logic or going backwards in time?

IMO, any modifications to room color, brush, and pen should be happening before line 694 because that small section with the comments "-- room fill" and "-- room border" are where they get used.

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #25 on Tue 26 Mar 2019 02:57 AM (UTC)
Message
If you know you can definitely reproduce the crash, for example by zooming right out, then a helpful thing to do is to add some debugging prints.

Even something simple like printing which room number you are currently drawing could indicate where the problem lies. You may find that just before the crash you draw the same room number hundreds of times for example.

You may find that your output window fills up with a lot of spam messages but that doesn't really matter if this helps to solve the problem. You may need to increase the number of lines shown in the window, from the default to something like 500000.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #26 on Tue 26 Mar 2019 07:27 AM (UTC)

Amended on Tue 26 Mar 2019 08:12 AM (UTC) by Death

Message
Fiendish said:

First, not completely related to the problem you're having and yet at the same time a reasonable way to prevent similar problems from happening in the first place, a few pieces of advice on making it easier to follow what's happening in your code...

1. Don't use string.match in places where you can just use a double equal sign. == is far more idiomatic and probably more efficient. It will also save you the pain of accidentally stumbling face first into "patterns" ( https://www.lua.org/pil/20.2.html ).

2. Fix your whitespace and indentation levels. Consistent indentation is one of the most important guides your brain has for making sense of complex logic.

3. If you find yourself writing almost identical lines of code over and over and over again, there's almost certainly a better way that is more compact and less overwhelming to look at at. Lookup tables can be a great help with this. As an example, I would replace your DRAW MAP IMAGES section that looks like this...

if string.match (room.fillcolour, "9109504") then
    WindowDrawImage (win, "ocean", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
elseif string.match (room.fillcolour, "9465920") then
    WindowDrawImage (win, "town", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill
elseif string.match (room.fillcolour, "61680") then
    WindowDrawImage (win, "stream", left, top, right, bottom, miniwin.image_stretch)  -- stretch to fill

-- et cetera

with something like this instead...

color_to_image = {
    ["9109504"] = "ocean",
    ["9465920"] = "town",
    ["61680"] = "stream",
    -- et cetera
}

WindowDrawImage(win, color_to_image[room.fillcolour], left, top, right, bottom, miniwin.image_stretch)


I can't really do it like that, since each example is also doing its own unique WindowCircleOp, as shown
				         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)


but other than that, that code DOES look easier to read.

How might I go about including all of my windowcircleops in that same format?

On a side note, my mushclient just nuked itself (crashed) when I reinstalled my mapper.
I'll try to find out why.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #27 on Tue 26 Mar 2019 02:38 PM (UTC)

Amended on Tue 26 Mar 2019 03:17 PM (UTC) by Fiendish

Message
Quote:
I can't really do it like that

You very clearly can.

Quote:
since each example is also doing its own unique WindowCircleOp

Your WindowCircleOps aren't "unique". They vary only by color. Make a table that links each room.info to a color _exactly_ like I did linking fillcolour to image name in my example.

Quote:
On a side note, my mushclient just nuked itself (crashed) when I reinstalled my mapper.
I'll try to find out why.

You gave us your lua file but not your plugin file. Perhaps if you linked to that as well (and also a link to the server for your game) we could help test the crash.

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

Posted by Death   (55 posts)  Bio
Date Reply #28 on Tue 26 Mar 2019 08:38 PM (UTC)

Amended on Tue 26 Mar 2019 11:22 PM (UTC) by Death

Message
Here we go:

https://pastebin.com/3cJpGc2r


This is my mapper plugin.

I was just thinking: I didn't make a way to only tag a room as one tile, and also if the room gets tagged more than once, it puts the same thing in (If I tag waypoint twice, it puts waypointwaypoint in my sql)

Might this cause problems? I can imagine it trying to draw a cleric and warrior tile over and over, but maybe it would just drop them on top of each other and I'd never know. I'd imagine that's how it would draw, so I doubt it.

For the WindowCircleOp thing, would it be something like
special_room_border = {
    ["magetrainer"] = "MAGE_COLOUR_FILL",
    ["clerictrainer"] = "CLERIC_COLOUR_FILL",
    ["necromancertrainer"] = "NECRO_COLOUR_FILL",
    -- et cetera
}
WindowCircleOp (win, special_room_border[room.bordercolour], left-2-room.borderpenwidth, top-2-room.borderpenwidth,
                                         right+2+room.borderpenwidth, bottom+2+room.borderpenwidth,[room.bordercolour],
                                         room.borderpen, room.borderpenwidth,-1,miniwin.brush_null)

or did I mess up the WindowCircleOp (second argument)? should I put it back to
(win, miniwin.circle_rectangle??




Also, I fixed the border stuff by putting
   -- SPECIAL ROOM COLOUR FILLS
special_room = false
                         if room.info and room.info ~= "" then
                         if string.match (room.info, "waypoint") then
                                         special_room = true
                         elseif string.match (room.info, "bank") then
                                         special_room = true
                        ETC ETC ETC ETC 



in my mapper plugin, and

				         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)												 
                 ETC ETC ETC
										end
                                        end -- if
			             if uid == current_room and not special_room then
                                         WindowCircleOp (win, miniwin.circle_rectangle, left-2-room.borderpenwidth, top-2-room.borderpenwidth,
                                         right+2+room.borderpenwidth, bottom+2+room.borderpenwidth,OUR_ROOM_COLOUR.colour,
                                         room.borderpen, room.borderpenwidth,-2,miniwin.brush_null)										
end
end
  
in my mapper.lua


I'll try to convert the system to the new way fiendish showed me today, if I can get the WindowCircleOp part right. Should be much more pretty looking.

The link for my mud is dentinmud.org, port 3000.
You won't be able to see my mapper in its full glory unless you have all of the files relevant to it. You might only need my images folder, or you can spoof one.
If you connect, type "set kxwt on", as you don't have my plugin that automatically does that: this will feed you room and walk info every time you look or walk.
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #29 on Wed 27 Mar 2019 07:04 PM (UTC)

Amended on Wed 27 Mar 2019 07:12 PM (UTC) by Fiendish

Message
Quote:
For the WindowCircleOp thing, would it be something like

That's now invalid code. Look carefully at what I did again.

I replaced

if thing == A1 then
   my_function(some args, B1, some more args)
elseif thing == A2 then
   my_function(some args, B2, some more args)
...

with

from_A_to_B = {
  [A1] = B1,
  [A2] = B2,
   ...
}

my_function(some args, from_A_to_B[thing], some more args)


Quote:
You won't be able to see my mapper in its full glory unless

Please provide an entire working directory then, since the whole point was to be able to help you debug a crash, and that's easier to do if we can actually run what you're running.

https://github.com/fiendish/aardwolfclientpackage
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,859 views.

This is page 2, 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.