MCPcopy Create free account
hub / github.com/crawl/crawl / parse_corpse_spec

Method parse_corpse_spec

crawl-ref/source/mapdef.cc:5202–5239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5200}
5201
5202bool 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
5241bool item_list::parse_single_spec(item_spec& result, string s)
5242{

Callers

nothing calls this directly

Calls 7

strip_tagFunction · 0.85
strip_suffixFunction · 0.85
make_stringfFunction · 0.85
add_monsMethod · 0.80
emptyMethod · 0.45
get_monsterMethod · 0.45

Tested by

no test coverage detected