XML talk:BINA/OBJC/TRGV: Difference between revisions

re-sigh
(sigh)
(re-sigh)
Line 37: Line 37:


Thanks for checking the runtime '''ai_name''' and how it doesn't have any extra characters after all. I am not yet convinced that the comparison is by pointer and not by content, but if it is so, then it would mean that string arguments passed from runtime events (TRGV etc) are completely unusable - because they have their own unique pointer, which will never match anything you compare it with (unless you do something like '''BOB_string = ai_name''', but then the two strings are in fact one and the same, and there's nothing left to compare). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 11:05, 18 May 2020 (CEST)
Thanks for checking the runtime '''ai_name''' and how it doesn't have any extra characters after all. I am not yet convinced that the comparison is by pointer and not by content, but if it is so, then it would mean that string arguments passed from runtime events (TRGV etc) are completely unusable - because they have their own unique pointer, which will never match anything you compare it with (unless you do something like '''BOB_string = ai_name''', but then the two strings are in fact one and the same, and there's nothing left to compare). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 11:05, 18 May 2020 (CEST)
I have confirmed in my own way that the strings coming from runtime events are (apparently) compared by pointer rather than by content. Suppose you define two global string vars, '''dead_name''' and '''dead_name_too'''. Then you kill '''A_t48'''  twice (after force-spawning him), with '''t48_dead(string ai_name)''' performing the assignment '''dead_name = ai_name'''. Between the two deaths, do '''dead_name_too = dead_name''' from the console (this is now a redirect to the same string data, and '''dead_name_too eq dead_name''' evaluates to '''true'''). After the second A_t48 death, try '''dead_name_too eq dead_name''' again, and see that it evaluates to '''false''' now (there used to be one string, and now it's two identical strings at different addresses). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)
It should be noted, however, that "ordinary" string literals (the ones that are included in BSL scripts and allocated at level start) seem to be always compared by content even if they're changed to completely new literals at runtime (as long as it's from the console). If you have two global string vars '''testVar''' and '''testVar2''', you can set them both to "bla" from the console, and '''testVar eq testVar2''' will evaluate as '''true''' - so apparently the comparison becomes lazy (by pointer) if at least one of the strings (pointers) is in the dynamic range used by runtime events, but for new strings from the console (also dynamically allocated) it still uses the non-lazy comparison. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)