]> git.pond.sub.org Git - empserver/log
empserver
16 years agoFix tracking of planes flying a sortie
Markus Armbruster [Sun, 23 Mar 2008 18:21:19 +0000 (19:21 +0100)]
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().

16 years agoDistinguish between planes "in orbit" and "launched"
Markus Armbruster [Sat, 22 Mar 2008 17:38:51 +0000 (18:38 +0100)]
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.

16 years agoFactor out a single plane's end of sortie into new pln_put1()
Markus Armbruster [Sat, 22 Mar 2008 13:55:30 +0000 (14:55 +0100)]
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.

16 years agoOops when air_defense() somehow leaks interceptors
Markus Armbruster [Sat, 22 Mar 2008 18:47:30 +0000 (19:47 +0100)]
Oops when air_defense() somehow leaks interceptors

16 years agoFix memory leak in air_defense() oops
Markus Armbruster [Sat, 22 Mar 2008 18:46:47 +0000 (19:46 +0100)]
Fix memory leak in air_defense() oops

Broken in commit 9c27a771.

16 years agoFix memory leaks in plane interception
Markus Armbruster [Sat, 22 Mar 2008 18:43:38 +0000 (19:43 +0100)]
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.

16 years agoFix explanation pdump field of laun
Markus Armbruster [Sat, 22 Mar 2008 17:38:29 +0000 (18:38 +0100)]
Fix explanation pdump field of laun

16 years agoMake pupgr() reject planes in orbit early
Markus Armbruster [Sat, 22 Mar 2008 17:25:39 +0000 (18:25 +0100)]
Make pupgr() reject planes in orbit early

It's best to check and report conditions the player can't change
before those he could.

16 years agoFix trade to enforce destination rules for satellites and asats
Markus Armbruster [Sat, 22 Mar 2008 16:41:37 +0000 (17:41 +0100)]
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.

16 years agoSimplify calls to mpr()
Markus Armbruster [Sat, 22 Mar 2008 10:04:53 +0000 (11:04 +0100)]
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.

16 years agoMake mpr()'s behavior on zero first argument more obvious
Markus Armbruster [Sat, 22 Mar 2008 09:07:37 +0000 (10:07 +0100)]
Make mpr()'s behavior on zero first argument more obvious

16 years agoRemove mission_pln_arm()'s argument tech
Markus Armbruster [Fri, 21 Mar 2008 16:05:51 +0000 (17:05 +0100)]
Remove mission_pln_arm()'s argument tech

It always existed, and was never used for anything.

16 years agoRemove leftover test for anti-satellite nuke in detonate()
Markus Armbruster [Fri, 21 Mar 2008 16:03:30 +0000 (17:03 +0100)]
Remove leftover test for anti-satellite nuke in detonate()

These existed in Chainsaw many years ago.

16 years agoFix fillcache() and do_write() error handling
Markus Armbruster [Fri, 21 Mar 2008 08:13:04 +0000 (09:13 +0100)]
Fix fillcache() and do_write() error handling

Fix test for interrupted I/O.  Catch read hitting EOF unexpectedly.
Log errors in more detail.

16 years agoMake empsched less loquacious on unrecognized options
Markus Armbruster [Mon, 17 Mar 2008 18:57:58 +0000 (19:57 +0100)]
Make empsched less loquacious on unrecognized options

16 years agoFix empdump error messages to include program name
Markus Armbruster [Mon, 17 Mar 2008 18:55:42 +0000 (19:55 +0100)]
Fix empdump error messages to include program name

16 years agoChange empdump syntax
Markus Armbruster [Mon, 17 Mar 2008 18:54:08 +0000 (19:54 +0100)]
Change empdump syntax

Require -i for import, and fail when no action is requested.  Also
rename option -t to -n.

16 years agoSilence compiler warning on our getpwuid() for _WIN32
Markus Armbruster [Sun, 16 Mar 2008 11:59:48 +0000 (12:59 +0100)]
Silence compiler warning on our getpwuid() for _WIN32

16 years agoJournal the PRNG seed
Markus Armbruster [Sun, 16 Mar 2008 11:56:03 +0000 (12:56 +0100)]
Journal the PRNG seed

16 years agoSimplify how fire command parses third argument
Markus Armbruster [Sat, 15 Mar 2008 07:26:35 +0000 (08:26 +0100)]
Simplify how fire command parses third argument

Remove a useless strcpy() that truncated the argument to 19
characters.

16 years agoClean up fire command's enum targ_type
Markus Armbruster [Sat, 15 Mar 2008 07:24:04 +0000 (08:24 +0100)]
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.

16 years agoSimplify fire command's encoding of attacker
Markus Armbruster [Sat, 15 Mar 2008 07:08:59 +0000 (08:08 +0100)]
Simplify fire command's encoding of attacker

Use file types instead of enum targ_type.

16 years agoFix use of uninitialized variable in multifire()
Markus Armbruster [Sat, 15 Mar 2008 06:51:25 +0000 (07:51 +0100)]
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.

16 years agoRemove nightly build configurations files that are not being used
Ron Koenderink [Sun, 16 Mar 2008 23:17:04 +0000 (17:17 -0600)]
Remove nightly build configurations files that are not being used

This files are not current with nightlybuild.sh, common.sh
and report.sh.

16 years agoRemove pre_update_hook decoration
Ron Koenderink [Sun, 16 Mar 2008 23:09:00 +0000 (17:09 -0600)]
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.

16 years agoDon't write junk bits to unused bytes of telegram files
Markus Armbruster [Fri, 14 Mar 2008 20:22:32 +0000 (21:22 +0100)]
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.

16 years agoFix update's resupply of food to avoid starvation
Markus Armbruster [Fri, 14 Mar 2008 19:01:23 +0000 (20:01 +0100)]
Fix update's resupply of food to avoid starvation

do_feed() used supply_commod() incorrectly, which wiped out all food
in the starving sector.

16 years agoFix return fire ammunition use in fire command
Markus Armbruster [Fri, 14 Mar 2008 19:00:48 +0000 (20:00 +0100)]
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.

16 years agoNew emp_searchque()
Markus Armbruster [Thu, 13 Mar 2008 21:30:43 +0000 (22:30 +0100)]
New emp_searchque()

16 years agoSimplify how fire command encodes lists of firing objects
Markus Armbruster [Fri, 14 Mar 2008 19:00:30 +0000 (20:00 +0100)]
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.

16 years agoSimplify multifire() to silence compiler warning
Markus Armbruster [Thu, 13 Mar 2008 21:34:44 +0000 (22:34 +0100)]
Simplify multifire() to silence compiler warning

16 years agoSimplify how fire command passes attacker to defend()
Markus Armbruster [Thu, 13 Mar 2008 21:05:36 +0000 (22:05 +0100)]
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).

16 years agoSimplify how fire command passes defender to defend()
Markus Armbruster [Thu, 13 Mar 2008 20:32:12 +0000 (21:32 +0100)]
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).

16 years agoSimplify quiet_bigdef()
Markus Armbruster [Thu, 13 Mar 2008 19:34:04 +0000 (20:34 +0100)]
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.

16 years agoPlug memory leak in fire command
Markus Armbruster [Thu, 13 Mar 2008 19:06:13 +0000 (20:06 +0100)]
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.

16 years agoFix commit 91eefc3f
Markus Armbruster [Thu, 13 Mar 2008 18:22:21 +0000 (19:22 +0100)]
Fix commit 91eefc3f

It miscomputed size of configdir, resulting in excessive memory
allocation.

16 years agoFix make distclean to remove generated sources.mk
Markus Armbruster [Sun, 9 Mar 2008 17:19:07 +0000 (18:19 +0100)]
Fix make distclean to remove generated sources.mk

16 years agoBump version to 4.3.12
Markus Armbruster [Sun, 9 Mar 2008 17:06:13 +0000 (18:06 +0100)]
Bump version to 4.3.12

16 years agoUpdate known contributors comments
Markus Armbruster [Sun, 9 Mar 2008 15:26:27 +0000 (16:26 +0100)]
Update known contributors comments

16 years agoMake xundump catch extraneous fields
Markus Armbruster [Sun, 9 Mar 2008 12:50:00 +0000 (13:50 +0100)]
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.

16 years agoFix stmtch() for exact match after multiple partial matches
Markus Armbruster [Sun, 9 Mar 2008 12:45:29 +0000 (13:45 +0100)]
Fix stmtch() for exact match after multiple partial matches

Keep looking for exact match after finding the second partial match.

16 years agoNew timestamp selectors
Markus Armbruster [Sun, 9 Mar 2008 12:41:13 +0000 (13:41 +0100)]
New timestamp selectors

New timestamp selector for commodity, country, game, loan, nation,
news, trade, treaty.

16 years agoSet timestamp automatically on write
Markus Armbruster [Wed, 5 Mar 2008 21:43:10 +0000 (22:43 +0100)]
Set timestamp automatically on write

Do it in do_write().  Remove the setting of timestamps elsewhere.

This fixes empdump to set timestamps to the current time instead of
zero on import.

16 years agoPut a timestamp into struct emptypedstr
Markus Armbruster [Wed, 5 Mar 2008 21:36:48 +0000 (22:36 +0100)]
Put a timestamp into struct emptypedstr

Make sure all members of unit empobj_storage share it.

Add matching timestamp member to struct comstr, struct empobj, struct
gamestr, struct lonstr, struct natstr, struct nwsstr, struct trdstr,
struct trtstr.  The timestamp isn't yet set for these.  To be fixed.

Move the timestamp member to the right place in struct lndstr, struct
loststr, struct realmstr, struct nukstr, struct plnstr, struct sctstr,
struct shpstr.

16 years agoFactor common code out of add() and new() into nat_reset()
Markus Armbruster [Wed, 5 Mar 2008 21:21:08 +0000 (22:21 +0100)]
Factor common code out of add() and new() into nat_reset()

The common nation wipe code is not quite identical, and it doesn't
wipe the nation thoroughly enough.  The new code does.

Changes to both commands:

* Wipe nat_update, nat_ann, nat_access, and nat_contact.  Bug: should
  set nat_ann to the number of announcements.

Changes to add command:

* Don't wipe for status active and god.  Before, nat_relate and
  nat_flags where wiped then.

Changes to newcap command:

* Wipe nat_hostaddr, nat_hostname, nat_userid, nat_dayno, nat_minused,
  nat_reserve, nat_last_login, nat_last_logout, nat_newstim,
  nat_annotim, nat_relate, nat_rejects, nat_flags.

16 years agoUpdate indent-emp for removed typedef names, belatedly.
Markus Armbruster [Wed, 5 Mar 2008 05:10:54 +0000 (06:10 +0100)]
Update indent-emp for removed typedef names, belatedly.

16 years agoReplace some typedef names by enum tags.
Markus Armbruster [Wed, 5 Mar 2008 05:09:48 +0000 (06:09 +0100)]
Replace some typedef names by enum tags.

Also get rid of some mildly silly manual packing of enum types.

16 years agoNew utility program empdump
Markus Armbruster [Tue, 4 Mar 2008 20:55:29 +0000 (21:55 +0100)]
New utility program empdump

empdump exports and imports game state as plain text.  Limitations: it
currently can't export player bmaps, power report, telegrams,
announcements, message of the day, no-login message and log files.
Exported floating-point values may be inexact.  Importing an exported
game state may not result in identical data files; besides the loss of
floating-point precision just mentioned, coordinates are normalized,
and characters beyond a string's terminating zero in a character array
are lost.  Bug: importing resets timestamps to zero.  It should set
them to the current time.

16 years agoImplement human-readable dialect for xdump
Markus Armbruster [Tue, 4 Mar 2008 20:49:44 +0000 (21:49 +0100)]
Implement human-readable dialect for xdump

This is for the forthcoming empdump utility program.  The xdump
command still does not support the human-readable dialect.

xundump has supported the human-readable dialect for a long time
(commit 4871a10a).

16 years agoMake xundump interpret escapes in identifiers
Markus Armbruster [Tue, 4 Mar 2008 20:41:26 +0000 (21:41 +0100)]
Make xundump interpret escapes in identifiers

We need this because we have symbols with spaces, e.g. missions[].

16 years agoMinor xdump documentation edit
Markus Armbruster [Tue, 4 Mar 2008 20:38:59 +0000 (21:38 +0100)]
Minor xdump documentation edit

16 years agoMake xdump code available for future use outside the server
Markus Armbruster [Fri, 8 Feb 2008 20:51:24 +0000 (21:51 +0100)]
Make xdump code available for future use outside the server

Move the bits useful there from src/lib/commands/xdump.c to new
include/xdump.h and src/lib/common/xdump.c.

16 years agoPrepare some xdump code for future use outside the server
Markus Armbruster [Fri, 8 Feb 2008 20:12:43 +0000 (21:12 +0100)]
Prepare some xdump code for future use outside the server

We don't have player->cnum, player->god and pr() there.  Pass
parameters instead.

16 years agoDon't store land unit stats in struct lndstr, part 2
Markus Armbruster [Tue, 4 Mar 2008 20:27:30 +0000 (21:27 +0100)]
Don't store land unit stats in struct lndstr, part 2

struct lndstr members lnd_spy, lnd_rad, lnd_ammo, lnd_fuelc,
lnd_fuelu, lnd_maxlight, lnd_maxlight are mere copies of struct
lchrstr members l_spy, l_rad, l_ammo, l_fuelc, l_fuelu, l_nxlight,
l_nland.  Remove them.

Make land unit selectors spy, rmax, ammo, fuelc, fuelu, maxlight
virtual.

16 years agoDon't store land unit stats in struct lndstr, part 1
Markus Armbruster [Tue, 4 Mar 2008 20:20:23 +0000 (21:20 +0100)]
Don't store land unit stats in struct lndstr, part 1

New lnd_att(), lnd_def(), lnd_vul(), lnd_spd(), lnd_vis(), lnd_frg(),
lnd_acc(), lnd_dam(), lnd_aaf() replace the struct lndstr members with
the same names.

Make land unit selectors att, def, vul, spd, vis, frg, acc, dam, aaf
virtual.

16 years agoDon't store ship stats in struct shpstr
Markus Armbruster [Tue, 4 Mar 2008 20:15:59 +0000 (21:15 +0100)]
Don't store ship stats in struct shpstr

New shp_armor(), shp_speed(), shp_visib(), shp_frnge(), shp_glim()
replace the struct shpstr members with the same names.

16 years agoDon't store plane stats in struct plnstr
Markus Armbruster [Tue, 4 Mar 2008 20:09:32 +0000 (21:09 +0100)]
Don't store plane stats in struct plnstr

New pln_att(), pln_def(), pln_acc(), pln_range_max(), pln_load()
replace the struct plnstr members with the same names.

Make plane selectors att and def virtual.

16 years agoNew nstr_mksymval() to create symbolic values
Markus Armbruster [Tue, 4 Mar 2008 09:29:49 +0000 (10:29 +0100)]
New nstr_mksymval() to create symbolic values

16 years agoVirtual selectors
Markus Armbruster [Tue, 4 Mar 2008 20:02:00 +0000 (21:02 +0100)]
Virtual selectors

Where ordinary selectors specify a value stored in some object,
virtual selectors specify a function to call to compute a value
associated with some object.

Use them to replace the special case xdump ver by new table
EF_VERSION.

Move configkeys[] to lib/common because nsc_init() needs it to
initialize empfile[EF_VERSION].cadef.

16 years agoReorder members of struct castr to make nsc.c easier to read
Markus Armbruster [Tue, 4 Mar 2008 19:27:26 +0000 (20:27 +0100)]
Reorder members of struct castr to make nsc.c easier to read

16 years agoMake nstr_exec oops on bad operator
Markus Armbruster [Tue, 4 Mar 2008 07:10:05 +0000 (08:10 +0100)]
Make nstr_exec oops on bad operator

16 years agoMake nstr_exec_val() return its first argument
Markus Armbruster [Tue, 4 Mar 2008 07:03:01 +0000 (08:03 +0100)]
Make nstr_exec_val() return its first argument

16 years agoMake nstr_exec_val() more robust
Markus Armbruster [Tue, 4 Mar 2008 06:55:32 +0000 (07:55 +0100)]
Make nstr_exec_val() more robust

Oops on bad argument, and make a better error value then.

16 years agoMove nstr_promote() to src/lib/common/, external linkage
Markus Armbruster [Tue, 4 Mar 2008 06:51:56 +0000 (07:51 +0100)]
Move nstr_promote() to src/lib/common/, external linkage

16 years agoDocument nsc.h more completely
Markus Armbruster [Tue, 4 Mar 2008 06:47:06 +0000 (07:47 +0100)]
Document nsc.h more completely

16 years agoFix documentation of empfile[] contents
Markus Armbruster [Tue, 4 Mar 2008 06:43:23 +0000 (07:43 +0100)]
Fix documentation of empfile[] contents

16 years agoMake xdprval() oops on bad argument
Markus Armbruster [Mon, 3 Mar 2008 20:43:36 +0000 (21:43 +0100)]
Make xdprval() oops on bad argument

16 years agoFix oops recovery in xdprval()
Markus Armbruster [Mon, 3 Mar 2008 20:40:22 +0000 (21:40 +0100)]
Fix oops recovery in xdprval()

Failed to print the separator, which could run fields together.

16 years agoFactor out torpedo hit chance into shp_torp_hitchance()
Markus Armbruster [Mon, 3 Mar 2008 19:59:39 +0000 (20:59 +0100)]
Factor out torpedo hit chance into shp_torp_hitchance()

16 years agoFactor out ship usable gun calculation into shp_usable_gun()
Markus Armbruster [Mon, 3 Mar 2008 19:33:54 +0000 (20:33 +0100)]
Factor out ship usable gun calculation into shp_usable_gun()

16 years agoGive effrange() internal linkage.
Markus Armbruster [Mon, 3 Mar 2008 19:28:03 +0000 (20:28 +0100)]
Give effrange() internal linkage.

16 years agoFactor out land unit firing range calculation into lnd_fire_range()
Markus Armbruster [Mon, 3 Mar 2008 19:24:52 +0000 (20:24 +0100)]
Factor out land unit firing range calculation into lnd_fire_range()

16 years agoFactor out ship firing range calculation into shp_fire_range()
Markus Armbruster [Mon, 3 Mar 2008 19:20:39 +0000 (20:20 +0100)]
Factor out ship firing range calculation into shp_fire_range()

16 years agoTighten gcc warning options
Markus Armbruster [Mon, 3 Mar 2008 19:12:46 +0000 (20:12 +0100)]
Tighten gcc warning options

Suppress only unused parameters, not all unused stuff.

16 years agoRemove an unused variable in fit_plane_off_land()
Markus Armbruster [Mon, 3 Mar 2008 19:09:26 +0000 (20:09 +0100)]
Remove an unused variable in fit_plane_off_land()

16 years agoRemove dead code for estimating defense
Markus Armbruster [Mon, 3 Mar 2008 19:08:43 +0000 (20:08 +0100)]
Remove dead code for estimating defense

Clean up of intelligence_report().  Should have been done in commit
092a52f2.

16 years agouse_supply() is now unused, remove
Markus Armbruster [Mon, 3 Mar 2008 07:31:03 +0000 (08:31 +0100)]
use_supply() is now unused, remove

16 years agoFactor out common land unit fire code into lnd_fire()
Markus Armbruster [Mon, 3 Mar 2008 07:29:52 +0000 (08:29 +0100)]
Factor out common land unit fire code into lnd_fire()

This takes care of a number of bugs / inconsistencies:

* Resupply before fire: fire command did not require unit to be in
  supply, and resupplied shells.  Everywhere else (return fire,
  support and interdiction) the land unit had to be in supply after
  resupply of everything.  Unify not to resupply anything and not to
  require being in supply.  This is consistent with ships and sectors.

* Resupply after fire: fire command resupplied shells after active
  fire.  Unify not to do that.  This is consistent with ships and
  sectors.

* When a land unit returned fire to multiple attackers, quiet_bigdef()
  charged it ammo for each one.  Finally, it was charged one shell
  more by use_ammo().  Except only the first land unit got charged
  there in fact, because buggy add_to_fired_queue() entered only the
  first land unit into the defender list.  Fix add_to_fired_queue()
  and change quiet_bigdef() not to charge ammo, just like for ships
  and sectors.  This charges only one shell instead of the true ammo
  use, which is wrong, but consistent with ships.

* lnd_support() tallied support damage unrounded.  Unify to round
  before tally.

16 years agoSimplify torpedo return fire logic
Markus Armbruster [Sun, 2 Mar 2008 21:19:57 +0000 (22:19 +0100)]
Simplify torpedo return fire logic

Don't bother checking capabilities that will be checked again later,
just try torpedo, then depth charge / gun fire.

16 years agoFactor out common torpedo fire code into shp_torp()
Markus Armbruster [Sun, 2 Mar 2008 14:45:41 +0000 (15:45 +0100)]
Factor out common torpedo fire code into shp_torp()

This takes care of a number of bugs / inconsistencies:

* Submarines with zero mobility could interdict.  Change to require
  positive mobility.

* Submarines with zero firing range could not interdict.  Fix by
  dropping the test from perform_mission().  No ships in the stock
  game are affected.

* Submarines without capability torp could fire return torpedoes and
  interdict.  Stock sbc, nm and msb were affected by the return fire
  bug.  Closes bug#950936.

* Shell resupply bugs: quiet_bigdef(), fire_torp() and
  perform_mission() resupplied before checking all other requirements
  and could thus get more shells than actually needed.

torp() no longer resupplies shells.  It's hardly worth the bother, and
fire doesn't do it either.

16 years agoFix torpedo return fire line of sight requirement and range
Markus Armbruster [Sun, 2 Mar 2008 13:05:31 +0000 (14:05 +0100)]
Fix torpedo return fire line of sight requirement and range

anti_torp() required line of sight and used gun range for all kinds of
return fire.  Require line of sight only for torpedoes, not for gun
fire and depth charges.  Use torpedo range for torpedoes, gun range
for gun fire and depth charges.

16 years agoChange test whether a land unit is artillery
Markus Armbruster [Mon, 3 Mar 2008 06:29:24 +0000 (07:29 +0100)]
Change test whether a land unit is artillery

Test for land unit firing damage instead of range, for consistency
with ships.

16 years agoFactor out common ship gun fire code into shp_fire()
Markus Armbruster [Sun, 2 Mar 2008 10:59:56 +0000 (11:59 +0100)]
Factor out common ship gun fire code into shp_fire()

This takes care of a number of bugs / inconsistencies:

* Ships with zero firing range could return fire and fire support, but
  not fire actively or interdict.  Fix by testing for gun limit
  instead in multifire() and mission().  No ships in the stock game
  are affected.

* Required gun crew was inconsistent: multifire() let N military fire
  max(1,floor(N/2)) guns for active fire.  Ditto perform_mission() for
  interdiction.  quiet_bigdef() let them fire N guns for returning gun
  fire.  Ditto sd() for firing support and firing at boarding parties.
  fire_dchrg() let them fire floor(N/2) for returning fire to
  torpedoes.  Unify to let N military fire floor((N+1)/2) guns.

* Shell use was inconsistent: sd() and perform_mission() used one
  shell per gun, everything else one per two guns.  Unify to one shell
  per two guns.

* Shell resupply bugs: multifire() got two shells regardless of actual
  ammo use.  quiet_bigdef() got one shell (but use_ammo() uses only
  one, which is a bug).  sd() and perform_mission() resupplied before
  checking all other requirements and could thus get more shells than
  actually needed.

16 years agoMake depth-charging code and documentation match
Markus Armbruster [Sun, 2 Mar 2008 10:01:42 +0000 (11:01 +0100)]
Make depth-charging code and documentation match

Before 4.0.6, depth charges required no guns, one military, did damage
like shell fire from two guns, and used two shells.  Missions were not
quite consistent with that (bug).  4.0.6 changed depth charges to work
exactly like shell fire (but without updating documentation
accordingly): require guns and gun crew, non-zero firing range, scale
damage and ammunition use with guns.

Go back to the old model, but with damage like three guns, to avoid
changing the stock game's dd now (three gun damage for two shells).
Stock game's af changes from two gun damage for one shell, and nas
from four gun damage for two shells.

Factor out common depth-charging code into shp_dchrg().

16 years agoFactor out common fortress fire code into fort_fire()
Markus Armbruster [Fri, 14 Mar 2008 19:01:05 +0000 (20:01 +0100)]
Factor out common fortress fire code into fort_fire()

This takes care of a number of bugs / inconsistencies:

* sb() fired support even when there were not enough mil.

* Shell resupply bugs: multifire() and quiet_bigdef() resupplied
  shells before checking all other requirements and could thus get
  more shells than actually needed.

Rename landgun() to fortgun() for consistency.

16 years agoInclude system headers before ours
Markus Armbruster [Fri, 29 Feb 2008 06:09:34 +0000 (07:09 +0100)]
Include system headers before ours

16 years agoGive logx() internal linkage
Markus Armbruster [Fri, 29 Feb 2008 06:08:59 +0000 (07:08 +0100)]
Give logx() internal linkage

16 years agoNew unit stat development functions
Markus Armbruster [Fri, 29 Feb 2008 05:49:18 +0000 (06:49 +0100)]
New unit stat development functions

The macros defining unit stat development in tech are somewhat
inconvenient to use.  Define more convenient functions, and hide away
the macros near the function definitions.

16 years agoConvert a CANT_HAPPEN() to CANT_REACH()
Markus Armbruster [Thu, 28 Feb 2008 19:26:54 +0000 (20:26 +0100)]
Convert a CANT_HAPPEN() to CANT_REACH()

16 years agoRemove edit keys deprecated in 4.3.3
Markus Armbruster [Thu, 28 Feb 2008 19:22:12 +0000 (20:22 +0100)]
Remove edit keys deprecated in 4.3.3

These are: land 'C', plane 'a' and 'd', unit 'X', ship 'H', 'P', 'X'
and 'Y'.

16 years agoImplement xundump table truncation
Markus Armbruster [Tue, 26 Feb 2008 20:19:26 +0000 (21:19 +0100)]
Implement xundump table truncation

16 years agoNew ef_truncate()
Markus Armbruster [Sun, 9 Mar 2008 12:42:12 +0000 (13:42 +0100)]
New ef_truncate()

16 years agoPOSIX compatible ftruncate() for Windows
Markus Armbruster [Tue, 26 Feb 2008 19:05:36 +0000 (20:05 +0100)]
POSIX compatible ftruncate() for Windows

16 years agoClean up dependencies after failed compile
Markus Armbruster [Mon, 25 Feb 2008 20:38:22 +0000 (21:38 +0100)]
Clean up dependencies after failed compile

If gcc's preprocessor chokes, it leaves an empty dependency file
behind, and doesn't touch the object file.  If an old object file
exists, and is newer than the .c file, make will then consider the
object file up-to-date.  This can lead to nasty version errors.

16 years agoRemove redundant initializations from fairland's fl_sct_init()
Markus Armbruster [Mon, 25 Feb 2008 20:22:07 +0000 (21:22 +0100)]
Remove redundant initializations from fairland's fl_sct_init()

16 years agoClean up confusing loop control in fairland
Markus Armbruster [Mon, 25 Feb 2008 20:20:48 +0000 (21:20 +0100)]
Clean up confusing loop control in fairland

16 years agoReplace unit_type_name() by empobj_chr_name()
Markus Armbruster [Mon, 25 Feb 2008 20:18:35 +0000 (21:18 +0100)]
Replace unit_type_name() by empobj_chr_name()

16 years agoSimplify empobj_chr_name() oops recovery
Markus Armbruster [Mon, 25 Feb 2008 20:15:50 +0000 (21:15 +0100)]
Simplify empobj_chr_name() oops recovery

Return something usable instead of null.  Matches obj_nameof().  Fixes
those callers that neglected to check the value.

16 years agoRename emp_obj_chr_name() to empobj_chr_name()
Markus Armbruster [Mon, 25 Feb 2008 20:11:19 +0000 (21:11 +0100)]
Rename emp_obj_chr_name() to empobj_chr_name()

16 years agoMake ef_verify() check ef_type and uid
Markus Armbruster [Mon, 25 Feb 2008 20:07:06 +0000 (21:07 +0100)]
Make ef_verify() check ef_type and uid