From 951e0d87fa9ef8e820bd49c643202394f049198f Mon Sep 17 00:00:00 2001 From: keni Date: Thu, 12 Oct 2006 00:17:17 +0000 Subject: [PATCH] Pad rumors to improve distribution of delivered rumors. --- doc/fixes35.0 | 1 + src/rumors.c | 13 ++++++ util/makedefs.c | 110 +++++++++++++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index bc4dac53d..497058b1f 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -163,6 +163,7 @@ bugles affect all monsters to some extent nurses are affected if player is polymorphed as a cockatrice getting a particular rotten food result can't make attempting to eat a corpse of one of the Riders be survivable +pad rumors to improve distribution of delivered rumors Platform- and/or Interface-Specific Fixes diff --git a/src/rumors.c b/src/rumors.c index 5d37b75d8..dd47a6e57 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -149,6 +149,19 @@ boolean exclude_cookie; pline("Can't open rumors file!"); true_rumor_size = -1; /* don't try to open it again */ } +/* this is safe either way, so do it always since we can't get the definition + * out of makedefs.c + */ +#define PAD_RUMORS_TO +#ifdef PAD_RUMORS_TO + /* remove padding */ + { + char *x = eos(rumor_buf) - 1; + while(x > rumor_buf && *x=='_') x--; + *++x = '\n'; + *x = '\0'; + } +#endif return rumor_buf; } diff --git a/util/makedefs.c b/util/makedefs.c index 4afda5f8e..fd860fb2d 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -132,7 +132,7 @@ static char xclear[MAX_ROW][MAX_COL]; #endif /*-end of vision defs-*/ -static char in_line[256], filename[60]; +static char in_line[256], filename[600]; #ifdef FILE_PREFIX /* if defined, a first argument not starting with - is @@ -344,12 +344,65 @@ const char *str; return buf; } +#define PAD_RUMORS_TO 60 +/* common code for do_rumors(). Return 0 on error. */ +static long +read_rumors_file( + const char *file_ext, + int *rumor_count, + long *rumor_size, + long old_rumor_offset +){ + char infile[600]; + long rumor_offset; + Sprintf(infile, DATA_IN_TEMPLATE, RUMOR_FILE); + Strcat(infile, file_ext); + if (!(ifp = fopen(infile, RDTMODE))) { + perror(infile); + return 0; + } + + /* copy the rumors */ + while (fgets(in_line, sizeof in_line, ifp) != 0) { +#ifdef PAD_RUMORS_TO + int len = strlen(in_line); + if(len <= PAD_RUMORS_TO){ /* XXX enforce min len? */ + char *base = index(in_line, '\n'); + while(len++