ID:2881971
 
Resolved
new/area(loc) returned the path of the area if the area already existed. This did not apply to situations where loc was omitted or null, which always results in a new area being created.
BYOND Version:515.1610
Operating System:Windows 11 Home 64-bit
Web Browser:Firefox 115.0
Applies to:Dream Daemon
Status: Resolved (515.1611)

This issue has been resolved.
Descriptive Problem Summary:
when creating an area like this `new /area/A(loc)` if the type already exists it will return the type

Code Snippet (if applicable) to Reproduce Problem:
#define get_area(A) (isarea(A) ? A : get_step(A, 0)?.loc)

/mob/verb/ReuseAreaInstance()
var/turf/theTurf = get_step(loc, 0)
var/area/theArea = theTurf.loc
theArea.contents -= theTurf
var/area/newArea = new /area/A(theTurf)
newArea.contents += theTurf
usr << ref(get_area(loc))


Expected Results:
For it to just return the instance

Actual Results:
Returns the type path

Does the problem occur: Everytime

When does the problem NOT occur? Unknown

Workarounds:
Just keep a list of instanced areas
the codesnippet seems needlessly complex and has odd logic.

this is a self contained version that showcases the bug:

/area/test
/client/verb/area_test()
world.maxz = 2
world.maxy = 1
world.maxx = 1
var/turf/T1 = locate(1,1,1)
world.log << json_encode(list(T1.loc, T1.loc.type, ref(T1.loc), ispath(T1.loc)))
var/turf/T2 = locate(1,1,2)
world.log << json_encode(list(T2.loc, T2.loc.type, ref(T2.loc), ispath(T2.loc)))
var/area/test/A1 = new(T1)
var/area/test/A2 = new(T2)
world.log << json_encode(list(T1.loc, T1.loc.type, ref(T1.loc), ispath(T1.loc)))
world.log << json_encode(list(T2.loc, T2.loc.type, ref(T2.loc), ispath(T2.loc)))
world.log << json_encode(list(A1, A1.type, ref(A1), ispath(A1)))
world.log << json_encode(list(A2, A2.type, ref(A2), ispath(A2)))
Lummox JR resolved issue with message:
new/area(loc) returned the path of the area if the area already existed. This did not apply to situations where loc was omitted or null, which always results in a new area being created.