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.14,1.15 pingu.hxx,1.6,1.7


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.14,1.15 pingu.hxx,1.6,1.7 pingu_action.hxx,1.4,1.5 pingu_enums.hxx,1.2,1.3 string_converter.cxx,1.3,1.4 string_converter.hxx,1.2,1.3 world.cxx,1.9,1.10
Date: 26 Jun 2002 19:13:15 -0000

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

Modified Files:
        pingu.cxx pingu.hxx pingu_action.hxx pingu_enums.hxx 
        string_converter.cxx string_converter.hxx world.cxx 
Log Message:
- removed PinguEnvironment, this might cause lots of action bugs, but it makes 
the code cleaner
- testers are welcome again to test
- persistant handling is still ugly, should be moved completly out of pingu.?xx

Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- pingu.cxx   26 Jun 2002 17:43:18 -0000      1.14
+++ pingu.cxx   26 Jun 2002 19:13:13 -0000      1.15
@@ -31,6 +31,7 @@
 #include "pingu_action_factory.hxx"
 #include "my_gettext.hxx"
 #include "debug.hxx"
+#include "string_converter.hxx"
 
 const float deadly_velocity = 20.0;
 int   Pingu::id_counter = 0;
@@ -42,7 +43,6 @@
     id (++id_counter),
     font (PingusResource::load_font("Fonts/numbers", "fonts")),
     owner_id (owner),
-    environment (ENV_LAND),
     status (PS_ALIVE),
     pos (arg_pos)
 {
@@ -81,13 +81,6 @@
   return id;
 }
 
-// Returns environment
-PinguEnvironment
-Pingu::get_environment()
-{
-  return environment;
-}
-
 bool
 Pingu::change_allowed (const std::string& new_action)
 {
@@ -123,11 +116,10 @@
       pout(PINGUS_DEBUG_ACTIONS) << _("Setting action to a dead pingu") << 
std::endl;
       return false;
     }
-
   act->set_pingu(this);
 
   // check for persistent actions
-  if (act->get_type() != (ActionType)ONCE) 
+  if (act->get_type() != (ActionType)ONCE) // action is persistent
     {
       pout(PINGUS_DEBUG_ACTIONS) << "Pingu: Found some persistant action" << 
std::endl
                                 << "Pingu: Action is " 
@@ -144,21 +136,9 @@
 
       persist.push_back(act);
       return true;
-    } 
+    }
   else 
-    {
-      if (act->get_environment() == (PinguEnvironment)ENV_ALWAYS)
-       {
-         action = act;
-         return true;
-       }
-
-      // if environment is bad return
-      if (!(act->get_environment() & environment))
-       { 
-         return false; 
-       }
-    
+    {  
       if (act->activation_time() == -1)
        { // Immediately activate the action
          if (action && (action->get_name() == act->get_name()))
@@ -166,10 +146,18 @@
              pout(PINGUS_DEBUG_ACTIONS) << "Pingu: Already have action" << 
std::endl;
              return false;
            }
-         action = act;
-         return true;      
+
+         if (act->change_allowed (string_downcase(action->get_name ()))) 
//FIXME: ugly
+           {
+             set_action (act);
+             return true;
+           }
+         else
+           {
+             return false;         
+           }
        }
-      else 
+      else // timed action
        {
          if (countdown_action && countdown_action->get_name() == 
act->get_name())
            { // We skip the action, since it is already set
@@ -178,8 +166,8 @@
          // We set the action and start the countdown
          action_time = act->activation_time();
          countdown_action = act;
+         return true;
        }
-      return true;
     }
 }
 
@@ -246,24 +234,6 @@
   return sqrt(((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y)));
 }
 
-void
-Pingu::update_persistent(float /*delta*/)
-{
-  // set floater action if required
-  if (environment == ENV_AIR
-      && action->get_type() != (ActionType)FALL && rel_getpixel(0, -1) == 
GroundpieceData::GP_NOTHING) 
-    {
-      for (unsigned int i=0; i < persist.size(); ++i) 
-       {
-         if (persist[i]->get_type() == (ActionType)FALL) 
-           {
-             // FIXME: Use action slots instead of the persistend vector
-              set_action("floater");
-           }
-       }
-    }
-}
-
 // Let the pingu do his job (i.e. walk his way)
 // FIXME: This function is *much* too large, it needs a real cut down
 // into smaller pieces.  
@@ -303,7 +273,6 @@
       update_action(delta);
     }
 
-  update_persistent(delta);
   action->update(delta);
 }
 

Index: pingu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pingu.hxx   26 Jun 2002 17:43:18 -0000      1.6
+++ pingu.hxx   26 Jun 2002 19:13:13 -0000      1.7
@@ -76,7 +76,6 @@
 
   // The stat of the pingu, these can be modified by PinguActions
   
-  PinguEnvironment environment;
   PinguStatus status;
   /// The postion of the pingu (CL_Vector::z is always zero)
   CL_Vector pos;
@@ -109,8 +108,6 @@
   /** Returns the y position of the pingu
       For backward comp. only */
   int  get_y(void);
-  ///
-  PinguEnvironment get_environment(); 
 
   /** Checks if this action allows to be overwritten with the given new action 
*/
   bool change_allowed (const std::string&);
@@ -171,22 +168,12 @@
   /** Returns true if the pingu needs to catch another pingu */
   bool need_catch();
   
-  ///
   void draw_offset(int x, int y, float s = 1.0);
-  ///
   void apply_force(CL_Vector);
-
-  ///
+  
   void update(float delta);
-  ///
-  void update_persistent(float delta);
-  ///
   void update_action(float delta);
-  ///
-  //void update_falling(float delta);
-  ///
-  //void update_walking(float delta);
-
+  
   /** Indicate if the pingu's speed is above the deadly velocity */
   //bool is_tumbling () const;
   

Index: pingu_action.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pingu_action.hxx    24 Jun 2002 22:52:55 -0000      1.4
+++ pingu_action.hxx    26 Jun 2002 19:13:13 -0000      1.5
@@ -67,10 +67,6 @@
    */
   int  rel_getpixel(int x, int y);
 
-  /** Returns the enviroment, used to check if an action can be
-      applied. */
-  virtual PinguEnvironment get_environment() const =0;
-
   /** Checks if this action allows to be overwritten with the given new action 
*/
   virtual bool change_allowed (const std::string&) { return true; }
   

Index: pingu_enums.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_enums.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingu_enums.hxx     24 Jun 2002 22:52:55 -0000      1.2
+++ pingu_enums.hxx     26 Jun 2002 19:13:13 -0000      1.3
@@ -24,15 +24,6 @@
     good idea. Maybe that should be changed to a bitmask. */
 enum PinguStatus { PS_ALIVE, PS_EXITED, PS_DEAD };
 
-/// The environment in which a PinguAction get be activated.
-enum PinguEnvironment {
-  ENV_LAND   = 1<<0,
-  ENV_WATER  = 1<<1,
-  ENV_FIRE   = 1<<2,
-  ENV_AIR    = 1<<3,
-  ENV_ALWAYS = ~0
-};
-
 ///
 enum PingusGameMode { 
   INTERACTIVE_MODE,

Index: string_converter.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/string_converter.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- string_converter.cxx        20 Jun 2002 11:23:53 -0000      1.3
+++ string_converter.cxx        26 Jun 2002 19:13:13 -0000      1.4
@@ -20,6 +20,8 @@
 #include <stdio.h>
 #include "string_converter.hxx"
 
+using namespace std;
+
 int 
 StringConverter::to_int(const std::string& str)
 {
@@ -64,6 +66,20 @@
   char buffer[256];
   sprintf (buffer, "%f", i);
   return buffer;
+}
+
+std::string string_upcase (const std::string& str)
+{
+  std::string name = str;
+  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+  return name;
+}
+
+std::string string_downcase (const std::string& str)
+{
+  std::string name = str;
+  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+  return name;
 }
 
 /* EOF */

Index: string_converter.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/string_converter.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- string_converter.hxx        24 Jun 2002 22:52:57 -0000      1.2
+++ string_converter.hxx        26 Jun 2002 19:13:13 -0000      1.3
@@ -69,6 +69,9 @@
   x = temp;
 }
 
+std::string string_upcase (const std::string&);
+std::string string_downcase (const std::string&);
+
 class StringConverter
 {
 private:

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- world.cxx   21 Jun 2002 08:11:27 -0000      1.9
+++ world.cxx   26 Jun 2002 19:13:13 -0000      1.10
@@ -130,7 +130,8 @@
 
   if (do_armageddon && armageddon_count != pingus->end())
     {
-      (*armageddon_count)->set_action("bomber");
+      // The iterator here might be invalid
+      (*armageddon_count)->request_set_action("bomber");
       armageddon_count++;
     }
   




reply via email to

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