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

@ -374,7 +374,6 @@ build_ship(struct sctstr *sp, struct mchrstr *mp, short *vec, int tlev)
ship.shp_orig_own = player->cnum;
ship.shp_orig_x = sp->sct_x;
ship.shp_orig_y = sp->sct_y;
ship.shp_fuel = mchr[(int)ship.shp_type].m_fuelc;
ship.shp_rflags = 0;
memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
shp_set_tech(&ship, tlev);
@ -490,7 +489,6 @@ build_land(struct sctstr *sp, struct lchrstr *lp, short *vec, int tlev)
land.lnd_nland = 0;
land.lnd_harden = 0;
land.lnd_retreat = morale_base;
land.lnd_fuel = lp->l_fuelc;
land.lnd_nxlight = 0;
land.lnd_rflags = 0;
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));

View file

@ -346,7 +346,6 @@ pr_land(struct lndstr *land)
pr("Tech <t>: %d\t\t", land->lnd_tech);
pr("Army <a>: %.1s\n", &land->lnd_army);
pr("Fortification <F>: %d\t", land->lnd_harden);
pr("Fuel <B>: %d\n", land->lnd_fuel);
pr("Land unit <Y>: %d\n", land->lnd_land);
pr("Ship <S>: %d\t\t", land->lnd_ship);
pr("Radius <P>: %d\n", land->lnd_rad_max);
@ -386,9 +385,6 @@ pr_ship(struct shpstr *ship)
pr("Efficiency <E>: %d\n", ship->shp_effic);
pr("Mobility <M>: %d\t\t", ship->shp_mobil);
pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
/* could depend on opt_FUEL - but a deity might want to set this
up before enabling the option */
pr("Fuel <B>: %d\n", ship->shp_fuel);
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
ship->shp_rpath, ship->shp_rflags);
pr("Plague Stage <a>: %d\t\t",ship->shp_pstage);
@ -810,7 +806,7 @@ doship(char op, int arg, char *p, struct shpstr *ship)
ship->shp_mobil = arg;
break;
case 'B':
ship->shp_fuel = errcheck(arg, 0, 255);
warn_deprecated(op);
break;
case 'F':
if (p[0] == '~')
@ -928,7 +924,7 @@ dounit(char op, int arg, char *p, struct lndstr *land)
land->lnd_harden = errcheck(arg, 0, 255);
break;
case 'B':
land->lnd_fuel = errcheck(arg, 0, 255);
warn_deprecated(op);
break;
case 'S':
land->lnd_ship = arg;

View file

@ -1,454 +0,0 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---
*
* See files README, COPYING and CREDITS in the root of the source
* tree for related information and legal notices. It is expected
* that future projects/authors will amend these files as needed.
*
* ---
*
* fuel.c: fuel ships/land units
*
* Known contributors to this file:
*
*/
#include <config.h>
#include <ctype.h>
#include "commands.h"
#include "empobj.h"
#include "optlist.h"
#include "plague.h"
int
fuel(void)
{
static int shp_or_lnd[] = { EF_SHIP, EF_LAND, EF_BAD };
struct nstr_item ni;
union empobj_storage item, item2;
int type;
struct mchrstr *mp;
struct lchrstr *lcp;
char *p;
int fueled;
int land_fuel, ship_fuel;
int oil_amt, pet_amt, fuel_amt, tot_fuel, max_amt;
int move_amt;
double extra;
struct sctstr sect;
struct natstr *natp;
int harbor, sector;
int fuelled_ship = -1;
struct nstr_item tender, ltender;
char prompt[128];
char buf[1024];
if (opt_FUEL == 0) {
pr("Option 'FUEL' not enabled\n");
return RET_SYN;
}
if ((p =
getstarg(player->argp[1], "Ship or land unit (s,l)? ", buf)) == 0)
return RET_SYN;
type = ef_byname_from(p, shp_or_lnd);
if (type < 0) {
pr("Ships or land units only! (s, l)\n");
return RET_SYN;
}
sprintf(prompt, "%s(s)? ", ef_nameof(type));
p = getstarg(player->argp[2], prompt, buf);
if (!snxtitem(&ni, type, p))
return RET_SYN;
if (isdigit(*p))
fuelled_ship = atoi(p);
p = getstarg(player->argp[3], "Amount: ", buf);
if (p == 0 || *p == 0)
return RET_SYN;
fuel_amt = atoi(p);
if (fuel_amt <= 0) {
pr("Fuel amount must be positive!\n");
return RET_FAIL;
}
while (nxtitem(&ni, &item)) {
fueled = 0;
if (type == EF_SHIP) {
if (item.ship.shp_own != player->cnum) {
int rel;
if (item.ship.shp_uid != fuelled_ship)
continue;
natp = getnatp(player->cnum);
rel = getrel(natp, item.ship.shp_own);
if (rel < FRIENDLY)
continue;
}
if (!getsect(item.ship.shp_x, item.ship.shp_y, &sect))
continue;
if (!item.ship.shp_own)
continue;
if (shp_check_nav(&sect, &item.ship) == CN_LANDLOCKED) {
pr("%s is landlocked and cannot be fueled.\n",
prship(&item.ship));
continue;
}
mp = &mchr[(int)item.ship.shp_type];
harbor = 0;
if (sect_has_dock(&sect)) {
harbor = 1;
oil_amt = sect.sct_item[I_OIL];
pet_amt = sect.sct_item[I_PETROL];
if ((oil_amt + pet_amt) == 0)
harbor = 0;
if (sect.sct_effic < 2) {
pr("The harbor at %s is not 2%% efficient yet.\n",
xyas(item.ship.shp_x, item.ship.shp_y,
player->cnum));
harbor = 0;
}
if ((sect.sct_own != player->cnum) && sect.sct_own)
harbor = 0;
}
if ((mp->m_fuelu == 0) && (item.ship.shp_own == player->cnum)) {
pr("%s does not use fuel!\n", prship(&item.ship));
continue;
}
if (harbor) {
ship_fuel = item.ship.shp_fuel;
oil_amt = sect.sct_item[I_OIL];
pet_amt = sect.sct_item[I_PETROL];
max_amt = mp->m_fuelc - ship_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",
prship(&item.ship));
continue;
}
tot_fuel = (oil_amt * 50 + pet_amt * 5);
if (tot_fuel == 0) {
pr("No fuel in the harbor at %s!\n",
xyas(sect.sct_x, sect.sct_y, player->cnum));
continue;
}
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
item.ship.shp_fuel += move_amt;
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5), 0);
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = move_amt / 50.0 - move_amt / 50;
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
sect.sct_item[I_OIL]
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
if (sect.sct_pstage == PLG_INFECT
&& item.ship.shp_pstage == PLG_HEALTHY)
item.ship.shp_pstage = PLG_EXPOSED;
putsect(&sect);
putship(item.ship.shp_uid, &item.ship);
} else { /* not in a harbor */
if (!player->argp[4])
pr("%s is not in a supplied, efficient harbor\n",
prship(&item.ship));
if (!snxtitem(&tender, EF_SHIP,
getstarg(player->argp[4], "Oiler? ", buf)))
continue;
if (!check_ship_ok(&item.ship))
continue;
if (!nxtitem(&tender, &item2))
continue;
if (!(mchr[(int)item2.ship.shp_type].m_flags & M_OILER)) {
pr("%s is not an oiler!\n", prship(&item2.ship));
continue;
}
if (item2.ship.shp_own != player->cnum) {
pr("You don't own that oiler!\n");
continue;
}
if ((item2.ship.shp_x != item.ship.shp_x) ||
(item2.ship.shp_y != item.ship.shp_y)) {
pr("Not in the same sector!\n");
continue;
}
ship_fuel = item.ship.shp_fuel;
oil_amt = item2.ship.shp_item[I_OIL];
pet_amt = item2.ship.shp_item[I_PETROL];
max_amt = mp->m_fuelc - ship_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",
prship(&item.ship));
continue;
}
tot_fuel = oil_amt * 50 + pet_amt * 5;
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
item.ship.shp_fuel += move_amt;
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
item2.ship.shp_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
item2.ship.shp_item[I_PETROL]
= MAX((pet_amt - move_amt / 5), 0);
} else {
item2.ship.shp_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = move_amt / 50.0 - move_amt / 50;
item2.ship.shp_item[I_OIL]
= MAX(oil_amt - (move_amt / 50), 0);
if (extra > 0.0)
item2.ship.shp_item[I_OIL]
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
item2.ship.shp_item[I_OIL]
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
if (item2.ship.shp_pstage == PLG_INFECT
&& item.ship.shp_pstage == PLG_HEALTHY)
item.ship.shp_pstage = PLG_EXPOSED;
putship(item.ship.shp_uid, &item.ship);
/* quick hack -KHS */
if (item.ship.shp_uid == item2.ship.shp_uid)
item2.ship.shp_fuel = item.ship.shp_fuel;
putship(item2.ship.shp_uid, &item2.ship);
}
pr("%s", prship(&item.ship));
} else {
if (item.land.lnd_own != player->cnum)
continue;
if (!getsect(item.land.lnd_x, item.land.lnd_y, &sect))
continue;
if (!player->owner)
continue;
lcp = &lchr[(int)item.land.lnd_type];
sector = 1;
oil_amt = sect.sct_item[I_OIL];
pet_amt = sect.sct_item[I_PETROL];
if ((oil_amt + pet_amt) == 0)
sector = 0;
if (lcp->l_fuelu == 0
&& (item.land.lnd_own == player->cnum)) {
pr("%s does not use fuel!\n", prland(&item.land));
continue;
}
if (sector) {
land_fuel = item.land.lnd_fuel;
oil_amt = sect.sct_item[I_OIL];
pet_amt = sect.sct_item[I_PETROL];
max_amt = lcp->l_fuelc - land_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",
prland(&item.land));
continue;
}
tot_fuel = (oil_amt * 50 + pet_amt * 5);
if (tot_fuel == 0) {
pr("No fuel in the sector at %s!\n",
xyas(sect.sct_x, sect.sct_y, player->cnum));
continue;
}
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
item.land.lnd_fuel += move_amt;
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5), 0);
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = move_amt / 50.0 - move_amt / 50;
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
sect.sct_item[I_OIL]
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
if (sect.sct_pstage == PLG_INFECT
&& item.land.lnd_pstage == PLG_HEALTHY)
item.land.lnd_pstage = PLG_EXPOSED;
putsect(&sect);
putland(item.land.lnd_uid, &item.land);
} else { /* not in a sector */
if (!player->argp[4])
pr("%s is not in a supplied sector\n",
prland(&item.land));
if (!snxtitem(&ltender, EF_LAND,
getstarg(player->argp[4], "Supply unit? ",
buf)))
continue;
if (!check_land_ok(&item.land))
continue;
if (!nxtitem(&ltender, &item2))
continue;
if (!(lchr[(int)item2.land.lnd_type].l_flags & L_SUPPLY)) {
pr("%s is not a supply unit!\n", prland(&item2.land));
continue;
}
if (item2.land.lnd_own != player->cnum) {
pr("You don't own that unit!\n");
continue;
}
if ((item2.land.lnd_x != item.land.lnd_x) ||
(item2.land.lnd_y != item.land.lnd_y)) {
pr("Not in the same sector!\n");
continue;
}
land_fuel = item.land.lnd_fuel;
oil_amt = item2.land.lnd_item[I_OIL];
pet_amt = item2.land.lnd_item[I_PETROL];
max_amt = lcp->l_fuelc - land_fuel;
if (max_amt == 0) {
pr("%s already has a full fuel load.\n",
prland(&item.land));
continue;
}
tot_fuel = oil_amt * 50 + pet_amt * 5;
move_amt = MIN(tot_fuel, fuel_amt);
move_amt = MIN(move_amt, max_amt);
if (move_amt == 0)
continue;
item.land.lnd_fuel += move_amt;
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
item2.land.lnd_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
else
item2.land.lnd_item[I_PETROL]
= MAX((pet_amt - move_amt / 5), 0);
} else {
item2.land.lnd_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = move_amt / 50.0 - move_amt / 50;
item2.land.lnd_item[I_OIL]
= MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
item2.land.lnd_item[I_OIL]
= MAX((oil_amt - move_amt / 50) - 1, 0);
else
item2.land.lnd_item[I_OIL]
= MAX((oil_amt - move_amt / 50), 0);
}
/* load plague */
if (item2.land.lnd_pstage == PLG_INFECT
&& item.land.lnd_pstage == PLG_HEALTHY)
item.land.lnd_pstage = PLG_EXPOSED;
putland(item.land.lnd_uid, &item.land);
/* quick hack -KHS */
if (item2.land.lnd_uid == item.land.lnd_uid)
item2.land.lnd_fuel = item.land.lnd_fuel;
putland(item2.land.lnd_uid, &item2.land);
}
pr("%s", prland(&item.land));
}
if (fueled) {
pr(" takes on %d fuel in %s\n",
move_amt,
xyas(item.ship.shp_x, item.ship.shp_y, player->cnum));
if (player->cnum != item.ship.shp_own)
wu(0, item.ship.shp_own,
"%s takes on %d fuel in %s courtesy of %s\n",
prship(&item.ship),
move_amt,
xyas(item.ship.shp_x, item.ship.shp_y,
item.ship.shp_own), cname(player->cnum));
}
}
return RET_OK;
}

View file

@ -60,8 +60,6 @@ land(void)
if (player->god)
pr("own ");
pr(" # unit type x,y a eff mil frt mu fd");
if (opt_FUEL)
pr(" fl");
pr(" tch retr rd xl ln carry\n");
}
if (land.lnd_off)
@ -77,8 +75,6 @@ land(void)
pr("%4d", land.lnd_harden);
pr("%4d", land.lnd_mobil);
pr("%4d", land.lnd_item[I_FOOD]);
if (opt_FUEL)
pr("%3d", land.lnd_fuel);
pr("%4d ", land.lnd_tech);
pr("%3d%%", land.lnd_retreat);
pr("%3d", land.lnd_rad_max);

View file

@ -337,10 +337,7 @@ ldump(void)
pr(" %d", land.lnd_item[I_FOOD]);
break;
case 10:
if (opt_FUEL)
pr(" %d", land.lnd_fuel);
else
pr(" 0");
pr(" 0");
break;
case 11:
pr(" %d", land.lnd_tech);

View file

@ -315,10 +315,7 @@ sdump(void)
pr(" %d", ship.shp_mobil);
break;
case 15:
if (opt_FUEL)
pr(" %d", ship.shp_fuel);
else
pr(" 0");
pr(" 0");
break;
case 16:
pr(" %d", ship.shp_tech);

View file

@ -59,8 +59,6 @@ shi(void)
pr("own ");
pr("shp# ship type x,y fl eff civ mil uw fd pn"
" he xl ln mob");
if (opt_FUEL)
pr(" fuel");
pr(" tech\n");
}
if (ship.shp_off)
@ -83,8 +81,6 @@ shi(void)
pr("%3d", ship.shp_nxlight);
pr("%3d", ship.shp_nland);
pr("%4d", ship.shp_mobil);
if (opt_FUEL)
pr("%5d", ship.shp_fuel);
pr("%5d\n", ship.shp_tech);
if (ship.shp_name[0] != 0) {
if (player->god)

View file

@ -162,9 +162,6 @@ vers(void)
pr("The starting mobility when acquiring a sector or unit is %d.\n",
-(etu_per_update / sect_mob_neg_factor));
pr("\n");
if (opt_FUEL)
pr("For ships and land units, fuelu makes %d mobility.\n\n",
fuel_mult);
pr("Ships on autonavigation may use %i cargo holds per ship.\n", TMAX);
if (opt_TRADESHIPS) {
pr("Trade-ships that go at least %d sectors get a return of %.1f%% per sector.\n",