| 110 | } |
| 111 | |
| 112 | static inline bool select_caste_mat(color_ostream &out, vector<string> &tokens, |
| 113 | int16_t &mat_type, int32_t &mat_index, const string &material_str) |
| 114 | { |
| 115 | split_string(&tokens, material_str, ":"); |
| 116 | if (tokens.size() == 1) |
| 117 | { // Default to empty caste to display a list of valid castes later |
| 118 | tokens.push_back(""); |
| 119 | } |
| 120 | else if (tokens.size() != 2) { |
| 121 | out.printerr("You must specify a creature ID and caste for this item type!\n"); |
| 122 | return CR_FAILURE; |
| 123 | } |
| 124 | |
| 125 | for (size_t i = 0; i < world->raws.creatures.all.size(); i++) |
| 126 | { |
| 127 | string castes = ""; |
| 128 | auto creature = world->raws.creatures.all[i]; |
| 129 | if (creature->creature_id == tokens[0]) |
| 130 | { |
| 131 | for (size_t j = 0; j < creature->caste.size(); j++) |
| 132 | { |
| 133 | auto caste = creature->caste[j]; |
| 134 | castes += " " + caste->caste_id; |
| 135 | if (caste->caste_id == tokens[1]) |
| 136 | { |
| 137 | mat_type = i; |
| 138 | mat_index = j; |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | if (mat_type == -1) { |
| 143 | if (tokens[1].empty()) |
| 144 | out.printerr("You must also specify a caste.\n"); |
| 145 | else |
| 146 | out.printerr("The creature you specified has no such caste!\n"); |
| 147 | out.printerr("Valid castes:{}\n", castes); |
| 148 | return false; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | if (mat_type == -1) { |
| 153 | out.printerr("Unrecognized creature ID!\n"); |
| 154 | return false; |
| 155 | } |
| 156 | return true; |
| 157 | } |
| 158 | |
| 159 | static inline bool select_plant_growth(color_ostream &out, vector<string> &tokens, df::item_type &item_type, |
| 160 | int16_t &item_subtype, int16_t &mat_type, int32_t &mat_index, const string &material_str) |
no test coverage detected