(ITEM_MAX): New, value 9999.
(give, deliver_it): Use it instead of 9990. (load_comm_ship, load_comm_land, rese): Use it instead of 9999. (thre): Use it instead of 10000. (check_market, explore, move, pln_dropoff): Use it instead of 32767. (unload_it): Use it instead of 99999 (which couldn't possibly work, but what do you expect from the autonav code).
This commit is contained in:
parent
5ec624514a
commit
95ef2b139d
11 changed files with 27 additions and 31 deletions
|
@ -184,10 +184,12 @@ extern struct dchrstr bigcity_dchr;
|
||||||
/* Sector flags */
|
/* Sector flags */
|
||||||
#define MOVE_IN_PROGRESS bit(0) /* move in progress */
|
#define MOVE_IN_PROGRESS bit(0) /* move in progress */
|
||||||
|
|
||||||
/* maximum number of che, must fit into struct sctstr member sct_che */
|
/* maximum amount of an item, must fit into sct_item[], sct_del[], sct_dist */
|
||||||
#define CHE_MAX 255
|
#define ITEM_MAX 9999
|
||||||
/* maximum number of mines, must fit into struct sctstr member sct_mines */
|
/* maximum number of mines, must fit into struct sctstr member sct_mines */
|
||||||
#define MINES_MAX 65535
|
#define MINES_MAX 65535
|
||||||
|
/* maximum number of che, must fit into struct sctstr member sct_che */
|
||||||
|
#define CHE_MAX 255
|
||||||
/* maximum fallout, must fit into struct sctstr member sct_fallout */
|
/* maximum fallout, must fit into struct sctstr member sct_fallout */
|
||||||
#define FALLOUT_MAX 9999
|
#define FALLOUT_MAX 9999
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ check_market(void)
|
||||||
wu(0, comm.com_owner,
|
wu(0, comm.com_owner,
|
||||||
"Sale #%d fell through. Goods remain on the market.\n", n);
|
"Sale #%d fell through. Goods remain on the market.\n", n);
|
||||||
comm.com_maxbidder = comm.com_owner;
|
comm.com_maxbidder = comm.com_owner;
|
||||||
} else if (m + comm.com_amount > 32767) {
|
} else if (m + comm.com_amount > ITEM_MAX) {
|
||||||
wu(0, comm.com_maxbidder,
|
wu(0, comm.com_maxbidder,
|
||||||
"Warehouse full, sale #%d fell though.\n", n);
|
"Warehouse full, sale #%d fell though.\n", n);
|
||||||
wu(0, comm.com_owner,
|
wu(0, comm.com_owner,
|
||||||
|
|
|
@ -236,8 +236,8 @@ explore(void)
|
||||||
start.sct_flags &= ~MOVE_IN_PROGRESS;
|
start.sct_flags &= ~MOVE_IN_PROGRESS;
|
||||||
putsect(&start);
|
putsect(&start);
|
||||||
amt_dst = sect.sct_item[vtype];
|
amt_dst = sect.sct_item[vtype];
|
||||||
if (32767 - amt_dst < amount) {
|
if (amount > ITEM_MAX - amt_dst) {
|
||||||
amount = 32767 - amt_dst;
|
amount = ITEM_MAX - amt_dst;
|
||||||
pr("Only %d can be left there.\n", amount);
|
pr("Only %d can be left there.\n", amount);
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
getsect(start.sct_x, start.sct_y, §);
|
getsect(start.sct_x, start.sct_y, §);
|
||||||
|
|
|
@ -72,8 +72,8 @@ give(void)
|
||||||
n = sect.sct_item[ip->i_vtype];
|
n = sect.sct_item[ip->i_vtype];
|
||||||
if (amt < 0 && -amt > n) {
|
if (amt < 0 && -amt > n) {
|
||||||
m = 0;
|
m = 0;
|
||||||
} else if (amt > 0 && amt + n > 9990) {
|
} else if (amt > 0 && amt + n > ITEM_MAX) {
|
||||||
m = 9990;
|
m = ITEM_MAX;
|
||||||
} else
|
} else
|
||||||
m = n + amt;
|
m = n + amt;
|
||||||
sect.sct_item[ip->i_vtype] = m;
|
sect.sct_item[ip->i_vtype] = m;
|
||||||
|
|
|
@ -767,8 +767,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
||||||
move_amt = -ship_amt;
|
move_amt = -ship_amt;
|
||||||
if (move_amt > sect_amt)
|
if (move_amt > sect_amt)
|
||||||
move_amt = sect_amt;
|
move_amt = sect_amt;
|
||||||
if (move_amt < sect_amt - 9999)
|
if (move_amt < sect_amt - ITEM_MAX)
|
||||||
move_amt = sect_amt - 9999;
|
move_amt = sect_amt - ITEM_MAX;
|
||||||
if (!move_amt)
|
if (!move_amt)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
||||||
|
@ -970,8 +970,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
||||||
move_amt = -land_amt;
|
move_amt = -land_amt;
|
||||||
if (move_amt > sect_amt)
|
if (move_amt > sect_amt)
|
||||||
move_amt = sect_amt;
|
move_amt = sect_amt;
|
||||||
if (move_amt < sect_amt - 9999)
|
if (move_amt < sect_amt - ITEM_MAX)
|
||||||
move_amt = sect_amt - 9999;
|
move_amt = sect_amt - ITEM_MAX;
|
||||||
if (!move_amt)
|
if (!move_amt)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
if (sectp->sct_own != player->cnum && move_amt > 0) {
|
if (sectp->sct_own != player->cnum && move_amt > 0) {
|
||||||
|
|
|
@ -308,8 +308,8 @@ move(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
amt_dst = sect.sct_item[vtype];
|
amt_dst = sect.sct_item[vtype];
|
||||||
if (32767 - amt_dst < amount) {
|
if (amount > ITEM_MAX - amt_dst) {
|
||||||
amount = 32767 - amt_dst;
|
amount = ITEM_MAX - amt_dst;
|
||||||
pr("Only room for %d, the rest were lost.\n", amount);
|
pr("Only room for %d, the rest were lost.\n", amount);
|
||||||
}
|
}
|
||||||
if (istest)
|
if (istest)
|
||||||
|
|
|
@ -122,8 +122,8 @@ rese(void)
|
||||||
sect.sct_y = comm.sell_y;
|
sect.sct_y = comm.sell_y;
|
||||||
m = sect.sct_item[ix->i_vtype];
|
m = sect.sct_item[ix->i_vtype];
|
||||||
m = m + comm.com_amount;
|
m = m + comm.com_amount;
|
||||||
if (m > 9999)
|
if (m > ITEM_MAX)
|
||||||
m = 9999;
|
m = ITEM_MAX;
|
||||||
sect.sct_item[ix->i_vtype] = m;
|
sect.sct_item[ix->i_vtype] = m;
|
||||||
putsect(§);
|
putsect(§);
|
||||||
comm.com_owner = 0;
|
comm.com_owner = 0;
|
||||||
|
|
|
@ -88,8 +88,8 @@ thre(void)
|
||||||
if (*p == '\0' || *p == '-')
|
if (*p == '\0' || *p == '-')
|
||||||
continue;
|
continue;
|
||||||
thresh = atoi(p);
|
thresh = atoi(p);
|
||||||
if (thresh > 10000)
|
if (thresh > ITEM_MAX)
|
||||||
thresh = 10000;
|
thresh = ITEM_MAX;
|
||||||
if ((val > 0) && (val == thresh)) {
|
if ((val > 0) && (val == thresh)) {
|
||||||
pr("%s threshold unchanged (left at %d)\n",
|
pr("%s threshold unchanged (left at %d)\n",
|
||||||
xyas(nstr.x, nstr.y, player->cnum), val);
|
xyas(nstr.x, nstr.y, player->cnum), val);
|
||||||
|
|
|
@ -240,7 +240,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
there = sectp->sct_item[ip->i_vtype];
|
there = sectp->sct_item[ip->i_vtype];
|
||||||
max = 32767;
|
max = ITEM_MAX;
|
||||||
} else {
|
} else {
|
||||||
sp = ptr;
|
sp = ptr;
|
||||||
there = sp->shp_item[ip->i_vtype];
|
there = sp->shp_item[ip->i_vtype];
|
||||||
|
|
|
@ -101,10 +101,9 @@ deliver(register struct sctstr *from, struct ichrstr *ip, int dir,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
amt_dst = to->sct_item[vtype];
|
amt_dst = to->sct_item[vtype];
|
||||||
if (amt_moved + amt_dst > 9990) {
|
if (amt_moved > ITEM_MAX - amt_dst) {
|
||||||
/* delivery backlog */
|
/* delivery backlog */
|
||||||
if ((amt_moved = 9990 - amt_dst) <= 0)
|
amt_moved = ITEM_MAX - amt_dst;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
to->sct_item[vtype] = amt_moved + amt_dst;
|
to->sct_item[vtype] = amt_moved + amt_dst;
|
||||||
/* deliver the plague too! */
|
/* deliver the plague too! */
|
||||||
|
|
|
@ -84,8 +84,8 @@ check_nav(struct sctstr *sect)
|
||||||
int
|
int
|
||||||
load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
|
load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
|
||||||
{
|
{
|
||||||
int comm, shipown, amount, ship_amt, sect_amt,
|
int comm, shipown, amount, ship_amt, sect_amt;
|
||||||
abs_max, max_amt, transfer;
|
int abs_max, max_amt, transfer;
|
||||||
s_char item;
|
s_char item;
|
||||||
struct mchrstr *vship;
|
struct mchrstr *vship;
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
|
||||||
if (comm == V_CIVIL || comm == V_MILIT)
|
if (comm == V_CIVIL || comm == V_MILIT)
|
||||||
sect_amt--; /* leave 1 civ or mil to hold the sector. */
|
sect_amt--; /* leave 1 civ or mil to hold the sector. */
|
||||||
vship = &mchr[(int)sp->shp_type];
|
vship = &mchr[(int)sp->shp_type];
|
||||||
abs_max = max_amt = (vl_find(comm, vship->m_vtype,
|
abs_max = max_amt = vl_find(comm, vship->m_vtype,
|
||||||
vship->m_vamt, (int)vship->m_nv));
|
vship->m_vamt, (int)vship->m_nv);
|
||||||
|
|
||||||
if (!abs_max)
|
if (!abs_max)
|
||||||
return 0; /* can't load the ship, skip to the end. */
|
return 0; /* can't load the ship, skip to the end. */
|
||||||
|
@ -168,7 +168,6 @@ unload_it(register struct shpstr *sp)
|
||||||
int comm;
|
int comm;
|
||||||
int sect_amt;
|
int sect_amt;
|
||||||
int ship_amt;
|
int ship_amt;
|
||||||
int abs_max = 99999; /* max amount a sector can hold. */
|
|
||||||
int max_amt;
|
int max_amt;
|
||||||
int level;
|
int level;
|
||||||
|
|
||||||
|
@ -204,11 +203,7 @@ unload_it(register struct shpstr *sp)
|
||||||
if (comm == V_CIVIL)
|
if (comm == V_CIVIL)
|
||||||
ship_amt--; /* This leaves 1 civs on board the ship */
|
ship_amt--; /* This leaves 1 civs on board the ship */
|
||||||
|
|
||||||
if (sect_amt >= abs_max)
|
max_amt = min(ship_amt, ITEM_MAX - sect_amt);
|
||||||
continue; /* The sector is full. */
|
|
||||||
|
|
||||||
max_amt = min(ship_amt, abs_max - sect_amt);
|
|
||||||
|
|
||||||
if (max_amt <= 0)
|
if (max_amt <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue