Commit graph

2979 commits

Author SHA1 Message Date
8e354e56c0 Update change log for 4.3.13 2008-04-06 22:00:25 +02:00
a291e6dd23 Belatedly update c_form of xdump command
Update for commit da8a1dae, v4.3.12.
2008-04-06 21:52:33 +02:00
4f5e2119c6 Put MAXNOC in xdump version
Create virtual selector nsc_ver_maxnoc() for it.
2008-04-06 15:03:37 +02:00
2725d6e736 Doc fix: don't claim empdump doesn't exist yet 2008-04-06 14:48:12 +02:00
7a0252e40a Fix initialization of realms in newcap
Broken in commit e1a68c72, v4.3.12.
2008-04-06 09:49:47 +02:00
793cc220ec Fix add of for status arguments active, god, delete
Broken in commit e1a68c72, v4.3.12.
2008-04-06 09:18:56 +02:00
ef00d65051 Bump version to 4.3.13 2008-04-06 09:18:51 +02:00
01106d3024 Remove unused unit stat development macros
Commit 0219bf08 hid all of them them away, but used only some of them
in their new home.  Clean up.
2008-04-04 20:35:09 +02:00
b47617004a Update change log for 4.3.12 2008-04-02 07:36:47 +02:00
1f9e884525 Don't make more babies than food permits
babies() rounded the maximum number of babies permitted by food.  When
this rounded up, grow_people() could use more food than available, and
the sector's food could become negative.  Fix by always rounding down.
2008-04-01 20:05:10 +02:00
fc6f1da568 Doc fix 2008-03-28 20:53:22 +01:00
0d09bdc8dc Remove src/scripts/tag-changeling, it's specific to CVS 2008-03-28 20:52:31 +01:00
a7cf600abc Update documentation to talk about git instead of CVS 2008-03-28 20:42:49 +01:00
2f5cad1997 Revert "Use XYOFFSET() instead of sctoff() in sector iterators"
This reverts commit d2ca7d4ed2.

Turns out the arguments are not always normalized, e.g. after
snxtitem_all().
2008-03-28 07:17:17 +01:00
Ron Koenderink
9a4f49f128 Add missing thread yield system call.
This change fixes a bug where the threads were not treated
fairly.  Before the fix, empth_yield would only yield to
threads already waiting hThreadMutex mutex.  It would not
yield to other threads ready to run from the release of other
mutexes.  An example of this is that the update task did
not start when force command was issued from script sequence.
2008-03-27 20:07:11 -06:00
e89a4b5657 Revert "Fix update's resupply of food to avoid starvation"
This reverts commit 03811b2c97.

That "fix" could actually conjure up food.  The resupply doesn't wipe
out food, because it resuppies from the sector itself.
2008-03-26 22:13:21 +01:00
15109ebef0 Fix empdump to check for export write errors 2008-03-26 22:13:21 +01:00
e5ef3d4840 Pass struct natstr * instead of natid to virtual selectors
This is because we want to define them in src/lib/global/, and code
there can't use getnatp(), because that requires
src/lib/common/file.c.  Which renders a cnum parameter pretty useless.

Virtual selectors requiring code from common/ could well come up again
in the future, but let's not worry about that now.
2008-03-26 22:13:21 +01:00
44295e43af No need to assign uid after ef_blank()
The redundant assignments should have been removed in commit 2da8d0c7.
2008-03-26 22:13:21 +01:00
ae8e347ed6 Fix the obvious bogosities in info launch 2008-03-26 22:13:21 +01:00
d5c9cfec28 Check pln_airbase_ok() in msl_sel()
The lack of base checking there permitted ship and land unit missile
interdiction and ballistic missile interception without a proper base.
2008-03-26 22:13:21 +01:00
52b303498e Replace laun()'s base checking code by pln_airbase_ok()
This outlaws launch from unowned sectors.  Also, non-VTOL missiles
require an efficient airfield now, except that such missiles don't
exist currently, because init_plchr() makes all missiles VTOL.
2008-03-26 22:13:17 +01:00
9e90aa173a Change launch not to destroy missiles stuck on foreign ships
When laun() refused to launch a missile because of its carrier's
nationality, it destroyed the missile.  Don't do that.
2008-03-26 22:13:04 +01:00
8d62bdb360 Fix launch_as() to use up supplies only when actually launching 2008-03-26 22:13:04 +01:00
15fab1c9a5 Fix launch to require petrol for launching satellites
launch_sat() failed to call msl_equip().  Change msl_equip() to take
the mission character as argument, because the old hardcoded 'p' isn't
appropriate for satellites.  Best fit for satellites is 'r' for
reconnaissance, but mission_pln_equip() doesn't accept that
(pln_equip() does).  Fix that as well.
2008-03-26 22:13:00 +01:00
ee863c5d25 Fix empdump not to depend on POGO's origin
Treat NATID_BAD as deity with absolute coordinates in nstr_exec_val()
and xdinit().  Use that in dump_table().
2008-03-26 22:12:07 +01:00
9c2a05e126 Make xnorm() and ynorm() use XNORM() and YNORM()
They duplicated them before.
2008-03-26 22:12:03 +01:00
ae835ff1db Simplify xrel() and yrel()
Value of XNORM() and YNORM() is in [0,WORLD_X) and [0,WORLD_Y),
respectively.
2008-03-26 22:11:23 +01:00
5f76428524 Simplify XNORM() and YNORM()
Simplify (M - (n % M)) % M  to M - (n % M), for n < 0.
2008-03-26 22:11:23 +01:00
9c8109768d Use nstr_sect member id instead of recomputing it
bmnxtsct() sets it.  The old code recomputed it with sctoff() without
checking for failure.  Not a bug, because it can't actually fail, just
confusing.
2008-03-26 22:11:23 +01:00
a530ea4d65 Doc fix 2008-03-26 22:11:23 +01:00
d2ca7d4ed2 Use XYOFFSET() instead of sctoff() in sector iterators
Old code didn't check value of sctoff() for success.  But it can't
fail, because we already took care of the condition that can make it
fail.  Moreover, the arguments are already normalized.  Therefore, we
can just call XYOFFSET().
2008-03-26 22:11:19 +01:00
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