Check subscript of rpt[]
Make nws_vrb unsigned to simplify that.
This commit is contained in:
parent
5fda9462bd
commit
990b39edec
4 changed files with 8 additions and 4 deletions
|
@ -50,7 +50,7 @@ struct nwsstr {
|
||||||
short nws_uid;
|
short nws_uid;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
natid nws_ano; /* "actor" country # */
|
natid nws_ano; /* "actor" country # */
|
||||||
signed char nws_vrb; /* action (verb) */
|
unsigned char nws_vrb; /* action (verb) */
|
||||||
natid nws_vno; /* "victim" country # */
|
natid nws_vno; /* "victim" country # */
|
||||||
signed char nws_ntm; /* number of times */
|
signed char nws_ntm; /* number of times */
|
||||||
time_t nws_when; /* time of action */
|
time_t nws_when; /* time of action */
|
||||||
|
|
|
@ -84,6 +84,8 @@ head(void)
|
||||||
snxtitem_all(&nstr, EF_NEWS);
|
snxtitem_all(&nstr, EF_NEWS);
|
||||||
maxcnum = 0;
|
maxcnum = 0;
|
||||||
while (nxtitem(&nstr, &news)) {
|
while (nxtitem(&nstr, &news)) {
|
||||||
|
if (!news.nws_vrb || CANT_HAPPEN(news.nws_vrb > N_MAX_VERB))
|
||||||
|
continue;
|
||||||
news_age = now - news.nws_when;
|
news_age = now - news.nws_when;
|
||||||
if (news_age > news_per)
|
if (news_age > news_per)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -85,6 +85,8 @@ news(void)
|
||||||
head();
|
head();
|
||||||
pr("\nThe details of Empire news since %s", ctime(&then));
|
pr("\nThe details of Empire news since %s", ctime(&then));
|
||||||
while (nxtitem(&nstr, &nws)) {
|
while (nxtitem(&nstr, &nws)) {
|
||||||
|
if (!nws.nws_vrb || CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB))
|
||||||
|
continue;
|
||||||
if (nws.nws_when < then)
|
if (nws.nws_when < then)
|
||||||
continue;
|
continue;
|
||||||
if (opt_HIDDEN) {
|
if (opt_HIDDEN) {
|
||||||
|
@ -102,6 +104,8 @@ news(void)
|
||||||
pr("\n\t === %s ===\n", page_headings[page].name);
|
pr("\n\t === %s ===\n", page_headings[page].name);
|
||||||
snxtitem_rewind(&nstr);
|
snxtitem_rewind(&nstr);
|
||||||
while (nxtitem(&nstr, &nws)) {
|
while (nxtitem(&nstr, &nws)) {
|
||||||
|
if (CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB))
|
||||||
|
continue;
|
||||||
if (rpt[(int)nws.nws_vrb].r_newspage != page)
|
if (rpt[(int)nws.nws_vrb].r_newspage != page)
|
||||||
continue;
|
continue;
|
||||||
if (nws.nws_when < then)
|
if (nws.nws_when < then)
|
||||||
|
@ -191,8 +195,6 @@ preport(struct nwsstr *np)
|
||||||
strcpy(cp, cname(np->nws_ano));
|
strcpy(cp, cname(np->nws_ano));
|
||||||
cp += strlen(cp);
|
cp += strlen(cp);
|
||||||
*cp++ = ' ';
|
*cp++ = ' ';
|
||||||
if (np->nws_vrb < 1 || np->nws_vrb > N_MAX_VERB)
|
|
||||||
np->nws_vrb = 0;
|
|
||||||
sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[random() % NUM_RPTS],
|
sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[random() % NUM_RPTS],
|
||||||
cname(np->nws_vno));
|
cname(np->nws_vno));
|
||||||
cp += strlen(cp);
|
cp += strlen(cp);
|
||||||
|
|
|
@ -427,7 +427,7 @@ struct castr loan_ca[] = {
|
||||||
struct castr news_ca[] = {
|
struct castr news_ca[] = {
|
||||||
/* no need for uid as long as it's not referenced from other tables */
|
/* no need for uid as long as it's not referenced from other tables */
|
||||||
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor", EF_NATION},
|
||||||
{NSC_CHAR, 0, 0, fldoff(nwsstr, nws_vrb), "action", EF_NEWS_CHR},
|
{NSC_UCHAR, 0, 0, fldoff(nwsstr, nws_vrb), "action", EF_NEWS_CHR},
|
||||||
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_vno), "victim", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_vno), "victim", EF_NATION},
|
||||||
{NSC_CHAR, 0, 0, fldoff(nwsstr, nws_ntm), "times", EF_BAD},
|
{NSC_CHAR, 0, 0, fldoff(nwsstr, nws_ntm), "times", EF_BAD},
|
||||||
{NSC_TIME, 0, 0, fldoff(nwsstr, nws_when), "time", EF_BAD},
|
{NSC_TIME, 0, 0, fldoff(nwsstr, nws_when), "time", EF_BAD},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue