Commit graph

268 commits

Author SHA1 Message Date
c0ed527311 Consistently use int for file type parameters and locals 2009-12-29 17:23:22 +01:00
60519b3cd0 Consistently use int for mission type parameters 2009-12-29 13:06:35 +01:00
fd894d9864 Fix and enable collateral damage for missing missiles
Collateral damage was disabled, because after msl_hit() reported a
miss, the missile may or may not have reached the target.

Fix by splitting msl_launch() off msl_hit().

Drop the disabled collateral damage code for sector targets, because
sectors can't be missed.  Enable it for ships and land units.

Since msl_launch() returns whether the missile is sub-launched, drop
launch_missile() parameter sublaunch, and simplify its caller.
2009-12-13 08:05:26 +01:00
0060e48ea4 Refactor missile interception code
Keep only the common part in msl_intercept(), and give it internal
linkage.  Wrap new msl_abm_intercept() and msl_asat_intercept() around
it.  They are simpler to use.
2009-12-13 08:04:07 +01:00
eace95fab8 Get rid of msl_launch_mindam()
It's awkward, especially in shp_missile_interdiction().  Inline into
callers and simplify.
2009-12-13 08:04:07 +01:00
f7f3178ce2 Move msl_equip() to callers, internal linkage 2009-12-13 08:03:49 +01:00
a269cdd7e9 Limit nukes to strategic missions
Before Empire 2, nukes could be delivered only with bomb (special
mission 'n', airburst only) and launch (targeting sectors or
satellites only).

Empire 2 made nukes available for any kind of bombing, and for any
missile strike on sectors or ships.  This included interdiction and
support missions.  Nuclear-tipped anti-sats and bomb mission n were
removed.

Unfortunately, this was done in a messy way, which led to
inconsistencies and bugs.  The problem is that ordinary damage affects
just the target, while nuke damage affects an area.  Code dealing with
plane damage was designed for the former.  Instead of rewriting it to
cope with area damage cleanly, nuke damage got shoehorned into
pln_damage(), the function to compute conventional plane damage, as a
side effect: computing damage blasted sectors in the area.

If the plane carried a nuke, pln_damage() returned zero (conventional)
damage.  Without further logic, this simply bypassed the code to apply
damage to the target.  This worked out okay when the target already
got damaged correctly by the side effect.

However, some targets are immune to the side effect: when interdicting
a move or explore command, the commodities being moved are not in any
sector.

For other targets, damage has effects other than damaging the target:
offensive and defensive support don't apply the (conventional) damage
to the target sector.  Instead, they turn it into a combat bonus.
Without further logic, nuclear damage doesn't contribute to that.

To make all that work, pln_damage() returned the nuclear damage for
ground zero as well.  Because a plane does either conventional or
nuclear damage, one of them is always zero.

Most callers simply ignored the nuclear damage, and applied only the
conventional damage.

Bug: land units and ships failed to retreat when pin-bombed or
missiled with a nuke.  That's because they received zero conventional
damage.

The mission code flies planes and missiles and tallies their damage.
This mission damage included nuclear damage at ground zero (except for
missiles sometimes, see below), to make support and commodity
interdiction work.  Unfortunately, this broke other things.

Bug: when bombers interdicted ships or land units, nukes first damaged
the ships or land units by the side effect, then again through mission
damage.  Interdicting missiles had a special case to avoid this.

Bug: when interdicting move, explore or transport, nukes first damaged
the sector by the side effect, then again through mission damage's
collateral damage.

There may well be more bugs hiding in this mess.

The mess is not worth fixing.  While the idea of interdicting and
supporting with nukes sounds kind of cool, I believe it's pretty
irrelevant in actual play.

Instead, go back to a variation of the original rules: nukes can be
delivered only through bomb mission 's' and launch at sectors.

Make arm reject marine missiles in addition to satellites, ABMs and
SAMs, and clear the mission.  Make mission reject planes armed with
nukes.  Oops when they show up in mission_pln_equip() anyway.

Make pln_equip() allow planes with nukes only for missions 's' and
't'.

Clean up pln_damage() to just compute damage, without side effect.
Change strat_bomb() and launch_missile() to detonate nukes.  Simplify
the other callers.  Parameter mission of msl_launch_mindam() is now
unused, remove it.

Missiles exploding on launch no longer set off their nukes.  That was
pretty ridiculous anyway.
2009-12-13 07:46:00 +01:00
528df9acba Improve launch diagnostic messages, switch off supply
msl_equip() used mission_pln_equip(), which is for automatic defenses,
and therefore silent.  Its users launch_as(), launch_missile() and
launch_sat() printed failure diagnostics based on assumptions on what
could go wrong.

Switch to the appropriate function for commands, pln_equip(), and
remove the guesswork.  Implement mission 'i' there.  When launching
from a foreign base, its owner now gets informed.  Unimportant at this
time, as players can't easily deploy missiles in foreign bases.

This change also switches off automatic supply for launch.  Consistent
with bomb.
2009-12-12 16:28:52 +01:00
0fe43096bc Simplify calling of pln_arm() & friends
pln_arm(), pln_equip(), mission_pln_arm() mission_pln_equip() took a
mission parameter encoding the kind of sortie (strategic bomb,
pinpoint bomb, transport, ...), a flag parameter to further specify
the plane's role, and a parameter ip to specify the load.

The flags argument was always either P_F (intercept), P_F | P_ESC
(escort), or zero (any other role).

With non-zero flags, mission and ip argument were not used in any way.

Use mission 'e' and null load for escorts, and remove flags.
Intercept can still be identified by mission zero.

Also change pln_mobcost() to take a mission parameter instead of
flags, so that pln_arm() and mission_pln_arm() can simply pass on
their mission.
2009-12-08 08:15:51 +01:00
ad296698f9 Factor new lnd_sabo() out of sabo()
This permits giving seagun(), fortgun() and landunitgun() internal
linkage.
2009-12-05 15:19:37 +01:00
f760150d8f Rename plane_caps() to pln_caps() and give it external linkage 2009-03-08 17:14:59 +01:00
322f96ecb7 Redesign automatic supply interface
The automatic supply interface has design flaws that make it hard to
use correctly.  Its current uses are in fact all wrong (until commit
0179fd86, the update had a few uses that might have been correct).
Some of the bugs can only bite with land unit capability combinations
that don't exist in the stock game, though.

Automatic supply draws supplies from supply sources in range.  Since
that can update any supply source in range, all copies of potential
supply sources a caller may keep can get invalidated.  Writing back
such an invalid copy wipes out the deduction of supplies and mobility
from a source, triggering a seqno mismatch oops.

This commit redesigns the interface so that callers can safely keep a
copy of the object drawing the supplies (the "supply sink").  The idea
is to pass the sink to the supply code, so it can avoid using it as
source.  The actual avoiding will be implemented in a later commit.

Copies other than the supply sink still need to be eliminated.  See
commit 65410d16 for an example.

Other improvements to help avoid common errors:

* Supply functions are commonly used to ensure the sink has a certain
  amount of supplies.  A common error is to fetch that amount
  regardless of how many the sink already has.  It's more convenient
  for such users to pass how many they need to have instead of how
  many to get.

* A common use of supply functions is to get supplies for immediate
  use.  If that use turns out not to be possible after all, the
  supplies need to be added somewhere, which is all too easy to
  forget.  Many bugs of this kind have been fixed over time, and there
  are still some left.  This class of bugs can be avoided by adding
  the supplies to the sink automatically.

In fact, this commit fixes precisely such bugs in mission_pln_equip()
and shp_missile_defense(): plane interception and support missions,
missile interception (abms), launch of ballistic missiles and
anti-sats could all lose shells, or supply more than needed.

Replace supply_commod() by new sct_supply(), shp_supply(),
lnd_supply(), and resupply_all() by new lnd_supply_all().  Simplify
users accordingly.

There's just one use of resupply_commod() left, in landmine().  Use
lnd_supply_all() there, and remove resupply_commod().
2009-02-17 19:31:37 +01:00
5ea0d19c20 Fix automatic supply of defending and reacting units
Being in supply is relevant for defending and reacting units.  The
code used has_supply() to check that.

Contrary to its name, has_supply() does not check whether the land
unit has enough supplies to be in supply, but whether it has or could
draw enough.  So, defending and reacting units did not actually draw
any missing supplies.

Fix that in get_dlist() and att_reacting_units() by calling
resupply_all(), then checking with new lnd_in_supply() instead of
has_supply().  The fix of att_reacting_units() is complicated by the
fact that it is also used in the strength command, and should keep not
drawing supplies there.

Rename has_supply() to lnd_could_be_supplied().  Replace its uses
immediately after resupply_all() by lnd_in_supply().
2009-02-17 19:30:35 +01:00
9ff2c62309 Avoid repeated hours and game down status notifications
may_play_now() tells deities about hours restriction and game down
status.  It runs at login and before and after each command.  Getting
notified that often is annoying.

Avoid repetition by remembering notification in new player flags
PF_HOURS and PF_DOWN.  Add a notification when hours restriction has
been lifted.  Ensure the notification is printed before the prompt,
not before the command, by calling may_play_now() from command() only
for mortals.  Safe, because may_play_now() always returns true for
deities anyway.
2009-02-08 14:59:26 +01:00
e8926559d1 Move show_first_tel() from player.c to rea.c 2009-02-08 14:21:15 +01:00
d2cd46ce20 Don't log out deity when gamedown() can't read downfil
Broken in commit c7e2442d.  Fix by factoring show_first_tel() out of
gamedown() and show_motd().
2009-02-08 14:21:15 +01:00
35ef345ecb Update copyright notice 2009-02-08 09:33:18 +01:00
Ron Koenderink
c7e2442d3a Prevent command from executing after game is down
Move the gamedown() check from status to may_play_now() so it is
checked upon login, before a command is executed and after command
completion.  This fixes the situation where a player to could execute
one more command after the game was down.

Report to the deities that the game is down.

Remove to duplicate gamedown message.
2009-02-04 20:53:26 -06:00
6564ff2240 Integrate air defense missions into interception
The ancients designed interception dead simple: when you overfly a
sector, you get intercepted by the sector owner.  Fine print
interception rules govern which planes intercept.

Then complexity got piled on top of it.

Chainsaw 2 added an extra interception by surface ship owners, in the
target sector only.

Chainsaw 3 added an extra interception by land unit owners, in the
target sector only (Empire 4 later merged this extra land unit
interception with the extra surface ship interception).

Chainsaw 3 added an entirely separate kind of interception: air
defense missions.  When you enter a sector in some air defense op
area, you get intercepted.  Fine print air defense rules govern which
planes intercept.  These rules differ significantly from the
interception fine print.

Additional complexity comes from these facts:

* Air defense mission interception happens in addition to non-mission
  interception.  You can boost your total interception by setting up
  air defense.  Which means you must set it up, or forgo an advantage.

* Air defense planes are not available for non-mission interception
  duty.  You need to decide on a split.

* In contrast to non-mission interception, interceptors flying air
  defense get intercepted.

Moreover, the air defense code breaks one of the plane code's design
assumptions, namely that just one plane sortie is active at a time.
The air defense sortie runs while the sortie it intercepts is in
progress.  This leads to two interceptions being active at the same
time: the one intercepting the original sortie, and the one
intercepting the air defense sortie.  The same plane can fly in both
interceptions, and damage received in the interception of the air
defense sortie is wiped out, triggering a seqno mismatch oops.

The previous commit already simplified non-mission interception: you
get intercepted by anyone who owns the sector, or a surface ship or a
land unit there, whether it's the target sector or not.

Now simplify mission interception, by merging air defense back into
ordinary interception: when you overfly a sector, you get intercepted
by anyone who owns the sector, or a surface ship or land unit there,
or has an air defense mission covering the sector.  That's all.  No
multiple interceptions, no separate air defense rules.

Remove air_defense().  Simplify ac_encounter() and sam_intercept()
accordingly; both lose their last parameter.

Change sam_intercept() and ac_intercept() to intercept in mission op
areas.  New parameter only_mission to suppress non-mission
interception.  Pass zero when the intercepting country owns the sector
or a surface ship or land unit in the sector.

ac_encounter() can't efficiently predict whether a country intercepts,
so it needs to call ac_intercept() unconditionally.  This kills the
optimization to collect interceptors only when needed; simplify
accordingly, replacing getilist() by getilists().
2009-02-01 17:14:39 +01:00
b624ce30dd Pass only PM_* mission flags to ac_encounter()
Since the previous two commits, ac_encounter() checks its
mission_flags argument only for proper mission flags PM_R and PM_S,
not for plane flags P_A, P_S, P_I.

This makes the code to put plane flags into mission flags useless.
Remove it from bomb(), drop(), fly(), para(), reco(),
perform_mission(), mission_pln_arm(), air_defense(), pln_arm().

Much of that code was useless even before: P_X and P_H since Chainsaw
3 option STEALTHV became mandatory in Empire 2, and P_MINE since
commit cc0c3e4f (v4.3.0) cleaned up mine drops.
2009-02-01 17:14:38 +01:00
Ron Koenderink
d1ff2a6089 Factor out gamehours and max minutes per day checks
Combine the checks from player_main(), command() and status() into
may_play_now().
2009-02-01 06:29:57 -06:00
d5f371cc1d Remove oprange()'s mission parameter
Use the current mission instead.  Make mission() set it before calling
oprange(), and clean up somewhat.
2008-12-25 11:47:32 +01:00
7ac151acac Move show_mission() to sole caller, give it internal linkage 2008-12-25 11:47:32 +01:00
bf89453f8a Remove non-mission land unit reaction
Land unit reactions are overly complex because we have two different
concepts controlling them: reaction radius (set with lrange) and
reserve mission (set with mission).  You need to deal with both to set
up or query reactions.

Commit 8d0e1af5 "fixed" this by making reserve missions meaningless.

The previous commit made reserve missions meaningful again: they
support an op-area now.  This brought back the problem of having to
deal with two separate commands to accomplish one thing.

Fix this for good by removing non-mission land unit reaction
alltogether.  The only feature we lose by that is the ability to order
land units to react until the order is explicitely cancelled.  That's
because missions are implicitely cleared by many commands and events,
while non-mission reaction wasn't.  Closes #858121 and #858122.

Remove the non-mission reaction case from att_reacting_units().

Don't limit reserve missions to the land unit's reaction radius: make
lnd_reaction_range() return the type's maximum radius instead of
lnd_rad_max.

The reaction radius is now useless.  Remove the lrange command, and
struct lndstr member lnd_rad_max along with its selector react.
Remove land command's column rd.  Make ldump show column react as
zero.  Deprecate edit key 'P' in dounit(), and don't show it in
pr_land().
2008-12-25 11:47:05 +01:00
8e527b6cff Make land units on reserve mission react within op-area
Before, they always reacted to their maximum range, and the op-area
was unused.  Change mission() to define the op-area for reserve
missions as well.  Remove the special-case for showing reserve
missions from mission() and show_mission().  New lnd_reaction_range()
factored out of att_reacting_units().  Use it in oprange() to cover
reserve missions.  Pass the mission as separate parameter to oprange()
for now, because miss() doesn't set it in the object until later.
2008-12-17 12:30:43 -05:00
40d8357746 New in_oparea(), factored out of build_mission_list_type() 2008-12-17 11:37:55 -05:00
439fa2eadc Don't reduce mission op area when range shrinks
The mission command limits op area radius to the possible range.
That's okay, as it doesn't actually restrict possible op areas.  When
the mission is executed, it was limited again.  Don't do that; remove
the limiting code from build_mission_list_type() and show_mission().

The removed limiting had no effect, except when the range shrunk.
Then limiting reduced the op area more than necessary.  For instance,
consider an object O with initial range 3 on a mission around M with
range 3:

    - - - y - - -
     - - z y - -
    - - z x y - -
     - O x x M -
    - - z x y - -
     - - z y - -
    - - - y - - -

Initially, all sectors not marked - are in range and in the op area.
If the range drops to two, sectors marked O, x and z are still in
range of O.  But only the x are still in range of M.  The O and z got
excluded.

Range can currently shrink when plane range is reduced (range
command), or a ship, plane or land unit somehow loses tech (deity
intervention).
2008-12-17 11:36:49 -05:00
Ron Koenderink
875a80d14f Rewrite accounting of play time
Replace daychange() and gettimeleft() by update_timeused_login(),
update_timeused() and enforce_minimum_session_time().  The new
code doesn't assume the day is always 24 hours long which can
occur when transitioning into or out of DST and such.  Logging
in after more a multiple of 128 days now resets nat_timeused
properly.

Fix nat_timeused calculation on midnight rollover to include
the time since midnight.

struct natstr member nat_dayno and struct player member timeleft
are now unused, remove them.
2008-11-15 13:08:19 -06:00
cacc393c53 Age che just like reserves (1% per 24 ETUs)
Factor aging out of age_levels() into new age_people().  Use it in
do_feed() to age che.
2008-11-01 11:37:35 -04:00
Ron Koenderink
14319b89ec Represent logged in time in seconds rather than minutes
This simplifies things.  In particular, it gets rid of random rounding
in getcommand(), which created a variation in the nightly build
depending on whether the update starts before or after the deity logs
out.

Replace struct natstr member nat_minused by nat_timeused, and update
cou_ca[] accordingly (this affects xdump nat).  Replace player member
minleft by timeleft, and getminleft() by gettimeleft().  Update
getcommand(), daychange(), player_main(), status() accordingly, taking
care not to change player output.  Change edit country key 'u' to work
in seconds.
2008-10-28 08:48:25 -06:00
d702068457 Fix trailing whitespace 2008-09-17 21:31:40 -04:00
69b74bb5dd Remove takeover_ship() and takeover_land() parameter hostile
All callers pass non-zero.  Simplify accordingly.
2008-09-15 19:40:44 -04:00
f3651f17e5 Refactor and fix scuttle and scrap code
Factor unit_drop_cargo() out of scra(), scuttle_ship(),
scuttle_land(), fix it up:

* Some messages were sent as bulletins instead of printing them.

* Nukes were always destroyed.  They're now treated exactly like other
  cargo.

* scuttle destroyed some cargo silently, and listed other cargo as
  "scuttled".  It now simply lets unit_update_cargo() running from
  carrier prewrite callbacks list all cargo "lost".

Simplify its callers.  scuttle_ship() and scuttle_land() are now
trivial, inline and remove.
2008-09-15 19:40:13 -04:00
b024d57b38 Remove take_plane_off_ship(), take_plane_off_land()
Commit 3e370da5 left them pretty trivial.  Inline, simplify, remove.
2008-09-14 10:21:27 -04:00
e7f5b517a0 Make the item iterator capable of iterating over a cargo list
New snxtitem_cargo() initializes an iterator for a cargo list, with
new enum ns_seltype member NS_GROUP and new struct nstr_item member
next.  Extend nxtitem() and nxtitemp() to step through the list.
2008-09-12 18:46:54 -04:00
3e370da58c Get rid of ship and land unit load counters
Load counters are redundant; they can be computed from the carrier
uids.  Keeping them up-to-date as the carriers change is a pain, and
we never got that quite complete.

Computing load counters straight from the carrier uids every time we
need them would be rather inefficient, but computing them from cargo
lists is not.  So do that.

Remove the load counters: struct shpstr members shp_nplane,
shp_nchoppers, shp_nxlight, shp_nland, and struct lndstr members
lnd_nxlight and lnd_nland.

Don't compute/update load counters in build_ship(), build_land(),
land(), ldump(), load_plane_ship(), load_land_ship(),
load_plane_land(), load_land_land(), lstat(), sdump(), shi(), sstat(),
tend_land(), check_trade(), put_combat(), pln_oneway_to_carrier_ok),
pln_newlanding(), fit_plane_on_ship(), fit_plane_on_land(),
unit_list().

Nothing left in fit_plane_off_ship(), fit_plane_off_land(), so remove
them.

load_land_ship(), load_land_land(), check_trade(), pln_newlanding(),
put_plane_on_ship(), take_plane_off_ship(), put_plane_on_land(),
take_plane_off_land() no longer change the carrier, so don't put it.

Remove functions to recompute the load counters from carrier uids:
count_units(), lnd_count_units(), count_planes(), count_land_planes(),
pln_fixup() and lnd_fixup(), along with the latter two's private
copies of fit_plane_on_ship() and fit_plane_on_land().

New cargo list functions to compute load counts: unit_cargo_count()
and unit_nplane(), with convenience wrappers shp_nplane(),
shp_nland(), lnd_nxlight(), lnd_nland().

Use them to make ship selectors nplane, nchoppers, nxlight, nland
virtual.  They now reflect what is loaded, not how the load uses the
available slots.  This makes a difference when x-light planes or
choppers use plane slots.

Use them to make land unit selectors nxlight and nland virtual.

Use them to get load counts in land(), ldump(), load_plane_ship(),
load_land_ship(), load_plane_land(), load_land_land(), sdump(), shi(),
tend_land(), fit_plane_on_land(), trade_desc(), unit_list().

Rewrite fit_plane_on_ship() and could_be_on_ship() to use
shp_nplane().  could_be_on_ship() now takes load count arguments, as
computed by shp_nplane(), so it can be used for checking against an
existing load as well.
2008-09-08 21:32:56 -04:00
4086c25a15 Enable the new nuk_on_plane(), replacing the old one
Callers changed, as the new one isn't a drop-in replacements.
2008-09-08 21:32:52 -04:00
64a53c90f0 Cargo lists storing lists of cargo for each carrier
Persistent game state encodes "who carries what" by storing the
carrier uid in the cargo.  Cargo lists augment that: they store lists
of cargo for each carrier.  They are not persistent.

New unit_cargo_init() to compute the cargo lists from game state.
Call it in ef_init_srv() and at the end of update_main().

New unit_onresize() to resize the cargo list data structure.
Installed as units' struct empfile callback onresize to make them
resize automatically with the unit files.

New unit_carrier_change() to update cargo lists when carriers change
in game state.  Convenience wrappers pln_carrier_change(),
lnd_carrier_change() and nuk_carrier_change().  Call them from
prewrite callbacks to keep cargo lists in sync with game state.

To make that work, unused units must not point to a carrier.  Add new
pln_oninit(), lnd_oninit() and nuk_oninit() take care of newly created
units.  Change lnd_prewrite() and nuk_prewrite() to take dead land
units and nukes off their carrier.  pln_prewrite() did that already.

New unit_cargo_first(), unit_cargo_next() to traverse cargo lists.
Convenience wrappers lnd_first_on_ship(), lnd_first_on_land(),
lnd_next_on_unit(), pln_first_on_ship(), pln_first_on_land(),
pln_next_on_unit() and nuk_on_plane().  The latter is disabled for now
because it clashes with an existing function.
2008-09-08 21:30:39 -04:00
c5482e4bfb Pass old element to empfile callback prewrite()
Change sct_prewrite(), shp_prewrite(), pln_prewrite(), lnd_prewrite(),
nuk_prewrite() accordingly.  New argument isn't used for anything,
yet.
2008-09-08 21:26:40 -04:00
bf436a4498 Change empfile members postread() and prewrite() to return void
Callers ignore the value, and callees always return 1.  Pointless.
2008-09-03 20:43:13 -04:00
aee8272d3d Give some identifiers internal linkage
Give draw_map(), xdeval(), LwpSchedQ[], LwpDeadQ, LwpContextPtr,
LwpMaxpri, LwpStackGrowsDown internal linkage.
2008-08-09 08:40:04 -04:00
4b696a5c30 chkmoney() is no longer used, remove it 2008-08-09 08:40:04 -04:00
71bbd642df New show product
This is the human-readable buddy of xdump product, which dumps pchr[].
It duplicates much of the information in show sect c, but in more
accessible form.  It's in show_product().

Remove product information from info Quick-ref.  show reflects the
actual game, is more complete, and should be just as readable.
2008-07-28 07:51:49 -04:00
3cc8de8aef Fix extra prompt after abort due to misuse of snxtitem()
The old code used getstarg() to get an argument with a different
prompt than snxtitem() uses, then passed the value to snxtitem()
unchecked.  If the player aborts, getstarg() returns a null pointer,
and snxtitem() prompts again.  Affected:

* load/lload plane/land third argument; load_plane_ship(),
  load_land_ship(), load_plane_land(), load_land_land()

* bomb, drop, fly, paradrop, recon and sweep second argument;
  get_planes()

* tend and ltend second and fourth argument; ltend(), tend(),
  tend_land()

* mission second argument; mission()

Fix by making snxtitem() taking a prompt argument, null pointer
requests the old prompt.

Use that to simplify multifire() and torp().  Change the other callers
to pass NULL.
2008-07-26 21:36:37 -04:00
d3f644a37f New get_planes(), factored out of plane flying commands
No functional change.
2008-07-26 15:01:45 -04:00
f2294d67a4 Change pln_mine() parameters to match pln_dropoff()
This moves getting the target sector from caller into pln_mine().
Makes sense, because that's where it's put.
2008-07-12 14:53:46 -04:00
27edba1f1b Change pln_dropoff() parameters to match pln_newlanding()
This moves getting the target sector or ship from caller into
pln_dropoff().  Makes sense, because that's where it's put.
2008-07-12 14:53:28 -04:00
a233ecfea9 Remove columns lnd, pln from spy report to fix spy unit leak
The values in these columns were computed by count_sect_units() and
count_sect_planes(), which included land units and planes in the count
that aren't shown by prunits() and prplanes(), namely own and embarked
units.  Confusing.  Moreover, count_sect_planes() and prunits() rolled
dice separately for spy units.  This could leak the presence of spies
even when prunits() didn't show them.

All fixable, but not worth the trouble; just remove the counts.
2008-06-14 18:55:29 +02:00
0cc474bd6d Fix crash bug in satellite maps
The value of diffx() had the wrong sign when the arguments differed by
WORLD_X / 2.  Same for diffy() and WORLD_Y / 2.  satmap() used them to
find the vector from map center to ship or land unit to put on the
map, and got incorrect values for ships and land units directly
opposite to the center in x or y.  The bug made satmap() read a
pointer out bounds of its malloced radbuf[], and then write through
that with unpredictable consequences.

Broken in 4.2.12.  The original bug was in Empire 1.1: it
miscalculated where to put ships on the map (no crash).  An incomplete
fix for radmap() and satmap() appeared in Chainsaw 2 (still no crash).
radmap() got fixed correctly in Chainsaw 3, but satmap() was
forgotten.  That one got "fixed" in 4.2.7, and again in 4.2.12, but
both "fixes" were flawed and could crash.

Fix by backing out the flawed fixes and adopting the fix from radmap()
instead.
2008-05-13 08:36:06 +02:00
3b4de2feb1 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().
2008-05-12 09:25:20 +02:00