[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  OnPluginTick getting blocked by other plugin processing?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: OnPluginTick getting blocked by other plugin processing?
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Fiendish   USA  (942 posts)  [Biography] bio   Global Moderator
Date Tue 30 Nov 2010 07:12 PM (UTC)  quote  ]

Amended on Tue 30 Nov 2010 07:14 PM (UTC) by Fiendish

Message
FYI, Nick, my current solution is this:
local repaint_on_tick = false
local last_repaint_time = utils.timer()
function OnPluginBroadcast (msg, id, name, text)
    if (msg == 999 and text == "repaint") then
        repaint_on_tick = true
        if (utils.timer() - last_repaint_time > .1) then
            repaint_on_tick = false        
            Repaint()
            last_repaint_time = utils.timer()
        end
    end
end

-- if ticks are coming through, then we have enough time to repaint again
function OnPluginTick()
    if repaint_on_tick == true then
        repaint_on_tick = false        
        Repaint()
        last_repaint_time = utils.timer()
    end
end

I *think* this allows me to get deferred drawing for better performance when running a lot of plugins at once like Redraw and also the higher priority of Repaint that causes it to happen at all instead of never when under load.

http://aardwolfclientpackage.googlecode.com/
https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Fiendish   USA  (942 posts)  [Biography] bio   Global Moderator
Date Tue 30 Nov 2010 02:41 AM (UTC)  quote  ]

Amended on Tue 30 Nov 2010 02:44 AM (UTC) by Fiendish

Message
Nick Gammon said:

What's all this then? Simulating Redraw?

I was experimenting with a way to batch calls to repaint. Essentially I want something sort of like Redraw, in that it doesn't do something expensive every single call, but that actually still forces painting periodically like repaint does.

Quote:
There is no real way of guaranteeing a firing of 25 times a second, because an individual script might take more than 40 milliseconds to run.
That much I expected, but it wasn't even firing in between function calls because it's getting co-opted by processing new mud output. The WM_TIMER explanation makes sense.

Quote:
In your particular case, you might check for elapsed time in the repaint broadcast message, and do whatever you are planning to do if 40 milliseclonds have elapsed.

An excellent suggestion. I'll try that.

http://aardwolfclientpackage.googlecode.com/
https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (19,188 posts)  [Biography] bio   Forum Administrator
Date Tue 30 Nov 2010 02:36 AM (UTC)  quote  ]
Message
Fiendish said:

If this is expected behavior, something in the helps should indicate it.


I've updated the documentation. There is no real way of guaranteeing a firing of 25 times a second, because an individual script might take more than 40 milliseconds to run.

In your particular case, you might check for elapsed time in the repaint broadcast message, and do whatever you are planning to do if 40 milliseclonds have elapsed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (19,188 posts)  [Biography] bio   Forum Administrator
Date Tue 30 Nov 2010 02:17 AM (UTC)  quote  ]
Message
Fiendish said:

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars


What's all this then? Simulating Redraw?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (19,188 posts)  [Biography] bio   Forum Administrator
Date Tue 30 Nov 2010 02:16 AM (UTC)  quote  ]
Message
Hmmmmm.

http://msdn.microsoft.com/en-us/library/ms644902%28VS.85%29.aspx


The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.


OnPluginTick uses WM_TIMER messages.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (942 posts)  [Biography] bio   Global Moderator
Date Tue 30 Nov 2010 02:09 AM (UTC)  quote  ]

Amended on Tue 30 Nov 2010 02:13 AM (UTC) by Fiendish

Message
It looks like OnPluginTick isn't getting called at all, let alone 25 times per second, if other plugins are doing a lot of work on a lot of input.

Having, for example,
local reset_on_tick = false

function OnPluginBroadcast (msg, id, name, text)
    if (msg == 999 and text == "repaint") then
        Note("repaint broadcast from "..name)
        reset_on_tick = true
    end
end

function OnPluginTick()
    Note("tick")
    if reset_on_tick then
        reset_on_tick = false
        Note("repainting")
        Repaint()
    end
end
and replacing all calls to repaint in other plugins with related broadcasts results in this...
Quote:

tick
tick
tick
tick
tick
tick
tick
run 6e
tick
tick
tick
tick
Great Andolor Highway (3210)
repaint broadcast from Aardwolf_BigMap_Graphical

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
North of a Great Carnivale (3209)
repaint broadcast from Aardwolf_BigMap_Graphical

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
A dusty field (3208)
repaint broadcast from Aardwolf_BigMap_Graphical

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
Fields near the Dragon River (3207)
repaint broadcast from Aardwolf_BigMap_Graphical

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
The Dragon River (3206)
repaint broadcast from Aardwolf_BigMap_Graphical

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
A Small Village
repaint broadcast from Aardwolf_BigMap_Graphical
There are several small fields filled with crops surrounding a cluster of
log houses here. People dressed in rough woolen clothing are scattered
around doing various activities which keep any small, rural settlement
alive. In the distance, a young boy can be seen watching over a flock of
sheep, and a woman seems to be carrying water back to one of the houses.
Several men seem to be heading for the larger town, and its extensive
forests. There is a very large forest a bit farther to the east, and the
people of this village seem to be avoiding it, almost desperately. The
skyline in that direction seems to give off a bright shimmer, almost as if
the trees themselves glitter softly.

repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_Ascii_Mapper
repaint broadcast from Aardwolf_GMCP_Mapper
[Exits: north east south west]
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars
repaint broadcast from Aardwolf_Statmon
repaint broadcast from Aardwolf_Health_Bars

< 3039/3039hp 2324/2324mp 3191/3211mv 3341tnl 820737g Quest=0 Dbl: 10 > < -2470 >

INFO: Zodiac raises a level. Now up to level 195.
INFO: Bladedge raises a level. Now up to level 12.

tick
repainting
tick
tick
tick
tick
tick
tick


If this is expected behavior, something in the helps should indicate it. Currently forum posts and the very limited documentation on OnPluginTick indicates that we can expect 25 updates per second, not 25 or 0 updates per second. It doesn't even fire in between other plugin events.

http://aardwolfclientpackage.googlecode.com/
https://github.com/fiendish/aardwolfclientpackage
[Go to top] 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.


1,913 views.

[New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]