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_holder.hxx,1.5,1.6 smallmap_im


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src action_holder.hxx,1.5,1.6 smallmap_image.cxx,1.5,1.6 true_server.cxx,1.6,1.7 world.cxx,1.22,1.23 world.hxx,1.10,1.11
Date: 14 Sep 2002 22:41:33 -0000

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

Modified Files:
        action_holder.hxx smallmap_image.cxx true_server.cxx world.cxx 
        world.hxx 
Log Message:
- some cleanup and docu

Index: action_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_holder.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- action_holder.hxx   25 Aug 2002 09:08:48 -0000      1.5
+++ action_holder.hxx   14 Sep 2002 22:41:31 -0000      1.6
@@ -46,6 +46,8 @@
   std::map<ActionName, int> available_actions;
 
 public:
+  /** Create an action holder from the number of actions given in a
+      PLF file */
   ActionHolder (PLF* plf);
   ~ActionHolder ();
 
@@ -62,7 +64,7 @@
 
   /** Returns the number of actions of the specified name which are available 
    *  thru get_action() 
-   * @return 0 if the name is unknown
+   * @return 0 if the name is unknown FIXME: should use .find instead of []
    */
   int  get_available(ActionName);
 
@@ -81,9 +83,3 @@
 #endif
 
 /* EOF */
-
-
-
-
-
-

Index: smallmap_image.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap_image.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- smallmap_image.cxx  23 Aug 2002 15:49:50 -0000      1.5
+++ smallmap_image.cxx  14 Sep 2002 22:41:31 -0000      1.6
@@ -56,9 +56,6 @@
   unsigned char  current_pixel;
   int tx, ty;
 
-  CL_Surface entrance_sur = 
PingusResource::load_surface("misc/smallmap_entrance", "core");
-  CL_Surface exit_sur     = PingusResource::load_surface("misc/smallmap_exit", 
"core");
-
   World* world = server->get_world();
 
   ColMap* colmap = world->get_colmap(); 
@@ -118,6 +115,13 @@
     }
 
 #if 0
+  /* This draws the exits and entrances to the smallmap, due to the
+     class reordering this is no longer working, a generic
+     WorldObj::draw_smallmap (SmallMap* / CL_Canvas*) should help
+     here. */
+  CL_Surface entrance_sur = 
PingusResource::load_surface("misc/smallmap_entrance", "core");
+  CL_Surface exit_sur     = PingusResource::load_surface("misc/smallmap_exit", 
"core");
+
   PLF* plf = world->get_plf();
 
   std::vector<ExitData>     exit_d     = plf->get_exit();
@@ -144,11 +148,6 @@
 
   canvas->unlock();
   
-  //  sur = CL_Surface(canvas, true);
-  
-  //rwidth = CL_Display::get_width() * width / 
client->get_server()->get_world()->get_colmap()->get_width();
-  //rheight = CL_Display::get_height() * height / 
client->get_server()->get_world()->get_colmap()->get_height();
-
   return CL_Surface(canvas, true);
 }
 

Index: true_server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- true_server.cxx     14 Sep 2002 19:06:33 -0000      1.6
+++ true_server.cxx     14 Sep 2002 22:41:31 -0000      1.7
@@ -47,10 +47,6 @@
   local_game_speed = game_speed;
 
   world = new World (plf);
-
-  // FIXME: this is complete trash, delete it and place it in world
-  // object or so...
-  world->set_action_holder(&action_holder);
 }
 
 TrueServer::~TrueServer()

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- world.cxx   14 Sep 2002 19:06:33 -0000      1.22
+++ world.cxx   14 Sep 2002 22:41:31 -0000      1.23
@@ -52,11 +52,10 @@
 // } 
 #endif
 
-World::World(PLF* arg_plf)
+World::World(PLF* plf)
   : game_time (new GameTime (game_speed)),
     particle_holder (new ParticleHolder()),
     pingus (new PinguHolder()),
-    plf (arg_plf),
     view (0)
 { 
   // Not perfect, but works
@@ -73,8 +72,60 @@
     std::cout << "World: Time is not in the tolerated range: " << exit_time << 
std::endl;
   shutdown_time = -1;
 
-  init_map();
-  init_worldobjs();
+  init_map(plf);
+  init_worldobjs(plf);
+}
+
+void
+World::init_map(PLF* plf)
+{
+  gfx_map = new PingusSpotMap(plf);
+  colmap = gfx_map->get_colmap();
+
+  world_obj.push_back (gfx_map);
+}
+
+void
+World::init_worldobjs(PLF* plf)
+{
+  vector<WeatherData>   weather_d  = plf->get_weather();
+  vector<WorldObjData*> worldobj_d = plf->get_worldobjs_data ();
+
+  for(vector<WeatherData>::iterator i = weather_d.begin();
+      i != weather_d.end();
+      ++i)
+    {
+      world_obj.push_back(WeatherGenerator::create(*i));
+    }
+
+  for (vector<WorldObjData*>::iterator i = worldobj_d.begin ();
+       i != worldobj_d.end ();
+       ++i)
+    {
+      WorldObj* obj = (*i)->create_WorldObj ();
+      if (obj)
+       {
+         world_obj.push_back(obj);
+       }
+      else
+       {
+         std::cout << "World: Couldn't create object from data" << std::endl;
+       }
+    }
+
+   world_obj.push_back(pingus);
+
+   //world_obj->sort(WorldObj_less);
+   std::stable_sort (world_obj.begin (), world_obj.end (), WorldObj_less);
+
+  // Drawing all world objs to the colmap
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
+    (*obj)->draw_colmap();
+
+  // Setup the gravity force
+  // Clear all old forces
+  ForcesHolder::clear_all_forces();
+  ForcesHolder::add_force(GravityForce(grav));
 }
 
 World::~World()
@@ -121,12 +172,14 @@
 {
   game_time->update ();
 
-  //std::cout << "World::update (" << delta << ")" << std::endl;
-
+  // if a exit condition is schedule a shutdown of the world in the
+  // next 75 ticks
   if (!exit_world && (allowed_pingus == released_pingus || do_armageddon)
       && pingus->size() == 0) 
     {
-      if (verbose) std::cout << "World: world finished, going down in the next 
seconds..." << endl;
+      if (verbose)
+       std::cout << "World: world finished, going down in the next seconds..." 
<< endl;
+
       exit_world = true;
       shutdown_time = game_time->get_ticks() + 75;
     }
@@ -163,58 +216,13 @@
       }
     }
 
+  // FIXME: Why is the particle holder still a seperate object?
   particle_holder->update(delta);
 
   // Clear the explosion force list
   ForcesHolder::clear_explo_list();
 }
 
-void
-World::init_map()
-{
-  gfx_map = new PingusSpotMap(plf);
-  colmap = gfx_map->get_colmap();
-
-  world_obj.push_back (gfx_map);
-}
-
-void
-World::init_worldobjs()
-{
-  vector<WeatherData>   weather_d  = plf->get_weather();
-  vector<WorldObjData*> worldobj_d = plf->get_worldobjs_data ();
-
-  for(vector<WeatherData>::iterator i = weather_d.begin();
-      i != weather_d.end();
-      ++i)
-    {
-      world_obj.push_back(WeatherGenerator::create(*i));
-    }
-
-  for (vector<WorldObjData*>::iterator i = worldobj_d.begin ();
-       i != worldobj_d.end ();
-       ++i)
-    {
-      WorldObj* obj = (*i)->create_WorldObj ();
-      if (obj)
-       world_obj.push_back(obj);
-    }
-
-   world_obj.push_back(pingus);
-
-   //world_obj->sort(WorldObj_less);
-   std::stable_sort (world_obj.begin (), world_obj.end (), WorldObj_less);
-
-  // Drawing all world objs to the colmap
-  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
-    (*obj)->draw_colmap();
-
-  // Setup the gravity force
-  // Clear all old forces
-  ForcesHolder::clear_all_forces();
-  ForcesHolder::add_force(GravityForce(grav));
-}
-
 PinguHolder*
 World::get_pingu_p(void)
 {
@@ -305,28 +313,16 @@
   return gfx_map;
 }
 
-ActionHolder*
+/*ActionHolder*
 World::get_action_holder ()
 {
   return action_holder;
-}
+}*/
 
 ParticleHolder* 
 World::get_particle_holder()
 {
   return particle_holder;
-}
-
-PLF*
-World::get_plf()
-{
-  return plf;
-}
-
-void
-World::set_action_holder(ActionHolder* a)
-{
-  action_holder = a;
 }
 
 void 

Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- world.hxx   4 Sep 2002 19:40:19 -0000       1.10
+++ world.hxx   14 Sep 2002 22:41:31 -0000      1.11
@@ -40,7 +40,6 @@
 class Trap;
 class View;
 class ColMap;
-class WorldImpl;
 class WorldObj;
 class GameTime;
 class GraphicContext;
@@ -55,23 +54,37 @@
 class World
 {
 private:
-  WorldImpl* impl;
-
+  /** groundmap for the pingus */
   PinguMap* gfx_map;
+
+  /** manager class for the time in the pingus world */
   GameTime* game_time;
+
+  /** set to true once an armageddon got started */
   bool do_armageddon;
+
+  /** FIXME: ugly hack to iterate over all pingus and make bombers out
+      of them, should use pingus_id instead */
   std::list<Pingu*>::iterator armageddon_count;
 
+  /** number of already released pingus */
   unsigned int released_pingus;
+
+  /** number of total pingus available in this level */
   unsigned int allowed_pingus;
+
+  /** number of pingus to save */
   unsigned int number_to_save;
+
+  /** */
   bool exit_world;
   
   /** End the world when the given time is reached, this is set by
       armageddon or similar events.  */
   int  shutdown_time;  
 
-  /// The time you have to finish a level
+  /** The time in which you have to finish a level, aka the time limit
+      of a level */
   int exit_time;
 
   std::vector<WorldObj*> world_obj;
@@ -84,11 +97,10 @@
   // Pointers which are references to objects from other classes
   ActionHolder*   action_holder;
   ColMap*         colmap;
-  PLF*            plf;
   View*           view;
 
-  void    init_worldobjs (void);
-  void    init_map (void);
+  void    init_worldobjs (PLF* plf);
+  void    init_map (PLF* plf);
 
 public:
   World(PLF*);
@@ -100,14 +112,17 @@
   /** Update the World */
   void    update (float delta);
 
-  /// Issue an armageddon, all Pingus will explode in some seconds.
+  /** Issue an armageddon, all Pingus will explode in some seconds. */
   void    armageddon ();
 
   /** @return The absolute height of the world. */
   int     get_height ();
   /** @return The absolute width of the world */
   int     get_width();
-  ///
+
+  /** @return true if the world is finished, meaning the time limit
+      has passed or the world is out of pingus (which is simulated by
+      the time => FIXME: hack) */
   bool    is_finished ();
 
   /** Returns the time passed since the level was started */
@@ -129,34 +144,43 @@
   /** @return A pointer to the worlds particle holder */
   ParticleHolder* get_particle_holder();
   
-  /** @return Pointer to the ActionHolder of the world */
-  ActionHolder* get_action_holder();
-
-  PLF* get_plf();
-
   unsigned int get_released_pingus() { return released_pingus; }
   void         inc_released_pingus() { ++released_pingus; }
-  unsigned int check_armageddon() { return do_armageddon; }
+
+  /** @return true if the world is currently doing an armageddon */
+  bool check_armageddon() { return do_armageddon; }
+
+  /** @return the number of totally allowed pingus */
   unsigned int get_allowed_pingus() { return allowed_pingus; }
-  unsigned int get_pingus_out();
-  unsigned int get_saved_pingus();
+
+  /** @return the number of pingus currently moving around in the
+      world, exited, killed and not yet released pingus are not
+      counted */
+  unsigned int get_pingus_out(); unsigned int get_saved_pingus(); 
+
+  /** @return number of pingus which need to get saved in this level
+      to finish it successfull */
   unsigned int get_number_to_save() { return number_to_save; }
 
   /** Play a sound as if it would have been generated at the given
       position, adjust panning and volume by the position relative to
       the center of the screen 
       @param name Filename of the wav file to play
-      @param pos Position from which the sound seems to come (z-pos is going 
to be ignored) void play_wav (std::string name, const
+      @param pos Position from which the sound seems to come (z-pos is
+      going to be ignored) void play_wav (std::string name, const
       @param volume The volume of the sound
   */
   void play_wav (std::string name, const CL_Vector& pos, float volume = 0.5f);
 
   /** Sets the main view, it is needed to play stereo wave and for
-      other screen orientated effects */
+      other screen orientated effects 
+
+      FIXME: This is really ugly and should be handled otherwise, by a
+      FIXME: play_sound (View*) analog to draw() and update() or something
+      FIXME: like that */
   void set_view (View* v);
 
   PinguHolder* get_pingu_p(void);
-  void set_action_holder(ActionHolder*);
 
   /** @return the pingu at the given word coordinates, an empty
       shared_ptr is returned if none is there */





reply via email to

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