Commit graph

2947 commits

Author SHA1 Message Date
a419904c70 Make newcap's second argument mandatory
The code to find a suitable sanctuary location is flawed: to find
space and resources around the location, it does a depth-first search
limited to 300 sectors.  Pretty useless when the limit is reached.  A
breadth-first search would work, but why bother?  This feature is
obscure and rarely (if ever) used: no conscientious deity would use it
for a real game, and for blitzes fairland does a better job.  Remove
it.
2008-03-26 22:10:29 +01:00
a0fa4550a8 Use sctstr member sct_uid instead of recomputing it
The old code recomputed it with sctoff() in some places, without
checking for failure.  Not a bug, because it can't actually fail, just
confusing.
2008-03-26 22:10:29 +01:00
f18502a1d1 Make would_abandon() more robust
Do the right thing when caller passes a larger amount than actually
there.
2008-03-26 22:10:28 +01:00
f89a1a711b Simplify would_abandon() 2008-03-26 22:10:28 +01:00
a55f5d016f Oops on unexpected mission in pln_equip() and mission_pln_equip() 2008-03-26 22:10:28 +01:00
3b8ff8a92d Use mission 0 instead of 'r' for air defense
reco() uses 'r' for reconnaissance.  sam_intercept() and
ac_intercept() use 0 for intercept.  Switch air_defense() to use 0 as
well.  No functional change, because 'r' and 0 behave the same, just
cleanup.
2008-03-26 22:10:28 +01:00
d8688508c4 Simplify mission_pln_equip()
Cases 't' and 'd' are identical.
2008-03-26 22:10:28 +01:00
ce7ab95c3b Check plane efficiency and capabilities earlier in pln_sel()
This way we don't complain about range to assembly point and
destination for planes that can't go regardless.
2008-03-26 22:10:28 +01:00
9e0950456d Simplify pln_equip() and mission_pln_equip()
Mission 'n' was removed along with nuke_bomb() many years ago.
Simplify accordingly.
2008-03-26 22:10:28 +01:00
feaa2dd938 Oops rather than complain to player on bad mission in bomb() 2008-03-26 22:10:28 +01:00
7ca4f412b1 Fix tracking of planes flying a sortie
Planes normally sit in their base (sector or carrier), where they can
be spied, damaged, captured, loaded, unloaded, upgraded and so forth.
All this must not be possible while they fly.  There are two kinds of
flying planes: satellites in orbit, and planes flying a sortie.

Satellites in orbit have always been marked with flag PLN_LAUNCHED.
Works.  What didn't work was tracking planes flying a sortie.

If you look at one sortie in isolation, up to three groups of planes
can be flying at any point of time: the primary group, which carries
out the sortie's mission (bomb, transport, ...), their escorts, and a
group of hostile planes flying interception or air defense.

The old code attempted to track these planes by passing those groups
to the places that need to know whether a plane is flying.  This was
complex and incomplete, and broke down completely for the pin-bombing
command.

It was complex, because the plane code needs to keep track of all the
call chains that can lead to a place that needs to know whether a
plane flies, and pass the groups down the call chains.  This leads to
a rather ugly passing of plane groups all over the place.

It was incomplete, because it generally failed to pass the escorts.

And the whole scheme broke down for the pin-bombing command.  That's
because pin-bombing asks the player for targets while his planes are
loitering above the target sector.  This yields the processor and lets
other code run.  Which does not get the flying planes passed.

The new code marks planes and SAMs (but not other missiles) flying a
sortie with flag PLN_LAUNCHED (the previous commit laid the groundwork
for that), and does away with passing around groups of flying planes.

This fixes the following bugs:

* Many commands could interact with foreign planes flying for a
  pin-bombing command as if they were sitting in their base.  This
  includes spying, damaging, capturing, loading, or upgrading them,
  and even getting intercepted by them.  Any changes to those planes
  were wiped out when they landed.  Abusable.

* The bomb command could bomb its own escorts, directly (pin-bomb
  planes) or through collateral damage, strategic sector damage,
  collapsing bridges or nuke damage.  The damage to the escorts was
  wiped out when they landed.

* If you asked for a plane to fly both in the primary group and the
  escort group, you got charged fuel for two sorties instead of one.

* pln_put1() and pln_put() now recognize planes that didn't take off,
  and refrain from making them land.  Intercept (since commit
  c64e2149) and air defense can do that.  Making them land had no
  ill-effects, but it was still wrong.

There's one new problem: if PLN_LAUNCHED doesn't get reset properly,
due to game crash during flight or some other bug, the plane gets
stuck in the air.  Catch and fix that on game start in ef_verify().
2008-03-26 22:10:13 +01:00
8006543878 Distinguish between planes "in orbit" and "launched"
Use new pln_is_in_orbit() when we want to test for orbit specifically,
and test PLN_LAUNCHED when we want to test whether the plane not
sitting in the sector (because it is flying).  This distinction is
pointless at this time, because the only way PLN_LAUNCHED gets set is
when a satellite goes into orbit.  It will become useful in a later
commit, which will use PLN_LAUNCHED to mark flying planes.
2008-03-26 22:09:09 +01:00
5e930f5fdf Factor out a single plane's end of sortie into new pln_put1()
Use it in pln_put() and ac_planedamage().

This changes ac_planedamage() to deal with a destroyed airbase.
Before, aborted planes happily landed there.  This bug could not
actually bite, because the code neither yields nor does damage to
potential airbases between checking the landing airbase before takeoff
and aborting planes in ac_planedamage().

It changes pln_put() to cope with dead planes.  Before, it made them
land as if they lived, fortunately without ill effects (complaints
about not being able to land were suppressed for dead planes).
ac_planedamage() removes dead planes, but pinflak_planedamage()
doesn't, and these end up in pln_put().  pinflak_planedamage() no
longer has to take shot down planes off their carriers, because
pln_put() now takes care of that.
2008-03-26 22:09:09 +01:00
1a75f8fe04 Oops when air_defense() somehow leaks interceptors 2008-03-26 22:09:06 +01:00
f105db1082 Fix memory leak in air_defense() oops
Broken in commit 9c27a771.
2008-03-26 22:08:46 +01:00
6fe12d0b7f Fix memory leaks in plane interception
Interception builds lists of planes that could intercept.  Only list
nodes for missiles were freed.  Broken since BSD Empire 1.1.

The fix frees interceptors that actually intercepted when
ac_intercept() returns, and the interceptors that didn't when
ac_encounter() returns.

The latter introduces a small bug: it passes planes that didn't fly to
pln_put().  pln_put() expects only planes that actually took off.
Same bug exists in air defense missions.  Luckily, it has no ill
effects.  To be fixed soon.
2008-03-26 22:08:15 +01:00
f7d5576675 Fix explanation pdump field of laun 2008-03-26 22:03:26 +01:00
65e934a083 Make pupgr() reject planes in orbit early
It's best to check and report conditions the player can't change
before those he could.
2008-03-26 22:03:23 +01:00
c69c5ff6d2 Fix trade to enforce destination rules for satellites and asats
Trade teleports planes to a destination chosen by the buyer, except
for satellites in orbit.  trad() failed to enforce the usual rules on
destinations for satellites (not in orbit) and asat missiles: they
could be teleported anywhere.  Abusable, because abms intercept from
anywhere, and satellites can be launched from unowned sectors, even
sea.  Broken since BSD Empire 1.1.
2008-03-26 22:02:45 +01:00
0a962c0380 Simplify calls to mpr()
mpr() does nothing when its first argument is zero.  No need to avoid
calling it in that case; remove the conditionals.
2008-03-22 11:04:53 +01:00
4c0d843c01 Make mpr()'s behavior on zero first argument more obvious 2008-03-22 11:04:16 +01:00
5fda0594e4 Remove mission_pln_arm()'s argument tech
It always existed, and was never used for anything.
2008-03-21 17:05:51 +01:00
ba710c1c7c Remove leftover test for anti-satellite nuke in detonate()
These existed in Chainsaw many years ago.
2008-03-21 17:03:30 +01:00
570ce80edf Fix fillcache() and do_write() error handling
Fix test for interrupted I/O.  Catch read hitting EOF unexpectedly.
Log errors in more detail.
2008-03-21 09:13:04 +01:00
54f1e9a07f Make empsched less loquacious on unrecognized options 2008-03-17 19:57:58 +01:00
b7c8a2e03f Fix empdump error messages to include program name 2008-03-17 19:55:42 +01:00
4525ae2d17 Change empdump syntax
Require -i for import, and fail when no action is requested.  Also
rename option -t to -n.
2008-03-17 19:54:08 +01:00
af8ff598aa Silence compiler warning on our getpwuid() for _WIN32 2008-03-17 19:08:34 +01:00
3de358e451 Journal the PRNG seed 2008-03-17 19:08:34 +01:00
e1b3a8239c Simplify how fire command parses third argument
Remove a useless strcpy() that truncated the argument to 19
characters.
2008-03-17 19:08:34 +01:00
ea43696e0d Clean up fire command's enum targ_type
You can't fire at land units.  target is never set to targ_unit, only
compared to it.  Remove.
2008-03-17 19:08:34 +01:00
38d8fd046f Simplify fire command's encoding of attacker
Use file types instead of enum targ_type.
2008-03-17 19:08:34 +01:00
7d14fb4495 Fix use of uninitialized variable in multifire()
multifire() used shots to print either shell or shells.  4.2.3 removed
its initialization for land unit fire, and commit 22c6fd8b removed it
for ship fire.  Fix by just printing shells always.
2008-03-17 19:08:33 +01:00
Ron Koenderink
975419e7d3 Remove nightly build configurations files that are not being used
This files are not current with nightlybuild.sh, common.sh
and report.sh.
2008-03-16 17:17:04 -06:00
Ron Koenderink
0b4ee6ac27 Remove pre_update_hook decoration
Improve the portability.  The Windows version of "echo" does
not support single quotes as a quoting character and therefore
fails and prevents updates in the Windows nightly build.
2008-03-16 17:09:00 -06:00
18acaf0e7d Don't write junk bits to unused bytes of telegram files
There are holes in struct telstr, which typed_wu() neglected to
initialize.  Fix that.
2008-03-14 21:22:32 +01:00
03811b2c97 Fix update's resupply of food to avoid starvation
do_feed() used supply_commod() incorrectly, which wiped out all food
in the starving sector.
2008-03-14 21:00:56 +01:00
f89edc7ae6 Fix return fire ammunition use in fire command
The old code let each defender fire on each target separately.  To
avoid charging ammo multiple times, it didn't update the defenders
after fire; it charged them in use_ammo() instead.  Bugs: not updating
the defender lost any shells fetched by automatic resupply, and
use_ammo() always charged one shell for gun fire, which was wrong for
most ships and land units.

Rewrite to let each defender fire once, updating it normally.  Reuse
the damage for the other targets.  This also yields the proper
probability distribution for damage.
2008-03-14 21:00:56 +01:00
942eddf533 New emp_searchque() 2008-03-14 21:00:29 +01:00
292f92f705 Simplify how fire command encodes lists of firing objects
Use file type rather than enum targ_type for struct flist member type.

Clean up natid vs. int sloppiness while there.
2008-03-14 21:00:26 +01:00
d741c45560 Simplify multifire() to silence compiler warning 2008-03-14 20:34:48 +01:00
7f4a5d0630 Simplify how fire command passes attacker to defend()
Pass attacker empobj instead of attacker's targ_type, sector (used for
targ_land), ship (used otherwise) and coordinates (used in either
case).
2008-03-14 20:34:44 +01:00
7b2574c167 Simplify how fire command passes defender to defend()
Pass defender country number instead of target type, sector (used if
target type is targ_land), and ship (used otherwise).
2008-03-14 20:25:45 +01:00
4babf726f0 Simplify quiet_bigdef()
Move common part of submarine and surface ship return fire out of the
conditional.

Use ni.curdist instead of recomputing the range.
2008-03-14 20:25:44 +01:00
3c7ea15195 Plug memory leak in fire command
add_to_fired_queue() adds a defender at most once.  It neglects to
free the defender flist nodes it doesn't add.  Broken since option
MULTIFIRE appeared in Chainsaw.
2008-03-14 20:25:44 +01:00
7ba662567f Fix commit 91eefc3f
It miscomputed size of configdir, resulting in excessive memory
allocation.
2008-03-14 20:25:44 +01:00
231947e41a Fix make distclean to remove generated sources.mk 2008-03-14 20:25:44 +01:00
09c21f8397 Bump version to 4.3.12 2008-03-14 20:25:44 +01:00
0dd6702df1 Update known contributors comments 2008-03-14 20:25:44 +01:00
726a8e3dae Make xundump catch extraneous fields
Make deffld() reject fields whose selector has flag NSC_EXTRA set.
Since xundump() doesn't provides space for these, the bug could lead
to buffer overruns.
2008-03-14 20:25:43 +01:00