예제 #1
0
void CityUpdater::freeRoad(){
    //std::cout<<"Freeing "<<std::endl;
    getAdjacencyList();
    Visitor* visitorPtr;
    std::vector<Location> path;
    for (int i=0; i<cityMap->getMaxVisitors(); i++){
        if ((visitorPtr = cityMap->getVisitor(i)) && (visitorPtr->isOnStandby())){
            path.clear();
            generateFullPath(visitorPtr->getLoc(), visitorPtr->getEndLoc(), path);
            //std::cout<<path.size()<<std::endl;
            visitorPtr->setPath(path);
        }
    }
}
예제 #2
0
void CityUpdater::addRoadBlock(Road* toBlock){
    pthread_mutex_lock(&visitormutex);
    toBlock->setUpBarricade(true, MAXROADBLOCKTURNS);
    //std::cout<<"Blocking "<<toBlock->getLocation().getRow()<<" . "<<toBlock->getLocation().getCol()<<std::endl;
    blockedRoads.push_back(toBlock);
    getAdjacencyList();
    Visitor* visitorPtr;
    std::vector<Location> path;
    for (int i=0; i<cityMap->getMaxVisitors(); i++){
        if ((visitorPtr = cityMap->getVisitor(i)) && visitorPtr->passesThrough(toBlock->getLocation())){
            path.clear();
            generateFullPath(visitorPtr->getLoc(), visitorPtr->getEndLoc(), path);
            visitorPtr->setPath(path);
        }
    }
    pthread_mutex_unlock(&visitormutex);
}