void SolidTexture::read(const string &prefix) { backgroundColor = GetConfigColor(prefix, "Color", RGB(128, 128, 128)); bevel = GetConfigBoolean(prefix, "Bevel"); darkBevelColor = GetConfigColor(prefix, "DarkBevelColor", DarkenColor(backgroundColor)); lightBevelColor = GetConfigColor(prefix, "LightBevelColor", LightenColor(backgroundColor)); }
bool CServer::OnLoad() { // If in debug mode set memory test function #ifdef NIV_DEBUG atexit(MemoryTest); #endif // Open the log file CLogFile::Open("Server.log", true); // Install our exception handler CExceptionHandler::Install(); CLogFile::Printf("Starting up " SERVER_TITLE "..."); // Create the config instance g_pConfig = new CConfig(); if(!g_pConfig) { CLogFile::Printf("Failed to create config instance!"); return false; } CLogFile::Printf("Config instance created"); // Open the config file if(!g_pConfig->Open(String("%sServer.conf", SharedUtility::GetAppPath()))) CLogFile::Printf("Failed to open config file! Settings will default to appropriate values."); else CLogFile::Printf("Config file opened"); // Initialize the net module if(!CNetworkModule::Init()) { CLogFile::Printf("Failed to initialize the net module!"); return false; } CLogFile::Printf("Net module initialized"); // Create the network manager instance m_pNetworkManager = new CNetworkManager(); if(!m_pNetworkManager) { CLogFile::Printf("Failed to create network manager instance!"); return false; } CLogFile::Printf("Network manager instance created"); // Create the player manager instance m_pPlayerManager = new CPlayerManager(); if(!GetPlayerManager()) { CLogFile::Printf("Failed to create player manager instance!"); } CLogFile::Printf("Player manager instance created"); // Create the vehicle manager instance m_pVehicleManager = new CVehicleManager(); if(!m_pVehicleManager) { CLogFile::Printf("Failed to create vehicle manager instance!"); } CLogFile::Printf("Vehicle manager instance created"); // Get server port int iServerPort = GetConfigInteger("port", 9999); // Get show fps m_bShowFPS = GetConfigBoolean("showfps", true); // Start up the network manager m_pNetworkManager->Startup(iServerPort, PLAYER_MAX); CLogFile::Printf("Network manager started up"); // Create the resource and scripting manager CEntityIDs::Initalize(); m_pRootEntity = new CRootEntity(); g_pRootEntity = m_pRootEntity; m_pResourceManager = new CResourceManager("resources/"); g_pResourceManager = m_pResourceManager; // Load resources, get the first resource node if(g_pConfig->GetXML()->findNode("resource")) { while(true) { // Get the resource name String strResource = g_pConfig->GetXML()->nodeContent(); // Make sure the name is valid and attempt to load the resource if(strResource && !strResource.IsEmpty()) m_pResourceManager->Load(strResource); // Attempt to load the next resource node (if any) if(!g_pConfig->GetXML()->nextNode()) break; } } /*TiXmlDocument pDocument("Server.conf"); if(pDocument.LoadFile()) { TiXmlNode* pNode = pDocument.RootElement()->FirstChild("resource"); while(pNode) { String strResource = pNode->ToElement()->GetText(); pNode = pNode->NextSibling("resource"); } }*/ // Create the server lister instance m_pServerLister = new CServerLister(iServerPort); // Set the server title #ifdef WIN32 SetTitle(SERVER_TITLE); #endif CLogFile::Printf("Server started on port %d", iServerPort); /*// Temporary code CVehicle * pVehicle = m_pVehicleManager->Add(174); pVehicle->SetPosition(CVector3(-341.36f, 1144.80f, 14.79f)); pVehicle->SetRotation(CVector3(0.0f, 0.0f, 40.114815f)); pVehicle->SpawnForWorld();*/ return true; }