ID:151806
 
Is overriding Stat() to periodically update an HUD a sinful thing? Also, it is really that bad to periodically update an HUD rather than on demand? It seems like the extra overhead would be negligible.
Jeff8500 wrote:
Is overriding Stat() to periodically update an HUD a sinful thing?

No, but saying "an HUD" instead of "a HUD" is. :)

Actually the only thing to watch out for is that you don't actually send out updates to the HUD unless something changes, even if you're using Stat() to coordinate it. In SotS II, I overrode Stat() to replace the old statpanel updates with calls to output() and such, but those are only done if the text to be displayed has changed.

Also, it is really that bad to periodically update an HUD rather than on demand? It seems like the extra overhead would be negligible.

Yes, it's really that bad. HUD updates aren't done on any kind of optimized basis, so when you update one part of the HUD you update them all. Don't update until you have to, and if possible try to keep your updates all in the same place.

However, there is one exception to this rule of thumb. If you set the vars in a HUD object and they don't end up changing anything substantive, the "HUD is dirty" flag shouldn't trigger and the client won't have to re-download the whole HUD. On the whole though, I wouldn't rely on this to make frequent updates feasible.

Lummox JR
In response to Lummox JR
Oh, I seem to have forgotten to mention this HUD is made in interface controls, not objects (I typically think of a HUD as interface controls now). Sorry!

However, most of this should still apply, correct? I see what you mean, even if I used winset(), it would still waste bandwidth. Thanks for the help!
Jeff8500 wrote:
Is overriding Stat() to periodically update an HUD a sinful thing? Also, it is really that bad to periodically update an HUD rather than on demand? It seems like the extra overhead would be negligible.

The overhead is not really what you have to worry about with interfaces, it's the timely-update factor. You don't want to update when you don't have to, though if you do, it's OK. On the other hand, you want to show the user the updated information as soon as possible, not make him wait around for a second to finally see it (because the loop is taking so long), and any faster creates overhead you just really could do without.