diff --git a/include/commodity.h b/include/commodity.h index b2f211ba..5ae2d2bf 100644 --- a/include/commodity.h +++ b/include/commodity.h @@ -51,9 +51,7 @@ struct comstr { coord sell_y; }; -#define getcomm(n, p) \ - ef_read(EF_COMM, n, p) -#define putcomm(n, p) \ - ef_write(EF_COMM, n, p) +#define getcomm(n, p) ef_read(EF_COMM, (n), (p)) +#define putcomm(n, p) ef_write(EF_COMM, (n), (p)) #endif diff --git a/include/land.h b/include/land.h index f316e0f0..576e4cb9 100644 --- a/include/land.h +++ b/include/land.h @@ -174,12 +174,9 @@ struct lchrstr { /* Chance to detect L_SPY unit (percent) */ #define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0) -#define getland(n, p) \ - ef_read(EF_LAND, n, p) -#define putland(n, p) \ - ef_write(EF_LAND, n, p) -#define getlandp(n) \ - (struct lndstr *) ef_ptr(EF_LAND, n) +#define getland(n, p) ef_read(EF_LAND, (n), (p)) +#define putland(n, p) ef_write(EF_LAND, (n), (p)) +#define getlandp(n) (struct lndstr *)ef_ptr(EF_LAND, (n)) extern struct lchrstr lchr[N_MAXLAND + 1]; diff --git a/include/loan.h b/include/loan.h index 60949b4f..48447c19 100644 --- a/include/loan.h +++ b/include/loan.h @@ -59,11 +59,8 @@ struct lonstr { extern long get_outstand(int); extern double loan_owed(struct lonstr *loan, time_t paytime); -#define getloan(n, lp) \ - ef_read(EF_LOAN, n, lp) -#define putloan(n, lp) \ - ef_write(EF_LOAN, n, lp) -#define getloanp(n) \ - (struct lonstr *) ef_ptr(EF_LOAN, n) +#define getloan(n, p) ef_read(EF_LOAN, (n), (p)) +#define putloan(n, p) ef_write(EF_LOAN, (n), (p)) +#define getloanp(n) (struct lonstr *)ef_ptr(EF_LOAN, (n)) #endif diff --git a/include/lost.h b/include/lost.h index 98c67acd..71b87619 100644 --- a/include/lost.h +++ b/include/lost.h @@ -47,8 +47,8 @@ struct loststr { time_t lost_timestamp; /* When it was lost */ }; -#define getlost(n, p) ef_read(EF_LOST, n, p) -#define putlost(n, p) ef_write(EF_LOST, n, p) +#define getlost(n, p) ef_read(EF_LOST, (n), (p)) +#define putlost(n, p) ef_write(EF_LOST, (n), (p)) /* src/lib/subs/lostsub.c */ extern void makelost(char, natid, short, coord, coord); diff --git a/include/map.h b/include/map.h index bc7f471c..9bdbf01c 100644 --- a/include/map.h +++ b/include/map.h @@ -37,7 +37,7 @@ #include "misc.h" #include "xy.h" -#define MAPWIDTH(persec) ((WORLD_X/2)*(persec + 1)+1) +#define MAPWIDTH(persec) ((WORLD_X/2) * ((persec) + 1) + 1) extern void blankfill(char *, struct range *, int); /* src/lib/subs/bigmap.c */ diff --git a/include/misc.h b/include/misc.h index f3603ce6..626d46ea 100644 --- a/include/misc.h +++ b/include/misc.h @@ -55,7 +55,7 @@ typedef long ssize_t; #define random rand #define srandom srand -#define strncasecmp(s1, s2, s3) _strnicmp(s1, s2, s3) +#define strncasecmp(s1, s2, s3) _strnicmp((s1), (s2), (s3)) #define mkdir(dir,perm) _mkdir((dir)) typedef int pid_t; diff --git a/include/nat.h b/include/nat.h index 00098f0c..4f261862 100644 --- a/include/nat.h +++ b/include/nat.h @@ -173,15 +173,11 @@ extern char *relates[]; /* procedures relating to nation stuff */ -#define putnat(n) \ - ef_write(EF_NATION, n->nat_cnum, n) -#define getnatp(n) \ - (struct natstr *) ef_ptr(EF_NATION, (int)n) +#define putnat(p) ef_write(EF_NATION, n->nat_cnum, (p)) +#define getnatp(n) (struct natstr *)ef_ptr(EF_NATION, (n)) -#define putrealm(p) \ - ef_write(EF_REALM, (int)(p)->r_uid, p) -#define getrealm(r, n, p) \ - ef_read(EF_REALM, (int)(r + (n * MAXNOR)), p) +#define getrealm(r, n, p) ef_read(EF_REALM, ((r) + ((n) * MAXNOR)), (p)) +#define putrealm(p) ef_write(EF_REALM, (p)->r_uid, (p)) extern double tfact(natid cn, double mult); extern double tfactfire(natid cn, double mult); diff --git a/include/news.h b/include/news.h index 2ad1df3b..a914c3e0 100644 --- a/include/news.h +++ b/include/news.h @@ -161,12 +161,9 @@ struct rptstr { #define N_TELE 11 #define N_MAX_PAGE 11 -#define getnews(n, p) \ - ef_read(EF_NEWS, n, p) -#define putnews(n, p) \ - ef_write(EF_NEWS, n, p) -#define getnewsp(n) \ - (struct nwsstr *) ef_ptr(EF_NEWS, n) +#define getnews(n, p) ef_read(EF_NEWS, (n), (p)) +#define putnews(n, p) ef_write(EF_NEWS, (n), (p)) +#define getnewsp(n) (struct nwsstr *)ef_ptr(EF_NEWS, (n)) extern struct rptstr rpt[N_MAX_VERB + 2]; extern struct symbol page_headings[N_MAX_PAGE + 2]; diff --git a/include/nuke.h b/include/nuke.h index 054c3480..84881676 100644 --- a/include/nuke.h +++ b/include/nuke.h @@ -69,12 +69,9 @@ struct nchrstr { #define N_NEUT bit(0) /* Neutron bomb (low damage, high fallout) */ -#define getnuke(n, p) \ - ef_read(EF_NUKE, n, p) -#define putnuke(n, p) \ - ef_write(EF_NUKE, n, p) -#define getnukep(n) \ - (struct nukstr *) ef_ptr(EF_NUKE, n) +#define getnuke(n, p) ef_read(EF_NUKE, (n), (p)) +#define putnuke(n, p) ef_write(EF_NUKE, (n), (p)) +#define getnukep(n) (struct nukstr *)ef_ptr(EF_NUKE, (n)) /* Work required for building */ #define NUK_BLD_WORK(lcm, hcm, oil, rad) \ diff --git a/include/plane.h b/include/plane.h index 5b573afa..4f479283 100644 --- a/include/plane.h +++ b/include/plane.h @@ -137,12 +137,9 @@ struct plist { struct plnstr plane; /* struct plane */ }; -#define getplane(n, p) \ - ef_read(EF_PLANE, n, p) -#define putplane(n, p) \ - ef_write(EF_PLANE, n, p) -#define getplanep(n) \ - (struct plnstr *) ef_ptr(EF_PLANE, n) +#define getplane(n, p) ef_read(EF_PLANE, (n), (p)) +#define putplane(n, p) ef_write(EF_PLANE, (n), (p)) +#define getplanep(n) (struct plnstr *)ef_ptr(EF_PLANE, (n)) extern struct plchrstr plchr[N_MAXPLANE + 1]; diff --git a/include/power.h b/include/power.h index d24302c0..f369b87c 100644 --- a/include/power.h +++ b/include/power.h @@ -55,11 +55,8 @@ struct powstr { float p_power; }; -#define getpower(n, p) \ - ef_read(EF_POWER, n, p) -#define putpower(n, p) \ - ef_write(EF_POWER, n, p) -#define getpowerp(n) \ - (struct powstr *) ef_ptr(EF_POWER, n) +#define getpower(n, p) ef_read(EF_POWER, (n), (p)) +#define putpower(n, p) ef_write(EF_POWER, (n), (p)) +#define getpowerp(n) (struct powstr *)ef_ptr(EF_POWER, (n)) #endif diff --git a/include/sect.h b/include/sect.h index 5a46c090..58f54775 100644 --- a/include/sect.h +++ b/include/sect.h @@ -155,21 +155,17 @@ struct dchrstr { #define SCT_EFFIC 34 /* used in update & budget */ #define SCT_MAXDEF 34 /* highest sector type in header files */ -#define getsect(x, y, p) \ - ef_read(EF_SECTOR, sctoff((x), (y)), (p)) -#define putsect(p) \ - ef_write(EF_SECTOR, sctoff((p)->sct_x, (p)->sct_y), (p)) -#define getsectp(x, y) \ - (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y))) -#define getsectid(id) \ - (struct sctstr *)ef_ptr(EF_SECTOR, id) +#define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p)) +#define putsect(p) ef_write(EF_SECTOR, sctoff((p)->sct_x, (p)->sct_y), (p)) +#define getsectp(x, y) (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y))) +#define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id)) /* things relating to sectors */ extern int sctoff(coord x, coord y); extern struct dchrstr dchr[SCT_MAXDEF + 1]; extern struct dchrstr bigcity_dchr; -#define IS_BIG_CITY(sect) (dchr[sect].d_pkg == UPKG) +#define IS_BIG_CITY(sect) (dchr[(sect)].d_pkg == UPKG) /* Minimal efficiency of sectors that can be knocked down (bridges) */ #define SCT_MINEFF 20 diff --git a/include/ship.h b/include/ship.h index feb6526a..794e6e42 100644 --- a/include/ship.h +++ b/include/ship.h @@ -178,12 +178,9 @@ struct mchrstr { #define M_CANAL bit(19) /* Can navigate a canal (BIG CITY) */ #define M_ANTIMISSILE bit(20) /* Shoot down missile */ -#define getship(n, p) \ - ef_read(EF_SHIP, n, p) -#define putship(n, p) \ - ef_write(EF_SHIP, n, p) -#define getshipp(n) \ - (struct shpstr *) ef_ptr(EF_SHIP, n) +#define getship(n, p) ef_read(EF_SHIP, (n), (p)) +#define putship(n, p) ef_write(EF_SHIP, (n), (p)) +#define getshipp(n) (struct shpstr *)ef_ptr(EF_SHIP, (n)) extern struct mchrstr mchr[N_MAXSHIPS + 1]; diff --git a/include/trade.h b/include/trade.h index 5739c5bf..63e8d272 100644 --- a/include/trade.h +++ b/include/trade.h @@ -71,11 +71,8 @@ extern int trade_desc(struct trdstr *, union trdgenstr *); extern int trade_getitem(struct trdstr *, union trdgenstr *); extern long get_couval(int); -#define gettrade(n, p) \ - ef_read(EF_TRADE, n, p) -#define puttrade(n, p) \ - ef_write(EF_TRADE, n, p) -#define gettradep(n) \ - (struct trdstr *) ef_ptr(EF_TRADE, n) +#define gettrade(n, p) ef_read(EF_TRADE, (n), (p)) +#define puttrade(n, p) ef_write(EF_TRADE, (n), (p)) +#define gettradep(n) (struct trdstr *)ef_ptr(EF_TRADE, (n)) #endif diff --git a/include/treaty.h b/include/treaty.h index d5fc5997..7d00ab17 100644 --- a/include/treaty.h +++ b/include/treaty.h @@ -64,11 +64,8 @@ struct trtstr { #define TRTENL bit(9) /* no enlistment */ #define SUBFIR bit(10) /* no depth-charging submarines */ -#define gettre(n, p) \ - ef_read(EF_TREATY, n, p) -#define puttre(n, p) \ - ef_write(EF_TREATY, n, p) -#define gettrep(n) \ - (struct trtstr *) ef_ptr(EF_TREATY, n) +#define gettre(n, p) ef_read(EF_TREATY, (n), (p)) +#define puttre(n, p) ef_write(EF_TREATY, (n), (p)) +#define gettrep(n) (struct trtstr *)ef_ptr(EF_TREATY, (n)) #endif diff --git a/src/lib/common/bestpath.c b/src/lib/common/bestpath.c index 0fc2fafb..b708e512 100644 --- a/src/lib/common/bestpath.c +++ b/src/lib/common/bestpath.c @@ -56,7 +56,7 @@ static int owned_and_navigable(char *, int, int, int); #define MAXROUTE 100 -#define valid(x,y) (((x^y)&1)==0) +#define valid(x,y) ((((x) ^ (y)) & 1) == 0) static char *dirchar = "juygbn"; int dx[6] = { 2, 1, -1, -2, -1, 1 };