shithub: cstory

Download patch

ref: ee88e805b35f4087a126856f27264133bced1212
parent: bedae97796d459b4422828ec28739aa5ee8db074
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Feb 5 17:51:44 EST 2019

Fix some errors and prevent some GCC warnings

--- a/src/BossOhm.cpp
+++ b/src/BossOhm.cpp
@@ -51,6 +51,7 @@
 		{
 			case 0:
 				gBoss[i].act_no = 1;
+				// Fallthrough
 			case 1:
 				if (i == 3)
 					gBoss[i].x = gBoss[0].x - 0x2000;
@@ -150,6 +151,7 @@
 		gBoss[0].act_no = 30;
 		gBoss[0].act_wait = 0;
 		gBoss[0].ani_no = 0;
+		// Fallthrough
 	case 30:
 		SetQuake(2);
 		gBoss[0].y -= 0x200;
--- a/src/Bullet.cpp
+++ b/src/Bullet.cpp
@@ -915,7 +915,7 @@
 			}
 			
 			PlaySoundObject(44, 1);
-			
+			// Fallthrough
 		case 1:
 			if (level == 1)
 			{
--- a/src/Caret.cpp
+++ b/src/Caret.cpp
@@ -17,7 +17,7 @@
 
 void ActCaret00(CARET *crt)
 {
-	;
+	(void)crt;
 }
 
 void ActCaret01(CARET *crt)
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -145,9 +145,9 @@
 	unsigned char (*src_pixels)[surf[surf_no].surface->pitch / 4][4] = (unsigned char (*)[surf[surf_no].surface->pitch/ 4][4])surf[surf_no].surface->pixels;
 	unsigned char (*dst_pixels)[pitch / 4][4] = (unsigned char (*)[pitch/ 4][4])raw_pixels;
 
-	for (unsigned int h = 0; h < surf[surf_no].surface->h; ++h)
+	for (int h = 0; h < surf[surf_no].surface->h; ++h)
 	{
-		for (unsigned int w = 0; w < surf[surf_no].surface->w; ++w)
+		for (int w = 0; w < surf[surf_no].surface->w; ++w)
 		{
 			dst_pixels[h][w][0] = src_pixels[h][w][0];
 			dst_pixels[h][w][1] = src_pixels[h][w][1];
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -58,7 +58,7 @@
 		case 3:
 		case 4:
 			length = zero_bit;
-			charcode = string[0] & (1 << (8 - zero_bit)) - 1;
+			charcode = (string[0] & (1 << (8 - zero_bit))) - 1;
 
 			for (unsigned int i = 1; i < zero_bit; ++i)
 			{
@@ -230,7 +230,7 @@
 			const int letter_x = x + pen_x + face->glyph->bitmap_left;
 			const int letter_y = y + ((FT_MulFix(face->ascender, face->size->metrics.y_scale) - face->glyph->metrics.horiBearingY + (64 / 2)) / 64);
 
-			for (int iy = MAX(-letter_y, 0); letter_y + iy < MIN(letter_y + converted.rows, surface->h); ++iy)
+			for (int iy = MAX(-letter_y, 0); letter_y + iy < MIN(letter_y + converted.rows, (unsigned int)surface->h); ++iy)
 			{
 				if (face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD)
 				{
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -6,6 +6,7 @@
 #include "NpChar.h"
 #include "Game.h"
 #include "CommonDefines.h"
+#include "Boss.h"
 
 FRAME gFrame;
 
@@ -127,8 +128,8 @@
 
 void SetFrameTargetBoss(int no, int wait)
 {
-	//gFrame.tgt_x = &gBoss[no].x;
-	//gFrame.tgt_y = &gBoss[no].y;
+	gFrame.tgt_x = &gBoss[no].x;
+	gFrame.tgt_y = &gBoss[no].y;
 	gFrame.wait = wait;
 }
 
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -92,7 +92,7 @@
 		}
 		
 		//Draw digit
-		if ( bZero && offset == 2 || sw != 0 || offset == 3 )
+		if ((bZero && offset == 2) || sw != 0 || offset == 3 )
 			PutBitmap3(&rcClient, x + 8 * offset, y, &rect[a], SURFACE_ID_TEXT_BOX);
 		
 		//Go to next digit
@@ -119,7 +119,7 @@
 	
 	CutNoise();
 	
-	int wait = 0;
+	unsigned int wait = 0;
 	while (wait < 500)
 	{
 		//Increase timer
@@ -295,7 +295,7 @@
 	gMC.equip |= 0x100;
 	
 	//Start loop
-	int wait = 0;
+	unsigned int wait = 0;
 	
 	while (true)
 	{
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -414,7 +414,7 @@
 		case 0: //Init
 			npc->y += 0x600;
 			npc->act_no = 1;
-
+			// Fallthrough
 		case 1: //Waiting
 			//Look at player
 			if (npc->x <= gMC.x)
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -52,7 +52,7 @@
 			break;
 	}
 
-	RECT rect[0];
+	RECT rect[1];
 
 	rect[0]	= {224, 40, 240, 48};
 
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -39,6 +39,7 @@
 			npc->act_no = 1;
 			npc->ani_no = 0;
 			npc->ani_wait = 0;
+			// Fallthrough
 		case 1:
 			if (Random(0, 120) == 10)
 			{
@@ -65,6 +66,7 @@
 			npc->act_no = 4;
 			npc->ani_no = 2;
 			npc->ani_wait = 0;
+			// Fallthrough
 		case 4:
 			if (++npc->ani_wait > 4)
 			{
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -639,7 +639,7 @@
 		case 0: //Init
 			npc->y += 0x600;
 			npc->act_no = 1;
-
+			// Fallthrough
 		case 1: //Waiting
 			//Look at player
 			if (npc->x <= gMC.x)
--- a/src/NpcAct140.cpp
+++ b/src/NpcAct140.cpp
@@ -793,6 +793,7 @@
 			for (int i = 0; i < 4; i++)
 				SetNpChar(4, npc->x, npc->y, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
 			PlaySoundObject(71, 1);
+			// Fallthrough
 		case 11:
 			npc->ani_no = 2;
 			break;
@@ -800,6 +801,7 @@
 			npc->act_no = 21;
 			npc->act_wait = 64;
 			PlaySoundObject(29, 1);
+			// Fallthrough
 		case 21:
 			if (!--npc->act_wait)
 				npc->cond = 0;
@@ -808,6 +810,7 @@
 			npc->act_no = 51;
 			npc->ani_no = 3;
 			npc->ani_wait = 0;
+			// Fallthrough
 		case 51:
 			if (++npc->ani_wait > 4)
 			{
@@ -827,6 +830,7 @@
 			npc->ani_no = 7;
 			npc->tgt_x = npc->x;
 			npc->tgt_y = npc->y;
+			// Fallthrough
 		case 61:
 			npc->tgt_y += 0x100;
 			npc->x = npc->tgt_x + (Random(-1, 1) << 9);
@@ -837,6 +841,7 @@
 			npc->act_wait = 0;
 			npc->ani_no = 3;
 			npc->ani_wait = 0;
+			// Fallthrough
 		case 0x47:
 			if ( npc->direct )
 				npc->x -= 0x100;
@@ -859,6 +864,7 @@
 			npc->act_no = 101;
 			npc->ani_no = 3;
 			npc->ani_wait = 0;
+			// Fallthrough
 		case 101:
 			npc->ym += 0x40;
 			if (npc->ym > 0x5FF)
--- a/src/NpcAct200.cpp
+++ b/src/NpcAct200.cpp
@@ -34,5 +34,5 @@
 	else if (Random(0, 40) == 1)
 		SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, 0, 0x100);
 
-	npc->rect = rc[1];
-}
\ No newline at end of file
+	npc->rect = rc[0];
+}
--- a/src/NpcAct280.cpp
+++ b/src/NpcAct280.cpp
@@ -13,6 +13,8 @@
 //Quake
 void ActNpc292(NPCHAR *npc)
 {
+	(void)npc;
+
 	SetQuake(10);
 }
 
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -19,7 +19,7 @@
 
 	const size_t tblSize = SDL_RWsize(fp);
 
-	const int npcCount = tblSize / 0x18;
+	const size_t npcCount = tblSize / 0x18;
 	gNpcTable = (NPC_TABLE*)malloc(npcCount * sizeof(NPC_TABLE));
 
 	for (size_t i = 0; i < npcCount; i++) //bits
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -123,7 +123,7 @@
 			uint8_t *wp_sub = wp;
 			size_t wav_tp = 0;
 			
-			for (int i = 0; i < data_size; i++)
+			for (size_t i = 0; i < data_size; i++)
 			{
 				uint8_t work = *(wavep+wav_tp);
 				work += 0x80;
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -76,9 +76,6 @@
 
 void SOUNDBUFFER::Release()
 {
-	if (this == NULL)
-		return;
-	
 	//TODO: find a better and more stable(?) way to handle this function
 	delete this;
 }
@@ -85,9 +82,6 @@
 
 void SOUNDBUFFER::Lock(uint8_t **outBuffer, size_t *outSize)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 
 	if (outBuffer != nullptr)
@@ -99,17 +93,11 @@
 
 void SOUNDBUFFER::Unlock()
 {
-	if (this == NULL)
-		return;
-	
 	SDL_UnlockAudioDevice(audioDevice);
 }
 
 void SOUNDBUFFER::SetCurrentPosition(uint32_t dwNewPosition)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	samplePosition = dwNewPosition;
 	SDL_UnlockAudioDevice(audioDevice);
@@ -117,9 +105,6 @@
 
 void SOUNDBUFFER::SetFrequency(uint32_t dwFrequency)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	frequency = (double)dwFrequency;
 	SDL_UnlockAudioDevice(audioDevice);
@@ -134,9 +119,6 @@
 
 void SOUNDBUFFER::SetVolume(int32_t lVolume)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	volume = MillibelToVolume(lVolume);
 	SDL_UnlockAudioDevice(audioDevice);
@@ -144,9 +126,6 @@
 
 void SOUNDBUFFER::SetPan(int32_t lPan)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	volume_l = MillibelToVolume(-lPan);
 	volume_r = MillibelToVolume(lPan);
@@ -155,9 +134,6 @@
 
 void SOUNDBUFFER::Play(bool bLooping)
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	playing = true;
 	looping = bLooping;
@@ -166,9 +142,6 @@
 
 void SOUNDBUFFER::Stop()
 {
-	if (this == NULL)
-		return;
-	
 	SDL_LockAudioDevice(audioDevice);
 	playing = false;
 	SDL_UnlockAudioDevice(audioDevice);
@@ -176,9 +149,6 @@
 
 void SOUNDBUFFER::Mix(float (*buffer)[2], size_t samples)
 {
-	if (this == NULL)
-		return;
-	
 	if (!playing) //This sound buffer isn't playing
 		return;
 
@@ -225,6 +195,8 @@
 //Sound mixer
 void AudioCallback(void *userdata, uint8_t *stream, int len)
 {
+	(void)userdata;
+
 	float (*buffer)[2] = (float(*)[2])stream;
 	const size_t samples = len / (sizeof(float) * 2);
 
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -521,7 +521,6 @@
 					else if (gTS.flags & 0x10)
 					{
 						//SAT/CAT/TUR printing
-						x;
 						for (x = gTS.p_read; ; x++)
 						{
 							//Break if reaches command, or new-line
--- a/src/ValueView.cpp
+++ b/src/ValueView.cpp
@@ -21,7 +21,7 @@
 	int i;
 	
 	//TODO: Boi I'm reaaaally boutta getcho pickle chin aah boi, egg head like collard greens head ass boi, ol' hell dat bell dirt aaah boi stank ah boi afro head ass, lip gloss chin ah boi ugly ahhh boi *snort* uglaaaa
-	for (i = 0; i < VALUEVIEW_MAX && (!gVV[i].flag || gVV[i].px != px || (gVV[i].value >= 0 || value >= 0) && (gVV[i].value <= 0 || value <= 0)); i++);
+	for (i = 0; i < VALUEVIEW_MAX && (!gVV[i].flag || gVV[i].px != px || ((gVV[i].value >= 0 || value >= 0) && (gVV[i].value <= 0 || value <= 0))); i++);
 	
 	int index;
 	if (i == VALUEVIEW_MAX)
--