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.35,1.36 pingu_action.cxx,


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu.cxx,1.35,1.36 pingu_action.cxx,1.8,1.9 pingu_action.hxx,1.18,1.19 pingu_action_factory.cxx,1.8,1.9 pingu_action_factory.hxx,1.7,1.8
Date: 13 Oct 2002 16:40:01 -0000

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

Modified Files:
        pingu.cxx pingu_action.cxx pingu_action.hxx 
        pingu_action_factory.cxx pingu_action_factory.hxx 
Log Message:
Pingu* is now a constructor parameter of a PinguAction, set_pingu() is no 
longer necesarry

Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- pingu.cxx   12 Oct 2002 00:49:10 -0000      1.35
+++ pingu.cxx   13 Oct 2002 16:39:55 -0000      1.36
@@ -55,8 +55,7 @@
 
   // Initialisize the action, after this step the action ptr will
   // always be valid in the pingu class
-  action = PinguActionFactory::instance()->create(Faller);
-  action->set_pingu(this);
+  action = PinguActionFactory::instance()->create(this, Faller);
 }
 
 Pingu::~Pingu ()
@@ -219,13 +218,13 @@
 bool 
 Pingu::request_set_action (ActionName action_name)
 {
-  return request_set_action (PinguActionFactory::instance ()->create 
(action_name));
+  return request_set_action (PinguActionFactory::instance ()->create (this, 
action_name));
 }
 
 void
 Pingu::set_action (ActionName action_name) 
 {
-  set_action(PinguActionFactory::instance()->create(action_name));
+  set_action(PinguActionFactory::instance()->create(this, action_name));
 }
 
 // Sets an action without any checking
@@ -237,7 +236,6 @@
   previous_action = action->get_type();
 
   action = act;
-  action->set_pingu(this);
 }
 
 bool

Index: pingu_action.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingu_action.cxx    16 Sep 2002 20:31:09 -0000      1.8
+++ pingu_action.cxx    13 Oct 2002 16:39:58 -0000      1.9
@@ -27,20 +27,13 @@
 // Initialise class static.
 const int PinguAction::pingu_height = 26;
 
-PinguAction::PinguAction () : pingu (0)
+PinguAction::PinguAction (Pingu* p)
+  : pingu (p)
 {
 }
 
 PinguAction::~PinguAction ()
 {
-}
-
-void
-PinguAction::set_pingu (Pingu* pingu_data)
-{
-  pingu = pingu_data;
-  assert(pingu);
-  init();
 }
 
 // Checks if the pingu action needs to catch another pingu (needed for 

Index: pingu_action.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.hxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- pingu_action.hxx    12 Oct 2002 00:49:10 -0000      1.18
+++ pingu_action.hxx    13 Oct 2002 16:39:58 -0000      1.19
@@ -48,8 +48,7 @@
   static const int pingu_height;
 
 public:
-
-  PinguAction();
+  PinguAction(Pingu* p);
   virtual ~PinguAction();
 
   /// Gives the PinguAction class access to the data of the Pingu.
@@ -67,11 +66,6 @@
   /** Checks if this action allows to be overwritten with the given new action 
*/
   virtual bool change_allowed (Actions::ActionName) { return true; }
   
-  /** Used to load all data, which is needed by the action, its
-      seperated and called in set_pingu(), because some data will be
-      only valid if set_pingu() is called. */
-  virtual void init (void) {};
-
   /// The "AI" of the pingu.
   virtual void update () = 0;
 

Index: pingu_action_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action_factory.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingu_action_factory.cxx    25 Aug 2002 09:08:48 -0000      1.8
+++ pingu_action_factory.cxx    13 Oct 2002 16:39:59 -0000      1.9
@@ -94,7 +94,7 @@
 }
 
 PinguAction* 
-PinguActionFactory::create (ActionName id)
+PinguActionFactory::create (Pingu* pingu, ActionName id)
 {
   std::map<ActionName, PinguActionAbstractFactory*>::iterator it = 
factories.find(id);
   
@@ -102,7 +102,7 @@
     PingusError::raise("PinguActionFactory: Invalid id: " + id);
   else 
     {
-      PinguAction* action = it->second->create ();
+      PinguAction* action = it->second->create (pingu);
       all_actions.push_back (action);
       return action;
     }

Index: pingu_action_factory.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action_factory.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pingu_action_factory.hxx    27 Sep 2002 11:26:44 -0000      1.7
+++ pingu_action_factory.hxx    13 Oct 2002 16:39:59 -0000      1.8
@@ -49,7 +49,7 @@
   void delete_actions ();
 
   /** Allocate the given action */
-  PinguAction* create (Actions::ActionName id);
+  PinguAction* create (Pingu* p, Actions::ActionName id);
   
 private:
   PinguActionFactory (const PinguActionFactory&);
@@ -63,7 +63,7 @@
     PinguActionFactory::instance ()-> register_factory (id, this);
   }
   
-  virtual PinguAction* create () =0;
+  virtual PinguAction* create (Pingu* p) =0;
   
 private:
   PinguActionAbstractFactory (const PinguActionAbstractFactory&);
@@ -79,8 +79,8 @@
   {
   }
 
-  PinguAction* create () {
-    return new T ();
+  PinguAction* create (Pingu* p) {
+    return new T (p);
   }
   
 private:





reply via email to

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