From 66bcfac6e3167531fa880e662dcdb3d6fd6eaf85 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 24 Mar 2023 09:12:14 +0100 Subject: [PATCH] Fixed a bug when reading mails --- .../Responses/GetMailInfosResponse.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/StatisticsAnalysisTool/Network/Operations/Responses/GetMailInfosResponse.cs b/src/StatisticsAnalysisTool/Network/Operations/Responses/GetMailInfosResponse.cs index 441823621..8a5c808cf 100644 --- a/src/StatisticsAnalysisTool/Network/Operations/Responses/GetMailInfosResponse.cs +++ b/src/StatisticsAnalysisTool/Network/Operations/Responses/GetMailInfosResponse.cs @@ -2,6 +2,7 @@ using StatisticsAnalysisTool.Common; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using StatisticsAnalysisTool.Trade.Mails; @@ -27,13 +28,24 @@ public GetMailInfosResponse(Dictionary parameters) !parameters.ContainsKey(6) || parameters[6] == null || !parameters.ContainsKey(10) || parameters[10] == null || !parameters[3].GetType().IsArray || - typeof(long[]).Name != parameters[3].GetType().Name) + (typeof(long[]).Name != parameters[3].GetType().Name && + typeof(int[]).Name != parameters[3].GetType().Name)) { return; } - + var guid = parameters[0].ObjectToGuid(); - var mailIdArray = ((long[]) parameters[3]).ToArray(); + + long[] mailIdArray = {}; + // If the mails are ever below 32.767, an error will appear here, but this should not happen on the current west and east servers, since the mail ID is above it and can never come below it again. + if (typeof(int[]).Name == parameters[3].GetType().Name) + { + mailIdArray = Array.ConvertAll((int[]) parameters[3], x => (long) x); + } + else if (typeof(long[]).Name == parameters[3].GetType().Name) + { + mailIdArray = ((long[]) parameters[3]).ToArray(); + } if (mailIdArray is not { Length: > 0 }) {