Author: suokko
Date: Fri May 23 19:37:37 2008
New Revision: 26797
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26797&view=rev
Log:
Removing extras from commit #26795
Removed:
trunk/src/time.cpp
trunk/src/time.hpp
Modified:
trunk/src/SConscript
trunk/src/animated.i
trunk/src/menu_events.cpp
trunk/src/server/server.cpp
Modified: trunk/src/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=26797&r1=26796&r2=26797&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Fri May 23 19:37:37 2008
@@ -181,7 +181,6 @@
statistics.cpp
team.cpp
terrain_filter.cpp
- time.cpp
titlescreen.cpp
unit.cpp
unit_abilities.cpp
@@ -217,7 +216,6 @@
editor/editor_dialogs.cpp
editor/editor_undo.cpp
animated_editor.cpp
- time.cpp
""")
if have_client_prereqs and have_X:
wesnoth_editor = env.Program("wesnoth_editor", wesnoth_editor_sources +
[libwesnoth_core, libwesnoth_sdl, libwesnoth] + wesnoth_editor_res)
Modified: trunk/src/animated.i
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/animated.i?rev=26797&r1=26796&r2=26797&view=diff
==============================================================================
--- trunk/src/animated.i (original)
+++ trunk/src/animated.i Fri May 23 19:37:37 2008
@@ -22,7 +22,6 @@
#include "SDL.h"
#include "animated.hpp"
-#include "time.hpp"
#include "util.hpp"
#include "serialization/string_utils.hpp"
@@ -32,8 +31,7 @@
void new_animation_frame()
{
- ntime::source::get_source().start_frame();
- current_ticks = ntime::source::get_source().get_time();
+ current_ticks = SDL_GetTicks();
}
int get_current_animation_tick()
Modified: trunk/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=26797&r1=26796&r2=26797&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Fri May 23 19:37:37 2008
@@ -37,7 +37,6 @@
#include "replay.hpp"
#include "sound.hpp"
#include "team.hpp"
-#include "time.hpp"
#include "unit_display.hpp"
#include "unit_types.hpp"
#include "wml_separators.hpp"
@@ -1824,7 +1823,6 @@
//But since it makes the called method more generic, it is done
anyway.
chat_handler::do_speak(textbox_info_.box()->text(),textbox_info_.check() !=
NULL ? textbox_info_.check()->checked() : false);
}
-
void menu_handler::add_chat_message(const time_t& time,
const std::string& speaker, int side, const
std::string& message,
@@ -2317,7 +2315,6 @@
using chmap::command_failed;
using chmap::command_failed_need_arg;
- void do_animode();
void do_refresh();
void do_droid();
void do_theme();
@@ -2387,7 +2384,6 @@
_("Clear chat history."));
register_command("sunset",
&console_handler::do_sunset,
_("Visualize the screen refresh
procedure."), "", "D");
- register_command("animode",
&console_handler::do_animode, "Change animation time mode");
register_command("fps",
&console_handler::do_fps, "Show fps.");
register_command("benchmark",
&console_handler::do_benchmark);
register_command("save",
&console_handler::do_save, _("Save game."));
@@ -2799,18 +2795,6 @@
void console_handler::do_save() {
menu_handler_.save_game(get_data(),gui::NULL_DIALOG);
}
- void console_handler::do_animode(){
- if (ntime::source::get_source().get_time_mode() ==
ntime::source::REAL_TIME)
- {
-
ntime::source::get_source().set_time_mode(ntime::source::SMOOTH_TIME);
- print(get_cmd(), "Smooth rendering");
- }
- else
- {
-
ntime::source::get_source().set_time_mode(ntime::source::REAL_TIME);
- print(get_cmd(), "Realtime rendering");
- }
- }
void console_handler::do_save_quit() {
menu_handler_.save_game(get_data(),gui::NULL_DIALOG);
throw end_level_exception(QUIT);
Modified: trunk/src/server/server.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=26797&r1=26796&r2=26797&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Fri May 23 19:37:37 2008
@@ -23,7 +23,6 @@
#include "../map.hpp" // gamemap::MAX_PLAYERS
#include "../network.hpp"
#include "../filesystem.hpp"
-#include "../time.hpp"
#include "../serialization/parser.hpp"
#include "../serialization/preprocessor.hpp"
#include "../serialization/string_utils.hpp"
@@ -298,6 +297,7 @@
simple_wml::document games_and_users_list_;
metrics metrics_;
+ fps_limiter fps_limit_;
time_t last_ping_;
time_t last_stats_;
@@ -414,7 +414,7 @@
// remember to make new one as a daemon or it will block old one
restart_command = cfg_["restart_command"];
-
time::source::get_source().set_frame_time(lexical_cast_default<size_t>(cfg_["ms_per_frame"],20));
+
fps_limit_.set_ms_per_frame(lexical_cast_default<size_t>(cfg_["ms_per_frame"],20));
accepted_versions_.clear();
const std::string& versions = cfg_["versions_accepted"];
@@ -477,7 +477,7 @@
for (int loop = 0;; ++loop) {
// Try to run with 50 FPS all the time
// Server will respond a bit faster under heavy load
- time::source::get_source().start_frame();
+ fps_limit_.limit();
try {
// We are going to waith 10 seconds before shutting
down so users can get out of game.
if (graceful_restart && games_.size() == 0 &&
++graceful_counter > 500 )
@@ -502,7 +502,7 @@
process_command(admin_cmd);
}
- time_t now = time(NULL);
+ time_t now = time(NULL);
if (last_ping_ + 15 <= now) {
// and check if bans have expired
ban_manager_.check_ban_times(now);
Removed: trunk/src/time.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/time.cpp?rev=26796&view=auto
==============================================================================
--- trunk/src/time.cpp (original)
+++ trunk/src/time.cpp (removed)
@@ -1,118 +1,0 @@
-/* $Id$ */
-/*
- Copyright (C) 2008 by Pauli Nieminen <[EMAIL PROTECTED]>
- Part of the Battle for Wesnoth Project http://www.wesnoth.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- or at your option any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY.
-
- See the COPYING file for more details.
-*/
-
-#include <iostream>
-#include "time.hpp"
-#include "global.hpp"
-#include "SDL.h"
-
-namespace ntime {
-
- source source::time_source_;
-
- source::source() : frame_time_(20),
- current_time_(SDL_GetTicks()),
- index_(0),
- mode_(REAL_TIME)
- {
- for (int i = 0; i < frames_to_remember; ++i)
- {
- time_[i] = 0;
- }
- }
-
- int source::next_index()
- {
- return (index_ + 1) % frames_to_remember;
- }
-
- size_t source::start_frame(const bool limit)
- {
- size_t previus_time = current_time_;
- size_t current_time = SDL_GetTicks();
- size_t frame_used = current_time - previus_time;
- if (limit && frame_time_ > frame_used)
- {
- // use delay to wait so we don't take all cpu
- size_t wait_time = frame_time_ - frame_used;
- SDL_Delay(wait_time);
- current_time += wait_time;
- }
-
-
- // Advance index only in begin of frame
- index_ = next_index();
- time_[index_] = current_time;
- if (mode_ == REAL_TIME)
- {
- current_time_ = current_time;
- }
- else
- {
- // Check if we have allready enought frames
- // for smooth time calculation
- if (time_[next_index()])
- {
- // smooth calcuations uses rounding to
- // keep time as near of real time as possible
- // @todo There should be error correction
- // Maybe should use 3 bits shifted
values
-
- size_t average = ((current_time -
time_[next_index()]))/((frames_to_remember - 1));
-
-
- current_time_ += average;
- }
- else
- {
- current_time_ = current_time;
- }
- }
- return frame_used;
- }
-
- void source::set_frame_rate(const size_t fps)
- {
- frame_time_ = 1000/fps;
- }
-
- void source::set_frame_time(const size_t ms)
- {
- frame_time_ = ms;
- }
-
- size_t source::get_time() const
- {
- return current_time_;
- }
-
- void source::set_time_mode(const time_mode& mode)
- {
- mode_ = mode;
- }
-
- source::time_mode source::get_time_mode() const
- {
- return mode_;
- }
-
- source& source::get_source()
- {
- return source::time_source_;
- }
-
-
-
-}
-
Removed: trunk/src/time.hpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/time.hpp?rev=26796&view=auto
==============================================================================
--- trunk/src/time.hpp (original)
+++ trunk/src/time.hpp (removed)
@@ -1,59 +1,0 @@
-/* $Id$ */
-/*
- Copyright (C) 2008 by Pauli Nieminen <[EMAIL PROTECTED]>
- Part of the Battle for Wesnoth Project http://www.wesnoth.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- or at your option any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY.
-
- See the COPYING file for more details.
-*/
-
-#ifndef TIME_HPP_INCLUDED
-#define TIME_HPP_INCLUDED
-#include <cstdlib>
-
-namespace ntime {
-
- const int frames_to_remember = 6;
- class source {
- public:
- enum time_mode {
- REAL_TIME,
- SMOOTH_TIME
- };
- private:
- size_t time_[frames_to_remember];
- size_t frame_time_;
- size_t current_time_;
- int index_;
- time_mode mode_;
- static source time_source_;
- source();
- source(const source&);
- void operator=(const source&);
-
- int next_index();
- public:
- /**
- * Called in begin of each frame
- * @return How many milliseconds this frame took?
- */
- size_t start_frame(const bool limit = true);
- void set_frame_rate(const size_t fps);
- void set_frame_time(const size_t ms);
-
- size_t get_time() const;
-
- void set_time_mode(const time_mode& mode);
- time_mode get_time_mode() const;
-
- static source& get_source();
-
- };
-}
-
-#endif
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits