MCPcopy Create free account
hub / github.com/NetHack/NetHack / dropp

Function dropp

src/polyself.c:1122–1154  ·  view source on GitHub ↗

dropx() jacket for break_armor() */

Source from the content-addressed store, hash-verified

1120
1121/* dropx() jacket for break_armor() */
1122staticfn void
1123dropp(struct obj *obj)
1124{
1125 struct obj *otmp;
1126
1127 /*
1128 * Dropping worn armor while polymorphing might put hero into water
1129 * (loss of levitation boots or water walking boots that the new
1130 * form can't wear), where emergency_disrobe() could remove it from
1131 * inventory. Without this, dropx() could trigger an 'object lost'
1132 * panic. Right now, boots are the only armor which might encounter
1133 * this situation, but handle it for all armor.
1134 *
1135 * Hypothetically, 'obj' could have merged with something (not
1136 * applicable for armor) and no longer be a valid pointer, so scan
1137 * inventory for it instead of trusting obj->where.
1138 */
1139 for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
1140 if (otmp == obj) {
1141 dropx(obj);
1142 /* Note that otmp->nobj is pointing at fobj now,
1143 * as a result of:
1144 * dropx() -> dropy() -> dropz() -> place_object(),
1145 * and no longer pointing at the next obj in inventory.
1146 * That would be an issue if this loop were allowed
1147 * to continue, but the break statement that
1148 * follows prevents the loop from continuing on with
1149 * objects on the floor.
1150 */
1151 break;
1152 }
1153 }
1154}
1155
1156staticfn void
1157break_armor(void)

Callers 1

break_armorFunction · 0.85

Calls 1

dropxFunction · 0.85

Tested by

no test coverage detected