| 357 | |
| 358 | /* might destroy otmp if hero drops it */ |
| 359 | staticfn struct obj * |
| 360 | touchfood(struct obj *otmp) |
| 361 | { |
| 362 | if (otmp->quan > 1L) { |
| 363 | if (!carried(otmp)) |
| 364 | (void) splitobj(otmp, otmp->quan - 1L); |
| 365 | else |
| 366 | otmp = splitobj(otmp, 1L); |
| 367 | debugpline0("split food,"); |
| 368 | } |
| 369 | |
| 370 | if (!otmp->oeaten) { |
| 371 | costly_alteration(otmp, COST_BITE); |
| 372 | otmp->oeaten = obj_nutrition(otmp); |
| 373 | } |
| 374 | |
| 375 | if (carried(otmp)) { |
| 376 | freeinv(otmp); |
| 377 | if (inv_cnt(FALSE) >= invlet_basic) { |
| 378 | sellobj_state(SELL_DONTSELL); |
| 379 | dropy(otmp); |
| 380 | sellobj_state(SELL_NORMAL); |
| 381 | if (otmp->where == OBJ_DELETED) |
| 382 | otmp = (struct obj *) NULL; |
| 383 | } else { |
| 384 | otmp = addinv_nomerge(otmp); |
| 385 | } |
| 386 | } |
| 387 | return otmp; |
| 388 | } |
| 389 | |
| 390 | /* When food decays, in the middle of your meal, we don't want to dereference |
| 391 | * any dangling pointers, so set it to null (which should still trigger |
no test coverage detected