From f0336e14af04d93f5a72fb89a6adacef76eb9181 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Mon, 23 Sep 2013 20:28:12 +0100
Subject: [PATCH] [Change] Improved some of the shooting handling.

---
 src/board.c |  2 +-
 src/pilot.c | 49 +++++++++++++++++++++++++++++--------------------
 src/pilot.h |  2 +-
 3 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/board.c b/src/board.c
index 6bbe5e9..b5a448f 100644
--- a/src/board.c
+++ b/src/board.c
@@ -196,7 +196,7 @@ static int board_fail(void) {
 /**
  * @fn static void board_update(void)
  *
- * @brief Updates the boarding window fields.
+ * @brief Updates the boarding window.
  */
 static void board_update(void) {
   int i;
diff --git a/src/pilot.c b/src/pilot.c
index f69a018..484333f 100644
--- a/src/pilot.c
+++ b/src/pilot.c
@@ -163,7 +163,7 @@ Fleet* fleet_get(const char* name) {
 }
 
 /* Attempt to turn the pilot to face dir. */
-double pilot_face(Pilot* p, const float dir) {
+double pilot_face(Pilot* p, const double dir) {
   double diff, turn;
 
   diff = angle_diff(p->solid->dir, dir);
@@ -219,6 +219,14 @@ void pilot_shoot(Pilot* p, const unsigned int target, const int secondary) {
   }
 }
 
+/**
+ * @fn static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t)
+ *
+ * @brief Actually handles the shooting, how often the player can shoot and such.
+ *    @param p Pilot that is shooting.
+ *    @param w Pilot's outfit to shoot.
+ *    @param t Pilot's target.
+ */
 static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
   int quantity, delay;
   /* WElll... Trying to shoot when you have no ammo?? FUUU */
@@ -227,28 +235,29 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
 
   /* Check to see if weapon is ready. */
   if((SDL_GetTicks() - w->timer) < (unsigned int)(delay/quantity)) return;
-  /* Regular weapons. */
-  if(outfit_isWeapon(w->outfit) || (outfit_isTurret(w->outfit))) {
-    /* Different weapons. */
-    switch(w->outfit->type) {
-    case OUTFIT_TYPE_TURRET_BOLT:
-    case OUTFIT_TYPE_BOLT:
-      /* Enough energy? */
-      if(outfit_energy(w->outfit) > p->energy) return;
+  /* Regular bolt weapons. */
+  if(outfit_isBolt(w->outfit)) {
+    /* Enough energy? */
+    if(outfit_energy(w->outfit) > p->energy) return;
 
-      p->energy -= outfit_energy(w->outfit);
-      weapon_add(w->outfit, p->solid->dir, &p->solid->pos,
-                 &p->solid->vel, p->id, t);
+    p->energy -= outfit_energy(w->outfit);
+    weapon_add(w->outfit, p->solid->dir,
+        &p->solid->pos, &p->solid->vel, p->id, t);
 
-      /* Can't shoot for a while. */
-      w->timer = SDL_GetTicks();
-      break;
-    default:
-      break;
-    }
+    /* Can't shoot it for a bit. */
+    w->timer = SDL_GetTicks();
   }
-  /* Missile launchers. */
-  /* Must be secondary weapon. */
+
+  /* Beam Weapons. */
+  else if(outfit_isBeam(w->outfit)) {
+
+  }
+
+  /*
+   * Missile Launchers.
+   *
+   * Must be a secondary weapon.
+   */
   else if(outfit_isLauncher(w->outfit) && (w == p->secondary)) {
     /* Shooter can't be the target - Sanity check for the player. */
     if((w->outfit->type != OUTFIT_TYPE_MISSILE_DUMB) && (p->id == t))
diff --git a/src/pilot.h b/src/pilot.h
index abaef21..8e70382 100644
--- a/src/pilot.h
+++ b/src/pilot.h
@@ -204,7 +204,7 @@ void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
 void pilot_setSecondary(Pilot* p, const char* secondary);
 void pilot_setAmmo(Pilot* p);
 void pilot_setAfterburner(Pilot* p);
-double pilot_face(Pilot* p, const float dir);
+double pilot_face(Pilot* p, const double dir);
 /* Outfits. */
 int pilot_freeSpace(Pilot* p); /* Pilot space. */
 int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);