summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--build.zig2
-rw-r--r--src/Decals.cpp2
-rw-r--r--src/GameDraw.cpp10
-rw-r--r--src/GameTick.cpp7
-rw-r--r--src/Person.cpp3
-rw-r--r--src/Quaternions.h1
6 files changed, 13 insertions, 12 deletions
diff --git a/build.zig b/build.zig
index 9f69257..989d620 100644
--- a/build.zig
+++ b/build.zig
@@ -46,7 +46,7 @@ pub fn build(b: *Build) void {
         "src/Quaternions.cpp",
         "src/Skeleton.cpp",
         "src/Sprites.cpp",
-    }, &.{ "--std=c++17", "-fno-sanitize=undefined" });
+    }, &.{ "--std=c++17", "-Wall", "-Werror", "-fno-sanitize=undefined" });
 
     for ([_]struct { []const u8, []const u8 }{
         .{ "gfz", "lib/gfz/src/gfz.zig" },
diff --git a/src/Decals.cpp b/src/Decals.cpp
index 1fb3063..eb2a90b 100644
--- a/src/Decals.cpp
+++ b/src/Decals.cpp
@@ -44,7 +44,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly,
 	if(normalv[2]>normalv[major])major=2;
 
 	if (normalv[0] == 1 || normalv[1] == 1 || normalv[2] == 1) {
-		if (major == 0 && normal.x > 0 || major == 1)
+		if ((major == 0 && normal.x > 0) || major == 1)
 			right = {0.0f, 0.0f, -1.0f};
 		else if (major == 0)
 			right = {0.0f, 0.0f, 1.0f};
diff --git a/src/GameDraw.cpp b/src/GameDraw.cpp
index 12ac309..911e9ea 100644
--- a/src/GameDraw.cpp
+++ b/src/GameDraw.cpp
@@ -19,7 +19,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
 
-#include <stdio.h>
+#include <string>
 
 #include <GL/glu.h>
 
@@ -927,7 +927,7 @@ void Game::DrawGLScene(void)
 		static char str[256] = "";
 
 		if (!debug) {
-			char *s;
+			std::string s;
 			switch (person[0].whichgun) {
 			case nogun:
 				s = "UNARMED";
@@ -954,7 +954,7 @@ void Game::DrawGLScene(void)
 				s = "HANDGUN";
 				break;
 			}
-			glPrint(&this->text, 10, 90, s, 1, 0.8, 640, 480);
+			glPrint(&this->text, 10, 90, s.c_str(), 1, 0.8, 640, 480);
 			if(person[0].whichgun!=nogun&&person[0].whichgun!=knife&&person[0].whichgun!=grenade){
 				glColor4f(0,1,0,1);
 				glPrint(&this->text, 10, 30, "Magazines",
@@ -991,7 +991,7 @@ void Game::DrawGLScene(void)
 		} else {
 			sprintf(str, "FPS: %.0f", 1.0f / multiplier);
 			glPrint(&this->text, 10,30,str,0,.8,screenwidth,screenheight);
-			char *s;
+			std::string s;
 			switch (enemystate) {
 			case 0:
 				s = "Enemies are in random assassination mode.";
@@ -1003,7 +1003,7 @@ void Game::DrawGLScene(void)
 				s = "Enemies are in DIE!!!! mode.";
 				break;
 			}
-			glPrint(&this->text, 10, 20, s, 0, 0.8,
+			glPrint(&this->text, 10, 20, s.c_str(), 0, 0.8,
 				screenwidth, screenheight);
 			sprintf(str, "You have pointlessly shot or beaten %d unarmed civilians.", civkills);
 			glPrint(&this->text, 10,60,str,0,.8,screenwidth,screenheight);
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index bdba3b6..634db76 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -1154,7 +1154,7 @@ void Game::Tick()
 										    && j != 1 && blocksimple.LineCheck2(person[i].playercoords, person[i].pathtarget, &blah, move, cityrotation[person[i].whichblockx][person[i].whichblocky]) == -1
 										    && blocksimple.LineCheck2(person[i].playercoords, person[i].pathtarget, &blah, move, cityrotation[l][m]) == -1) {
 											person[i].lastdistancevictim = sqrlen(person[i].pathtarget - person[person[i].killtarget].playercoords);
-											leastdistance - sqrlen(person[i].playercoords - person[i].pathtarget);
+											leastdistance = sqrlen(person[i].playercoords - person[i].pathtarget);
 											closesttarget=j;
 											finaltarget=person[i].pathtarget;
 											person[i].whichblockx=l;
@@ -2291,7 +2291,8 @@ void Game::Tick()
 			if (sprites.type[i] == grenadesprite
 			    && sqrlen(sprites.velocity[i]) > 20) {
 				for (int j = 0; j < numpeople; ++j) {
-					if (j == 0 && sprites.brightness[i] > 0.9f || !person[j].existing)
+					if ((j == 0 && sprites.brightness[i] > 0.9f)
+					    || !person[j].existing)
 						continue;
 					auto hitstruct = person[j].BulletCollideWithPlayer(j, sprites.oldlocation[i], sprites.location[i]);
 					if (!hitstruct.collision)
@@ -2359,7 +2360,7 @@ void Game::Tick()
 
 		// Explode
 		if (sprites.type[i] == grenadesprite
-		    && (sprites.brightness[i] <= 0 || impact && sprites.size[i] > 1)) {
+		    && (sprites.brightness[i] <= 0 || (impact && sprites.size[i] > 1))) {
 			sprites.brightness[i] = 0;
 			sprites.MakeSprite(smokesprite, 1, 1, 1, 1, sprites.location[i], facing*0, 60);
 			sprites.MakeSprite(muzzleflashsprite, 1, 1, 1, 1, sprites.location[i], facing*0, 9);
diff --git a/src/Person.cpp b/src/Person.cpp
index c5ce963..d4a298b 100644
--- a/src/Person.cpp
+++ b/src/Person.cpp
@@ -650,7 +650,8 @@ void Person::control()
 
 void Person::DoStuff(int who)
 {
-	if (targetanimation != idleanim && targetanimation != crouchanim || visions)
+	if ((targetanimation != idleanim && targetanimation != crouchanim)
+	    || visions)
 		playerlowrotation = playerrotation;
 	if (targetanimation != crouchanim && currentanimation != crouchanim) {
 		if (playerrotation > playerlowrotation + 50) {
diff --git a/src/Quaternions.h b/src/Quaternions.h
index 9380905..6ed778a 100644
--- a/src/Quaternions.h
+++ b/src/Quaternions.h
@@ -41,7 +41,6 @@ constexpr XYZ& operator/=(XYZ& u, float k) { return u = u / k; }
 #ifdef __cplusplus
 extern "C" {
 #endif // __cplusplus
-	float dotProduct(struct XYZ, struct XYZ);
 	float sqrlen(struct XYZ);
 	float len(struct XYZ);
 	struct XYZ crossProduct(struct XYZ, struct XYZ);