ID:121772
 
Resolved
Setting screen_loc to "" did not immediately remove an item from the HUD, but only after a delay, unless another HUD object also updated.
BYOND Version:493
Operating System:Windows 7 Pro 64-bit
Web Browser:Chrome 15.0.874.121
Applies to:Dream Daemon
Status: Resolved (494)

This issue has been resolved.
Descriptive Problem Summary:
Setting an object's screen_loc updates fairly quick, but setting an object's screen_loc to an empty string takes a second or two to update (hide the object).

Edit: If you set screen_loc to a valid value after setting it to an empty string, but before it actually hides the object, it'll still hide it and ignore the new location (once it finally does update). So when setting screen_loc to "" and then a valid location shortly after, the valid location will be ignored once "" finally sets in. So it's not that the process is slow, but is actually delayed/spawned, or so it seems.

Numbered Steps to Reproduce Problem:
1. Add a screen object to the screen.
2. Set object's screen_loc to ""

Expected Results:
For it to update as quickly as a normal screen_loc change.

Actual Results:
Takes a second or two to hide the object.

Note: Setting screen_loc to "" to hide it, but keep it on the screen is very useful, especially when screen_loc changes quite a bit in a short amount of time and also appears and disappears. It's just a little slow when being hidden.

Does setting it to null make a difference compared to ""?
Falacy wrote:
Does setting it to null make a difference compared to ""?

It appears setting it to null is delayed the same as setting it to "".

I've been just setting it to "1:-33,1:-33" to basically hide said object from view, which is essentially what setting it to "" does.
I think I know why this is happening.

We have code that specifically sets a flag to update client.screen whenever a HUD element changes, which avoids an unnecessary comparison loop. The HUD is also updated on a timed basis as well, if that flag isn't set. This code however is looking for cases where the object that changed has its screen_loc set to a non-blank value. So what needs to be done is either 1) objects already on the HUD need to have some kind of internal flag set, or 2) changing screen_loc should trigger this calculation separately.

There are a number of available workarounds. One simple one is to remove the object from client.screen, which is the preferred method of hiding. You can set your screen_loc to a hidden location as you mentioned, which triggers the flag-setting code; you also have the option of immediately following that with a change to null, if you're relying on a blank value for your code. Changing a different HUD object should trigger the update flag as well.
Lummox JR wrote:
I think I know why this is happening.
We have code that specifically sets a flag to update client.screen whenever a HUD element changes, which avoids an unnecessary comparison loop. The HUD is also updated on a timed basis as well, if that flag isn't set. This code however is looking for cases where the object that changed has its screen_loc set to a non-blank value. So what needs to be done is either 1) objects already on the HUD need to have some kind of internal flag set, or 2) changing screen_loc should trigger this calculation separately.
There are a number of available workarounds. One simple one is to remove the object from client.screen, which is the preferred method of hiding. You can set your screen_loc to a hidden location as you mentioned, which triggers the flag-setting code; you also have the option of immediately following that with a change to null, if you're relying on a blank value for your code. Changing a different HUD object should trigger the update flag as well.

The reason I can't (or don't want to anyway) just remove and re-add it to the screen is for performance reasons. What I do is add a couple "mouse over effects" onto the screen and simply change their screen_loc to the screen_loc of the mouse over-ed item.

I suppose just offsetting the item off the screen, like I'm currently doing, will work then. Thanks.
Lummox JR resolved issue with message:
Setting screen_loc to "" did not immediately remove an item from the HUD, but only after a delay, unless another HUD object also updated.