(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 load_it(register struct shpstr *, register struct sctstr *,
|
||||
int);
|
||||
extern int com_num(s_char *);
|
||||
extern void unload_it(register struct shpstr *);
|
||||
extern void auto_fuel_ship(register struct shpstr *);
|
||||
/* nxtitemp.c */
|
||||
|
|
|
@ -411,8 +411,8 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
|||
ship.shp_autonav = 0;
|
||||
/* new code for autonav, Chad Zabel 1-15-94 */
|
||||
for (i = 0; i < TMAX; ++i) {
|
||||
ship.shp_tstart[i] = ' ';
|
||||
ship.shp_tend[i] = ' ';
|
||||
ship.shp_tstart[i] = I_NONE;
|
||||
ship.shp_tend[i] = I_NONE;
|
||||
ship.shp_lstart[i] = 0;
|
||||
ship.shp_lend[i] = 0;
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ orde(void)
|
|||
ship.shp_mission = 0;
|
||||
ship.shp_autonav &= ~(AN_AUTONAV + AN_STANDBY + AN_LOADING);
|
||||
for (i = 0; i < TMAX; i++) {
|
||||
ship.shp_tstart[i] = ' ';
|
||||
ship.shp_tend[i] = ' ';
|
||||
ship.shp_tstart[i] = I_NONE;
|
||||
ship.shp_tend[i] = I_NONE;
|
||||
ship.shp_lstart[i] = 0;
|
||||
ship.shp_lend[i] = 0;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ orde(void)
|
|||
level = 0; /* prevent negatives. */
|
||||
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;
|
||||
pr("Order Set \n");
|
||||
break;
|
||||
|
@ -258,7 +258,7 @@ orde(void)
|
|||
level = 0;
|
||||
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;
|
||||
pr("Order Set \n");
|
||||
break;
|
||||
|
@ -286,7 +286,7 @@ orde(void)
|
|||
&& (ship.shp_lstart[1] != ' '))) {
|
||||
|
||||
coord tcord;
|
||||
s_char tcomm[TMAX];
|
||||
s_char tcomm;
|
||||
short lev[TMAX];
|
||||
int i;
|
||||
|
||||
|
@ -306,9 +306,9 @@ orde(void)
|
|||
lev[i] = ship.shp_lstart[i];
|
||||
ship.shp_lstart[i] = ship.shp_lend[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_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
|
||||
qorde(void)
|
||||
{
|
||||
|
@ -388,23 +401,11 @@ qorde(void)
|
|||
if (ship.shp_autonav & AN_AUTONAV) {
|
||||
|
||||
pr(" [");
|
||||
for (i = 0; i < TMAX; i++) {
|
||||
if (ship.shp_tend[i] != ' ' && ship.shp_lend[i] != 0) {
|
||||
pr("%d-", i + 1);
|
||||
pr("%c", ship.shp_tend[i]);
|
||||
pr(":");
|
||||
pr("%d ", ship.shp_lend[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TMAX; i++)
|
||||
prhold(i, ship.shp_tend[i], ship.shp_lend[i]);
|
||||
pr("] , (");
|
||||
for (i = 0; i < TMAX; i++) {
|
||||
if (ship.shp_tstart[i] != ' ' && ship.shp_lstart[i] != 0) {
|
||||
pr("%d-", i + 1);
|
||||
pr("%c", ship.shp_tstart[i]);
|
||||
pr(":");
|
||||
pr("%d ", ship.shp_lstart[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < TMAX; i++)
|
||||
prhold(i, ship.shp_tstart[i], ship.shp_lstart[i]);
|
||||
pr(")");
|
||||
if (ship.shp_autonav & AN_SCUTTLE)
|
||||
pr(" scuttling");
|
||||
|
|
|
@ -158,8 +158,7 @@ static int
|
|||
nav_loadship(register struct shpstr *sp, natid cnum)
|
||||
{
|
||||
struct sctstr *sectp;
|
||||
s_char item;
|
||||
int i, landown, shipown, level, didsomething[TMAX], rel;
|
||||
int i, landown, shipown, didsomething[TMAX], rel;
|
||||
|
||||
for (i = 0; i < TMAX; i++)
|
||||
didsomething[i] = 0;
|
||||
|
@ -182,12 +181,9 @@ nav_loadship(register struct shpstr *sp, natid cnum)
|
|||
|
||||
/* loop through each field for that ship */
|
||||
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. */
|
||||
|
||||
if (item == ' ' || level == 0) {
|
||||
if (sp->shp_tend[i] == I_NONE || sp->shp_lend[i] == 0) {
|
||||
/* nothing to do move on. */
|
||||
didsomething[i] = 1;
|
||||
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 abs_max, max_amt, transfer;
|
||||
s_char item;
|
||||
struct mchrstr *vship;
|
||||
|
||||
amount = sp->shp_lend[i];
|
||||
shipown = sp->shp_own;
|
||||
item = sp->shp_tend[i]; /* commodity */
|
||||
comm = com_num(&item);
|
||||
comm = sp->shp_tend[i];
|
||||
if (CANT_HAPPEN((unsigned)comm > I_MAX))
|
||||
return 0;
|
||||
|
||||
ship_amt = sp->shp_item[comm];
|
||||
sect_amt = psect->sct_item[comm];
|
||||
|
@ -161,7 +161,6 @@ void
|
|||
unload_it(register struct shpstr *sp)
|
||||
{
|
||||
struct sctstr *sectp;
|
||||
s_char item;
|
||||
int i;
|
||||
int landowner;
|
||||
int shipown;
|
||||
|
@ -169,8 +168,6 @@ unload_it(register struct shpstr *sp)
|
|||
int sect_amt;
|
||||
int ship_amt;
|
||||
int max_amt;
|
||||
int level;
|
||||
|
||||
|
||||
sectp = getsectp(sp->shp_x, sp->shp_y);
|
||||
|
||||
|
@ -178,17 +175,16 @@ unload_it(register struct shpstr *sp)
|
|||
shipown = sp->shp_own;
|
||||
|
||||
for (i = 0; i < TMAX; ++i) {
|
||||
item = sp->shp_tend[i];
|
||||
level = sp->shp_lend[i];
|
||||
|
||||
if (item == ' ' || level == 0)
|
||||
if (sp->shp_tend[i] == I_NONE || sp->shp_lend[i] == 0)
|
||||
continue;
|
||||
if (landowner == 0)
|
||||
continue;
|
||||
if (sectp->sct_type != SCT_HARBR)
|
||||
continue;
|
||||
|
||||
comm = com_num(&item);
|
||||
comm = sp->shp_tend[i];
|
||||
if (CANT_HAPPEN((unsigned)comm > I_MAX))
|
||||
continue;
|
||||
ship_amt = sp->shp_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
|
||||
* Assume a check for fuel=0 has already been made and passed.
|
||||
* Try to fill a ship using petro. and then oil.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue