shithub: cstory

Download patch

ref: affaf25e5c26b00e2e2126b391f40e0775c30328
parent: 6e20f4cc154a4dd502029519bdb91102f4683c02
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jan 7 15:35:15 EST 2020

Sorted out the other NPCs' variables too

--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -1096,10 +1096,9 @@
 // Balrog (hover)
 void ActNpc036(NPCHAR *npc)
 {
-	unsigned char deg;
-	int ym;
-	int xm;
 	int i;
+	unsigned char deg;
+	int xm, ym;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -118,6 +118,8 @@
 // Sue
 void ActNpc042(NPCHAR *npc)
 {
+	int n;
+
 	RECT rcLeft[13] = {
 		{0, 0, 16, 16},
 		{16, 0, 32, 16},
@@ -150,8 +152,6 @@
 		{160, 48, 176, 64},
 	};
 
-	int n;
-
 	switch (npc->act_no)
 	{
 		case 0:
@@ -870,8 +870,7 @@
 void ActNpc049(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	if (npc->act_no >= 10 && npc->pNpc->code_char == 3)
 	{
@@ -1916,8 +1915,8 @@
 			if ((++npc->count2 % 8) == 0 && npc->x < gMC.x + (160 * 0x200) && npc->x > gMC.x - (160 * 0x200))	// TODO: Maybe do something about this for widescreen
 			{
 				unsigned char deg;
-				int ym;
 				int xm;
+				int ym;
 
 				deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
 				deg += (unsigned char)Random(-6, 6);
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -199,6 +199,8 @@
 // King
 void ActNpc061(NPCHAR *npc)
 {
+	int i;
+
 	RECT rcLeft[11] = {
 		{224, 32, 240, 48},
 		{240, 32, 256, 48},
@@ -226,8 +228,6 @@
 		{0, 0, 0, 0},
 		{112, 32, 128, 48},
 	};
-
-	int i;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct080.cpp
+++ b/src/NpcAct080.cpp
@@ -877,8 +877,7 @@
 {
 	int i;
 	unsigned char deg;
-	int xm;
-	int ym;
+	int xm, ym;
 
 	RECT rcLeft[12] = {
 		{0, 0, 40, 40},
--- a/src/NpcAct100.cpp
+++ b/src/NpcAct100.cpp
@@ -1068,8 +1068,6 @@
 // Press
 void ActNpc114(NPCHAR *npc)
 {
-	int i;
-
 	RECT rcLeft[3] = {
 		{144, 112, 160, 136},
 		{160, 112, 176, 136},
@@ -1076,6 +1074,8 @@
 		{176, 112, 192, 136},
 	};
 
+	int i;
+
 	switch (npc->act_no)
 	{
 		case 0:
@@ -1521,6 +1521,8 @@
 // Curly (boss)
 void ActNpc118(NPCHAR *npc)
 {
+	BOOL bUpper;
+
 	RECT rcLeft[9] = {
 		{0, 32, 32, 56},
 		{32, 32, 64, 56},
@@ -1545,7 +1547,7 @@
 		{160, 56, 192, 80},
 	};
 
-	BOOL bUpper = FALSE;
+	bUpper = FALSE;
 
 	if (npc->direct == 0 && npc->x < gMC.x)
 		bUpper = TRUE;
--- a/src/NpcAct120.cpp
+++ b/src/NpcAct120.cpp
@@ -1090,8 +1090,7 @@
 void ActNpc135(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	RECT rcLeft[2] = {
 		{256, 32, 288, 64},
--- a/src/NpcAct140.cpp
+++ b/src/NpcAct140.cpp
@@ -764,9 +764,8 @@
 // Critter (purple)
 void ActNpc147(NPCHAR *npc)
 {
+	int xm, ym;
 	unsigned char deg;
-	int xm;
-	int ym;
 
 	RECT rcLeft[6] = {
 		{0, 96, 16, 112},
@@ -1349,7 +1348,7 @@
 	npc->rect = rc;
 }
 
-static const RECT grcKitL[21] = {
+const RECT grcKitL[21] = {
 	{0, 0, 24, 24},
 	{24, 0, 48, 24},
 	{48, 0, 72, 24},
@@ -1373,7 +1372,7 @@
 	{96, 48, 120, 72}
 };
 
-static const RECT grcKitR[21] = {
+const RECT grcKitR[21] = {
 	{0, 24, 24, 48},
 	{24, 24, 48, 48},
 	{48, 24, 72, 48},
@@ -1624,8 +1623,7 @@
 void ActNpc155(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	if (npc->x > gMC.x + (((WINDOW_WIDTH / 2) + 160) * 0x200) || npc->x < gMC.x - (((WINDOW_WIDTH / 2) + 160) * 0x200) || npc->y > gMC.y + (((WINDOW_HEIGHT / 2) + 120) * 0x200) || npc->y < gMC.y - (((WINDOW_HEIGHT / 2) + 120) * 0x200))
 		return;
--- a/src/NpcAct160.cpp
+++ b/src/NpcAct160.cpp
@@ -1071,8 +1071,7 @@
 void ActNpc173(NPCHAR *npc)
 {
 	unsigned char deg;
-	int xm;
-	int ym;
+	int xm, ym;
 
 	RECT rcLeft[4] = {
 		{0, 128, 24, 152},
--- a/src/NpcAct180.cpp
+++ b/src/NpcAct180.cpp
@@ -19,8 +19,7 @@
 // Curly AI
 void ActNpc180(NPCHAR *npc)
 {
-	int xx;
-	int yy;
+	int xx, yy;
 
 	RECT rcLeft[11] = {
 		{0, 96, 16, 112},
@@ -978,12 +977,12 @@
 // Broken robot
 void ActNpc190(NPCHAR *npc)
 {
-	int i;
-
 	RECT rect[2] = {
 		{192, 32, 208, 48},
 		{208, 32, 224, 48},
 	};
+
+	int i;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct200.cpp
+++ b/src/NpcAct200.cpp
@@ -17,8 +17,7 @@
 void ActNpc200(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	RECT rcLeft[6] = {
 		{0, 0, 40, 40},
@@ -475,8 +474,8 @@
 		case 3:
 			switch (npc->act_wait)
 			{
-				// Interestingly, this NPC counts down at 60 frames per second,
-				// while the NPC322 (Deleet), counts at 50.
+				// Interestingly, this NPC counts down at 60 frames
+				// per second, while NPC322 (Deleet) counts at 50.
 				case 60 * 0:
 					SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100);
 					break;
--- a/src/NpcAct220.cpp
+++ b/src/NpcAct220.cpp
@@ -1129,10 +1129,10 @@
 // Gunfish projectile
 void ActNpc237(NPCHAR *npc)
 {
+	RECT rc = {312, 32, 320, 40};
+
 	int i;
 	BOOL bHit;
-
-	RECT rc = {312, 32, 320, 40};
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct240.cpp
+++ b/src/NpcAct240.cpp
@@ -318,12 +318,14 @@
 // Lava drop
 void ActNpc244(NPCHAR *npc)
 {
+	RECT rc = {96, 0, 104, 16};
+	BOOL bHit;
+
 	int i;
 
-	RECT rc = {96, 0, 104, 16};
 	npc->ym += 0x40;
 
-	BOOL bHit = FALSE;
+	bHit = FALSE;
 
 	if (npc->flag & 0xFF)
 		bHit = TRUE;
@@ -411,8 +413,6 @@
 // Press (proximity)
 void ActNpc246(NPCHAR *npc)
 {
-	int i;
-
 	RECT rcLeft[3] = {
 		{144, 112, 160, 136},
 		{160, 112, 176, 136},
@@ -419,6 +419,8 @@
 		{176, 112, 192, 136},
 	};
 
+	int i;
+
 	switch (npc->act_no)
 	{
 		case 0:
@@ -504,8 +506,7 @@
 void ActNpc247(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	RECT rcLeft[9] = {
 		{0, 0, 16, 16},
--- a/src/NpcAct260.cpp
+++ b/src/NpcAct260.cpp
@@ -186,8 +186,7 @@
 void ActNpc263(NPCHAR *npc)
 {
 	int deg;
-	int xm;
-	int ym;
+	int xm, ym;
 
 	RECT rcLeft[9] = {
 		{0, 0, 24, 32},
@@ -469,10 +468,9 @@
 // Doctor red wave (projectile)
 void ActNpc264(NPCHAR *npc)
 {
+	RECT rc = {288, 0, 304, 16};
 	unsigned char deg;
 
-	RECT rc = {288, 0, 304, 16};
-
 	if (npc->x < 0 || npc->x > gMap.width * 0x10 * 0x200)
 	{
 		VanishNpChar(npc);
@@ -597,8 +595,7 @@
 		{40, 160, 80, 208},
 	};
 
-	int ym;
-	int xm;
+	int xm, ym;
 	int i;
 
 	switch (npc->act_no)
@@ -1133,8 +1130,7 @@
 void ActNpc268(NPCHAR *npc)
 {
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	RECT rcLeft[10] = {
 		{0, 0, 40, 40},
@@ -1631,8 +1627,7 @@
 	};
 
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	switch (npc->act_no)
 	{
@@ -1825,8 +1820,7 @@
 	};
 
 	unsigned char deg;
-	int ym;
-	int xm;
+	int xm, ym;
 
 	switch (npc->act_no)
 	{
@@ -2158,12 +2152,12 @@
 // Falling block (large)
 void ActNpc279(NPCHAR *npc)
 {
-	int i;
-
 	RECT rc[2] = {
 		{0, 16, 32, 48},
 		{16, 0, 32, 16},
 	};
+
+	int i;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct280.cpp
+++ b/src/NpcAct280.cpp
@@ -129,6 +129,7 @@
 // Mini Undead Core (active)
 void ActNpc282(NPCHAR *npc)
 {
+	// Yes, Pixel spelt this wrong (should be 'rc')
 	RECT tc[3] = {
 		{256, 80, 320, 120},
 		{256, 0, 320, 40},
@@ -203,9 +204,7 @@
 // Misery (transformed)
 void ActNpc283(NPCHAR *npc)
 {
-	int x;
-	int y;
-	int direct;
+	int x, y, direct;
 
 	RECT rcLeft[11] = {
 		{0, 64, 32, 96},
@@ -966,6 +965,7 @@
 void ActNpc285(NPCHAR *npc)
 {
 	RECT rc = {232, 104, 248, 120};
+	unsigned char deg;
 
 	if (npc->x < 0 || npc->x > gMap.width * 0x10 * 0x200)
 	{
@@ -973,8 +973,6 @@
 		return;
 	}
 
-	unsigned char deg;
-
 	switch (npc->act_no)
 	{
 		case 0:
@@ -1422,9 +1420,7 @@
 // Quake + falling block generator
 void ActNpc294(NPCHAR *npc)
 {
-	int x;
-	int y;
-	int dir;
+	int x, y, dir;
 
 	switch (npc->act_no)
 	{
@@ -1567,10 +1563,7 @@
 // Cloud generator
 void ActNpc296(NPCHAR *npc)
 {
-	int x;
-	int y;
-	int dir;
-	int pri;
+	int x, y, dir, pri;
 
 	if (++npc->act_wait > 16)
 	{
--- a/src/NpcAct300.cpp
+++ b/src/NpcAct300.cpp
@@ -35,6 +35,8 @@
 // Fish missile (Misery)
 void ActNpc301(NPCHAR *npc)
 {
+	int dir;
+
 	RECT rect[8] = {
 		{144, 0, 160, 16},
 		{160, 0, 176, 16},
@@ -46,8 +48,6 @@
 		{192, 16, 208, 32},
 	};
 
-	int dir;
-
 	switch (npc->act_no)
 	{
 		case 0:
@@ -102,6 +102,8 @@
 // Camera focus marker
 void ActNpc302(NPCHAR *npc)
 {
+	int n;
+
 	switch (npc->act_no)
 	{
 		case 10:
@@ -143,18 +145,16 @@
 
 			if (npc->direct != 0)
 			{
-				int i;
-
-				for (i = 0xAA; i < 0x200; ++i)
+				for (n = 0xAA; n < 0x200; ++n)
 				{
-					if (gNPC[i].cond & 0x80 && gNPC[i].code_event == npc->direct)
+					if (gNPC[n].cond & 0x80 && gNPC[n].code_event == npc->direct)
 					{
-						npc->pNpc = &gNPC[i];
+						npc->pNpc = &gNPC[n];
 						break;
 					}
 				}
 
-				if (i == 0x200)
+				if (n == 0x200)
 				{
 					npc->cond = 0;
 					break;
@@ -401,6 +401,8 @@
 // Stumpy
 void ActNpc308(NPCHAR *npc)
 {
+	unsigned char deg;
+
 	RECT rcLeft[2] = {
 		{128, 112, 144, 128},
 		{144, 112, 160, 128},
@@ -410,8 +412,6 @@
 		{128, 128, 144, 144},
 		{144, 128, 160, 144},
 	};
-
-	unsigned char deg;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct320.cpp
+++ b/src/NpcAct320.cpp
@@ -220,7 +220,7 @@
 			switch (npc->act_wait)
 			{
 				// Interestingly, this NPC counts down at 50 frames per second,
-				// while the NPC206 (the Egg Corridor Counter Bomb), counts at 60.
+				// while NPC206 (the Egg Corridor Counter Bomb), counts at 60.
 				case 50 * 0:
 					SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 0, NULL, 0x180);
 					break;
@@ -801,13 +801,13 @@
 // Ballos shockwave
 void ActNpc332(NPCHAR *npc)
 {
-	int xm;
-
 	RECT rc[3] = {
 		{144, 96, 168, 120},
 		{168, 96, 192, 120},
 		{192, 96, 216, 120},
 	};
+
+	int xm;
 
 	switch (npc->act_no)
 	{
--- a/src/NpcAct340.cpp
+++ b/src/NpcAct340.cpp
@@ -592,7 +592,6 @@
 void ActNpc342(NPCHAR *npc)
 {
 	static int flash;
-	unsigned char deg;
 
 	RECT rc[3] = {
 		{240, 48, 280, 88},
@@ -600,6 +599,8 @@
 		{280, 48, 320, 88},
 	};
 
+	unsigned char deg;
+
 	if (npc->act_no < 1000 && npc->pNpc->act_no >= 1000)
 		npc->act_no = 1000;
 
@@ -905,8 +906,6 @@
 // Ballos skull projectile
 void ActNpc345(NPCHAR *npc)
 {
-	int i;
-
 	RECT rc[4] = {
 		{128, 176, 144, 192},
 		{144, 176, 160, 192},
@@ -914,6 +913,8 @@
 		{176, 176, 192, 192},
 	};
 
+	int i;
+
 	switch (npc->act_no)
 	{
 		case 0:
@@ -974,10 +975,9 @@
 // Ballos 4 orbiting platform
 void ActNpc346(NPCHAR *npc)
 {
+	RECT rc = {240, 0, 272, 16};
 	unsigned char deg;
 
-	RECT rc = {240, 0, 272, 16};
-
 	if (npc->act_no < 1000 && npc->pNpc->act_no >= 1000)
 		npc->act_no = 1000;
 
@@ -1724,9 +1724,7 @@
 // Invisible deathtrap wall
 void ActNpc354(NPCHAR *npc)
 {
-	int i;
-	int x;
-	int y;
+	int i, x, y;
 
 	switch (npc->act_no)
 	{