ID:2890845
 
Resolved
The new block() syntax was incorrectly handling values at the upper bounds of the map, cutting off at maxx+1 instead of at maxx, and likewise for maxy and maxz.
BYOND Version:515
Operating System:Windows 10 Home
Web Browser:Firefox 117.0
Applies to:Dream Daemon
Status: Resolved (515.1615)

This issue has been resolved.
Descriptive Problem Summary:
The new syntax for block doesn't properly clamp the values of the upper right corner and returns references to turfs outside of map bounds, which don't exist.
Numbered Steps to Reproduce Problem:
1. Iterate over block(world.maxx, world.maxy, world.maxz, world.maxx + 1, world.maxy + 1, world.maxz)
2. Access turf values inside your loop
3. Get a Bad turf runtime error
Code Snippet (if applicable) to Reproduce Problem:
world
maxx = 50
maxy = 50
maxz = 1

mob
verb
DoBug()
var/list/turfs = list(locate(50,50,1), locate(1,1,1), locate(50,1,1), locate(1,50,1))
var/turf/T, turf/origin
var/i = 0
for(origin in turfs)
for(T in block(origin.x-1,origin.y-1,origin.z, origin.x+1, origin.y+1, origin.z))
try
if(T.density) i++ // runtime trying to access values of an invalid turf
catch(var/exception/e)
world << json_encode(list(origin.x-1,origin.y-1,origin.z, origin.x+1, origin.y+1, origin.z))
world << ref(T)
world.log << "[e] ([e.file]: [e.line])"
world << "--------------------"


Expected Results:
Block clamps the upper bounds and doesn't return invalid turf references.
Actual Results:
Block returns invalid turf references.
Does the problem occur:
Every time? Or how often? Every time
In other games? Yes
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur?
By using the old block syntax, since locate() wouldn't return an invalid turf reference before block is even called so you have to clamp manually.
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.)
Tested in 515.1614
Workarounds:
Use the old block(locate(), locate()) syntax
Lummox JR resolved issue with message:
The new block() syntax was incorrectly handling values at the upper bounds of the map, cutting off at maxx+1 instead of at maxx, and likewise for maxy and maxz.