From 7d45927b9118861ee3c3518f88406e17abac0c5e Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 25 Feb 2023 14:32:25 +0800 Subject: [PATCH] Fix integer overflow on network bytes metric --- src/RustServerMetrics/MetricsLogger.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/RustServerMetrics/MetricsLogger.cs b/src/RustServerMetrics/MetricsLogger.cs index a677415..35bcf35 100644 --- a/src/RustServerMetrics/MetricsLogger.cs +++ b/src/RustServerMetrics/MetricsLogger.cs @@ -25,9 +25,9 @@ public class MetricsLogger : SingletonComponent class NetworkUpdateData { public int count; - public int bytes; + public long bytes; - public NetworkUpdateData(int count, int bytes) + public NetworkUpdateData(int count, long bytes) { this.count = count; this.bytes = bytes; @@ -169,12 +169,12 @@ internal void OnNetWriteSend(NetWrite write, SendInfo sendInfo) if (sendInfo.connection != null) { data.count++; - data.bytes += (int)write.Position; + data.bytes += write.Position; } else if (sendInfo.connections != null) { data.count += sendInfo.connections.Count; - data.bytes += (int)write.Position * data.count; + data.bytes += write.Position * data.count; } }