MCPcopy Index your code
hub / github.com/NetHack/NetHack / newmail

Function newmail

src/mail.c:398–456  ·  view source on GitHub ↗

Deliver a scroll of mail. */ ARGSUSED*/

Source from the content-addressed store, hash-verified

396/* Deliver a scroll of mail. */
397/*ARGSUSED*/
398staticfn void
399newmail(struct mail_info *info)
400{
401 struct monst *md;
402 coord start, stop;
403 boolean message_seen = FALSE;
404
405 /* Try to find good starting and stopping places. */
406 if (!md_start(&start) || !md_stop(&stop, &start))
407 goto give_up;
408
409 /* Make the daemon. Have it rush towards the hero. */
410 if (!(md = makemon(&mons[PM_MAIL_DAEMON], start.x, start.y, NO_MM_FLAGS)))
411 goto give_up;
412 if (!md_rush(md, stop.x, stop.y))
413 goto go_back;
414
415 message_seen = TRUE;
416 if (!Deaf) {
417 SetVoice(md, 0, 80, 0);
418 verbalize("%s, %s! %s.", Hello(md), svp.plname, info->display_txt);
419 } else {
420 pline("Message: %s.", info->display_txt);
421 }
422
423 if (info->message_typ) {
424 struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
425
426 if (info->object_nam)
427 obj = oname(obj, info->object_nam, ONAME_NO_FLAGS);
428 if (info->response_cmd)
429 new_omailcmd(obj, info->response_cmd);
430
431 if (!m_next2u(md)) {
432 if (!Deaf) {
433 SetVoice(md, 0, 80, 0);
434 verbalize("Catch!");
435 } else {
436 /* don't bother with nonverbal alternative ... */
437 ;
438 }
439 }
440 display_nhwindow(WIN_MESSAGE, FALSE);
441 obj = hold_another_object(obj, "Oops!", (const char *) 0,
442 (const char *) 0);
443 nhUse(obj);
444 }
445
446 go_back:
447 /* zip back to starting location */
448 if (!md_rush(md, start.x, start.y))
449 md->mx = md->my = 0; /* for mongone, md is not on map */
450 mongone(md);
451
452 give_up:
453 /* deliver some classes of messages even if no daemon ever shows up */
454 if (!message_seen && info->message_typ == MSG_OTHER)
455 pline("Hark! \"%s.\"", info->display_txt);

Callers 1

ckmailstatusFunction · 0.70

Calls 12

md_startFunction · 0.85
md_stopFunction · 0.85
makemonFunction · 0.85
md_rushFunction · 0.85
verbalizeFunction · 0.85
HelloFunction · 0.85
mksobjFunction · 0.85
onameFunction · 0.85
hold_another_objectFunction · 0.85
mongoneFunction · 0.85
plineFunction · 0.70
new_omailcmdFunction · 0.70

Tested by

no test coverage detected