ID:2096549
 
Resolved
SEE_TURFS now turns off SEE_PIXELS just like SEE_OBJS/MOBS do. Additionally, mouse behavior did not handle the dark square from SEE_PIXELS properly.
BYOND Version:510
Operating System:Windows 10 Pro
Web Browser:Chrome 50.0.2661.102
Applies to:Dream Seeker
Status: Resolved (510.1346)

This issue has been resolved.
Descriptive Problem Summary:
We've discovered a few problems in one of our new implementations involving the sight flag SEE_PIXELS:

1. SEE_PIXELS overrides SEE_TURFS. Even though SEE_TURFS explicitly states that,
"// can see all turfs (and areas), no matter what"
turfs are covered with a darkness overlay when SEE_PIXELS and SEE_TURFS are enabled.
Associated image : http://puu.sh/plFwc/861bb9b582.png

Furthermore, SEE_TURFS only functions (while SEE_PIXELS is enabled), when both SEE_TURFS and SEE_OBJECTS are enabled.

2. SEE_PIXELS does not *fully* block out turfs below it (ie prevent click behavior). This allows players to use click behavior, particularly right click behavior, on turfs outside of their vision. Which gives them the ability to gather otherwise impossible information about the location of anything with a right click verb by right clicking over the darkness which is passed onto the turf.
Associated image: available on request

Numbered Steps to Reproduce Problem:
1. Apply SEE_PIXELS to the sight var of a mob
2. Try right clicking turfs obscured by darkness that are right clickable, or have objects that are right clickable and discover information about them such as name, sprite, location.
or
1. Apply SEE_TURFS to the sight var of a mob, view all turfs in view despite vision obscuration or luminosity
2. Apply SEE_PIXELS, turfs out of view and not luminous become obscured
3. Apply SEE_OBJS and turfs become visible again

Code Snippet (if applicable) to Reproduce Problem:
Test case can be created on request


Expected Results:
1. Turfs should never be obscured with the SEE_TURFS flag, regardless of SEE_PIXELS
2. SEE_PIXELS should prevent click behavior on obscured turfs

Actual Results:
1. Turfs are obscured when SEE_PIXELS and SEE_TURFS is combined, but not obscured when SEE_PIXELS, SEE_TURFS, and SEE_OBJS are combined.
2. SEE_PIXELS does not prevent any click behavior on obscured turfs


When does the problem NOT occur?
SEE_PIXELS does not break SEE_TURFS when SEE_OBJS is also enabled.

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.)
Currently unknown, can test prior version upon request

Workarounds:
None known
It seems to me that only the menu behavior would be impacted by this, not regular clicks. Since the darkness overlay is mouse-opaque, it should always block clicks except for the right-click menus. Right-click menus are a totally different animal. The menu thing may be relatively simple to fix, but I'll have to see.

The flag combination issue is a trickier deal. You can't use SEE_PIXELS to block only one type of thing and not another; it doesn't play nice with infrared, either. It's designed strictly as a minimalist overlay to cover up a tile (in topdown mode only) so that atoms moving in and out of that tile can be properly obscured instead of disappearing/appearing suddenly.
Perhaps I should also explain our use case:

We are using it primarily as a divider between planes above and below 0. Since planes below 0 are hidden by SEE_PIXELS on obscured turfs we can use full screen images in the clients screen below plane 0 freely without worrying about them being shown over non-visible turfs.
In response to Lummox JR
Lummox JR wrote:
It seems to me that only the menu behavior would be impacted by this, not regular clicks. Since the darkness overlay is mouse-opaque, it should always block clicks except for the right-click menus.

This may very well be the case. We have in use a 'click catcher' in the client screen to allow users to click on darkness, however since it was below plane 0 we believed it would be obscured by SEE_PIXELS (and therefore that SEE_PIXELS was allowing normal clicks to go through to it). It could be that this click catcher could be creating results that wouldn't align with normal behavior for most games.
In response to Clusterfack
If you have a plane master on plane 0, this starts to make a great deal of sense. It may be that the darkness doesn't catch properly when it's grouped under a plane master.
No, all our plane masters are below plane 0 at the moment actually (and the click catcher only collects left clicks and never allowed popup menu clicks)
I don't suppose there's a chance you could work up a simple test case for this? Something I can just load up and go would be a lot easier than trying to reproduce it in the SS13 source itself.
Yes I think we should be able to do that easily enough
SEE_MOBS also seems to override SEE_PIXELS, or something like that.
Okay Lummox I think I did fairly thorough testing to find out what was going on here.

Here is my test case:
http://puu.sh/pnv9n/0afceea1c5.rar

What I tested
1. SEE_PIXELS not working with SEE_TURFS was really easy to produce I would say. All you need to do in my test case is try out various combinations of SEE_TURFS|SEE_PIXELS along with SEE_OBJS or SEE_MOBS. I did not test infrared sight because I rarely use it and can't say I know how to very well.

2. This issue was hard to reproduce I first tested just adding SEE_PIXELS but that didn't work at all! So then I went back to my codebase and found out what kind of verbs were showing up, not all of them did and this was extremely useful information to me. It turns out what verbs showed up under SEE PIXELS was a matter of verb scoping.


My short analysis:
1. SEE_PIXELS doesn't work with SEE_TURFS

SEE_PIXELS and SEE_TURFS shows all turfs only when combined with a vision flag that shows something specific like SEE_MOBS or SEE_OBJS

This seems to be the case, but I really cannot find out any reason why it should be this way.
You can't use SEE_PIXELS to block only one type of thing and not another
The problem with this is that it doesn't seem to be true!
If you have SEE_PIXELS|SEE_TURFS|SEE_MOBS you can see turfs but can't see objects!
If you have SEE_PIXELS|SEE_TURFS|SEE_OBJS you can see turfs but can't see mobs!

If mobs or objs can be blocked when SEE TURFS and SEE PIXELS are enabled, why can't they both be blocked and turfs be shown?

2. This issue was far more complex to reproduce as I said before. It turns out that the scoping of the verbs is what matters most here. Simply doing (as mob|turf|obj) was not enough to make it show up in the right click menu.

As you can see in the test I have two procs added to verbs (you'll see within the test)
verb/something1(atom/A as mob|turf|obj)
The above isn't right clickable with see pixels in darkness

HOWEVER

verb/something2(atom/A as mob|turf|obj IN WORLD)
The above not only makes everything right clickable, it also allows ALL click behavior within darkness.
You can't use SEE_PIXELS to block only one type of thing and not another

The problem with this is that it doesn't seem to be true!
If you have SEE_PIXELS|SEE_TURFS|SEE_MOBS you can see turfs but can't see objects!
If you have SEE_PIXELS|SEE_TURFS|SEE_OBJS you can see turfs but can't see mobs!

Yes, that's correct. What I meant was, the blocking done in SEE_PIXELS will block everything if it's used, because it's simply a black icon drawn on top of the entire tile. What you're seeing in those two cases is that SEE_PIXELS is not actually being used.

Directly from the code:

    // this determines whether we need to draw an "unlit" tile, after all drawing is done.
// This will have the effect of clipping movable atoms moving from lit to unlit and vice-versa
// One bug is that it will not work if we have movable "always visible" atoms, since those need to be
// drawn on top of unlit areas
u1c unlit = x>0 && y>0 && x<full_cviewX-1 && y<full_cviewY-1 &&
!vis && (extra_sight&MOB_SEE_PIXELS) && !(extra_sight&(MOB_SEE_MOBS|MOB_SEE_OBJS)) && !PANE_LIT(*this,x,y);

if(unlit) {
vis = NORMAL_VIS; // draw everything, we blank later
}

This perfectly explains the (1) part of the behavior you're seeing; right-click menus are really the only issue.

Case 1: If you use SEE_PIXELS alone, everything is drawn on that tile as if it's in line-of-sight and lit, and then a blank tile is drawn over it.

Case 2: If you use SEE_PIXELS | SEE_TURFS, which is a non-sequitur, all of the logic for SEE_PIXELS alone still applies; turfs are still drawn and covered. This is technically a bug; it should be canceling SEE_PIXELS mode just like the movables do, since the turf is never drawn.

Case 3: If you use SEE_PIXELS with either SEE_OBJS or SEE_MOBS, then unlit behavior is turned off and it acts as if SEE_PIXELS is off. (It should do this for SEE_TURFS as well, but doesn't.) The result is that you'll see the tile without it being blanked out, but only atom types you've specified sight flags for will be visible on the obscured tiles.

So in short: SEE_OBJS and SEE_MOBS will turn SEE_PIXELS off, but SEE_TURFS does not even though it should. (And I consider the latter a bug.)

Being able to right-click an item that's fully and properly obscured by a SEE_PIXELS black tile, though, is not good. I agree those objects shouldn't show up in the list. I see a spot in the code that explains this, and can fix it for the next release.
In response to Lummox JR
Lummox JR wrote:
So in short: SEE_OBJS and SEE_MOBS will turn SEE_PIXELS off, but SEE_TURFS does not even though it should. (And I consider the latter a bug.)

Being able to right-click an item that's fully and properly obscured by a SEE_PIXELS black tile, though, is not good. I agree those objects shouldn't show up in the list. I see a spot int he code that explains this, and can fix it for the next release.

Assuming I'm reading this right it's exactly what I hoped to hear on this, thanks!
(The see_turfs not turning see pixels off was my only issue with (1)!)
This is now fixed (the SEE_TURFS part and the mouse click behavior); I'll close this for the next release.
Thank you so much!
Lummox JR resolved issue with message:
SEE_TURFS now turns off SEE_PIXELS just like SEE_OBJS/MOBS do. Additionally, mouse behavior did not handle the dark square from SEE_PIXELS properly.