The huge advantage is that you can now change and add weapons much easier:
You don't have to think of "How will the weapon behave for the other wormux 
instance" anymore, as the other wormux instance will call the same methods to 
use the weapon.
---
 lib/wormux/include/WORMUX_action.h |    6 +--
 src/ai/ai_shoot_module.cpp         |    3 +-
 src/include/action_handler.cpp     |   71 ++++-----------------------
 src/weapon/airhammer.cpp           |   17 ++++++-
 src/weapon/airhammer.h             |    7 +--
 src/weapon/blowtorch.cpp           |   24 ++++-----
 src/weapon/blowtorch.h             |   10 +---
 src/weapon/bounce_ball.cpp         |    2 +-
 src/weapon/cluster_bomb.cpp        |    2 +-
 src/weapon/disco_grenade.cpp       |    2 +-
 src/weapon/flamethrower.cpp        |   24 ++++++++-
 src/weapon/flamethrower.h          |    8 ++-
 src/weapon/footbomb.cpp            |    2 +-
 src/weapon/gnu.cpp                 |   51 ++++++--------------
 src/weapon/gnu.h                   |   10 +---
 src/weapon/grapple.cpp             |   16 ++++--
 src/weapon/grapple.h               |    7 +--
 src/weapon/grenade.cpp             |    2 +-
 src/weapon/jetpack.cpp             |    8 ++--
 src/weapon/jetpack.h               |    2 +-
 src/weapon/lowgrav.cpp             |   11 ++--
 src/weapon/lowgrav.h               |    3 +-
 src/weapon/parachute.cpp           |    4 +-
 src/weapon/parachute.h             |    2 +-
 src/weapon/polecat.cpp             |   46 +++++-------------
 src/weapon/polecat.h               |   11 +---
 src/weapon/submachine_gun.cpp      |    3 +-
 src/weapon/supertux.cpp            |   48 ++----------------
 src/weapon/supertux.h              |    6 +--
 src/weapon/weapon.cpp              |   93 +++++++++++++----------------------
 src/weapon/weapon.h                |   15 +++---
 src/weapon/weapon_launcher.cpp     |    9 +++-
 src/weapon/weapon_launcher.h       |    2 +-
 33 files changed, 197 insertions(+), 330 deletions(-)

diff --git a/lib/wormux/include/WORMUX_action.h 
b/lib/wormux/include/WORMUX_action.h
index 489154a..b443741 100644
--- a/lib/wormux/include/WORMUX_action.h
+++ b/lib/wormux/include/WORMUX_action.h
@@ -92,10 +92,11 @@ public:
 
     // ########################################################
     // Using Weapon
-    ACTION_WEAPON_SHOOT,
     ACTION_WEAPON_STOP_USE,
 
     // Quite standard weapon options
+    ACTION_WEAPON_START_SHOOTING,
+    ACTION_WEAPON_STOP_SHOOTING,
     ACTION_WEAPON_SET_TIMEOUT,
     ACTION_WEAPON_SET_TARGET,
     ACTION_WEAPON_START_MOVING_LEFT,
@@ -110,9 +111,6 @@ public:
 
     // Special weapon options
     ACTION_WEAPON_CONSTRUCTION,
-    ACTION_WEAPON_GNU,
-    ACTION_WEAPON_POLECAT,
-    ACTION_WEAPON_SUPERTUX,
 
     // Bonus Box
     ACTION_DROP_BONUS_BOX,
diff --git a/src/ai/ai_shoot_module.cpp b/src/ai/ai_shoot_module.cpp
index c14fe58..04019a9 100644
--- a/src/ai/ai_shoot_module.cpp
+++ b/src/ai/ai_shoot_module.cpp
@@ -341,7 +341,8 @@ void AIShootModule::Shoot()
 {
   if (m_current_time > m_last_shoot_time + 2 ||
       m_last_shoot_time == 0) {
-    ActiveTeam().GetWeapon().NewActionWeaponShoot();
+    //TODO find better replacement for:
+    ActiveTeam().AccessWeapon().PrepareShoot(0, 
ActiveCharacter().GetAbsFiringAngle());
     m_last_shoot_time = m_current_time;
   }
 
diff --git a/src/include/action_handler.cpp b/src/include/action_handler.cpp
index 337bee5..9ed80fe 100644
--- a/src/include/action_handler.cpp
+++ b/src/include/action_handler.cpp
@@ -56,8 +56,6 @@
 #include "weapon/explosion.h"
 #include "weapon/gnu.h"
 #include "weapon/grapple.h"
-#include "weapon/polecat.h"
-#include "weapon/supertux.h"
 #include "weapon/weapon.h"
 #include "weapon/weapon_launcher.h"
 #include "weapon/weapons_list.h"
@@ -613,19 +611,19 @@ static void 
Action_Character_StopDecreasingFireAngle(Action *a)
   ActiveCharacter().StopDecreasingFireAngle(slowly);
 }
 
-static void Action_Weapon_Shoot (Action *a)
+static void Action_Weapon_StopUse(Action */*a*/)
 {
-  if (Game::GetInstance()->ReadState() != Game::PLAYING)
-    return; // hack related to bug 8656
+  ActiveTeam().AccessWeapon().ActionStopUse();
+}
 
-  double strength = a->PopDouble();
-  double angle = a->PopDouble();
-  ActiveTeam().AccessWeapon().PrepareShoot(strength, angle);
+static void Action_Weapon_StartShooting(Action */*a*/)
+{
+  ActiveTeam().AccessWeapon().StartShooting();
 }
 
-static void Action_Weapon_StopUse(Action */*a*/)
+static void Action_Weapon_StopShooting(Action */*a*/)
 {
-  ActiveTeam().AccessWeapon().ActionStopUse();
+  ActiveTeam().AccessWeapon().StopShooting();
 }
 
 static void Action_Weapon_SetTarget (Action *a)
@@ -696,52 +694,6 @@ static void Action_Weapon_Construction (Action *a)
   construct_weapon->SetAngle(a->PopDouble());
 }
 
-static void Action_Weapon_Gnu (Action *a)
-{
-  GnuLauncher* launcher = 
dynamic_cast<GnuLauncher*>(&(ActiveTeam().AccessWeapon()));
-  NET_ASSERT(launcher != NULL)
-  {
-    return;
-  }
-
-  Point2d pos(a->PopPoint2d());
-  launcher->ExplosionFromNetwork(pos);
-}
-
-static void Action_Weapon_Polecat (Action *a)
-{
-  PolecatLauncher* launcher = 
dynamic_cast<PolecatLauncher*>(&(ActiveTeam().AccessWeapon()));
-  NET_ASSERT(launcher != NULL)
-  {
-    return;
-  }
-
-  Point2d pos(a->PopPoint2d());
-  launcher->ExplosionFromNetwork(pos);
-}
-
-static void Action_Weapon_Supertux (Action *a)
-{
-  TuxLauncher* launcher = 
dynamic_cast<TuxLauncher*>(&(ActiveTeam().AccessWeapon()));
-  NET_ASSERT(launcher != NULL)
-  {
-    return;
-  }
-
-  int subaction = a->PopInt();
-
-  if (subaction == 0) {
-    double angle = a->PopDouble();
-    Point2d pos(a->PopPoint2d());
-    launcher->RefreshFromNetwork(angle, pos);
-  } else if (subaction == 1) {
-    Point2d pos(a->PopPoint2d());
-    launcher->ExplosionFromNetwork(pos);
-  } else {
-    ASSERT(false);
-  }
-}
-
 // ########################################################
 
 static void Action_Network_RandomInit (Action *a)
@@ -982,10 +934,12 @@ void Action_Handler_Init()
 
   // ########################################################
   // Using Weapon
-  ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SHOOT, 
"WEAPON_shoot", &Action_Weapon_Shoot);
   ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_STOP_USE, 
"WEAPON_stop_use", &Action_Weapon_StopUse);
 
   // Quite standard weapon options
+
+  ActionHandler::GetInstance()->Register 
(Action::ACTION_WEAPON_START_SHOOTING, "WEAPON_start_shooting", 
&Action_Weapon_StartShooting);
+  ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_STOP_SHOOTING, 
"WEAPON_stop_shooting", &Action_Weapon_StopShooting);
   ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SET_TIMEOUT, 
"WEAPON_set_timeout", &Action_Weapon_SetTimeout);
   ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SET_TARGET, 
"WEAPON_set_target", &Action_Weapon_SetTarget);
   ActionHandler::GetInstance()->Register 
(Action::ACTION_WEAPON_START_MOVING_LEFT, "WEAPON_start_moving_left", 
&Action_Weapon_StartMovingLeft);
@@ -999,9 +953,6 @@ void Action_Handler_Init()
 
   // Special weapon options
   ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_CONSTRUCTION, 
"WEAPON_construction", &Action_Weapon_Construction);
-  ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_GNU, 
"WEAPON_gnu", &Action_Weapon_Gnu);
-  ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_POLECAT, 
"WEAPON_polecat", &Action_Weapon_Polecat);
-  ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SUPERTUX, 
"WEAPON_supertux", &Action_Weapon_Supertux);
 
   // Bonus box
   ActionHandler::GetInstance()->Register (Action::ACTION_DROP_BONUS_BOX, 
"BONUSBOX_drop_box", &Action_DropBonusBox);
diff --git a/src/weapon/airhammer.cpp b/src/weapon/airhammer.cpp
index 01b5e4f..3dc3528 100644
--- a/src/weapon/airhammer.cpp
+++ b/src/weapon/airhammer.cpp
@@ -146,9 +146,22 @@ void Airhammer::p_Deselect()
   ActiveCharacter().SetMovement("breathe");
 }
 
+void Airhammer::StartShooting()
+{
+  if (EnoughAmmoUnit()) {
+    Weapon::RepeatShoot();
+  }
+}
+void Airhammer::StopShooting()
+{
+  ActiveTeam().AccessNbUnits() = 0; // ammo units are lost
+  Game::GetInstance()->SetState(Game::HAS_PLAYED);
+  p_Deselect();
+}
+
 //-----------------------------------------------------------------------------
 
-void Airhammer::HandleKeyRefreshed_Shoot()
+void Airhammer::Refresh()
 {
   if (EnoughAmmoUnit()) {
     Weapon::RepeatShoot();
@@ -157,7 +170,7 @@ void Airhammer::HandleKeyRefreshed_Shoot()
 
 bool Airhammer::IsInUse() const
 {
-  return m_last_fire_time + m_time_between_each_shot > 
Time::GetInstance()->Read();
+  return m_last_fire_time + m_time_between_each_shot > 
Time::GetInstance()->Read() || m_is_active;
 }
 
 void Airhammer::p_Select()
diff --git a/src/weapon/airhammer.h b/src/weapon/airhammer.h
index 668698c..ff2c6a4 100644
--- a/src/weapon/airhammer.h
+++ b/src/weapon/airhammer.h
@@ -43,16 +43,15 @@ class Airhammer : public Weapon
     void p_Select();
     void p_Deselect();
     bool p_Shoot();
-    void Refresh() { };
+    void Refresh();
 
   public:
     Airhammer();
     AirhammerConfig &cfg();
     bool IsInUse() const;
     void ActionStopUse();
-    void HandleKeyPressed_Shoot() { HandleKeyRefreshed_Shoot(); };
-    void HandleKeyRefreshed_Shoot();
-    void HandleKeyReleased_Shoot() { NewActionWeaponStopUse(); };
+    void StartShooting();
+    void StopShooting();
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
 };
diff --git a/src/weapon/blowtorch.cpp b/src/weapon/blowtorch.cpp
index c0b61ae..0db8d56 100644
--- a/src/weapon/blowtorch.cpp
+++ b/src/weapon/blowtorch.cpp
@@ -26,7 +26,6 @@
 #include "character/character.h"
 #include "character/move.h"
 #include "character/body.h"
-#include "include/action_handler.h"
 #include "map/map.h"
 #include "game/game_mode.h"
 #include "game/time.h"
@@ -70,16 +69,6 @@ void Blowtorch::p_Deselect()
   ActiveTeam().AccessNbUnits() = 0;
 }
 
-bool Blowtorch::IsInUse() const
-{
-  return m_last_fire_time + m_time_between_each_shot > 
Time::GetInstance()->Read();
-}
-
-void Blowtorch::ActionStopUse()
-{
-  SignalTurnEnd();
-}
-
 bool Blowtorch::p_Shoot()
 {
   Point2i hole = ActiveCharacter().GetCenter();
@@ -97,16 +86,23 @@ bool Blowtorch::p_Shoot()
   return true;
 }
 
-void Blowtorch::HandleKeyPressed_Shoot()
+void Blowtorch::StartShooting()
 {
   
ActiveCharacter().BeginMovementRL(GameMode::GetInstance()->character.walking_pause);
   ActiveCharacter().SetRebounding(false);
   ActiveCharacter().body->StartWalk();
 
-  HandleKeyRefreshed_Shoot();
+  m_is_active = true;
+}
+
+
+void Blowtorch::StopShooting()
+{
+  m_is_active = false;
+  SignalTurnEnd();
 }
 
-void Blowtorch::HandleKeyRefreshed_Shoot()
+void Blowtorch::Refresh()
 {
   if (EnoughAmmoUnit()) {
     Weapon::RepeatShoot();
diff --git a/src/weapon/blowtorch.h b/src/weapon/blowtorch.h
index e075fbb..c481f88 100644
--- a/src/weapon/blowtorch.h
+++ b/src/weapon/blowtorch.h
@@ -31,19 +31,15 @@ class Blowtorch : public Weapon
   protected:
     bool p_Shoot();
     void p_Deselect();
-    void Refresh() { };
+    void Refresh();
 
     void RepeatShoot() const ;
   public:
     Blowtorch();
     BlowtorchConfig& cfg();
 
-    virtual void ActionStopUse();
-
-    virtual void HandleKeyPressed_Shoot();
-    virtual void HandleKeyRefreshed_Shoot();
-    virtual void HandleKeyReleased_Shoot() { NewActionWeaponStopUse(); };
-    bool IsInUse() const;
+    void StartShooting();
+    void StopShooting();
 
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
diff --git a/src/weapon/bounce_ball.cpp b/src/weapon/bounce_ball.cpp
index 3b5d9b2..5a203c9 100644
--- a/src/weapon/bounce_ball.cpp
+++ b/src/weapon/bounce_ball.cpp
@@ -75,7 +75,7 @@ void BounceBall::SignalOutOfMap()
 //-----------------------------------------------------------------------------
 
 BounceBallLauncher::BounceBallLauncher() :
-  WeaponLauncher(WEAPON_BOUNCE_BALL, "bounce_ball", new 
ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
+  WeaponLauncher(WEAPON_BOUNCE_BALL, "bounce_ball", new 
ExplosiveWeaponConfig())
 {
   UpdateTranslationStrings();
 
diff --git a/src/weapon/cluster_bomb.cpp b/src/weapon/cluster_bomb.cpp
index b18389a..3b70b74 100644
--- a/src/weapon/cluster_bomb.cpp
+++ b/src/weapon/cluster_bomb.cpp
@@ -173,7 +173,7 @@ void ClusterBomb::SetEnergyDelta(int /* delta */, bool /* 
do_report */){};
 //-----------------------------------------------------------------------------
 
 ClusterLauncher::ClusterLauncher() :
-  WeaponLauncher(WEAPON_CLUSTER_BOMB, "cluster_bomb", new ClusterBombConfig(), 
VISIBLE_ONLY_WHEN_INACTIVE)
+  WeaponLauncher(WEAPON_CLUSTER_BOMB, "cluster_bomb", new ClusterBombConfig())
 {
   UpdateTranslationStrings();
 
diff --git a/src/weapon/disco_grenade.cpp b/src/weapon/disco_grenade.cpp
index a0bad0f..33b2ffa 100644
--- a/src/weapon/disco_grenade.cpp
+++ b/src/weapon/disco_grenade.cpp
@@ -141,7 +141,7 @@ void DiscoGrenade::SignalDrowning()
 //-----------------------------------------------------------------------------
 
 DiscoGrenadeLauncher::DiscoGrenadeLauncher() :
-  WeaponLauncher(WEAPON_DISCO_GRENADE, "disco_grenade", new 
ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE)
+  WeaponLauncher(WEAPON_DISCO_GRENADE, "disco_grenade", new 
ExplosiveWeaponConfig())
 {
   UpdateTranslationStrings();
 
diff --git a/src/weapon/flamethrower.cpp b/src/weapon/flamethrower.cpp
index 5ff4700..6a05796 100644
--- a/src/weapon/flamethrower.cpp
+++ b/src/weapon/flamethrower.cpp
@@ -124,6 +124,7 @@ FlameThrower::FlameThrower() : 
WeaponLauncher(WEAPON_FLAMETHROWER, "flamethrower
 
   m_weapon_fire = new 
Sprite(GetResourceManager().LoadImage(weapons_res_profile, m_id+"_fire"));
   m_weapon_fire->EnableRotationCache(32);
+  shooting = false;
 
   ReloadLauncher();
 }
@@ -164,10 +165,27 @@ bool FlameThrower::p_Shoot()
   return true;
 }
 
-void FlameThrower::HandleKeyRefreshed_Shoot()
+void FlameThrower::p_Deselect()
 {
-  if (EnoughAmmoUnit()) {
-    Weapon::RepeatShoot();
+  WeaponLauncher::p_Deselect();
+  shooting = false;
+}
+
+void FlameThrower::StartShooting()
+{
+  shooting = true;
+  m_is_active = true;
+}
+
+void FlameThrower::StopShooting()
+{
+  shooting = false;
+}
+
+void FlameThrower::Refresh()
+{
+  if (shooting && EnoughAmmoUnit()) {
+    WeaponLauncher::RepeatShoot();
   }
 }
 
diff --git a/src/weapon/flamethrower.h b/src/weapon/flamethrower.h
index 883257a..d557d81 100644
--- a/src/weapon/flamethrower.h
+++ b/src/weapon/flamethrower.h
@@ -29,14 +29,18 @@
 class FlameThrower : public WeaponLauncher
 {
     ParticleEngine particle;
+    bool shooting;
   protected:
     WeaponProjectile * GetProjectileInstance();
     void IncMissedShots();
     bool p_Shoot();
+    void p_Deselect();
   public:
     FlameThrower();
-    virtual void HandleKeyPressed_Shoot() { HandleKeyRefreshed_Shoot(); };
-    virtual void HandleKeyRefreshed_Shoot();
+    virtual void Refresh();
+    virtual void StartShooting();
+    virtual void StopShooting();
+    virtual bool IsInUse() const {return WeaponLauncher::IsInUse() || 
m_is_active;}
 
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
diff --git a/src/weapon/footbomb.cpp b/src/weapon/footbomb.cpp
index 69846cf..d576be6 100644
--- a/src/weapon/footbomb.cpp
+++ b/src/weapon/footbomb.cpp
@@ -143,7 +143,7 @@ void FootBomb::SetEnergyDelta(int /* delta */, bool /* 
do_report */){};
 //-----------------------------------------------------------------------------
 
 FootBombLauncher::FootBombLauncher() :
-  WeaponLauncher(WEAPON_FOOTBOMB, "footbomb", new FootBombConfig(), 
VISIBLE_ONLY_WHEN_INACTIVE)
+  WeaponLauncher(WEAPON_FOOTBOMB, "footbomb", new FootBombConfig())
 {
   UpdateTranslationStrings();
 
diff --git a/src/weapon/gnu.cpp b/src/weapon/gnu.cpp
index eb87186..ae9a296 100644
--- a/src/weapon/gnu.cpp
+++ b/src/weapon/gnu.cpp
@@ -23,7 +23,6 @@
 #include "game/config.h"
 #include "game/time.h"
 #include "graphic/sprite.h"
-#include "include/action_handler.h"
 #include "interface/game_msg.h"
 #include "map/camera.h"
 #include "network/randomsync.h"
@@ -152,12 +151,15 @@ void Gnu::SignalOutOfMap()
 //-----------------------------------------------------------------------------
 
 GnuLauncher::GnuLauncher() :
-  WeaponLauncher(WEAPON_GNU, "gnulauncher", new ExplosiveWeaponConfig(), 
VISIBLE_ONLY_WHEN_INACTIVE),
+  WeaponLauncher(WEAPON_GNU, "gnulauncher", new ExplosiveWeaponConfig()),
   current_gnu(NULL),
   gnu_death_time(0)
 {
   UpdateTranslationStrings();
 
+  current_gnu = NULL;
+  gnu_death_time = 0;
+
   m_category = SPECIAL;
   ReloadLauncher();
 
@@ -186,6 +188,7 @@ bool GnuLauncher::p_Shoot()
 
 void GnuLauncher::Refresh()
 {
+  WeaponLauncher::Refresh();
   if (current_gnu)
     return;
 
@@ -196,54 +199,30 @@ void GnuLauncher::Refresh()
   }
 }
 
-bool GnuLauncher::IsInUse() const
+bool GnuLauncher::IsOnCooldownFromShot() const
 {
   return (current_gnu || gnu_death_time);
 }
 
-void GnuLauncher::SignalEndOfProjectile()
-{
-  if (!current_gnu)
-    return;
-
-  current_gnu = NULL;
-  gnu_death_time = Time::GetInstance()->Read();
-}
-
-void GnuLauncher::HandleKeyPressed_Shoot()
-{
-  if (current_gnu || gnu_death_time)
-    return;
-
-  Weapon::HandleKeyPressed_Shoot();
-}
-
-void GnuLauncher::HandleKeyRefreshed_Shoot()
+bool GnuLauncher::IsReady() const
 {
-  if (current_gnu || gnu_death_time)
-    return;
-
-  Weapon::HandleKeyRefreshed_Shoot();
+  return !IsOnCooldownFromShot() && WeaponLauncher::IsReady();
 }
 
-void GnuLauncher::HandleKeyReleased_Shoot()
+void GnuLauncher::StopShooting()
 {
-  if (current_gnu) {
-    Action* a = new Action(Action::ACTION_WEAPON_GNU);
-    a->Push(current_gnu->GetPos());
-    ActionHandler::GetInstance()->NewAction(a);
-    return;
-  } else if (!gnu_death_time)
-    Weapon::HandleKeyReleased_Shoot();
+  if (current_gnu)
+    current_gnu->Explosion();
+  WeaponLauncher::StopShooting();
 }
 
-void GnuLauncher::ExplosionFromNetwork(Point2d gnu_pos)
+void GnuLauncher::SignalEndOfProjectile()
 {
   if (!current_gnu)
     return;
 
-  current_gnu->SetPhysXY(gnu_pos);
-  current_gnu->Explosion();
+  current_gnu = NULL;
+  gnu_death_time = Time::GetInstance()->Read();
 }
 
 WeaponProjectile * GnuLauncher::GetProjectileInstance()
diff --git a/src/weapon/gnu.h b/src/weapon/gnu.h
index 9f9fb91..32ba67f 100644
--- a/src/weapon/gnu.h
+++ b/src/weapon/gnu.h
@@ -39,14 +39,10 @@ public:
   virtual void SignalProjectileCollision() { };
   virtual void SignalProjectileDrowning() { };
 
-  virtual bool IsInUse() const;
+  bool IsOnCooldownFromShot() const;
+  bool IsReady() const;
 
-  // Key Shoot management
-  virtual void HandleKeyPressed_Shoot();
-  virtual void HandleKeyRefreshed_Shoot();
-  virtual void HandleKeyReleased_Shoot();
-
-  void ExplosionFromNetwork(Point2d gnu_pos);
+  void StopShooting();
 
   void UpdateTranslationStrings();
   std::string GetWeaponWinString(const char *TeamName, uint items_count) const;
diff --git a/src/weapon/grapple.cpp b/src/weapon/grapple.cpp
index d21aaa5..ddee84c 100644
--- a/src/weapon/grapple.cpp
+++ b/src/weapon/grapple.cpp
@@ -808,12 +808,18 @@ void Grapple::HandleKeyReleased_MoveRight(bool slowly)
     ActiveCharacter().HandleKeyReleased_MoveRight(slowly);
 }
 
-void Grapple::HandleKeyPressed_Shoot()
+void Grapple::StartShooting()
 {
-  if (IsInUse()) {
-    NewActionWeaponStopUse();
-  } else
-    NewActionWeaponShoot();
+  if (!IsInUse())
+    Weapon::StartShooting();
+}
+
+void Grapple::StopShooting()
+{
+  if (IsInUse())
+    ActionStopUse();
+  else
+    Weapon::StopShooting();
 }
 
 void Grapple::PrintDebugRope()
diff --git a/src/weapon/grapple.h b/src/weapon/grapple.h
index 2015447..b66806c 100644
--- a/src/weapon/grapple.h
+++ b/src/weapon/grapple.h
@@ -125,6 +125,9 @@ class Grapple : public Weapon
     void StartMovingDown();
     void StopMovingDown();
 
+    void StartShooting();
+    void StopShooting();
+
     // Keys management
     void HandleKeyPressed_Up(bool slowly);
     void HandleKeyRefreshed_Up(bool slowly);
@@ -142,10 +145,6 @@ class Grapple : public Weapon
     void HandleKeyRefreshed_MoveLeft(bool slowly);
     void HandleKeyReleased_MoveLeft(bool slowly);
 
-    void HandleKeyPressed_Shoot();
-    void HandleKeyRefreshed_Shoot() { };
-    void HandleKeyReleased_Shoot() { };
-
     void PrintDebugRope();
 };
 
diff --git a/src/weapon/grenade.cpp b/src/weapon/grenade.cpp
index e2b61eb..f10d9bf 100644
--- a/src/weapon/grenade.cpp
+++ b/src/weapon/grenade.cpp
@@ -61,7 +61,7 @@ void Grenade::SignalOutOfMap()
 //-----------------------------------------------------------------------------
 
 GrenadeLauncher::GrenadeLauncher() :
-  WeaponLauncher(WEAPON_GRENADE, "grenade", new ExplosiveWeaponConfig(), 
VISIBLE_ONLY_WHEN_INACTIVE)
+  WeaponLauncher(WEAPON_GRENADE, "grenade", new ExplosiveWeaponConfig())
 {
   UpdateTranslationStrings();
 
diff --git a/src/weapon/jetpack.cpp b/src/weapon/jetpack.cpp
index 5327a04..16e12a9 100644
--- a/src/weapon/jetpack.cpp
+++ b/src/weapon/jetpack.cpp
@@ -200,12 +200,12 @@ void JetPack::HandleKeyReleased_Up(bool slowly)
     StopMovingUpForAllPlayers();
 }
 
-void JetPack::HandleKeyPressed_Shoot()
+void JetPack::StartShooting()
 {
-  if (!IsInUse())
-    NewActionWeaponShoot();
+  if (IsInUse())
+    ActionStopUse();
   else
-    NewActionWeaponStopUse();
+    Weapon::StartShooting();
 }
 
 bool JetPack::p_Shoot()
diff --git a/src/weapon/jetpack.h b/src/weapon/jetpack.h
index bb4e848..212fea0 100644
--- a/src/weapon/jetpack.h
+++ b/src/weapon/jetpack.h
@@ -43,10 +43,10 @@ class JetPack : public Weapon
 
     void StartMovingUp();
     void StopMovingUp();
+    void StartShooting();
 
     virtual void HandleKeyPressed_Up(bool slowly);
     virtual void HandleKeyReleased_Up(bool slowly);
-    virtual void HandleKeyPressed_Shoot();
 
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
diff --git a/src/weapon/lowgrav.cpp b/src/weapon/lowgrav.cpp
index b949558..0699a8b 100644
--- a/src/weapon/lowgrav.cpp
+++ b/src/weapon/lowgrav.cpp
@@ -67,14 +67,13 @@ bool LowGrav::p_Shoot()
   return true;
 }
 
-void LowGrav::HandleKeyPressed_Shoot()
+void LowGrav::StartShooting()
 {
-  if (!IsInUse()){
-    NewActionWeaponShoot();
-
-  }else{
-    NewActionWeaponStopUse();
+  if (IsInUse()) {
+    ActionStopUse();
     use.Stop();
+  } else {
+    Weapon::StartShooting();
   }
 }
 
diff --git a/src/weapon/lowgrav.h b/src/weapon/lowgrav.h
index e5b1773..1a77e04 100644
--- a/src/weapon/lowgrav.h
+++ b/src/weapon/lowgrav.h
@@ -30,8 +30,7 @@ class LowGrav : public Weapon
     LowGrav();
     void Draw() { };
     void ActionStopUse() { UseAmmoUnit(); };
-    void HandleKeyPressed_Shoot();
-
+    void StartShooting();
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
   protected:
diff --git a/src/weapon/parachute.cpp b/src/weapon/parachute.cpp
index e5d286b..dbf5a53 100644
--- a/src/weapon/parachute.cpp
+++ b/src/weapon/parachute.cpp
@@ -169,7 +169,7 @@ std::string Parachute::GetWeaponWinString(const char 
*TeamName, uint items_count
             items_count), TeamName, items_count);
 }
 
-void Parachute::HandleKeyPressed_Shoot()
+void Parachute::StartShooting()
 {
   if (open) {
     img->Finish();
@@ -177,7 +177,7 @@ void Parachute::HandleKeyPressed_Shoot()
     closing = false;
     UseAmmoUnit();
   } else {
-    Weapon::HandleKeyPressed_Shoot();
+    Weapon::StartShooting();
   }
 }
 
diff --git a/src/weapon/parachute.h b/src/weapon/parachute.h
index 596aac4..3b9d2cc 100644
--- a/src/weapon/parachute.h
+++ b/src/weapon/parachute.h
@@ -47,7 +47,7 @@ class Parachute : public Weapon
     void Draw();
     bool IsInUse() const;
 
-    void HandleKeyPressed_Shoot();
+    void StartShooting();
 
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
diff --git a/src/weapon/polecat.cpp b/src/weapon/polecat.cpp
index 9a8f796..3dd23f9 100644
--- a/src/weapon/polecat.cpp
+++ b/src/weapon/polecat.cpp
@@ -23,7 +23,6 @@
 #include "game/config.h"
 #include "game/time.h"
 #include "graphic/sprite.h"
-#include "include/action_handler.h"
 #include "interface/game_msg.h"
 #include "map/camera.h"
 #include "network/randomsync.h"
@@ -177,7 +176,7 @@ void Polecat::SignalOutOfMap()
 //-----------------------------------------------------------------------------
 
 PolecatLauncher::PolecatLauncher() :
-  WeaponLauncher(WEAPON_POLECAT, "polecatlauncher", new 
ExplosiveWeaponConfig(), VISIBLE_ONLY_WHEN_INACTIVE),
+  WeaponLauncher(WEAPON_POLECAT, "polecatlauncher", new 
ExplosiveWeaponConfig()),
   current_polecat(NULL),
   polecat_death_time(0)
 {
@@ -212,6 +211,7 @@ bool PolecatLauncher::p_Shoot()
 
 void PolecatLauncher::Refresh()
 {
+  WeaponLauncher::Refresh();
   if (current_polecat)
     return;
 
@@ -222,54 +222,32 @@ void PolecatLauncher::Refresh()
   }
 }
 
-bool PolecatLauncher::IsInUse() const
+bool PolecatLauncher::IsOnCooldownFromShot() const
 {
   return (current_polecat || polecat_death_time);
 }
 
-void PolecatLauncher::SignalEndOfProjectile()
-{
-  if (!current_polecat)
-    return;
-
-  current_polecat = NULL;
-  polecat_death_time = Time::GetInstance()->Read();
-}
-
-void PolecatLauncher::HandleKeyPressed_Shoot()
-{
-  if (current_polecat || polecat_death_time)
-    return;
-
-  Weapon::HandleKeyPressed_Shoot();
-}
-
-void PolecatLauncher::HandleKeyRefreshed_Shoot()
+bool PolecatLauncher::IsReady() const
 {
-  if (current_polecat || polecat_death_time)
-    return;
-
-  Weapon::HandleKeyRefreshed_Shoot();
+  return !IsOnCooldownFromShot() && WeaponLauncher::IsReady();
 }
 
-void PolecatLauncher::HandleKeyReleased_Shoot()
+void PolecatLauncher::StopShooting()
 {
   if (current_polecat) {
-    Action* a = new Action(Action::ACTION_WEAPON_POLECAT);
-    a->Push(current_polecat->GetPos());
-    ActionHandler::GetInstance()->NewAction(a);
+    current_polecat->Explosion();
     return;
-  } else if (!polecat_death_time)
-    Weapon::HandleKeyReleased_Shoot();
+  }
+  WeaponLauncher::StopShooting();
 }
 
-void PolecatLauncher::ExplosionFromNetwork(Point2d polecat_pos)
+void PolecatLauncher::SignalEndOfProjectile()
 {
   if (!current_polecat)
     return;
 
-  current_polecat->SetPhysXY(polecat_pos);
-  current_polecat->Explosion();
+  current_polecat = NULL;
+  polecat_death_time = Time::GetInstance()->Read();
 }
 
 WeaponProjectile * PolecatLauncher::GetProjectileInstance()
diff --git a/src/weapon/polecat.h b/src/weapon/polecat.h
index 50d0836..ad77c09 100644
--- a/src/weapon/polecat.h
+++ b/src/weapon/polecat.h
@@ -40,15 +40,10 @@ public:
   virtual void SignalProjectileCollision() { };
   virtual void SignalProjectileDrowning() { };
 
-  virtual bool IsInUse() const;
-
-  // Key Shoot management
-  virtual void HandleKeyPressed_Shoot();
-  virtual void HandleKeyRefreshed_Shoot();
-  virtual void HandleKeyReleased_Shoot();
-
-  void ExplosionFromNetwork(Point2d gnu_pos);
+  bool IsOnCooldownFromShot() const;
+  bool IsReady() const;
 
+  void StopShooting();
 
   void UpdateTranslationStrings();
   std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
diff --git a/src/weapon/submachine_gun.cpp b/src/weapon/submachine_gun.cpp
index 621d728..e73541b 100644
--- a/src/weapon/submachine_gun.cpp
+++ b/src/weapon/submachine_gun.cpp
@@ -138,8 +138,7 @@ bool SubMachineGun::p_Shoot()
 
 void SubMachineGun::Refresh()
 {
-  if (shoot_started
-      && (ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI())) {
+  if (shoot_started) {
     Weapon::RepeatShoot();
   }
 }
diff --git a/src/weapon/supertux.cpp b/src/weapon/supertux.cpp
index 46ae30c..a811c08 100644
--- a/src/weapon/supertux.cpp
+++ b/src/weapon/supertux.cpp
@@ -126,15 +126,6 @@ void SuperTux::Refresh()
     last_move = Time::GetInstance()->Read();
   }
 
-  if(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI())
-  {
-    Action a(Action::ACTION_WEAPON_SUPERTUX);
-    a.Push(0); // to ask for a position refresh
-    a.Push(angle_rad);
-    a.Push(GetPos());
-    Network::GetInstance()->SendActionToAll(a);
-  }
-
   if (!swimming)
     particle_engine.AddPeriodic(GetPosition(), particle_STAR, false, 
angle_rad, 0);
   // else
@@ -277,32 +268,22 @@ void TuxLauncher::SignalEndOfProjectile()
   tux_death_time = Time::GetInstance()->Read();
 }
 
-void TuxLauncher::HandleKeyPressed_Shoot()
+void TuxLauncher::StartShooting()
 {
   if (current_tux || tux_death_time)
     return;
 
-  Weapon::HandleKeyPressed_Shoot();
+  Weapon::StartShooting();
 }
 
-void TuxLauncher::HandleKeyRefreshed_Shoot()
-{
-  if (current_tux || tux_death_time)
-    return;
-
-  Weapon::HandleKeyRefreshed_Shoot();
-}
 
-void TuxLauncher::HandleKeyReleased_Shoot()
+void TuxLauncher::StopShooting()
 {
   if (current_tux) {
-    Action* a = new Action(Action::ACTION_WEAPON_SUPERTUX);
-    a->Push(1); // to ask for an explosion
-    a->Push(current_tux->GetPos());
-    ActionHandler::GetInstance()->NewAction(a);
+    current_tux->Explosion();
     return;
   } else if (!tux_death_time)
-    Weapon::HandleKeyReleased_Shoot();
+    Weapon::StopShooting();
 }
 
 // Move right
@@ -449,25 +430,6 @@ std::string TuxLauncher::GetWeaponWinString(const char 
*TeamName, uint items_cou
             items_count), TeamName, items_count);
 }
 
-void TuxLauncher::RefreshFromNetwork(double angle, Point2d pos)
-{
-  // Fix bug #9815 : Crash when changing tux angle in network mode.
-  if (!current_tux)
-    return;
-  current_tux->SetAngle(angle);
-  current_tux->SetPhysXY(pos);
-  current_tux->SetSpeedXY(Point2d(0,0));
-}
-
-void TuxLauncher::ExplosionFromNetwork(Point2d tux_pos)
-{
-  if (!current_tux)
-    return;
-
-  current_tux->SetPhysXY(tux_pos);
-  current_tux->Explosion();
-}
-
 SuperTuxWeaponConfig& TuxLauncher::cfg()
 {
   return static_cast<SuperTuxWeaponConfig&>(*extra_params);
diff --git a/src/weapon/supertux.h b/src/weapon/supertux.h
index c47e8a2..b90e504 100644
--- a/src/weapon/supertux.h
+++ b/src/weapon/supertux.h
@@ -44,10 +44,8 @@ public:
 
   virtual void SignalEndOfProjectile();
 
-  // Key Shoot management
-  virtual void HandleKeyPressed_Shoot();
-  virtual void HandleKeyRefreshed_Shoot();
-  virtual void HandleKeyReleased_Shoot();
+  void StartShooting();
+  void StopShooting();
 
   virtual void HandleKeyPressed_MoveRight(bool slowly);
   virtual void HandleKeyRefreshed_MoveRight(bool slowly);
diff --git a/src/weapon/weapon.cpp b/src/weapon/weapon.cpp
index 1980e77..8d4a756 100644
--- a/src/weapon/weapon.cpp
+++ b/src/weapon/weapon.cpp
@@ -237,32 +237,6 @@ bool Weapon::CanChangeWeapon() const
   return true;
 }
 
-void Weapon::NewActionWeaponShoot() const
-{
-  ASSERT(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI());
-
-  if (ActiveCharacter().IsPreparingShoot()) { // a shot is already in progress
-#ifdef DEBUG
-    fprintf(stderr, "\nWARNING: Weapon::NewActionWeaponShoot: a shot is 
already in progress!\n");
-    fprintf(stderr, "         Maybe, shot anim for this weapon is longer than 
m_time_between_each_shot\n\n");
-#endif
-    return;
-  }
-
-  Action* a_shoot = new Action(Action::ACTION_WEAPON_SHOOT,
-                               m_strength,
-                               ActiveCharacter().GetAbsFiringAngle());
-  ActionHandler::GetInstance()->NewAction(a_shoot);
-}
-
-void Weapon::NewActionWeaponStopUse() const
-{
-  ASSERT(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI());
-
-  Action* a = new Action(Action::ACTION_WEAPON_STOP_USE);
-  ActionHandler::GetInstance()->NewAction(a);
-}
-
 void Weapon::PrepareShoot(double strength, double angle)
 {
   MSG_DEBUG("weapon.shoot", "Try to shoot with strength:%f, angle:%f",
@@ -334,12 +308,41 @@ bool Weapon::Shoot()
   return true;
 }
 
+void Weapon::Refresh()
+{
+  if (IsLoading() && !ActiveCharacter().IsPreparingShoot()) {
+    // Strength == max strength -> Fire !!!
+    if (ReadStrength() >= max_strength) {
+        PrepareShoot(m_strength, ActiveCharacter().GetAbsFiringAngle());
+    } else {
+        // still pressing the Space key
+        UpdateStrength();
+    }
+  }
+}
+
+void Weapon::StartShooting()
+{
+  if (ActiveCharacter().IsPreparingShoot())
+    return;
+
+  if (max_strength != 0 && IsReady())
+    InitLoading();
+}
+
+void Weapon::StopShooting()
+{
+  if (!ActiveCharacter().IsPreparingShoot()) {
+    PrepareShoot(m_strength, ActiveCharacter().GetAbsFiringAngle());
+  }
+}
+
 void Weapon::RepeatShoot()
 {
   uint current_time = Time::GetInstance()->Read();
 
   if (current_time - m_last_fire_time >= m_time_between_each_shot) {
-    NewActionWeaponShoot();
+    PrepareShoot(m_strength, ActiveCharacter().GetAbsFiringAngle());
     // this is done in Weapon::Shoot() but let's set meanwhile,
     // to prevent problems with rapid fire weapons such as submachine
     m_last_fire_time = current_time;
@@ -518,13 +521,7 @@ void Weapon::Draw(){
   if (m_last_fire_time + m_fire_remanence_time > Time::GetInstance()->Read())
 #endif
     DrawWeaponFire();
-  weapon_strength_bar.visible = false;
-
-  // Do we need to draw strength_bar ? (real draw is done by class Interface)
-  // We do not draw on the network
-  if (max_strength != 0 && IsReady() && !IsInUse() &&
-      (ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()))
-    weapon_strength_bar.visible = true;
+  weapon_strength_bar.visible = IsLoading();
 
   DrawAmmoUnits();
 
@@ -750,34 +747,14 @@ void Weapon::ActionStopUse()
 // #################### SHOOT
 void Weapon::HandleKeyPressed_Shoot()
 {
-  if (ActiveCharacter().IsPreparingShoot())
-    return;
-
-  if (max_strength != 0 && IsReady())
-    InitLoading();
-}
-
-void Weapon::HandleKeyRefreshed_Shoot()
-{
-  if (ActiveCharacter().IsPreparingShoot())
-    return;
-  if (!IsLoading())
-    return;
-
-  // Strength == max strength -> Fire !!!
-  if (ReadStrength() >= max_strength) {
-    NewActionWeaponShoot();
-  } else {
-    // still pressing the Space key
-    UpdateStrength();
-  }
+  Action *a = new Action(Action::ACTION_WEAPON_START_SHOOTING);
+  ActionHandler::GetInstance()->NewAction(a);
 }
 
 void Weapon::HandleKeyReleased_Shoot()
 {
-  if (!ActiveCharacter().IsPreparingShoot()) {
-    NewActionWeaponShoot();
-  }
+  Action *a = new Action(Action::ACTION_WEAPON_STOP_SHOOTING);
+  ActionHandler::GetInstance()->NewAction(a);
 }
 
 void Weapon::p_Deselect()
diff --git a/src/weapon/weapon.h b/src/weapon/weapon.h
index 2b4f2a5..b8a0134 100644
--- a/src/weapon/weapon.h
+++ b/src/weapon/weapon.h
@@ -151,7 +151,7 @@ public:
 protected:
   virtual void p_Select() { m_last_fire_time = 0; };
   virtual void p_Deselect();
-  virtual void Refresh() = 0;
+  virtual void Refresh();
   virtual bool p_Shoot() = 0;
 
   virtual void DrawWeaponFire();
@@ -206,10 +206,6 @@ public:
   // Calculate weapon position
   virtual void PosXY (int &x, int &y) const;
 
-  // Create a new action "shoot/stop_use" in action handler
-  void NewActionWeaponShoot() const;
-  void NewActionWeaponStopUse() const;
-
   // Prepare the shoot : set the angle and strenght of the weapon
   // Begin the shooting animation of the character
   void PrepareShoot(double strength, double angle);
@@ -252,9 +248,9 @@ public:
   // Handle a keyboard event.
 
   // Key Shoot management
-  virtual void HandleKeyPressed_Shoot();
-  virtual void HandleKeyRefreshed_Shoot();
-  virtual void HandleKeyReleased_Shoot();
+  void HandleKeyPressed_Shoot();
+  void HandleKeyRefreshed_Shoot() {};
+  void HandleKeyReleased_Shoot();
 
   // To override standard moves of character
   virtual void HandleKeyPressed_MoveRight(bool slowly);
@@ -350,6 +346,9 @@ public:
 
   virtual void StartMovingDown() {};
   virtual void StopMovingDown() {};
+
+  virtual void StartShooting();
+  virtual void StopShooting();
 private:
   // Angle in radian between -PI to PI
   double min_angle, max_angle;
diff --git a/src/weapon/weapon_launcher.cpp b/src/weapon/weapon_launcher.cpp
index cccb8ec..4e07232 100644
--- a/src/weapon/weapon_launcher.cpp
+++ b/src/weapon/weapon_launcher.cpp
@@ -434,9 +434,14 @@ bool WeaponLauncher::p_Shoot()
   return true;
 }
 
+bool WeaponLauncher::IsOnCooldownFromShot() const
+{
+  return (m_last_fire_time > 0 && m_last_fire_time + m_time_between_each_shot 
> Time::GetInstance()->Read());
+}
+
 bool WeaponLauncher::IsInUse() const
 {
-  return m_last_fire_time > 0 && m_last_fire_time + m_time_between_each_shot > 
Time::GetInstance()->Read();
+  return IsOnCooldownFromShot() || IsLoading();
 }
 
 bool WeaponLauncher::ReloadLauncher()
@@ -459,7 +464,7 @@ void WeaponLauncher::Draw()
   //Display timeout for projectil if can be changed.
   if (projectile->change_timeout_allowed())
   {
-    if( IsInUse() ) //Do not display after launching.
+    if (IsOnCooldownFromShot()) //Do not display after launching.
       return;
 
     int tmp = projectile->GetTotalTimeout();
diff --git a/src/weapon/weapon_launcher.h b/src/weapon/weapon_launcher.h
index e5f77c6..7eca346 100644
--- a/src/weapon/weapon_launcher.h
+++ b/src/weapon/weapon_launcher.h
@@ -124,7 +124,6 @@ class WeaponLauncher : public Weapon
     virtual void p_Select();
     virtual WeaponProjectile * GetProjectileInstance() = 0;
     virtual bool ReloadLauncher();
-    virtual void Refresh() { };
   private:
     void DirectExplosion();
     void NetworkSetTimeoutProjectile() const;
@@ -161,6 +160,7 @@ class WeaponLauncher : public Weapon
 
     virtual void IncMissedShots();
     virtual bool IsInUse() const;
+    virtual bool IsOnCooldownFromShot() const;
     // Handle mouse events
     virtual void HandleMouseWheelUp(bool shift);
     virtual void HandleMouseWheelDown(bool shift);
-- 
1.6.0.4


_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à