VP_GetContact() broken in CMO version?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

VP_GetContact() broken in CMO version?

Post by KnightHawk75 »

Another one I've been meaning to ask about for awhile for CMO (at least all recent 114x.x builds tested).

Attached is a scene though just about any scene will do to highlight that VP_GetContact() appears broken due to a case conversion issue on the submitted guid. Load the scene, run the following.

Code: Select all

local u = SE_GetUnit({name='Stinger #1', guid='4FH7PU-0HM0LV5RLV4JO'});
 print(u.ascontact)
 for k,v in pairs(u.ascontact) do
   local c = VP_GetContact({GUID=v.guid}); -- error here, submitted contact guid will be 4FH7PU-0HM0LV5RMAMDN 
   print(c);
 end
 
 --If you want to check the contacts for the detecting side you can see this is the valid contact guid.
 local s = VP_GetSide({NAME="EC"})
 for k,v in pairs(s.contacts) do
  if v.guid == '4FH7PU-0HM0LV5RMAMDN' then
    print(v); 
  end
 end
 
The problem is 4FH7PU-0HM0LV5RMAMDN is being converted to lowercase in the compare, and compare is not flagged as textcompare, one or the other needs to change. For Devs you're looking for the following in the handler function for VP_Contacts inside the first for-each on the sides contact list that will look something like:
if (Operators.CompareString(the contact.guid that is caps, submittedGuid.ToLower(), false) == 0)

The change needed is either remove the .ToLower for CMO, OR change the false param for text compare to true and optionally don't bother with the the case conversion. When set to true in testing the function works as expected and successfully finds the match and returns me the contact. The textcompare param change option strikes me as more likely to work for any version of the code base.

Now there is of course a second attempt to do the match, and that one uses string.equals() with the ordinalIgnoreCase option as it should. However it never gets that far because at least in this case, the for-each is operating on the side's Lazy<ConcurrentDictionary<string,Contact> object which is empty for all sides, and seems to always be during my testing but maybe it's not always the case.

As for when it broke, probably since CMO release is my guess, last time I ran into it some months back I was able to avoid using the function for what I needed and forgot to report it or ask about it after being distracted with another issue.

Attachments
WCvsECs..aseIssue.zip
(75.98 KiB) Downloaded 11 times
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: VP_GetContact() broken in CMO version?

Post by michaelm75au »

Yea, that has been there always.
Michael
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: VP_GetContact() broken in CMO version?

Post by michaelm75au »

I'll add it to my list.[:D]
Fixed by using the common validation - as you can see from image, it uses either case.

In future buidl

Image
Attachments
Image 1.jpg
Image 1.jpg (92.55 KiB) Viewed 174 times
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: VP_GetContact() broken in CMO version?

Post by KnightHawk75 »

Thank you sir that was fast!! [:D]
Post Reply

Return to “Lua Legion”