pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.14,1.15 action_ho


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.14,1.15 action_holder.cxx,1.5,1.6 action_holder.hxx,1.7,1.8 capture_rectangle.cxx,1.9,1.10 capture_rectangle.hxx,1.5,1.6 pingu.cxx,1.31,1.32 pingus_main.cxx,1.21,1.22
Date: 4 Oct 2002 11:38:31 -0000

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

Modified Files:
        action_button.cxx action_holder.cxx action_holder.hxx 
        capture_rectangle.cxx capture_rectangle.hxx pingu.cxx 
        pingus_main.cxx 
Log Message:
- removed a few FIXME
- some minor clean/speed up


Index: action_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- action_button.cxx   3 Oct 2002 01:02:12 -0000       1.14
+++ action_button.cxx   4 Oct 2002 11:38:28 -0000       1.15
@@ -129,21 +129,18 @@
   // FIXME: around, doesn't look like a good idea. 
   available = action_holder->get_available(name);
 
-  if (unlimited_actions) {
-    str = "";
-  } else {
+  if (!unlimited_actions)
     str = to_string(available);
-  }
 
   if (pressed) 
     {
       if (fast_mode) {
-       CL_Display::fill_rect(x_pos, y_pos, x_pos + 60, y_pos + 35 ,
+       CL_Display::fill_rect(x_pos, y_pos, x_pos + 60, y_pos + 35,
                              1.0, 1.0, 1.0, 1.0);
       } else {
        //CL_Display::fill_rect(x_pos, y_pos, x_pos + 60, y_pos + 35 ,
        //1.0, 1.0, 1.0, 0.5);
-       backgroundhl.put_screen (x_pos, y_pos);
+       backgroundhl.put_screen(x_pos, y_pos);
       }
       font_h->print_center(x_pos + 46, y_pos + 10, str.c_str ());
     }
@@ -161,22 +158,23 @@
 
   // print the action name next to the button, when mouse pointer is on
   // the button.
-  if(action_help 
-     && CL_Mouse::get_x() > x_pos && CL_Mouse::get_x() < x_pos + 60
-     && CL_Mouse::get_y() < y_pos + 35 && CL_Mouse::get_y() > y_pos) 
+  if (    action_help 
+      && CL_Mouse::get_x() > x_pos      && CL_Mouse::get_x() < x_pos + 60
+      && CL_Mouse::get_y() < y_pos + 35 && CL_Mouse::get_y() > y_pos) 
   {
-       font_b->print_left (x_pos + 65, y_pos, action_to_string(name).c_str());
+       font_b->print_left(x_pos + 65, y_pos, action_to_string(name).c_str());
   }
 
   surface.put_screen(x_pos + 20 - surface.get_width ()/2,
-                    y_pos + 17 - surface.get_height ()/2,
+                    y_pos + 17 - surface.get_height()/2,
                     action_c);
   UNUSED_ARG(gc);
 }
 
 ArmageddonButton::ArmageddonButton (Server* s, int x, int y)
   : server (s),
-    x_pos (x), y_pos (y),
+    x_pos (x),
+    y_pos (y),
     background  (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
     backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
 {

Index: action_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_holder.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- action_holder.cxx   23 Aug 2002 15:49:47 -0000      1.5
+++ action_holder.cxx   4 Oct 2002 11:38:28 -0000       1.6
@@ -25,9 +25,9 @@
 
 ActionHolder::ActionHolder (PLF* plf)
 {
-  std::vector<ActionData> action_data = plf->get_actions ();
+  std::vector<ActionData> action_data = plf->get_actions();
   
-  for(std::vector<ActionData>::iterator i = action_data.begin(); i != 
action_data.end(); ++i) {
+  for (std::vector<ActionData>::iterator i = action_data.begin(); i != 
action_data.end(); ++i) {
     set_actions(i->name, i->number_of);
   }
 }
@@ -37,33 +37,33 @@
   //FIXME: This is not really a good place to free the actions
   //FIXME: But not otherwise to possible at the moment due to the
   //FIXME: singleton thing.
-  PinguActionFactory::instance ()->delete_actions ();
+  PinguActionFactory::instance()->delete_actions();
 }
 
 void
-ActionHolder::set_actions(ActionName name, int available)
+ActionHolder::set_actions (ActionName name, int available)
 {
   available_actions[name] = available;
 }
 
 void
-ActionHolder::push_action(ActionName name)
+ActionHolder::push_action (ActionName name)
 {
   available_actions[name]++;
 }
 
 int
-ActionHolder::get_available(ActionName name)
+ActionHolder::get_available (ActionName name)
 {
   return available_actions[name];
 }
 
 PinguAction*
-ActionHolder::get_action(ActionName name)
+ActionHolder::get_action (ActionName name)
 {
   if (unlimited_actions) // runtime option; defined in global.hh
     {    
-      return PinguActionFactory::instance ()->create(name);
+      return PinguActionFactory::instance()->create(name);
     } 
   else 
     {
@@ -71,7 +71,7 @@
       if (count > 0) 
        {
          --count;
-         return PinguActionFactory::instance ()->create(name);
+         return PinguActionFactory::instance()->create(name);
        }
       else // Out of actions
        {

Index: action_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_holder.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- action_holder.hxx   27 Sep 2002 11:26:43 -0000      1.7
+++ action_holder.hxx   4 Oct 2002 11:38:28 -0000       1.8
@@ -55,25 +55,25 @@
    * @param name the name of the action
    * @param available the number of actions available
    */
-  void set_actions(ActionName name, int available);
+  void set_actions (ActionName name, int available);
   
   /** Adds an action to the pool of actions, making one more action available
    * @param name the name of the action
    */
-  void push_action(ActionName name);
+  void push_action (ActionName name);
 
   /** Returns the number of actions of the specified name which are available 
    *  thru get_action() 
    * @return 0 if the name is unknown FIXME: should use .find instead of []
    */
-  int  get_available(ActionName);
+  int get_available (ActionName);
 
   /** Returns a newly allocated or cached action by a given name. It
    *  returns it from the action pool and decreases the number of available
    *  actions if necessary. If the actions are out, it returns 0. 
    *  The deletion of the action is handled by this class.  
    */
-  PinguAction* get_action(ActionName);
+  PinguAction* get_action (ActionName);
   
 private:
   ActionHolder (const ActionHolder&);

Index: capture_rectangle.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- capture_rectangle.cxx       2 Oct 2002 19:20:18 -0000       1.9
+++ capture_rectangle.cxx       4 Oct 2002 11:38:28 -0000       1.10
@@ -27,75 +27,48 @@
 #include "globals.hxx"
 #include "string_converter.hxx"
 
-CaptureRectangle::CaptureRectangle(ButtonPanel* arg_button_panel)
-  : pingu (0),
-    owner_id (0),
-    good (PingusResource::load_surface("Cursors/capgood", "game")),
-    bad (PingusResource::load_surface("Cursors/capbad",  "game")),
-    arrow_left (PingusResource::load_surface("Cursors/arrow_left",  "game")),
-    arrow_right (PingusResource::load_surface("Cursors/arrow_right", "game")),
+CaptureRectangle::CaptureRectangle (ButtonPanel* arg_button_panel)
+  : pingu(0),
+    owner_id(0),
+    good(PingusResource::load_surface("Cursors/capgood", "game")),
+    bad(PingusResource::load_surface("Cursors/capbad",  "game")),
+    arrow_left(PingusResource::load_surface("Cursors/arrow_left",  "game")),
+    arrow_right(PingusResource::load_surface("Cursors/arrow_right", "game")),
     button_panel(arg_button_panel),
-    font (PingusResource::load_font("Fonts/courier_small", "fonts"))
+    font(PingusResource::load_font("Fonts/courier_small", "fonts"))
 {
-  good.set_align_center ();
-  bad.set_align_center ();
-  arrow_left.set_align_center ();
-  arrow_right.set_align_center ();
+  good.set_align_center();
+  bad.set_align_center();
+  arrow_left.set_align_center();
+  arrow_right.set_align_center();
 }
 
-CaptureRectangle::~CaptureRectangle()
+CaptureRectangle::~CaptureRectangle ()
 {
 }
 
 void
-CaptureRectangle::draw_offset(int x_offset, int y_offset, float s)
+CaptureRectangle::draw_offset (int x_offset, int y_offset, float s)
 { 
-  if (pingu && pingu->catchable ())
+  if (pingu && pingu->catchable())
     {
-      Sprite * sur;
+      Sprite* sur;
       
       // FIXME: A check for surface good/bad should  be placed here
-      if (pingu->change_allowed (button_panel->get_action_name ()))
+      if (pingu->change_allowed(button_panel->get_action_name()))
        sur = &good;
       else
        sur = &bad;
       
       if (s == 1.0) 
-       { // FIXME: this should use GC and should probally be cached
-         // FIXME: as long as the pingu is the same
-         std::string action_str = pingu->get_action()->get_name();
-
-          PinguAction * wall_action = pingu->get_wall_action();
-          PinguAction * fall_action = pingu->get_fall_action();
-          
-          if (wall_action || fall_action) {
-          
-            action_str += " [";
-            
-            if (wall_action)
-              action_str += wall_action->get_persistent_char();
-              
-            if (fall_action)
-              action_str += fall_action->get_persistent_char();
-              
-            action_str += "]";
-          }
-         
-         if (maintainer_mode)
-           {
-             action_str += " Id: " + to_string(pingu->get_id());
-           }
+       { // FIXME: this should use GC
 
          // Draw the caputure rectangle
          sur->put_screen(pingu->get_center_pos() + Vector(x_offset,y_offset));
          
-         // If pingu has an action, print its name
-         if (pingu->get_action())
-           {
-             font->print_center(int(pingu->get_center_pos().x) + x_offset,
-                                int(pingu->get_center_pos().y) + y_offset - 32,
-                                action_str.c_str());
-           }
+         font->print_center(static_cast<int>(pingu->get_center_pos().x) + 
x_offset,
+                            static_cast<int>(pingu->get_center_pos().y) + 
y_offset - 32,
+                            action_str.c_str());
          /*font->print_center(pingu->get_center_pos().x + x_offset,
                             pingu->get_center_pos().y + y_offset - 16 + 62,
                             to_string(pingu->get_owner()).c_str());*/
@@ -104,25 +77,44 @@
          // Paint the direction arrow
          if (pingu->direction.is_left()) 
            {
-             arrow_left.put_screen(pingu->get_center_pos() + Vector (x_offset, 
y_offset + 28));
+             arrow_left.put_screen(pingu->get_center_pos() + Vector(x_offset, 
y_offset + 28));
            }
          else
            {
-             arrow_right.put_screen(pingu->get_center_pos() + Vector 
(x_offset, y_offset + 28));
+             arrow_right.put_screen(pingu->get_center_pos() + Vector(x_offset, 
y_offset + 28));
            }
        } 
       else 
        {
-         sur->put_screen(pingu->get_center_pos() + Vector (x_offset, 
y_offset));
+         sur->put_screen(pingu->get_center_pos() + Vector(x_offset, y_offset));
        }
     }
 }
 
 void
-CaptureRectangle::set_pingu(Pingu* p)
+CaptureRectangle::set_pingu (Pingu* p)
 {
-  pingu = p; 
+  pingu = p;
+  action_str = pingu->get_action()->get_name();
+  
+  if (pingu->get_wall_action() || pingu->get_fall_action())
+    {
+      action_str += "[";
+
+      if (pingu->get_wall_action())
+        action_str += pingu->get_wall_action()->get_persistent_char();
+
+      if (pingu->get_fall_action())
+        action_str += pingu->get_fall_action()->get_persistent_char();
+
+      action_str += "]";
+    }
+
+  if (maintainer_mode)
+    {
+      action_str += " Id: ";
+      action_str += to_string(pingu->get_id());
+    }
 }
 
 /* EOF */
-

Index: capture_rectangle.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- capture_rectangle.hxx       27 Sep 2002 11:26:43 -0000      1.5
+++ capture_rectangle.hxx       4 Oct 2002 11:38:28 -0000       1.6
@@ -35,7 +35,8 @@
 class CaptureRectangle
 {
 private:
-  Pingu*       pingu; 
+  Pingu*      pingu; 
+  std::string action_str;  
 
   /// The id of the owner of this capture rectangle
   int owner_id;
@@ -47,6 +48,7 @@
 
   ButtonPanel* button_panel;
   CL_Font* font;
+
 public:
   CaptureRectangle(ButtonPanel*);
   ~CaptureRectangle(); 

Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- pingu.cxx   3 Oct 2002 01:02:12 -0000       1.31
+++ pingu.cxx   4 Oct 2002 11:38:28 -0000       1.32
@@ -221,7 +221,7 @@
 void
 Pingu::set_action (ActionName action_name) 
 {
-  set_action (PinguActionFactory::instance ()->create (action_name));
+  set_action(PinguActionFactory::instance()->create(action_name));
 }
 
 // Sets an action without any checking

Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- pingus_main.cxx     3 Oct 2002 01:02:12 -0000       1.21
+++ pingus_main.cxx     4 Oct 2002 11:38:28 -0000       1.22
@@ -138,7 +138,7 @@
 }
 
 void
-PingusMain::read_rc_file(void)
+PingusMain::read_rc_file (void)
 {
   if (!no_config_file)
     {





reply via email to

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