22 bool registered,
const size_t max_messages,
23 const size_t time_period,
const bool sp,
28 , registered_(registered)
30 , messages_since_flood_start_(0)
31 , MaxMessages(max_messages)
32 , TimePeriod(time_period)
34 , moderator_(moderator)
48 cfg_.set_attr(
"status",
"lobby");
51 cfg_.set_attr(
"status",
"playing");
54 cfg_.set_attr(
"status",
"observing");
57 cfg_.set_attr(
"status",
"unknown");
66 cfg_.set_attr(
"available",
"yes");
69 cfg_.set_attr(
"available",
"no");
71 cfg_.set_attr_dup(
"game_id", lexical_cast_default<std::string>(game_id).c_str());
72 cfg_.set_attr_dup(
"location", location.c_str());
77 cfg_.set_attr(
"registered", registered ?
"yes" :
"no");
78 registered_ = registered;
83 const time_t now = time(
nullptr);
84 if (flood_start_ == 0) {
89 ++messages_since_flood_start_;
91 if (now - flood_start_ > TimePeriod) {
92 messages_since_flood_start_ = 0;
94 }
else if (messages_since_flood_start_ >= MaxMessages) {
node & set_attr(const char *key, const char *value)
void mark_available(const int game_id=0, const std::string &location="")
Templates and utility-routines for strings and numbers.
player(const std::string &n, simple_wml::node &cfg, bool registered, const size_t max_messages=4, const size_t time_period=10, const bool sp=false, const bool moderator=false)
Encapsulates the map of the game.
void mark_registered(bool registered=true)
node & set_attr_dup(const char *key, const char *value)
bool is_message_flooding()
void set_status(STATUS status)
GLsizei const GLcharARB ** string