From 9842b9043399f44a19c58d15e297d2a9dfadd272 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20BERNIGAUD?= Date: Mon, 16 May 2011 03:49:03 +0200 Subject: [PATCH] bugfix about weapons --- Source/Weapons.cpp | 67 ++++++++++++++++++++++++---------------------- Source/Weapons.h | 2 +- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index a771989..2f87d33 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -97,8 +97,8 @@ void Weapon::setType(int t) { } } -void Weapon::DoStuff() { - static int i,whichpatchx,whichpatchz,j,k,whichhit,m; +void Weapon::DoStuff(int i) { + static int whichpatchx,whichpatchz,whichhit,m; static XYZ start,end,colpoint,normalrot,footvel,footpoint; static XYZ terrainnormal; static XYZ vel; @@ -119,17 +119,13 @@ void Weapon::DoStuff() { if(owner!=-1){ oldowner=owner; } - if(damage>=2&&type==staff&&owner!=-1){ + if(damage>=2 && type==staff && owner!=-1){ emit_sound_at(staffbreaksound, tippoint); XYZ tempvel; - XYZ speed; - //speed=(tippoint-oldtippoint)/multiplier/6; - speed=0; - for(j=0;j<40;j++){ + for(int j=0;j<40;j++){ tempvel.x=float(abs(Random()%100)-50)/20; tempvel.y=float(abs(Random()%100)-50)/20; tempvel.z=float(abs(Random()%100)-50)/20; - tempvel+=speed; Sprite::MakeSprite(splintersprite, position+(tippoint-position)*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1); } int tempowner; @@ -141,11 +137,12 @@ void Weapon::DoStuff() { firstfree=1; position=0; physics=0; - if(tempowner!=-1){ + if(tempowner!=-1) { player[tempowner].num_weapons--; - if(player[tempowner].num_weapons){ + if(player[tempowner].num_weapons) { player[tempowner].weaponids[0]=player[tempowner].weaponids[player[tempowner].num_weapons]; - if(player[tempowner].weaponstuck==player[tempowner].num_weapons)player[tempowner].weaponstuck=0; + if(player[tempowner].weaponstuck==player[tempowner].num_weapons) + player[tempowner].weaponstuck=0; } player[tempowner].weaponactive=-1; } @@ -157,10 +154,10 @@ void Weapon::DoStuff() { tippoint+=velocity*multiplier; whichpatchx=position.x/(terrain.size/subdivision*terrain.scale); whichpatchz=position.z/(terrain.size/subdivision*terrain.scale); - if(whichpatchx>0&&whichpatchz>0&&whichpatchx0 && whichpatchz>0 && whichpatchxtemppoint2.x)rotation1=360-rotation1; + if(temppoint1.x>temppoint2.x) rotation1=360-rotation1; } } //Sword physics @@ -369,8 +371,8 @@ void Weapon::DoStuff() { tempmult=multiplier; multiplier/=10; - for(int l=0;l<10;l++){ - if(owner==-1&&(velocity.x||velocity.y||velocity.z)&&physics){ + for(int l=0;l<10;l++) { + if(owner==-1&&(velocity.x||velocity.y||velocity.z)&&physics) { //move position+=velocity*multiplier; tippoint+=tipvelocity*multiplier; @@ -394,8 +396,8 @@ void Weapon::DoStuff() { whichpatchz=(position.z)/(terrain.size/subdivision*terrain.scale); if(whichpatchx>0&&whichpatchz>0&&whichpatchx::iterator weapon = begin(); weapon != end(); ++weapon) { - weapon->DoStuff(); + weapon->DoStuff(i++); } } diff --git a/Source/Weapons.h b/Source/Weapons.h index 35271f7..bb178c1 100644 --- a/Source/Weapons.h +++ b/Source/Weapons.h @@ -58,7 +58,7 @@ class Weapon { static GLuint stafftextureptr; void Draw(); - void DoStuff(); + void DoStuff(int); int getType() { return type; } void setType(int); -- 2.39.2