| 321 | } |
| 322 | |
| 323 | command_result df_getplants(color_ostream& out, vector <string>& parameters) { |
| 324 | string plantMatStr = ""; |
| 325 | std::vector<selectability> plantSelections; |
| 326 | std::vector<size_t> collectionCount; |
| 327 | set<string> plantNames; |
| 328 | bool deselect = false, exclude = false, treesonly = false, shrubsonly = false, all = false, verbose = false, farming = false; |
| 329 | size_t maxCount = 999999; |
| 330 | int count = 0; |
| 331 | |
| 332 | plantSelections.resize(world->raws.plants.all.size()); |
| 333 | collectionCount.resize(world->raws.plants.all.size()); |
| 334 | |
| 335 | for (size_t i = 0; i < plantSelections.size(); i++) { |
| 336 | plantSelections[i] = selectability::Unselected; |
| 337 | collectionCount[i] = 0; |
| 338 | } |
| 339 | |
| 340 | bool anyPlantsSelected = false; |
| 341 | |
| 342 | for (size_t i = 0; i < parameters.size(); i++) { |
| 343 | if (parameters[i] == "help" || parameters[i] == "?") |
| 344 | return CR_WRONG_USAGE; |
| 345 | else if (parameters[i] == "-t") |
| 346 | treesonly = true; |
| 347 | else if (parameters[i] == "-s") |
| 348 | shrubsonly = true; |
| 349 | else if (parameters[i] == "-c") |
| 350 | deselect = true; |
| 351 | else if (parameters[i] == "-x") |
| 352 | exclude = true; |
| 353 | else if (parameters[i] == "-a") |
| 354 | all = true; |
| 355 | else if (parameters[i] == "-v") |
| 356 | verbose = true; |
| 357 | else if (parameters[i] == "-f") |
| 358 | farming = true; |
| 359 | else if (parameters[i] == "-n") { |
| 360 | if (parameters.size() > i + 1) { |
| 361 | maxCount = atoi(parameters[i + 1].c_str()); |
| 362 | if (maxCount >= 1) { |
| 363 | i++; // We've consumed the next parameter, so we need to progress the iterator. |
| 364 | } |
| 365 | else { |
| 366 | out.printerr("-n requires a positive integer parameter!\n"); |
| 367 | return CR_WRONG_USAGE; |
| 368 | } |
| 369 | } |
| 370 | else { |
| 371 | out.printerr("-n requires a positive integer parameter!\n"); |
| 372 | return CR_WRONG_USAGE; |
| 373 | } |
| 374 | } |
| 375 | else |
| 376 | plantNames.insert(toUpper_cp437(parameters[i])); |
| 377 | } |
| 378 | if (treesonly && shrubsonly) { |
| 379 | out.printerr("Cannot specify both -t and -s at the same time!\n"); |
| 380 | return CR_WRONG_USAGE; |
nothing calls this directly
no test coverage detected