(build_ship, orde, qorde, nav_loadship, load_it, unload_it): Store
item types instead of mnemo characters in shpstr members shp_tstart[] and shp_tend[]. (com_num): No longer used, remove. (orde): Simplify swap code. (prhold): New, factored out of qorde().
This commit is contained in:
parent
7b42409c9a
commit
e42f7e8210
5 changed files with 35 additions and 67 deletions
|
@ -583,7 +583,6 @@ extern int nav_ship(register struct shpstr *);
|
||||||
extern int check_nav(struct sctstr *);
|
extern int check_nav(struct sctstr *);
|
||||||
extern int load_it(register struct shpstr *, register struct sctstr *,
|
extern int load_it(register struct shpstr *, register struct sctstr *,
|
||||||
int);
|
int);
|
||||||
extern int com_num(s_char *);
|
|
||||||
extern void unload_it(register struct shpstr *);
|
extern void unload_it(register struct shpstr *);
|
||||||
extern void auto_fuel_ship(register struct shpstr *);
|
extern void auto_fuel_ship(register struct shpstr *);
|
||||||
/* nxtitemp.c */
|
/* nxtitemp.c */
|
||||||
|
|
|
@ -411,8 +411,8 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
||||||
ship.shp_autonav = 0;
|
ship.shp_autonav = 0;
|
||||||
/* new code for autonav, Chad Zabel 1-15-94 */
|
/* new code for autonav, Chad Zabel 1-15-94 */
|
||||||
for (i = 0; i < TMAX; ++i) {
|
for (i = 0; i < TMAX; ++i) {
|
||||||
ship.shp_tstart[i] = ' ';
|
ship.shp_tstart[i] = I_NONE;
|
||||||
ship.shp_tend[i] = ' ';
|
ship.shp_tend[i] = I_NONE;
|
||||||
ship.shp_lstart[i] = 0;
|
ship.shp_lstart[i] = 0;
|
||||||
ship.shp_lend[i] = 0;
|
ship.shp_lend[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,8 +121,8 @@ orde(void)
|
||||||
ship.shp_mission = 0;
|
ship.shp_mission = 0;
|
||||||
ship.shp_autonav &= ~(AN_AUTONAV + AN_STANDBY + AN_LOADING);
|
ship.shp_autonav &= ~(AN_AUTONAV + AN_STANDBY + AN_LOADING);
|
||||||
for (i = 0; i < TMAX; i++) {
|
for (i = 0; i < TMAX; i++) {
|
||||||
ship.shp_tstart[i] = ' ';
|
ship.shp_tstart[i] = I_NONE;
|
||||||
ship.shp_tend[i] = ' ';
|
ship.shp_tend[i] = I_NONE;
|
||||||
ship.shp_lstart[i] = 0;
|
ship.shp_lstart[i] = 0;
|
||||||
ship.shp_lend[i] = 0;
|
ship.shp_lend[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ orde(void)
|
||||||
level = 0; /* prevent negatives. */
|
level = 0; /* prevent negatives. */
|
||||||
pr("You must use positive number! Level set to 0.\n");
|
pr("You must use positive number! Level set to 0.\n");
|
||||||
}
|
}
|
||||||
ship.shp_tstart[sub] = (s_char)i1->i_mnem;
|
ship.shp_tstart[sub] = (s_char)i1->i_vtype;
|
||||||
ship.shp_lstart[sub] = level;
|
ship.shp_lstart[sub] = level;
|
||||||
pr("Order Set \n");
|
pr("Order Set \n");
|
||||||
break;
|
break;
|
||||||
|
@ -258,7 +258,7 @@ orde(void)
|
||||||
level = 0;
|
level = 0;
|
||||||
pr("You must use positive number! Level set to 0.\n");
|
pr("You must use positive number! Level set to 0.\n");
|
||||||
}
|
}
|
||||||
ship.shp_tend[sub] = (s_char)i1->i_mnem;
|
ship.shp_tend[sub] = (s_char)i1->i_vtype;
|
||||||
ship.shp_lend[sub] = level;
|
ship.shp_lend[sub] = level;
|
||||||
pr("Order Set \n");
|
pr("Order Set \n");
|
||||||
break;
|
break;
|
||||||
|
@ -286,7 +286,7 @@ orde(void)
|
||||||
&& (ship.shp_lstart[1] != ' '))) {
|
&& (ship.shp_lstart[1] != ' '))) {
|
||||||
|
|
||||||
coord tcord;
|
coord tcord;
|
||||||
s_char tcomm[TMAX];
|
s_char tcomm;
|
||||||
short lev[TMAX];
|
short lev[TMAX];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -306,9 +306,9 @@ orde(void)
|
||||||
lev[i] = ship.shp_lstart[i];
|
lev[i] = ship.shp_lstart[i];
|
||||||
ship.shp_lstart[i] = ship.shp_lend[i];
|
ship.shp_lstart[i] = ship.shp_lend[i];
|
||||||
ship.shp_lend[i] = lev[i];
|
ship.shp_lend[i] = lev[i];
|
||||||
tcomm[i] = ship.shp_tstart[i];
|
tcomm = ship.shp_tstart[i];
|
||||||
ship.shp_tstart[i] = ship.shp_tend[i];
|
ship.shp_tstart[i] = ship.shp_tend[i];
|
||||||
ship.shp_tend[i] = tcomm[i];
|
ship.shp_tend[i] = tcomm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -353,6 +353,19 @@ eta_calc(struct shpstr *sp, s_char *path, int *len, int *nupdates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
prhold(int hold, int itype, int amt)
|
||||||
|
{
|
||||||
|
if (itype != I_NONE && amt != 0) {
|
||||||
|
if (CANT_HAPPEN((unsigned)itype > I_MAX))
|
||||||
|
return;
|
||||||
|
pr("%d-", hold + 1);
|
||||||
|
pr("%c", ichr[itype].i_mnem);
|
||||||
|
pr(":");
|
||||||
|
pr("%d ", amt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qorde(void)
|
qorde(void)
|
||||||
{
|
{
|
||||||
|
@ -388,23 +401,11 @@ qorde(void)
|
||||||
if (ship.shp_autonav & AN_AUTONAV) {
|
if (ship.shp_autonav & AN_AUTONAV) {
|
||||||
|
|
||||||
pr(" [");
|
pr(" [");
|
||||||
for (i = 0; i < TMAX; i++) {
|
for (i = 0; i < TMAX; i++)
|
||||||
if (ship.shp_tend[i] != ' ' && ship.shp_lend[i] != 0) {
|
prhold(i, ship.shp_tend[i], ship.shp_lend[i]);
|
||||||
pr("%d-", i + 1);
|
|
||||||
pr("%c", ship.shp_tend[i]);
|
|
||||||
pr(":");
|
|
||||||
pr("%d ", ship.shp_lend[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pr("] , (");
|
pr("] , (");
|
||||||
for (i = 0; i < TMAX; i++) {
|
for (i = 0; i < TMAX; i++)
|
||||||
if (ship.shp_tstart[i] != ' ' && ship.shp_lstart[i] != 0) {
|
prhold(i, ship.shp_tstart[i], ship.shp_lstart[i]);
|
||||||
pr("%d-", i + 1);
|
|
||||||
pr("%c", ship.shp_tstart[i]);
|
|
||||||
pr(":");
|
|
||||||
pr("%d ", ship.shp_lstart[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pr(")");
|
pr(")");
|
||||||
if (ship.shp_autonav & AN_SCUTTLE)
|
if (ship.shp_autonav & AN_SCUTTLE)
|
||||||
pr(" scuttling");
|
pr(" scuttling");
|
||||||
|
|
|
@ -158,8 +158,7 @@ static int
|
||||||
nav_loadship(register struct shpstr *sp, natid cnum)
|
nav_loadship(register struct shpstr *sp, natid cnum)
|
||||||
{
|
{
|
||||||
struct sctstr *sectp;
|
struct sctstr *sectp;
|
||||||
s_char item;
|
int i, landown, shipown, didsomething[TMAX], rel;
|
||||||
int i, landown, shipown, level, didsomething[TMAX], rel;
|
|
||||||
|
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
didsomething[i] = 0;
|
didsomething[i] = 0;
|
||||||
|
@ -182,12 +181,9 @@ nav_loadship(register struct shpstr *sp, natid cnum)
|
||||||
|
|
||||||
/* loop through each field for that ship */
|
/* loop through each field for that ship */
|
||||||
for (i = 0; i < TMAX; ++i) {
|
for (i = 0; i < TMAX; ++i) {
|
||||||
item = sp->shp_tend[i]; /* commodity */
|
|
||||||
level = sp->shp_lend[i]; /* amount */
|
|
||||||
|
|
||||||
/* check and see if the data fields have been set. */
|
/* check and see if the data fields have been set. */
|
||||||
|
|
||||||
if (item == ' ' || level == 0) {
|
if (sp->shp_tend[i] == I_NONE || sp->shp_lend[i] == 0) {
|
||||||
/* nothing to do move on. */
|
/* nothing to do move on. */
|
||||||
didsomething[i] = 1;
|
didsomething[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -86,13 +86,13 @@ 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;
|
||||||
int abs_max, max_amt, transfer;
|
int abs_max, max_amt, transfer;
|
||||||
s_char item;
|
|
||||||
struct mchrstr *vship;
|
struct mchrstr *vship;
|
||||||
|
|
||||||
amount = sp->shp_lend[i];
|
amount = sp->shp_lend[i];
|
||||||
shipown = sp->shp_own;
|
shipown = sp->shp_own;
|
||||||
item = sp->shp_tend[i]; /* commodity */
|
comm = sp->shp_tend[i];
|
||||||
comm = com_num(&item);
|
if (CANT_HAPPEN((unsigned)comm > I_MAX))
|
||||||
|
return 0;
|
||||||
|
|
||||||
ship_amt = sp->shp_item[comm];
|
ship_amt = sp->shp_item[comm];
|
||||||
sect_amt = psect->sct_item[comm];
|
sect_amt = psect->sct_item[comm];
|
||||||
|
@ -161,7 +161,6 @@ void
|
||||||
unload_it(register struct shpstr *sp)
|
unload_it(register struct shpstr *sp)
|
||||||
{
|
{
|
||||||
struct sctstr *sectp;
|
struct sctstr *sectp;
|
||||||
s_char item;
|
|
||||||
int i;
|
int i;
|
||||||
int landowner;
|
int landowner;
|
||||||
int shipown;
|
int shipown;
|
||||||
|
@ -169,8 +168,6 @@ unload_it(register struct shpstr *sp)
|
||||||
int sect_amt;
|
int sect_amt;
|
||||||
int ship_amt;
|
int ship_amt;
|
||||||
int max_amt;
|
int max_amt;
|
||||||
int level;
|
|
||||||
|
|
||||||
|
|
||||||
sectp = getsectp(sp->shp_x, sp->shp_y);
|
sectp = getsectp(sp->shp_x, sp->shp_y);
|
||||||
|
|
||||||
|
@ -178,17 +175,16 @@ unload_it(register struct shpstr *sp)
|
||||||
shipown = sp->shp_own;
|
shipown = sp->shp_own;
|
||||||
|
|
||||||
for (i = 0; i < TMAX; ++i) {
|
for (i = 0; i < TMAX; ++i) {
|
||||||
item = sp->shp_tend[i];
|
if (sp->shp_tend[i] == I_NONE || sp->shp_lend[i] == 0)
|
||||||
level = sp->shp_lend[i];
|
|
||||||
|
|
||||||
if (item == ' ' || level == 0)
|
|
||||||
continue;
|
continue;
|
||||||
if (landowner == 0)
|
if (landowner == 0)
|
||||||
continue;
|
continue;
|
||||||
if (sectp->sct_type != SCT_HARBR)
|
if (sectp->sct_type != SCT_HARBR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
comm = com_num(&item);
|
comm = sp->shp_tend[i];
|
||||||
|
if (CANT_HAPPEN((unsigned)comm > I_MAX))
|
||||||
|
continue;
|
||||||
ship_amt = sp->shp_item[comm];
|
ship_amt = sp->shp_item[comm];
|
||||||
sect_amt = sectp->sct_item[comm];
|
sect_amt = sectp->sct_item[comm];
|
||||||
|
|
||||||
|
@ -217,30 +213,6 @@ unload_it(register struct shpstr *sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* com_num
|
|
||||||
* This small but useful bit of code runs through the list
|
|
||||||
* of commodities and return the integer value of the
|
|
||||||
* commodity it finds if possible.
|
|
||||||
* Basicly its a hacked version of whatitem.c found in the
|
|
||||||
* /player directory.
|
|
||||||
* new autonav code.
|
|
||||||
* Chad Zabel 6/1/94
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
com_num(s_char *ptr)
|
|
||||||
{
|
|
||||||
struct ichrstr *ip;
|
|
||||||
|
|
||||||
for (ip = &ichr[1]; ip->i_mnem != 0; ip++) {
|
|
||||||
if (*ptr == ip->i_mnem)
|
|
||||||
return ip->i_vtype;
|
|
||||||
}
|
|
||||||
return 0; /*NOTREACHED*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* auto_fuel_ship
|
/* auto_fuel_ship
|
||||||
* Assume a check for fuel=0 has already been made and passed.
|
* Assume a check for fuel=0 has already been made and passed.
|
||||||
* Try to fill a ship using petro. and then oil.
|
* Try to fill a ship using petro. and then oil.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue