WIP: SDF Finder WIP #715

Draft
NQNStudios wants to merge 1 commits from NQNStudios/sdf-finder into master
2 changed files with 36 additions and 0 deletions

View File

@@ -610,3 +610,33 @@ std::string cScenario::get_sdf_name(int row, int col) {
return "";
return sdf_names[row][col];
}
void cScenario::for_each_special(std::function<void(const cSpecial&)> callback) {
for_each_scen_special(callback);
for(int town = 0; town < towns.size(); ++town){
for_each_town_special(town, callback);
}
for(int x = 0; x < outdoors.width(); ++x){
for(int y = 0; y < outdoors.height(); ++y){
for_each_out_special(x, y, callback);
}
}
}
void cScenario::for_each_scen_special(std::function<void(const cSpecial&)> callback) {
for(cSpecial special : scen_specials){
callback(special);
}
}
void cScenario::for_each_town_special(int town, std::function<void(const cSpecial&)> callback) {
for(cSpecial special : towns[town]->specials){
callback(special);
}
}
void cScenario::for_each_out_special(int sector_x, int sector_y, std::function<void(const cSpecial&)> callback) {
for(cSpecial special : outdoors[sector_x][sector_y]->specials){
callback(special);
}
}

View File

@@ -58,6 +58,12 @@ public:
cItemStorage& operator = (legacy::item_storage_shortcut_type& old);
};
void destroy_terrain();
// Iterate through EVERY special node with a callback.
void for_each_special(std::function<void(const cSpecial&)> callback);
// Factored into 3 separate functions in case there's ever a reason to be more selective:
void for_each_scen_special(std::function<void(const cSpecial&)> callback);
void for_each_town_special(int town, std::function<void(const cSpecial&)> callback);
void for_each_out_special(int sector_x, int sector_y, std::function<void(const cSpecial&)> callback);
public:
unsigned short difficulty,intro_pic,default_ground;
int bg_out, bg_fight, bg_town, bg_dungeon;