bool Map::shouldGenerateCorridor(int x, int y) { if (getRegion(x, y)) { return false; } std::array<Tile, 4> neighbors = Tile(x, y).getNeighbors(); for (uint32_t i = 0; i < neighbors.size(); ++i) { if (getRegion(neighbors[i])) { return false; } } return true; }
std::ostream & CondBallPos::print( std::ostream & out ) const { out << "(bpos "; if ( getRegion() == NULL ) { out << "(null)"; } else { out << *getRegion(); } return out << ")"; }
std::ostream & CondBallPos::printPretty( std::ostream & out, const std::string & line_header ) const { out << line_header << "is ball position at: " << std::endl; if ( getRegion() == NULL ) { out << line_header << " (null)\n"; } else { getRegion()->printPretty( out, line_header + " " ); } return out; }
void addToRegion ( int compnr, char* name ) { getRegion(compnr)->add(name); }
void excludeFromRegion ( int compnr, char* name ) { getRegion(compnr)->exclude(name); }
bool Commander::isOccupied(BWTA::Region* region) { BWTA::Polygon p = region->getPolygon(); vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents(); for (int i = 0; i < (int)agents.size(); i++) { BaseAgent* agent = agents.at(i); if (agent->isAlive() && agent->getUnitType().isResourceDepot()) { BWTA::Region* aRegion = getRegion(agents.at(i)->getUnit()->getTilePosition()); Position c1 = region->getCenter(); Position c2 = aRegion->getCenter(); if (c2.x() == c1.x() && c2.y() == c1.y()) { return true; } } } //Check expansion site TilePosition expansionSite = ExplorationManager::getInstance()->getExpansionSite(); TilePosition center = TilePosition(region->getCenter()); if (expansionSite.x() >= 0) { double dist = expansionSite.getDistance(center); if (dist <= 15) { return true; } } return false; }
SharedAnnotationData Peak2GeneFormatLoader::parseLine(const QStringList &lineValues) { SharedAnnotationData data(new AnnotationData); CHECK_EXT(lineValues.size() == COLUMNS_COUNT, skipLine = true; os.addWarning(QString("Incorrect columns count at line %1: expect %2, got %3") .arg(currentLineNumber).arg(COLUMNS_COUNT).arg(lineValues.size())), data); data->qualifiers << U2Qualifier("chrom", getChromName(lineValues)); CHECK(!skipLine, data); data->location->regions << getRegion(lineValues); CHECK(!skipLine, data); data->name = getPeakName(lineValues); CHECK(!skipLine, data); data->qualifiers << U2Qualifier("score", getPeakScore(lineValues)); CHECK(!skipLine, data); data->qualifiers << U2Qualifier("NA", getNa(lineValues)); CHECK(!skipLine, data); data->qualifiers << U2Qualifier("Genes", getGenes(lineValues)); CHECK(!skipLine, data); data->qualifiers << U2Qualifier("Strand", getStrand(lineValues)); CHECK(!skipLine, data); data->qualifiers << U2Qualifier("TSS2pCenter", getTss2pCenter(lineValues)); CHECK(!skipLine, data); return data; }
Chunk* WorldCache::getChunk(const ChunkPos& pos) { CacheEntry<ChunkPos, Chunk>& entry = chunkcache[getChunkCacheIndex(pos)]; // check if chunk is already in cache if (entry.used && entry.key == pos) { //chunkstats.hits++; return &entry.value; } // if not try to get the region of the chunk from the cache RegionFile* region = getRegion(pos.getRegion()); if (region == nullptr) { //chunkstats.unavailable++; return nullptr; } // then try to load the chunk int status = region->loadChunk(pos, entry.value); // the chunk does not exist, chunk in cache was not modified if (status == RegionFile::CHUNK_DOES_NOT_EXIST) return nullptr; if (status != RegionFile::CHUNK_OK) { //chunkstats.unavailable++; // the chunk is not valid, chunk in cache was probably modified entry.used = false; return nullptr; } entry.used = true; entry.key = pos; //chunkstats.misses++; return &entry.value; }
Location &SMEntity::getLocation(Location &loc) const { loc.setRegion(getRegion()); loc.setPos(entity->getPos()); loc.setRotation(entity->getRotation()); return loc; }
bool Location::equals(const Location &other) const { return getRegion() == other.getRegion() && getX() == other.getX() && getY() == other.getY() && getZ() == other.getZ() && getYaw() == other.getYaw()&& getPitch() == other.getPitch(); }
bool HTMLAreaElement::pointInArea(LayoutPoint location, const LayoutSize& containerSize) { if (m_lastSize != containerSize) { m_region = adoptPtr(new Path(getRegion(containerSize))); m_lastSize = containerSize; } return m_region->contains(FloatPoint(location)); }
void listFill(const Coordinate & centerPos, const brush_t & brush, const uint64_t fillsoid, const std::unordered_set<Coordinate> & voxels) { const auto region = getRegion(centerPos, brush); auto cubeChangeSet = processRegion(region.first, region.second, [fillsoid, &voxels](uint64_t & voxel, Coordinate globalPos){ if (voxels.find(globalPos) != std::end(voxels)) { voxel = fillsoid; } }); coordCubesMarkChanged(cubeChangeSet); }
/** * Generates a brand new saved game with starting data. * @return A new saved game. */ SavedGame *Ruleset::newSave() const { SavedGame *save = new SavedGame(); // Add countries for (std::vector<std::string>::const_iterator i = _countriesIndex.begin(); i != _countriesIndex.end(); ++i) { save->getCountries()->push_back(new Country(getCountry(*i))); } // Adjust funding to total $6M int missing = ((6000 - save->getCountryFunding()/1000) / (int)save->getCountries()->size()) * 1000; for (std::vector<Country*>::iterator i = save->getCountries()->begin(); i != save->getCountries()->end(); ++i) { (*i)->setFunding((*i)->getFunding().back() + missing); } save->setFunds(save->getCountryFunding()); // Add regions for (std::vector<std::string>::const_iterator i = _regionsIndex.begin(); i != _regionsIndex.end(); ++i) { save->getRegions()->push_back(new Region(getRegion(*i))); } // Set up IDs std::map<std::string, int> ids; for (std::vector<std::string>::const_iterator i = _craftsIndex.begin(); i != _craftsIndex.end(); ++i) { ids[*i] = 1; } save->initIds(ids); // Set up starting base Base *base = new Base(this); base->load(_startingBase, save, true); // Correct IDs for (std::vector<Craft*>::const_iterator i = base->getCrafts()->begin(); i != base->getCrafts()->end(); ++i) { save->getId((*i)->getRules()->getType()); } // Generate soldiers int soldiers = _startingBase["randomSoldiers"].as<int>(0); for (int i = 0; i < soldiers; ++i) { Soldier *soldier = new Soldier(getSoldier("XCOM"), getArmor("STR_NONE_UC"), &_names, save->getId("STR_SOLDIER")); soldier->setCraft(base->getCrafts()->front()); base->getSoldiers()->push_back(soldier); } save->getBases()->push_back(base); // Setup alien strategy save->getAlienStrategy().init(this); save->setTime(_startingTime); return save; }
subobjectRetrievalMap readVoxels(const Coordinate & centerPos, const brush_t &brush) { subobjectRetrievalMap subobjects; const auto region = getRegion(centerPos, brush); processRegion(region.first, region.second, [&subobjects](uint64_t & voxel, Coordinate position){ if (voxel != 0) {//don’t select the unsegmented area as object subobjects.emplace(std::piecewise_construct, std::make_tuple(voxel), std::make_tuple(position)); } }); return subobjects; }
void LLWorld::removeRegion(const LLHost &host) { F32 x, y; LLViewerRegion *regionp = getRegion(host); if (!regionp) { llwarns << "Trying to remove region that doesn't exist!" << llendl; return; } if (regionp == gAgent.getRegion()) { for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter) { LLViewerRegion* reg = *iter; llwarns << "RegionDump: " << reg->getName() << " " << reg->getHost() << " " << reg->getOriginGlobal() << llendl; } llwarns << "Agent position global " << gAgent.getPositionGlobal() << " agent " << gAgent.getPositionAgent() << llendl; llwarns << "Regions visited " << gAgent.getRegionsVisited() << llendl; llwarns << "gFrameTimeSeconds " << gFrameTimeSeconds << llendl; llwarns << "Disabling region " << regionp->getName() << " that agent is in!" << llendl; LLAppViewer::instance()->forceDisconnect(LLTrans::getString("YouHaveBeenDisconnected")); regionp->saveObjectCache() ; //force to save objects here in case that the object cache is about to be destroyed. return; } from_region_handle(regionp->getHandle(), &x, &y); llinfos << "Removing region " << x << ":" << y << llendl; mRegionList.remove(regionp); mActiveRegionList.remove(regionp); mCulledRegionList.remove(regionp); mVisibleRegionList.remove(regionp); mRegionRemovedSignal(regionp); //double check all objects of this region are removed. gObjectList.clearAllMapObjectsInRegion(regionp) ; //llassert_always(!gObjectList.hasMapObjectInRegion(regionp)) ; updateWaterObjects(); delete regionp; }
void addStudents (Game g, int regionID) { int i = 0; int x = 0; int y = 0; int z = 0; int curPlayer = UNI_A; int curVertex = g->gameBoard.campus[x][y][z]; int *regionSurround = getRegion (g, x, y, z); while (x < COORD) { while (y < COORD) { while (z < COORD) { curVertex = g->gameBoard.campus[x][y][z]; if (curVertex > 0) { regionSurround = getRegion (g, x, y, z); i = 0; while (i < 3) { if (regionSurround[i] == regionID) { if (curVertex >= 1 && curVertex <= 3) { curPlayer = curVertex; g->uni[curPlayer].numStudents[getDiscipline(g, regionID)]++; } else { curPlayer = curVertex - 3; g->uni[curPlayer].numStudents[getDiscipline(g, regionID)]+=2; } } i++; } } z++; } z = 0; y++; } y = 0; x++; } free (regionSurround); }
std::auto_ptr< Cond > CondBallPos::deepCopy() const { if ( getRegion() ) { return std::auto_ptr< Cond >( new CondBallPos( M_reg->deepCopy() ) ); } else { return std::auto_ptr< Cond >( new CondBallPos() ); } }
void ICMainWindow::updateMask() { QBitmap Bitmap(size()); Bitmap.clear(); QPainter Painter(&Bitmap); Painter.setClipRegion(getRegion()); Painter.fillRect(rect(), Qt::color1); Painter.end(); setMask(Bitmap); }
void ChunkPos::rotate(int count) { int nx = getLocalX(), nz = getLocalZ(), nnx, nnz; for (int i = 0; i < count; i++) { nnx = 31 - nz; nnz = nx; nx = nnx; nz = nnz; } RegionPos region = getRegion(); x = nx + region.x * 32; z = nz + region.z * 32; }
void writeVoxels(const Coordinate & centerPos, const uint64_t value, const brush_t & brush, bool isMarkChanged) { //all the different invocations here are listed explicitly so the compiler can inline the f**k out of it //the brush differentiations were moved outside the core lambda which is called for every voxel CubeCoordSet cubeChangeSet; CubeCoordSet cubeChangeSetWholeCube; if (Session::singleton().annotationMode.testFlag(AnnotationMode::Mode_Paint)) { const auto region = getRegion(centerPos, brush); if (brush.shape == brush_t::shape_t::angular) { if (!brush.inverse || Segmentation::singleton().selectedObjectsCount() == 0) { //for rectangular brushes no further range checks are needed if (brush.mode == brush_t::mode_t::three_dim && brush.shape == brush_t::shape_t::angular) { //rarest special case: processes completely exclosed cubes first cubeChangeSet = processRegion(region.first, region.second, [&brush, centerPos, value](uint64_t & voxel, Coordinate){ voxel = value; }, wholeCubes(region.first, region.second, value, cubeChangeSetWholeCube)); } else { cubeChangeSet = processRegion(region.first, region.second, [&brush, centerPos, value](uint64_t & voxel, Coordinate){ voxel = value; }); } } else {//inverse but selected cubeChangeSet = processRegion(region.first, region.second, [&brush, centerPos, value](uint64_t & voxel, Coordinate){ if (Segmentation::singleton().isSubObjectIdSelected(voxel)) {//if there’re selected objects, we only want to erase these voxel = 0; } }); } } else if (!brush.inverse || Segmentation::singleton().selectedObjectsCount() == 0) { //voxel need to check if they are inside the circle cubeChangeSet = processRegion(region.first, region.second, [&brush, centerPos, value](uint64_t & voxel, Coordinate globalPos){ if (isInsideSphere(globalPos.x - centerPos.x, globalPos.y - centerPos.y, globalPos.z - centerPos.z, brush.radius)) { voxel = value; } }); } else {//circle, inverse and selected cubeChangeSet = processRegion(region.first, region.second, [&brush, centerPos, value](uint64_t & voxel, Coordinate globalPos){ if (isInsideSphere(globalPos.x - centerPos.x, globalPos.y - centerPos.y, globalPos.z - centerPos.z, brush.radius) && Segmentation::singleton().isSubObjectIdSelected(voxel)) { voxel = 0; } }); } } if (isMarkChanged) { for (auto &elem : cubeChangeSetWholeCube) { cubeChangeSet.emplace(elem); } coordCubesMarkChanged(cubeChangeSet); } }
bool RegionManager::jumpRegion(const std::string& _targetRegion, unsigned int _x, unsigned int _y, RegionEntity *_entity, bool _updateCurrentRegion) { if (hasRegion(_targetRegion)) { std::cout << "Region '" << _targetRegion << "' is present" << std::endl; auto& r = getRegion(_targetRegion); r.addEntity(_entity); _entity->setPosition(sf::Vector2f(static_cast<float>(_x), static_cast<float>(_y))); if (_updateCurrentRegion) { setCurrentRegion(_targetRegion); } return true; } return false; }
bool HTMLAreaElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result) { if (m_lastSize != size) { m_region = adoptPtr(new Path(getRegion(size))); m_lastSize = size; } if (!m_region->contains(location)) return false; result.setInnerNode(this); result.setURLElement(this); return true; }
std::string LLSLURL::asString() const { std::ostringstream result; result << " mAppCmd:" << getAppCmd() << " mAppPath:" + getAppPath().asString() << " mAppQueryMap:" + getAppQueryMap().asString() << " mAppQuery: " + getAppQuery() << " mGrid: " + getGrid() << " mRegion: " + getRegion() << " mPosition: " << " mType: " << mType << " mPosition: " << mPosition; return result.str(); }
void LLWorld::removeRegion(const LLHost &host) { F32 x, y; LLViewerRegion *regionp = getRegion(host); if (!regionp) { llwarns << "Trying to remove region that doesn't exist!" << llendl; return; } if (regionp == gAgent.getRegion()) { for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter) { LLViewerRegion* reg = *iter; llwarns << "RegionDump: " << reg->getName() << " " << reg->getHost() << " " << reg->getOriginGlobal() << llendl; } llwarns << "Agent position global " << gAgent.getPositionGlobal() << " agent " << gAgent.getPositionAgent() << llendl; llwarns << "Regions visited " << gAgent.getRegionsVisited() << llendl; llwarns << "gFrameTimeSeconds " << gFrameTimeSeconds << llendl; llwarns << "Disabling region " << regionp->getName() << " that agent is in!" << llendl; LLAppViewer::instance()->forceDisconnect("You have been disconnected from the region you were in."); return; } from_region_handle(regionp->getHandle(), &x, &y); llinfos << "Removing region " << x << ":" << y << llendl; mRegionList.remove(regionp); mActiveRegionList.remove(regionp); mCulledRegionList.remove(regionp); mVisibleRegionList.remove(regionp); delete regionp; updateWaterObjects(); }
LayoutRegion* NclDocument::getRegion(string regionId) { LayoutRegion* region; map<int, RegionBase*>::iterator i; i = regionBases->begin(); while (i != regionBases->end()) { region = getRegion(regionId, i->second); if (region != NULL) { return region; } ++i; } return NULL; }
void LLPathfindingNavMeshZone::NavMeshLocation::enable() { clear(); LLViewerRegion *region = getRegion(); if (region == NULL) { mRegionUUID.setNull(); } else { mRegionUUID = region->getRegionID(); mNavMeshSlot = LLPathfindingManager::getInstance()->registerNavMeshListenerForRegion(region, boost::bind(&LLPathfindingNavMeshZone::NavMeshLocation::handleNavMesh, this, _1, _2, _3)); } }
void DrawItemShape::OnPaint( Graphics &g ) { if(isChangeRegion()) { ResetRegion(); } auto region = getRegion(); SolidBrush brush(DrawTools::ColorNormal); if (m_isFillPath) { if (StateNormal == m_state) { g.FillRegion(&brush, region.get()); } else if (StateHovered == m_state) { g.FillRegion(&SolidBrush(DrawTools::ColorHovered), region.get()); } else if (StateDisable == m_state) { g.FillRegion(&SolidBrush(DrawTools::ColorDisable), region.get()); } else if (StateDown == m_state) { g.FillRegion(&SolidBrush(DrawTools::ColorDown), region.get()); } else if (StateError == m_state) { g.FillRegion(&SolidBrush(DrawTools::ColorError), region.get()); } else { g.FillRegion(&SolidBrush(m_fillColor), region.get()); } } if (m_isDrawPath) { GraphicsPath path; path.StartFigure(); for(auto itter = m_lines.begin();itter != m_lines.end() ; itter++ ) { (*itter)->getPath(path); } path.CloseFigure(); g.DrawPath(&Pen(m_drawColor),&path); } }
BioStruct3DReference BioStruct3DSubsetEditor::getSubset() { assert(validate().isEmpty() && "validate first!"); BioStruct3DObject *obj = static_cast<BioStruct3DObject*> ( objectCombo->itemData(objectCombo->currentIndex()).value<void*>() ); int modelId = modelCombo->itemData(modelCombo->currentIndex()).value<int>(); if (chainCombo->currentText() == ALL_CHAINS) { QList<int> chains = obj->getBioStruct3D().moleculeMap.keys(); return BioStruct3DReference(obj, chains, modelId); } else { int chainId = chainCombo->itemData(chainCombo->currentIndex()).value<int>(); U2Region chainRegion = getRegion(); return BioStruct3DReference(obj, chainId, chainRegion, modelId); } }
void LLPathfindingNavMeshZone::NavMeshLocation::refresh() { LLViewerRegion *region = getRegion(); if (region == NULL) { llassert(mRegionUUID.isNull()); LLPathfindingNavMeshStatus newNavMeshStatus(mRegionUUID); LLSD::Binary nullData; handleNavMesh(LLPathfindingNavMesh::kNavMeshRequestNotEnabled, newNavMeshStatus, nullData); } else { llassert(mRegionUUID == region->getRegionID()); LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(region, false); } }
QString BioStruct3DSubsetEditor::validate() { if (regionEdit->isEnabled()) { QString regionText = regionEdit->text(); if (!QRegExp("[0-9]*\\.\\.[0-9]*").exactMatch(regionText)) { return QString("invalid region spec %1").arg(regionText); } BioStruct3DObject *bso = static_cast<BioStruct3DObject*>( objectCombo->itemData(objectCombo->currentIndex()).value<void*>() ); int chainId = chainCombo->itemData(chainCombo->currentIndex()).value<int>(); int length = bso->getBioStruct3D().moleculeMap.value(chainId)->residueMap.size(); U2Region region = getRegion(); if (region.startPos < 0 || region.startPos >= region.endPos() || region.endPos() > length) { return QString("region values out of range %1..%2 (%3..%4)").arg(region.startPos + 1).arg(region.endPos()).arg(1).arg(length); } } return QString(""); }