Looks good :)

(For next patches, if I don't answer, it is because I have nothing more 
to say that "Looks good :)" ;) )

Florian Köberle a écrit :
> ---
>  lib/wormux/include/WORMUX_action.h |    9 ++++++
>  src/include/action_handler.cpp     |   48 +++++++++++++++++++++++++++++++++++
>  src/weapon/weapon.cpp              |   49 
> ++++++++++++++++++++++++++++++++++++
>  src/weapon/weapon.h                |   24 +++++++++++++++++
>  4 files changed, 130 insertions(+), 0 deletions(-)
>
> diff --git a/lib/wormux/include/WORMUX_action.h 
> b/lib/wormux/include/WORMUX_action.h
> index 4f6e957..5922155 100644
> --- a/lib/wormux/include/WORMUX_action.h
> +++ b/lib/wormux/include/WORMUX_action.h
> @@ -98,6 +98,15 @@ public:
>      // Quite standard weapon options
>      ACTION_WEAPON_SET_TIMEOUT,
>      ACTION_WEAPON_SET_TARGET,
> +    ACTION_WEAPON_START_MOVING_LEFT,
> +    ACTION_WEAPON_STOP_MOVING_LEFT,
> +    ACTION_WEAPON_START_MOVING_RIGHT,
> +    ACTION_WEAPON_STOP_MOVING_RIGHT,
> +    ACTION_WEAPON_START_MOVING_UP,
> +    ACTION_WEAPON_STOP_MOVING_UP,
> +    ACTION_WEAPON_START_MOVING_DOWN,
> +    ACTION_WEAPON_STOP_MOVING_DOWN,
> +
>  
>      // Special weapon options
>      ACTION_WEAPON_CONSTRUCTION,
> diff --git a/src/include/action_handler.cpp b/src/include/action_handler.cpp
> index 67731a0..a0a0e59 100644
> --- a/src/include/action_handler.cpp
> +++ b/src/include/action_handler.cpp
> @@ -639,6 +639,46 @@ static void Action_Weapon_SetTimeout (Action *a)
>    launcher->GetProjectile()->m_timeout_modifier = a->PopInt();
>  }
>  
> +static void Action_Weapon_StartMovingLeft(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StartMovingLeft();
> +}
> +
> +static void Action_Weapon_StopMovingLeft(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StopMovingLeft();
> +}
> +
> +static void Action_Weapon_StartMovingRight(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StartMovingRight();
> +}
> +
> +static void Action_Weapon_StopMovingRight(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StopMovingRight();
> +}
> +
> +static void Action_Weapon_StartMovingUp(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StartMovingUp();
> +}
> +
> +static void Action_Weapon_StopMovingUp(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StopMovingUp();
> +}
> +
> +static void Action_Weapon_StartMovingDown(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StartMovingDown();
> +}
> +
> +static void Action_Weapon_StopMovingDown(Action */*a*/)
> +{
> +  ActiveTeam().AccessWeapon().StopMovingDown();
> +}
> +
>  static void Action_Weapon_Construction (Action *a)
>  {
>    Construct* construct_weapon = 
> dynamic_cast<Construct*>(&(ActiveTeam().AccessWeapon()));
> @@ -981,6 +1021,14 @@ void Action_Handler_Init()
>    // Quite standard weapon options
>    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);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_STOP_MOVING_LEFT, "WEAPON_stop_moving_left", 
> &Action_Weapon_StopMovingLeft);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_START_MOVING_RIGHT, "WEAPON_start_moving_right", 
> &Action_Weapon_StartMovingRight);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_STOP_MOVING_RIGHT, "WEAPON_stop_moving_right", 
> &Action_Weapon_StopMovingRight);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_START_MOVING_UP, "WEAPON_start_moving_up", 
> &Action_Weapon_StartMovingUp);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_STOP_MOVING_UP, "WEAPON_stop_moving_up", 
> &Action_Weapon_StopMovingUp);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_START_MOVING_DOWN, "WEAPON_start_moving_down", 
> &Action_Weapon_StartMovingDown);
> +  ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_STOP_MOVING_DOWN, "WEAPON_stop_moving_down", 
> &Action_Weapon_StopMovingDown);
>  
>    // Special weapon options
>    ActionHandler::GetInstance()->Register 
> (Action::ACTION_WEAPON_CONSTRUCTION, "WEAPON_construction", 
> &Action_Weapon_Construction);
> diff --git a/src/weapon/weapon.cpp b/src/weapon/weapon.cpp
> index 75d4e8f..1980e77 100644
> --- a/src/weapon/weapon.cpp
> +++ b/src/weapon/weapon.cpp
> @@ -34,6 +34,7 @@
>  #include "include/app.h"
>  #include "include/action_handler.h"
>  #include "map/camera.h"
> +#include "network/network.h"
>  #include "team/macro.h"
>  #include "team/team.h"
>  #include "tool/math_tools.h"
> @@ -345,6 +346,54 @@ void Weapon::RepeatShoot()
>    }
>  }
>  
> +void Weapon::StartMovingLeftForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_START_MOVING_LEFT);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StopMovingLeftForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_STOP_MOVING_LEFT);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StartMovingRightForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_START_MOVING_RIGHT);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StopMovingRightForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_STOP_MOVING_RIGHT);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StartMovingUpForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_START_MOVING_UP);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StopMovingUpForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_STOP_MOVING_UP);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StartMovingDownForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_START_MOVING_DOWN);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
> +void Weapon::StopMovingDownForAllPlayers()
> +{
> +  Action *a = new Action(Action::ACTION_WEAPON_STOP_MOVING_DOWN);
> +  ActionHandler::GetInstance()->NewAction(a);
> +}
> +
>  // Compute position of weapon's image
>  void Weapon::PosXY (int &x, int &y) const
>  {
> diff --git a/src/weapon/weapon.h b/src/weapon/weapon.h
> index 42cdb8b..2b4f2a5 100644
> --- a/src/weapon/weapon.h
> +++ b/src/weapon/weapon.h
> @@ -158,6 +158,18 @@ protected:
>    void DrawAmmoUnits() const;
>  
>    void RepeatShoot();
> +
> +  void StartMovingLeftForAllPlayers();
> +  void StopMovingLeftForAllPlayers();
> +
> +  void StartMovingRightForAllPlayers();
> +  void StopMovingRightForAllPlayers();
> +
> +  void StartMovingUpForAllPlayers();
> +  void StopMovingUpForAllPlayers();
> +
> +  void StartMovingDownForAllPlayers();
> +  void StopMovingDownForAllPlayers();
>  public:
>    Weapon(Weapon_type type,
>           const std::string &id,
> @@ -326,6 +338,18 @@ public:
>    inline const double &GetMinAngle() const {return min_angle;}
>    inline void SetMaxAngle(double max) {max_angle = max;}
>    inline const double &GetMaxAngle() const {return max_angle;}
> +
> +  virtual void StartMovingLeft() {};
> +  virtual void StopMovingLeft() {};
> +
> +  virtual void StartMovingRight() {};
> +  virtual void StopMovingRight() {};
> +
> +  virtual void StartMovingUp() {};
> +  virtual void StopMovingUp() {};
> +
> +  virtual void StartMovingDown() {};
> +  virtual void StopMovingDown() {};
>  private:
>    // Angle in radian between -PI to PI
>    double min_angle, max_angle;
>   


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

Répondre à