| 5200 | } |
| 5201 | |
| 5202 | bool item_list::parse_corpse_spec(item_spec &result, string s) |
| 5203 | { |
| 5204 | const bool never_decay = strip_tag(s, "never_decay"); |
| 5205 | |
| 5206 | if (never_decay) |
| 5207 | result.props[CORPSE_NEVER_DECAYS].get_bool() = true; |
| 5208 | |
| 5209 | const bool corpse = strip_suffix(s, "corpse"); |
| 5210 | const bool skeleton = !corpse && strip_suffix(s, "skeleton"); |
| 5211 | |
| 5212 | result.base_type = OBJ_CORPSES; |
| 5213 | result.sub_type = static_cast<int>(corpse ? CORPSE_BODY : |
| 5214 | CORPSE_SKELETON); |
| 5215 | |
| 5216 | // The caller wants a specific monster, no doubt with the best of |
| 5217 | // motives. Let's indulge them: |
| 5218 | mons_list mlist; |
| 5219 | const string mons_parse_err = mlist.add_mons(s, true); |
| 5220 | if (!mons_parse_err.empty()) |
| 5221 | { |
| 5222 | error = mons_parse_err; |
| 5223 | return false; |
| 5224 | } |
| 5225 | |
| 5226 | // Get the actual monster spec: |
| 5227 | mons_spec spec = mlist.get_monster(0); |
| 5228 | monster_type mtype = static_cast<monster_type>(spec.type); |
| 5229 | if (!monster_corpse_is_valid(&mtype, s, skeleton)) |
| 5230 | { |
| 5231 | error = make_stringf("Requested corpse '%s' is invalid", |
| 5232 | s.c_str()); |
| 5233 | return false; |
| 5234 | } |
| 5235 | |
| 5236 | // Ok, looking good, the caller can have their requested toy. |
| 5237 | result.set_corpse_monster_spec(spec); |
| 5238 | return true; |
| 5239 | } |
| 5240 | |
| 5241 | bool item_list::parse_single_spec(item_spec& result, string s) |
| 5242 | { |
nothing calls this directly
no test coverage detected