void CFriends::Init(bool Foes) { CALLSTACK_ADD(); m_Foes = Foes; IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); IConsole *pConsole = Kernel()->RequestInterface<IConsole>(); if(pConsole) { if(Foes) { pConsole->Register("add_foe", "s[name] ?s[clan]", CFGFLAG_CLIENT, ConAddFriend, this, "Add a foe"); pConsole->Register("remove_foe", "s[name] ?s[clan]", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a foe"); pConsole->Register("foes", "", CFGFLAG_CLIENT, ConFriends, this, "List foes"); } else { pConsole->Register("add_friend", "s[name] ?s[clan]", CFGFLAG_CLIENT, ConAddFriend, this, "Add a friend"); pConsole->Register("remove_friend", "s[name] ?s[clan]", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a friend"); pConsole->Register("friends", "", CFGFLAG_CLIENT, ConFriends, this, "List friends"); } } }
void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVersion) { m_pNetClient = pClient; str_copy(m_aNetVersion, pNetVersion, sizeof(m_aNetVersion)); m_pMasterServer = Kernel()->RequestInterface<IMasterServer>(); IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); }
void CLua::Init() { IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); IConsole *pConsole = Kernel()->RequestInterface<IConsole>(); if(pConsole) { pConsole->Register("add_lua_file", "s", CFGFLAG_CLIENT, ConAddLuaFile, this, "Add a Lua file"); } }
void CFriends::Init() { IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); IConsole *pConsole = Kernel()->RequestInterface<IConsole>(); if(pConsole) { pConsole->Register("add_friend", "ss", CFGFLAG_CLIENT, ConAddFriend, this, "Add a friend"); pConsole->Register("remove_Friend", "ss", CFGFLAG_CLIENT, ConRemoveFriend, this, "Remove a friend"); } }
void CLua::Init() { IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); m_pConsole = Kernel()->RequestInterface<IConsole>(); if(m_pConsole) { //m_pConsole->Register("add_lua_file", "s", CFGFLAG_SERVER, ConAddLuaFile, this, "Add a Lua file"); m_pConsole->Register("delete_lua_file", "s", CFGFLAG_SERVER, ConDeleteLuaFile, this, "Delete a Lua file"); m_pConsole->Register("delete_all_lua_files", "", CFGFLAG_SERVER, ConDeleteAllLuaFiles, this, "Delete all lua files"); m_pConsole->Register("list_lua_files", "", CFGFLAG_SERVER, ConListLuaFiles, this, "List active Lua files"); } }
int32_t CCmdHandler::LoadConfig(const char *pConfigName, const char *pFileContent) { int32_t nResult = 0; IConfig *pConfig = g_Frame.GetSafeConfig(pConfigName); if(pConfig != NULL) { nResult = pConfig->Parser((char *)pFileContent); } else { nResult = -1; } return nResult; }
void CBinds::OnConsoleInit() { // bindings IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); Console()->Register("bind", "sr", CFGFLAG_CLIENT, ConBind, this, "Bind key to execute the command"); Console()->Register("unbind", "s", CFGFLAG_CLIENT, ConUnbind, this, "Unbind key"); Console()->Register("unbindall", "", CFGFLAG_CLIENT, ConUnbindAll, this, "Unbind all keys"); Console()->Register("dump_binds", "", CFGFLAG_CLIENT, ConDumpBinds, this, "Dump binds"); // default bindings SetDefaults(); }
virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases ) const { for( std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin(), itEnd = m_functionsInOrder.end(); it != itEnd; ++it ) { if( testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() ) ) matchingTestCases.push_back( *it ); } }
virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases, bool negated = false ) const { for( std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin(), itEnd = m_functionsInOrder.end(); it != itEnd; ++it ) { bool includeTest = testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() ); if( includeTest != negated ) matchingTestCases.push_back( *it ); } sortTests( config, matchingTestCases ); }
// Processes interactive option void Installer::processInteractive() { // process all options IConfig* config = m_factory->getConfig(); // before set any new config file option // reread config file config->load(); // look for the option OptionList options = config->getOptions(); for (OptionList::iterator i = options.begin(); i != options.end(); i++) { const std::string name = (*i)->getName(); const std::string oldval = (*i)->getValue(); std::cout << "Option '" << name << "' has the following value: " << oldval << std::endl; if (ask("Do you want to change it [N/y]: ")) { std::string value = get("New value: "); setOption((*i)->getName(), value); } } if (ask("Do you want to recreate DB [N/y]: ")) { recreateDB(); } // resources detection if (ask("Do you want to detect resources [N/y]: ")) { detectResources(); } }
static void sortTests( IConfig const& config, std::vector<TestCase>& matchingTestCases ) { switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: std::sort( matchingTestCases.begin(), matchingTestCases.end(), LexSort() ); break; case RunTests::InRandomOrder: { RandomNumberGenerator rng; std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng ); } break; case RunTests::InDeclarationOrder: // already in declaration order break; } }
std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { std::vector<TestCase> sorted = unsortedTestCases; switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: std::sort( sorted.begin(), sorted.end() ); break; case RunTests::InRandomOrder: seedRng( config ); RandomNumberGenerator::shuffle( sorted ); break; case RunTests::InDeclarationOrder: // already in declaration order break; } return sorted; }
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { std::vector<TestCase> sorted = unsortedTestCases; switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: std::sort( sorted.begin(), sorted.end(), LexSort() ); break; case RunTests::InRandomOrder: { seedRng( config ); std::random_device rng; std::mt19937 urng(rng()); std::shuffle( sorted.begin(), sorted.end(), rng ); } break; case RunTests::InDeclarationOrder: // already in declaration order break; } return sorted; }
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); }
void seedRng( IConfig const& config ) { if( config.rngSeed() != 0 ) std::srand( config.rngSeed() ); }