Index: src/game/CellImpl.h =================================================================== --- src/game/CellImpl.h (revision 4845) +++ src/game/CellImpl.h (working copy) @@ -30,239 +30,192 @@ { CellPair standing_cell = l.i_cellPair; CellPair cell_iter; + if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) return; - if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) - return; - - switch( (district_t)this->data.Part.reserved ) + uint16 CurDistrict = (district_t)this->data.Part.reserved; + if (CurDistrict == CENTER_DISTRICT ){ m.Visit(l, visitor); return;} + + + + switch(CurDistrict) { - case ALL_DISTRICT: + case ALL_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell << 1; + update_cell -= 1; + for(; abs(int(standing_cell.x_coord - update_cell.x_coord)) < 2; update_cell >> 1) { - CellPair update_cell(standing_cell); - update_cell << 1; - update_cell -= 1; - for(; abs(int(standing_cell.x_coord - update_cell.x_coord)) < 2; update_cell >> 1) - { - for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); + for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) + { + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); - if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - break; + if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; + } + if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } - case UPPER_LEFT_DISTRICT: + } + break; + case UPPER_LEFT_DISTRICT: + { + CellPair update_cell(standing_cell); + standing_cell << 1; + standing_cell -= 1; + for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) { - CellPair update_cell(standing_cell); - standing_cell << 1; - standing_cell -= 1; - - for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - for(cell_iter=update_cell, cell_iter += 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - break; - } - case UPPER_RIGHT_DISTRICT: + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; + } + for(cell_iter=update_cell, cell_iter += 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) + { + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; + } + } + break; + case UPPER_RIGHT_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell >> 1; + update_cell -= 1; + for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter << 1) { - CellPair update_cell(standing_cell); - update_cell >> 1; - update_cell -= 1; - - for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter << 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == 0) - break; - } - - for(cell_iter=update_cell, cell_iter += 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == 0) break; } - case LOWER_LEFT_DISTRICT: + for(cell_iter=update_cell, cell_iter += 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) { - CellPair update_cell(standing_cell); - update_cell << 1; - update_cell += 1; - - for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - for(cell_iter=update_cell, cell_iter -= 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter -= 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == 0) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; + } + } + break; + case LOWER_LEFT_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell << 1; + update_cell += 1; + for(cell_iter = update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) + { + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } - case LOWER_RIGHT_DISTRICT: + for(cell_iter=update_cell, cell_iter -= 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter -= 1) { - CellPair update_cell(standing_cell); - update_cell >> 1; - update_cell += 1; - - for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter << 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == 0) - break; - } - - for(cell_iter=update_cell, cell_iter -= 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter -= 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == 0) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == 0) break; } - case LEFT_DISTRICT: + } + break; + case LOWER_RIGHT_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell >> 1; + update_cell += 1; + for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter << 1) { - CellPair update_cell(standing_cell); - update_cell << 1; - update_cell -= 1; - - for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == 0) break; } - case RIGHT_DISTRICT: + for(cell_iter=update_cell, cell_iter -= 1; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter -= 1) { - CellPair update_cell(standing_cell); - update_cell >> 1; - update_cell -= 1; - - for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == 0) break; } - case UPPER_DISTRICT: + } + break; + case LEFT_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell << 1; + update_cell -= 1; + for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) { - CellPair update_cell(standing_cell); - update_cell << 1; - update_cell -= 1; - - for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } - case LOWER_DISTRICT: + } + break; + case RIGHT_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell >> 1; + update_cell -= 1; + for(cell_iter=update_cell; abs(int(standing_cell.y_coord - cell_iter.y_coord)) < 2; cell_iter += 1) { - CellPair update_cell(standing_cell); - update_cell << 1; - update_cell += 1; - - for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) - { - Cell r_zone = RedZone::GetZone(cell_iter); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_iter); - m.Visit(lock, visitor); - - if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) - break; - } - - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.y_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } - case CENTER_DISTRICT: + } + break; + case UPPER_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell << 1; + update_cell -= 1; + for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) { - m.Visit(l, visitor); - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } - default: + } + break; + case LOWER_DISTRICT: + { + CellPair update_cell(standing_cell); + update_cell << 1; + update_cell += 1; + for(cell_iter=update_cell; abs(int(standing_cell.x_coord - cell_iter.x_coord)) < 2; cell_iter >> 1) { - assert( false ); - break; + Cell r_zone = RedZone::GetZone(cell_iter); + r_zone.data.Part.nocreate = l->data.Part.nocreate; + CellLock lock(r_zone, cell_iter); + m.Visit(lock, visitor); + if (cell_iter.x_coord == TOTAL_NUMBER_OF_CELLS_PER_MAP-1) break; } + } + break; + default: + { + assert( false ); + } + break; } } #endif