summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTriskele69 <64135034+Triskele69@users.noreply.github.com>2020-09-03 23:08:56 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-09-04 21:55:02 +0300
commit9f5901ce26fd728ef007286103f45baef77e0565 (patch)
treedff2d2039d355ffc0cee20f2c327e9f95088a8d2
parent016a44540e5f937f2144cfea312e46b414c34420 (diff)
Update contact.cpp
fixed getContactFromString() function to work with both ?contact and ?ccount
-rw-r--r--plugins/Variables/src/contact.cpp10
1 files changed, 6 insertions, 4 deletions
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);