Coding style fixes, mostly indentation and whitespace
This commit is contained in:
parent
8a0d117d45
commit
373651359e
47 changed files with 131 additions and 130 deletions
|
@ -49,22 +49,22 @@ enum {
|
|||
};
|
||||
|
||||
typedef enum {
|
||||
I_NONE = -1,
|
||||
I_CIVIL,
|
||||
I_MILIT,
|
||||
I_SHELL,
|
||||
I_GUN,
|
||||
I_PETROL,
|
||||
I_IRON,
|
||||
I_DUST,
|
||||
I_BAR,
|
||||
I_FOOD,
|
||||
I_OIL,
|
||||
I_LCM,
|
||||
I_HCM,
|
||||
I_UW,
|
||||
I_RAD,
|
||||
I_MAX = I_RAD
|
||||
I_NONE = -1,
|
||||
I_CIVIL,
|
||||
I_MILIT,
|
||||
I_SHELL,
|
||||
I_GUN,
|
||||
I_PETROL,
|
||||
I_IRON,
|
||||
I_DUST,
|
||||
I_BAR,
|
||||
I_FOOD,
|
||||
I_OIL,
|
||||
I_LCM,
|
||||
I_HCM,
|
||||
I_UW,
|
||||
I_RAD,
|
||||
I_MAX = I_RAD
|
||||
} ATTRIBUTE((packed)) i_type;
|
||||
|
||||
struct ichrstr {
|
||||
|
|
|
@ -192,7 +192,7 @@ extern int lnd_hardtarget(struct lndstr *);
|
|||
extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
|
||||
extern int lnd_support(natid, natid, coord, coord, int);
|
||||
extern int lnd_can_attack(struct lndstr *);
|
||||
extern int lnd_fortify (struct lndstr *lp, int hard_amt);
|
||||
extern int lnd_fortify(struct lndstr *lp, int hard_amt);
|
||||
extern void lnd_set_tech(struct lndstr *, int);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ struct loststr {
|
|||
natid lost_owner; /* Who lost it */
|
||||
/* end of part matching struct empobj */
|
||||
short lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
|
||||
int lost_id; /* uid of lost thing (0 for sector)*/
|
||||
int lost_id; /* uid of lost thing (0 for sector) */
|
||||
coord lost_x;
|
||||
coord lost_y;
|
||||
};
|
||||
|
|
|
@ -61,17 +61,17 @@ struct lwpProc *lwpCreate(int prio, void (*)(void *), int size,
|
|||
int flags, char *name,
|
||||
int argc, char **argv, void *ud);
|
||||
void lwpExit(void);
|
||||
void lwpTerminate(struct lwpProc * p);
|
||||
void lwpTerminate(struct lwpProc *);
|
||||
void lwpYield(void);
|
||||
int lwpSleepFd(int fd, int flags, struct timeval *timeout);
|
||||
int lwpSleepUntil(time_t until);
|
||||
void lwpWakeup(struct lwpProc *);
|
||||
int lwpSigWait(sigset_t *set, int *sig);
|
||||
void *lwpGetUD(struct lwpProc * p);
|
||||
void lwpSetUD(struct lwpProc * p, char *ud);
|
||||
void *lwpGetUD(struct lwpProc *);
|
||||
void lwpSetUD(struct lwpProc *, char *ud);
|
||||
int lwpSetPriority(int prio);
|
||||
char *lwpName(struct lwpProc * p);
|
||||
void lwpSetName(struct lwpProc * p, char *name);
|
||||
char *lwpName(struct lwpProc *);
|
||||
void lwpSetName(struct lwpProc *, char *name);
|
||||
|
||||
struct lwp_rwlock *lwp_rwlock_create(char *);
|
||||
void lwp_rwlock_destroy(struct lwp_rwlock *);
|
||||
|
|
|
@ -183,7 +183,7 @@ extern int influx(struct natstr *np);
|
|||
extern struct natstr *nat_reset(struct natstr *, enum nat_status, coord, coord);
|
||||
extern int check_nat_name(char *cname);
|
||||
|
||||
extern int grant_btus(struct natstr *, int );
|
||||
extern int grant_btus(struct natstr *, int);
|
||||
|
||||
/* nation flags */
|
||||
#define NF_INFORM bit(0) /* Inform me of telegrams right away */
|
||||
|
|
|
@ -286,7 +286,7 @@ extern struct symbol sector_navigation[];
|
|||
|
||||
/* src/lib/subs/nstr.c */
|
||||
extern int nstr_comp(struct nscstr *np, int len, int type, char *str);
|
||||
extern char *nstr_comp_val(char *, struct valstr*, int);
|
||||
extern char *nstr_comp_val(char *, struct valstr *, int);
|
||||
extern int nstr_exec(struct nscstr *, int, void *);
|
||||
/* src/lib/common/nstreval.c */
|
||||
extern struct valstr *nstr_mksymval(struct valstr *, struct castr *, int);
|
||||
|
|
|
@ -112,7 +112,7 @@ servercmd(int code, char *arg, int len)
|
|||
break;
|
||||
case C_INFORM:
|
||||
if (arg[0] != '\n') {
|
||||
snprintf(teles, sizeof(teles), "(%.*s) ", len -1, arg);
|
||||
snprintf(teles, sizeof(teles), "(%.*s) ", len - 1, arg);
|
||||
if (!redir_fp) {
|
||||
putchar('\07');
|
||||
prompt(code, the_prompt, teles);
|
||||
|
|
|
@ -85,9 +85,9 @@ cens(void)
|
|||
n = sect.sct_dist[I_FOOD] % 1000;
|
||||
pr("%c ", n == 0 ? '.' : '0' + (n / 100));
|
||||
if (sect.sct_own != sect.sct_oldown)
|
||||
pr("%3d", sect.sct_oldown);
|
||||
pr("%3d", sect.sct_oldown);
|
||||
else
|
||||
pr(" ");
|
||||
pr(" ");
|
||||
|
||||
pr("%5d", sect.sct_item[I_CIVIL]);
|
||||
pr("%5d", sect.sct_item[I_MILIT]);
|
||||
|
|
|
@ -386,7 +386,7 @@ pr_ship(struct shpstr *ship)
|
|||
pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
|
||||
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
|
||||
ship->shp_rpath, ship->shp_rflags);
|
||||
pr("Plague Stage <a>: %d\t\t",ship->shp_pstage);
|
||||
pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
|
||||
pr("Plague Time <b>: %d\n", ship->shp_ptime);
|
||||
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
|
||||
pr(" c m u f s g p i d o l h r\n");
|
||||
|
|
|
@ -82,7 +82,7 @@ fort(void)
|
|||
if (hard_amt <= 0)
|
||||
continue;
|
||||
|
||||
if (lnd_fortify (&land, hard_amt) <= 0) {
|
||||
if (lnd_fortify(&land, hard_amt) <= 0) {
|
||||
pr("%s can't be fortified%s\n", prland(&land),
|
||||
land.lnd_harden >= land_mob_max ? " any further" : "");
|
||||
continue;
|
||||
|
|
|
@ -320,7 +320,7 @@ info(void)
|
|||
default:
|
||||
pr("Error reading info dir\n");
|
||||
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
|
||||
GetLastError(), infodir, filename);
|
||||
GetLastError(), infodir, filename);
|
||||
}
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ apro(void)
|
|||
lhitlim = 100;
|
||||
}
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s\\*",infodir);
|
||||
snprintf(filename, sizeof(filename), "%s\\*", infodir);
|
||||
hDir = FindFirstFile(filename, &fData);
|
||||
if (hDir == INVALID_HANDLE_VALUE) {
|
||||
if (GetLastError() == ERROR_PATH_NOT_FOUND) {
|
||||
|
@ -421,7 +421,7 @@ apro(void)
|
|||
} else {
|
||||
pr("Error reading info dir\n");
|
||||
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
|
||||
GetLastError(), infodir, filename);
|
||||
GetLastError(), infodir, filename);
|
||||
}
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ apro(void)
|
|||
(fData.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE) ||
|
||||
(fData.dwFileAttributes == FILE_ATTRIBUTE_READONLY))) {
|
||||
snprintf(filename, sizeof(filename), "%s\\%s", infodir,
|
||||
fData.cFileName);
|
||||
fData.cFileName);
|
||||
fp = fopen(filename, "rb");
|
||||
alreadyhit = 0;
|
||||
nll = nlhl = 0;
|
||||
|
|
|
@ -109,7 +109,7 @@ landmine(void)
|
|||
continue;
|
||||
if (land.lnd_ship >= 0 || land.lnd_land >= 0) {
|
||||
pr("%s is on a %s\n", prland(&land),
|
||||
land. lnd_ship >= 0 ? "ship" : "land unit");
|
||||
land.lnd_ship >= 0 ? "ship" : "land unit");
|
||||
continue;
|
||||
}
|
||||
if (land.lnd_mobil < 1) {
|
||||
|
|
|
@ -125,8 +125,8 @@ do_unit_move(struct emp_qelem *ulist, int *together,
|
|||
}
|
||||
if (!skip)
|
||||
nav_map(leader->x, leader->y,
|
||||
type == EF_SHIP ?
|
||||
!(mchr[(int)leader->type].m_flags & M_SUB) : 1);
|
||||
type == EF_SHIP
|
||||
? !(mchr[(int)leader->type].m_flags & M_SUB) : 1);
|
||||
else
|
||||
skip = 0;
|
||||
sprintf(prompt, "<%.1f:%.1f: %s> ", *maxmob,
|
||||
|
@ -171,7 +171,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
|
|||
if (dir >= 0) {
|
||||
if (type == EF_SHIP) {
|
||||
stopping |= shp_nav_one_sector(ulist, dir,
|
||||
player->cnum, *together);
|
||||
player->cnum, *together);
|
||||
if (stopping != 2) {
|
||||
*pt++ = dirch[dir];
|
||||
*pt = '\0';
|
||||
|
@ -179,7 +179,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
|
|||
} else
|
||||
stopping |=
|
||||
lnd_mar_one_sector(ulist, dir, player->cnum,
|
||||
*together);
|
||||
*together);
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ para(void)
|
|||
pr("range to target is %d\n", ap_to_target);
|
||||
if (target.sct_own == player->cnum) {
|
||||
pr("You can't air-assault your own sector!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
return RET_FAIL;
|
||||
}
|
||||
/*
|
||||
* select planes within range
|
||||
*/
|
||||
|
|
|
@ -264,7 +264,7 @@ pdump(void)
|
|||
case 19:
|
||||
pr(pln_is_in_orbit(&plane)
|
||||
&& (plane.pln_flags & PLN_SYNCHRONOUS)
|
||||
? " Y" : " N");
|
||||
? " Y" : " N");
|
||||
break;
|
||||
case 20:
|
||||
if (getnuke(nuk_on_plane(&plane), &nuke)) {
|
||||
|
|
|
@ -102,7 +102,7 @@ radar(int type)
|
|||
if (mchr[(int)item.ship.shp_type].m_flags & M_SONAR)
|
||||
tf = techfact(item.ship.shp_tech, 1.0);
|
||||
tech = techfact(item.ship.shp_tech,
|
||||
mchr[(int)item.ship.shp_type].m_vrnge);
|
||||
mchr[(int)item.ship.shp_type].m_vrnge);
|
||||
} else {
|
||||
if (!(lchr[(int)item.land.lnd_type].l_flags & L_RADAR)) {
|
||||
pr("%s can't use radar!\n", prland(&item.land));
|
||||
|
|
|
@ -58,7 +58,7 @@ swaps(void)
|
|||
!getsect(sectb.sct_x, sectb.sct_y, §b))
|
||||
return RET_SYN;
|
||||
print_res(§b);
|
||||
if (!confirm ("Are you sure these are the two sectors you wish to swap? "))
|
||||
if (!confirm("Are you sure these are the two sectors you wish to swap? "))
|
||||
return RET_FAIL;
|
||||
if (!check_sect_ok(§a) || !check_sect_ok(§b))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -403,7 +403,7 @@ check_trade(void)
|
|||
"The bidding is over & you bought %s #%d from %s for $%.2f\n",
|
||||
trade_nameof(&trade, &tg), saveid, cname(trade.trd_owner),
|
||||
price);
|
||||
}
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -255,4 +255,3 @@ tran_nmap(coord curx, coord cury, char *arg)
|
|||
{
|
||||
return display_region_map(0, EF_NUKE, curx, cury, arg);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#include "ship.h"
|
||||
|
||||
enum {
|
||||
UPGR_COST = 15, /* how much avail and money to charge */
|
||||
UPGR_EFF = 35 /* efficiency reduction */
|
||||
UPGR_COST = 15, /* how much avail and money to charge */
|
||||
UPGR_EFF = 35 /* efficiency reduction */
|
||||
};
|
||||
|
||||
static int lupgr(void);
|
||||
|
|
|
@ -201,7 +201,7 @@ vers(void)
|
|||
pr("Fallout decays by %.0f%% per update\n",
|
||||
100.0 - (decay_per_etu + 6.0) * fallout_spread * MIN(24, etu_per_update) * 100.0);
|
||||
pr("\n");
|
||||
pr ("Damage to\t\t\tSpills to\n");
|
||||
pr("Damage to\t\t\tSpills to\n");
|
||||
pr("\t Sector People Mater. Ships Planes LandU.\n");
|
||||
pr("Sector\t\t --\t%3.0f%%\t100%%\t 0%%\t%3.0f%%\t%3.0f%%\n",
|
||||
people_damage * 100.0, unit_damage / 0.07, unit_damage * 100.0);
|
||||
|
|
|
@ -81,7 +81,7 @@ zdon(void)
|
|||
if (*p == 'y' || *p == 'Y') {
|
||||
checking = 0;
|
||||
wantupd = 1;
|
||||
} else if (*p == 'n' || *p == 'N') {
|
||||
} else if (*p == 'n' || *p == 'N') {
|
||||
checking = 0;
|
||||
wantupd = 0;
|
||||
} else {
|
||||
|
|
|
@ -117,7 +117,8 @@ weekday(char *str, int *wday)
|
|||
*/
|
||||
static char *day_name[7] = {
|
||||
"sunday", "monday", "tuesday", "wednesday",
|
||||
"thursday", "friday", "saturday" };
|
||||
"thursday", "friday", "saturday"
|
||||
};
|
||||
int i, j;
|
||||
|
||||
for (; isspace(*str); ++str) ;
|
||||
|
|
|
@ -211,21 +211,21 @@ struct castr dchr_ca[] = {
|
|||
};
|
||||
|
||||
#define NSC_GENITEM(ef_type, ef_chr) \
|
||||
{"uid", empobjoff(uid), NSC_INT, 0, NULL, ef_type, 0}, \
|
||||
{"uid", empobjoff(uid), NSC_INT, 0, NULL, ef_type, 0}, \
|
||||
{"timestamp", empobjoff(timestamp), NSC_TIME, 0, NULL, EF_BAD, NSC_EXTRA}, \
|
||||
{"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0}, \
|
||||
{"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"type", empobjoff(type), NSC_CHAR, 0, NULL, ef_chr, 0}, \
|
||||
{"effic", empobjoff(effic), NSC_CHAR, 0, NULL, EF_BAD, 0}, \
|
||||
{"mobil", empobjoff(mobil), NSC_CHAR , 0, NULL, EF_BAD, 0}, \
|
||||
{"off", empobjoff(off), NSC_UCHAR , 0, NULL, EF_BAD, 0}, \
|
||||
{"tech", empobjoff(tech), NSC_SHORT, 0, NULL, EF_BAD, 0}, \
|
||||
{"group", empobjoff(group), NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \
|
||||
{"opx", empobjoff(opx), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"opy", empobjoff(opy), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"mission", empobjoff(mission), NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \
|
||||
{"radius", empobjoff(radius), NSC_SHORT, 0, NULL, EF_BAD, 0}
|
||||
{"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0}, \
|
||||
{"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"type", empobjoff(type), NSC_CHAR, 0, NULL, ef_chr, 0}, \
|
||||
{"effic", empobjoff(effic), NSC_CHAR, 0, NULL, EF_BAD, 0}, \
|
||||
{"mobil", empobjoff(mobil), NSC_CHAR , 0, NULL, EF_BAD, 0}, \
|
||||
{"off", empobjoff(off), NSC_UCHAR , 0, NULL, EF_BAD, 0}, \
|
||||
{"tech", empobjoff(tech), NSC_SHORT, 0, NULL, EF_BAD, 0}, \
|
||||
{"group", empobjoff(group), NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \
|
||||
{"opx", empobjoff(opx), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"opy", empobjoff(opy), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \
|
||||
{"mission", empobjoff(mission), NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \
|
||||
{"radius", empobjoff(radius), NSC_SHORT, 0, NULL, EF_BAD, 0}
|
||||
|
||||
struct castr ship_ca[] = {
|
||||
#define CURSTR struct shpstr
|
||||
|
@ -482,7 +482,7 @@ struct castr news_ca[] = {
|
|||
|
||||
struct castr lost_ca[] = {
|
||||
#define CURSTR struct loststr
|
||||
/* 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 */
|
||||
{"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL,
|
||||
EF_BAD, 0},
|
||||
{"owner", fldoff(lost_owner), NSC_NATID, 0, NULL, EF_NATION, 0},
|
||||
|
|
|
@ -84,7 +84,9 @@ mineq(char *a, char *b)
|
|||
/* find common prefix: */
|
||||
for (i = 0; a[i] != 0 && a[i] == b[i]; i++) ;
|
||||
|
||||
if (a[i] != 0) return ME_MISMATCH;
|
||||
if (b[i] == 0 || b[i] == ' ') return ME_EXACT;
|
||||
if (a[i] != 0)
|
||||
return ME_MISMATCH;
|
||||
if (b[i] == 0 || b[i] == ' ')
|
||||
return ME_EXACT;
|
||||
return ME_PARTIAL;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ xdcolhdr(struct xdstr *xd, struct castr ca[])
|
|||
n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0;
|
||||
if (n) {
|
||||
for (j = 0; j < n; j++) {
|
||||
xd->pr("%s%s(%d)",sep, ca[i].ca_name, j);
|
||||
xd->pr("%s%s(%d)", sep, ca[i].ca_name, j);
|
||||
sep = " ";
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -349,7 +349,7 @@ deffld(int fldno, char *name, int idx)
|
|||
int res;
|
||||
|
||||
res = stmtch(name, ca, offsetof(struct castr, ca_name),
|
||||
sizeof(struct castr));
|
||||
sizeof(struct castr));
|
||||
if (res < 0)
|
||||
return gripe("Header %s of field %d is %s", name, fldno + 1,
|
||||
res == M_NOTUNIQUE ? "ambiguous" : "unknown");
|
||||
|
@ -851,7 +851,7 @@ xufooter(FILE *fp, struct castr ca[], int recs)
|
|||
|
||||
res = -1;
|
||||
if (human) {
|
||||
if (fscanf(fp, "config%n", &res) != 0 || res < 0)
|
||||
if (fscanf(fp, "config%n", &res) != 0 || res < 0)
|
||||
return gripe("Malformed table footer");
|
||||
} else {
|
||||
if (fscanf(fp, "%d", &n) != 1)
|
||||
|
|
|
@ -439,7 +439,7 @@ empth_rwlock_wrlock(empth_rwlock_t *rwlock)
|
|||
empth_status("waiting for wrlock %s", rwlock->name);
|
||||
pthread_cond_wait(&rwlock->can_write, &mtx_ctxsw);
|
||||
empth_status("got wrlock %s %d %d",
|
||||
rwlock->name, rwlock->nread, rwlock->nwrite);
|
||||
rwlock->name, rwlock->nread, rwlock->nwrite);
|
||||
empth_restorectx();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,5 +64,5 @@ signed char dirindex[] = {
|
|||
|
||||
/* must agree with dirch[] and DIR_ defines */
|
||||
char *routech[] = {
|
||||
" ", " /", " >"," \\","/ ","< ","\\ "
|
||||
" ", " /", " >", " \\", "/ ", "< ", "\\ "
|
||||
};
|
||||
|
|
|
@ -87,7 +87,7 @@ struct symbol meta_flags[] = {
|
|||
{0, NULL}
|
||||
};
|
||||
|
||||
struct symbol meta_type[] = {
|
||||
struct symbol meta_type[] = {
|
||||
{NSC_LONG, "d"},
|
||||
{NSC_DOUBLE, "g"},
|
||||
{NSC_STRING, "s"},
|
||||
|
@ -101,7 +101,7 @@ struct symbol meta_type[] = {
|
|||
{NSC_HIDDEN, "d"},
|
||||
{NSC_TIME, "d"},
|
||||
{NSC_FLOAT, "g"},
|
||||
{NSC_STRINGY,"c"},
|
||||
{NSC_STRINGY, "c"},
|
||||
{NSC_NOTYPE, NULL}
|
||||
};
|
||||
|
||||
|
@ -150,7 +150,7 @@ struct symbol nation_relations[] = {
|
|||
|
||||
struct symbol nation_status[] = {
|
||||
{STAT_UNUSED, "unused"},
|
||||
{STAT_NEW, "new"},
|
||||
{STAT_NEW, "new"},
|
||||
{STAT_VIS, "visitor"},
|
||||
{STAT_SANCT, "sanctuary"},
|
||||
{STAT_ACTIVE, "active"},
|
||||
|
|
|
@ -76,10 +76,10 @@ player_new(int s)
|
|||
|
||||
lp = malloc(sizeof(struct player));
|
||||
if (!lp)
|
||||
return NULL;
|
||||
return NULL;
|
||||
memset(lp, 0, sizeof(struct player));
|
||||
idle_timeout.tv_sec = max_idle * 60;
|
||||
idle_timeout.tv_usec = 0 ;
|
||||
idle_timeout.tv_usec = 0;
|
||||
if (s >= 0) {
|
||||
/* real player, not dummy created by update and market update */
|
||||
lp->iop = io_open(s, IO_READ | IO_WRITE, IO_BUFSIZE, idle_timeout);
|
||||
|
|
|
@ -167,7 +167,7 @@ disable_coms(void)
|
|||
cmd = comtch(name, player_coms, -1);
|
||||
if (cmd < 0) {
|
||||
logerror("Warning: not disabling %s command %s\n",
|
||||
cmd == M_NOTUNIQUE ? "ambiguous" : "unknown", name);
|
||||
cmd == M_NOTUNIQUE ? "ambiguous" : "unknown", name);
|
||||
continue;
|
||||
}
|
||||
player_coms[cmd].c_permit |= GOD;
|
||||
|
@ -219,7 +219,7 @@ update_timeused(time_t now)
|
|||
void
|
||||
enforce_minimum_session_time(void)
|
||||
{
|
||||
struct natstr *natp = getnatp(player->cnum);
|
||||
struct natstr *natp = getnatp(player->cnum);
|
||||
|
||||
time_t dt = natp->nat_last_logout - natp->nat_last_login;
|
||||
if (dt > seconds_since_midnight(natp->nat_last_logout))
|
||||
|
|
|
@ -101,7 +101,7 @@ struct cmndstr player_coms[] = {
|
|||
0, edit, C_MOD, GOD},
|
||||
{"enable", 0, enab, C_MOD, GOD},
|
||||
{"enlist <SECTS> <NUM>", 2, enli, C_MOD, NORM + MONEY + CAP},
|
||||
{"execute <INPUT FILE>", 0, execute, 0, VIS + EXEC },
|
||||
{"execute <INPUT FILE>", 0, execute, 0, VIS + EXEC},
|
||||
{"explore <c|m> <SECT> <NUM> <PATH|DESTINATION>",
|
||||
1, explore, C_MOD, NORM + MONEY + CAP},
|
||||
{"financial", 0, fina, 0, NORM},
|
||||
|
|
|
@ -508,7 +508,7 @@ perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
|
|||
}
|
||||
if (mcp->m_flags & M_SUB) {
|
||||
if (!targeting_ships)
|
||||
return dam; /* subs interdict only ships */
|
||||
return dam; /* subs interdict only ships */
|
||||
range = roundrange(torprange(sp));
|
||||
if (md > range)
|
||||
return dam;
|
||||
|
|
|
@ -199,8 +199,10 @@ static int
|
|||
strnncmp(char *s1, size_t sz1, char *s2, size_t sz2)
|
||||
{
|
||||
int res;
|
||||
if (sz1 == sz2) return strncmp(s1, s2, sz2);
|
||||
if (sz1 < sz2) return -strnncmp(s2, sz2, s1, sz1);
|
||||
if (sz1 == sz2)
|
||||
return strncmp(s1, s2, sz2);
|
||||
if (sz1 < sz2)
|
||||
return -strnncmp(s2, sz2, s1, sz1);
|
||||
res = strncmp(s1, s2, sz2);
|
||||
return res ? res : s1[sz2];
|
||||
}
|
||||
|
@ -278,7 +280,8 @@ nstr_parse_val(char *str, struct valstr *val)
|
|||
val->val_cat = NSC_VAL;
|
||||
val->val_as.str.base = str + 1;
|
||||
val->val_as.str.maxsz = tail - (str + 1);
|
||||
if (*tail) ++tail;
|
||||
if (*tail)
|
||||
++tail;
|
||||
/* FIXME else unclosed string */
|
||||
return tail;
|
||||
}
|
||||
|
@ -353,7 +356,7 @@ static int
|
|||
nstr_is_name_of_ca(struct valstr *val, struct castr *ca, int idx)
|
||||
{
|
||||
if (CANT_HAPPEN(val->val_cat != NSC_ID && idx >= 0))
|
||||
return 0;
|
||||
return 0;
|
||||
return idx >= 0 && strlen(ca[idx].ca_name) == val->val_as.str.maxsz;
|
||||
}
|
||||
|
||||
|
@ -487,11 +490,11 @@ nstr_optype(enum nsc_type lft, enum nsc_type rgt)
|
|||
lft = nstr_promote(lft);
|
||||
rgt = nstr_promote(rgt);
|
||||
if (lft == rgt)
|
||||
return lft;
|
||||
return lft;
|
||||
if (lft == NSC_DOUBLE && rgt == NSC_LONG)
|
||||
return NSC_DOUBLE;
|
||||
return NSC_DOUBLE;
|
||||
if (rgt == NSC_DOUBLE && lft == NSC_LONG)
|
||||
return NSC_DOUBLE;
|
||||
return NSC_DOUBLE;
|
||||
return NSC_NOTYPE;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
|
|||
|
||||
getsect(x, y, §);
|
||||
|
||||
more:
|
||||
more:
|
||||
while (*p) {
|
||||
if (sarg_xy(p, &dx, &dy)) {
|
||||
bp = NULL;
|
||||
|
|
|
@ -544,7 +544,7 @@ copy_ascii_no_funny(char *dst, char *src)
|
|||
if ((ch < 0x20 && ch != '\t' && ch != '\n') || ch == 0x7f)
|
||||
; /* ignore funny control */
|
||||
else if (ch > 0x7f)
|
||||
*p++ = '?'; /* replace non-ASCII */
|
||||
*p++ = '?'; /* replace non-ASCII */
|
||||
else
|
||||
*p++ = ch;
|
||||
}
|
||||
|
@ -619,8 +619,7 @@ ufindpfx(char *s, int n)
|
|||
{
|
||||
int i = 0;
|
||||
|
||||
while (n && s[i])
|
||||
{
|
||||
while (n && s[i]) {
|
||||
if ((s[i++] & 0xc0) == 0xc0)
|
||||
while ((s[i] & 0xc0) == 0x80)
|
||||
i++;
|
||||
|
|
|
@ -85,7 +85,7 @@ sarg_xy(char *str, coord *xp, coord *yp)
|
|||
return 0;
|
||||
y = strtoy(str, &str);
|
||||
if (y < 0 || (*str != 0 && !isspace(*str)))
|
||||
return 0;
|
||||
return 0;
|
||||
if ((x ^ y) & 1)
|
||||
return 0;
|
||||
np = getnatp(player->cnum);
|
||||
|
|
|
@ -605,7 +605,7 @@ show_news(int tlev)
|
|||
if (rpt[i].r_newspage == N_NOTUSED)
|
||||
continue;
|
||||
pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
|
||||
page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
|
||||
page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
|
||||
for (j = 0; j < NUM_RPTS; j++)
|
||||
pr(" %s\n", rpt[i].r_newstory[j]);
|
||||
}
|
||||
|
@ -686,12 +686,12 @@ fmttime2822(time_t t)
|
|||
(time->tm_isdst ? tzi.DaylightBias : tzi.StandardBias));
|
||||
|
||||
nn = _snprintf(buf + n, sizeof(buf) - n, " %+03d%02d",
|
||||
time_offset/60, abs(time_offset) % 60);
|
||||
time_offset / 60, abs(time_offset) % 60);
|
||||
if (CANT_HAPPEN(nn <= 0 || nn + n >= sizeof(buf)))
|
||||
buf[0] = 0;
|
||||
#else
|
||||
size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
|
||||
localtime(&t));
|
||||
localtime(&t));
|
||||
if (CANT_HAPPEN(n == 0))
|
||||
buf[0] = 0;
|
||||
#endif
|
||||
|
|
|
@ -627,8 +627,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
|
|||
mpr(victim, "Incoming fire does %d damage!\n", dam);
|
||||
#if 0
|
||||
mpr(victim, "%s fires at you for %d!\n",
|
||||
xyas(fsect.sct_x,fsect.sct_y,victim),
|
||||
dam);
|
||||
xyas(fsect.sct_x, fsect.sct_y, victim), dam);
|
||||
#endif
|
||||
wu(0, fsect.sct_own,
|
||||
"%s fires at %s ships in %s for %d!\n",
|
||||
|
|
|
@ -161,7 +161,7 @@ unit_path(int together, struct empobj *unit, char *buf)
|
|||
d_sect.sct_x, d_sect.sct_y, player->cnum);
|
||||
if (!cp || unit->mobil <= 0) {
|
||||
pr("Can't get to '%s' right now.\n",
|
||||
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
|
||||
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -201,8 +201,8 @@ unit_view(struct emp_qelem *list)
|
|||
pr("[oil:%d] ", sect.sct_oil);
|
||||
}
|
||||
pr("%s @ %s %d%% %s\n", obj_nameof(&ulp->unit.gen),
|
||||
xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
|
||||
sect.sct_effic, dchr[sect.sct_type].d_name);
|
||||
xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
|
||||
sect.sct_effic, dchr[sect.sct_type].d_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ deliver(struct sctstr *from, struct ichrstr *ip, int dir,
|
|||
int thresh, int amt_src, int plague, enum i_packing packing)
|
||||
{
|
||||
struct sctstr *to;
|
||||
i_type vtype; /* item vartype */
|
||||
i_type vtype; /* item vartype */
|
||||
int amt_moved;
|
||||
int amt_dst;
|
||||
int mobility;
|
||||
|
|
|
@ -183,8 +183,8 @@ planerepair(struct plnstr *pp, struct natstr *np, struct bp *bp, int etus)
|
|||
delta = 100 - pp->pln_effic;
|
||||
|
||||
memset(mvec, 0, sizeof(mvec));
|
||||
mvec[I_MILIT] = pcp->pl_crew;
|
||||
mvec[I_LCM] = pcp->pl_lcm;
|
||||
mvec[I_MILIT] = pcp->pl_crew;
|
||||
mvec[I_LCM] = pcp->pl_lcm;
|
||||
mvec[I_HCM] = pcp->pl_hcm;
|
||||
build = get_materials(sp, bp, mvec, delta);
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ guerrilla(struct sctstr *sp)
|
|||
uw -= n;
|
||||
sp->sct_item[I_UW] = uw;
|
||||
}
|
||||
domove:
|
||||
domove:
|
||||
if (move && che > 0) {
|
||||
struct sctstr *nicest_sp = NULL;
|
||||
if (convert)
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
|
||||
struct iovec {
|
||||
/* Base address of a memory region for input or output. */
|
||||
void *iov_base;
|
||||
void *iov_base;
|
||||
/* The size of the memory pointed to by iov_base. */
|
||||
size_t iov_len;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
extern ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
|
||||
|
|
|
@ -81,33 +81,32 @@ fd_is_socket(int fd, SOCKET *sockp)
|
|||
void
|
||||
w32_set_winsock_errno(void)
|
||||
{
|
||||
int err = WSAGetLastError();
|
||||
WSASetLastError(0);
|
||||
int err = WSAGetLastError();
|
||||
WSASetLastError(0);
|
||||
|
||||
/* Map some WSAE* errors to the runtime library's error codes. */
|
||||
switch (err)
|
||||
{
|
||||
/* Map some WSAE* errors to the runtime library's error codes. */
|
||||
switch (err) {
|
||||
case WSA_INVALID_HANDLE:
|
||||
errno = EBADF;
|
||||
break;
|
||||
errno = EBADF;
|
||||
break;
|
||||
case WSA_NOT_ENOUGH_MEMORY:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
case WSA_INVALID_PARAMETER:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
errno = EINVAL;
|
||||
break;
|
||||
case WSAEWOULDBLOCK:
|
||||
errno = EAGAIN;
|
||||
break;
|
||||
errno = EAGAIN;
|
||||
break;
|
||||
case WSAENAMETOOLONG:
|
||||
errno = ENAMETOOLONG;
|
||||
break;
|
||||
errno = ENAMETOOLONG;
|
||||
break;
|
||||
case WSAENOTEMPTY:
|
||||
errno = ENOTEMPTY;
|
||||
break;
|
||||
errno = ENOTEMPTY;
|
||||
break;
|
||||
default:
|
||||
errno = (err > 10000 && err < 10025) ? err - 10000 : err;
|
||||
break;
|
||||
errno = (err > 10000 && err < 10025) ? err - 10000 : err;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,8 +283,7 @@ fcntl(int fd, int cmd, ...)
|
|||
unsigned long nonblocking;
|
||||
SOCKET sock;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case F_GETFL:
|
||||
return 0;
|
||||
case F_SETFL:
|
||||
|
|
|
@ -1167,7 +1167,7 @@ write_newcap_script(void)
|
|||
}
|
||||
|
||||
static void
|
||||
qprint(const char * const fmt, ...)
|
||||
qprint(const char *const fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue