From 61dbda67f7347385abb49b459dd5c2ee7adb4408 Mon Sep 17 00:00:00 2001
From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>
Date: Sun, 14 Aug 2022 00:48:29 +0200
Subject: [PATCH] Address reported issues

Addressed:
* 'Expression: vector subscript out of range' (we only ever ensured capacity upon construction).
* Compiler error as AssertMsg1 is unimplemented, used Assert instead.
---
 r5dev/common/igameserverdata.h | 2 +-
 r5dev/mathlib/sha256.cpp       | 2 +-
 r5dev/tier1/cvar.cpp           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/r5dev/common/igameserverdata.h b/r5dev/common/igameserverdata.h
index c7c4ce75..3693db5a 100644
--- a/r5dev/common/igameserverdata.h
+++ b/r5dev/common/igameserverdata.h
@@ -50,7 +50,7 @@ public:
 		m_bValidated = false;
 		m_bAuthorized = false;
 		m_bInputOnly = false;
-		m_RecvBuffer.reserve(sizeof(int)); // Reserve enough for length-prefix.
+		m_RecvBuffer.resize(sizeof(int)); // Reserve enough for length-prefix.
 	}
 };
 
diff --git a/r5dev/mathlib/sha256.cpp b/r5dev/mathlib/sha256.cpp
index 794b2f0b..dca19588 100644
--- a/r5dev/mathlib/sha256.cpp
+++ b/r5dev/mathlib/sha256.cpp
@@ -127,7 +127,7 @@ string sha256(const string& input)
     char buf[2*SHA256::DIGEST_SIZE+1];
     memset(buf, '\0', 2*SHA256::DIGEST_SIZE+1);
 
-    for (int i = 0; i < SHA256::DIGEST_SIZE; i++) {
+    for (unsigned int i = 0; i < SHA256::DIGEST_SIZE; i++) {
         sprintf(buf + i * 2, "%02x", digest[i]);
     }
 
diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp
index 8513d257..980feb83 100644
--- a/r5dev/tier1/cvar.cpp
+++ b/r5dev/tier1/cvar.cpp
@@ -959,7 +959,7 @@ CConCommandHash::CCommandHashHandle_t CConCommandHash::Find(const ConCommandBase
 #ifdef DBGFLAG_ASSERT // double check against search by name
 	CCommandHashHandle_t dbghand = Find(cmd->GetName());
 
-	AssertMsg1(InvalidHandle() == dbghand,
+	Assert(InvalidHandle() == dbghand,
 		"ConCommand %s couldn't be found by pointer, but was found by name!", cmd->GetName());
 #endif
 	return InvalidHandle();