[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.17,1.18 pingu_action.hxx,
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.17,1.18 pingu_action.hxx,1.9,1.10 |
Date: |
22 Aug 2002 10:21:31 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv23987
Modified Files:
pingu.cxx pingu_action.hxx
Log Message:
added oh-no sound
Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- pingu.cxx 28 Jun 2002 18:11:10 -0000 1.17
+++ pingu.cxx 22 Aug 2002 10:21:29 -0000 1.18
@@ -113,83 +113,101 @@
bool
Pingu::request_set_action(PinguAction* act)
{
+ bool ret_val = false;
assert(act);
if (status == PS_DEAD)
{
pout(PINGUS_DEBUG_ACTIONS) << _("Setting action to a dead pingu") <<
std::endl;
- return false;
+ ret_val = false;
}
-
- switch (act->get_activation_mode()) {
+ else
+ {
+ switch (act->get_activation_mode()) {
- case INSTANT:
+ case INSTANT:
- if (act->get_type() == action->get_type())
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Pingu: Already have action" <<
std::endl;
- return false;
- }
- else if (action->change_allowed(act->get_type()))
- {
- pout(PINGUS_DEBUG_ACTIONS) << "setting instant action" << std::endl;
- act->set_pingu(this);
- set_action(act);
- return true;
- }
- else
- {
- pout(PINGUS_DEBUG_ACTIONS) << "change from action " <<
action->get_name () << " not allowed" << std::endl;
- return false;
- }
+ if (act->get_type() == action->get_type())
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Pingu: Already have action" <<
std::endl;
+ ret_val = false;
+ }
+ else if (action->change_allowed(act->get_type()))
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "setting instant action" << std::endl;
+ act->set_pingu(this);
+ set_action(act);
+ ret_val = true;
+ }
+ else
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "change from action " <<
action->get_name () << " not allowed" << std::endl;
+ ret_val = false;
+ }
+ break;
- case WALL_TRIGGERED:
+ case WALL_TRIGGERED:
- if (wall_action && wall_action->get_type() == act->get_type())
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Not using wall action, we have
already" << std::endl;
- return false;
- }
- else
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Setting wall action" << std::endl;
- wall_action = act;
- return true;
- }
+ if (wall_action && wall_action->get_type() == act->get_type())
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Not using wall action, we have
already" << std::endl;
+ ret_val = false;
+ }
+ else
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Setting wall action" << std::endl;
+ wall_action = act;
+ ret_val = true;
+ }
+ break;
- case FALL_TRIGGERED:
+ case FALL_TRIGGERED:
- if (fall_action && fall_action->get_type() == act->get_type())
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Not using fall action, we have
already" << std::endl;
- return false;
- }
- else
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Setting fall action" << std::endl;
- fall_action = act;
- return true;
- }
+ if (fall_action && fall_action->get_type() == act->get_type())
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Not using fall action, we have
already" << std::endl;
+ ret_val = false;
+ }
+ else
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Setting fall action" << std::endl;
+ fall_action = act;
+ ret_val = true;
+ }
+ break;
- case COUNTDOWN_TRIGGERED:
+ case COUNTDOWN_TRIGGERED:
- if (countdown_action && countdown_action->get_type() == act->get_type())
- {
- pout(PINGUS_DEBUG_ACTIONS) << "Not using countdown action, we have
already" << std::endl;
- return false;
- }
+ if (countdown_action && countdown_action->get_type() == act->get_type())
+ {
+ pout(PINGUS_DEBUG_ACTIONS) << "Not using countdown action, we have
already" << std::endl;
+ ret_val = false;
+ break;
+ }
- pout(PINGUS_DEBUG_ACTIONS) << "Setting countdown action" << std::endl;
- // We set the action and start the countdown
- action_time = act->activation_time();
- countdown_action = act;
- return true;
-
- default:
- pout(PINGUS_DEBUG_ACTIONS) << "unknown action activation_mode" <<
std::endl;
- assert(0);
- return false;
- }
+ pout(PINGUS_DEBUG_ACTIONS) << "Setting countdown action" << std::endl;
+ // We set the action and start the countdown
+ action_time = act->activation_time();
+ countdown_action = act;
+ ret_val = true;
+ break;
+
+ default:
+ pout(PINGUS_DEBUG_ACTIONS) << "unknown action activation_mode" <<
std::endl;
+ assert(0);
+ ret_val = false;
+ break;
+ }
+ }
+
+ if (ret_val == true) // Action successfull applied
+ {
+ act->on_successfull_apply (this);
+ }
+ else // Action failed to be set
+ {
+ act->on_failed_apply (this);
+ }
}
bool
Index: pingu_action.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pingu_action.hxx 2 Jul 2002 13:36:06 -0000 1.9
+++ pingu_action.hxx 22 Aug 2002 10:21:29 -0000 1.10
@@ -115,6 +115,12 @@
/// True if Pingu in specified position would bang its head if it were
walking
bool head_collision_on_walk (int x, int y);
+
+ /** Called if the action was successfully applied via request_set_action */
+ virtual void on_successfull_apply (Pingu*) {}
+
+ /** Called if the request_set_action failded to apply this action */
+ virtual void on_failed_apply (Pingu*) {}
};
#endif /* PINGU_ACTION_HH */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.17,1.18 pingu_action.hxx,1.9,1.10,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.7,1.8 bomber.hxx,1.6,1.7
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src world.cxx,1.16,1.17
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.7,1.8 bomber.hxx,1.6,1.7
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src world.cxx,1.16,1.17
- Index(es):