Remove option FUEL

The abstract idea of tying ships and land units to a logistical tether
is sound, the concrete implementation as option FUEL is flawed.  It
adds too much busy-work to the game to be enjoyable.  It hasn't been
enabled in a public game for years.  The code implementing it is ugly,
repetitive, and a burden to maintain.

Remove selector fuel from ship_ca[] and land_ca[], and selectors
fuelc, fuelu from mchr_ca[] and lchr_ca[].  Remove fields fuelc, fuelu
from ship.config and land.config.

Remove command fuel from player_coms[].

Deprecate edit key 'B' in doship(), dounit(), and don't show it in
pr_ship(), pr_land().

Drop opt_FUEL code from build_ship(), shi(), sdump(), ship_damage(),
show_ship_stats(), do_mob_ship(), nav_ship(), build_land(), land(),
ldump(), land_damage(), show_land_stats(), do_mob_land(),
resupply_all(), resupply_commod(), get_minimum(), has_supply(),
unit_list(), vers().

Remove opt_FUEL, fuel_mult, struct shpstr member shp_fuel, struct
mchrstr members m_fuelc and m_fuelu, M_OILER, struct lndstr member
lnd_fuel, struct lchrstr members l_fuelc and l_fuelu, fuel(), and
auto_fuel_ship().
This commit is contained in:
Markus Armbruster 2008-05-12 09:25:20 +02:00
parent 3cc80e83c3
commit 3b4de2feb1
42 changed files with 124 additions and 984 deletions

View file

@ -181,10 +181,7 @@ mob_ship(void)
static void
do_mob_ship(struct shpstr *sp, int etus)
{
int newfuel = 0;
int value;
int can_add, have_fuel_for, total_add;
double d;
if (CANT_HAPPEN(etus < 0))
etus = 0;
@ -192,72 +189,10 @@ do_mob_ship(struct shpstr *sp, int etus)
if (sp->shp_own == 0)
return;
if (opt_FUEL == 0 || mchr[(int)sp->shp_type].m_fuelu == 0) {
value = sp->shp_mobil + (float)etus * ship_mob_scale;
if (value > ship_mob_max)
value = ship_mob_max;
sp->shp_mobil = (signed char)value;
} else {
if (sp->shp_mobil >= ship_mob_max) {
sp->shp_mobil = ship_mob_max;
return;
}
can_add = ship_mob_max - sp->shp_mobil;
if (can_add > (float)etus * ship_mob_scale)
can_add = (float)etus * ship_mob_scale;
have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult, 1);
if (can_add > have_fuel_for) {
int need;
need = can_add - have_fuel_for;
d = need;
d *= mchr[(int)sp->shp_type].m_fuelu;
d /= fuel_mult;
d /= 5.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
I_PETROL, need);
sp->shp_fuel += newfuel * 5;
}
have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult, 1);
if (can_add > have_fuel_for) {
int need;
need = can_add - have_fuel_for;
d = need;
d *= mchr[(int)sp->shp_type].m_fuelu;
d /= fuel_mult;
d /= 50.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
I_OIL, need);
sp->shp_fuel += newfuel * 50;
}
have_fuel_for = ldround(((double)sp->shp_fuel /
(double)mchr[(int)sp->shp_type].m_fuelu)
* (double)fuel_mult, 1);
if (can_add > have_fuel_for)
total_add = have_fuel_for;
else
total_add = can_add;
d = total_add;
d *= mchr[(int)sp->shp_type].m_fuelu;
d /= fuel_mult;
sp->shp_fuel -= ldround(d, 1);
sp->shp_fuel = MIN(sp->shp_fuel, mchr[(int)sp->shp_type].m_fuelc);
sp->shp_mobil += total_add;
}
value = sp->shp_mobil + (float)etus * ship_mob_scale;
if (value > ship_mob_max)
value = ship_mob_max;
sp->shp_mobil = (signed char)value;
}
void
@ -281,11 +216,7 @@ mob_land(void)
static void
do_mob_land(struct lndstr *lp, int etus)
{
int newfuel = 0;
int value;
int can_add, have_fuel_for, total_add;
double d;
struct lchrstr *lcp = lchr + lp->lnd_type;
if (CANT_HAPPEN(etus < 0))
etus = 0;
@ -293,85 +224,24 @@ do_mob_land(struct lndstr *lp, int etus)
if (lp->lnd_own == 0)
return;
if (opt_FUEL == 0 || lcp->l_fuelu == 0) {
value = lp->lnd_mobil + ((float)etus * land_mob_scale);
if (value > land_mob_max) {
if (lp->lnd_harden < land_mob_max && !opt_MOB_ACCESS) {
/*
* Automatic fortification on excess mobility.
* Disabled for MOB_ACCESS, because it leads to
* excessively deep recursion and thus miserable
* performance as the number of land units grows.
*
* Provide mobility to be used in lnd_fortify()
* without overflowing lnd_mobil.
*/
lp->lnd_mobil = land_mob_max;
lnd_fortify(lp, value - land_mob_max);
}
value = land_mob_max;
}
lp->lnd_mobil = value;
} else {
if (lp->lnd_mobil >= land_mob_max) {
value = lp->lnd_mobil + ((float)etus * land_mob_scale);
if (value > land_mob_max) {
if (lp->lnd_harden < land_mob_max && !opt_MOB_ACCESS) {
/*
* Automatic fortification on excess mobility.
* Disabled for MOB_ACCESS, because it leads to
* excessively deep recursion and thus miserable
* performance as the number of land units grows.
*
* Provide mobility to be used in lnd_fortify()
* without overflowing lnd_mobil.
*/
lp->lnd_mobil = land_mob_max;
return;
lnd_fortify(lp, value - land_mob_max);
}
can_add = land_mob_max - lp->lnd_mobil;
if (can_add > (float)etus * land_mob_scale)
can_add = (float)etus * land_mob_scale;
have_fuel_for = (lp->lnd_fuel / lcp->l_fuelu) * fuel_mult;
if (can_add > have_fuel_for) {
int need;
need = can_add - have_fuel_for;
d = need;
d *= lcp->l_fuelu;
d /= fuel_mult;
d /= 5.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y,
I_PETROL, need);
lp->lnd_fuel += newfuel * 5;
}
have_fuel_for = (lp->lnd_fuel / lcp->l_fuelu) * fuel_mult;
if (can_add > have_fuel_for) {
int need;
need = can_add - have_fuel_for;
d = need;
d *= lcp->l_fuelu;
d /= fuel_mult;
d /= 50.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(lp->lnd_own, lp->lnd_x, lp->lnd_y,
I_OIL, need);
lp->lnd_fuel += newfuel * 50;
}
have_fuel_for = (lp->lnd_fuel / lcp->l_fuelu) * fuel_mult;
if (can_add > have_fuel_for) {
total_add = have_fuel_for;
} else
total_add = can_add;
d = total_add;
d *= lcp->l_fuelu;
d /= fuel_mult;
lp->lnd_fuel -= ldround(d, 1);
lp->lnd_fuel = MIN(lp->lnd_fuel, lcp->l_fuelc);
lp->lnd_mobil += total_add;
/* No excess mobility here, hence no automatic fortification */
value = land_mob_max;
}
lp->lnd_mobil = value;
}
void

View file

@ -239,9 +239,6 @@ nav_load_ship_at_sea(struct shpstr *sp)
* Continue to loop until the ship runs out of mobility, a load fails,
* the ship gets sunk (forts,ect..), the ship hits a mine.
*
* A check has been added for fuel so ships don't end up running
* out of mobility in the ocean.
*
* Questions, bugs (fixes) , or new ideas should be directed at
* Chad Zabel.
* 6-1-94
@ -250,7 +247,6 @@ nav_load_ship_at_sea(struct shpstr *sp)
int
nav_ship(struct shpstr *sp)
{
struct sctstr *sectp;
char *cp;
int stopping;
int quit;
@ -287,14 +283,6 @@ nav_ship(struct shpstr *sp)
sp->shp_own);
if (QEMPTY(&ship_list))
return RET_OK;
/* before we move check to see if ship needs fuel. */
sectp = getsectp(sp->shp_x, sp->shp_y);
if (opt_FUEL &&
sectp->sct_own != 0 &&
sp->shp_fuel <= 0 &&
((struct mchrstr *)mlp->chrp)->m_fuelu != 0)
auto_fuel_ship(sp);
mlp->unit.ship.shp_fuel = sp->shp_fuel;
cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
sp->shp_destx[0], sp->shp_desty[0],

View file

@ -178,59 +178,3 @@ unload_it(struct shpstr *sp)
sectp->sct_pstage = PLG_EXPOSED;
}
}
/* 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.
* new autonav code.
* This should be merged with the fuel command someday.
* Chad Zabel 6/1/94
*/
void
auto_fuel_ship(struct shpstr *sp)
{
double d;
int totalfuel = 0;
int need;
int maxfuel;
int newfuel = 0;
int add_fuel = 0;
if (opt_FUEL == 0)
return;
getship(sp->shp_uid, sp); /* refresh */
/* fill with petrol */
maxfuel = mchr[(int)sp->shp_type].m_fuelc;
d = maxfuel / 5.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
I_PETROL, need);
add_fuel += newfuel * 5;
if (add_fuel > maxfuel)
add_fuel = maxfuel;
sp->shp_fuel += add_fuel;
totalfuel += add_fuel;
if (totalfuel == maxfuel) {
putship(sp->shp_uid, sp);
return; /* the ship is full */
}
add_fuel = 0;
/* fill with oil */
d = (maxfuel - totalfuel) / 50.0;
if (d - (int)d > 0.0)
d++;
need = (int)d;
newfuel = supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
I_OIL, need);
add_fuel = newfuel * 50;
if (add_fuel > maxfuel)
add_fuel = maxfuel;
sp->shp_fuel += add_fuel;
putship(sp->shp_uid, sp);
}