pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src entrance.cxx,1.3,1.4 game_time.cxx,1.


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src entrance.cxx,1.3,1.4 game_time.cxx,1.3,1.4 game_time.hxx,1.3,1.4 server.cxx,1.6,1.7 true_server.cxx,1.2,1.3 world.cxx,1.11,1.12 world.hxx,1.3,1.4
Date: 28 Jun 2002 09:51:48 -0000

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

Modified Files:
        entrance.cxx game_time.cxx game_time.hxx server.cxx 
        true_server.cxx world.cxx world.hxx 
Log Message:
- changed gametime to become a member of the World instead of a singleton
- fixed a bug in the walker (a bridge on a hill works now)

Index: entrance.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/entrance.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- entrance.cxx        28 Jun 2002 08:32:20 -0000      1.3
+++ entrance.cxx        28 Jun 2002 09:51:46 -0000      1.4
@@ -23,6 +23,7 @@
 #include "entrance.hxx"
 #include "game_time.hxx"
 #include "pingu.hxx"
+#include "game_time.hxx"
 
 Entrance::Entrance(const EntranceData& data)
 {
@@ -38,8 +39,8 @@
 bool
 Entrance::pingu_ready()
 {
-  if (last_release < (GameTime::get_ticks() - release_rate)) {
-    last_release = GameTime::get_ticks();
+  if (last_release < (world->get_game_time()->get_ticks() - release_rate)) {
+    last_release = world->get_game_time()->get_ticks();
     return true;
   } else {
     return false;

Index: game_time.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_time.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- game_time.cxx       28 Jun 2002 08:32:20 -0000      1.3
+++ game_time.cxx       28 Jun 2002 09:51:46 -0000      1.4
@@ -20,7 +20,10 @@
 #include "globals.hxx"
 #include "game_time.hxx"
 
-int GameTime::count;
+GameTime::GameTime (int arg_tick_time)
+  : count (0), tick_time (arg_tick_time)
+{
+}
 
 int
 GameTime::get_time ()
@@ -41,9 +44,9 @@
 }
 
 void
-GameTime::increase(void)
+GameTime::update(void)
 {
-  ++count;
+  count += 1;
 }
 
 void

Index: game_time.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_time.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- game_time.hxx       28 Jun 2002 08:32:20 -0000      1.3
+++ game_time.hxx       28 Jun 2002 09:51:46 -0000      1.4
@@ -30,24 +30,29 @@
 {
 private:
   /** Tick counter */
-  static int count;
+  int count;
+  
+  /** How long does a tick take in msec */
+  int tick_time;
 
 public:
+  GameTime (int arg_tick_time);
+  
   /** Number of ticks since the time starts, a tick is one basically
       update call to the world */
-  static int  get_ticks(void);
+  int  get_ticks(void);
 
   /** Return the passed time in miliseconds (1000msec = 1sec) */
-  static int get_time ();
+  int get_time ();
 
   /** Return in realtime (milisecondons ) how long a tick normally takes */
-  static int get_tick_time ();
+  int get_tick_time ();
 
   /** Increase the tick count */
-  static void increase(void);
+  void update(void);
   
   /** Start from zero */
-  static void reset(void);
+  void reset(void);
 };
 
 #endif

Index: server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- server.cxx  28 Jun 2002 08:32:20 -0000      1.6
+++ server.cxx  28 Jun 2002 09:51:46 -0000      1.7
@@ -26,6 +26,7 @@
 #include "pingu_holder.hxx"
 #include "pingus_error.hxx"
 #include "string_converter.hxx"
+#include "game_time.hxx"
 #include "world.hxx"
 
 using namespace std;
@@ -104,7 +105,7 @@
 void
 Server::send_event(std::string event)
 {
-  recorder.queue_event(to_string(GameTime::get_ticks()) + ":" + event);
+  recorder.queue_event(to_string(world->get_game_time ()->get_ticks()) + ":" + 
event);
   process_event(event);
 }
 

Index: true_server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- true_server.cxx     13 Jun 2002 14:25:12 -0000      1.2
+++ true_server.cxx     28 Jun 2002 09:51:46 -0000      1.3
@@ -52,8 +52,6 @@
   // FIXME: this is complete trash, delete it and place it in world
   // object or so...
   world->set_action_holder(&action_holder);
-
-  GameTime::reset();
 }
 
 TrueServer::~TrueServer()
@@ -75,20 +73,17 @@
        {
          // To let the game run faster we just update it multiple
          // times
-          GameTime::increase();
-         Server::update(delta);
-         world->update(delta);
-          GameTime::increase();
-         Server::update(delta);
-         world->update(delta);
-          GameTime::increase();
+         for (int i = 0; i < 4; ++i)
+           {
+             Server::update(delta);
+             world->update(delta);
+           }
+       }
+      else
+       {
          Server::update(delta);
          world->update(delta);
        }
-
-      GameTime::increase();
-      Server::update(delta);
-      world->update(delta);
     }
 }
 

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- world.cxx   28 Jun 2002 08:32:20 -0000      1.11
+++ world.cxx   28 Jun 2002 09:51:46 -0000      1.12
@@ -30,6 +30,7 @@
 #include "particles/weather_generator.hxx"
 #include "pingu.hxx"
 #include "worldobj_data.hxx"
+#include "game_time.hxx"
 
 using namespace std;
 using boost::shared_ptr;
@@ -56,7 +57,8 @@
 #endif
 
 World::World(PLF* arg_plf)
-  : world_obj (new std::list<WorldObj*>),
+  : game_time (new GameTime (game_speed)),
+    world_obj (new std::list<WorldObj*>),
     particle_holder (new ParticleHolder()),
     pingus (new PinguHolder()),
     plf (arg_plf),
@@ -89,6 +91,7 @@
   }
   
   delete world_obj;
+  delete game_time;
 }
 
 // Merge the different layers on the screen together
@@ -118,6 +121,8 @@
 void 
 World::update(float delta)
 {
+  game_time->update ();
+
   //std::cout << "World::update (" << delta << ")" << std::endl;
 
   if (!exit_world && (allowed_pingus == released_pingus || do_armageddon)
@@ -125,7 +130,7 @@
     {
       if (verbose) std::cout << "World: world finished, going down in the next 
seconds..." << endl;
       exit_world = true;
-      shutdown_time = GameTime::get_ticks() + 75;
+      shutdown_time = game_time->get_ticks() + 75;
     }
 
   if (do_armageddon && armageddon_count != pingus->end())
@@ -134,21 +139,7 @@
       (*armageddon_count)->request_set_action("bomber");
       armageddon_count++;
     }
-  
-  // Create new pingus, if enough time is passed
-  /*
-    if (!do_armageddon)
-    {
-    for(vector<shared_ptr<Entrance> >::iterator i = entrance.begin(); i != 
entrance.end(); i++) 
-    {
-    if ((*i)->pingu_ready() && (unsigned int)pingus->total_size() < 
allowed_pingus)
-    {
-    pingus->push_back((*i)->get_pingu());
-    ++released_pingus;
-    }
-    }
-    }*/
-  
+    
   // Let all pingus move and
   // Let the pingus catch each other and
   // Let the traps catch the pingus and
@@ -160,6 +151,9 @@
       (*obj)->update(delta);
     }
   
+  // FIXME: This is a relictn, pingus should handle that themself
+  // FIXME: WorldObj::for_each_pingu (Func f); might cause throuble
+  // FIXME: with MSVC
   for(PinguIter pingu = pingus->begin(); pingu != pingus->end(); ++pingu) {
 
       (*pingu)->update(delta);
@@ -257,7 +251,7 @@
 {
   if (exit_time != -1) // There is a time limit
     {
-      return exit_time - GameTime::get_ticks();
+      return exit_time - game_time->get_ticks();
     }
   else // No timelimit given
     {
@@ -268,7 +262,7 @@
 int
 World::get_time_passed()
 {
-  return GameTime::get_ticks();
+  return game_time->get_ticks();
 }
 
 unsigned int
@@ -294,11 +288,11 @@
 World::is_finished(void)
 {
   // Return true if the world is finished and some time has passed
-  if (((exit_time != -1) && (exit_time < (GameTime::get_ticks())))
-      || ((shutdown_time != -1) && shutdown_time < GameTime::get_ticks()))
+  if (((exit_time != -1) && (exit_time < (game_time->get_ticks())))
+      || ((shutdown_time != -1) && shutdown_time < game_time->get_ticks()))
     {
       std::cout << "ExitTime: " << exit_time << std::endl
-               << "GameTime: " << GameTime::get_ticks() << std::endl
+               << "GameTime: " << game_time->get_ticks() << std::endl
                << "ShutDown: " << shutdown_time << std::endl;
       return true;
     } 
@@ -391,6 +385,12 @@
   }
   
   return current_pingu;
+}
+
+GameTime*
+World::get_game_time ()
+{
+  return game_time;
 }
 
 /* EOF */

Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- world.hxx   24 Jun 2002 22:52:57 -0000      1.3
+++ world.hxx   28 Jun 2002 09:51:46 -0000      1.4
@@ -40,6 +40,7 @@
 class ColMap;
 class WorldImpl;
 class WorldObj;
+class GameTime;
 
 /** The World holds all objects of the pingu enviroment. 
     
@@ -52,6 +53,7 @@
   WorldImpl* impl;
 
   PinguMap* gfx_map;
+  GameTime* game_time;
   bool do_armageddon;
   std::list<Pingu*>::iterator armageddon_count;
 
@@ -160,6 +162,9 @@
   /** @return the pingu at the given word coordinates, an empty
       shared_ptr is returned if none is there */
   Pingu* get_pingu (const CL_Vector& pos);
+  
+  /** Return a pointer to the GameTime object of this World */
+  GameTime* get_game_time ();
 };
 
 #endif




reply via email to

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