Use std::time_t instead of plain C time_t
(cherry-picked from commit ccbb736a18
)
This commit is contained in:
parent
ccbf2f7705
commit
21580d3ef1
44 changed files with 123 additions and 121 deletions
|
@ -54,8 +54,8 @@ struct addon_info
|
|||
|
||||
std::string feedback_url;
|
||||
|
||||
time_t updated;
|
||||
time_t created;
|
||||
std::time_t updated;
|
||||
std::time_t created;
|
||||
|
||||
// Artificial upload order index used to preserve add-ons upload order
|
||||
// until we have actual first-upload timestamps implemented. This index
|
||||
|
|
|
@ -576,7 +576,7 @@ void server::handle_request_campaign_list(const server::request& req)
|
|||
{
|
||||
LOG_CS << "sending campaign list to " << req.addr << " using gzip\n";
|
||||
|
||||
time_t epoch = time(nullptr);
|
||||
std::time_t epoch = time(nullptr);
|
||||
config campaign_list;
|
||||
|
||||
campaign_list["timestamp"] = epoch;
|
||||
|
@ -585,14 +585,14 @@ void server::handle_request_campaign_list(const server::request& req)
|
|||
}
|
||||
|
||||
bool before_flag = false;
|
||||
time_t before = epoch;
|
||||
std::time_t before = epoch;
|
||||
try {
|
||||
before += req.cfg["before"].to_time_t();
|
||||
before_flag = true;
|
||||
} catch(const bad_lexical_cast&) {}
|
||||
|
||||
bool after_flag = false;
|
||||
time_t after = epoch;
|
||||
std::time_t after = epoch;
|
||||
try {
|
||||
after += req.cfg["after"].to_time_t();
|
||||
after_flag = true;
|
||||
|
@ -825,7 +825,7 @@ void server::handle_upload(const server::request& req)
|
|||
LOG_CS << "Upload denied - hidden add-on.\n";
|
||||
send_error("Add-on upload denied. Please contact the server administration for assistance.", req.sock);
|
||||
} else {
|
||||
const time_t upload_ts = time(nullptr);
|
||||
const std::time_t upload_ts = time(nullptr);
|
||||
|
||||
LOG_CS << "Upload is owner upload.\n";
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
|||
void do_speak(const std::string& message, bool allies_only=false);
|
||||
|
||||
//called from do_speak
|
||||
virtual void add_chat_message(const time_t& time,
|
||||
virtual void add_chat_message(const std::time_t& time,
|
||||
const std::string& speaker, int side, const std::string& message,
|
||||
MESSAGE_TYPE type=MESSAGE_PRIVATE) = 0;
|
||||
virtual void send_chat_message(const std::string& message, bool allies_only=false) = 0;
|
||||
|
|
|
@ -296,9 +296,9 @@ std::size_t config_attribute_value::to_size_t(std::size_t def) const
|
|||
return apply_visitor(attribute_numeric_visitor<std::size_t>(def));
|
||||
}
|
||||
|
||||
time_t config_attribute_value::to_time_t(time_t def) const
|
||||
std::time_t config_attribute_value::to_time_t(std::time_t def) const
|
||||
{
|
||||
return apply_visitor(attribute_numeric_visitor<time_t>(def));
|
||||
return apply_visitor(attribute_numeric_visitor<std::time_t>(def));
|
||||
}
|
||||
|
||||
double config_attribute_value::to_double(double def) const
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
long long to_long_long(long long def = 0) const;
|
||||
unsigned to_unsigned(unsigned def = 0) const;
|
||||
std::size_t to_size_t(std::size_t def = 0) const;
|
||||
time_t to_time_t(time_t def = 0) const;
|
||||
std::time_t to_time_t(std::time_t def = 0) const;
|
||||
double to_double(double def = 0.) const;
|
||||
std::string str(const std::string& fallback = "") const;
|
||||
t_string t_str() const;
|
||||
|
|
|
@ -44,7 +44,7 @@ display_chat_manager::chat_message::chat_message(int speaker, int h)
|
|||
{}
|
||||
|
||||
|
||||
void display_chat_manager::add_chat_message(const time_t& time, const std::string& speaker,
|
||||
void display_chat_manager::add_chat_message(const std::time_t& time, const std::string& speaker,
|
||||
int side, const std::string& message, events::chat_handler::MESSAGE_TYPE type,
|
||||
bool bell)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void remove_whisperer(const std::string& nick) { whisperers_.erase(nick); }
|
||||
const std::set<std::string>& whisperers() const { return whisperers_; }
|
||||
|
||||
void add_chat_message(const time_t& time, const std::string& speaker,
|
||||
void add_chat_message(const std::time_t& time, const std::string& speaker,
|
||||
int side, const std::string& msg, events::chat_handler::MESSAGE_TYPE type, bool bell);
|
||||
void clear_chat_messages() { prune_chat_messages(true); }
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ bool file_exists(const std::string& name)
|
|||
return file_exists(bfs::path(name));
|
||||
}
|
||||
|
||||
time_t file_modified_time(const std::string& fname)
|
||||
std::time_t file_modified_time(const std::string& fname)
|
||||
{
|
||||
error_code ec;
|
||||
std::time_t mtime = bfs::last_write_time(bfs::path(fname), ec);
|
||||
|
|
|
@ -219,7 +219,7 @@ bool is_directory(const std::string& fname);
|
|||
bool file_exists(const std::string& name);
|
||||
|
||||
/** Get the modification time of a file. */
|
||||
time_t file_modified_time(const std::string& fname);
|
||||
std::time_t file_modified_time(const std::string& fname);
|
||||
|
||||
/** Returns true if the file ends with '.gz'. */
|
||||
bool is_gzip_file(const std::string& filename);
|
||||
|
@ -239,7 +239,7 @@ struct file_tree_checksum
|
|||
void reset() {nfiles = 0;modified = 0;sum_size=0;}
|
||||
// @todo make variables private!
|
||||
std::size_t nfiles, sum_size;
|
||||
time_t modified;
|
||||
std::time_t modified;
|
||||
bool operator==(const file_tree_checksum &rhs) const;
|
||||
bool operator!=(const file_tree_checksum &rhs) const
|
||||
{ return !operator==(rhs); }
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
namespace utils {
|
||||
|
||||
std::string format_time_summary(time_t t) {
|
||||
time_t curtime = time(nullptr);
|
||||
std::string format_time_summary(std::time_t t) {
|
||||
std::time_t curtime = time(nullptr);
|
||||
const struct tm* timeptr = localtime(&curtime);
|
||||
if(timeptr == nullptr) {
|
||||
return "";
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
#include <string>
|
||||
|
||||
namespace utils {
|
||||
std::string format_time_summary(time_t t);
|
||||
std::string format_time_summary(std::time_t t);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static lg::log_domain log_lobby("lobby");
|
|||
|
||||
namespace mp {
|
||||
|
||||
chat_message::chat_message(const time_t& timestamp,
|
||||
chat_message::chat_message(const std::time_t& timestamp,
|
||||
const std::string& user,
|
||||
const std::string& message)
|
||||
: timestamp(timestamp), user(user), message(message)
|
||||
|
@ -57,7 +57,7 @@ chat_session::chat_session() : history_()
|
|||
{
|
||||
}
|
||||
|
||||
void chat_session::add_message(const time_t& timestamp,
|
||||
void chat_session::add_message(const std::time_t& timestamp,
|
||||
const std::string& user,
|
||||
const std::string& message)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <ctime>
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
|
@ -28,11 +29,11 @@ namespace mp {
|
|||
struct chat_message
|
||||
{
|
||||
/** Create a chat message */
|
||||
chat_message(const time_t& timestamp,
|
||||
chat_message(const std::time_t& timestamp,
|
||||
const std::string& user,
|
||||
const std::string& message);
|
||||
|
||||
time_t timestamp;
|
||||
std::time_t timestamp;
|
||||
std::string user;
|
||||
std::string message;
|
||||
};
|
||||
|
@ -43,7 +44,7 @@ class chat_session
|
|||
public:
|
||||
chat_session();
|
||||
|
||||
void add_message(const time_t& timestamp,
|
||||
void add_message(const std::time_t& timestamp,
|
||||
const std::string& user,
|
||||
const std::string& message);
|
||||
|
||||
|
|
|
@ -832,7 +832,7 @@ void addon_manager::copy_url_callback(text_box& url_box)
|
|||
desktop::clipboard::copy_to_clipboard(url_box.get_value(), false);
|
||||
}
|
||||
|
||||
static std::string format_addon_time(time_t time)
|
||||
static std::string format_addon_time(std::time_t time)
|
||||
{
|
||||
if(time) {
|
||||
std::ostringstream ss;
|
||||
|
|
|
@ -174,7 +174,7 @@ debug_clock::time::time() : hour(0), minute(0), second(0), millisecond(0)
|
|||
|
||||
void debug_clock::time::set_current_time()
|
||||
{
|
||||
time_t now = ::time(nullptr);
|
||||
std::time_t now = ::time(nullptr);
|
||||
tm* stamp = localtime(&now);
|
||||
|
||||
hour = stamp->tm_hour;
|
||||
|
|
|
@ -253,7 +253,7 @@ void chatbox::user_relation_changed(const std::string& /*name*/)
|
|||
}
|
||||
}
|
||||
|
||||
void chatbox::add_chat_message(const time_t& /*time*/,
|
||||
void chatbox::add_chat_message(const std::time_t& /*time*/,
|
||||
const std::string& speaker,
|
||||
int /*side*/,
|
||||
const std::string& message,
|
||||
|
|
|
@ -107,7 +107,7 @@ protected:
|
|||
virtual void user_relation_changed(const std::string& name) override;
|
||||
|
||||
/** Inherited form @ref chat_handler */
|
||||
virtual void add_chat_message(const time_t& time,
|
||||
virtual void add_chat_message(const std::time_t& time,
|
||||
const std::string& speaker,
|
||||
int side,
|
||||
const std::string& message,
|
||||
|
|
|
@ -84,7 +84,7 @@ std::string get_base_filename()
|
|||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
time_t t = time(nullptr);
|
||||
std::time_t t = time(nullptr);
|
||||
ss << std::put_time(std::localtime(&t), "%Y%m%d_%H%M%S");
|
||||
|
||||
static unsigned counter = 0;
|
||||
|
|
|
@ -172,18 +172,18 @@ bool broke_strict() {
|
|||
return strict_threw_;
|
||||
}
|
||||
|
||||
std::string get_timestamp(const time_t& t, const std::string& format) {
|
||||
std::string get_timestamp(const std::time_t& t, const std::string& format) {
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << std::put_time(std::localtime(&t), format.c_str());
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
std::string get_timespan(const time_t& t) {
|
||||
std::string get_timespan(const std::time_t& t) {
|
||||
std::ostringstream sout;
|
||||
// There doesn't seem to be any library function for this
|
||||
const time_t minutes = t / 60;
|
||||
const time_t days = minutes / 60 / 24;
|
||||
const std::time_t minutes = t / 60;
|
||||
const std::time_t days = minutes / 60 / 24;
|
||||
if(t <= 0) {
|
||||
sout << "expired";
|
||||
} else if(minutes == 0) {
|
||||
|
|
|
@ -138,8 +138,8 @@ public:
|
|||
|
||||
void timestamps(bool);
|
||||
void precise_timestamps(bool);
|
||||
std::string get_timestamp(const time_t& t, const std::string& format="%Y%m%d %H:%M:%S ");
|
||||
std::string get_timespan(const time_t& t);
|
||||
std::string get_timestamp(const std::time_t& t, const std::string& format="%Y%m%d %H:%M:%S ");
|
||||
std::string get_timespan(const std::time_t& t);
|
||||
|
||||
logger &err(), &warn(), &info(), &debug();
|
||||
log_domain& general();
|
||||
|
|
|
@ -109,7 +109,7 @@ std::string unique_log_filename()
|
|||
|
||||
o << log_file_prefix;
|
||||
|
||||
const time_t cur = time(nullptr);
|
||||
const std::time_t cur = time(nullptr);
|
||||
o << std::put_time(std::localtime(&cur), "%Y%m%d-%H%M%S-");
|
||||
|
||||
o << GetCurrentProcessId() << log_file_suffix;
|
||||
|
|
|
@ -1011,7 +1011,7 @@ void menu_handler::do_speak()
|
|||
textbox_info_.box()->text(), textbox_info_.check() != nullptr ? textbox_info_.check()->checked() : false);
|
||||
}
|
||||
|
||||
void menu_handler::add_chat_message(const time_t& time,
|
||||
void menu_handler::add_chat_message(const std::time_t& time,
|
||||
const std::string& speaker,
|
||||
int side,
|
||||
const std::string& message,
|
||||
|
@ -1272,7 +1272,7 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
|
|||
config cfg;
|
||||
cfg["id"] = preferences::login();
|
||||
cfg["message"] = message;
|
||||
const time_t time = ::time(nullptr);
|
||||
const std::time_t time = ::time(nullptr);
|
||||
std::stringstream ss;
|
||||
ss << time;
|
||||
cfg["time"] = ss.str();
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
const gamemap& map() const;
|
||||
|
||||
protected:
|
||||
void add_chat_message(const time_t& time,
|
||||
void add_chat_message(const std::time_t& time,
|
||||
const std::string& speaker,
|
||||
int side,
|
||||
const std::string& message,
|
||||
|
|
|
@ -889,7 +889,7 @@ compression::format save_compression_format()
|
|||
return compression::GZIP;
|
||||
}
|
||||
|
||||
std::string get_chat_timestamp(const time_t& t) {
|
||||
std::string get_chat_timestamp(const std::time_t& t) {
|
||||
if (chat_timestamping()) {
|
||||
if(preferences::use_twelve_hour_clock_format() == false) {
|
||||
return lg::get_timestamp(t, _("[%H:%M]")) + " ";
|
||||
|
|
|
@ -199,7 +199,7 @@ class acquaintance;
|
|||
|
||||
|
||||
// Multiplayer functions
|
||||
std::string get_chat_timestamp(const time_t& t);
|
||||
std::string get_chat_timestamp(const std::time_t& t);
|
||||
bool chat_timestamping();
|
||||
void set_chat_timestamping(bool value);
|
||||
|
||||
|
|
|
@ -124,9 +124,9 @@ static void verify(const unit_map& units, const config& cfg) {
|
|||
LOG_REPLAY << "verification passed\n";
|
||||
}
|
||||
|
||||
static time_t get_time(const config &speak)
|
||||
static std::time_t get_time(const config &speak)
|
||||
{
|
||||
time_t time;
|
||||
std::time_t time;
|
||||
if (!speak["time"].empty())
|
||||
{
|
||||
std::stringstream ss(speak["time"].str());
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "map/location.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
@ -35,14 +36,14 @@ public:
|
|||
const std::string &text() const { return text_; }
|
||||
const std::string &nick() const { return nick_; }
|
||||
const std::string &color() const { return color_; }
|
||||
const time_t &time() const { return time_; }
|
||||
const std::time_t &time() const { return time_; }
|
||||
chat_msg(const config &cfg);
|
||||
virtual ~chat_msg();
|
||||
private:
|
||||
std::string color_;
|
||||
std::string nick_;
|
||||
std::string text_;
|
||||
time_t time_;
|
||||
std::time_t time_;
|
||||
};
|
||||
|
||||
class replay
|
||||
|
|
|
@ -1534,7 +1534,7 @@ REPORT_GENERATOR(report_clock, /*rc*/)
|
|||
? "%I:%M %p"
|
||||
: "%H:%M";
|
||||
|
||||
time_t t = std::time(nullptr);
|
||||
std::time_t t = std::time(nullptr);
|
||||
ss << std::put_time(std::localtime(&t), format);
|
||||
|
||||
return text_report(ss.str(), _("Clock"));
|
||||
|
|
|
@ -43,11 +43,11 @@ void extract_summary_from_config(config&, config&);
|
|||
|
||||
void save_index_class::rebuild(const std::string& name)
|
||||
{
|
||||
time_t modified = filesystem::file_modified_time(filesystem::get_saves_dir() + "/" + name);
|
||||
std::time_t modified = filesystem::file_modified_time(filesystem::get_saves_dir() + "/" + name);
|
||||
rebuild(name, modified);
|
||||
}
|
||||
|
||||
void save_index_class::rebuild(const std::string& name, const time_t& modified)
|
||||
void save_index_class::rebuild(const std::string& name, const std::time_t& modified)
|
||||
{
|
||||
log_scope("load_summary_from_file");
|
||||
|
||||
|
@ -74,7 +74,7 @@ void save_index_class::remove(const std::string& name)
|
|||
write_save_index();
|
||||
}
|
||||
|
||||
void save_index_class::set_modified(const std::string& name, const time_t& modified)
|
||||
void save_index_class::set_modified(const std::string& name, const std::time_t& modified)
|
||||
{
|
||||
modified_[name] = modified;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void save_index_class::set_modified(const std::string& name, const time_t& modif
|
|||
config& save_index_class::get(const std::string& name)
|
||||
{
|
||||
config& result = data(name);
|
||||
time_t m = modified_[name];
|
||||
std::time_t m = modified_[name];
|
||||
|
||||
config::attribute_value& mod_time = result["mod_time"];
|
||||
if(mod_time.empty() || mod_time.to_time_t() != m) {
|
||||
|
@ -227,7 +227,7 @@ std::string save_info::format_time_local() const
|
|||
|
||||
std::string save_info::format_time_summary() const
|
||||
{
|
||||
time_t t = modified();
|
||||
std::time_t t = modified();
|
||||
return utils::format_time_summary(t);
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ create_save_info::create_save_info(const std::string* d)
|
|||
|
||||
save_info create_save_info::operator()(const std::string& filename) const
|
||||
{
|
||||
time_t modified = filesystem::file_modified_time(dir + "/" + filename);
|
||||
std::time_t modified = filesystem::file_modified_time(dir + "/" + filename);
|
||||
save_index_manager.set_modified(filename, modified);
|
||||
return save_info(filename, modified);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class save_info
|
|||
private:
|
||||
friend class create_save_info;
|
||||
|
||||
save_info(const std::string& name, const time_t& modified)
|
||||
save_info(const std::string& name, const std::time_t& modified)
|
||||
: name_(name)
|
||||
, modified_(modified)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
return name_;
|
||||
}
|
||||
|
||||
const time_t& modified() const
|
||||
const std::time_t& modified() const
|
||||
{
|
||||
return modified_;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string name_;
|
||||
time_t modified_;
|
||||
std::time_t modified_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -86,10 +86,10 @@ public:
|
|||
save_index_class();
|
||||
|
||||
void rebuild(const std::string& name);
|
||||
void rebuild(const std::string& name, const time_t& modified);
|
||||
void rebuild(const std::string& name, const std::time_t& modified);
|
||||
|
||||
void remove(const std::string& name);
|
||||
void set_modified(const std::string& name, const time_t& modified);
|
||||
void set_modified(const std::string& name, const std::time_t& modified);
|
||||
|
||||
config& get(const std::string& name);
|
||||
|
||||
|
@ -103,7 +103,7 @@ private:
|
|||
|
||||
bool loaded_;
|
||||
config data_;
|
||||
std::map<std::string, time_t> modified_;
|
||||
std::map<std::string, std::time_t> modified_;
|
||||
};
|
||||
|
||||
extern save_index_class save_index_manager;
|
||||
|
|
|
@ -85,7 +85,7 @@ static lg::log_domain log_server("server");
|
|||
}
|
||||
|
||||
banned::banned(const std::string& ip,
|
||||
const time_t end_time,
|
||||
const std::time_t end_time,
|
||||
const std::string& reason,
|
||||
const std::string& who_banned,
|
||||
const std::string& group,
|
||||
|
@ -324,7 +324,7 @@ static lg::log_domain log_server("server");
|
|||
writer.write(cfg);
|
||||
}
|
||||
|
||||
bool ban_manager::parse_time(const std::string& duration, time_t* time) const
|
||||
bool ban_manager::parse_time(const std::string& duration, std::time_t* time) const
|
||||
{
|
||||
if (!time) return false;
|
||||
|
||||
|
@ -489,7 +489,7 @@ static lg::log_domain log_server("server");
|
|||
}
|
||||
|
||||
std::string ban_manager::ban(const std::string& ip,
|
||||
const time_t& end_time,
|
||||
const std::time_t& end_time,
|
||||
const std::string& reason,
|
||||
const std::string& who_banned,
|
||||
const std::string& group,
|
||||
|
@ -562,7 +562,7 @@ static lg::log_domain log_server("server");
|
|||
write();
|
||||
}
|
||||
|
||||
void ban_manager::check_ban_times(time_t time_now)
|
||||
void ban_manager::check_ban_times(std::time_t time_now)
|
||||
{
|
||||
while (!time_queue_.empty())
|
||||
{
|
||||
|
@ -704,7 +704,7 @@ static lg::log_domain log_server("server");
|
|||
{
|
||||
ban_times_.clear();
|
||||
for (const config &bt : cfg.child_range("ban_time")) {
|
||||
time_t duration = 0;
|
||||
std::time_t duration = 0;
|
||||
if (parse_time(bt["time"], &duration)) {
|
||||
ban_times_.emplace(bt["name"], duration);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ namespace wesnothd {
|
|||
unsigned int ip_;
|
||||
unsigned int mask_;
|
||||
std::string ip_text_;
|
||||
time_t end_time_;
|
||||
time_t start_time_;
|
||||
std::time_t end_time_;
|
||||
std::time_t start_time_;
|
||||
std::string reason_;
|
||||
std::string who_banned_;
|
||||
std::string group_;
|
||||
|
@ -68,19 +68,19 @@ namespace wesnothd {
|
|||
banned(const std::string& ip);
|
||||
|
||||
public:
|
||||
banned(const std::string& ip, const time_t end_time, const std::string& reason, const std::string& who_banned=who_banned_default_, const std::string& group="", const std::string& nick="");
|
||||
banned(const std::string& ip, const std::time_t end_time, const std::string& reason, const std::string& who_banned=who_banned_default_, const std::string& group="", const std::string& nick="");
|
||||
banned(const config&);
|
||||
|
||||
void read(const config&);
|
||||
void write(config&) const;
|
||||
|
||||
time_t get_end_time() const
|
||||
std::time_t get_end_time() const
|
||||
{ return end_time_; }
|
||||
|
||||
std::string get_human_end_time() const;
|
||||
std::string get_human_start_time() const;
|
||||
std::string get_human_time_span() const;
|
||||
static std::string get_human_time(const time_t&);
|
||||
static std::string get_human_time(const std::time_t&);
|
||||
|
||||
std::string get_reason() const
|
||||
{ return reason_; }
|
||||
|
@ -135,7 +135,7 @@ namespace wesnothd {
|
|||
{ return c - '0'; }
|
||||
|
||||
void init_ban_help();
|
||||
void check_ban_times(time_t time_now);
|
||||
void check_ban_times(std::time_t time_now);
|
||||
inline void expire_bans() {
|
||||
check_ban_times(time(nullptr));
|
||||
}
|
||||
|
@ -152,9 +152,9 @@ namespace wesnothd {
|
|||
* @returns false if an invalid time modifier is encountered.
|
||||
* *time is undefined in that case.
|
||||
*/
|
||||
bool parse_time(const std::string& duration, time_t* time) const;
|
||||
bool parse_time(const std::string& duration, std::time_t* time) const;
|
||||
|
||||
std::string ban(const std::string&, const time_t&, const std::string&, const std::string&, const std::string&, const std::string& = "");
|
||||
std::string ban(const std::string&, const std::time_t&, const std::string&, const std::string&, const std::string&, const std::string& = "");
|
||||
void unban(std::ostringstream& os, const std::string& ip, bool immediate_write=true);
|
||||
void unban_group(std::ostringstream& os, const std::string& group);
|
||||
|
||||
|
|
|
@ -220,8 +220,8 @@ std::string fuh::user_info(const std::string& name) {
|
|||
throw error("No user with the name '" + name + "' exists.");
|
||||
}
|
||||
|
||||
time_t reg_date = get_registrationdate(name);
|
||||
time_t ll_date = get_lastlogin(name);
|
||||
std::time_t reg_date = get_registrationdate(name);
|
||||
std::time_t ll_date = get_lastlogin(name);
|
||||
|
||||
std::string reg_string = ctime(®_date);
|
||||
std::string ll_string;
|
||||
|
@ -269,27 +269,27 @@ std::string fuh::get_mail(const std::string& user) {
|
|||
}
|
||||
}
|
||||
|
||||
time_t fuh::get_lastlogin(const std::string& user) {
|
||||
std::time_t fuh::get_lastlogin(const std::string& user) {
|
||||
try {
|
||||
int time_int = get_writable_detail_for_user<int>(user, "user_lastvisit");
|
||||
return time_t(time_int);
|
||||
return std::time_t(time_int);
|
||||
} catch (const sql_error& e) {
|
||||
ERR_UH << "Could not retrieve last visit for user '" << user << "' :" << e.message << std::endl;
|
||||
return time_t(0);
|
||||
return std::time_t(0);
|
||||
}
|
||||
}
|
||||
|
||||
time_t fuh::get_registrationdate(const std::string& user) {
|
||||
std::time_t fuh::get_registrationdate(const std::string& user) {
|
||||
try {
|
||||
int time_int = get_detail_for_user<int>(user, "user_regdate");
|
||||
return time_t(time_int);
|
||||
return std::time_t(time_int);
|
||||
} catch (const sql_error& e) {
|
||||
ERR_UH << "Could not retrieve registration date for user '" << user << "' :" << e.message << std::endl;
|
||||
return time_t(0);
|
||||
return std::time_t(0);
|
||||
}
|
||||
}
|
||||
|
||||
void fuh::set_lastlogin(const std::string& user, const time_t& lastlogin) {
|
||||
void fuh::set_lastlogin(const std::string& user, const std::time_t& lastlogin) {
|
||||
|
||||
try {
|
||||
write_detail(user, "user_lastvisit", int(lastlogin));
|
||||
|
|
|
@ -85,11 +85,11 @@ class fuh : public user_handler {
|
|||
std::string get_mail(const std::string& user);
|
||||
/*std::vector<std::string> get_friends(const std::string& user);
|
||||
std::vector<std::string> get_ignores(const std::string& user);*/
|
||||
time_t get_lastlogin(const std::string& user);
|
||||
time_t get_registrationdate(const std::string& user);
|
||||
std::time_t get_lastlogin(const std::string& user);
|
||||
std::time_t get_registrationdate(const std::string& user);
|
||||
bool is_inactive(const std::string& user);
|
||||
|
||||
void set_lastlogin(const std::string& user, const time_t& lastlogin);
|
||||
void set_lastlogin(const std::string& user, const std::time_t& lastlogin);
|
||||
|
||||
std::string db_name_, db_host_, db_user_, db_password_, db_users_table_, db_banlist_table_, db_extra_table_;
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ std::ostream& metrics::requests(std::ostream& out) const
|
|||
|
||||
std::ostream& operator<<(std::ostream& out, metrics& met)
|
||||
{
|
||||
const time_t time_up = time(nullptr) - met.started_at_;
|
||||
const std::time_t time_up = time(nullptr) - met.started_at_;
|
||||
const int seconds = time_up%60;
|
||||
const int minutes = (time_up/60)%60;
|
||||
const int hours = (time_up/(60*60))%24;
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
int current_requests_;
|
||||
int nrequests_;
|
||||
int nrequests_waited_;
|
||||
const time_t started_at_;
|
||||
const std::time_t started_at_;
|
||||
std::map<std::string,int> terminations_;
|
||||
};
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ void wesnothd::player::mark_registered(bool registered)
|
|||
|
||||
bool wesnothd::player::is_message_flooding()
|
||||
{
|
||||
const time_t now = time(nullptr);
|
||||
const std::time_t now = time(nullptr);
|
||||
if (flood_start_ == 0) {
|
||||
flood_start_ = now;
|
||||
return false;
|
||||
|
|
|
@ -73,10 +73,10 @@ private:
|
|||
|
||||
bool registered_;
|
||||
|
||||
time_t flood_start_;
|
||||
std::time_t flood_start_;
|
||||
unsigned int messages_since_flood_start_;
|
||||
const std::size_t MaxMessages;
|
||||
const time_t TimePeriod;
|
||||
const std::time_t TimePeriod;
|
||||
STATUS status_;
|
||||
bool moderator_;
|
||||
};
|
||||
|
|
|
@ -119,7 +119,7 @@ void suh::set_realname(const std::string& user, const std::string& realname) {
|
|||
// set_lastlogin() is not called by the server via set_user_detail()
|
||||
// and thus must not throw user_handler::error
|
||||
|
||||
void suh::set_lastlogin(const std::string& user, const time_t& lastlogin) {
|
||||
void suh::set_lastlogin(const std::string& user, const std::time_t& lastlogin) {
|
||||
users_[user].lastlogin = lastlogin;
|
||||
}
|
||||
|
||||
|
@ -137,11 +137,11 @@ std::string suh::get_realname(const std::string& user) {
|
|||
return users_[user].realname;
|
||||
}
|
||||
|
||||
time_t suh::get_lastlogin(const std::string& user) {
|
||||
std::time_t suh::get_lastlogin(const std::string& user) {
|
||||
return users_[user].lastlogin;
|
||||
}
|
||||
|
||||
time_t suh::get_registrationdate(const std::string& user) {
|
||||
std::time_t suh::get_registrationdate(const std::string& user) {
|
||||
return users_[user].registrationdate;
|
||||
}
|
||||
|
||||
|
@ -185,11 +185,11 @@ void suh::clean_up() {
|
|||
return;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
std::time_t now = time(nullptr);
|
||||
|
||||
//A minute has 60 seconds, an hour 60 minutes and
|
||||
//a day 24 hours.
|
||||
time_t limit = user_expiration_ * 60 * 60 * 24;
|
||||
std::time_t limit = user_expiration_ * 60 * 60 * 24;
|
||||
|
||||
std::vector<std::string> us = users();
|
||||
for(std::vector<std::string>::const_iterator u = us.begin(); u != us.end(); ++u) {
|
||||
|
@ -211,8 +211,8 @@ void suh::user_logged_in(const std::string& name) {
|
|||
std::string suh::user_info(const std::string& name) {
|
||||
if(!user_exists(name)) throw error("No user with the name '" + name + "' exists.");
|
||||
|
||||
time_t reg_date = get_registrationdate(name);
|
||||
time_t ll_date = get_lastlogin(name);
|
||||
std::time_t reg_date = get_registrationdate(name);
|
||||
std::time_t ll_date = get_lastlogin(name);
|
||||
|
||||
std::string reg_string = ctime(®_date);
|
||||
std::string ll_string;
|
||||
|
|
|
@ -58,8 +58,8 @@ class suh : public user_handler {
|
|||
std::string password;
|
||||
std::string realname;
|
||||
std::string mail;
|
||||
time_t lastlogin;
|
||||
time_t registrationdate;
|
||||
std::time_t lastlogin;
|
||||
std::time_t registrationdate;
|
||||
bool is_moderator;
|
||||
};
|
||||
|
||||
|
@ -73,8 +73,8 @@ class suh : public user_handler {
|
|||
std::string get_mail(const std::string& user);
|
||||
std::string get_password(const std::string& user);
|
||||
std::string get_realname(const std::string& user) ;
|
||||
time_t get_lastlogin(const std::string& user);
|
||||
time_t get_registrationdate(const std::string& user);
|
||||
std::time_t get_lastlogin(const std::string& user);
|
||||
std::time_t get_registrationdate(const std::string& user);
|
||||
|
||||
void check_name(const std::string& name);
|
||||
void check_mail(const std::string& mail);
|
||||
|
@ -85,7 +85,7 @@ class suh : public user_handler {
|
|||
void set_password(const std::string& user, const std::string& password);
|
||||
void set_realname(const std::string& user, const std::string& realname);
|
||||
|
||||
void set_lastlogin(const std::string& user, const time_t& lastlogin);
|
||||
void set_lastlogin(const std::string& user, const std::time_t& lastlogin);
|
||||
|
||||
int user_expiration_;
|
||||
|
||||
|
|
|
@ -504,14 +504,14 @@ std::string server::is_ip_banned(const std::string& ip) {
|
|||
return ban_manager_.is_ip_banned(ip);
|
||||
}
|
||||
|
||||
void server::dump_stats(const time_t& now) {
|
||||
void server::dump_stats(const std::time_t& now) {
|
||||
last_stats_ = now;
|
||||
LOG_SERVER << "Statistics:"
|
||||
<< "\tnumber_of_games = " << games().size()
|
||||
<< "\tnumber_of_users = " << player_connections_.size() << "\n";
|
||||
}
|
||||
|
||||
void server::clean_user_handler(const time_t& now) {
|
||||
void server::clean_user_handler(const std::time_t& now) {
|
||||
if(!user_handler_) {
|
||||
return;
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ bool server::authenticate(socket_ptr socket, const std::string& username, const
|
|||
}
|
||||
// This name is registered and an incorrect password provided
|
||||
else if(!(user_handler_->login(username, password, seeds_[reinterpret_cast<unsigned long>(socket.get())]))) {
|
||||
const time_t now = time(nullptr);
|
||||
const std::time_t now = time(nullptr);
|
||||
|
||||
// Reset the random seed
|
||||
seeds_.erase(reinterpret_cast<unsigned long>(socket.get()));
|
||||
|
@ -1812,7 +1812,7 @@ void server::send_server_message_to_all(const std::string& message, socket_ptr e
|
|||
}
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
std::time_t now = time(nullptr);
|
||||
if (last_ping_ + network::ping_interval <= now) {
|
||||
if (lan_server_ && players_.empty() && last_user_seen_time_ + lan_server_ < now)
|
||||
{
|
||||
|
@ -2432,7 +2432,7 @@ void server::ban_handler(const std::string& issuer_name, const std::string& /*qu
|
|||
const std::string target(parameters.begin(), first_space);
|
||||
|
||||
const std::string duration(first_space + 1, second_space);
|
||||
time_t parsed_time = time(nullptr);
|
||||
std::time_t parsed_time = time(nullptr);
|
||||
if (ban_manager_.parse_time(duration, &parsed_time) == false) {
|
||||
*out << "Failed to parse the ban duration: '" << duration << "'\n"
|
||||
<< ban_manager_.get_ban_help();
|
||||
|
@ -2500,7 +2500,7 @@ void server::kickban_handler(const std::string& issuer_name, const std::string&
|
|||
std::string::iterator second_space = std::find(first_space + 1, parameters.end(), ' ');
|
||||
const std::string target(parameters.begin(), first_space);
|
||||
const std::string duration(first_space + 1, second_space);
|
||||
time_t parsed_time = time(nullptr);
|
||||
std::time_t parsed_time = time(nullptr);
|
||||
if (ban_manager_.parse_time(duration, &parsed_time) == false) {
|
||||
*out << "Failed to parse the ban duration: '" << duration << "'\n"
|
||||
<< ban_manager_.get_ban_help();
|
||||
|
@ -2589,7 +2589,7 @@ void server::gban_handler(const std::string& issuer_name, const std::string& /*q
|
|||
second_space = std::find(first_space + 1, parameters.end(), ' ');
|
||||
|
||||
const std::string duration(first_space + 1, second_space);
|
||||
time_t parsed_time = time(nullptr);
|
||||
std::time_t parsed_time = time(nullptr);
|
||||
if (ban_manager_.parse_time(duration, &parsed_time) == false) {
|
||||
*out << "Failed to parse the ban duration: '" << duration << "'\n"
|
||||
<< ban_manager_.get_ban_help();
|
||||
|
|
|
@ -74,10 +74,10 @@ private:
|
|||
wesnothd::ban_manager ban_manager_;
|
||||
|
||||
struct connection_log {
|
||||
connection_log(std::string _nick, std::string _ip, time_t _log_off) :
|
||||
connection_log(std::string _nick, std::string _ip, std::time_t _log_off) :
|
||||
nick(_nick), ip(_ip), log_off(_log_off) {}
|
||||
std::string nick, ip;
|
||||
time_t log_off;
|
||||
std::time_t log_off;
|
||||
|
||||
bool operator==(const connection_log& c) const
|
||||
{
|
||||
|
@ -89,11 +89,11 @@ private:
|
|||
std::deque<connection_log> ip_log_;
|
||||
|
||||
struct login_log {
|
||||
login_log(std::string _ip, int _attempts, time_t _first_attempt) :
|
||||
login_log(std::string _ip, int _attempts, std::time_t _first_attempt) :
|
||||
ip(_ip), attempts(_attempts), first_attempt(_first_attempt) {}
|
||||
std::string ip;
|
||||
int attempts;
|
||||
time_t first_attempt;
|
||||
std::time_t first_attempt;
|
||||
|
||||
bool operator==(const login_log& l) const
|
||||
{
|
||||
|
@ -140,8 +140,8 @@ private:
|
|||
std::size_t default_time_period_;
|
||||
std::size_t concurrent_connections_;
|
||||
bool graceful_restart;
|
||||
time_t lan_server_;
|
||||
time_t last_user_seen_time_;
|
||||
std::time_t lan_server_;
|
||||
std::time_t last_user_seen_time_;
|
||||
std::string restart_command;
|
||||
std::size_t max_ip_log_size_;
|
||||
std::string uh_name_;
|
||||
|
@ -151,7 +151,7 @@ private:
|
|||
bool allow_remote_shutdown_;
|
||||
std::vector<std::string> tor_ip_list_;
|
||||
int failed_login_limit_;
|
||||
time_t failed_login_ban_;
|
||||
std::time_t failed_login_ban_;
|
||||
std::deque<login_log>::size_type failed_login_buffer_size_;
|
||||
|
||||
/** Parse the server config into local variables. */
|
||||
|
@ -167,12 +167,12 @@ private:
|
|||
|
||||
metrics metrics_;
|
||||
|
||||
time_t last_ping_;
|
||||
time_t last_stats_;
|
||||
void dump_stats(const time_t& now);
|
||||
std::time_t last_ping_;
|
||||
std::time_t last_stats_;
|
||||
void dump_stats(const std::time_t& now);
|
||||
|
||||
time_t last_uh_clean_;
|
||||
void clean_user_handler(const time_t& now);
|
||||
std::time_t last_uh_clean_;
|
||||
void clean_user_handler(const std::time_t& now);
|
||||
|
||||
/** Process commands from admins and users. */
|
||||
std::string process_command(std::string cmd, std::string issuer_name);
|
||||
|
|
|
@ -862,7 +862,7 @@ struct dialog_tester<mp_lobby>
|
|||
};
|
||||
|
||||
class fake_chat_handler : public events::chat_handler {
|
||||
void add_chat_message(const time_t&,
|
||||
void add_chat_message(const std::time_t&,
|
||||
const std::string&, int, const std::string&,
|
||||
MESSAGE_TYPE) {}
|
||||
void send_chat_message(const std::string&, bool) {}
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
#include <clocale> // for setlocale, LC_ALL, etc
|
||||
#include <cstdio> // for remove, fprintf, stderr
|
||||
#include <cstdlib> // for srand, exit
|
||||
#include <ctime> // for time, ctime, time_t
|
||||
#include <ctime> // for time, ctime, std::time_t
|
||||
#include <exception> // for exception
|
||||
#include <fstream> // for operator<<, basic_ostream, etc
|
||||
#include <iostream> // for cerr, cout
|
||||
|
@ -1041,7 +1041,7 @@ int main(int argc, char** argv)
|
|||
|
||||
try {
|
||||
std::cerr << "Battle for Wesnoth v" << game_config::revision << '\n';
|
||||
const time_t t = time(nullptr);
|
||||
const std::time_t t = time(nullptr);
|
||||
std::cerr << "Started on " << ctime(&t) << "\n";
|
||||
|
||||
const std::string& exe_dir = filesystem::get_exe_dir();
|
||||
|
|
Loading…
Add table
Reference in a new issue