diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45a8b055aae7..0c4a10812cb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -898,7 +898,6 @@ set(wesnoth-main_SRC mouse_handler_base.cpp movetype.cpp mp_game_settings.cpp - mp_replay_controller.cpp game_initialization/mp_game_utils.cpp game_initialization/mp_options.cpp mp_ui_alerts.cpp @@ -1049,7 +1048,6 @@ set(libwesnoth-game_STAT_SRC quit_confirmation.cpp reports.cpp show_dialog.cpp - simple_rng.cpp sound.cpp soundsource.cpp sound_music_track.cpp diff --git a/src/SConscript b/src/SConscript index 5ab995b40631..d528fd36c8d4 100644 --- a/src/SConscript +++ b/src/SConscript @@ -125,7 +125,6 @@ libwesnoth_sources = Split(""" race.cpp reports.cpp show_dialog.cpp - simple_rng.cpp sound.cpp soundsource.cpp sound_music_track.cpp @@ -478,7 +477,6 @@ wesnoth_sources = Split(""" mouse_handler_base.cpp movetype.cpp mp_game_settings.cpp - mp_replay_controller.cpp game_initialization/mp_game_utils.cpp game_initialization/mp_options.cpp mp_ui_alerts.cpp diff --git a/src/mp_replay_controller.cpp b/src/mp_replay_controller.cpp deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/src/mp_replay_controller.hpp b/src/mp_replay_controller.hpp deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/src/simple_rng.cpp b/src/simple_rng.cpp deleted file mode 100644 index 008ffbba328c..000000000000 --- a/src/simple_rng.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2003 by David White - Copyright (C) 2005 - 2016 by Yann Dirson - 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 as published by - the Free Software Foundation; either version 2 of the License, 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 "simple_rng.hpp" -#include "config.hpp" -#include "log.hpp" -#include -static lg::log_domain log_random("random"); -#define DBG_RND LOG_STREAM(debug, log_random) -#define LOG_RND LOG_STREAM(info, log_random) -#define WRN_RND LOG_STREAM(warn, log_random) -#define ERR_RND LOG_STREAM(err, log_random) - - -namespace rand_rng -{ -simple_rng::simple_rng() : - random_seed_(rand() & 0x7FFFFFFF), - random_pool_(random_seed_), - random_calls_(0) -{ -} - -simple_rng::simple_rng(const config& cfg) : - random_seed_(cfg["random_seed"]), - random_pool_(random_seed_), - random_calls_(cfg["random_calls"].to_int(0)) -{ - for ( unsigned calls = 0; calls < random_calls_; ++calls ) - random_next(); -} - -int simple_rng::get_next_random() -{ - random_next(); - ++random_calls_; - DBG_RND << "pulled user random " << random_pool_ - << " for call " << random_calls_ - << " with seed " << random_seed_ << '\n'; - - return (random_pool_ / 65536) % 32768; -} - -void simple_rng::rotate_random() -{ - random_seed_ = random_pool_ & 0x7FFFFFFF; - random_calls_ = 0; -} - -void simple_rng::seed_random(const int seed, const unsigned call_count) -{ - random_pool_ = seed; - random_seed_ = seed; - for(random_calls_ = 0; random_calls_ < call_count; ++random_calls_) { - random_next(); - } - DBG_RND << "Seeded random with " << random_seed_ << " with " - << random_calls_ << " calls, pool is now at " - << random_pool_ << '\n'; -} - -void simple_rng::random_next() -{ - // Use the simple random generator as shown in man rand(3). - // The division is done separately since we also want to - // quickly go the the wanted index in the random list. - random_pool_ = random_pool_ * 1103515245 + 12345; -} - - -} // ends rand_rng namespace - diff --git a/src/simple_rng.hpp b/src/simple_rng.hpp deleted file mode 100644 index 68b337a57a3b..000000000000 --- a/src/simple_rng.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2003 by David White - Copyright (C) 2005 - 2016 by Yann Dirson - 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 as published by - the Free Software Foundation; either version 2 of the License, 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 SIMPLE_RNG_HPP_INCLUDED -#define SIMPLE_RNG_HPP_INCLUDED - -class config; - -namespace rand_rng -{ - -class simple_rng -{ -public: - simple_rng(); - simple_rng(const config& cfg); - - /** Get a new random number. */ - int get_next_random(); - - /** - * Seeds the random pool. - * - * @param seed The initial value for the random engine. - * @param call_count Upon loading we need to restore the state at saving - * so set the number of times a random number is - * generated for replays the orginal value is - * required. - */ - void seed_random(const int seed, const unsigned call_count = 0); - - /** - * Resets the random to the 0 calls and the seed to the random - * this way we stay in the same sequence but don't have a lot - * calls. Used when moving to the next scenario. - */ - void rotate_random(); - - int get_random_seed() const { return random_seed_; } - int get_random_calls() const { return random_calls_; } - -private: - /** Initial seed for the pool. */ - int random_seed_; - - /** State for the random pool (modulo arithmetic). */ - unsigned long random_pool_; - - /** Number of time a random number is generated. */ - unsigned random_calls_; - - /** Sets the next random number in the pool. */ - void random_next(); -}; - -} // ends rand_rng namespace - -#endif