mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 19:02:00 +00:00
Removing extras from commit #26795
This commit is contained in:
parent
011b767395
commit
69ca6b875e
@ -181,7 +181,6 @@ wesnoth_sources = Split("""
|
||||
statistics.cpp
|
||||
team.cpp
|
||||
terrain_filter.cpp
|
||||
time.cpp
|
||||
titlescreen.cpp
|
||||
unit.cpp
|
||||
unit_abilities.cpp
|
||||
@ -217,7 +216,6 @@ wesnoth_editor_sources = Split("""
|
||||
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)
|
||||
|
@ -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 @@ namespace {
|
||||
|
||||
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()
|
||||
|
@ -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"
|
||||
@ -1825,7 +1824,6 @@ private:
|
||||
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,
|
||||
game_display::MESSAGE_TYPE type)
|
||||
@ -2317,7 +2315,6 @@ private:
|
||||
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 @@ private:
|
||||
_("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 @@ private:
|
||||
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);
|
||||
|
@ -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 @@ private:
|
||||
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 @@ void server::load_config() {
|
||||
// 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 @@ void server::run() {
|
||||
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 @@ void server::run() {
|
||||
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);
|
||||
|
118
src/time.cpp
118
src/time.cpp
@ -1,118 +0,0 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
|
||||
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_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
59
src/time.hpp
59
src/time.hpp
@ -1,59 +0,0 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user