called as you start to eat */
| 2019 | |
| 2020 | /* called as you start to eat */ |
| 2021 | staticfn void |
| 2022 | start_eating(struct obj *otmp, boolean already_partly_eaten) |
| 2023 | { |
| 2024 | const char *old_nomovemsg, *save_nomovemsg; |
| 2025 | static char msgbuf[BUFSZ]; |
| 2026 | |
| 2027 | debugpline2("start_eating: %s (victual = %s)", |
| 2028 | /* note: fmt_ptr() returns a static buffer but supports |
| 2029 | several such so we don't need to copy the first result |
| 2030 | before calling it a second time */ |
| 2031 | fmt_ptr((genericptr_t) otmp), |
| 2032 | fmt_ptr((genericptr_t) svc.context.victual.piece)); |
| 2033 | debugpline1("reqtime = %d", svc.context.victual.reqtime); |
| 2034 | debugpline1("(original reqtime = %d)", objects[otmp->otyp].oc_delay); |
| 2035 | debugpline1("nmod = %d", svc.context.victual.nmod); |
| 2036 | debugpline1("oeaten = %d", otmp->oeaten); |
| 2037 | svc.context.victual.fullwarn = svc.context.victual.doreset = 0; |
| 2038 | svc.context.victual.eating = 1; |
| 2039 | |
| 2040 | if (otmp->otyp == CORPSE || otmp->globby) { |
| 2041 | cprefx(svc.context.victual.piece->corpsenm); |
| 2042 | if (!svc.context.victual.piece || !svc.context.victual.eating) { |
| 2043 | /* rider revived, or hero died and was lifesaved */ |
| 2044 | return; |
| 2045 | } |
| 2046 | } |
| 2047 | |
| 2048 | old_nomovemsg = gn.nomovemsg; |
| 2049 | if (bite()) { |
| 2050 | /* survived choking, finish off food that's nearly done; |
| 2051 | need this to handle cockatrice eggs, fortune cookies, etc */ |
| 2052 | if (++svc.context.victual.usedtime >= svc.context.victual.reqtime) { |
| 2053 | /* don't want done_eating() to issue gn.nomovemsg if it |
| 2054 | is due to vomit() called by bite() */ |
| 2055 | save_nomovemsg = gn.nomovemsg; |
| 2056 | if (!old_nomovemsg) |
| 2057 | gn.nomovemsg = 0; |
| 2058 | done_eating(FALSE); |
| 2059 | if (!old_nomovemsg) |
| 2060 | gn.nomovemsg = save_nomovemsg; |
| 2061 | } |
| 2062 | return; |
| 2063 | } |
| 2064 | |
| 2065 | if (++svc.context.victual.usedtime >= svc.context.victual.reqtime) { |
| 2066 | /* print "finish eating" message if they just resumed -dlc */ |
| 2067 | done_eating((svc.context.victual.reqtime > 1 |
| 2068 | || already_partly_eaten) ? TRUE : FALSE); |
| 2069 | return; |
| 2070 | } |
| 2071 | |
| 2072 | Sprintf(msgbuf, "eating %s", food_xname(otmp, TRUE)); |
| 2073 | set_occupation(eatfood, msgbuf, 0); |
| 2074 | } |
| 2075 | |
| 2076 | /* used by shrink_glob() timer routine */ |
| 2077 | boolean |
no test coverage detected