Map API - refresh speed

Discussion in 'Plugin Development' started by matejdro, Jan 10, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    matejdro

    I have been playing with map API and biggest problem I see is that is slow. Very slow. It takes like 5 seconds to update it completely. Actually, this would not be so bad if map would update at once. But it updates line-by-line which makes it look like crap.

    Videos that I have seen (youtube and nyancat inside map) were running pretty smooth, which means that it can be sped up. Or were those fake?

    Is there a way to speed this up or at least make it update whole map at once instead of line-by-line crap?
     
  2. Offline

    desht

    Call player.sendMap(map); at the end of your renderer method to send the whole lot to the player at once. Take care to only send maps when they've actually changed, to avoid excessive network communication. See https://github.com/desht/ScrollingM...rollingmenusign/views/map/SMSMapRenderer.java for an example map renderer. It updates the map image and sends it to the player as soon as the menu contents are changed or the view is scrolled by the player.
     
    NathanWolf likes this.
  3. Offline

    matejdro

    Is MapCanvas linked to map?

    I was thinking about manually updating map at fixed rate and ignore render() method. Would that be possible?

    EDIT: sending map works perfectly. Thanks!
     
  4. Offline

    desht

    Sounds like you have it pretty much sorted, but anyway...

    As far as I can tell (I'm no expert but I've fiddled with the map API a bit), the render() method is called pretty much continually as long as you (or indeed any player) are holding a map in your hand. Which is why you need to take care to return quickly from render() if you don't have anything new to draw - renderers can get called a lot.

    The MapCanvas is indeed linked to the map view (see the canvas.getMapView() method) - you get a one-to-one relationship if you initialise your MapRenderer with the contextual parameter to be false (see the call to super() in my SMSMapRenderer constructor), and a many-to-one relationship if you initialise with contextual as true, i.e. in that case there will be a separate canvas for each player who holds a copy of the map in question. One MapView, many MapRenderer objects.

    My plugin has per-player (contextual) canvases, since each player can have a different scroll position on the map view they're holding.
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page