[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3836 - trunk/pingus/src
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3836 - trunk/pingus/src |
Date: |
Wed, 16 Jul 2008 15:42:53 +0200 |
Author: grumbel
Date: 2008-07-16 15:42:53 +0200 (Wed, 16 Jul 2008)
New Revision: 3836
Modified:
trunk/pingus/src/fps_counter.cpp
trunk/pingus/src/fps_counter.hpp
Log:
Use sstream instead of c-string
Modified: trunk/pingus/src/fps_counter.cpp
===================================================================
--- trunk/pingus/src/fps_counter.cpp 2008-07-16 12:39:19 UTC (rev 3835)
+++ trunk/pingus/src/fps_counter.cpp 2008-07-16 13:42:53 UTC (rev 3836)
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <stdio.h>
+#include <sstream>
#include "fonts.hpp"
#include "fps_counter.hpp"
#include "gettext.h"
@@ -25,7 +25,6 @@
FPSCounter::FPSCounter()
{
start_time = SDL_GetTicks();
- strcpy(fps_string, "");
fps_count = 0;
}
@@ -45,7 +44,7 @@
}
else
{
- Fonts::pingus_small.render(origin_center, Display::get_width()/2, 34, "+
" + std::string(fps_string) + " +", Display::get_framebuffer());
+ Fonts::pingus_small.render(origin_center, Display::get_width()/2, 34, "+
" + fps_string + " +", Display::get_framebuffer());
odd_frame = true;
}
}
@@ -61,9 +60,13 @@
if (start_time + 1000 < current_time)
{
current_fps = fps_count * 1000 / (current_time - start_time);
- snprintf(fps_string, 16, "%d fps", current_fps);
+
fps_count = 0;
start_time = SDL_GetTicks();
+
+ std::ostringstream str;
+ str << current_fps << " fps";
+ fps_string = str.str();
}
}
Modified: trunk/pingus/src/fps_counter.hpp
===================================================================
--- trunk/pingus/src/fps_counter.hpp 2008-07-16 12:39:19 UTC (rev 3835)
+++ trunk/pingus/src/fps_counter.hpp 2008-07-16 13:42:53 UTC (rev 3836)
@@ -16,6 +16,8 @@
#ifndef HEADER_PINGUS_FPS_COUNTER_HPP
#define HEADER_PINGUS_FPS_COUNTER_HPP
+
+#include <string>
class FPSCounter
{
@@ -25,7 +27,7 @@
/** A string holding the current value of frames + "fps", its
updated every second */
- char fps_string[16];
+ std::string fps_string;
/** Count the fps until one second is passed */
int fps_count;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3836 - trunk/pingus/src,
grumbel at BerliOS <=