Whenever passing text arguments to an object initializer (/New) via Byond_New, it seems it will corrupt input args (only tried with text, though) - the corruption seems to be related to the previous operation?
Numbered Steps to Reproduce Problem:
See code below, includes both a minimal reproducible C++ example, and the DM code to demonstrate the issue
Code Snippet (if applicable) to Reproduce Problem:
/datum/example
var/a
var/b
/datum/example/New(text)
world.log << "/datum/example/New: text=\"[text]\""
src.a = "[text]"
src.b = "12345 [text]"
/world/New()
do_the_thing()
del(src)
/proc/do_the_thing()
var/datum/example/thingy = call_ext("bynewtest", "byond:test")()
if(!istype(thingy))
world.log << "thingy failed to initialize"
return
world.log << "thingy: \ref[thingy]"
world.log << "thingy.a: \[[thingy.a]\]"
world.log << "thingy.b: \[[thingy.b]\]"
#include "byondapi.h"
#include "byondapi_cpp_wrappers.h"
extern "C" BYOND_EXPORT CByondValue test(u4c argc, ByondValue argv[]) {
auto example_path = ByondValue("/datum/example");
auto str = ByondValue("hihi!");
auto obj = ByondValue();
auto ret = Byond_New(example_path, &str, 1);
return ret;
}
Expected Results:
Welcome BYOND! (5.0 Beta Version 515.1614)
/datum/example/New: text="hihi!"
thingy: [0x21000000]
thingy.a: [hihi!]
thingy.b: [12345 hihi!]
Actual Results:
Welcome BYOND! (5.0 Beta Version 515.1614)
/datum/example/New: text="hihi!"
thingy: [0x21000000]
thingy.a: [thingy: [0x21000000]]
thingy.b: [12345 hihi!]
Does the problem occur:
Every time? Or how often? Yes
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? Haven't tested
Workarounds: Create a new string, such as by appending a space to the input string in /New:
/datum/example/New(text)
world.log << "/datum/example/New: text=\"[text]\""
src.a = "[text] "
src.b = "12345 [text]"