[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.28,1.29 game_session.cxx
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.28,1.29 game_session.cxx,1.17,1.18 timer.cxx,1.2,1.3 timer.hxx,1.5,1.6 |
Date: |
7 Oct 2002 23:11:11 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv7565
Modified Files:
client.cxx game_session.cxx timer.cxx timer.hxx
Log Message:
changed the timer class a bit, still needs work and sub-milisec timing
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- client.cxx 4 Oct 2002 16:54:03 -0000 1.28
+++ client.cxx 7 Oct 2002 23:11:09 -0000 1.29
@@ -57,10 +57,7 @@
unplayable.set_align_center();
- Timer timer;
-
- timer.start();
- if (verbose) std::cout << "Client: Generating UI elements..." << std::flush;
+ Timer timer("Client UI generation");
Display::set_cursor(CL_MouseCursorProvider::load("Cursors/cursor",
PingusResource::get("game")));
@@ -94,7 +91,7 @@
playfield->set_server(server);
playfield->set_client(this);
- if (verbose) std::cout << "done " << timer.stop() << std::endl;
+ timer.stop();
}
Client::~Client()
Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- game_session.cxx 4 Oct 2002 16:54:04 -0000 1.17
+++ game_session.cxx 7 Oct 2002 23:11:09 -0000 1.18
@@ -31,19 +31,17 @@
PingusGameSession::PingusGameSession (std::string arg_filename)
: filename (arg_filename)
{
- Timer timer;
-
- timer.start();
+ Timer plf_timer("GameSession plf creation");
plf = PLF::create(filename);
- std::cout << "Timer: Level loading took: " << timer.stop() << std::endl;
+ plf_timer.stop();
- timer.start();
+ Timer server_timer("GameSession server creation");
server = new TrueServer(plf);
- std::cout << "Timer: TrueServer creation took: " << timer.stop() <<
std::endl;
+ server_timer.stop();
- timer.start();
+ Timer client_timer("GameSession client creation");
client = new Client(server);
- std::cout << "Timer: Client creation took: " << timer.stop() << std::endl;
+ client_timer.stop();
last_redraw = CL_System::get_time();
last_update = CL_System::get_time();
@@ -95,11 +93,14 @@
int time_passed = (CL_System::get_time() - last_update) + left_over_time;
int update_time = game_speed;
int min_frame_skip = 0;
+ int max_frame_skip = 0;
left_over_time = 0;
int i;
- for (i = 0; i * update_time < time_passed || i < min_frame_skip; i += 1)
+ for (i = 0;
+ (i * update_time < time_passed && i < min_frame_skip + 1);
+ ++i)
{
// This updates the world and all objects
server->update ();
Index: timer.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/timer.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- timer.cxx 13 Jun 2002 14:25:12 -0000 1.2
+++ timer.cxx 7 Oct 2002 23:11:09 -0000 1.3
@@ -17,29 +17,22 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include <cassert>
#include <ClanLib/Core/System/system.h>
+#include <iostream>
#include "timer.hxx"
-Timer::Timer()
+Timer::Timer(const char* desc)
+ : description(desc),
+ start_time (CL_System::get_time())
{
- running = false;
}
-int
-Timer::start()
-{
- assert(!running);
- running = true;
- return (last_time = CL_System::get_time());
-}
-
-int
+void
Timer::stop()
{
- assert(running);
- running = false;
- return CL_System::get_time() - last_time;
+ unsigned int time = CL_System::get_time() - start_time;
+ std::cout << "Timer: '" << description << "' took "
+ << time << "msec" << std::endl;
}
/* EOF */
Index: timer.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/timer.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- timer.hxx 27 Sep 2002 11:26:44 -0000 1.5
+++ timer.hxx 7 Oct 2002 23:11:09 -0000 1.6
@@ -27,18 +27,16 @@
class Timer
{
private:
- int last_time;
- bool running;
+ const char* description;
+ unsigned int start_time;
public:
- Timer();
+ /** Init a timer with a description and start it */
+ Timer(const char* desc);
- /** Start the timer
- @return The current time, as returned by CL_System::get_time() */
- int start();
/** Stop the timer
@return The time passed since the last start() */
- int stop();
+ void stop();
private:
Timer (const Timer&);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.28,1.29 game_session.cxx,1.17,1.18 timer.cxx,1.2,1.3 timer.hxx,1.5,1.6,
grumbel <=