Simplify load computation in pln_equip(), mission_pln_equip()
This commit is contained in:
parent
29a6baca6d
commit
b2107e5301
2 changed files with 38 additions and 36 deletions
|
@ -900,44 +900,43 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
|
||||||
item[I_PETROL] -= pcp->pl_fuel;
|
item[I_PETROL] -= pcp->pl_fuel;
|
||||||
load = pln_load(pp);
|
load = pln_load(pp);
|
||||||
itype = I_NONE;
|
itype = I_NONE;
|
||||||
needed = 0;
|
|
||||||
switch (mission) {
|
switch (mission) {
|
||||||
case 's': /* strategic bomb */
|
case 's': /* strategic bomb */
|
||||||
case 'p': /* pinpoint bomb */
|
case 'p': /* pinpoint bomb */
|
||||||
if (nuk_on_plane(pp) < 0) {
|
if (nuk_on_plane(pp) >= 0)
|
||||||
|
break;
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = load;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 't': /* transport */
|
case 't': /* transport */
|
||||||
case 'd': /* drop */
|
case 'd': /* drop */
|
||||||
if (!(pcp->pl_flags & P_C) || !ip)
|
if (!(pcp->pl_flags & P_C) || !ip)
|
||||||
break;
|
break;
|
||||||
itype = ip->i_uid;
|
itype = ip->i_uid;
|
||||||
needed = (load * 2) / ip->i_lbs;
|
load *= 2;
|
||||||
break;
|
break;
|
||||||
case 'a': /* paradrop */
|
case 'a': /* paradrop */
|
||||||
if (!(pcp->pl_flags & P_P))
|
if (!(pcp->pl_flags & P_P))
|
||||||
break;
|
break;
|
||||||
itype = I_MILIT;
|
itype = I_MILIT;
|
||||||
needed = load / ichr[I_MILIT].i_lbs;
|
|
||||||
break;
|
break;
|
||||||
case 'i': /* missile interception */
|
case 'i': /* missile interception */
|
||||||
if (load) {
|
if (load)
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = load;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'r': /* reconnaissance */
|
case 'r': /* reconnaissance */
|
||||||
case 'e': /* escort */
|
case 'e': /* escort */
|
||||||
case 0: /* plane interception */
|
case 0: /* plane interception */
|
||||||
|
load = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CANT_REACH();
|
CANT_REACH();
|
||||||
|
load = 0;
|
||||||
}
|
}
|
||||||
if (itype != I_NONE && needed <= 0)
|
|
||||||
return -1;
|
|
||||||
if (itype != I_NONE) {
|
if (itype != I_NONE) {
|
||||||
|
needed = load / ichr[itype].i_lbs;
|
||||||
|
if (needed <= 0)
|
||||||
|
return -1;
|
||||||
if (itype == I_SHELL && item[itype] < needed) {
|
if (itype == I_SHELL && item[itype] < needed) {
|
||||||
if (pp->pln_ship >= 0)
|
if (pp->pln_ship >= 0)
|
||||||
shp_supply(&ship, I_SHELL, needed);
|
shp_supply(&ship, I_SHELL, needed);
|
||||||
|
@ -949,11 +948,12 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
|
||||||
if (item[itype] < needed)
|
if (item[itype] < needed)
|
||||||
return -1;
|
return -1;
|
||||||
item[itype] -= needed;
|
item[itype] -= needed;
|
||||||
}
|
|
||||||
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
|
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
|
||||||
plp->bombs = needed;
|
plp->bombs = needed;
|
||||||
else
|
else
|
||||||
plp->misc = needed;
|
plp->misc = needed;
|
||||||
|
}
|
||||||
|
|
||||||
if (pp->pln_ship >= 0)
|
if (pp->pln_ship >= 0)
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
else if (pp->pln_land >= 0)
|
else if (pp->pln_land >= 0)
|
||||||
|
|
|
@ -650,41 +650,43 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
|
||||||
item[I_PETROL] -= pcp->pl_fuel;
|
item[I_PETROL] -= pcp->pl_fuel;
|
||||||
load = pln_load(pp);
|
load = pln_load(pp);
|
||||||
itype = I_NONE;
|
itype = I_NONE;
|
||||||
needed = 0;
|
|
||||||
switch (mission) {
|
switch (mission) {
|
||||||
case 's': /* strategic bomb */
|
case 's': /* strategic bomb */
|
||||||
case 'p': /* pinpoint bomb */
|
case 'p': /* pinpoint bomb */
|
||||||
if (nuk_on_plane(pp) < 0) {
|
if (nuk_on_plane(pp) >= 0)
|
||||||
|
break;
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = load;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 't': /* transport */
|
case 't': /* transport */
|
||||||
case 'd': /* drop */
|
case 'd': /* drop */
|
||||||
if (!(pcp->pl_flags & P_C) || !ip)
|
if (!(pcp->pl_flags & P_C) || !ip)
|
||||||
break;
|
break;
|
||||||
itype = ip->i_uid;
|
itype = ip->i_uid;
|
||||||
needed = (load * 2) / ip->i_lbs;
|
load *= 2;
|
||||||
break;
|
break;
|
||||||
case 'm': /* mine */
|
case 'm': /* mine */
|
||||||
if ((pcp->pl_flags & P_MINE) == 0)
|
if ((pcp->pl_flags & P_MINE) == 0)
|
||||||
break;
|
break;
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = (load * 2) / ichr[I_SHELL].i_lbs;
|
load *= 2;
|
||||||
break;
|
break;
|
||||||
case 'a': /* paradrop */
|
case 'a': /* paradrop */
|
||||||
if (!(pcp->pl_flags & P_P))
|
if (!(pcp->pl_flags & P_P))
|
||||||
break;
|
break;
|
||||||
itype = I_MILIT;
|
itype = I_MILIT;
|
||||||
needed = load / ichr[I_MILIT].i_lbs;
|
|
||||||
break;
|
break;
|
||||||
case 'r': /* reconnaissance */
|
case 'r': /* reconnaissance */
|
||||||
case 'e': /* escort */
|
case 'e': /* escort */
|
||||||
|
load = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CANT_REACH();
|
CANT_REACH();
|
||||||
|
load = 0;
|
||||||
}
|
}
|
||||||
if (itype != I_NONE && needed <= 0) {
|
|
||||||
|
if (itype != I_NONE) {
|
||||||
|
needed = load / ichr[itype].i_lbs;
|
||||||
|
if (needed <= 0) {
|
||||||
pr("%s can't contribute to mission\n", prplane(pp));
|
pr("%s can't contribute to mission\n", prplane(pp));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -692,7 +694,6 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
|
||||||
pr("You don't control those civilians!\n");
|
pr("You don't control those civilians!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (itype != I_NONE) {
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Supply is broken somewhere, so don't use it for now */
|
/* Supply is broken somewhere, so don't use it for now */
|
||||||
if (itype == I_SHELL && item[itype] < needed)
|
if (itype == I_SHELL && item[itype] < needed)
|
||||||
|
@ -707,11 +708,12 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
item[itype] -= needed;
|
item[itype] -= needed;
|
||||||
}
|
|
||||||
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
|
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
|
||||||
plp->bombs = needed;
|
plp->bombs = needed;
|
||||||
else
|
else
|
||||||
plp->misc = needed;
|
plp->misc = needed;
|
||||||
|
}
|
||||||
|
|
||||||
if (pp->pln_ship >= 0) {
|
if (pp->pln_ship >= 0) {
|
||||||
if (pp->pln_own != ship.shp_own) {
|
if (pp->pln_own != ship.shp_own) {
|
||||||
wu(0, ship.shp_own,
|
wu(0, ship.shp_own,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue