static void deinitializeServer() { // Write configuration file Configuration::deinitialize(); // Stop world timer worldTimer.stop(); // Quit ENet enet_deinitialize(); // Destroy message handlers delete gameHandler; delete accountHandler; delete postMan; delete gBandwidth; // Destroy Managers delete stringFilter; monsterManager->deinitialize(); itemManager->deinitialize(); MapManager::deinitialize(); StatusManager::deinitialize(); PHYSFS_deinit(); }
/* Continuous model synthesis main function */ bool continuousModelSynthesis(vector<Edge*> &edges, vector<Vertex*> &vertices, CMSModel3D &input, Grid &grid) { Utils::Timer timer; cout << endl << "---Continuous Model Synthesis Progress---" << std::endl; unsigned int seed = (unsigned int)time(NULL); std::cout<< "Changing seed..." << seed << std::endl; srand(seed); if(firstrun) { for( std::vector<Vertex*>::iterator vertex_itr = vertices.begin(); vertex_itr != vertices.end(); vertex_itr++) { sortEdges(*vertex_itr); } //firstrun = false; } PotentialVertex *currentVertex; std::vector<PotentialVertex*> unassignedVertices; std::vector<PotentialVertex*>::iterator unassignedItr; PotentialVertexState selectedState; if(firstrun) { cout << "Generating states..." << endl; timer.start(); bruteForceGenerate(unassignedVertices, input, grid); timer.stop(); timer.printSeconds(); firstrun = false; } else { while(history.selectedVertexList.size() > 0) { vector<vector<PotentialVertexState>*>::iterator listitr; vector<PotentialVertexState>::iterator stateitr; listitr = history.constrainedVertexList.back().begin(); stateitr = history.removedStatesList.back().begin(); while( listitr != history.constrainedVertexList.back().end() && stateitr != history.removedStatesList.back().end() ) { (*listitr)->push_back(*stateitr); listitr++; stateitr++; } history.constrainedVertexList.pop_back(); history.removedStatesList.pop_back(); unassignedVertices.push_back(history.selectedVertexList.back()); unassignedVertices.back()->states.push_back(history.selectedState.back()); history.selectedVertexList.pop_back(); history.selectedState.pop_back(); } } cout << "Assigning states..." << endl; timer.start(); while(unassignedVertices.size() > 0) { //std::cout << "Assignments Remaining: " << unassignedVertices.size() << std::endl; sort(unassignedVertices.begin(), unassignedVertices.end(), sortVertex); if( (*unassignedVertices.begin())->states.size() == 0) { //unassignedVertices.erase(unassignedVertices.begin()); //continue; //backtrack //std::cout << "BACKTRACK: " << unassignedVertices.size() << std::endl; vector<vector<PotentialVertexState>*>::iterator listitr; vector<PotentialVertexState>::iterator stateitr; listitr = history.constrainedVertexList.back().begin(); stateitr = history.removedStatesList.back().begin(); while( listitr != history.constrainedVertexList.back().end() && stateitr != history.removedStatesList.back().end() ) { (*listitr)->push_back(*stateitr); listitr++; stateitr++; } history.constrainedVertexList.pop_back(); history.removedStatesList.pop_back(); if(history.constrainedVertexList.size() == 0 || history.removedStatesList.size() == 0) { std::cout << "!!!" << std::endl; break; } history.constrainedVertexList.back().push_back(&(history.selectedVertexList.back()->states)); history.removedStatesList.back().push_back(history.selectedState.back()); unassignedVertices.push_back(history.selectedVertexList.back()); history.selectedVertexList.pop_back(); history.selectedState.pop_back(); continue; } unassignedItr = unassignedVertices.begin(); currentVertex = *(unassignedItr); unassignedVertices.erase(unassignedItr); selectedState = currentVertex->getAndRemoveRandomState(); history.selectedVertexList.push_back(currentVertex); history.selectedState.push_back(selectedState); history.constrainedVertexList.push_back(vector<vector<PotentialVertexState>*>()); history.removedStatesList.push_back(vector<PotentialVertexState>()); for(int i = 0; i < NUM_VOLUMES; i++) { if(currentVertex->volumes[i] != NULL) { constrainVolume(currentVertex->volumes[i], selectedState.volumes[i], unassignedVertices, history); } } } for(std::vector<PotentialVertex*>::iterator itr = unassignedVertices.begin(); itr != unassignedVertices.end(); itr++) { delete (*itr); } timer.stop(); timer.printSeconds(); return true; }