]> git.pond.sub.org Git - empserver/log
empserver
14 years agoFix client's command abort feature
Markus Armbruster [Fri, 2 Apr 2010 16:22:52 +0000 (18:22 +0200)]
Fix client's command abort feature

The server aborts the current command when it receives a special line
of input for a prompt.  To make the client send it, you type the INTR
character (normally ^C).  This sends the client the SIGINT signal.
Unfortunately, it never quite worked.

Because we use a special line of input to signal interrupt, the client
can do that only after a complete line of input.

What if SIGINT arrives in the middle of a line?  We split the line in
two then and there, by inserting a newline.  Nasty, but it's simple,
and happens rarely.

However, we inserted the newline always, even after a complete line.
In that case, we inserted an empty line of input before the interrupt.
If you hit INTR at a server prompt, the server received an empty line
of input for that prompt, and the interrupt only for the *next*
prompt.  Which may well be too late to abort the command you wanted to
abort.

Fix by inserting the newline only when needed.

14 years agoFix sabo not to kill the spy every time
Markus Armbruster [Mon, 29 Mar 2010 15:39:07 +0000 (17:39 +0200)]
Fix sabo not to kill the spy every time

The hack to protect the spy from sabotage damage killed it outright.
Broken in 861a6662, v4.3.17.

14 years agoDocument empire options -h and -v in manual page
Markus Armbruster [Sat, 27 Mar 2010 12:07:27 +0000 (13:07 +0100)]
Document empire options -h and -v in manual page

Was forgotten in commit 46c0410e, v4.3.11.  Reported by Tom
Dickson-Hunt.

14 years agoContract empire options in manual page synopsis
Markus Armbruster [Sat, 27 Mar 2010 12:04:27 +0000 (13:04 +0100)]
Contract empire options in manual page synopsis

14 years agoSort empdump options in manual page synopsis
Markus Armbruster [Sat, 27 Mar 2010 12:02:22 +0000 (13:02 +0100)]
Sort empdump options in manual page synopsis

14 years agoBump version to 4.3.26
Markus Armbruster [Sat, 27 Mar 2010 11:49:08 +0000 (12:49 +0100)]
Bump version to 4.3.26

14 years agoUpdate change log again for 4.3.25 v4.3.25
Markus Armbruster [Sun, 21 Mar 2010 08:28:23 +0000 (09:28 +0100)]
Update change log again for 4.3.25

14 years agoFix test for capability sweep in shp_hit_mine()
Markus Armbruster [Sun, 21 Mar 2010 08:26:37 +0000 (09:26 +0100)]
Fix test for capability sweep in shp_hit_mine()

Bogus array index, unpredictable result, can crash the server.  Broken
in commit ef7ea893, v4.3.24.

14 years agoUpdate change log again for 4.3.25
Markus Armbruster [Sat, 20 Mar 2010 17:54:10 +0000 (18:54 +0100)]
Update change log again for 4.3.25

14 years agoComment fix
Markus Armbruster [Sat, 20 Mar 2010 17:46:02 +0000 (18:46 +0100)]
Comment fix

14 years agoFix interdiction not to wipe out target ship updates
Markus Armbruster [Sat, 20 Mar 2010 16:55:56 +0000 (17:55 +0100)]
Fix interdiction not to wipe out target ship updates

Ships can expend shells to defend against missiles, in
shp_missile_defense().  Any shell use by the target ship got wiped out
when shp_missile_interdiction() wrote back the target ship, triggering
a seqno mismatch oops.

Ships get updated when they launch planes to intercept interdicting
planes, in mission_pln_equip().  Any petrol use by the target ship got
wiped out when shp_mission_interdiction() wrote back the target ship,
triggering a seqno mismatch oops.

Fix by re-reading the target ship in shp_damage_one().  This also
affects shp_fort_interdiction(), where it is not necessary.  A bit
inefficient, but let's keep this fix simple.

14 years agoFix navigate and march not to lay mines free of charge
Markus Armbruster [Sat, 13 Mar 2010 21:47:13 +0000 (22:47 +0100)]
Fix navigate and march not to lay mines free of charge

do_unit_move() reads the ships into a list.  It re-reads them when it
prompts for sub-commands.  shp_nav_one_sector() writes them back when
it moves ships.

Mine-laying (sub-command 'd') updates the minelayer, invalidating the
copy in the list.  Any movement sub-command before the next prompt for
sub-commands wiped out this update, triggering a seno mismatch oops.

Happens only if 'd' is used without arguments, because remaining
sub-commands are discarded when there are arguments.

Broken when mine-laying was added in commits 2438fe7c, v4.3.7.

Same for march, commit 274c8e42, v4.3.7.

Fix by stopping after 'd' regardless of arguments.

14 years agoFix navigate and march not to prompt for number of mines to lay
Markus Armbruster [Sat, 20 Mar 2010 10:24:49 +0000 (11:24 +0100)]
Fix navigate and march not to prompt for number of mines to lay

When sub-command 'd' was used without arguments, do_unit_move() failed
to supply the second argument to mine(), which duly prompted for it.
This contracticted info, and could trigger a generation oops.

do_unit_move() reads the ships into a list.  It re-reads them when it
prompts for sub-commands.  shp_nav_one_sector() writes them back when
it moves ships.

The mine prompt made the list stale.  Movement sub-commands before the
next prompt for sub-commands wrote back stale ships, triggering a
generation oops.  Example: "nav 15 dg".

Broken when mine-laying was added in commits 2438fe7c, v4.3.7.

Same for march, commit 274c8e42, v4.3.7.

14 years agoUpdate change log for 4.3.25
Markus Armbruster [Tue, 16 Mar 2010 20:42:10 +0000 (21:42 +0100)]
Update change log for 4.3.25

14 years agoNuclear-tipped missile exploding on launch could not damage base
Markus Armbruster [Sat, 13 Mar 2010 12:49:36 +0000 (13:49 +0100)]
Nuclear-tipped missile exploding on launch could not damage base

Commit a269cdd7 (v4.3.23) removed the nuclear damage.  But it left the
nuke on the missile, which made pln_damage() oops and return zero
damage.

Fix by destroying the nuke separately.

14 years agoDon't print Blam-blam when missile explodes on launch
Markus Armbruster [Sat, 13 Mar 2010 12:42:49 +0000 (13:42 +0100)]
Don't print Blam-blam when missile explodes on launch

14 years agoFix news for torpedo attack's return torpedo
Markus Armbruster [Fri, 12 Mar 2010 19:39:39 +0000 (20:39 +0100)]
Fix news for torpedo attack's return torpedo

When a torpedo attack triggered a return torpedo, the news reported it
to be fired by the attacker instead of the defender.

14 years agoInterdiction attacked submarines with surface-only weapons
Markus Armbruster [Wed, 10 Mar 2010 07:54:06 +0000 (08:54 +0100)]
Interdiction attacked submarines with surface-only weapons

shp_mission_interdiction() used MI_INTERDICT instead of MI_SINTERDICT.
Broken in commit cd8fe31e, v4.3.24.

14 years agoFix unsafe use of shared buffers in commands drawing maps
Markus Armbruster [Thu, 25 Feb 2010 06:07:28 +0000 (07:07 +0100)]
Fix unsafe use of shared buffers in commands drawing maps

Maps are generally drawn into static scratch buffers.  Each command
has its own buffers.

Static scratch buffers are safe as long as they're never used across
yields.  Player output can yield unless the command has flag C_MOD
set.  Commands lradar, path, radar, route, satellite, sect, survey
hadn't.  If such a command yields while using scratch buffers, another
instance of the command can clobber them.

Abuse seems tricky, but possible: if a malicious player stalls output
just right, a command yields while printing a map from the scratch
buffer.  It resumes only when the malicious player reads some output.
If another player runs the same command before that, it overwrites the
same static scratch buffer with its map.  The malicious player
receives the last such run's map.

4.2.8 fixed the same bug for bmap, lbmap, lmap, map, nmap, pbmap,
pmap, sbmap and smap.

All were broken in 4.2.0.  Except radar maps (lradar and radar) were
already broken in Empire 2 for AIX.

14 years agoGeneration numbers didn't catch all potential yields on output
Markus Armbruster [Sun, 21 Feb 2010 17:44:16 +0000 (18:44 +0100)]
Generation numbers didn't catch all potential yields on output

io_output_if_queue_long() called ef_make_stale() only for long queues.
Missed in commit 2fa5f652, v4.3.24.

14 years agofiles could clobber the game when reading confirmation fails
Markus Armbruster [Sun, 14 Feb 2010 18:29:13 +0000 (19:29 +0100)]
files could clobber the game when reading confirmation fails

fgets() fails on read error or EOF.  When it fails, it doesn't touch
the buffer.  Since files didn't check its return value, it read an
uninitialized character from the buffer.  If that happened to be 'y'
or 'Y', it happily clobbered the game.

14 years agoUpdate link to `Recursive Make Considered Harmful'
Markus Armbruster [Sat, 13 Feb 2010 20:04:01 +0000 (21:04 +0100)]
Update link to `Recursive Make Considered Harmful'

14 years agoLess verbose make output
Markus Armbruster [Sat, 13 Feb 2010 17:48:31 +0000 (18:48 +0100)]
Less verbose make output

Many commands, compiler invocations in particular, are rather long,
and warnings tend to get lost in the noise.  Suppress the command
details.  Run make with a V=1 parameter for full output.

14 years agoChange fairland not to reject small worlds without trying
Markus Armbruster [Sat, 6 Feb 2010 20:36:21 +0000 (21:36 +0100)]
Change fairland not to reject small worlds without trying

Instead, print a warning and try.  It may well work, and when it
doesn't, it fails cleanly.

14 years agoClean up commented out code left behind by commit eea24fb0
Markus Armbruster [Sat, 6 Feb 2010 20:28:39 +0000 (21:28 +0100)]
Clean up commented out code left behind by commit eea24fb0

14 years agoBump version to 4.3.25
Markus Armbruster [Sat, 6 Feb 2010 20:27:17 +0000 (21:27 +0100)]
Bump version to 4.3.25

14 years agoUpdate change log again for 4.3.24 v4.3.24
Markus Armbruster [Tue, 26 Jan 2010 21:30:24 +0000 (22:30 +0100)]
Update change log again for 4.3.24

14 years agoFix generation numbers for order command
Markus Armbruster [Tue, 26 Jan 2010 21:20:16 +0000 (22:20 +0100)]
Fix generation numbers for order command

orde() uses a "clever" trick to get away with just one
check_ship_ok(): it makes a copy of the ship in the beginning, and
checks it at the end.  Generation numbers (commit 2fa5f652) break this
trick.  It could be fixed by manually marking the ship fresh.
Instead, check the ship the stupid, straightforward way, without a
copy.

14 years agoNormalize order's reaction to bad input
Markus Armbruster [Tue, 26 Jan 2010 21:02:34 +0000 (22:02 +0100)]
Normalize order's reaction to bad input

Consistently fail the command on bad or missing argument.  Before, it
merely skipped to the next ship in some cases.

14 years agoGet third argument of "order l" the ordinary way
Markus Armbruster [Tue, 26 Jan 2010 20:48:26 +0000 (21:48 +0100)]
Get third argument of "order l" the ordinary way

Now prompts when the argument is empty.  Before, that was interpreted
as zero.  Not likely to affect players.

14 years agoClean up dead code in orde()
Markus Armbruster [Tue, 26 Jan 2010 20:23:10 +0000 (21:23 +0100)]
Clean up dead code in orde()

Does not change optimized code (gcc -O) apart from __LINE__.

14 years agoFix windows client not always exiting
Ron Koenderink [Mon, 25 Jan 2010 02:45:51 +0000 (20:45 -0600)]
Fix windows client not always exiting

The call to WSAEnumNetworkEvents() was reseting network
events in particular WSAECONNRESET was sometimes being lost
causing the client to not exit.  The WSAEnumNetworkEvents()
was called from fd_is_socket() and has been replace with
getsockopt() to determine if the fd is socket or not.

Broken in commit 4d40a275, v4.3.23

14 years agoUpdate change log for 4.3.24
Markus Armbruster [Mon, 18 Jan 2010 18:35:37 +0000 (19:35 +0100)]
Update change log for 4.3.24

14 years agoClean up dead stores
Markus Armbruster [Sat, 16 Jan 2010 16:40:28 +0000 (17:40 +0100)]
Clean up dead stores

Does not change optimized code (gcc -O).

Spotted by the Clang Static Analyzer.

14 years agoFix navigate/march crash on funny path arguments
Markus Armbruster [Sat, 16 Jan 2010 16:15:22 +0000 (17:15 +0100)]
Fix navigate/march crash on funny path arguments

For an argument consisting of a valid path plus whitespace,
do_unit_move() eventually passed the whitespace suffix to parse(),
then dereferenced player->argp[0].  But that was null.

Broken in commit 0c12d837, v4.3.7.  Trivial for players to trigger.

14 years agoFix player_login() not to print null pointer
Markus Armbruster [Sat, 16 Jan 2010 15:29:41 +0000 (16:29 +0100)]
Fix player_login() not to print null pointer

When the input line contains only whitespace, player->argp[0] is null
after parse().  This condition was not checked, comtch() returned
M_IGNORE, and code handling that printed the null pointer.  Some
systems (GNU, Windows) deal gracefully with printing null strings,
others crash.  Trivial to trigger remotely.

Before the fix, the value of parse() was assigned, but never used, and
that was spotted by the Clang Static Analyzer.

14 years agoClean up useless getnatp() in conv(), nav_map(), tele()
Markus Armbruster [Sat, 16 Jan 2010 09:14:43 +0000 (10:14 +0100)]
Clean up useless getnatp() in conv(), nav_map(), tele()

Spotted by the Clang Static Analyzer.

14 years agoMove -h to the end of the emp_server -h output
Markus Armbruster [Sat, 16 Jan 2010 08:31:08 +0000 (09:31 +0100)]
Move -h to the end of the emp_server -h output

This is consistent with the other programs.

14 years agoMake empire, empsched and files catch extra operands
Markus Armbruster [Sat, 16 Jan 2010 08:29:53 +0000 (09:29 +0100)]
Make empire, empsched and files catch extra operands

This also avoids a dead increment ap++ in src/client/main.c reported
by the Clang Static Analyzer.

14 years agoMake empire and files not print usage on bad option
Markus Armbruster [Sat, 16 Jan 2010 08:22:48 +0000 (09:22 +0100)]
Make empire and files not print usage on bad option

Point to -h instead.  This is consistent with the other programs.

14 years agoFix lwpReschedule()'s assertion "have runnable thread"
Markus Armbruster [Fri, 15 Jan 2010 21:06:51 +0000 (22:06 +0100)]
Fix lwpReschedule()'s assertion "have runnable thread"

If there is no runnable thread, we're deadlocked.  lwpReschedule() has
an assertion to catch this.  But it didn't work, and the code
following it would crash then.  Can't actually happen, because the
EventHandler thread is always runnable.  Spotted by the Clang Static
Analyzer.

14 years agoDeclare cant_listen() noreturn
Markus Armbruster [Fri, 15 Jan 2010 19:20:36 +0000 (20:20 +0100)]
Declare cant_listen() noreturn

Local analysis can now easily find out what's up.  Before, inter-
procedural analysis was required.  The Clang Static Analyzer
complained about a dereference of res that is actually fine.

14 years agoMake CANT_HAPPEN() more obvious for static analysis
Markus Armbruster [Fri, 15 Jan 2010 19:02:11 +0000 (20:02 +0100)]
Make CANT_HAPPEN() more obvious for static analysis

Local analysis can now easily find out what's up.  Before,
whole-program analysis was required.  The Clang Static Analyzer
complained about code that is actually fine.

14 years agoFix getpath() not to crash when path exceeds MAX_PATH_LEN
Markus Armbruster [Thu, 14 Jan 2010 21:39:42 +0000 (22:39 +0100)]
Fix getpath() not to crash when path exceeds MAX_PATH_LEN

Trivial for players to trigger.  Broken in commit 0b0612ea, v4.3.16.
Spotted by the Clang Static Analyzer.

14 years agoFix oops on escort, recon, and launch of satellite
Markus Armbruster [Wed, 13 Jan 2010 20:21:58 +0000 (21:21 +0100)]
Fix oops on escort, recon, and launch of satellite

Broken in commit 528df9ac, v4.3.23.  pln_equip() recovered fine.

14 years agoUpdate copyright notice
Markus Armbruster [Sun, 10 Jan 2010 07:53:25 +0000 (08:53 +0100)]
Update copyright notice

14 years agoFix trailing whitespace
Markus Armbruster [Sun, 10 Jan 2010 07:47:40 +0000 (08:47 +0100)]
Fix trailing whitespace

14 years agoStop ship and land unit movement on interdiction with no damage
Markus Armbruster [Sat, 9 Jan 2010 15:21:40 +0000 (16:21 +0100)]
Stop ship and land unit movement on interdiction with no damage

Movement stops when shp_interdict() or lnd_interdict() report
interdiction.  However, they reported it only when there was
interdiction damage.

Zero interdiction damage commonly happens when interdicting missiles
miss, or all bombers abort.  Stopping regardless of damage makes more
sense there.

Moreover, not stopping is buggy: do_unit_move() needs to take care not
to wipe out updates made by interdiction to the moving ships or land
units.  It does so only when it stops.  Updates made by interdiction
without interdiction damage could get wiped out, triggering a seqno
mismatch oops.

Known ways moving ships and land units can get updated by interdiction
despite there is no interdiction damage:

* Interdicting bombers get intercepted by planes based on a navigating
  carrier, carrier gets charged petrol.  The bug wipes out the petrol
  use.

* Marching land units get interdicted by planes, but all planes miss.
  Sufficiently large collateral damage to the sector can still damage
  the land units.  The bug wipes out the damage to land units.

To make shp_interdict() and lnd_interdict() report interdiction
regardless of damage, change lnd_missile_interdiction(),
lnd_fort_interdiction(), lnd_mission_interdiction(),
shp_missile_interdiction(), shp_fort_interdiction(),
shp_mission_interdiction() to return whether there was interdiction.
Before, they returned whether there was damage.

Change unit_interdict(), perform_mission(), perform_mission_land(),
perform_mission_ship(), perform_mission_msl(), and
perform_mission_bomb() to return -1 for no interdiction, so that
callers can distinguish no interdiction from interdiction with no
damage.

14 years agoClean up poorly chosen loop control variable names
Markus Armbruster [Sat, 9 Jan 2010 13:51:59 +0000 (14:51 +0100)]
Clean up poorly chosen loop control variable names

Calling a counting loop's control variable q or z is tasteless
bordering on actively misleading.

14 years agoSimplify perform_mission()
Markus Armbruster [Sat, 9 Jan 2010 13:22:51 +0000 (14:22 +0100)]
Simplify perform_mission()

14 years agoRemove struct genlist member cp
Markus Armbruster [Sat, 9 Jan 2010 12:49:34 +0000 (13:49 +0100)]
Remove struct genlist member cp

14 years agoRemove perform_mission_land(), perform_mission_ship() parameter md
Markus Armbruster [Sat, 9 Jan 2010 12:46:33 +0000 (13:46 +0100)]
Remove perform_mission_land(), perform_mission_ship() parameter md

14 years agoSplit up perform_mission()
Markus Armbruster [Sat, 9 Jan 2010 12:26:16 +0000 (13:26 +0100)]
Split up perform_mission()

Move code out of perform_mission() into new perform_mission_land(),
perform_mission_ship(), perform_mission_msl(), perform_mission_bomb().

14 years agoMake lnd_mission_interdiction() apply damage
Markus Armbruster [Sat, 9 Jan 2010 08:44:12 +0000 (09:44 +0100)]
Make lnd_mission_interdiction() apply damage

To make lnd_mission_interdiction() work just like
shp_mission_interdiction().

14 years agoNew lnd_mission_interdiction()
Markus Armbruster [Sat, 9 Jan 2010 08:40:01 +0000 (09:40 +0100)]
New lnd_mission_interdiction()

Factored out of lnd_interdict().  No functional change.

14 years agoNew shp_mission_interdiction()
Markus Armbruster [Sat, 9 Jan 2010 08:39:15 +0000 (09:39 +0100)]
New shp_mission_interdiction()

Factored out of shp_interdict().  No functional change.

14 years agoFix att_reacting_units() to initialize ulist member eff
Markus Armbruster [Sat, 2 Jan 2010 08:27:55 +0000 (09:27 +0100)]
Fix att_reacting_units() to initialize ulist member eff

This left initial eff at zero.  No effect, because its only user
get_land() ignores efficiency increases.

14 years agoSimplify ask_olist and get_dlist() not to re-read land units
Markus Armbruster [Sat, 2 Jan 2010 08:14:55 +0000 (09:14 +0100)]
Simplify ask_olist and get_dlist() not to re-read land units

getland() is obviously redundant in get_dlist(), because the land unit
can't have changed since the previous read.

What's up with ask_olist() is less obvious.  For each capable land
unit, ask_olist() asks the player whether to attack with it.  If it
attacks, it gets copied into olist.  Since asking the player yields
the processor, these copies can become stale.  However, re-reading
fixes that just for the last one.  Moreover, the code copes with stale
copies just fine: ask_olist() is always directly followed by
att_get_offense() or att_move_in_off(), and both replace the
potentially stale copy in olist.

14 years agoRemove get_land() parameter uid
Markus Armbruster [Sun, 3 Jan 2010 20:45:10 +0000 (21:45 +0100)]
Remove get_land() parameter uid

For all remaining calls, the uid can be obtained from parameter llp.

14 years agoInline get_land()'s "first time" case into its callers
Markus Armbruster [Sat, 2 Jan 2010 07:53:25 +0000 (08:53 +0100)]
Inline get_land()'s "first time" case into its callers

ask_olist() and get_dlist() called get_land() with llp->chrp still
null, which made it initialize parts of llp instead of performing its
usual integrity check.  att_reacting_units() had the initialization
inline.  Change the other two to match, and simplify get_land().  No
functional change.

14 years agoDrop last parameter of shp_hit_mine() and lnd_hit_mine()
Markus Armbruster [Fri, 1 Jan 2010 15:55:24 +0000 (16:55 +0100)]
Drop last parameter of shp_hit_mine() and lnd_hit_mine()

14 years agoSimplify use of shp_missile_interdiction()
Markus Armbruster [Fri, 1 Jan 2010 15:38:47 +0000 (16:38 +0100)]
Simplify use of shp_missile_interdiction()

shp_missile_interdiction() does nothing when there are no suitable
targets.  Its users avoid to call it when there are none, probably to
save a few cycles.  Optimize shp_missile_interdiction() for that case,
and simplify the callers.

14 years agoMake empdump call ef_close() regardless of -n
Markus Armbruster [Fri, 1 Jan 2010 10:15:51 +0000 (11:15 +0100)]
Make empdump call ef_close() regardless of -n

Avoiding ef_close() with -n is not necessary, so don't.

14 years agoRearrange struct sctstr slightly to expose commonalities with units
Markus Armbruster [Thu, 31 Dec 2009 10:50:22 +0000 (11:50 +0100)]
Rearrange struct sctstr slightly to expose commonalities with units

Nice bonus: space needed for sectors shrinks some 4%.  Size of game
state could shrink perhaps 1-2%.

14 years agoNarrow struct sctstr member sct_mobil to char
Markus Armbruster [Thu, 31 Dec 2009 10:39:17 +0000 (11:39 +0100)]
Narrow struct sctstr member sct_mobil to char

To bring it in line with unit mobility.

14 years agoMake struct sctstr member sct_effic signed
Markus Armbruster [Thu, 31 Dec 2009 10:36:59 +0000 (11:36 +0100)]
Make struct sctstr member sct_effic signed

To bring it in line with unit efficiency.

14 years agoStreamline fortgun()'s efficiency comparison
Markus Armbruster [Thu, 31 Dec 2009 10:33:06 +0000 (11:33 +0100)]
Streamline fortgun()'s efficiency comparison

Use >= 60 instead of > 59, for consistency with similar comparisons
elsewhere.

14 years agoFix sloppy sanity check for mobility going negative in transport
Markus Armbruster [Thu, 31 Dec 2009 10:27:48 +0000 (11:27 +0100)]
Fix sloppy sanity check for mobility going negative in transport

Assignment to sct_mobil was vulnerable to integer underflow.  Should
not happen, as move_ground() never returns a cost exceeding available
mobility.

14 years agoGeneration numbers to catch write back of stale copies
Markus Armbruster [Thu, 31 Dec 2009 12:14:36 +0000 (13:14 +0100)]
Generation numbers to catch write back of stale copies

Oops when a stale copy is written back, i.e. the processor was yielded
since the copy was made.  Such bugs are difficult to spot.  Sequence
numbers catch them when they do actual harm (they also catch different
bugs).  Generation numbers catch them even when they don't.

New ef_generation to count generations.  Call new ef_make_stale() to
increment it whenever the processor may be yielded.

New struct emptypedstr member generation.  To conserve space, make it
a bit-field of twelve bits, i.e. generations are only recorded modulo
2^12.  Make sure all members of unit empobj_storage share it.  It is
only used in copies; its value on disk and in the cache is
meaningless.  Copies with generation other than ef_generation are
stale.  Stale copies that are a multiple of 2^12 generations old can't
be detected, but that is sufficiently improbable.

Set generation to ef_generation by calling new ef_mark_fresh() when
making copies in ef_read() and ef_blank().  nav_ship() and
fltp_to_list() make copies without going through ef_read(), and
therefore need to call ef_mark_fresh() as well.  Also call it in
obj_changed() to make check_sect_ok() & friends freshen their argument
when it is unchanged.

New must_be_fresh() oopses when its argument is stale.  Call it in
ef_write() to catch write back of stale copies.

14 years agoStore sequence numbers more compactly
Markus Armbruster [Thu, 31 Dec 2009 09:30:54 +0000 (10:30 +0100)]
Store sequence numbers more compactly

Store them and ef_type in bit-fields.

Allocate eight bits for ef_type.  Values range from 0 to EF_GAME
(currently 16), so this is plenty.

Allocate twelve bits for sequence numbers.  Sequence number mismatches
are now missed when the numbers are equal modulo 2^12.  Still
sufficiently improbable.

Common machines store the bit-fields in a 32 bit word.  There are
twelve bits left in that word for future use.  Total savings 16 bits,
which is exactly what the previous commit spent on wider uids on
common machines.

14 years agoStore uids as int to support more sectors and units
Markus Armbruster [Wed, 30 Dec 2009 13:07:51 +0000 (14:07 +0100)]
Store uids as int to support more sectors and units

Before, they were stored as short.  Wider uids use more space, but the
next commit will recover it by narrowing other members.

The use of short has always limited the number of ships, planes, land
units and nukes to SHRT_MAX (commonly 32768).  Only the most extreme
games ever came close.

Commit 49780e2c (v4.3.12) added struct sctstr member sct_uid to make
struct empobj member uid work for sectors.  This made the limit apply
to sectors as well.  We've had games with more than 32768 sectors.

14 years agoFix new_seqno()'s recovery from seqno mismatch
Markus Armbruster [Thu, 31 Dec 2009 11:12:39 +0000 (12:12 +0100)]
Fix new_seqno()'s recovery from seqno mismatch

A sequence number mismatch occurs when an invalid copy (with a stale
sequence number) gets written.  To continue after the error, we need
to use the current sequence number.  But new_seqno() used the larger
one of the two, which is correct only as long as sequence numbers do
not overflow.  Overflow is rather unlikely, though.

14 years agoRecord news more compactly
Markus Armbruster [Thu, 31 Dec 2009 08:18:37 +0000 (09:18 +0100)]
Record news more compactly

Member nws_uid is unused since the commit before previous.  Remove it.

Member nws_seqno is of marginal value, because we write news only
through ncache[], and thus aren't prone to the errors sequence numbers
can catch.  Remove it.

Make timestamp selector virtual, computing nws_when + nws_duration,
and remove member nws_timestamp.  Impact:

* In ncache(), the removed timestamp equals nws_when + nws_duration,
  both for new news and updated news.  No change.

* delete_old_news() becomes invisible.  Before, its move of unexpired
  news to the beginning of the news file touched all the timestamps.
  That was unwanted, because the move does not change news, only their
  storage.  Improvement.

* empdump no longer flags the imported news changed via the timestamp.
  This is somewhat unfortunate.  Document as bug.

With these members removed, struct nwsstr no longer matches struct
emptypedstr, so clear news table flag EFF_TYPED and remove union
empobj_storage member news.  This loses the automatic maintenance of
member ef_type via struct emptypedstr.  Remove ef_type as well.

This shrinks struct nwsstr from 20 to 12 bytes on common 32 bit
machines, and from 32 to 16 bytes on common 64 bit machines.  Since
the server doesn't map the whole news file (EFF_MAP is off), this
reduces I/O, while the table's memory use remains the same.

Historical note: struct nwsstr is now pretty much what it was back in
BSD Empire 1.1.  Members ef_type and nws_uid go back to Empire 3 (for
C_SYNC?).  v4.3.12 added member nws_timestamp, which doubled the size
on common 64 bit machines.  v4.3.15 added nws_seqno.

14 years agoNew news selector duration
Markus Armbruster [Thu, 31 Dec 2009 08:17:54 +0000 (09:17 +0100)]
New news selector duration

Backed by new struct nwsstr member nws_duration.  Time between first
and last occurence of the news recorded in this item, in seconds.

14 years agoRevert "Get rid of struct newscache"
Markus Armbruster [Thu, 31 Dec 2009 06:36:47 +0000 (07:36 +0100)]
Revert "Get rid of struct newscache"

This reverts commit 832574b6dee87f4efb56945c62e5d2fadec27288.

To prepare for removal of struct nwsstr member nws_uid.

Conflicts:

src/lib/subs/nreport.c

14 years agoRemove unused members of struct lndstr, lonstr, nukstr, trtstr
Markus Armbruster [Wed, 30 Dec 2009 12:49:41 +0000 (13:49 +0100)]
Remove unused members of struct lndstr, lonstr, nukstr, trtstr

struct lndstr member lnd_flags is a leftover from Empire3's C_SYNC,
which was ripped out in 4.0.0.

struct lonstr member l_sel, struct nuk_str members nuk_ship, nuk_land,
and struct trtstr member trt_bond have been there basically forever
without any use.

14 years agoConsistently use int for sector and unit uid parameters
Markus Armbruster [Wed, 30 Dec 2009 11:44:01 +0000 (12:44 +0100)]
Consistently use int for sector and unit uid parameters

14 years agoConsistently use int for file type parameters and locals
Markus Armbruster [Tue, 29 Dec 2009 12:09:01 +0000 (13:09 +0100)]
Consistently use int for file type parameters and locals

14 years agoConsistently use int for mission type parameters
Markus Armbruster [Tue, 29 Dec 2009 12:06:35 +0000 (13:06 +0100)]
Consistently use int for mission type parameters

14 years agoFix launch not to wipe out target sector updates
Markus Armbruster [Sat, 26 Dec 2009 13:02:50 +0000 (14:02 +0100)]
Fix launch not to wipe out target sector updates

Launching ABMs updates their base, in mission_pln_equip().  The update
got wiped out when launch_missile() wrote back the target sector,
triggering a seqno mismatch oops.  Harmless with the stock game's
ABMs, because they use neither shells nor petrol.

Fix by re-reading the target sector.

14 years agoFix launch not to wipe out target ship updates
Markus Armbruster [Sat, 26 Dec 2009 10:28:25 +0000 (11:28 +0100)]
Fix launch not to wipe out target ship updates

Ships can expend shells to defend against missiles, in
shp_missile_defense().  Any shell use by the target ship got wiped out
when launch_missile() wrote back the target ship, triggering a seqno
mismatch oops.

Fix by re-reading the target ship.

14 years agoBump version to 4.3.24
Markus Armbruster [Sat, 26 Dec 2009 09:20:21 +0000 (10:20 +0100)]
Bump version to 4.3.24

14 years agoFix nightly build v4.3.23
Markus Armbruster [Mon, 14 Dec 2009 05:56:23 +0000 (06:56 +0100)]
Fix nightly build

Commit 5f89f8cb added pre_update.econfig with incorrect permissions.

14 years agoUpdate change log for 4.3.23
Markus Armbruster [Sun, 13 Dec 2009 16:37:13 +0000 (17:37 +0100)]
Update change log for 4.3.23

14 years agoUpdate known contributors comments
Markus Armbruster [Sun, 13 Dec 2009 14:10:07 +0000 (15:10 +0100)]
Update known contributors comments

14 years agoBelatedly update make dependencies for standalone client build
Markus Armbruster [Sun, 13 Dec 2009 07:58:07 +0000 (08:58 +0100)]
Belatedly update make dependencies for standalone client build

main.$O was out of date since commit 518c8d6f.

14 years agoDon't patch constants.c for nightly, use econfig
Ron J Koenderink [Fri, 4 Dec 2009 02:21:22 +0000 (20:21 -0600)]
Don't patch constants.c for nightly, use econfig

14 years agoFix info navigate on missile interdiction targets
Markus Armbruster [Wed, 14 Oct 2009 23:19:00 +0000 (19:19 -0400)]
Fix info navigate on missile interdiction targets

Missile interdiction targets only "valuable" ships since Empire 3.

14 years agoFix info Mobility not to claim missions get a bonus
Markus Armbruster [Wed, 14 Oct 2009 23:10:48 +0000 (19:10 -0400)]
Fix info Mobility not to claim missions get a bonus

Bonus was dropped in v4.0.0.

14 years agoMake transport chopper not light
Markus Armbruster [Wed, 14 Oct 2009 00:19:39 +0000 (20:19 -0400)]
Make transport chopper not light

Capability light has no effect for choppers since commit 041ad4ce,
v4.3.11.

14 years agoFix messages in msl_launch()
Markus Armbruster [Mon, 12 Oct 2009 02:32:44 +0000 (22:32 -0400)]
Fix messages in msl_launch()

14 years agoDon't intercept tactical and marine missiles targeting planes
Markus Armbruster [Mon, 12 Oct 2009 02:18:26 +0000 (22:18 -0400)]
Don't intercept tactical and marine missiles targeting planes

Missiles attacking ground targets (sectors, ships or land units) can
be intercepted, missiles targeting planes can't.  Except msl_launch()
checked the missile's capabilities instead of its target, and thus
intercepted missiles that *could* target ground even when they
targeted planes.

This broke the missile interception code's assumption that
interceptors aren't intercepted, and crashed the server through
infinite recursion: tactical abm #1 intercepts, tactical abm #2
intercepts #1, #1 intercepts #2, ...

Same bug in msl_hit() printed "incoming missile" for missiles that
could target ground but do target planes.

Broken in Empire 2.  Bug can't bite with the stock game's planes.

14 years agoFix and enable collateral damage for missing missiles
Markus Armbruster [Sun, 11 Oct 2009 16:04:16 +0000 (12:04 -0400)]
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.

14 years agoNews reported victim as actor for sub-launched anti-sat and ABM
Markus Armbruster [Tue, 13 Oct 2009 23:33:33 +0000 (19:33 -0400)]
News reported victim as actor for sub-launched anti-sat and ABM

If the intercepted missile was sub-launched as well, this disclosed
its owner.

The stock game's anti-sats and ABMs can't be sub-launched.

14 years agoClarify how perform_mission() uses missiles
Markus Armbruster [Sun, 11 Oct 2009 15:58:00 +0000 (11:58 -0400)]
Clarify how perform_mission() uses missiles

Interdiction of ships and land units with missiles happens elsewhere.
Oops when perform_mission() strays on that turf.

14 years agoRefactor missile interception code
Markus Armbruster [Sat, 10 Oct 2009 22:26:31 +0000 (18:26 -0400)]
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.

14 years agoFix defense value of intercepted missiles and satellites
Markus Armbruster [Sat, 10 Oct 2009 22:15:22 +0000 (18:15 -0400)]
Fix defense value of intercepted missiles and satellites

Use the plane's defense value, not the plane type's base value.

14 years agoFix missiles interdicting ships outside range or op area
Markus Armbruster [Sat, 10 Oct 2009 21:07:27 +0000 (17:07 -0400)]
Fix missiles interdicting ships outside range or op area

Ship interdiction works sector by sector.  Interdicting missiles
targeted all ships not yet interdicted, not just the ones in the
current sector.  This could lead to interdiction outside missile range
or op area.

14 years agoGet rid of msl_launch_mindam()
Markus Armbruster [Sat, 10 Oct 2009 20:32:18 +0000 (16:32 -0400)]
Get rid of msl_launch_mindam()

It's awkward, especially in shp_missile_interdiction().  Inline into
callers and simplify.

14 years agoSimplify control logic in msl_intercept()
Markus Armbruster [Sat, 10 Oct 2009 16:23:38 +0000 (12:23 -0400)]
Simplify control logic in msl_intercept()