From fd694cd2324a7e2d61d833a78024b68fd3605053 Mon Sep 17 00:00:00 2001 From: leak Date: Sun, 19 Dec 2010 17:06:33 +0100 Subject: Streamlining loading functions for server startup - Added a couple of timer outputs - Improved code consistency between loading functions - Progess bars should look and behave similar on all OS now (sLog.outString() is not needed anymore to replace the progress bar in log files) --HG-- branch : trunk --- src/server/shared/Utilities/ProgressBar.cpp | 32 ++++++----------------------- src/server/shared/Utilities/ProgressBar.h | 1 - src/server/shared/Utilities/Timer.h | 5 +++++ 3 files changed, 11 insertions(+), 27 deletions(-) (limited to 'src/server/shared') diff --git a/src/server/shared/Utilities/ProgressBar.cpp b/src/server/shared/Utilities/ProgressBar.cpp index 6d6cdf893d1..01f467b798f 100755 --- a/src/server/shared/Utilities/ProgressBar.cpp +++ b/src/server/shared/Utilities/ProgressBar.cpp @@ -21,17 +21,7 @@ #include "ProgressBar.h" char const* const barGoLink::empty = " "; -#ifdef _WIN32 -char const* const barGoLink::full = "\x3D"; -#else char const* const barGoLink::full = "*"; -#endif - -barGoLink::~barGoLink() -{ - printf( "\n" ); - fflush(stdout); -} barGoLink::barGoLink( uint64 row_count ) { @@ -39,17 +29,9 @@ barGoLink::barGoLink( uint64 row_count ) rec_pos = 0; indic_len = 50; num_rec = row_count; - #ifdef _WIN32 - printf( "\x3D" ); - #else printf( "[" ); - #endif for (uint64 i = 0; i < indic_len; ++i) printf( empty ); - #ifdef _WIN32 - printf( "\x3D 0%%\r\x3D" ); - #else printf( "] 0%%\r[" ); - #endif fflush(stdout); } @@ -62,22 +44,20 @@ void barGoLink::step( void ) n = rec_no * indic_len / num_rec; if ( n != rec_pos ) { - #ifdef _WIN32 - printf( "\r\x3D" ); - #else printf( "\r[" ); - #endif for (i = 0; i < n; i++ ) printf( full ); for (; i < indic_len; i++ ) printf( empty ); float percent = (((float)n/(float)indic_len)*100); - #ifdef _WIN32 - printf( "\x3D %i%% \r\x3D", (int)percent); - #else printf( "] %i%% \r[", (int)percent); - #endif fflush(stdout); rec_pos = n; } + + if( num_rec == rec_no) + { + printf( "\n" ); + fflush(stdout); + } } diff --git a/src/server/shared/Utilities/ProgressBar.h b/src/server/shared/Utilities/ProgressBar.h index 93363dc70b9..6c5382ab735 100755 --- a/src/server/shared/Utilities/ProgressBar.h +++ b/src/server/shared/Utilities/ProgressBar.h @@ -34,6 +34,5 @@ class barGoLink void step( void ); barGoLink( uint64 ); - ~barGoLink(); }; #endif diff --git a/src/server/shared/Utilities/Timer.h b/src/server/shared/Utilities/Timer.h index 28c7fcd999b..bae864bef02 100755 --- a/src/server/shared/Utilities/Timer.h +++ b/src/server/shared/Utilities/Timer.h @@ -37,6 +37,11 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime) return newMSTime - oldMSTime; } +inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime) +{ + return getMSTimeDiff(oldMSTime, getMSTime()); +} + struct IntervalTimer { public: -- cgit v1.2.3