| 141 | } |
| 142 | |
| 143 | command_result digFlood (color_ostream &out, std::vector <std::string> & parameters) |
| 144 | { |
| 145 | bool adding = true; |
| 146 | set<string> toAdd, toRemove; |
| 147 | for ( size_t a = 0; a < parameters.size(); a++ ) { |
| 148 | int32_t i = (int32_t)strtol(parameters[a].c_str(), NULL, 0); |
| 149 | if ( i == 0 && parameters[a] == "0" ) { |
| 150 | plugin_enable(out, false); |
| 151 | adding = false; |
| 152 | continue; |
| 153 | } else if ( i == 1 ) { |
| 154 | plugin_enable(out, true); |
| 155 | adding = true; |
| 156 | continue; |
| 157 | } |
| 158 | |
| 159 | if ( parameters[a] == "CLEAR" ) { |
| 160 | autodigMaterials.clear(); |
| 161 | continue; |
| 162 | } |
| 163 | |
| 164 | if ( parameters[a] == "digAll0" ) { |
| 165 | digAll = false; |
| 166 | continue; |
| 167 | } |
| 168 | if ( parameters[a] == "digAll1" ) { |
| 169 | digAll = true; |
| 170 | continue; |
| 171 | } |
| 172 | |
| 173 | for ( size_t b = 0; b < world->raws.inorganics.size(); b++ ) { |
| 174 | df::inorganic_raw* inorganic = world->raws.inorganics[b]; |
| 175 | if ( parameters[a] == inorganic->id ) { |
| 176 | if ( adding ) |
| 177 | toAdd.insert(parameters[a]); |
| 178 | else |
| 179 | toRemove.insert(parameters[a]); |
| 180 | goto loop; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | out.print("Could not find material \"{}\".\n", parameters[a]); |
| 185 | return CR_WRONG_USAGE; |
| 186 | |
| 187 | loop: continue; |
| 188 | } |
| 189 | |
| 190 | autodigMaterials.insert(toAdd.begin(), toAdd.end()); |
| 191 | for ( auto a = toRemove.begin(); a != toRemove.end(); a++ ) |
| 192 | autodigMaterials.erase(*a); |
| 193 | |
| 194 | return CR_OK; |
| 195 | } |