From f45feb77fc328e1206b2b8885d87dfe9663faa0e Mon Sep 17 00:00:00 2001
From: Alam Ed Arias <alam@srb2.org>
Date: Sun, 22 May 2016 00:44:12 -0400
Subject: [PATCH] MSVC: kill level 3 warnings

---
 SRB2_common.props     |  3 ++-
 src/p_setup.c         |  2 +-
 src/p_spec.c          |  2 +-
 src/r_data.c          |  4 ++--
 src/sdl/i_system.c    |  2 +-
 src/sdl/mixer_sound.c | 10 +++++-----
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/SRB2_common.props b/SRB2_common.props
index 72f3e10c2..775816bea 100644
--- a/SRB2_common.props
+++ b/SRB2_common.props
@@ -9,13 +9,14 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <WarningLevel>Level2</WarningLevel>
+      <WarningLevel>Level3</WarningLevel>
       <PreprocessorDefinitions>HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <CompileAs>CompileAsC</CompileAs>
       <BrowseInformation>true</BrowseInformation>
       <TreatWarningAsError>true</TreatWarningAsError>
       <EnablePREfast>false</EnablePREfast>
       <SDLCheck>false</SDLCheck>
+      <DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
diff --git a/src/p_setup.c b/src/p_setup.c
index 7265f508f..b36bf0b80 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -1214,7 +1214,7 @@ static void P_LoadLineDefs2(void)
 		case 443: // Calls a named Lua function
 			if (sides[ld->sidenum[0]].text)
 			{
-				UINT8 len = strlen(sides[ld->sidenum[0]].text)+1;
+				size_t len = strlen(sides[ld->sidenum[0]].text)+1;
 				if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
 					len += strlen(sides[ld->sidenum[1]].text);
 				ld->text = Z_Malloc(len, PU_LEVEL, NULL);
diff --git a/src/p_spec.c b/src/p_spec.c
index b939e15f0..fbcb8b4f0 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -407,7 +407,7 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum, INT32 *i)
 void P_ParseAnimationDefintion(SINT8 istexture, INT32 *i)
 {
 	char *animdefsToken;
-	UINT8 animdefsTokenLength;
+	size_t animdefsTokenLength;
 	char *endPos;
 	INT32 animSpeed;
 
diff --git a/src/r_data.c b/src/r_data.c
index c3393a79b..cb5cf3591 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -497,7 +497,7 @@ void R_LoadTextures(void)
 static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
 {
 	char *texturesToken;
-	UINT8 texturesTokenLength;
+	size_t texturesTokenLength;
 	char *endPos;
 	char *patchName = NULL;
 	INT16 patchXPos;
@@ -623,7 +623,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
 static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
 {
 	char *texturesToken;
-	UINT8 texturesTokenLength;
+	size_t texturesTokenLength;
 	char *endPos;
 	INT32 newTextureWidth;
 	INT32 newTextureHeight;
diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index 469837c0b..0212e620b 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -1679,7 +1679,7 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener)
 		UINT8 *p = mumble->context;
 		WRITEMEM(p, server_context, 8);
 		WRITEINT16(p, gamemap);
-		mumble->context_len = p - mumble->context;
+		mumble->context_len = (UINT32)(p - mumble->context);
 	}
 
 	if (mobj) {
diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c
index 9eb5c3154..faebca6b4 100644
--- a/src/sdl/mixer_sound.c
+++ b/src/sdl/mixer_sound.c
@@ -239,7 +239,7 @@ static Mix_Chunk *ds2chunk(void *stream)
 	}
 
 	// return Mixer Chunk.
-	return Mix_QuickLoad_RAW(sound, (UINT8*)d-sound);
+	return Mix_QuickLoad_RAW(sound, (Uint32)((UINT8*)d-sound));
 }
 
 void *I_GetSfx(sfxinfo_t *sfx)
@@ -647,9 +647,9 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
 		const char *key1 = "LOOP";
 		const char *key2 = "POINT=";
 		const char *key3 = "MS=";
-		const UINT8 key1len = strlen(key1);
-		const UINT8 key2len = strlen(key2);
-		const UINT8 key3len = strlen(key3);
+		const size_t key1len = strlen(key1);
+		const size_t key2len = strlen(key2);
+		const size_t key3len = strlen(key3);
 		char *p = data;
 		while ((UINT32)(p - data) < len)
 		{
@@ -668,7 +668,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
 			else if (!strncmp(p, key3, key3len)) // is it LOOPMS=?
 			{
 				p += key3len; // skip MS=
-				loop_point = atoi(p) / 1000.0L; // LOOPMS works by real time, as miliseconds.
+				loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds.
 				// Everything that uses LOOPMS will work perfectly with SDL_Mixer.
 			}
 			// Neither?! Continue searching.
-- 
GitLab