summary refs log tree commit diff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 1193c3c..fc5305b 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -186,7 +186,7 @@ void click(Game* game, int button, int action, int mods)
 
 	XYZ flatfacing = facing;
 	flatfacing.y = 0;
-	Normalise(&flatfacing);
+	flatfacing = normalize(flatfacing);
 
 	// Gun whacking or knife slashing
 	if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS
@@ -932,7 +932,7 @@ void renderLaser(Game* game)
 		return;
 	}
 
-	Normalise(&aim);
+	aim = normalize(aim);
 	auto& coords = player.playercoords;
 	auto start = coords
 		+ DoRotation(joints[lefthand].position, 0.0f, rotation, 0.0f)
@@ -1015,7 +1015,7 @@ void Game::Tick()
 
 	XYZ flatfacing = facing;
 	flatfacing.y = 0;
-	Normalise(&flatfacing);
+	flatfacing = normalize(flatfacing);
 
 	// Check collision with buildings
 	int beginx,endx;
@@ -1449,8 +1449,7 @@ void Game::Tick()
 					}
 
 					if(person[i].targetanimation!=zombieeatanim||person[i].type!=zombietype){
-						towards=person[i].playercoords-person[i].pathtarget;
-						Normalise(&towards);
+						towards = normalize(person[i].playercoords - person[i].pathtarget);
 						person[i].playerrotation=asin(0-towards.x)*360/6.28;
 						if(towards.z>0)person[i].playerrotation=180-person[i].playerrotation;
 					}
@@ -1527,8 +1526,8 @@ void Game::Tick()
 					person[i].playercoords.y = joint.position.y;
 
 			//Find orientation
-			XYZ firsttop=person[i].skeleton.joints[neck].position-person[i].skeleton.joints[groin].position;
-			Normalise(&firsttop);
+			XYZ firsttop = normalize(person[i].skeleton.joints[neck].position
+				- person[i].skeleton.joints[groin].position);
 			person[i].playerrotation=acos(0-firsttop.z);
 			person[i].playerrotation*=360/6.28;
 			if(0>firsttop.x)person[i].playerrotation=360-person[i].playerrotation;
@@ -1626,7 +1625,7 @@ void Game::Tick()
 				aim = aimPlayer(this);
 			else
 				aim = facing;
-			Normalise(&aim);
+			aim = normalize(aim);
 
 			int aimjoint;
 			switch (person[j].whichgun) {
@@ -2000,10 +1999,8 @@ void Game::Tick()
 								joint.offset += DoRotation(aim * 200 / distance / totalarea * 10,
 									0, -person[whichhit].playerrotation, 0);
 							}
-							if (findLengthfast(joint.offset) > 36) {
-								Normalise(&joint.offset);
-								joint.offset *= 6;
-							}
+							if (findLengthfast(joint.offset) > 36)
+								joint.offset = normalize(joint.offset) * 6;
 						}
 					}
 
@@ -2232,7 +2229,7 @@ void Game::Tick()
 				if (sprites.size[i] > 1)
 					decals.MakeDecal(crater, wallhit, 9, normalrotated, whichtri, &blocks[citytype[wherex][wherey]], move, cityrotation[wherex][wherey] * 90);
 				sprites.location[i] = wallhit + normalrotated * 0.02f;
-				ReflectVector(&sprites.velocity[i], &normalrotated);
+				reflect(&sprites.velocity[i], normalrotated);
 				sprites.velocity[i] *= 0.3f;
 
 				if (sprites.type[i] == grenadesprite && sprites.size[i] <= 1) {
@@ -2341,8 +2338,7 @@ void Game::Tick()
 								joint.offset += DoRotation(sprites.velocity[i] * 0.1 * 200 / distance / totalarea * 10, 0, -person[j].playerrotation, 0);
 							}
 							if (findLengthfast(joint.offset) > 9) {
-								Normalise(&joint.offset);
-								joint.offset *= 3;
+								joint.offset = normalize(joint.offset) * 3;
 							}
 						}
 					}
@@ -2432,8 +2428,7 @@ void Game::Tick()
 
 				person[k].longdead=1;
 				for (auto& joint : person[k].skeleton.joints) {
-					relation = joint.position - sprites.location[i];
-					Normalise(&relation);
+					relation = normalize(joint.position - sprites.location[i]);
 					auto distance = findDistance(joint.position, sprites.location[i]);
 					if (distance > 1)
 						joint.velocity += relation / distance * 300;