pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.24,1.25 client.hxx,1.20,


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.24,1.25 client.hxx,1.20,1.21 exit_menu.cxx,1.10,1.11 exit_menu.hxx,1.8,1.9 game_session.cxx,1.12,1.13 game_session.hxx,1.8,1.9 gui_screen.cxx,1.9,1.10 gui_screen.hxx,1.10,1.11 input_debug_screen.cxx,1.3,1.4 input_debug_screen.hxx,1.3,1.4 option_menu.cxx,1.7,1.8 option_menu.hxx,1.6,1.7 pingus_menu_manager.cxx,1.14,1.15 pingus_menu_manager.hxx,1.13,1.14 screen.hxx,1.9,1.10 screen_manager.cxx,1.18,1.19 sprite.cxx,1.8,1.9 story.cxx,1.12,1.13 story.hxx,1.9,1.10 true_server.cxx,1.12,1.13 true_server.hxx,1.7,1.8
Date: 1 Oct 2002 21:48:34 -0000

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

Modified Files:
        client.cxx client.hxx exit_menu.cxx exit_menu.hxx 
        game_session.cxx game_session.hxx gui_screen.cxx 
        gui_screen.hxx input_debug_screen.cxx input_debug_screen.hxx 
        option_menu.cxx option_menu.hxx pingus_menu_manager.cxx 
        pingus_menu_manager.hxx screen.hxx screen_manager.cxx 
        sprite.cxx story.cxx story.hxx true_server.cxx true_server.hxx 
Log Message:
some trying around with the timing code

Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- client.cxx  28 Sep 2002 11:52:21 -0000      1.24
+++ client.cxx  1 Oct 2002 21:48:32 -0000       1.25
@@ -111,42 +111,11 @@
 void 
 Client::update (float delta)
 {
-  // Let the server process a game loop
-  //send_next_event();
-
-  /*float wannabe_delta = 0.0333f;
-    unsigned int frames = 1;
-    bool auto_frame_skip = false;
-    float current_delta;*/
-
   if (server->is_finished())
     {
       std::cout << "Client: update(): Server is finished" << std::endl;
       ScreenManager::instance ()->pop_screen ();
     }
-
-  /*
-    CL_System::keep_alive ();
-    CL_System::sleep (0);
-
-    if (current_delta > wannabe_delta)
-    {
-    update (delta.getset ());
-    ++frames;
-    if (frames % int(frame_skip) == 0)
-    {
-    if (!auto_frame_skip)
-    {
-    draw ();
-    }
-    }
-    else
-    {
-    CL_System::sleep (int(1000 * (wannabe_delta - delta.get ())));
-    }
-    }*/
-    
-  if(delta);
 }
 
 #if 0
@@ -438,12 +407,13 @@
     button_panel->previous_action ();
 }
 
-void
+bool
 Client::draw (GraphicContext& gc)
 {
   GUIScreen::draw (gc);
   if (!server->get_plf()->get_playable())
     gc.draw(unplayable, Vector(400, 50));
+  return true;
 }
 
 void

Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- client.hxx  1 Oct 2002 19:53:44 -0000       1.20
+++ client.hxx  1 Oct 2002 21:48:32 -0000       1.21
@@ -104,7 +104,7 @@
   void on_mouse_button_release(const CL_Key &key);
 
   // Overloaded GUIScreen stuff
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
   void on_startup ();
   void on_shutdown ();
 

Index: exit_menu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/exit_menu.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- exit_menu.cxx       28 Sep 2002 11:52:21 -0000      1.10
+++ exit_menu.cxx       1 Oct 2002 21:48:32 -0000       1.11
@@ -82,7 +82,7 @@
 {
 }
 
-void 
+bool 
 ExitMenu::draw (GraphicContext& gc)
 {
   CL_Display::fill_rect (0, 0, CL_Display::get_width (), 
CL_Display::get_height (),
@@ -90,6 +90,7 @@
   sur.put_screen (CL_Display::get_width ()/2 - sur.get_width ()/2, 
                  CL_Display::get_height ()/2 - sur.get_height ()/2);
   UNUSED_ARG(gc);
+  return true;
 }
 
 void 

Index: exit_menu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/exit_menu.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- exit_menu.hxx       27 Sep 2002 11:26:43 -0000      1.8
+++ exit_menu.hxx       1 Oct 2002 21:48:32 -0000       1.9
@@ -34,7 +34,7 @@
   ExitMenu (PingusMenuManager* manager);
   ~ExitMenu ();
 
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
   void update (float delta);
   void preload ();
   

Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- game_session.cxx    1 Oct 2002 19:53:44 -0000       1.12
+++ game_session.cxx    1 Oct 2002 21:48:32 -0000       1.13
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <ClanLib/Core/System/system.h>
 #include <iostream>
 #include "client.hxx"
 #include "true_server.hxx"
@@ -24,6 +25,7 @@
 #include "game_session_result.hxx"
 #include "timer.hxx"
 #include "plf.hxx"
+#include "globals.hxx"
 
 PingusGameSession::PingusGameSession (std::string arg_filename)
   : filename (arg_filename)
@@ -41,6 +43,12 @@
   timer.start();
   client = new Client(server);
   std::cout << "Timer: Client creation took: " << timer.stop() << std::endl;
+
+  last_redraw = CL_System::get_time();
+  last_update = CL_System::get_time();
+  
+  frames = 0;
+  frame_skips = 0;
 }
 
 PingusGameSession::~PingusGameSession ()
@@ -56,16 +64,40 @@
   return PingusGameSessionResult ();
 }
 
-void
+bool
 PingusGameSession::draw (GraphicContext& gc)
 {
   client->draw (gc);
+  last_redraw = CL_System::get_time();
+  return true;
 }
 
 void
 PingusGameSession::update (const GameDelta& delta)
 {
-  server->update ();
+  int time_passed = (CL_System::get_time() - last_update);
+  int update_time = game_speed;
+
+  if (time_passed > update_time)
+    {
+      for (int i = 0;  i < time_passed; i += update_time)
+       {
+         // This updates the world and all objects
+         server->update ();
+       }
+      // This updates something else... what?! Well, userinterface and
+      // things like that...
+      last_update = CL_System::get_time();
+    }
+  else
+    {
+      if (!max_cpu_usage)
+       {
+         CL_System::sleep(update_time - time_passed);
+       }
+    }
+  
+  // Client is independend of the update limit, well, not completly...
   client->update (delta);
 }
 

Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- game_session.hxx    27 Sep 2002 11:26:43 -0000      1.8
+++ game_session.hxx    1 Oct 2002 21:48:32 -0000       1.9
@@ -49,6 +49,12 @@
       the called must delete the returned PLF object */
   PLF* create_plf (std::string filename);
 
+  unsigned int last_redraw;
+  unsigned int last_update;
+
+  unsigned int frames;
+  unsigned int frame_skips;
+  
 public:
   /** Create a new game session which is launched on start ()
       @param arg_filename The filename of a Pingus Level file 
@@ -63,7 +69,7 @@
 
   // Overloaded Screen functions 
   /** Draw this screen */
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
 
   /** Pass a delta to the screen */
   void update (const GameDelta& delta);

Index: gui_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- gui_screen.cxx      19 Sep 2002 13:30:08 -0000      1.9
+++ gui_screen.cxx      1 Oct 2002 21:48:32 -0000       1.10
@@ -37,13 +37,14 @@
   delete gui_manager;
 }
 
-  /** Draw this screen */
-void
+/** Draw this screen */
+bool
 GUIScreen::draw (GraphicContext& gc)
 {
   draw_background ();
   gui_manager->draw (gc);
   draw_foreground ();
+  return true;
 }
 
   /** Pass a delta to the screen */

Index: gui_screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- gui_screen.hxx      27 Sep 2002 11:26:43 -0000      1.10
+++ gui_screen.hxx      1 Oct 2002 21:48:32 -0000       1.11
@@ -44,7 +44,7 @@
   /** Draw this screen */
   virtual void draw_foreground () {}
   virtual void draw_background () {}
-  virtual void draw (GraphicContext& gc);
+  virtual bool draw (GraphicContext& gc);
 
   /** Pass a game delta to the screen */
   virtual void update (const GameDelta& delta);

Index: input_debug_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input_debug_screen.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- input_debug_screen.cxx      6 Sep 2002 17:33:29 -0000       1.3
+++ input_debug_screen.cxx      1 Oct 2002 21:48:32 -0000       1.4
@@ -30,11 +30,12 @@
 }
 
 /** Draw this screen */
-void
+bool
 InputDebugScreen::draw (GraphicContext& gc)
 {
   std::cout << "InputDebugScreen::draw ()" << std::endl;
   UNUSED_ARG(gc);
+  return true;
 }
 
 /** Pass a delta to the screen */

Index: input_debug_screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input_debug_screen.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- input_debug_screen.hxx      11 Sep 2002 15:27:19 -0000      1.3
+++ input_debug_screen.hxx      1 Oct 2002 21:48:32 -0000       1.4
@@ -31,7 +31,7 @@
   virtual ~InputDebugScreen ();
 
   /** Draw this screen */
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
 
   /** Pass a delta to the screen */
   void update (const GameDelta& delta);

Index: option_menu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/option_menu.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- option_menu.cxx     28 Sep 2002 11:52:22 -0000      1.7
+++ option_menu.cxx     1 Oct 2002 21:48:32 -0000       1.8
@@ -326,7 +326,7 @@
   }
 }
 
-void
+bool
 OptionMenu::draw(GraphicContext& gc)
 {  
   //draw_background();
@@ -342,6 +342,8 @@
       && CL_Mouse::get_y() < (int)back.get_height())
     CL_Display::fill_rect(0, 0, back.get_width(), back.get_height(),
                          1.0f, 1.0f, 1.0f, 0.3f);
+
+  return true;
 }
 
 void

Index: option_menu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/option_menu.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- option_menu.hxx     27 Sep 2002 11:26:43 -0000      1.6
+++ option_menu.hxx     1 Oct 2002 21:48:32 -0000       1.7
@@ -99,7 +99,7 @@
   void draw_background ();
   void preload () { init (); }
   void update (float delta);
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
   void check_click ();
   EntryIter current_item ();
   void add_entry (const std::string& e, bool* v);

Index: pingus_menu_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- pingus_menu_manager.cxx     28 Sep 2002 11:52:22 -0000      1.14
+++ pingus_menu_manager.cxx     1 Oct 2002 21:48:32 -0000       1.15
@@ -43,7 +43,7 @@
 {
 }
 
-void
+bool
 PingusMenuManager::draw (GraphicContext& gc)
 {
   background.draw ();
@@ -56,6 +56,8 @@
 
   for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
     (*i)->draw (gc);
+
+  return true;
 }
 
 void

Index: pingus_menu_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pingus_menu_manager.hxx     27 Sep 2002 11:26:44 -0000      1.13
+++ pingus_menu_manager.hxx     1 Oct 2002 21:48:32 -0000       1.14
@@ -60,7 +60,7 @@
 
   void fadeout ();
 
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
   void update (const GameDelta&);
 
   // !FIXME! Should use controller instead

Index: screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- screen.hxx  27 Sep 2002 11:26:44 -0000      1.9
+++ screen.hxx  1 Oct 2002 21:48:32 -0000       1.10
@@ -35,11 +35,14 @@
 
   Screen () { }
   
-  /** Draw this screen */
-  virtual void draw (GraphicContext& gc) =0;
+  /** Draw this screen @return true if draw was successfull, false if
+      frameskip has taken place ('causes a skip of flip_display) */
+  virtual bool draw (GraphicContext& gc) =0;
 
   /** Pass a delta to the screen */
   virtual void update (const GameDelta& delta) =0;
+
+  virtual unsigned int time_till_next_update() { return 0; }
 
   /** Called once the screen gets activated and becomes the current
       screen */

Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- screen_manager.cxx  30 Sep 2002 14:20:49 -0000      1.18
+++ screen_manager.cxx  1 Oct 2002 21:48:32 -0000       1.19
@@ -99,8 +99,8 @@
       // skip draw if the screen changed to avoid glitches
       if (last_screen == get_current_screen())
        {
-         get_current_screen()->draw (display_gc);
-         Display::flip_display ();
+         if (get_current_screen()->draw (display_gc))
+           Display::flip_display ();
        }
       else
        {

Index: sprite.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/sprite.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sprite.cxx  1 Oct 2002 19:53:44 -0000       1.8
+++ sprite.cxx  1 Oct 2002 21:48:32 -0000       1.9
@@ -211,7 +211,7 @@
 Sprite::update ()
 {
   // FIXME: game_speed is incorrect, but should work
-  update(game_speed/1000.0f);
+  update(1.0f/float(game_speed));
 }
 
 void

Index: story.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/story.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- story.cxx   28 Sep 2002 11:52:22 -0000      1.12
+++ story.cxx   1 Oct 2002 21:48:32 -0000       1.13
@@ -52,7 +52,7 @@
 {
 }
 
-void 
+bool 
 Story::draw(GraphicContext& gc)
 {
   CL_Display::fill_rect (0,0,
@@ -74,6 +74,8 @@
   gc.print_left(Fonts::pingus_small, 125, 80 + story.get_height() + 25 + (4 * 
15), "...");
   gc.print_left(Fonts::pingus_small, 125, 80 + story.get_height() + 25 + (5 * 
15), "...");
   gc.print_left(Fonts::pingus_small, 125, 80 + story.get_height() + 25 + (6 * 
15), "Press <Space> to continue...");
+
+  return true;
 }
 
 void

Index: story.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/story.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- story.hxx   27 Sep 2002 11:26:44 -0000      1.9
+++ story.hxx   1 Oct 2002 21:48:32 -0000       1.10
@@ -43,7 +43,7 @@
 
   void preload () { init (); }
 
-  void draw (GraphicContext& gc);
+  bool draw (GraphicContext& gc);
   void update (float delta);
 
   /// Display a string at the right position

Index: true_server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- true_server.cxx     1 Oct 2002 19:53:44 -0000       1.12
+++ true_server.cxx     1 Oct 2002 21:48:32 -0000       1.13
@@ -36,7 +36,6 @@
   fast_forward = false;
   pause = false;
   last_time = 0;
-  local_game_speed = game_speed;
 
   world = new World (plf);
 }
@@ -58,14 +57,13 @@
       // times
       for (int i = 0; i < 4; ++i)
        {
-         Server::update();
          world->update();
        }
     }
   else
     {
-      Server::update();
-      world->update();
+      if (!pause)
+       world->update();
     }
 }
 

Index: true_server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- true_server.hxx     1 Oct 2002 19:53:44 -0000       1.7
+++ true_server.hxx     1 Oct 2002 21:48:32 -0000       1.8
@@ -29,7 +29,6 @@
   bool fast_forward;
   bool pause;
   unsigned int  last_time;
-  int  local_game_speed;
   float delta;
   bool armageddon;
 





reply via email to

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