(tchrstr, tchr_ca): Remove, use struct symbol and symbol_ca. Users

changed.
(tchr, treaty_flags): Rename for consistency with other flags.
This commit is contained in:
Markus Armbruster 2005-10-29 14:10:23 +00:00
parent 02ec5df820
commit e612db5cb6
7 changed files with 17 additions and 31 deletions

View file

@ -205,7 +205,6 @@ extern struct castr lchr_ca[];
extern struct castr nuke_ca[];
extern struct castr nchr_ca[];
extern struct castr treaty_ca[];
extern struct castr tchr_ca[];
extern struct castr loan_ca[];
extern struct castr news_ca[];
extern struct castr lost_ca[];
@ -220,6 +219,7 @@ extern struct symbol ship_chr_flags[];
extern struct symbol plane_chr_flags[];
extern struct symbol land_chr_flags[];
extern struct symbol nuke_chr_flags[];
extern struct symbol treaty_flags[];
extern struct castr mdchr_ca[];
extern struct symbol meta_type[];
extern struct symbol meta_flags[];

View file

@ -46,11 +46,6 @@ struct trtstr {
time_t trt_exp; /* expiration date */
};
struct tchrstr {
int t_cond; /* bit to indicate this clause */
char *t_name; /* description of clause */
};
#define TS_FREE 0
#define TS_PROPOSED 1
#define TS_SIGNED 2
@ -68,8 +63,6 @@ struct tchrstr {
#define TRTENL bit(9) /* no enlistment */
#define SUBFIR bit(10) /* no depth-charging submarines */
/* global treaty variables */
#define gettre(n, p) \
ef_read(EF_TREATY, n, p)
#define puttre(n, p) \
@ -77,6 +70,4 @@ struct tchrstr {
#define gettrep(n) \
(struct trtstr *) ef_ptr(EF_TREATY, n)
extern struct tchrstr tchr[];
#endif /* _TREATY_H_ */

View file

@ -81,7 +81,7 @@ do_treaty(void)
register int ourcond;
register int theircond;
register int j;
struct tchrstr *tcp;
struct symbol *tfp;
struct trtstr trty;
struct nstr_item nstr;
natid recipient;
@ -105,21 +105,21 @@ do_treaty(void)
}
pr("Terms for %s:\n", cname(recipient));
theircond = 0;
for (tcp = tchr; tcp && tcp->t_cond; tcp++) {
sprintf(prompt, "%s? ", tcp->t_name);
for (tfp = treaty_flags; tfp && tfp->name; tfp++) {
sprintf(prompt, "%s? ", tfp->name);
if ((cp = getstring(prompt, buf)) == 0)
return RET_FAIL;
if (*cp == 'y')
theircond |= tcp->t_cond;
theircond |= tfp->value;
}
pr("Terms for you:\n");
ourcond = 0;
for (tcp = tchr; tcp && tcp->t_cond; tcp++) {
sprintf(prompt, "%s? ", tcp->t_name);
for (tfp = treaty_flags; tfp && tfp->name; tfp++) {
sprintf(prompt, "%s? ", tfp->name);
if ((cp = getstring(prompt, buf)) == 0)
return RET_FAIL;
if (*cp == 'y')
ourcond |= tcp->t_cond;
ourcond |= tfp->value;
}
if (ourcond == 0 && theircond == 0) {
pr("Treaties with no clauses aren't very useful, boss!\n");

View file

@ -122,9 +122,9 @@ struct empfile empfile[] = {
{EF_NEWS_CHR, "news chr", NULL, EFF_CFG,
sizeof(rpt[0]), NULL, NULL, NULL,
-1, -1, 0, 0, (char *)rpt, 0, rpt_ca},
{EF_TREATY_CHR, "treaty chr", NULL, EFF_CFG,
sizeof(tchr[0]), NULL, NULL, NULL,
-1, -1, 0, 0, (char *)tchr, 0, tchr_ca},
{EF_TREATY_CHR, "treaty flags", NULL, EFF_CFG,
sizeof(treaty_flags[0]), NULL, NULL, NULL,
-1, -1, 0, 0, (char *)treaty_flags, 0, symbol_ca},
{EF_ITEM, "item", NULL, EFF_CFG,
sizeof(ichr[0]), NULL, NULL, NULL,
-1, -1, 0, 0, (char *)ichr, 0, ichr_ca},

View file

@ -373,12 +373,6 @@ struct castr treaty_ca[] = {
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
};
struct castr tchr_ca[] = {
{NSC_STRING, 0, 0, offsetof(struct tchrstr, t_name), "name", EF_BAD},
{NSC_INT, 0, 0, offsetof(struct tchrstr, t_cond), "cond", EF_BAD},
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
};
struct castr loan_ca[] = {
{NSC_NATID, 0, 0, fldoff(lonstr, l_loner), "loaner", EF_BAD},
{NSC_SHORT, 0, 0, fldoff(lonstr, l_uid), "uid", EF_BAD},

View file

@ -33,9 +33,10 @@
*/
#include "misc.h"
#include "nsc.h"
#include "treaty.h"
struct tchrstr tchr[] = {
struct symbol treaty_flags[] = {
{LNDATT, "no attacks on any land units"},
{SEAATT, "no attacks on any ships"},
{SEAFIR, "no shelling any ships"},
@ -47,5 +48,5 @@ struct tchrstr tchr[] = {
{NEWPLN, "no building planes"},
{NEWLND, "no building land units"},
{TRTENL, "no enlistment"},
{0, 0}
{0, NULL}
};

View file

@ -69,16 +69,16 @@ distrea(int n, register struct trtstr *tp)
pr("%s expires %s", cname(tp->trt_cnb), ctime(&tp->trt_exp));
pr("%24.24s terms", cname(tp->trt_cna));
pr(" - %s terms\n", cname(tp->trt_cnb));
for (i = 0; 0 != (cond = tchr[i].t_cond); i++) {
for (i = 0; 0 != (cond = treaty_flags[i].value); i++) {
acond = tp->trt_acond & cond;
bcond = tp->trt_bcond & cond;
if (acond | bcond) {
if (acond)
pr("%30s", tchr[i].t_name);
pr("%30s", treaty_flags[i].name);
else
pr("%30s", "");
if (bcond)
pr(" - %s\n", tchr[i].t_name);
pr(" - %s\n", treaty_flags[i].name);
else
pr(" -\n");
}