shithub: cstory

Download patch

ref: 01ddc5e92332c23fc59f956910d1c14d38b669b9
parent: d55f72aeaf691071e02e2111ed923311c0985afd
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Feb 23 16:45:57 EST 2019

Fixed some warning MSVC2003 was giving in /W3 mode

--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -140,7 +140,7 @@
 			for (int y = 0; y < WINDOW_HEIGHT - 240 + 88; y += 88)
 			{
 				fillNext = ((fillNext) * 214013 + 2531011);
-				for (int x = -(fillNext % 149); x < WINDOW_WIDTH; x += 149)
+				for (int x = -(int)(fillNext % 149); x < WINDOW_WIDTH; x += 149)
 				{
 					PutBitmap4(&grcGame, x, y, &rcSkyFiller, SURFACE_ID_LEVEL_BACKGROUND);
 				}
--- a/src/BossFrog.cpp
+++ b/src/BossFrog.cpp
@@ -187,7 +187,7 @@
 				PlaySoundObject(25, 1);
 
 				if (gBoss->direct == 0)
-					gBoss->xm = -0x200u;
+					gBoss->xm = -0x200;
 				else
 					gBoss->xm = 0x200;
 
--- a/src/BossIronH.cpp
+++ b/src/BossIronH.cpp
@@ -164,7 +164,7 @@
 			gBoss[0].y = gBoss[0].tgt_y + (Random(-1, 1) * 0x200);
 
 			if (++gBoss[0].act_wait % 4 == 0)
-				SetNpChar(4, gBoss[0].x + (Random(-0x80u, 0x80) * 0x200), gBoss[0].y + (Random(-0x40u, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+				SetNpChar(4, gBoss[0].x + (Random(-0x80, 0x80) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
 
 			break;
 	}
--- a/src/Bullet.cpp
+++ b/src/Bullet.cpp
@@ -286,7 +286,7 @@
 						if (bul->xm < 0)
 							bul->xm = 0x400;
 						else
-							bul->xm = -0x400u;
+							bul->xm = -0x400;
 					}
 
 					break;
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -237,7 +237,7 @@
 							for (unsigned int j = 0; j < 3; ++j)
 							{
 								const double alpha = pow((font_pixel[j] / 255.0), 1.0 / 1.8);			// Gamma correction
-								surface_pixel[j] = (colours[j] * alpha) + (surface_pixel[j] * (1.0 - alpha));	// Alpha blending
+								surface_pixel[j] = (unsigned char)((colours[j] * alpha) + (surface_pixel[j] * (1.0 - alpha)));	// Alpha blending
 							}
 
 							surface_pixel[3] = 0xFF;
@@ -257,7 +257,7 @@
 						if (alpha)
 						{
 							for (unsigned int j = 0; j < 3; ++j)
-								surface_pixel[j] = (colours[j] * alpha) + (surface_pixel[j] * (1.0 - alpha));	// Alpha blending
+								surface_pixel[j] = (unsigned char)((colours[j] * alpha) + (surface_pixel[j] * (1.0 - alpha)));	// Alpha blending
 
 							surface_pixel[3] = 0xFF;
 						}
--- a/src/MycHit.cpp
+++ b/src/MycHit.cpp
@@ -666,7 +666,7 @@
 	else
 		v1 = (long double)(npc->x - gMC.x);
 	
-	float fx1 = v1;
+	float fx1 = (float)v1;
 	
 	if (npc->y <= gMC.y)
 		v2 = (long double)(gMC.y - npc->y);
@@ -673,14 +673,14 @@
 	else
 		v2 = (long double)(npc->y - gMC.y);
 	
-	float fx2 = (long double)npc->hit.back;
+	float fx2 = (float)npc->hit.back;
 	if (0.0 == fx1)
 		fx1 = 1.0;
 	if (0.0 == fx2)
 		fx2 = 1.0;
 	
-	float fy1 = v2;
-	float fy2 = (long double)npc->hit.top;
+	float fy1 = (float)v2;
+	float fy2 = (float)npc->hit.top;
 	
 	if (fy1 / fx1 <= fy2 / fx2)
 	{
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -1522,7 +1522,7 @@
 			npc->xm -= 0x10;
 
 			if (npc->xm < -0x400)
-				npc->xm = -0x400u;
+				npc->xm = -0x400;
 
 			if (npc->shock)
 				npc->x += npc->xm / 2;
@@ -1805,7 +1805,7 @@
 				if (npc->direct == 0)
 				{
 					npc->x = gMC.x + 0x20000;
-					npc->xm = -0x2FFu;
+					npc->xm = -0x2FF;
 				}
 				else
 				{
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -1207,7 +1207,7 @@
 				gMC.x += 0x800;
 				gMC.y -= 0x1000;
 				gMC.xm = 0x5FF;
-				gMC.ym = -0x200u;
+				gMC.ym = -0x200;
 				gMC.direct = 2;
 				npc->direct = 2;
 			}
@@ -1215,8 +1215,8 @@
 			{
 				gMC.x -= 0x800;
 				gMC.y -= 0x1000;
-				gMC.xm = -0x5FFu;
-				gMC.ym = -0x200u;
+				gMC.xm = -0x5FF;
+				gMC.ym = -0x200;
 				gMC.direct = 0;
 				npc->direct = 0;
 			}
@@ -1371,7 +1371,7 @@
 			}
 
 			if (npc->direct == 0)
-				npc->xm = -0x100u;
+				npc->xm = -0x100;
 			else
 				npc->xm = 0x100;
 
--- a/src/NpcAct100.cpp
+++ b/src/NpcAct100.cpp
@@ -730,7 +730,7 @@
 		PlaySoundObject(6, 1);
 
 		if (npc->direct == 0)
-			npc->xm = -0x100u;
+			npc->xm = -0x100;
 		else
 			npc->xm = 0x100;
 	}
@@ -1187,7 +1187,7 @@
 					npc->direct = 2;
 
 				if (npc->direct == 0)
-					npc->xm = -0x200u;
+					npc->xm = -0x200;
 				else
 					npc->xm = 0x200;
 
@@ -1196,7 +1196,7 @@
 					npc->count1 = 0;
 					npc->ani_no = 4;
 					npc->act_no = 21;
-					npc->ym = -0x400u;
+					npc->ym = -0x400;
 					npc->xm *= 2;
 					npc->damage = 5;
 					PlaySoundObject(102, 1);
@@ -1204,7 +1204,7 @@
 				else
 				{
 					npc->act_no = 21;
-					npc->ym = -0x400u;
+					npc->ym = -0x400;
 					PlaySoundObject(30, 1);
 				}
 			}
--- a/src/NpcAct140.cpp
+++ b/src/NpcAct140.cpp
@@ -145,7 +145,7 @@
 				npc->ym = -0x5FF;
 
 				if (npc->direct == 0)
-					npc->xm = -0x200u;
+					npc->xm = -0x200;
 				else
 					npc->xm = 0x200;
 			}
@@ -247,7 +247,7 @@
 			npc->damage = 0;
 
 			for (int i = 0; i < 8; ++i)
-				SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600u, 0), 0, 0, 0x100);
+				SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
 
 			break;
 
--- a/src/NpcAct220.cpp
+++ b/src/NpcAct220.cpp
@@ -942,7 +942,7 @@
 				npc->direct = 0;
 
 			if (npc->direct == 0)
-				npc->xm = -0x400u;
+				npc->xm = -0x400;
 			else
 				npc->xm = 0x400;
 
--- a/src/NpcAct240.cpp
+++ b/src/NpcAct240.cpp
@@ -85,7 +85,7 @@
 				npc->direct = 0;
 
 			if (npc->direct == 0)
-				npc->xm = -0x200u;
+				npc->xm = -0x200;
 			else
 				npc->xm = 0x200;
 
--- a/src/NpcAct260.cpp
+++ b/src/NpcAct260.cpp
@@ -806,7 +806,7 @@
 
 			if (npc->act_wait > 20 && npc->act_wait % 3 == 1)
 			{
-				const int ym = Random(-0x200u, 0x200);
+				const int ym = Random(-0x200, 0x200);
 				const int xm = 4 * Random(0x100, 0x200);
 
 				if (npc->direct == 0)
--- a/src/NpcAct340.cpp
+++ b/src/NpcAct340.cpp
@@ -285,7 +285,7 @@
 
 				for (int i = 0; i < 8; ++i)
 				{
-					const int x = npc->x + (Random(-0x10u, 0x10) * 0x200);
+					const int x = npc->x + (Random(-0x10, 0x10) * 0x200);
 					SetNpChar(4, x, npc->y + 0x1400, 0, 0, 0, 0, 0x100);
 				}
 
@@ -1122,7 +1122,7 @@
 
 		case 12:
 			if (gMC.y < npc->y)
-				npc->ym = -0xAAu;
+				npc->ym = -0xAA;
 			else
 				npc->ym = 0xAA;
 
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -163,7 +163,7 @@
 	for (int j = 0; j < 8; j++)
 	{
 		for (int i = 0; i < 2; i++) {
-			int64_t tmpDouble = ((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000);
+			uint32_t tmpDouble = ((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000);
 			lpORGANBUFFER[track][j][i]->SetFrequency(tmpDouble);
 		}
 	}
--- a/src/PixTone.cpp
+++ b/src/PixTone.cpp
@@ -15,7 +15,7 @@
 	// Sine wave
 	for (i = 0; i < 256; ++i)
 	{
-		gWaveModelTable[0][i] = (sin(i * 6.283184 / 256.0) * 64.0);
+		gWaveModelTable[0][i] = (signed char)(sin(i * 6.283184 / 256.0) * 64.0);
 		a = gWaveModelTable[0][i];
 	}
 
@@ -64,7 +64,7 @@
 	// The Linux port added a cute optimisation here, where MakeWaveTables is only called once during the game's execution
 	MakeWaveTables();
 
-	char envelopeTable[0x100];
+	signed char envelopeTable[0x100];
 	memset(envelopeTable, 0, 0x100);
 
 	int i = 0;
@@ -73,7 +73,7 @@
 	dEnvelope = ptp->initial;
 	while (i < ptp->pointAx)
 	{
-		envelopeTable[i] = dEnvelope;
+		envelopeTable[i] = (signed char)dEnvelope;
 		dEnvelope = ((double)ptp->pointAy - ptp->initial) / ptp->pointAx + dEnvelope;
 		++i;
 	}
@@ -81,7 +81,7 @@
 	dEnvelope = ptp->pointAy;
 	while (i < ptp->pointBx)
 	{
-		envelopeTable[i] = dEnvelope;
+		envelopeTable[i] = (signed char)dEnvelope;
 		dEnvelope = ((double)ptp->pointBy - ptp->pointAy) / (double)(ptp->pointBx - ptp->pointAx) + dEnvelope;
 		++i;
 	}
@@ -89,7 +89,7 @@
 	dEnvelope = ptp->pointBy;
 	while (i < ptp->pointCx)
 	{
-		envelopeTable[i] = dEnvelope;
+		envelopeTable[i] = (signed char)dEnvelope;
 		dEnvelope = ((double)ptp->pointCy - ptp->pointBy) / (double)(ptp->pointCx - ptp->pointBx) + dEnvelope;
 		++i;
 	}
@@ -97,7 +97,7 @@
 	dEnvelope = ptp->pointCy;
 	while (i < 256)
 	{
-		envelopeTable[i] = dEnvelope;
+		envelopeTable[i] = (signed char)dEnvelope;
 		dEnvelope = (double)dEnvelope - ptp->pointCy / (double)(256 - ptp->pointCx);
 		++i;
 	}
@@ -130,7 +130,7 @@
 		const int a = (int)dMain % 256;
 		const int b = (int)dPitch % 256;
 		const int c = (int)dVolume % 256;
-		const int d = (double)(i * 0x100) / ptp->size;
+		const int d = (int)((double)(i * 0x100) / ptp->size);
 		pData[i] = gWaveModelTable[ptp->oMain.model][a]
 			* ptp->oMain.top
 			/ 64
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -115,7 +115,7 @@
 {
 	//Volume is in hundredths of decibels, from 0 to -10000
 	lVolume = clamp(lVolume, (int32_t)-10000, (int32_t)0);
-	return pow(10.0, lVolume / 2000.0);
+	return (float)pow(10.0, lVolume / 2000.0);
 }
 
 void SOUNDBUFFER::SetVolume(int32_t lVolume)
@@ -158,11 +158,11 @@
 		const double freqPosition = frequency / FREQUENCY; //This is added to position at the end
 		
 		//Get the in-between sample this is (linear interpolation)
-		const float sample1 = ((looped || ((size_t)samplePosition) >= 1) ? data[(size_t)samplePosition] : 0x80);
-		const float sample2 = ((looping || (((size_t)samplePosition) + 1) < size) ? data[(((size_t)samplePosition) + 1) % size] : 0x80);
+		const float sample1 = ((looped || ((size_t)samplePosition) >= 1) ? data[(size_t)samplePosition] : 128.0f);
+		const float sample2 = ((looping || (((size_t)samplePosition) + 1) < size) ? data[(((size_t)samplePosition) + 1) % size] : 128.0f);
 		
 		//Interpolate sample
-		const float subPos = std::fmod(samplePosition, 1.0);
+		const float subPos = (float)std::fmod(samplePosition, 1.0);
 		const float sampleA = sample1 + (sample2 - sample1) * subPos;
 		
 		//Convert sample to float32
@@ -169,8 +169,8 @@
 		const float sampleConvert = (sampleA - 128.0f) / 128.0f;
 		
 		//Mix
-		buffer[sample][0] += sampleConvert * volume * volume_l;
-		buffer[sample][1] += sampleConvert * volume * volume_r;
+		buffer[sample][0] += (float)(sampleConvert * volume * volume_l);
+		buffer[sample][1] += (float)(sampleConvert * volume * volume_r);
 		
 		//Increment position
 		samplePosition += freqPosition;
@@ -305,7 +305,7 @@
 
 size_t MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no)
 {
-	size_t sample_count = 0;
+	int sample_count = 0;
 	for (int i = 0; i < ptp_num; ++i)
 	{
 		if (ptp[i].size > sample_count)
--- a/src/Triangle.cpp
+++ b/src/Triangle.cpp
@@ -19,7 +19,7 @@
 	//Tangent
 	for (i = 0; i < 0x21; ++i)
 	{
-		float a = i * 6.2831855 / 256.0;
+		float a = (float)(i * 6.2831855 / 256.0);
 		float b = sinf(a) / cosf(a);
 		gTan[i] = (int16_t)(b * 8192.0);
 	}