Numbered Steps to Reproduce Problem:
1. Create a #define macro that returns some text that would be used for a tag string.
2. Use the #define macro to search for an existing datum. You'll get a true value when it should be false.
Code Snippet (if applicable) to Reproduce Problem:
#define UNIQUE_ID(a) (a.unique_id || a.unique_id())
atom
var tmp/unique_id
proc/unique_id()
unique_id = "\ref[src]"
return unique_id
mob
var/tmp/somedatum/sd
verb/trythis()
var somedatum/existing = locate("[UNIQUE_ID(src)]_and_[UNIQUE_ID(src)]")
if(!existing)
sd = new/somedatum(src,src)
else
world.log << "sd already exists!"
somedatum
New(atom/a, atom/b)
tag = "[UNIQUE_ID(a)]_and_[UNIQUE_ID(b)]"
Expected Results: To get the correct return value regardless of whether I'm using a #define macro or hard-text. Currently I'm forced to set the tag of non-client based mobs to their \ref value upon creation, and use the tag variable from there. There's nothing wrong with this (I save a variable with this method, so that's a plus that came from this), but I expect #define macros to act no differently.
Actual Results: locate() returns the wrong value, and in the case of my project, the game hard-crashes due (the window disappears without warning) to executing the wrong statements and running into runtime errors due to a non-existent mob.
Does the problem occur:
Every time? Or how often? Every time.
In other games? All; I reproduced it in a test project.
In other user accounts? N/A
On other computers? N/A
When does the problem NOT occur? When I avoid using #define inside of the locate() proc.
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.)
Though I'm using the latest 508.1299, I tested as far back as 508.1292 and it still occurred.
Workarounds: Don't use #define inside of locate().