boost::statechart::result MPLobby::react(const CheckSum& e) { TraceLogger(FSM) << "(HumanClientFSM) CheckSum."; std::map<std::string, unsigned int> checksums; ExtractContentCheckSumMessageData(e.m_message, checksums); InfoLogger() << "Got checksum message from server:"; for (const auto& c : checksums) InfoLogger() << c.first << " : " << c.second; return discard_event(); }
void GameRules::SetFromStrings(const std::map<std::string, std::string>& names_values) { CheckPendingGameRules(); DebugLogger() << "Setting Rules from Strings:"; for (const auto& entry : names_values) DebugLogger() << " " << entry.first << " : " << entry.second; ResetToDefaults(); for (auto& entry : names_values) { auto rule_it = m_game_rules.find(entry.first); if (rule_it == m_game_rules.end()) { InfoLogger() << "GameRules::serialize received unrecognized rule: " << entry.first; continue; } try { rule_it->second.SetFromString(entry.second); } catch (const boost::bad_lexical_cast& e) { ErrorLogger() << "Unable to set rule: " << entry.first << " to value: " << entry.second << " - couldn't cast string to allowed value for this option"; } catch (...) { ErrorLogger() << "Unable to set rule: " << entry.first << " to value: " << entry.second; } } DebugLogger() << "After Setting Rules:"; for (const auto& entry : m_game_rules) DebugLogger() << " " << entry.first << " : " << entry.second.ValueToString(); }
std::locale GetLocale(const std::string& name) { static bool locale_init { false }; // Initialize backend and generator on first use, provide a log for current enivornment locale static auto locale_backend = boost::locale::localization_backend_manager::global(); if (!locale_init) locale_backend.select("std"); static boost::locale::generator locale_gen(locale_backend); if (!locale_init) { locale_gen.locale_cache_enabled(true); try { InfoLogger() << "Global locale: " << std::use_facet<boost::locale::info>(locale_gen("")).name(); } catch (const std::runtime_error&) { ErrorLogger() << "Global locale: set to invalid locale, setting to C locale"; std::locale::global(std::locale::classic()); } locale_init = true; } std::locale retval; try { retval = locale_gen(name); } catch(const std::runtime_error&) { ErrorLogger() << "Requested locale \"" << name << "\" is not a valid locale for this operating system"; return std::locale::classic(); } TraceLogger() << "Requested " << (name.empty() ? "(default)" : name) << " locale" << " returning " << std::use_facet<boost::locale::info>(retval).name(); return retval; }
// static member(s) AIClientApp::AIClientApp(const std::vector<std::string>& args) : m_player_name(""), m_max_aggression(0) { if (args.size() < 2) { std::cerr << "The AI client should not be executed directly! Run freeorion to start the game."; ExitApp(1); } // read command line args m_player_name = args.at(1); if (args.size() >=3) { m_max_aggression = boost::lexical_cast<int>(args.at(2)); } // Force the log file if requested. if (GetOptionsDB().Get<std::string>("log-file").empty()) { const std::string AICLIENT_LOG_FILENAME((GetUserDataDir() / (m_player_name + ".log")).string()); GetOptionsDB().Set("log-file", AICLIENT_LOG_FILENAME); } // Force the log threshold if requested. auto force_log_level = GetOptionsDB().Get<std::string>("log-level"); if (!force_log_level.empty()) OverrideAllLoggersThresholds(to_LogLevel(force_log_level)); InitLoggingSystem(GetOptionsDB().Get<std::string>("log-file"), "AI"); InitLoggingOptionsDBSystem(); InfoLogger() << FreeOrionVersionString(); DebugLogger() << PlayerName() + " ai client initialized."; }
void ClientApp::VerifyCheckSum(const Message& msg) { std::map<std::string, unsigned int> server_checksums; ExtractContentCheckSumMessageData(msg, server_checksums); auto client_checksums = CheckSumContent(); if (server_checksums == client_checksums) { InfoLogger() << "Checksum received from server matches client checksum."; } else { WarnLogger() << "Checksum received from server does not match client checksum."; for (const auto& name_and_checksum : server_checksums) { const auto& name = name_and_checksum.first; const auto client_checksum = client_checksums[name]; if (client_checksum != name_and_checksum.second) WarnLogger() << "Checksum for " << name << " on server " << name_and_checksum.second << " != client " << client_checksum; } } }