aboutsummaryrefslogtreecommitdiff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-22 14:58:38 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-22 14:58:38 +0700
commitf673971c50ca968d3ddb16b780a389f5627418e2 (patch)
tree81bdbc0cd9ae7ae232b0a0f1c9842927cb82e68f /src/GameTick.cpp
parent1fda9269f0c2d505368abf3ab9ca5ef88886b7e9 (diff)
downloadblackshades-f673971c50ca968d3ddb16b780a389f5627418e2.tar.gz
Fix possible division by zero and clean up
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp109
1 files changed, 0 insertions, 109 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 045f903..3350634 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -1,51 +1,28 @@
#include "Game.h"
extern double multiplier;
-
extern int thirdperson;
-
extern int visions;
-
extern Sprites sprites;
-
extern unsigned int gSourceID[100];
-
extern unsigned int gSampleSet[100];
-
extern Camera camera;
-
extern float camerashake;
-
extern Fog fog;
-
extern int environment;
-
extern float precipitationhorz;
-
extern float precipitationvert;
-
extern float snowdelay;
-
extern float precipitationdensity;
-
extern float soundscalefactor;
-
extern int slomo;
-
extern int forwardskey;
-
extern int backwardskey;
-
extern int leftkey;
-
extern int rightkey;
-
extern int aimkey;
-
extern int psychicaimkey;
-
extern int psychickey;
-
extern Decals decals;
/********************> Tick() <*****/
@@ -54,58 +31,35 @@ extern Decals decals;
void Game::Splat(int k){
if(k!=0||visions==0){
-
person[k].health=0;
-
person[k].DoAnimations(k);
-
person[k].skeleton.offset=0;
-
person[k].skeleton.free=1;
-
person[k].longdead=1;
-
person[k].bleeding=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]];
for(int j=0;j<person[k].skeleton.num_joints;j++){
-
person[k].skeleton.joints[j].position+=person[k].skeleton.joints[j].offset;
-
person[k].skeleton.joints[j].position=DoRotation(person[k].skeleton.joints[j].position,0,person[k].playerrotation,0);
-
person[k].skeleton.joints[j].position+=person[k].playercoords;
-
person[k].skeleton.joints[j].realoldposition=person[k].skeleton.joints[j].position;
-
person[k].skeleton.joints[j].velocity=0;
-
person[k].skeleton.joints[j].velocity.y+=person[k].velocity.y;
}
float gLoc[3];
-
gLoc[0]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.x/soundscalefactor;
-
gLoc[1]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.y/soundscalefactor;
-
gLoc[2]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.z/soundscalefactor;
-
alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc);
-
alSourcePlay(gSourceID[headwhacksound]);
-
}
-
}
void Game::Tick(){
-
if(mainmenu){
unsigned char theKeyMap[16];
@@ -4401,13 +4355,10 @@ void Game::Tick(){
}
//camera shake
-
camerashake-=multiplier;
-
if(camerashake<0)camerashake=0;
//camera position
-
XYZ average;
if(!zoom)average=person[0].skeleton.joints[(person[0].skeleton.jointlabels[head])].position*(person[0].aimamount/2+.5)+person[0].skeleton.joints[(person[0].skeleton.jointlabels[neck])].position*((1-person[0].aimamount)/2);
@@ -4423,145 +4374,85 @@ void Game::Tick(){
if(camera.position.y<.1)camera.position.y=.1;
if(thirdperson!=2){
-
oldrot=camera.visrotation;
-
oldrot2=camera.visrotation2;
-
}
//Kill count
-
for(int i=0;i<numpeople;i++){
-
if(person[i].oldhealth>0&&person[i].health<=0){
-
if(i==1)alSourcePlay(gSourceID[losesound]);
-
if(person[i].type==civiliantype){
-
alSourcePlay(gSourceID[disguisekillsound]);
-
score-=300;
-
}
if(person[i].type==eviltype){
-
alSourcePlay(gSourceID[soulinsound]);
-
score+=75;
-
if(person[i].whichgun==knife)score+=50;
-
}
-
person[i].firstlongdead=0;
-
}
-
person[i].oldhealth=person[i].health;
-
}
if(slomo==2){
-
psychicpower-=multiplier*15;
-
if(psychicpower<0){
-
soundscalefactor=soundscalefactordefault;
-
alSourceStop(gSourceID[whichsong]);
-
alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 0);
-
alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 0);
-
if(person[0].whichgun==knife)whichsong=knifesong;
-
if(person[0].whichgun!=knife)whichsong=shootsong;
-
if(type==zombie_type)whichsong=zombiesong;
-
alSourcef(gSourceID[whichsong], AL_PITCH, 1);
-
alSourcePlay(gSourceID[whichsong]);
-
alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 1);
-
alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 1);
-
slomo=0;
-
alSourcePlay(gSourceID[soulinsound]);
-
psychicpower=0;
-
flashamount=.5;
-
flashr=1;flashg=1;flashb=1;
-
}
-
}
psychicpower+=multiplier*5;
-
if(psychicpower>10)psychicpower=10;
//3d sound
float gLoc[3];
-
gLoc[0]=camera.position.x/soundscalefactor;
-
gLoc[1]=camera.position.y/soundscalefactor;
-
gLoc[2]=camera.position.z/soundscalefactor;
//Set listener position
-
alListenerfv(AL_POSITION, gLoc);
//Set orientation with forward and up vectors
-
XYZ upvector;
-
upvector=0;
-
upvector.z=-1;
-
upvector=DoRotation(upvector,-camera.rotation2+90,0,0);
-
upvector=DoRotation(upvector,0,0-camera.rotation,0);
float ori[6];
-
ori[0] = -facing.x;
-
ori[1] = facing.y;
-
ori[2] = facing.z;
-
ori[3] = -upvector.x;
-
ori[4] = upvector.y;
-
ori[5] = upvector.z;
-
alListenerfv(AL_ORIENTATION, ori);
if(person[0].currentanimation==throwanim||person[0].currentanimation==diveanim||paused){
-
MoveMouse(oldmouseloc.h,oldmouseloc.v,&mouseloc);
-
GetMouse(&mouseloc);
-
}
oldmouseloc=mouseloc;
-
if(score<0)score=0;
-
}
}