void BaseSystem::TryLoadSystems () { BaseSystem* it ( GetFirst () ); while( it != nullptr ) { it->SetActive ( true ); GetNext ( it ); } }
void BaseSystem::InitSystems () { BaseSystem* it ( GetFirst () ); while( it != nullptr ) { it->Init (); GetNext ( it ); } }
void BaseSystem::TryUnloadSystems () { BaseSystem* it ( GetFirst () ); while( it != nullptr ) { if( ! it->GotJob () ) it->SetActive ( false ); GetNext ( it ); } }
void BaseSystem::UnloadAllSystems () { BaseSystem* it ( GetFirst () ); while( it != nullptr ) { it->SetActive ( false ); GetNext ( it ); } }
BaseSystem * BaseSystem::FindSystemByName ( const char * name ) { BaseSystem* it ( GetFirst () ); while( it != nullptr ) { if( stricmp ( it->GetName (), name ) == 0 ) return it; GetNext ( it ); } return nullptr; }
void World::addSystem(BaseSystem& system, detail::TypeId systemTypeId) { assert(!system.m_world && "System is already contained within a World"); m_systems[systemTypeId].reset(&system); system.m_world = this; system.initialize(); }
void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args ) { if( args.ArgC () > 1 ) { BaseSystem* it = GetFirst (); while( it != nullptr ) { if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 ) { if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 ) { it->SetConfig ( true ); it->SetActive ( true ); } else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 ) { it->SetConfig ( false ); it->SetActive ( false ); } else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 ) { if( args.ArgC () > 2 ) { it->m_verbose = atoi ( args.Arg ( 3 ) ); } return; } #ifdef NCZ_USE_METRICS else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().PrintAll (); } else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().ResetAll (); } #endif else if( !it->sys_cmd_fn ( args ) ) { printf ( "action %s not found.\nTry : %s\n", args.Arg ( 2 ), it->cmd_list () ); } return; } GetNext ( it ); } printf ( "System %s not found.\n", args.Arg ( 1 ) ); } else { printf ( "Usage: ncz system arg1 arg2 ...\n" ); printf ( "Systems list :\n" ); BaseSystem* it ( GetFirst () ); while( it != nullptr ) { printf ( "%s", it->GetName () ); if( it->IsActive () ) { printf ( " (Running)\n" ); } else if( !it->IsEnabledByConfig () ) { printf ( " (Disabled manually)\n" ); } else if( it->GetDisabledByConfigIni () ) { printf ( " (Disabled by config.ini)\n" ); } else { printf ( " (Sleeping - Waiting for players)\n" ); } printf ( "\tCommands : %s\n", it->cmd_list () ); GetNext ( it ); } } }
int animTcl::Command(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { if (argc < 2 ) { animTcl::OutputMessage("Usage: system|simulator <name> ...") ; return TCL_ERROR; } else if( strcmp(argv[0], "system") == 0 ) { // get the requested system by name and dispatch the command BaseSystem* tempSystem = GlobalResourceManager::use()->getSystem( argv[1] ); if( tempSystem != NULL ) { tempSystem->command( argc - 2, &argv[ 2 ] ); } else { animTcl::OutputMessage( "system %s was not found", argv[ 1 ] ) ; return TCL_ERROR; } } else if( strcmp(argv[0], "simulator") == 0 ) { // get the requested simulator by name and dispatch the command BaseSimulator* tempSimulator = GlobalResourceManager::use()->getSimulator( argv[1] ); if( tempSimulator != NULL ) { tempSimulator->command( argc - 2, &argv[ 2 ] ); } else { animTcl::OutputMessage("simulator %s was not found", argv[ 1 ] ) ; return TCL_ERROR; } } else if( strcmp(argv[0], "show" ) == 0 ) { if( argc < 2 ) { animTcl::OutputMessage("syntax: show system|simulator") ; return TCL_OK ; } if( strcmp(argv[1], "simulator" ) == 0 ) { unsigned int index; for( index = 0; index < GlobalResourceManager::use()->getNumberOfSimulators(); index++ ) { std::string name; GlobalResourceManager::use()->getSimulatorFromIndex( index )->getName( name ); animTcl::OutputListElement("%s", name.c_str() ) ; } } else if( strcmp(argv[1], "system" ) == 0 ) { unsigned int index; for( index = 0; index < GlobalResourceManager::use()->getNumberOfSystems(); index++ ) { std::string name; GlobalResourceManager::use()->getSystemFromIndex( index )->getName( name ); animTcl::OutputListElement("%s", name.c_str() ) ; } } } else if( strcmp(argv[0], "reset") == 0 ) { GlobalResourceManager::use()->resetAll(); } PostRedisplay(); return TCL_OK; }
void BaseSystem::ncz_cmd_fn ( const SourceSdk::CCommand &args ) { if( args.ArgC () > 1 ) { BaseSystem* it = GetFirst (); while( it != nullptr ) { if( stricmp ( it->GetName (), args.Arg ( 1 ) ) == 0 ) { if( stricmp ( "enable", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( true ); it->SetActive ( true ); } } else if( stricmp ( "disable", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( false ); it->SetActive ( false ); } } else if( stricmp ( "on", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( true ); it->SetActive ( true ); } } else if( stricmp ( "off", args.Arg ( 2 ) ) == 0 ) { if( it->IsStatic () ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s is static and cannot be loaded or unloaded", it->GetName () ) ); } else { it->SetConfig ( false ); it->SetActive ( false ); } } else if( stricmp ( "verbose", args.Arg ( 2 ) ) == 0 ) { if( args.ArgC () > 2 ) { it->m_verbose = atoi ( args.Arg ( 3 ) ); Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s verbose level is now %d", it->GetName (), it->m_verbose ) ); } return; } #ifdef NCZ_USE_METRICS else if( Helpers::bStriEq ( "printmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().PrintAll (); } else if( Helpers::bStriEq ( "resetmetrics", args.Arg ( 2 ) ) ) { ( *it )->GetMetrics ().ResetAll (); } #endif else if( !it->sys_cmd_fn ( args ) ) { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "action %s not found.\nTry : %s", args.Arg ( 2 ), it->cmd_list () ) ); } return; } GetNext ( it ); } Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( Helpers::format ( "System %s not found.", args.Arg ( 1 ) ) ); } else { Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( "Usage: ncz system arg1 arg2 ...\nSystems list :\n"); BaseSystem* it ( GetFirst () ); while( it != nullptr ) { basic_string prepared_message ( it->GetName () ); if( it->IsStatic () ) { prepared_message.append ( " (Static)\n" ); } else if( it->IsActive () ) { prepared_message.append ( " (Running)\n" ); } else if( !it->IsEnabledByConfig () ) { prepared_message.append ( " (Disabled manually)\n" ); } else if( it->GetDisabledByConfigIni () ) { prepared_message.append ( " (Disabled by config.ini)\n" ); } else { prepared_message.append ( " (Sleeping - Waiting for players)\n" ); } prepared_message.append ( Helpers::format( "\tCommands : %s\n", it->cmd_list () ) ); Logger::GetInstance ()->Msg<MSG_CMD_REPLY> ( prepared_message.c_str () ); GetNext ( it ); } } }