Clean up poorly chosen loop control variable names
Calling a counting loop's control variable q or x is tasteless bordering on actively misleading.
This commit is contained in:
parent
a2557a1dec
commit
a61e673a07
5 changed files with 47 additions and 47 deletions
|
@ -72,7 +72,7 @@ trad(void)
|
||||||
int bid;
|
int bid;
|
||||||
double tleft;
|
double tleft;
|
||||||
double tally;
|
double tally;
|
||||||
int q;
|
int i;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
if (!opt_MARKET) {
|
if (!opt_MARKET) {
|
||||||
|
@ -164,13 +164,13 @@ trad(void)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
tally = 0.0;
|
tally = 0.0;
|
||||||
for (q = 0; gettrade(q, &tmpt); q++) {
|
for (i = 0; gettrade(i, &tmpt); i++) {
|
||||||
if (tmpt.trd_maxbidder == player->cnum &&
|
if (tmpt.trd_maxbidder == player->cnum &&
|
||||||
tmpt.trd_unitid >= 0 && tmpt.trd_owner != player->cnum) {
|
tmpt.trd_unitid >= 0 && tmpt.trd_owner != player->cnum) {
|
||||||
tally += tmpt.trd_price * tradetax;
|
tally += tmpt.trd_price * tradetax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (q = 0; getcomm(q, &comt); q++) {
|
for (i = 0; getcomm(i, &comt); i++) {
|
||||||
if (comt.com_maxbidder == player->cnum &&
|
if (comt.com_maxbidder == player->cnum &&
|
||||||
comt.com_owner != 0 && comt.com_owner != player->cnum) {
|
comt.com_owner != 0 && comt.com_owner != player->cnum) {
|
||||||
tally += (comt.com_price * comt.com_amount) * buytax;
|
tally += (comt.com_price * comt.com_amount) * buytax;
|
||||||
|
|
|
@ -182,7 +182,7 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
|
||||||
struct bestp *bp = pp;
|
struct bestp *bp = pp;
|
||||||
coord x, y;
|
coord x, y;
|
||||||
coord nx, ny;
|
coord nx, ny;
|
||||||
int n = 0, q;
|
int n = 0, i;
|
||||||
struct sctstr *sp, *from, **ssp;
|
struct sctstr *sp, *from, **ssp;
|
||||||
/* Six pointers, just in case our cache isn't there */
|
/* Six pointers, just in case our cache isn't there */
|
||||||
struct sctstr *tsp[] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
struct sctstr *tsp[] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||||
|
@ -199,11 +199,11 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
|
||||||
ssp = (struct sctstr **)&tsp[0];
|
ssp = (struct sctstr **)&tsp[0];
|
||||||
else
|
else
|
||||||
ssp = (struct sctstr **)&neighsects[offset * 6];
|
ssp = (struct sctstr **)&neighsects[offset * 6];
|
||||||
for (q = 1; q <= 6; q++, ssp++) {
|
for (i = 1; i <= 6; i++, ssp++) {
|
||||||
if (*ssp == NULL) {
|
if (*ssp == NULL) {
|
||||||
/* We haven't cached this neighbor yet */
|
/* We haven't cached this neighbor yet */
|
||||||
nx = x + diroff[q][0];
|
nx = x + diroff[i][0];
|
||||||
ny = y + diroff[q][1];
|
ny = y + diroff[i][1];
|
||||||
sx = XNORM(nx);
|
sx = XNORM(nx);
|
||||||
sy = YNORM(ny);
|
sy = YNORM(ny);
|
||||||
offset = XYOFFSET(sx, sy);
|
offset = XYOFFSET(sx, sy);
|
||||||
|
|
|
@ -458,33 +458,33 @@ show_land_stats(int tlev)
|
||||||
void
|
void
|
||||||
show_sect_build(int foo)
|
show_sect_build(int foo)
|
||||||
{
|
{
|
||||||
int x, first;
|
int i, first;
|
||||||
|
|
||||||
pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
|
pr("sector type cost to des cost for 1%% eff lcms for 1%% hcms for 1%%\n");
|
||||||
for (x = 0; dchr[x].d_name; x++) {
|
for (i = 0; dchr[i].d_name; i++) {
|
||||||
if (dchr[x].d_mnem == 0)
|
if (dchr[i].d_mnem == 0)
|
||||||
continue;
|
continue;
|
||||||
if (dchr[x].d_cost < 0)
|
if (dchr[i].d_cost < 0)
|
||||||
continue;
|
continue;
|
||||||
if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
|
if ((dchr[i].d_cost > 0) || (dchr[i].d_build != 1) ||
|
||||||
(dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
|
(dchr[i].d_lcms > 0) || (dchr[i].d_hcms > 0)) {
|
||||||
pr("%-14c %-14d %-17d %-14d %d\n",
|
pr("%-14c %-14d %-17d %-14d %d\n",
|
||||||
dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
|
dchr[i].d_mnem, dchr[i].d_cost, dchr[i].d_build,
|
||||||
dchr[x].d_lcms, dchr[x].d_hcms);
|
dchr[i].d_lcms, dchr[i].d_hcms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pr("other 0 1 0 0\n");
|
pr("other 0 1 0 0\n");
|
||||||
|
|
||||||
first = 1;
|
first = 1;
|
||||||
for (x = 0; intrchr[x].in_name; x++) {
|
for (i = 0; intrchr[i].in_name; i++) {
|
||||||
if (!intrchr[x].in_enable)
|
if (!intrchr[i].in_enable)
|
||||||
continue;
|
continue;
|
||||||
if (first)
|
if (first)
|
||||||
pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
|
pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
|
||||||
" type lcms hcms mobility $$$$\n");
|
" type lcms hcms mobility $$$$\n");
|
||||||
pr("%-20s %4d %4d %8d %4d\n",
|
pr("%-20s %4d %4d %8d %4d\n",
|
||||||
intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
|
intrchr[i].in_name, intrchr[i].in_lcms, intrchr[i].in_hcms,
|
||||||
intrchr[x].in_mcost, intrchr[x].in_dcost);
|
intrchr[i].in_mcost, intrchr[i].in_dcost);
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,41 +492,41 @@ show_sect_build(int foo)
|
||||||
void
|
void
|
||||||
show_sect_stats(int foo)
|
show_sect_stats(int foo)
|
||||||
{
|
{
|
||||||
int x;
|
int i;
|
||||||
struct natstr *natp = getnatp(player->cnum);
|
struct natstr *natp = getnatp(player->cnum);
|
||||||
|
|
||||||
pr(" mob cost max max naviga packing max\n");
|
pr(" mob cost max max naviga packing max\n");
|
||||||
pr(" sector type 0%% 100%% off def bility bonus pop\n");
|
pr(" sector type 0%% 100%% off def bility bonus pop\n");
|
||||||
|
|
||||||
for (x = 0; dchr[x].d_name; x++) {
|
for (i = 0; dchr[i].d_name; i++) {
|
||||||
if (dchr[x].d_mnem == 0)
|
if (dchr[i].d_mnem == 0)
|
||||||
continue;
|
continue;
|
||||||
pr("%c %-21.21s", dchr[x].d_mnem, dchr[x].d_name);
|
pr("%c %-21.21s", dchr[i].d_mnem, dchr[i].d_name);
|
||||||
if (dchr[x].d_mob0 < 0)
|
if (dchr[i].d_mob0 < 0)
|
||||||
pr(" no way ");
|
pr(" no way ");
|
||||||
else
|
else
|
||||||
pr(" %3.1f %3.1f", dchr[x].d_mob0, dchr[x].d_mob1);
|
pr(" %3.1f %3.1f", dchr[i].d_mob0, dchr[i].d_mob1);
|
||||||
pr(" %5.2f %5.2f %7.7s %10.10s %5d\n",
|
pr(" %5.2f %5.2f %7.7s %10.10s %5d\n",
|
||||||
dchr[x].d_ostr, dchr[x].d_dstr,
|
dchr[i].d_ostr, dchr[i].d_dstr,
|
||||||
symbol_by_value(dchr[x].d_nav, sector_navigation),
|
symbol_by_value(dchr[i].d_nav, sector_navigation),
|
||||||
symbol_by_value(dchr[x].d_pkg, packing),
|
symbol_by_value(dchr[i].d_pkg, packing),
|
||||||
max_population(natp->nat_level[NAT_RLEV], x, 100));
|
max_population(natp->nat_level[NAT_RLEV], i, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
show_sect_capab(int foo)
|
show_sect_capab(int foo)
|
||||||
{
|
{
|
||||||
int x;
|
int i;
|
||||||
|
|
||||||
pr(" sector type product p.e.\n");
|
pr(" sector type product p.e.\n");
|
||||||
|
|
||||||
for (x = 0; dchr[x].d_name; x++) {
|
for (i = 0; dchr[i].d_name; i++) {
|
||||||
if (dchr[x].d_mnem == 0 || dchr[x].d_prd < 0)
|
if (dchr[i].d_mnem == 0 || dchr[i].d_prd < 0)
|
||||||
continue;
|
continue;
|
||||||
pr("%c %-23s %-7s %4d%%\n",
|
pr("%c %-23s %-7s %4d%%\n",
|
||||||
dchr[x].d_mnem, dchr[x].d_name, pchr[dchr[x].d_prd].p_sname,
|
dchr[i].d_mnem, dchr[i].d_name, pchr[dchr[i].d_prd].p_sname,
|
||||||
dchr[x].d_peffic);
|
dchr[i].d_peffic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ update_main(void)
|
||||||
{
|
{
|
||||||
int etu = etu_per_update;
|
int etu = etu_per_update;
|
||||||
int n;
|
int n;
|
||||||
int x;
|
int i;
|
||||||
struct bp *bp;
|
struct bp *bp;
|
||||||
int cn, cn2, rel;
|
int cn, cn2, rel;
|
||||||
struct natstr *cnp;
|
struct natstr *cnp;
|
||||||
|
@ -100,32 +100,32 @@ update_main(void)
|
||||||
prepare_sects(etu, bp);
|
prepare_sects(etu, bp);
|
||||||
logerror("done preparing sectors.");
|
logerror("done preparing sectors.");
|
||||||
logerror("producing for countries...");
|
logerror("producing for countries...");
|
||||||
for (x = 0; x < MAXNOC; x++) {
|
for (i = 0; i < MAXNOC; i++) {
|
||||||
long p_sect[SCT_TYPE_MAX+2][2];
|
long p_sect[SCT_TYPE_MAX+2][2];
|
||||||
|
|
||||||
memset(p_sect, 0, sizeof(p_sect));
|
memset(p_sect, 0, sizeof(p_sect));
|
||||||
if (!(np = getnatp(x)))
|
if (!(np = getnatp(i)))
|
||||||
continue;
|
continue;
|
||||||
if (np->nat_stat == STAT_SANCT) {
|
if (np->nat_stat == STAT_SANCT) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
logerror("Country %i is in sanctuary and did not update", x);
|
logerror("Country %i is in sanctuary and did not update", i);
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
np->nat_money += (int)(np->nat_reserve * money_res * etu);
|
np->nat_money += (int)(np->nat_reserve * money_res * etu);
|
||||||
|
|
||||||
/* maintain units */
|
/* maintain units */
|
||||||
prod_ship(etu, x, bp, 0);
|
prod_ship(etu, i, bp, 0);
|
||||||
prod_plane(etu, x, bp, 0);
|
prod_plane(etu, i, bp, 0);
|
||||||
prod_land(etu, x, bp, 0);
|
prod_land(etu, i, bp, 0);
|
||||||
|
|
||||||
/* produce all sects */
|
/* produce all sects */
|
||||||
produce_sect(x, etu, bp, p_sect);
|
produce_sect(i, etu, bp, p_sect);
|
||||||
|
|
||||||
/* build units */
|
/* build units */
|
||||||
prod_ship(etu, x, bp, 1);
|
prod_ship(etu, i, bp, 1);
|
||||||
prod_plane(etu, x, bp, 1);
|
prod_plane(etu, i, bp, 1);
|
||||||
prod_land(etu, x, bp, 1);
|
prod_land(etu, i, bp, 1);
|
||||||
}
|
}
|
||||||
logerror("done producing for countries.");
|
logerror("done producing for countries.");
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,8 @@ main(int argc, char *argv[])
|
||||||
printf("Can't make telegram directory\n");
|
printf("Can't make telegram directory\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (x = MAXNOC - 1; x >= 0; x--) {
|
for (i = 0; i < MAXNOC; i++) {
|
||||||
filename = mailbox(buf, x);
|
filename = mailbox(buf, i);
|
||||||
close(creat(filename, S_IRWUG));
|
close(creat(filename, S_IRWUG));
|
||||||
}
|
}
|
||||||
close(creat(annfil, S_IRWUG));
|
close(creat(annfil, S_IRWUG));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue