void usage_update() { if(!cur_players.empty()) { short n = cur_players.size(); short nbots = num_bots(); usage_per_30min.push_back(n - nbots); string msg = lex_cast(n - nbots) + " players"; if(nbots) msg += " (+ " + lex_cast(nbots) + " bots)"; timed_log(msg); } }
Any operator()(const std::string&value) { return lex_cast(value); }
// The nopurge argument indicates we are running the server with "--pstats" void init_known_players(const bool nopurge) { string fname = Config::get_config_dir() + playerfilename; ifstream file(fname.c_str(), ios_base::binary); if(!file) { to_log("Could not read player data; file missing or not readable."); return; } short numpl; file.read(reinterpret_cast<char*>(&numpl), sizeof(short)); if(numpl != STAT_VERSION) { to_log("Wrong statistics version in player data! All statistics will be cleared!"); return; } file.read(reinterpret_cast<char*>(&numpl), sizeof(short)); if(numpl < 0 || numpl > MAX_STORED_PLAYERS) { to_log("Player datafile is corrupt! Ignoring the data!"); return; } if(!nopurge) to_log("Player data contains " + lex_cast(numpl) + " entries;"); PlayerStats tmpstats; short sh; char ch; tmpstats.password[PASSW_LEN] = '\0'; int tooold; if(nopurge) tooold = 0; else // statpurge is hours, tooold seconds: tooold = 60*60*Config::int_settings[Config::IS_STATPURGE]; while(numpl--) { file.read(reinterpret_cast<char*>(&tmpstats.ID), sizeof(short)); file.read(tmpstats.password, PASSW_LEN); file.read(reinterpret_cast<char*>(tmpstats.kills), MAX_WAY_TO_KILL*sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.deaths), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.tks), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.healing_recvd), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.total_time), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.time_specced), sizeof(long)); file.read(reinterpret_cast<char*>(tmpstats.time_played), NO_CLASS*sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.arch_hits), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.arch_shots), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.cm_hits), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.cm_shots), sizeof(long)); file.read(reinterpret_cast<char*>(&tmpstats.ad_lvl), sizeof(e_AdminLvl)); file.read(reinterpret_cast<char*>(&tmpstats.last_seen), sizeof(time_t)); tmpstats.last_known_as.clear(); for(file.read(reinterpret_cast<char *>(&sh), sizeof(short)); sh > 0; --sh) { file.read(reinterpret_cast<char *>(&ch), sizeof(char)); tmpstats.last_known_as += ch; } if(!tooold || tmpstats.ad_lvl > AL_REG || (time(NULL) - tmpstats.last_seen) < tooold) known_players.push_back(tmpstats); } if(!nopurge) to_log(lex_cast(known_players.size()) + " entries accepted."); }