ID:2888142
 
Resolved
Overlays and underlays lists didn't respect the numeric indexes supplied in Cut(), choosing to remove items from the end of the array.
BYOND Version:514
Operating System:Windows 11 Home 64-bit
Web Browser:Chrome 116.0.0.0
Applies to:Dream Daemon
Status: Resolved (515.1615)

This issue has been resolved.
Descriptive Problem Summary:

If atom.overlays contains two or more identical items and we try to remove any one of them using the .Cut proc it always removes the last one instead (as if we used -=).

Numbered Steps to Reproduce Problem:
1.) Execute the code below.
2.) Note that the second instance of A got removed from overlays instead of the first one.

Code Snippet (if applicable) to Reproduce Problem:
proc/main()
var/obj/O = new
var/image/A = new/image{layer=1}
var/image/B = new/image{layer=2}
O.overlays += A
O.overlays += B
O.overlays += A
print_overlays(O)
O.overlays.Cut(1,2)
print_overlays(O)

proc/print_overlays(atom/A)
. = list()
for(var/image/I as anything in A.overlays)
. += ref(I.appearance)
world.log << jointext(., " ")


Expected Results:
[0x3a000002] [0x3a000003] [0x3a000002]
[0x3a000003] [0x3a000002]

Actual Results:
[0x3a000002] [0x3a000003] [0x3a000002]
[0x3a000002] [0x3a000003]

Does the problem occur:
Every time? Or how often?Every time
In other games?N/A
In other user accounts?N/A
On other computers?N/A

When does the problem NOT occur?

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:

Lummox JR resolved issue with message:
Overlays and underlays lists didn't respect the numeric indexes supplied in Cut(), choosing to remove items from the end of the array.