]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Removed unused local vars
[lugaru.git] / Source / GameTick.cpp
index 4235adc5630cc425e42c0808c41c33bb36fac4f2..c994c0f196496894fbeeb95da157e904f333456d 100644 (file)
@@ -2055,7 +2055,7 @@ void doDebugKeys()
         }
 
         if (Input::isKeyPressed(SDL_SCANCODE_C)) {
-            cameramode = 1 - cameramode;
+            cameramode = !cameramode;
         }
 
         if (Input::isKeyPressed(SDL_SCANCODE_X) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
@@ -2386,7 +2386,7 @@ void doDebugKeys()
         }
 
         if (Input::isKeyPressed(SDL_SCANCODE_M) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
-            editorenabled = 1 - editorenabled;
+            editorenabled = !editorenabled;
             if (editorenabled) {
                 Person::players[0]->damagetolerance = 100000;
             } else {
@@ -3197,7 +3197,6 @@ void doAerialAcrobatics()
 
 void doAttacks()
 {
-    static XYZ relative;
     static int randattack;
     static bool playerrealattackkeydown = 0;
 
@@ -5525,7 +5524,7 @@ void MenuTick()
         displayblinkdelay -= multiplier;
         if (displayblinkdelay <= 0) {
             displayblinkdelay = .3;
-            displayblink = 1 - displayblink;
+            displayblink = !displayblink;
         }
     }
 
@@ -5684,7 +5683,7 @@ void Game::Tick()
 
         //keys
         if (Input::isKeyPressed(SDL_SCANCODE_V) && debugmode) {
-            freeze = 1 - freeze;
+            freeze = !freeze;
             if (freeze) {
                 OPENAL_SetFrequency(OPENAL_ALL, 0.001);
             }
@@ -5718,7 +5717,7 @@ void Game::Tick()
             consoleblinkdelay -= multiplier;
             if (consoleblinkdelay <= 0) {
                 consoleblinkdelay = .3;
-                consoleblink = 1 - consoleblink;
+                consoleblink = !consoleblink;
             }
         }
 
@@ -6370,12 +6369,7 @@ void Game::Tick()
                                                             if (weapons[j].getType() != staff)
                                                                 emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
 
-                                                            Person::players[i]->weaponactive = 0;
-                                                            weapons[j].owner = Person::players[i]->id;
-                                                            if (Person::players[i]->num_weapons > 0)
-                                                                Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
-                                                            Person::players[i]->num_weapons++;
-                                                            Person::players[i]->weaponids[0] = j;
+                                                            Person::players[i]->takeWeapon(j);
                                                         }
                                             }
                                         } else if ((Person::players[i]->isIdle() ||
@@ -6404,12 +6398,7 @@ void Game::Tick()
                                                                 if (weapons[k].getType() != staff)
                                                                     emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
 
-                                                                Person::players[i]->weaponactive = 0;
-                                                                weapons[k].owner = Person::players[i]->id;
-                                                                if (Person::players[i]->num_weapons > 0)
-                                                                    Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
-                                                                Person::players[i]->num_weapons++;
-                                                                Person::players[i]->weaponids[0] = k;
+                                                                Person::players[i]->takeWeapon(k);
                                                             }
                                                 }
                                             }
@@ -6461,7 +6450,6 @@ void Game::Tick()
                                                             if (fleshstuck)
                                                                 emit_sound_at(fleshstabremovesound, Person::players[i]->coords, 128.);
 
-                                                            Person::players[i]->weaponactive = 0;
                                                             if (weapons[k].owner != -1) {
                                                                 if (Person::players[i]->victim->num_weapons == 1)
                                                                     Person::players[i]->victim->num_weapons = 0;
@@ -6509,12 +6497,7 @@ void Game::Tick()
                                                                 Person::players[i]->victim->jointVel(rightshoulder) += relative * 6;
                                                                 Person::players[i]->victim->jointVel(leftshoulder) += relative * 6;
                                                             }
-                                                            weapons[k].owner = i;
-                                                            if (Person::players[i]->num_weapons > 0) {
-                                                                Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
-                                                            }
-                                                            Person::players[i]->num_weapons++;
-                                                            Person::players[i]->weaponids[0] = k;
+                                                            Person::players[i]->takeWeapon(k);
                                                         }
                                                     }
                                                 }
@@ -6550,18 +6533,12 @@ void Game::Tick()
                                                                     Person::players[i]->throwtogglekeydown = 1;
                                                                     Person::players[i]->victim = Person::players[j];
                                                                     XYZ aim;
-                                                                    weapons[Person::players[i]->weaponids[0]].owner = -1;
                                                                     aim = Person::players[i]->victim->coords + DoRotation(Person::players[i]->victim->jointPos(abdomen), 0, Person::players[i]->victim->yaw, 0) * Person::players[i]->victim->scale + Person::players[i]->victim->velocity * findDistance(&Person::players[i]->victim->coords, &Person::players[i]->coords) / 50 - (Person::players[i]->coords + DoRotation(Person::players[i]->jointPos(righthand), 0, Person::players[i]->yaw, 0) * Person::players[i]->scale);
                                                                     Normalise(&aim);
 
                                                                     aim = DoRotation(aim, (float)abs(Random() % 30) - 15, (float)abs(Random() % 30) - 15, 0);
 
-                                                                    weapons[Person::players[i]->weaponids[0]].velocity = aim * 50;
-                                                                    weapons[Person::players[i]->weaponids[0]].tipvelocity = aim * 50;
-                                                                    weapons[Person::players[i]->weaponids[0]].missed = 0;
-                                                                    weapons[Person::players[i]->weaponids[0]].freetime = 0;
-                                                                    weapons[Person::players[i]->weaponids[0]].firstfree = 1;
-                                                                    weapons[Person::players[i]->weaponids[0]].physics = 0;
+                                                                    weapons[Person::players[i]->weaponids[0]].thrown(aim * 50, false);
                                                                     Person::players[i]->num_weapons--;
                                                                     if (Person::players[i]->num_weapons) {
                                                                         Person::players[i]->weaponids[0] = Person::players[i]->weaponids[Person::players[i]->num_weapons];