Пример #1
0
char *dag_parse_readline(struct lexer_book *bk, struct dag_node *n)
{
	struct dag *d = bk->d;
	struct dag_lookup_set s = { d, bk->category, n, NULL };

	char *line = get_continued_line(bk);

	if(line) {
		/* Chop off comments
		 * TODO: this will break if we use # in a string. */
		char *hash = strrchr(line, '#');
		if(hash && hash != line) {
			*hash = 0;
		}

		char *subst_line = string_subst(line, dag_lookup_str, &s);

		free(bk->linetext);
		bk->linetext = xxstrdup(subst_line);

		/* Expand backslash-escaped characters. */
		/* NOTE: This function call is responsible for translating escape
		   character sequences such as \n, \t, etc. which are found in the
		   makeflow file into their ASCII character equivalents. Such escape
		   sequences are necessary for assigning values to variables which
		   contain multiple lines of text, since the entire assignment
		   statement must be contained on one line. */
		string_replace_backslash_codes(subst_line, subst_line);

		return subst_line;
	}

	return NULL;
}
Пример #2
0
void dosounds(void)
{
    struct mkroom *sroom;
    int hallu, vx, vy;
    struct monst *mtmp;

    if (!flags.soundok || u.uswallow || Underwater) return;

    if (level->sounds && !rn2(level->sounds->freq)) {
	int idx = rn2(level->sounds->n_sounds);
	char *buf;
	struct lvl_sound_bite *snd = &level->sounds->sounds[idx];
	buf = string_subst(snd->msg);
	switch (snd->flags) {
	default:
	case LVLSND_HEARD:	You_hear(buf);			break;
	case LVLSND_PLINED:	pline(buf);			break;
	case LVLSND_VERBAL:	verbalize(buf);			break;
	case LVLSND_FELT:	pline("You feel %s", buf);	break;
	}
    }

    hallu = Hallucination ? 1 : 0;

    if (level->flags.nfountains && !rn2(400)) {
	static const char * const fountain_msg[4] = {
		"bubbling water.",
		"water falling on coins.",
		"the splashing of a naiad.",
		"a soda fountain!",
	};
	You_hear(fountain_msg[rn2(3)+hallu]);
    }

    if (level->flags.nsinks && !rn2(300)) {
	static const char * const sink_msg[3] = {
		"a slow drip.",
		"a gurgling noise.",
		"dishes being washed!",
	};
	You_hear(sink_msg[rn2(2)+hallu]);
    }

    if (level->flags.has_court && !rn2(200)) {
	static const char * const throne_msg[4] = {
		"the tones of courtly conversation.",
		"a sceptre pounded in judgment.",
		"Someone shouts \"Off with %s head!\"",
		"Queen Beruthiel's cats!",
	};
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if ((mtmp->msleeping ||
			is_lord(mtmp->data) || is_prince(mtmp->data)) &&
		!is_animal(mtmp->data) &&
		mon_in_room(mtmp, COURT)) {
		/* finding one is enough, at least for now */
		int which = rn2(3)+hallu;

		if (which != 2) You_hear(throne_msg[which]);
		else		pline(throne_msg[2], uhis());
		return;
	    }
	}
    }
    if (level->flags.has_garden && !rn2(200)) {
	static const char * const garden_msg[4] = {
		"crickets chirping.",
		"birds singing.",
		"grass growing!",
		"wind in the willows!",
	};
	You_hear(garden_msg[rn2(2) + 2 * hallu]);
	return;
    }
    if (level->flags.has_swamp && !rn2(200)) {
	static const char * const swamp_msg[3] = {
		"You hear mosquitoes!",
		"You smell marsh gas!",	/* so it's a smell...*/
		"You hear Donald Duck!",
	};
	pline(swamp_msg[rn2(2)+hallu]);
	return;
    }
    if (level->flags.has_vault && !rn2(200)) {
	if (!(sroom = search_special(level, VAULT))) {
	    /* strange ... */
	    level->flags.has_vault = 0;
	    return;
	}
	if (gd_sound())
	    switch (rn2(2)+hallu) {
		case 1: {
		    boolean gold_in_vault = FALSE;

		    for (vx = sroom->lx;vx <= sroom->hx; vx++)
			for (vy = sroom->ly; vy <= sroom->hy; vy++)
			    if (gold_at(level, vx, vy))
				gold_in_vault = TRUE;
		    if (vault_occupied(u.urooms) !=
			 (ROOM_INDEX(sroom) + ROOMOFFSET))
		    {
			if (gold_in_vault)
			    You_hear(!hallu ? "someone counting money." :
				"the quarterback calling the play.");
			else
			    You_hear("someone searching.");
			break;
		    }
		    /* fall into... (yes, even for hallucination) */
		}
		case 0:
		    You_hear("the footsteps of a guard on patrol.");
		    break;
		case 2:
		    You_hear("Ebenezer Scrooge!");
		    break;
	    }
	return;
    }
    if (level->flags.has_beehive && !rn2(200)) {
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) &&
		mon_in_room(mtmp, BEEHIVE)) {
		switch (rn2(2)+hallu) {
		    case 0:
			You_hear("a low buzzing.");
			break;
		    case 1:
			You_hear("an angry drone.");
			break;
		    case 2:
			You_hear("bees in your %sbonnet!",
			    uarmh ? "" : "(nonexistent) ");
			break;
		}
		return;
	    }
	}
    }
    if (level->flags.has_lemurepit && !rn2(20)) {
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if (mtmp->data == &mons[PM_LEMURE] &&
		mon_in_room(mtmp, LEMUREPIT)) {
		if (hallu) {
		    switch (rn2(3)) {
			case 0:
			    You_hear("screams of lust!");
			    break;
			case 1:
			    You_hear("the crack of your mistress's whip!");
			    break;
			case 2:
			    You_hear("a weeping willow!");
			    break;
		    }
		} else {
		    switch (rn2(6)) {
			case 0:
			    You_hear("the crack of a barbed whip!");
			    break;
			case 1:
			    You_hear("the screams of tortured souls!");
			    break;
			case 2:
			    You_hear("a wail of eternal anguish!");
			    break;
			case 3:
			    You_hear("diabolical laughter!");
			    break;
			case 4:
			    You_hear("cries of repentance!");
			    break;
			case 5:
			    You_hear("futile pleas for mercy!");
			    break;
		    }
		}
		return;
	    }
	}
    }
    if (level->flags.has_morgue && !rn2(200)) {
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if (is_undead(mtmp->data) &&
		mon_in_room(mtmp, MORGUE)) {
		switch (rn2(2)+hallu) {
		    case 1:
			if (!strcmp(body_part(HAIR), "hair")) {
			    pline("The %s on the back of your %s stands up.",
				body_part(HAIR), body_part(NECK));
			    break;
			}
			/* fall through */
		    case 2:
			if (!strcmp(body_part(HAIR), "hair")) {
			    pline("The %s on your %s seems to stand up.",
				    body_part(HAIR), body_part(HEAD));
			    break;
			}
			/* fall through */
		    case 0:
			pline("You suddenly realize it is unnaturally quiet.");
			break;
		}
		return;
	    }
	}
    }
    if (level->flags.has_barracks && !rn2(200)) {
	static const char * const barracks_msg[4] = {
		"blades being honed.",
		"loud snoring.",
		"dice being thrown.",
		"General MacArthur!",
	};
	int count = 0;

	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if (is_mercenary(mtmp->data) &&
		mon_in_room(mtmp, BARRACKS) &&
		/* sleeping implies not-yet-disturbed (usually) */
		(mtmp->msleeping || ++count > 5)) {
		You_hear(barracks_msg[rn2(3)+hallu]);
		return;
	    }
	}
    }
    if (level->flags.has_zoo && !rn2(200)) {
	static const char * const zoo_msg[3] = {
		"a sound reminiscent of an elephant stepping on a peanut.",
		"a sound reminiscent of a seal barking.",
		"Doctor Dolittle!",
	};
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if ((mtmp->msleeping || is_animal(mtmp->data)) &&
		    mon_in_room(mtmp, ZOO)) {
		You_hear(zoo_msg[rn2(2)+hallu]);
		return;
	    }
	}
    }
    if (level->flags.has_shop && !rn2(200)) {
	if (!(sroom = search_special(level, ANY_SHOP))) {
	    /* strange... */
	    level->flags.has_shop = 0;
	    return;
	}
	if (tended_shop(sroom) &&
		!strchr(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) {
	    static const char * const shop_msg[3] = {
		    "someone cursing shoplifters.",
		    "the chime of a cash register.",
		    "Neiman and Marcus arguing!",
	    };
	    You_hear(shop_msg[rn2(2)+hallu]);
	}
	return;
    }
    if (Is_oracle_level(&u.uz) && !rn2(400)) {
	/* make sure the Oracle is still here */
	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon)
	    if (!DEADMONSTER(mtmp) && mtmp->data == &mons[PM_ORACLE])
		break;
	/* and don't produce silly effects when she's clearly visible */
	if (mtmp && (hallu || !canseemon(level, mtmp))) {
	    static const char * const ora_msg[5] = {
		    "a strange wind.",		/* Jupiter at Dodona */
		    "convulsive ravings.",	/* Apollo at Delphi */
		    "snoring snakes.",		/* AEsculapius at Epidaurus */
		    "someone say \"No more woodchucks!\"",
		    "a loud ZOT!"		/* both rec.humor.oracle */
	    };
	    You_hear(ora_msg[rn2(3)+hallu*2]);
	}
	return;
    }
    if (!Is_blackmarket(&u.uz) && at_dgn_entrance(&u.uz, "One-eyed Sam's Market") &&
	!rn2(200)) {
	static const char *blkmar_msg[3] = {
	    "You hear someone complaining about the prices.",
	    "Somebody whispers: \"Food rations? Only 900 zorkmids.\"",
	    "You feel like searching for more gold.",
	};
	pline(blkmar_msg[rn2(2)+hallu]);
    }
}