pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.6,1.7


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.6,1.7
Date: 21 Jun 2002 16:50:22 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv2222

Modified Files:
        pingu.cxx 
Log Message:
simplified the code some more since action can't be 0 anymore


Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pingu.cxx   21 Jun 2002 13:42:34 -0000      1.6
+++ pingu.cxx   21 Jun 2002 16:50:20 -0000      1.7
@@ -36,8 +36,7 @@
 
 // Init a pingu at the given position while falling
 Pingu::Pingu(const CL_Vector& arg_pos, int owner)
-  : action (0),
-    countdown_action (0),
+  : countdown_action (0),
     id (++id_counter),
     font (PingusResource::load_font("Fonts/numbers", "fonts")),
     status (PS_ALIVE),
@@ -103,7 +102,7 @@
 
 // Set the action of the pingu (bridger, blocker, bomber, etc.)
 // This function is used by external stuff, like the ButtonPanel, etc
-int
+bool
 Pingu::set_action(PinguAction* act)
 {
   assert(act);
@@ -112,7 +111,7 @@
     {
       if (pingus_debug_flags & PINGUS_DEBUG_ACTIONS)
        std::cout << _("Setting action to a dead pingu") << std::endl;
-      return 0;
+      return false;
     }
 
   act->set_pingu(this);
@@ -135,25 +134,25 @@
            {
              if (pingus_debug_flags & PINGUS_DEBUG_ACTIONS)
                std::cout << "Not using action, we have allready" << std::endl;
-             return 0;
+             return false;
            }
        }
 
       persist.push_back(act);
-      return 1;
+      return true;
     } 
   else 
     {
       if (act->get_environment() == (PinguEnvironment)ENV_ALWAYS)
        {
          action = act;
-         return 1;
+         return true;
        }
 
       // if environment is bad return
       if (!(act->get_environment() & environment))
        { 
-         return 0; 
+         return false; 
        }
     
       if (act->activation_time() == -1)
@@ -165,7 +164,7 @@
              return false;
            }
          action = act;
-         return 1;         
+         return true;      
        }
       else 
        { // Use the activation time, given by t
@@ -197,6 +196,7 @@
 void
 Pingu::set_paction(PinguAction* act) 
 {
+  assert(act);
   action = act;
   action->set_pingu(this);
 }
@@ -246,8 +246,8 @@
 void
 Pingu::update_persistent(float /*delta*/)
 {
-  // 
-  if (environment == ENV_AIR && !action && rel_getpixel(0, -1) == 
ColMap::NOTHING) 
+  // set floater action if required
+  if (environment == ENV_AIR && action->get_type() != (ActionType)FALL && 
rel_getpixel(0, -1) == ColMap::NOTHING) 
     {
       for (unsigned int i=0; i < persist.size(); ++i) 
        {
@@ -289,8 +289,7 @@
   
   if ( !action || action->is_finished) 
     {
-      // FIXME: needs a better name now
-      update_normal(delta);
+      update_action(delta);
     }
 
   update_persistent(delta);
@@ -299,7 +298,7 @@
 
 // Check if the pingu is on ground and then do something.
 void 
-Pingu::update_normal(float /*delta*/)
+Pingu::update_action(float /*delta*/)
 {
   std::cout << "Pingu: No action set, setting action." << std::endl;
   if (rel_getpixel(0,-1) == ColMap::NOTHING)
@@ -315,8 +314,7 @@
   char str[64];
   y += 2;
 
-  if (action) 
-    action->draw_offset(x, y,s);
+  action->draw_offset(x, y,s);
   
   if (action_time != -1) 
     {
@@ -357,10 +355,7 @@
   if (status == PS_DEAD)
     return false;
   
-  if (action)
-    return action->need_catch();
-  else 
-    return false;
+  return action->need_catch();
 }
 
 void
@@ -414,11 +409,7 @@
 bool 
 Pingu::catchable ()
 {
-  if (action)
-    return action->catchable ();
-  
-  std::cout << "Pingu:catchable: No action given, default to true" << 
std::endl;
-  return true;
+  return action->catchable ();
 }
 
 /* EOF */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]