From de49de5f2c3fd25902a263b047ff8c71f5d43545 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 Sep 2017 22:42:00 +0300 Subject: Discord: fix for guild sorting order --- protocols/Discord/src/proto.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'protocols/Discord/src/proto.cpp') diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index b384f34be8..941fc5917b 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -17,9 +17,14 @@ along with this program. If not, see . #include "stdafx.h" +__forceinline int compareInt64(const SnowFlake i1, const SnowFlake i2) +{ + return (i1 == i2) ? 0 : (i1 < i2) ? -1 : 1; +} + static int compareMessages(const SnowFlake *p1, const SnowFlake *p2) { - return *p1 - *p2; + return compareInt64(*p1, *p2); } static int compareRequests(const AsyncHttpRequest *p1, const AsyncHttpRequest *p2) @@ -29,12 +34,12 @@ static int compareRequests(const AsyncHttpRequest *p1, const AsyncHttpRequest *p int compareUsers(const CDiscordUser *p1, const CDiscordUser *p2) { - return p1->id - p2->id; + return compareInt64(p1->id, p2->id); } static int compareGuilds(const CDiscordGuild *p1, const CDiscordGuild *p2) { - return p1->id - p2->id; + return compareInt64(p1->id, p2->id); } CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : -- cgit v1.2.3