returns 2 if pet dies, otherwise 1 */
| 215 | |
| 216 | /* returns 2 if pet dies, otherwise 1 */ |
| 217 | int |
| 218 | dog_eat(struct monst *mtmp, |
| 219 | struct obj *obj, /* if unpaid, then thrown or kicked by hero */ |
| 220 | coordxy x, /* dog's starting location, */ |
| 221 | coordxy y, /* might be different from current */ |
| 222 | boolean devour) |
| 223 | { |
| 224 | struct edog *edog = EDOG(mtmp); |
| 225 | int nutrit, res; |
| 226 | long oprice; |
| 227 | char objnambuf[BUFSZ], *obj_name; |
| 228 | |
| 229 | objnambuf[0] = '\0'; |
| 230 | if (edog->hungrytime < svm.moves) |
| 231 | edog->hungrytime = svm.moves; |
| 232 | nutrit = dog_nutrition(mtmp, obj); |
| 233 | |
| 234 | if (devour) { |
| 235 | if (mtmp->meating > 1) |
| 236 | mtmp->meating /= 2; |
| 237 | if (nutrit > 1) |
| 238 | nutrit = (nutrit * 3) / 4; |
| 239 | } |
| 240 | edog->hungrytime += nutrit; |
| 241 | mtmp->mconf = 0; |
| 242 | if (edog->mhpmax_penalty) { |
| 243 | /* no longer starving */ |
| 244 | mtmp->mhpmax += edog->mhpmax_penalty; |
| 245 | edog->mhpmax_penalty = 0; |
| 246 | } |
| 247 | if (mtmp->mflee && mtmp->mfleetim > 1) |
| 248 | mtmp->mfleetim /= 2; |
| 249 | if (mtmp->mtame < 20) |
| 250 | mtmp->mtame++; |
| 251 | if (x != mtmp->mx || y != mtmp->my) { /* moved & ate on same turn */ |
| 252 | newsym(x, y); |
| 253 | newsym(mtmp->mx, mtmp->my); |
| 254 | } |
| 255 | if (mtmp->data == &mons[PM_KILLER_BEE] |
| 256 | && obj->otyp == LUMP_OF_ROYAL_JELLY |
| 257 | && (res = bee_eat_jelly(mtmp, obj)) >= 0) |
| 258 | /* bypass most of dog_eat(), including apport update */ |
| 259 | return (res + 1); /* 1 -> 2, 0 -> 1; -1, keep going */ |
| 260 | |
| 261 | /* food items are eaten one at a time; entire stack for other stuff */ |
| 262 | if (obj->quan > 1L && obj->oclass == FOOD_CLASS) |
| 263 | obj = splitobj(obj, 1L); |
| 264 | if (obj->unpaid) |
| 265 | iflags.suppress_price++; |
| 266 | if (is_pool(mtmp->mx, mtmp->my) && !Underwater) { |
| 267 | /* Don't print obj */ |
| 268 | /* TODO: Reveal presence of sea monster (especially sharks) */ |
| 269 | } else { |
| 270 | /* food is at monster's current location, <mx,my>; |
| 271 | <x,y> was monster's location at start of this turn; |
| 272 | they might be the same but will be different when |
| 273 | the monster is moving+eating on same turn */ |
| 274 | boolean seeobj = cansee(mtmp->mx, mtmp->my), |
no test coverage detected