Created
February 11, 2018 21:40
-
-
Save daerogami/128dab0403b6a4f0cd68507c93cdbee0 to your computer and use it in GitHub Desktop.
Refactored erase_out_specials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void erase_out_specials() { | |
for(short i = 0; i < 2; i++) { | |
for (short j = 0; j < 2; j++) { | |
if (!quadrant_legal(i, j)) continue; | |
auto& sector = get_sector_ptr(univ.party.outdoor_corner.x + i, univ.party.outdoor_corner.y + j); | |
erase_hidden_towns(sector, i, j); | |
erase_completed_specials(sector); | |
} | |
} | |
} | |
void erase_hidden_towns(cOutdoors& sector, int quadrant_x, int quadrant_y) | |
{ | |
for (short tile_index = 0; tile_index < sector.city_locs.size(); tile_index++) { | |
if (!is_in_map(sector, tile_index) || | |
!is_sector_of_type(sector, tile_index, eTerSpec::TOWN_ENTRANCE) || | |
!is_tile_on_edge(sector, tile_index)) { | |
continue; | |
} | |
if (!town_exists(sector, tile_index)) { continue; } | |
auto town_pos_x = AREA_MEDIUM * quadrant_x + sector.city_locs[tile_index].x; | |
auto town_pos_y = AREA_MEDIUM * quadrant_y + sector.city_locs[tile_index].y; | |
auto spec_pos_x = sector.city_locs[tile_index].x; | |
auto spec_pos_y = sector.city_locs[tile_index].y; | |
auto area_index = sector.terrain[spec_pos_x][spec_pos_y]; | |
if (!univ.scenario.towns[sector.city_locs[tile_index].spec]->can_find) { | |
univ.out[town_pos_x][town_pos_y] = univ.scenario.ter_types[area_index].flag1; | |
} else { | |
univ.out[town_pos_x][town_pos_y] = area_index; | |
} | |
} | |
} | |
void erase_completed_specials(cOutdoors& sector) | |
{ | |
for (auto tile_index = 0; tile_index < sector.special_locs.size(); tile_index++) { | |
if (sector.special_locs[tile_index].spec < 0 || sector.special_locs[tile_index].spec >= sector.specials.size()) continue; | |
auto sn = sector.specials[sector.special_locs[tile_index].spec]; | |
if (univ.party.sd_legit(sn.sd1, sn.sd2) && PSD[sn.sd1][sn.sd2] == SDF_COMPLETE) { | |
auto where = sector.special_locs[tile_index]; | |
if (!tile_in_range(where)) { | |
beep(); | |
add_string_to_buf("Outdoor section corrupt. Problem fixed."); | |
sector.special_locs[tile_index].spec = -1; // TODO: Again, was there a reason for commenting this out? | |
} | |
sector.special_spot[where.x][where.y] = false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment