ID:1727117
 
Keywords: argument, filter, verb
BYOND Version:507
Operating System:Windows XP Pro
Web Browser:Chrome 38.0.2125.122
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary:
Using a verb with a custom filter proc does not update the popup menu to remove those verbs from the available ones.

Numbered Steps to Reproduce Problem:
1. Create a client verb that is filtered to a subtype of /obj on the argument list using the 'in' syntax.
2. Right click any /obj that doesn't pass the filter.
3. Notice that the verb is there in the popup menu.

Code Snippet (if applicable) to Reproduce Problem:
#define DEBUG

world
fps = 25 // 25 frames per second
icon_size = 32 // 32x32 icon size by default
loop_checks = 0

view = 6 // show up to 6 tiles outward from center (13x13 view)
maxx = 10
maxy = 10
maxz = 1
turf = /turf

world/New()
new /obj/targetable(locate(3,5,1))
new /obj/untargetable(locate(7,5,1))

turf
density = 0

obj
targetable
name = "Targetable"
density = 1

untargetable
name = "Untargetable"

proc/listTargetable()
var/list/R = list()
for (var/obj/targetable/T in view(usr))
R += T
return R

mob
step_size = 8

New()
..()

verb
use(var/obj/targetable/T as obj in listTargetable())
set name = "Use"
set popup_menu = 1
world << "used [T]"


Expected Results:
Verb is available when right clicking the targetable object. Using it works properly.
Verb is not available when right clicking the untargetable object.

Actual Results:
Verb is available when right clicking the targetable object. Using it works properly.
Verb is available when right clicking the untargetable object. Using creates an error message about invalid usage.

Does the problem occur:
Every time? Or how often? Always.
In other games? Yes.
In other user accounts? Yes.
On other computers? Yes.

When does the problem NOT occur?
It always occurs, but is hard to notice unless you're developing verbs which are only available on subtypes meeting certain criteria and not to everyone (such as admin tools).

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.)
Unknown.

Workarounds:
None that I managed to uncover.
Because of the way "in list" arguments work, this isn't too surprising to me. The only way to check if the obj is relevant to that verb is to run the proc, so for command expansion DS actually sends back a request for a list of choices. With the right-click menu this would have to be done for all verbs, and it'd involve checking this at the time of the right-click--so it'd have to be done for every object in the list that verb might conceivably apply to.

The routine that checks for whether an argument goes with a verb specifically short-circuits on server-side lists, to avoid this complexity/slowdown. So I guess you could say that yes, this is a bug because the obj doesn't really fit the verb; but the current behavior is actually done on purpose.

Interestingly, this is probably easier to fix on the webclient. Because it handles the right-click menu in two stages, it might well be more feasible to handle a check like this on demand.