Numbered Steps to Reproduce Problem:1.Make a new project.
2.Replace the code with the snippet below.
Code Snippet (if applicable) to Reproduce Problem:
mob
var
Gold=0
tmp
NeedsUpdated=1
verb
Update_Gold()
Gold+=1
NeedsUpdated=1
Stat()
while(!NeedsUpdated)
sleep(1)
statpanel("Test")
stat("Gold",Gold)
src<<"Updating statpanel to show the new gold amount of [Gold] gold."
NeedsUpdated=0
Expected Results:It's telling me it's updating the statpanel every time I click the Update_Gold() verb so when I click back over to the Test panel from clicking it under commands, it should be updated to reflect as much.
Actual Results:When I click back over to the Test panel from clicking it under commands, it's not updated.
Does the problem occur:
Every time? Or how often?Every Time
In other games?Yes
In other user accounts?Yes
On other computers?Yes
When does the problem NOT occur?Don't override Stat() like this.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Workarounds:Stop over-riding Stat() in this way.
EXTRA NOTES: If you make a macro for the verb and stay clicked into the Test panel, it will update properly, but it will never update if you are in another panel at the time.
It may never send the update to the client because the server likely knows what tab your in, now this is fine even, but under circumstances such as in the above code sleeping, it should send the last update gotten to the client when they switch back to the tab in question, if there's a pending update.
I am over-riding it to prevent a lengthy amount of code running using Stat() when it's not even updating anything, and it's all the same information.
I don't know if it already suppresses updates to the client or not when the Stat() code ends up generating all the same info for the statpanels and such or not, but if it does re-send even if it's identical to the last one sent to the client, this would save a small bit(although negligible amount) to networking as well.
That doesn't sound like the problem summary. It sounds like what you're expecting will happen.
Stat() is never, ever intended to sleep--or be called directly, which is what sleep() ultimately ends up doing when it finishes. It's not something you can just put on the back burner, because new calls to it will come in. You'll just wind up with a lot of sleeping procs that will eventually try to complete. I'm calling this a non-bug.
If you want to avoid pointless updates like ones that use long calculations, just cache that info and only recalculate when your var says so.