cRegion::RegionIterator4Items& cRegion::RegionIterator4Items::operator ++(int) { ++currentIndex; if (currentIndex > vecEntries.size()) NextCell(); return *this; }
int cPath::NextStep(int *px,int *py,int *cx,int *cy) { int move=CONTINUE; switch(dir) { case D_N: (*py)-=STEP_LENGTH; break; case D_S: (*py)+=STEP_LENGTH; break; case D_E: (*px)+=STEP_LENGTH; break; case D_O: (*px)-=STEP_LENGTH; break; case D_NE:(*py)-=STEP_LENGTH; (*px)+=STEP_LENGTH; break; case D_NO:(*py)-=STEP_LENGTH; (*px)-=STEP_LENGTH; break; case D_SE:(*py)+=STEP_LENGTH; (*px)+=STEP_LENGTH; break; case D_SO:(*py)+=STEP_LENGTH; (*px)-=STEP_LENGTH; break; } //Calculate next cell if( (((*px)%32)==0) && (((*py)%32)==0)) { x = (*px)>>5; *cx = x; y = (*py)>>5; *cy = y; if((nxf==-1) && (nyf==-1)) { move=NextCell(); } else//if((nxf>=0) || (nyf>=0)) { AStar->EndPathfinder(); delete AStar; AStar = NULL; Make(world,*cx,*cy,nxf,nyf); //move=CONTINUE; } }
void NosuchLife::Gen() { for (int r = 0; r < m_nrows; r++) { int rstart = r * m_ncols; for (int c = 0; c < m_ncols; c++) { LifeCell& cell_ul = Cell(r - 1, c - 1); LifeCell& cell_um = Cell(r - 1, c); LifeCell& cell_ur = Cell(r - 1, c + 1); LifeCell& cell_ml = Cell(r, c - 1); LifeCell& cell_mm = Cell(r, c); LifeCell& cell_mr = Cell(r, c + 1); LifeCell& cell_ll = Cell(r + 1, c - 1); LifeCell& cell_lm = Cell(r + 1, c); LifeCell& cell_lr = Cell(r + 1, c + 1); int tot = cell_ul.val() + cell_um.val() + cell_ur.val() + cell_ml.val() + cell_mr.val() + cell_ll.val() + cell_lm.val() + cell_lr.val(); int v = cell_mm.val(); // The middle (i.e. current) cell LifeCell& nextcell = NextCell(r, c); if (v == 1 ) { if (tot < 2 || tot > 3) { // dies due to under- or over-population nextcell.setVal(false); m_listener.onCellDeath(r, c, nextcell); } else { nextcell.setVal(true); // didn't change m_listener.onCellSurvive(r, c, nextcell); } } else { if (tot == 3) { // born nextcell.setVal(true); m_listener.onCellBirth(r, c, nextcell, cell_ul,cell_um,cell_ur, cell_ml,cell_mm,cell_mr, cell_ll,cell_lm,cell_lr); } else { nextcell.setVal(false); // didn't change } } } } LifeCell* t = m_cells; m_cells = m_nextcells; m_nextcells = t; }
void JTableSelectionIterator::MoveTo ( const JIteratorPosition newPosition, const JPoint& cell ) { if (itsTableSelection == NULL) { return; } const JSize rowCount = itsTableSelection->GetRowCount(); const JSize colCount = itsTableSelection->GetColCount(); itsAtEndFlag = kJFalse; if (newPosition == kJIteratorStartAtBeginning) { itsCursor.x = 1; itsCursor.y = 1; } else if (newPosition == kJIteratorStartAtEnd) { itsCursor.x = JMax((JSize) 1, colCount); itsCursor.y = JMax((JSize) 1, rowCount); itsAtEndFlag = kJTrue; } else if (newPosition == kJIteratorStartBefore) { assert( itsTableSelection->CellValid(cell) ); itsCursor = cell; } else { assert( newPosition == kJIteratorStartAfter ); assert( itsTableSelection->CellValid(cell) ); itsCursor = cell; NextCell(); } }
JBoolean JTableSelectionIterator::Next ( JPoint* cell ) { while (!AtEnd()) { *cell = itsCursor; NextCell(); if (itsTableSelection->IsSelected(*cell)) { return kJTrue; } } *cell = JPoint(0,0); return kJFalse; }