From 9f5901ce26fd728ef007286103f45baef77e0565 Mon Sep 17 00:00:00 2001 From: Triskele69 <64135034+Triskele69@users.noreply.github.com> Date: Thu, 3 Sep 2020 23:08:56 +0300 Subject: Update contact.cpp fixed getContactFromString() function to work with both ?contact and ?ccount --- plugins/Variables/src/contact.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/Variables/src') diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 3df3681d85..42a9357bde 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -178,10 +178,12 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (dwFlags & CI_NEEDCOUNT) { dwFlags &= ~CI_NEEDCOUNT; bReturnCount = true; + nMatch = -2; } else bReturnCount = false; // search the cache + if (nMatch == 0) { CONTACTCE tmp = { dwFlags, (wchar_t*)tszContact, 0 }; @@ -279,13 +281,13 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (bReturnCount) return count; - if (hMatch == 0) - return INVALID_CONTACT_ID; - // return random contact - if (nMatch == -1) + if (nMatch == -1 && arResults.getCount() != 0) return (UINT_PTR)arResults[rand() % arResults.getCount()]; + if (hMatch == 0) + return INVALID_CONTACT_ID; + // cache the found result if (count == 0) { mir_cslock lck(csContactCache); -- cgit v1.2.3