summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/Decals.cpp7
-rw-r--r--src/Decals.h75
-rw-r--r--src/GameInitDispose.cpp15
-rw-r--r--src/GameTick.cpp592
-rw-r--r--src/Models.cpp15
-rw-r--r--src/Skeleton.cpp4
-rw-r--r--src/Sprites.cpp15
-rw-r--r--src/Sprites.h124
-rw-r--r--src/TGALoader.cpp3
-rw-r--r--src/Text.cpp5
-rw-r--r--src/Text.h49
11 files changed, 480 insertions, 424 deletions
diff --git a/src/Decals.cpp b/src/Decals.cpp
index 7617420..2f82bb2 100644
--- a/src/Decals.cpp
+++ b/src/Decals.cpp
@@ -371,3 +371,10 @@ void Decals::draw()
 	glDisable(GL_POLYGON_OFFSET_FILL);
 	glDepthFunc(GL_LEQUAL);
 }
+
+Decals::~Decals()
+{
+	const GLuint holes[] {bulletholetextureptr, cratertextureptr};
+	glDeleteTextures(2, holes);
+	glDeleteTextures(11, bloodtextureptr);
+}
diff --git a/src/Decals.h b/src/Decals.h
index e6e9b37..f63a0ca 100644
--- a/src/Decals.h
+++ b/src/Decals.h
@@ -1,49 +1,60 @@
-#ifndef _DECALS_H_
-#define _DECALS_H_
+// Decal object
+// Copyright (C) 2002  David Rosen
+// Copyright (C) 2003  Steven Fuller
+// Copyright (C) 2003  Zachary Jack Slater
+// Copyright (C) 2021  Nguyễn Gia Phong
+//
+// This file is part of Black Shades.
+//
+// Black Shades is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Black Shades is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef BLACKSHADES_DECALS_H
+#define BLACKSHADES_DECALS_H
 
-#include "Quaternions.h"
 #include "Files.h"
 #include "Quaternions.h"
 #include "Camera.h"
 #include "Models.h"
 #include "Fog.h"
-//
-// Model Structures
-//
 
 #define maxdecals 120
 
 class Decals{
-	public:
-				GLuint 				bulletholetextureptr;
-				GLuint 				cratertextureptr;
-				GLuint 				bloodtextureptr[11];
+public:
+	GLuint bulletholetextureptr;
+	GLuint cratertextureptr;
+	GLuint bloodtextureptr[11];
 
-				int howmanydecals;
+	int howmanydecals;
 
-				int type[maxdecals];
+	int type[maxdecals];
 
-				XYZ points[8*maxdecals];
-				int numpoints[maxdecals];
-				float texcoordsx[8*maxdecals];
-				float texcoordsy[8*maxdecals];
-				float alivetime[maxdecals];
+	XYZ points[8*maxdecals];
+	int numpoints[maxdecals];
+	float texcoordsx[8*maxdecals];
+	float texcoordsy[8*maxdecals];
+	float alivetime[maxdecals];
 
-				void draw();
+	void draw();
 
-				int DeleteDecal(int which);
-				int MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, Model *model, XYZ move, float rotation);
+	int DeleteDecal(int which);
+	int MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, Model *model, XYZ move, float rotation);
 
-				void DoStuff();
-				void LoadBulletHoleTexture(char *fileName);
-				void LoadCraterTexture(char *fileName);
-				void LoadBloodTexture(char *fileName, int which);
-
-				~Decals() {
-					glDeleteTextures( 1, (const GLuint *)bulletholetextureptr );
-					glDeleteTextures( 1, (const GLuint *)cratertextureptr );
-					glDeleteTextures( 11, (const GLuint *)bloodtextureptr );
-				};
+	void DoStuff();
+	void LoadBulletHoleTexture(char *fileName);
+	void LoadCraterTexture(char *fileName);
+	void LoadBloodTexture(char *fileName, int which);
+	~Decals();
 };
-
-#endif
+#endif // BLACKSHADES_DECALS_H
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index b791183..b791f74 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -2108,10 +2108,6 @@ void Game::InitGame()
 	initialized=1;
 	loadingscreenamount+=5;
 
-	//Sync to refresh rate
-	if(vblsync)
-		GLint swapInt = 1;
-
 	/*
 	for(int i=0;i<sprites.howmanysprites;i++){
 		sprites.DeleteSprite(0);
@@ -2299,9 +2295,12 @@ GLvoid Game::ReSizeGLScene(float fov, float near)
 
 Game::~Game()
 {
+	const GLuint textures[] {
+		personspritetextureptr,
+		deadpersonspritetextureptr,
+		scopetextureptr,
+		flaretextureptr,
+	};
+	glDeleteTextures(4, textures);
 	alDeleteSources(100, gSourceID); // delete sound sources
-	glDeleteTextures(1, (const GLuint*) personspritetextureptr);
-	glDeleteTextures(1, (const GLuint*) deadpersonspritetextureptr);
-	glDeleteTextures(1, (const GLuint*) scopetextureptr);
-	glDeleteTextures(1, (const GLuint*) flaretextureptr);
 }
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 2800632..7f25e1b 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -57,7 +57,8 @@ void Game::Splat(int k)
 
 	auto& skeleton = person[k].skeleton;
 	skeleton.free = 1;
-	skeleton.offset = person[k].health = 0;
+	skeleton.offset = 0;
+	person[k].health = 0;
 	person[k].longdead = person[k].bleeding = person[k].bleeddelay = 1;
 	person[k].DoAnimations(k);
 
@@ -533,17 +534,14 @@ void Game::Tick()
 
 		if(endz>num_blocks-1)endz=num_blocks-1;
 
-		if(k!=0){
-			/* TODO: huh? */
-			beginx==person[k].whichblockx;
-
-			beginz==person[k].whichblocky;
-
-			endx==person[k].whichblockx;
-
-			endz==person[k].whichblocky;
-
-		}
+		/* TODO: huh?
+		 * if(k!=0) {
+		 * 	beginx == person[k].whichblockx;
+		 * 	beginz == person[k].whichblocky;
+		 * 	endx == person[k].whichblockx;
+		 * 	endz == person[k].whichblocky;
+		 * }
+		 */
 
 		if(beginx<=endx&&beginz<=endz)
 
@@ -671,18 +669,15 @@ void Game::Tick()
 
 			}
 
-		if(person[k].playercoords.y<=0){
-
-			person[k].onground=1;
-
-			person[k].playercoords.y=0;
-
-			if(person[k].velocity.y<-maxfallvel)Splat(k);
-
-			else person[k].velocity.y=0;
-
-			if(k==0)onblockx=-1;onblocky=-1;
-
+		if (person[k].playercoords.y <= 0) {
+			person[k].onground = 1;
+			person[k].playercoords.y = 0;
+			if (person[k].velocity.y<-maxfallvel)
+				Splat(k);
+			else
+				person[k].velocity.y = 0;
+			if (k == 0)
+				onblockx = onblocky = -1;
 		}
 
 		// SBF - this is definately in the wrong spot!
@@ -1014,38 +1009,38 @@ void Game::Tick()
 		}
 
 		if(person[i].health<100&&person[i].type!=zombietype){
-		 		person[i].health-=multiplier*120;
+				person[i].health-=multiplier*120;
 		}
 
 		if(person[i].health<100&&person[i].type==zombietype){
-		 		person[i].health+=multiplier*10;
-		 		if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
+				person[i].health+=multiplier*10;
+				if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
 		}
 
 		if(person[i].health<100&&person[i].type==zombietype&&person[i].skeleton.free==1){
-		 		person[i].health+=multiplier*10;
-		 		if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
+				person[i].health+=multiplier*10;
+				if(person[i].health>person[i].maxhealth)person[i].health=person[i].maxhealth;
 		}
 
 		if(person[i].health<40&&person[i].type==zombietype){
-		 		person[i].speedmult-=multiplier/20;
-		 		if(person[i].speedmult<.6){
+				person[i].speedmult-=multiplier/20;
+				if(person[i].speedmult<.6){
 					person[i].speedmult=.6;
 					person[i].killtarget=-1;
 				}
 		}
 
 		if(person[i].health>=40&&person[i].type==zombietype){
-		 		person[i].speedmult+=multiplier/40;
-		 		if(person[i].speedmult>.7+difficulty*.2){
+				person[i].speedmult+=multiplier/40;
+				if(person[i].speedmult>.7+difficulty*.2){
 					person[i].speedmult=.7+difficulty*.2;
 					person[i].killtarget=1;
 				}
 		}
 
 		if(person[i].maxhealth<100&&person[i].type==zombietype){
-		 		person[i].maxhealth+=multiplier*2;
-		 		if(person[i].maxhealth>100)person[i].maxhealth=100;
+				person[i].maxhealth+=multiplier*2;
+				if(person[i].maxhealth>100)person[i].maxhealth=100;
 		}
 
 		if(person[i].bleeding>0){
@@ -1070,21 +1065,21 @@ void Game::Tick()
 			if(person[i].type==playertype||person[i].type==eviltype){
 				if(i==0){
 					if(person[i].whichgun==shotgun)person[i].recoil-=multiplier*4;
-				 	if(person[i].whichgun==sniperrifle)person[i].recoil-=multiplier*2;
-				 	if(person[i].whichgun==handgun1)person[i].recoil-=multiplier*5;
-				 	if(person[i].whichgun==handgun2)person[i].recoil-=multiplier*5;
-				 	if(person[i].whichgun==assaultrifle)person[i].recoil-=multiplier*10;
-			 	}
+					if(person[i].whichgun==sniperrifle)person[i].recoil-=multiplier*2;
+					if(person[i].whichgun==handgun1)person[i].recoil-=multiplier*5;
+					if(person[i].whichgun==handgun2)person[i].recoil-=multiplier*5;
+					if(person[i].whichgun==assaultrifle)person[i].recoil-=multiplier*10;
+				}
 
-			 	if(i!=0){
+				if(i!=0){
 					if(person[i].whichgun==shotgun)person[i].recoil-=multiplier*1;
-				 	if(person[i].whichgun==sniperrifle)person[i].recoil-=multiplier*1;
-				 	if(person[i].whichgun==handgun1)person[i].recoil-=multiplier*2;
-				 	if(person[i].whichgun==handgun2)person[i].recoil-=multiplier*2;
-				 	if(person[i].whichgun==assaultrifle)person[i].recoil-=multiplier*10;
-			 	}
+					if(person[i].whichgun==sniperrifle)person[i].recoil-=multiplier*1;
+					if(person[i].whichgun==handgun1)person[i].recoil-=multiplier*2;
+					if(person[i].whichgun==handgun2)person[i].recoil-=multiplier*2;
+					if(person[i].whichgun==assaultrifle)person[i].recoil-=multiplier*10;
+				}
 
-			 	if(person[i].recoil<0)person[i].recoil=0;
+				if(person[i].recoil<0)person[i].recoil=0;
 
 				if(i==0){
 					oldzoom = zoom;
@@ -1111,22 +1106,22 @@ void Game::Tick()
 			if(i > 0
 			   && person[i].targetanimation == zombieeatanim
 			   && person[person[i].killtarget].eaten == i) {
-		 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].locked=1;
-		 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].locked=1;
-
-			 	for(int k=0;k<2;k++){
-		 			person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].position=DoRotation(person[i].skeleton.joints[person[i].skeleton.jointlabels[righthand]].position,0,person[i].playerrotation,0)+person[i].playercoords;
-			 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].velocity=0;
-			 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].position=DoRotation(person[i].skeleton.joints[person[i].skeleton.jointlabels[lefthand]].position,0,person[i].playerrotation,0)+person[i].playercoords;
-			 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].velocity=0;
-			 		person[person[i].killtarget].skeleton.DoConstraints();
+				person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].locked=1;
+				person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].locked=1;
+
+				for(int k=0;k<2;k++){
+					person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].position=DoRotation(person[i].skeleton.joints[person[i].skeleton.jointlabels[righthand]].position,0,person[i].playerrotation,0)+person[i].playercoords;
+					person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].velocity=0;
+					person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].position=DoRotation(person[i].skeleton.joints[person[i].skeleton.jointlabels[lefthand]].position,0,person[i].playerrotation,0)+person[i].playercoords;
+					person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].velocity=0;
+					person[person[i].killtarget].skeleton.DoConstraints();
 					person[person[i].killtarget].skeleton.DoConstraints(&blocksimplecollide[citytype[person[i].whichblockx][person[i].whichblocky]],&move,cityrotation[person[i].whichblockx][person[i].whichblocky]*90);
 				}
 
 				person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[head]].locked=0;
-		 		person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].locked=0;
-		 		person[person[i].killtarget].longdead=1;
-		 	}
+				person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].locked=0;
+				person[person[i].killtarget].longdead=1;
+			}
 
 			if(i>0&&enemystate!=1&&person[i].type==zombietype&&person[i].speedmult>.7){
 				if(findDistancefast(person[i].playercoords,person[1].playercoords)<20000)person[i].killtarget=1;
@@ -1139,16 +1134,26 @@ void Game::Tick()
 
 			bool realcheck = false;
 
-			//Pathfinding
-		 	if(i>0&&person[i].targetanimation!=getupfrontanim&&person[i].targetanimation!=thrownanim&&person[i].targetanimation!=getupbackanim&&person[i].currentanimation!=getupfrontanim&&person[i].currentanimation!=getupbackanim){
-
-		 		person[i].pathcheckdelay-=multiplier;
-
+			// Pathfinding
+			if (i > 0 && person[i].targetanimation != getupfrontanim
+			    && person[i].targetanimation != thrownanim
+			    && person[i].targetanimation != getupbackanim
+			    && person[i].currentanimation != getupfrontanim
+			    && person[i].currentanimation != getupbackanim) {
+				person[i].pathcheckdelay -= multiplier;
 				// Realcheck tells us
 				// a) we've got close to the end of our path or
 				// b) we're moving away from our target
-		 		realcheck=(abs(person[i].playercoords.x-person[i].pathtarget.x)<1&&abs(person[i].playercoords.z-person[i].pathtarget.z)<1)
-				  ||findDistancefast(person[i].playercoords,person[i].pathtarget)>findDistancefast(person[i].oldplayercoords,person[i].pathtarget);
+				auto moving_away
+					= findDistancefast(person[i].pathtarget,
+						person[i].playercoords)
+					> findDistancefast(person[i].pathtarget,
+						person[i].oldplayercoords);
+				realcheck = (abs(person[i].playercoords.x
+						- person[i].pathtarget.x) < 1
+					&& abs(person[i].playercoords.z
+						- person[i].pathtarget.z) < 1)
+					|| moving_away;
 
 				if(person[i].targetanimation==idleanim&&person[i].killtargetvisible==0){
 					person[i].targetanimation=walkanim;
@@ -1157,35 +1162,37 @@ void Game::Tick()
 				}
 
 				if((realcheck||((person[i].killtarget>-1&&person[i].type!=civiliantype)&&person[i].pathcheckdelay<=0)||person[i].killtargetvisible)){
-			 		person[i].pathcheckdelay=1.2;
-
-			 		if((person[i].killtarget==-1||person[i].type==civiliantype)&&!person[i].running){
-				 		person[i].killtargetvisible=0;
-				 		leastdistance=2000000;
-				 		for(int j=0;j<path.vertexNum;j++){
-				 			person[i].pathtarget.x=path.vertex[j].x;
-							person[i].pathtarget.z=path.vertex[j].z;
-							person[i].pathtarget.y=path.vertex[j].y;
-							person[i].pathtarget*=person[i].pathsize;
-							person[i].pathtarget.x+=person[i].whichblockx*block_spacing;
-							person[i].pathtarget.z+=person[i].whichblocky*block_spacing;
+					person[i].pathcheckdelay = 1.2f;
+
+					if ((person[i].killtarget == -1
+					     || person[i].type == civiliantype)
+					    && !person[i].running) {
+						person[i].killtargetvisible = 0;
+						leastdistance = 2000000;
+						for (int j = 0; j < path.vertexNum; j++) {
+							person[i].pathtarget.x = path.vertex[j].x;
+							person[i].pathtarget.z = path.vertex[j].z;
+							person[i].pathtarget.y = path.vertex[j].y;
+							person[i].pathtarget *= person[i].pathsize;
+							person[i].pathtarget.x += person[i].whichblockx*block_spacing;
+							person[i].pathtarget.z += person[i].whichblocky*block_spacing;
 
 							if(findDistancefast(person[i].playercoords,person[i].pathtarget)<leastdistance&&j!=1&&j!=person[i].oldpathnum&&j!=person[i].oldoldpathnum&&j!=person[i].oldoldoldpathnum){
 								leastdistance=findDistancefast(person[i].playercoords,person[i].pathtarget);
 								closesttarget=j;
 							}
-				 		}
-
-				 		if(closesttarget>=0&&closesttarget<path.vertexNum){
-					 		person[i].oldoldoldpathnum=person[i].oldoldpathnum;
-					 		person[i].oldoldpathnum=person[i].oldpathnum;
-					 		person[i].oldpathnum=person[i].pathnum;
-					 		person[i].pathnum=closesttarget;
-							person[i].pathtarget.x=path.vertex[person[i].pathnum].x;
-							person[i].pathtarget.z=path.vertex[person[i].pathnum].z;
-							person[i].pathtarget*=person[i].pathsize;
-							person[i].pathtarget.x+=person[i].whichblockx*block_spacing;
-							person[i].pathtarget.z+=person[i].whichblocky*block_spacing;
+						}
+
+						if (closesttarget >= 0 && closesttarget < path.vertexNum) {
+							person[i].oldoldoldpathnum = person[i].oldoldpathnum;
+							person[i].oldoldpathnum = person[i].oldpathnum;
+							person[i].oldpathnum = person[i].pathnum;
+							person[i].pathnum = closesttarget;
+							person[i].pathtarget.x = path.vertex[person[i].pathnum].x;
+							person[i].pathtarget.z = path.vertex[person[i].pathnum].z;
+							person[i].pathtarget *= person[i].pathsize;
+							person[i].pathtarget.x += person[i].whichblockx*block_spacing;
+							person[i].pathtarget.z += person[i].whichblocky*block_spacing;
 						}
 					}
 
@@ -1193,25 +1200,24 @@ void Game::Tick()
 						person[i].killtargetvisible=0;
 						person[i].targetanimation=joganim;
 
-						//Dead target?
-						if(person[person[i].killtarget].health<=0){
-						 	person[i].running=0;
-						 }
+						// Dead target?
+						if (person[person[i].killtarget].health <= 0)
+							person[i].running = 0;
 
 						 person[i].killtarget=1;
 
-						 //If pathfind
-						if(realcheck){
-				 		leastdistance=2000000;
-				 		person[i].lastdistancevictim=0;
-				 		closesttarget=-1;
+						// If pathfind
+						if (realcheck) {
+						leastdistance = 2000000;
+						person[i].lastdistancevictim = 0;
+						closesttarget = -1;
 
-				 		//Check best path
-				 		closesttarget=person[i].pathnum;
+						// Check best path
+						closesttarget = person[i].pathnum;
 
-				 		//Check other blocks?
-				 		if ((closesttarget==person[i].pathnum)){
-				 			beginx=person[i].whichblockx-2;
+						// Check other blocks?
+						if (closesttarget == person[i].pathnum) {
+							beginx = person[i].whichblockx-2;
 							if(beginx<0)beginx=0;
 							beginz=person[i].whichblocky-2;
 							if(beginz<0)beginz=0;
@@ -1221,12 +1227,12 @@ void Game::Tick()
 							if(endz>num_blocks-1)endz=num_blocks-1;
 							leastdistance=2000000;
 
-				 			for(int l=beginx;l<=endx;l++){
-								for(int m=beginx;m<=endx;m++){
-							 		for(int j=0;j<path.vertexNum;j++){
-							 			person[i].pathtarget.x=path.vertex[j].x;
-										person[i].pathtarget.y=path.vertex[j].y;
-										person[i].pathtarget.z=path.vertex[j].z;
+							for (int l = beginx; l <= endx; l++) {
+								for (int m = beginx; m <= endx; m++) {
+									for (int j = 0; j < path.vertexNum; j++){
+										person[i].pathtarget.x = path.vertex[j].x;
+										person[i].pathtarget.y = path.vertex[j].y;
+										person[i].pathtarget.z = path.vertex[j].z;
 										person[i].pathtarget*=person[i].pathsize;
 										person[i].pathtarget.x+=l*block_spacing;
 										person[i].pathtarget.z+=m*block_spacing;
@@ -1238,65 +1244,65 @@ void Game::Tick()
 											finaltarget=person[i].pathtarget;
 											person[i].whichblockx=l;
 											person[i].whichblocky=m;
-				 						}
-							 		}
-							 		}
-							 	}
-							 }
+										}
+									}
+									}
+								}
+							}
 
-				  		if(closesttarget!=-1){
-							person[i].pathnum=closesttarget;
-							person[i].pathtarget=finaltarget;
+						if (closesttarget != -1) {
+							person[i].pathnum = closesttarget;
+							person[i].pathtarget = finaltarget;
 						}
 						}
 					}
 
-					//Assassin
+					// Assassin
 					if((person[i].killtarget>-1&&person[i].type!=civiliantype)&&!person[i].running){
-						//Dead target?
+						// Dead target?
 						if(person[person[i].killtarget].health<=0&&person[i].type==eviltype){
-						 	person[i].playerrotation2=0;
-						 	person[i].whichgun=nogun;
-						 	person[i].targetanimation=walkanim;
-						 	person[i].lastdistancevictim=200000;
-						 	person[i].pathnum=-1;
-						 	enemystate=1;
-						 	person[i].killtarget=-1;
-						 	realcheck=1;
-						 }
-
-						 if(person[i].type==zombietype&&person[person[i].killtarget].health<=0){
+							person[i].playerrotation2 = 0;
+							person[i].whichgun = nogun;
+							person[i].targetanimation = walkanim;
+							person[i].lastdistancevictim = 200000;
+							person[i].pathnum = -1;
+							enemystate = 1;
+							person[i].killtarget = -1;
+							realcheck = 1;
+						}
+
+						if(person[i].type==zombietype&&person[person[i].killtarget].health<=0){
 							if(person[person[i].killtarget].eaten!=i){
-								person[i].playerrotation2=0;
-						 		person[i].targetanimation=zombiewalkanim;
-						 		person[i].lastdistancevictim=200000;
-						 		person[i].pathnum=-1;
-						 		realcheck=1;
-						 		person[i].killtarget=-1;
-						 	}
-
-						 	if(person[person[i].killtarget].eaten==i&&person[i].targetanimation!=zombieeatanim){
-						 		person[i].targetanimation=zombieeatanim;
-								person[i].targetframe=0;
-								person[i].target=0;
-						 	}
-						 	enemystate=1;
-						 }
-
-						 if(person[person[i].killtarget].health>0){
-						 if(person[person[i].killtarget].skeleton.free){
-						 	person[person[i].killtarget].playercoords=person[person[i].killtarget].averageloc;
-						 }
-
-						 //If pathfind
+								person[i].playerrotation2 = 0;
+								person[i].targetanimation = zombiewalkanim;
+								person[i].lastdistancevictim = 200000;
+								person[i].pathnum = -1;
+								realcheck = 1;
+								person[i].killtarget = -1;
+							}
+
+							if(person[person[i].killtarget].eaten == i && person[i].targetanimation != zombieeatanim) {
+								person[i].targetanimation = zombieeatanim;
+								person[i].targetframe = 0;
+								person[i].target = 0;
+							}
+							enemystate = 1;
+						}
+
+						if(person[person[i].killtarget].health>0){
+						if(person[person[i].killtarget].skeleton.free){
+							person[person[i].killtarget].playercoords=person[person[i].killtarget].averageloc;
+						}
+
+						// If pathfind
 						if(realcheck){
-				 		leastdistance=2000000;
-				 		person[i].lastdistancevictim=2000000;
-				 		closesttarget=-1;
+						leastdistance=2000000;
+						person[i].lastdistancevictim=2000000;
+						closesttarget=-1;
 
-				 		//Check best path
-				 		for(int j=0;j<path.vertexNum;j++){
-				 			person[i].pathtarget.x=path.vertex[j].x;
+						//Check best path
+						for(int j=0;j<path.vertexNum;j++){
+							person[i].pathtarget.x=path.vertex[j].x;
 							person[i].pathtarget.z=path.vertex[j].z;
 							person[i].pathtarget.y=path.vertex[j].y;
 							person[i].pathtarget*=person[i].pathsize;
@@ -1309,11 +1315,11 @@ void Game::Tick()
 								closesttarget=j;
 								finaltarget=person[i].pathtarget;
 							}
-				 		}
+						}
 
-				 		leastdistance=2000000;
-				 		for(int j=0;j<path.vertexNum;j++){
-				 			person[i].pathtarget.x=path.vertex[j].x;
+						leastdistance=2000000;
+						for(int j=0;j<path.vertexNum;j++){
+							person[i].pathtarget.x=path.vertex[j].x;
 							person[i].pathtarget.z=path.vertex[j].z;
 							person[i].pathtarget.y=path.vertex[j].y;
 							person[i].pathtarget*=person[i].pathsize;
@@ -1326,11 +1332,11 @@ void Game::Tick()
 								closesttarget=j;
 								finaltarget=person[i].pathtarget;
 							}
-				 		}
+						}
 
-				 		//Check other blocks?
-				 		if((closesttarget==person[i].pathnum)||closesttarget==-1){
-				 			beginx=person[i].whichblockx-2;
+						//Check other blocks?
+						if((closesttarget==person[i].pathnum)||closesttarget==-1){
+							beginx=person[i].whichblockx-2;
 							if(beginx<0)beginx=0;
 							beginz=person[i].whichblocky-2;
 							if(beginz<0)beginz=0;
@@ -1340,12 +1346,12 @@ void Game::Tick()
 							if(endz>num_blocks-1)endz=num_blocks-1;
 							leastdistance=2000000;
 
-				 			for(int l=beginx;l<=endx;l++){
+							for(int l=beginx;l<=endx;l++){
 								for(int m=beginx;m<=endx;m++){
-							 		if(l!=person[i].whichblockx||m!=person[i].whichblocky){
+									if(l!=person[i].whichblockx||m!=person[i].whichblocky){
 
-							 		for(int j=0;j<path.vertexNum;j++){
-							 			person[i].pathtarget.x=path.vertex[j].x;
+									for(int j=0;j<path.vertexNum;j++){
+										person[i].pathtarget.x=path.vertex[j].x;
 										person[i].pathtarget.y=path.vertex[j].y;
 										person[i].pathtarget.z=path.vertex[j].z;
 										person[i].pathtarget*=person[i].pathsize;
@@ -1358,15 +1364,15 @@ void Game::Tick()
 											finaltarget=person[i].pathtarget;
 											person[i].whichblockx=l;
 											person[i].whichblocky=m;
-				 						}
-							 		}
-							 		}
-							 	}
+										}
+									}
+									}
+								}
 							 }
-				 		}
+						}
 
-				 		if(closesttarget!=-1){
-				 			person[i].onpath=1;
+						if(closesttarget!=-1){
+							person[i].onpath=1;
 							person[i].pathnum=closesttarget;
 							person[i].pathtarget=finaltarget;
 						}
@@ -1379,10 +1385,10 @@ void Game::Tick()
 
 						if(closesttarget!=-1&&findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)>30000)person[i].killtargetvisible=0;
 
-				 		if(person[i].killtarget==0&&visions==1)person[i].killtargetvisible=0;
+						if(person[i].killtarget==0&&visions==1)person[i].killtargetvisible=0;
 
-				 		if(person[i].killtargetvisible){
-					 		beginx=person[i].whichblockx-2;
+						if(person[i].killtargetvisible){
+							beginx=person[i].whichblockx-2;
 							if(beginx<0)beginx=0;
 							beginz=person[i].whichblocky-2;
 							if(beginz<0)beginz=0;
@@ -1391,80 +1397,80 @@ void Game::Tick()
 							endz=person[i].whichblocky+2;
 							if(endz>num_blocks-1)endz=num_blocks-1;
 
-					 		for(int l=beginx;l<=endx;l++){
+							for(int l=beginx;l<=endx;l++){
 								for(int m=beginx;m<=endx;m++){
-							 		move.x=l*block_spacing;
+									move.x=l*block_spacing;
 									move.z=m*block_spacing;
 									move.y=-3;
 									if(person[i].killtargetvisible){
-								 		if(blocksimple.LineCheck2(person[i].playercoords,person[person[i].killtarget].playercoords,&blah,move,cityrotation[l][m])!=-1)
-			 							{
-			 								person[i].killtargetvisible=0;
-			 							}
-			 						}
-							 	}
+										if(blocksimple.LineCheck2(person[i].playercoords,person[person[i].killtarget].playercoords,&blah,move,cityrotation[l][m])!=-1)
+										{
+											person[i].killtargetvisible=0;
+										}
+									}
+								}
 							 }
 							}
 
 							if(person[i].type==eviltype){
 								 if(!person[i].killtargetvisible&&person[i].targetanimation==idleanim){
-								 	person[i].targetanimation=joganim;
+									person[i].targetanimation=joganim;
 								 }
 
 								 if(!person[i].killtargetvisible){
-								 	person[i].aiming=0;
+									person[i].aiming=0;
 								 }
 
 								 if(person[i].killtargetvisible){
-								 	person[i].onpath=0;
-								 	person[i].lastdistancevictim=200000;
-								 	person[i].pathnum=-1;
-
-								 	if(person[i].whichgun==nogun){
-								 		person[i].whichgun=possiblegun[abs(Random()%numpossibleguns)];
-								 		person[i].reloads[person[i].whichgun]=1;
-								 		if(person[i].whichgun==knife)person[i].speedmult=.8+.5*difficulty;
-								 	}
+									person[i].onpath=0;
+									person[i].lastdistancevictim=200000;
+									person[i].pathnum=-1;
+
+									if(person[i].whichgun==nogun){
+										person[i].whichgun=possiblegun[abs(Random()%numpossibleguns)];
+										person[i].reloads[person[i].whichgun]=1;
+										if(person[i].whichgun==knife)person[i].speedmult=.8+.5*difficulty;
+									}
 
-								 	if(person[i].aiming==0)person[i].shotdelay=shotdelayamount/difficulty;
+									if(person[i].aiming==0)person[i].shotdelay=shotdelayamount/difficulty;
 
-								 	person[i].aiming=1;
+									person[i].aiming=1;
 
-								 	if(person[i].reloading>0)person[i].aiming=0;
+									if(person[i].reloading>0)person[i].aiming=0;
 
-								 	if(person[i].whichgun==handgun1||person[i].whichgun==handgun2)person[i].playerrotation2=-10;
+									if(person[i].whichgun==handgun1||person[i].whichgun==handgun2)person[i].playerrotation2=-10;
 
-								 	if(person[i].whichgun==assaultrifle||person[i].whichgun==sniperrifle||person[i].whichgun==shotgun)person[i].playerrotation2=20;
+									if(person[i].whichgun==assaultrifle||person[i].whichgun==sniperrifle||person[i].whichgun==shotgun)person[i].playerrotation2=20;
 
-								 	tooclose=1300;
-								 	toofar=3000;
+									tooclose=1300;
+									toofar=3000;
 
-								 	if(person[i].whichgun==shotgun){
-								 		tooclose=1400;
-								 		toofar=5000;
-								 	}
+									if(person[i].whichgun==shotgun){
+										tooclose=1400;
+										toofar=5000;
+									}
 
-								 	if(person[i].whichgun==assaultrifle){
-								 		tooclose=5000;
-								 		toofar=9000;
-								 	}
+									if(person[i].whichgun==assaultrifle){
+										tooclose=5000;
+										toofar=9000;
+									}
 
-								 	if(person[i].whichgun==sniperrifle){
-								 		tooclose=10000;
-								 		toofar=20000;
-								 	}
+									if(person[i].whichgun==sniperrifle){
+										tooclose=10000;
+										toofar=20000;
+									}
 
-								 	if(person[i].whichgun==knife){
-								 		tooclose=20;
-								 		toofar=20000;
-								 	}
+									if(person[i].whichgun==knife){
+										tooclose=20;
+										toofar=20000;
+									}
 
-								 	if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)>toofar)
-									 	person[i].targetanimation=joganim;
+									if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)>toofar)
+										person[i].targetanimation=joganim;
 
-								 	if((findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=tooclose&&person[person[i].killtarget].skeleton.free==0)||(tooclose>200&&findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=200)||(tooclose<=200&&findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<tooclose)){
-								 		if(person[i].targetanimation!=idleanim){
-									 		person[i].targetanimation=idleanim;
+									if((findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=tooclose&&person[person[i].killtarget].skeleton.free==0)||(tooclose>200&&findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=200)||(tooclose<=200&&findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<tooclose)){
+										if(person[i].targetanimation!=idleanim){
+											person[i].targetanimation=idleanim;
 											person[i].targetframe=0;
 											person[i].target=0;
 										}
@@ -1497,35 +1503,35 @@ void Game::Tick()
 											}
 										}
 									}
-								 	finaltarget=person[person[i].killtarget].playercoords;
+									finaltarget=person[person[i].killtarget].playercoords;
 								 }
 							}
 
 							if(person[i].type==zombietype&&person[person[i].killtarget].health>0){
 								 if(!person[i].killtargetvisible&&person[i].targetanimation==idleanim){
-								 	person[i].targetanimation=zombiejoganim;
+									person[i].targetanimation=zombiejoganim;
 								 }
 
 								 if(!person[i].killtargetvisible){
-								 	person[i].aiming=0;
+									person[i].aiming=0;
 								 }
 
 								 if(person[i].killtargetvisible){
-								 	person[i].onpath=0;
-								 	person[i].lastdistancevictim=200000;
-								 	person[i].pathnum=-1;
+									person[i].onpath=0;
+									person[i].lastdistancevictim=200000;
+									person[i].pathnum=-1;
 
-								 	if(person[i].aiming==0)person[i].shotdelay=shotdelayamount/difficulty;
+									if(person[i].aiming==0)person[i].shotdelay=shotdelayamount/difficulty;
 
-								 	if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)>20||person[i].targetanimation!=idleanim)
-									 	person[i].targetanimation=zombiejoganim;
+									if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)>20||person[i].targetanimation!=idleanim)
+										person[i].targetanimation=zombiejoganim;
 
-								 	if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=20){
-								 		murderer=i;
-								 		person[person[i].killtarget].health=0;
-								 		person[person[i].killtarget].eaten=i;
+									if(findDistancefast(person[i].playercoords, person[person[i].killtarget].playercoords)<=20){
+										murderer=i;
+										person[person[i].killtarget].health=0;
+										person[person[i].killtarget].eaten=i;
 									}
-								 	finaltarget=person[person[i].killtarget].playercoords;
+									finaltarget=person[person[i].killtarget].playercoords;
 								 }
 							}
 
@@ -1541,16 +1547,16 @@ void Game::Tick()
 						if(towards.z>0)person[i].playerrotation=180-person[i].playerrotation;
 					}
 				}
-		 	}
+			}
 
-		 	person[i].whichblockx=((person[i].playercoords.x+block_spacing/2)/block_spacing);
-		 	person[i].whichblocky=((person[i].playercoords.z+block_spacing/2)/block_spacing);
+			person[i].whichblockx=((person[i].playercoords.x+block_spacing/2)/block_spacing);
+			person[i].whichblocky=((person[i].playercoords.z+block_spacing/2)/block_spacing);
 			if(!person[i].onground)person[i].velocity.y+=multiplier*gravity;
-		 	if(!person[i].onground&&(i!=0||visions!=1))person[i].playercoords+=person[i].velocity*multiplier;
+			if(!person[i].onground&&(i!=0||visions!=1))person[i].playercoords+=person[i].velocity*multiplier;
 
-		 	//Death by bleeding/shock
-	 		if(person[i].health<=0){
-	 			person[i].skeleton.offset=0;
+			//Death by bleeding/shock
+			if(person[i].health<=0){
+				person[i].skeleton.offset=0;
 				person[i].skeleton.free=1;
 				person[i].longdead=1;
 
@@ -1566,7 +1572,7 @@ void Game::Tick()
 			}
 		 }
 
-	 	//Rag doll
+		//Rag doll
 		if(person[i].skeleton.free==1&&person[i].longdead>0){
 			person[i].whichblockx=((person[i].skeleton.joints[0].position.x+block_spacing/2)/block_spacing);
 			person[i].whichblocky=((person[i].skeleton.joints[0].position.z+block_spacing/2)/block_spacing);
@@ -1613,7 +1619,7 @@ void Game::Tick()
 
 			//Find orientation
 			XYZ firsttop=person[i].skeleton.joints[person[i].skeleton.jointlabels[neck]].position-person[i].skeleton.joints[person[i].skeleton.jointlabels[groin]].position;
-		 	Normalise(&firsttop);
+			Normalise(&firsttop);
 			person[i].playerrotation=acos(0-firsttop.z);
 			person[i].playerrotation*=360/6.28;
 			if(0>firsttop.x)person[i].playerrotation=360-person[i].playerrotation;
@@ -2048,7 +2054,8 @@ void Game::Tick()
 		person[j].shotdelay = shotdelayamount / difficulty;
 
 		HitStruct hitstruct, temphitstruct;
-		person[j].litup = person[j].recoil = 1;
+		person[j].litup = 1;
+		person[j].recoil = 1;
 
 		float olddistance = 0.0f, distance = 0.0f;
 		float totalarea = 0.0f;
@@ -2058,8 +2065,6 @@ void Game::Tick()
 		if (person[j].whichgun != grenade)
 			person[j].ammo--;
 
-		auto& joints = person[0].skeleton.joints;
-		auto& jointlabels = person[0].skeleton.jointlabels;
 		for (int p = 0; p < numshots; p++) {
 			XYZ aim;
 			if (j)
@@ -2490,8 +2495,10 @@ void Game::Tick()
 
 					if(person[whichhit].health>0){
 
-						if(person[whichhit].killtargetvisible==0&&person[whichhit].type!=zombietype&&person[whichhit].currentanimation!=getupfrontanim&person[whichhit].currentanimation!=getupbackanim){
-
+						if (person[whichhit].killtargetvisible == 0
+						    && person[whichhit].type != zombietype
+						    && person[whichhit].currentanimation !=getupfrontanim
+						    && person[whichhit].currentanimation != getupbackanim) {
 							if(hitstruct.joint1->modelnum==headmodel)person[whichhit].targetanimation=headpainanim;
 
 							if(hitstruct.joint1->modelnum==chestmodel)person[whichhit].targetanimation=chestpainanim;
@@ -2590,7 +2597,7 @@ void Game::Tick()
 
 					//blood
 
-					if(!hitstruct.joint1->modelnum==headmodel){
+					if (hitstruct.joint1->modelnum != headmodel) {
 
 					if(person[j].whichgun==sniperrifle)sprites.MakeSprite(bloodspritenoup, 1, 1, 0, 0, hitstruct.hitlocation, velocity*0, 5);
 
@@ -2739,15 +2746,11 @@ void Game::Tick()
 
 				dot_tb = (c->x - b->x)*(a->x - b->x) + (c->y - b->y)*(a->y - b->y) + (c->z - b->z)*(a->z - b->z);
 
-				if (!dot_ta <= 0&&!dot_tb <= 0){
-
-						nearest.x = a->x + ((b->x - a->x) * dot_ta)/(dot_ta + dot_tb);
-
-						nearest.y = a->y + ((b->y - a->y) * dot_ta)/(dot_ta +dot_tb);
-
-						nearest.z = a->z + ((b->z - a->z) * dot_ta)/(dot_ta +dot_tb);
-
-					}
+				if (dot_ta > 0 && dot_tb > 0) {
+					nearest.x = a->x + ((b->x - a->x) * dot_ta) / (dot_ta + dot_tb);
+					nearest.y = a->y + ((b->y - a->y) * dot_ta) / (dot_ta + dot_tb);
+					nearest.z = a->z + ((b->z - a->z) * dot_ta) / (dot_ta + dot_tb);
+				}
 
 				if (nearest.x
 				    && findDistancefast(nearest, camera.position) < 10
@@ -3056,7 +3059,7 @@ void Game::Tick()
 					if (sprites.type[i] == grenadesprite
 					    && sprites.size[i] <= 1) {
 						auto soundpos = sprites.location[i] - camera.position;
-						auto v = findLengthfast(sprites.velocity[i]) * 0.2;
+						auto v = findLengthfast(sprites.velocity[i]) * 0.2f;
 						ALfloat gLoc[] {
 							soundpos.x / v / soundscalefactor,
 							soundpos.y / v / soundscalefactor,
@@ -3100,7 +3103,7 @@ void Game::Tick()
 						}
 
 						auto soundpos = sprites.location[i] - camera.position;
-						auto v = findLengthfast(sprites.velocity[i]) * 0.2;
+						auto v = findLengthfast(sprites.velocity[i]) * 0.2f;
 						ALfloat gLoc[] {
 							soundpos.x / v / soundscalefactor,
 							soundpos.y / v / soundscalefactor,
@@ -3133,7 +3136,7 @@ void Game::Tick()
 
 								sprites.location[i] = hitstruct.hitlocation;
 								auto landpos = sprites.location[i] - camera.position;
-								auto v = findLengthfast(sprites.velocity[i]) * 0.2;
+								auto v = findLengthfast(sprites.velocity[i]) * 0.2f;
 								ALfloat gLoc[] {
 									landpos.x / v / soundscalefactor,
 									landpos.y / v / soundscalefactor,
@@ -3152,34 +3155,28 @@ void Game::Tick()
 
 									person[j].longdead=1;
 
-									for(int k=0;k<person[j].skeleton.num_joints;k++){
-
-										person[j].skeleton.joints[k].position=DoRotation(person[j].skeleton.joints[k].position,0,person[j].playerrotation,0);
-
-										person[j].skeleton.joints[k].position+=person[j].playercoords;
-
-										person[j].skeleton.joints[k].realoldposition=person[j].skeleton.joints[k].position;
+									for (int k = 0; k < person[j].skeleton.num_joints; ++k) {
+										person[j].skeleton.joints[k].realoldposition
+											= person[j].skeleton.joints[k].position
+											= DoRotation(person[j].skeleton.joints[k].position,
+												0, person[j].playerrotation, 0)
+											+ person[j].playercoords;
 
-										person[j].skeleton.joints[k].velocity=person[j].velocity;
-
-										person[j].skeleton.joints[k].velocity.x+=abs(Random()%10)-5;
-
-										person[j].skeleton.joints[k].velocity.y+=abs(Random()%10)-5;
-
-										person[j].skeleton.joints[k].velocity.z+=abs(Random()%10)-5;
+										person[j].skeleton.joints[k].velocity = person[j].velocity;
+										person[j].skeleton.joints[k].velocity.x += abs(Random()%10)-5;
+										person[j].skeleton.joints[k].velocity.y += abs(Random()%10)-5;
+										person[j].skeleton.joints[k].velocity.z += abs(Random()%10)-5;
 
 									}
 
-									hitstruct.joint1->velocity+=sprites.velocity[i];
-
-									hitstruct.joint2->velocity+=sprites.velocity[i];
-
-									if(person[j].type==civiliantype)civkills++;
-
-									if(person[j].type==eviltype)goodkills++;
-
-								}else{
+									hitstruct.joint1->velocity += sprites.velocity[i];
+									hitstruct.joint2->velocity += sprites.velocity[i];
 
+									if (person[j].type == civiliantype)
+										civkills++;
+									if (person[j].type == eviltype)
+										goodkills++;
+								} else {
 									float totalarea = 0.0f;
 
 									alSourcefv(gSourceID[bodywhacksound], AL_POSITION, gLoc);
@@ -3336,14 +3333,11 @@ void Game::Tick()
 						}
 
 						person[k].DoAnimations(k);
+						person[k].longdead = 1;
+						person[k].bleeddelay = 1;
 
-						person[k].longdead=1;
-
-						person[k].bleeddelay=1;
-
-						person[k].bjoint1=&person[k].skeleton.joints[person[k].skeleton.jointlabels[head]];
-
-						person[k].bjoint2=&person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]];
+						person[k].bjoint1 = &person[k].skeleton.joints[person[k].skeleton.jointlabels[head]];
+						person[k].bjoint2 = &person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]];
 
 						for(int j=0;j<person[k].skeleton.num_joints;j++){
 
diff --git a/src/Models.cpp b/src/Models.cpp
index 60330c2..cc69c44 100644
--- a/src/Models.cpp
+++ b/src/Models.cpp
@@ -65,21 +65,18 @@ void Model::UpdateVertexArray(){
 bool Model::load(Str255 Name)
 {
 	short				tfile;
-	long				err;
 	Files file;
 
 	tfile=file.OpenFile(Name);
 	SetFPos(tfile,fsFromStart,0);
 
-		// read model settings
+	// read model settings
+	ReadShort(tfile,1,&vertexNum);
+	ReadShort(tfile,1,&TriangleNum);
 
-	err=ReadShort(tfile,1,&vertexNum);
-	err=ReadShort(tfile,1,&TriangleNum);
-
-		// read the model data
-
-	err=ReadXYZ(tfile,vertexNum,vertex);
-	err=ReadTexturedTriangle(tfile,TriangleNum,Triangles);
+	// read the model data
+	ReadXYZ(tfile,vertexNum,vertex);
+	ReadTexturedTriangle(tfile,TriangleNum,Triangles);
 
 	FSClose(tfile);
 
diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp
index 8ac7c4f..363fbcc 100644
--- a/src/Skeleton.cpp
+++ b/src/Skeleton.cpp
@@ -386,7 +386,9 @@ void Skeleton::SetJoint(float x, float y, float z, int which, int whichjoint)
 
 void Skeleton::AddMuscle(int attach1,int attach2,float minlength,float maxlength,int type)
 {
-	if(num_muscles<max_muscles-1&&attach1<num_joints&&attach1>=0&attach2<num_joints&&attach2>=0&&attach1!=attach2){
+	if (num_muscles < max_muscles - 1 && attach1 != attach2
+	    && attach1 < num_joints && attach1 >= 0
+	    && attach2 < num_joints && attach2 >= 0) {
 		muscles[num_muscles].parent1=&joints[attach1];
 		muscles[num_muscles].parent2=&joints[attach2];
 		muscles[num_muscles].length=findDistance(muscles[num_muscles].parent1->position,muscles[num_muscles].parent2->position);
diff --git a/src/Sprites.cpp b/src/Sprites.cpp
index ef60a7d..d18d64a 100644
--- a/src/Sprites.cpp
+++ b/src/Sprites.cpp
@@ -322,5 +322,18 @@ void Sprites::draw()
 	glDisable(GL_TEXTURE_2D);
 	glEnable(GL_CULL_FACE);
 	//glDisable(GL_POLYGON_OFFSET_FILL);
-
 }
+
+Sprites::~Sprites()
+{
+	const GLuint textures[] {
+		muzzleflaretextureptr,
+		flaretextureptr,
+		bullettextureptr,
+		smoketextureptr,
+		bloodtextureptr,
+		raintextureptr,
+		snowtextureptr,
+	};
+	glDeleteTextures(7, textures);
+};
diff --git a/src/Sprites.h b/src/Sprites.h
index d487c7e..155258b 100644
--- a/src/Sprites.h
+++ b/src/Sprites.h
@@ -1,23 +1,43 @@
-#ifndef _SPRITE_H_
-#define _SPRITE_H_
+// Model structure
+// Copyright (C) 2002  David Rosen
+// Copyright (C) 2003  Steven Fuller
+// Copyright (C) 2003  Zachary Jack Slater
+// Copyright (C) 2021  Nguyễn Gia Phong
+//
+// This file is part of Black Shades.
+//
+// Black Shades is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Black Shades is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef BLACKSHADES_SPRITES_H
+#define BLACKSHADES_SPRITES_H
 
-#include "Quaternions.h"
 #include <GL/gl.h>
 #include <GL/glu.h>
+
 #include "Files.h"
 #include "Quaternions.h"
 #include "Camera.h"
 #include "Models.h"
 #include "Fog.h"
-//
-// Model Structures
-//
 
 #define maxsprites 2000
 
 #define muzzleflashsprite 1
 #define smokesprite 2
 #define smokespritenoup 3
+#define bullet 4
+#define bulletinstant 5
 #define flashsprite 6
 #define grenadesprite 7
 #define pinsprite 8
@@ -28,61 +48,53 @@
 #define snowsprite 13
 #define rainsprite 14
 
-#define bullet 4
-#define bulletinstant 5
-
 class Sprites{
-	public:
-				GLuint 				flaretextureptr;
-				GLuint 				muzzleflaretextureptr;
-				GLuint 				smoketextureptr;
-				GLuint 				bullettextureptr;
-				GLuint 				bloodtextureptr;
-				GLuint 				raintextureptr;
-				GLuint 				snowtextureptr;
-
-				int howmanysprites;
+public:
+	GLuint flaretextureptr;
+	GLuint muzzleflaretextureptr;
+	GLuint smoketextureptr;
+	GLuint bullettextureptr;
+	GLuint bloodtextureptr;
+	GLuint raintextureptr;
+	GLuint snowtextureptr;
 
-				XYZ location[maxsprites];
-				XYZ oldlocation[maxsprites];
-				XYZ velocity[maxsprites];
-				XYZ initialvelocity[maxsprites];
-				float size[maxsprites];
-				float initialsize[maxsprites];
-				float brightness[maxsprites];
-				float initialbrightness[maxsprites];
-				float color1[maxsprites];
-				float color2[maxsprites];
-				float color3[maxsprites];
-				float alivetime[maxsprites];
-				float rotation[maxsprites];
-				int type[maxsprites];
-				int owner[maxsprites];
+	int howmanysprites;
 
-				void draw();
+	XYZ location[maxsprites];
+	XYZ oldlocation[maxsprites];
+	XYZ velocity[maxsprites];
+	XYZ initialvelocity[maxsprites];
+	float size[maxsprites];
+	float initialsize[maxsprites];
+	float brightness[maxsprites];
+	float initialbrightness[maxsprites];
+	float color1[maxsprites];
+	float color2[maxsprites];
+	float color3[maxsprites];
+	float alivetime[maxsprites];
+	float rotation[maxsprites];
+	int type[maxsprites];
+	int owner[maxsprites];
 
-				int DeleteSprite(int which);
-				int MakeSprite(int atype, float abrightness, float acolor1, float acolor2, float acolor3, XYZ alocation, XYZ avelocity, float asize);
-				int MakeSprite(int atype, float abrightness, float acolor1, float acolor2, float acolor3, XYZ alocation, XYZ avelocity, float asize, int aowner);
+	void draw();
 
-				void DoStuff();
-				void LoadMuzzleFlareTexture(char *fileName);
-				void LoadFlareTexture(char *fileName);
-				void LoadSmokeTexture(char *fileName);
-				void LoadBulletTexture(char *fileName);
-				void LoadBloodTexture(char *fileName);
-				void LoadSnowTexture(char *fileName);
-				void LoadRainTexture(char *fileName);
+	int DeleteSprite(int which);
+	int MakeSprite(int atype, float abrightness,
+		float acolor1, float acolor2, float acolor3,
+		XYZ alocation, XYZ avelocity, float asize);
+	int MakeSprite(int atype, float abrightness,
+		float acolor1, float acolor2, float acolor3,
+		XYZ alocation, XYZ avelocity, float asize, int aowner);
 
-				~Sprites() {
-					glDeleteTextures( 1, (const GLuint *)muzzleflaretextureptr );
-					glDeleteTextures( 1, (const GLuint *)flaretextureptr );
-					glDeleteTextures( 1, (const GLuint *)bullettextureptr );
-					glDeleteTextures( 1, (const GLuint *)smoketextureptr );
-					glDeleteTextures( 1, (const GLuint *)bloodtextureptr );
-					glDeleteTextures( 1, (const GLuint *)raintextureptr );
-					glDeleteTextures( 1, (const GLuint *)snowtextureptr );
-				};
+	void DoStuff();
+	void LoadMuzzleFlareTexture(char *fileName);
+	void LoadFlareTexture(char *fileName);
+	void LoadSmokeTexture(char *fileName);
+	void LoadBulletTexture(char *fileName);
+	void LoadBloodTexture(char *fileName);
+	void LoadSnowTexture(char *fileName);
+	void LoadRainTexture(char *fileName);
+	~Sprites();
 };
 
-#endif
+#endif // BLACKSHADES_SPRITES_H
diff --git a/src/TGALoader.cpp b/src/TGALoader.cpp
index ea26920..8862573 100644
--- a/src/TGALoader.cpp
+++ b/src/TGALoader.cpp
@@ -66,8 +66,7 @@ TGAImageRec*	LoadTGA( char *filename )
 	}
 
 	// Loop Through The Image Data
-	for( GLuint i = 0; i < int( imageSize ); i += bytesPerPixel )
-	{
+	for (GLuint i = 0; i < imageSize; i += bytesPerPixel) {
 		// Swaps The 1st And 3rd Bytes ('R'ed and 'B'lue)
 		temp = texture->data[i];					// Temporarily Store The Value At Image Data 'i'
 		texture->data[i] = texture->data[i + 2];	// Set The 1st Byte To The Value Of The 3rd Byte
diff --git a/src/Text.cpp b/src/Text.cpp
index 99878d3..2329360 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -66,3 +66,8 @@ void Text::glPrint(GLint x, GLint y, char *string, int set, float size, float wi
 	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
 	glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
 }
+
+Text::~Text()
+{
+	glDeleteTextures(1, &FontTexture);
+}
diff --git a/src/Text.h b/src/Text.h
index 220bf9c..af25c2d 100644
--- a/src/Text.h
+++ b/src/Text.h
@@ -1,25 +1,42 @@
-#ifndef _TEXT_H_
-#define _TEXT_H_
+// Text object
+// Copyright (C) 2002  David Rosen
+// Copyright (C) 2003  Steven Fuller
+// Copyright (C) 2003  Zachary Jack Slater
+// Copyright (C) 2021  Nguyễn Gia Phong
+//
+// This file is part of Black Shades.
+//
+// Black Shades is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published
+// by the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Black Shades is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
+
+#ifndef BLACKSHADES_TEXT_H
+#define BLACKSHADES_TEXT_H
 
-/**> HEADER FILES <**/
-#include "Quaternions.h"
 #include <GL/gl.h>
 #include <GL/glu.h>
+
 #include "Files.h"
 #include "Quaternions.h"
 
 class Text{
-	public:
-		GLuint FontTexture;
-		GLuint base;
+public:
+	GLuint FontTexture;
+	GLuint base;
 
-		void LoadFontTexture(char *fileName);
-		void BuildFont();
-		void glPrint(GLint x, GLint y, char *string, int set, float size, float width, float height);
-
-		~Text(){
-			glDeleteTextures( 1, (const GLuint *)FontTexture );
-		}
+	void LoadFontTexture(char *fileName);
+	void BuildFont();
+	void glPrint(GLint x, GLint y, char *string, int set,
+		float size, float width, float height);
+	~Text();
 };
-
-#endif
+#endif // BLACKSHADES_TEXT_H