From 92ac36ec562e3a04f0ba90428686291380f80c3b Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Fri, 25 Mar 2005 21:04:39 +0000 Subject: [PATCH] (rea): Set parameters for read to [yes|no|]. Add parameters for read in the command list and the info pages. Closes #1010010. --- info/Commands/read.t | 16 ++++++++++++---- src/lib/commands/rea.c | 19 +++++++++++-------- src/lib/player/empmod.c | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/info/Commands/read.t b/info/Commands/read.t index 5167ba8b..643fad98 100644 --- a/info/Commands/read.t +++ b/info/Commands/read.t @@ -1,20 +1,28 @@ .TH Command READ .NA read "Read your telegrams" .LV Basic -.SY "read" +.SY "read [yes|no|]" The read command is used to read the telegrams sent you by other countries and by the game, (e.g. when you make a sale or are attacked). .sp +After reading all your telegrams you may delete them by +specifying \*Qyes\*U or not by specifying \*Qno\*U as an argument. +If an argument is not supplied then you will be prompted +to either answer \*Qyes\*U or \*Qno\*U to delete the telegrams. +If you supply or answer \*Qno\*U, the telegrams will remain +pending but you will not be reminded of them. +.sp +Deities can specify a argument which +selects a country's telegrams to read. +If the argument is supplied, the telegrams can not be deleted. +.sp When telegrams arrive you are informed with: .NF \*QYou have a new telegram waiting ...\*U if there is just one new one, or \*QYou have ten new telegrams waiting ...\*U if there are ten of them, or \*QYou have several new telegrams waiting ...\*U if there are very many. .FI -After reading all your telegrams you may discard them by answering \*Qyes\*U to -the question posed. If you answer \*Qno\*U the telegrams will remain -pending but you will not be reminded of them. .s1 This command reads only telegrams & bulletins, use the 'wire' command to read announcements. diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index 3465caea..e319eb78 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -40,6 +40,7 @@ #include "tel.h" #include "commands.h" #include "optlist.h" +#include "match.h" #include #include @@ -77,24 +78,29 @@ rea(void) time_t delta; int first = 1; int readit; + int may_delete = 1; /* may messages be deleted? */ memset(kind, 0, sizeof(kind)); now = time(NULL); if (*player->argp[0] == 'w') { - sprintf(kind, "announcement"); + strcpy(kind, "announcement"); if (player->argp[1] && isdigit(*player->argp[1])) { delta = days(atoi(player->argp[1])); then = now - delta; + may_delete = 0; } else then = np->nat_annotim; mbox = annfil; } else { - sprintf(kind, "telegram"); - if (player->god && player->argp[1] != 0) { + strcpy(kind, "telegram"); + if (player->god && player->argp[1] && + (mineq(player->argp[1], "yes") == ME_MISMATCH) && + (mineq(player->argp[1], "no") == ME_MISMATCH)) { if ((n = natarg(player->argp[1], "")) < 0) return RET_SYN; num = n; + may_delete = 0; } mbox = mailbox(mbox_buf, num); clear_telegram_is_new(player->cnum); @@ -167,7 +173,7 @@ rea(void) } } p = NULL; - if (teles > 0 && player->cnum == num) { /* } */ + if (teles > 0 && player->cnum == num && may_delete) { pr("\n"); if (teles == 1) { if (chance(0.25)) @@ -180,10 +186,7 @@ rea(void) else p = "Can I throw away these old love letters? "; } - if (player->god && *kind == 't') - p = getstarg(player->argp[2], p, buf); - else - p = getstarg(player->argp[1], p, buf); + p = getstarg(player->argp[1], p, buf); if (p && *p == 'y') { if ((filelen = fsize(fileno(telfp))) > size) { pr("Wait a sec! A new %s has arrived...\n", kind); diff --git a/src/lib/player/empmod.c b/src/lib/player/empmod.c index ffd98ba5..d9e6bb58 100644 --- a/src/lib/player/empmod.c +++ b/src/lib/player/empmod.c @@ -192,7 +192,7 @@ struct cmndstr player_coms[] = { {"quit", 0, quit, 0, VIS}, {"radar ", 1, rada, 0, NORM + CAP}, {"range ", 1, range, C_MOD, NORM + CAP}, - {"read", 0, rea, C_MOD, VIS}, + {"read [yes|no|]", 0, rea, C_MOD, VIS}, {"realm []", 0, real, C_MOD, NORM}, {"recon ", 3, reco, C_MOD, NORM + MONEY + CAP},