Commit graph

4145 commits

Author SHA1 Message Date
373f20a8b5 Rename add argument "new" to "player"
This makes the correct choice for player countries obvious.  Keep
recognizing "new" for now, but deprecate it.
2011-12-29 11:47:05 +01:00
3fb00c79d9 Drop add argument "active"
Argument "active" is obscure.  It creates a country in STAT_ACTIVE
that doesn't have a capital, and has its origin at the true origin.
If you really want such a country, create it in STAT_NEW normally,
then use edit to go to STAT_ACTIVE.
2011-12-29 11:47:05 +01:00
62f0da239f Drop add's obscure sector check and wipe functionality
If you really need to wipe out a country, there's much more to wipe
than just sectors.
2011-12-29 11:47:05 +01:00
a9e485b13e Drop add's undocumented land unit destruction feature
It doesn't destroy ships, planes or nukes, either.
2011-12-29 11:47:05 +01:00
062c660e28 Permit no-op country name change again
Commit aa5861d1 (v4.3.20) made add, edit and change reject a country
name that is already in use.  Even if it's used by the same country.
Relax that.
2011-12-29 11:47:05 +01:00
9b2e906ea1 Improve newcap's origin error message 2011-12-29 11:47:05 +01:00
c9b380eee4 Streamline a few files error messages
Write one nice line to stderr instead of a cryptic one to stderr, and
an uninformative one to stdout.
2011-12-29 11:47:05 +01:00
73129c15cc Fix files and fairland to report ef_open() failure just once
ef_open() already reports failure since commit 7eb2fe57, v4.2.20.
Drop the second report from its callers.
2011-12-29 11:47:05 +01:00
f006e373f9 Replace exit(-1) by exit(1)
exit() uses only the least significant byte of its argument.
2011-12-29 11:47:05 +01:00
06753c7e2b Make allocate_memory() return void
It can't fail since commit ba1a320c, v4.3.15.
2011-12-29 11:47:05 +01:00
9be42299b5 Guard against unusable fd in pthreads' empth_select()
0 <= fd < FD_SETSIZE must hold, or else undefined behavior in
FD_SET().
2011-12-29 11:47:05 +01:00
55e689fb31 Fix lwpSleepFd()'s guard against unusable fd
0 <= fd < FD_SETSIZE must hold, or else undefined behavior in FD_SET()
and buffer overrun in LwpFdwait[fd].  Check of upper bound off by one,
check of lower bound missing.
2011-12-29 11:47:05 +01:00
0b66d8e281 Plug FILE leak on show_first_tel() error paths
Leak introduced in commit 4238323d, v4.3.20.  Unlikely to bite in
practice, as only corrupt mailbox files can cause these errors.
2011-12-29 11:47:05 +01:00
8e391f29a1 Plug memory leak in set_paths() error path
Leak appeared in commit 91eefc3f, v4.3.12.  Harmless in practice,
since the error is ultimately fatal.
2011-12-29 11:47:05 +01:00
5a77a8186e Fix read_schedule() not to fclose(stdin)
Did that since the initial commit 71320ed6, v4.3.10.
2011-12-29 11:47:04 +01:00
881dd41626 Plug FILE leak on read_schedule() parse error path
Leak introduced in initial commit 71320ed6, v4.3.10.
2011-12-29 11:47:04 +01:00
6104d534e9 Plug memory leak in verify_row()
Leak introduced in commit b30c83cd, v4.3.28.
2011-12-29 11:47:04 +01:00
354664eef2 Make play show no last command when there hasn't been one
Before, it printed NULL, which isn't helpful.
2011-12-29 11:47:04 +01:00
11d6e8ce80 Remove unreachable code in sell()
sell used to search multiple sectors for sellable commodities, keeping
tally in totalcom.  It failed with message "No eligible" when none
could be found.

sell's second argument got changed to a single sector in Empire 3.  If
the sector can't sell, we return early.  Else, totalcom is positive.
Thus, the "No eligible" code is unreachable.  Remove it.
2011-12-29 11:47:04 +01:00
845fc9eb56 Fix info sell on second argument
Empire 3 changed it to a single sector, but neglected to update info.
2011-12-29 11:47:04 +01:00
1086387f8b Make scripts/savecore create the core directory 2011-12-29 11:47:04 +01:00
5e9fb6b607 Rename tgz to arc in scripts/backup
tgz looks silly when you hack the script to use something other than
tar+gzip.
2011-12-29 11:47:04 +01:00
44235c0092 Fix empire(6) synopsis for argument of -s
Commit 464094a6 (v4.3.26) changed it in section description, but
missed section synopsis.
2011-12-29 11:47:04 +01:00
14af9e5b96 Fix use-after-free when plane is downed or aborted in dogfight
ac_dog() passed ap and dp to ac_dog_report() after ac_planedamage()
freed it.  Broken in commit 73260a8a, v4.3.27.  Diagnosed with
valgrind.
2011-12-29 11:44:16 +01:00
a990d90b84 Bump version to 4.3.29 2011-08-03 20:36:28 +02:00
513352f50c Clean up omit_ids() not to set an extra element in idgap[] 2011-07-16 15:30:10 +02:00
b7594e6570 Update change log for 4.3.28 2011-07-16 13:47:48 +02:00
617cb41f66 Don't let POGO (#0) navigate and march ghosts
POGO can navigate dead ships, and march dead land units.  The ghosts
even get sighted and interdicted, and can hit mines (landmines only
until commit fe372539, v4.3.27).  Noted for ships in commit 9100af0b.
Has always been broken.  Fix by making shp_sel() and lnd_sel()
explicitly reject ghosts.

Same code pattern also exists in pln_sel, but dead plains fail the
efficiency test, so it's harmless there.  Apply the same fix anyway.
2011-07-16 13:47:48 +02:00
45d090b8c3 Make llook ignore land units and planes loaded on land units
Probably overlooked when trains were added in 4.0.0.
2011-07-16 13:47:48 +02:00
0a693c1fa2 Fix "sector can board" test to ignore land units on land units
boar() lets a sector board if it has mobility or usable land units.
Embarked land units are not usable.  But it tests only "on ship", not
"on land unit".  Broken in 4.0.17.
2011-07-16 13:47:36 +02:00
41dc6de306 Fix transport to reject planes loaded on land units
The transported plane remains on its carrier.  When the land unit
moves, the plane is teleported right back to it.  Broken since
Chainsaw 3 added land units.

While there, improve the message for planes on ships.
2011-07-16 13:45:55 +02:00
5b0cf9c2a3 Fix lradar to reject land units loaded on land units
Probably overlooked when trains were added in 4.0.0.

While there, improve the message for land units on ships.
2011-07-16 11:48:35 +02:00
8ed7658f9b Fix strength to ignore land units loaded on land units
They can't defend their sector, see get_dlist().

Missed when 4.2.0 made them not defend the sector.
2011-07-13 20:37:41 +02:00
0faf0034e5 Fix navigate and march to find paths longer than 7 sectors again
Broken in commit 8f008bf8, v4.3.27.  How embarrassing...
2011-07-12 07:12:57 +02:00
80a2fdc8ff Make march sub-command 'i' show military, #land units loaded 2011-07-10 21:22:52 +02:00
16d00ae7bf Update doc/debugging for recent commit a9611a57 2011-07-10 21:17:01 +02:00
c6d3f68bbb New server option -F to force start even when state looks bad
Risks crashes and further corruption, but gives deities a chance to
fix up a bad game state with edit commands and such.
2011-07-10 21:17:01 +02:00
c27564c0a9 Give init_server() internal linkage 2011-07-10 21:17:01 +02:00
2a5d12be54 Change empdump to export even when game state looks bad
Just print a warning then.  Gives deities another tool to fix up a bad
game state.
2011-07-10 21:17:01 +02:00
d63b0e1a7b Split ef_verify() into ef_verify_config(), ef_verify_state() 2011-07-10 21:17:01 +02:00
c4a32b2fda Factor verify_table() out of ef_verify() 2011-07-10 21:16:41 +02:00
bea98f32c4 Fix return value of ef_verify() to match function comment
Comment added in commit 6eec0010.  Callers don't actually care.
2011-07-10 21:11:04 +02:00
a8b7d1d017 Fix prewrite callbacks' cargo list update for in-place update
When updating in-place (old==new), we must not write through new
before we're done reading the same memory through old.

Bug: we write the carrier uids too early.  Cargo lists aren't updated
when a carrier dies in an in-place update.  No such updates are known.
Broken in commit 64a53c90, v4.3.17.
2011-07-10 21:10:56 +02:00
91c2ecec53 Land units loaded on land units fight che again
They didn't since commit 93d033cf, v4.3.26.  Drawback: micromanagement
incentive to unload them for the update.  Similar incentive has always
existed for military on ships.

Since the previous commit, land units loaded on land units get
unloaded when the carrier dies fighting che.  Such land units get
stuck in the sector if the take over, and can be boarded.  Doesn't
feel right, and increases the micromanagement incentive.  Avoid by
letting them fight.
2011-07-10 21:10:17 +02:00
7aba25e826 Don't leave cargo stuck on land unit killed by che
When che destroy a land unit, any embarked units remain stuck on their
now dead carrier.  Closely related to and same impact as the bug fixed
in commit 8ccad0d7.  Broken since Chainsaw 3 added land units.

The obvious fix would be to match what normally happens when a carrier
gets destroyed: destroy the cargo.  Requires recursion.  To keep
things as simple as possible, destroy plane cargo, but unload land
unit cargo.  That way, the only cargo of cargo to visit are nukes on
planes.

Unloading the land units creates another problem, which will be
addressed in the next commit.
2011-07-10 21:09:37 +02:00
4c8d4228c8 Factor lnd_dies_fighting_che() out of take_casualties() 2011-07-10 21:08:56 +02:00
8ccad0d779 Units no longer die from lack of maintenance
Damage due to lack of maintenance is now limited by the unit's minimum
efficiency.

Before, units could die.  Unfortunately, the update left any embarked
units on their dead carrier.  Should have seen this when I fixed a
related bug in commit c2c0d1ff, v4.3.22.  Broken for ships and land
units when Empire 2 added their maintenance cost, and for planes when
commit 2e40a4bb (v4.3.4) replaced nuclear stockpiles by nuke units.
The common root cause of these bugs is the update bypassing pre-write
functions (bug#1010856).

If another unit with the same number got built, it picked up the stuck
cargo, triggering the oops from commit 6fb5caf6, which see.

In "stuck on dead carrier" state, units pretty much behave as if their
carrier was still alive, with additional protection from the fact that
a dead carrier can't be damaged or boarded.

The server detects this state on startup since commit 7da9aab5, and
refuses to start.

Only a deity can take units off a dead carrier.
2011-07-10 21:08:50 +02:00
8621911b4d Belatedly update info Maintenance for removed budget priorities
Missed in commit 520446ef, v4.3.6.
2011-07-10 11:43:44 +02:00
6fb5caf633 Oops when stuck cargo snaps to new ship, plane or land unit
When units somehow get stuck on a dead carrier, a new build reusing
the dead carrier's UID picks up its cargo.  The cargo gets teleported
to its new carrier when the carrier moves.

Oops when a ship, plane or land unit is created with cargo.  To
recover, destroy the cargo.
2011-07-10 11:43:44 +02:00
3de1e8be28 Avoid false positive generation oops in navigate and march
Commit e3cf1e32 (v4.3.27) created make_stale_if_command_arg() to
permit catching more potential yields on input.  Unfortunately, the
implementation of navigate and march sub-commands 'r', 'l' and 's'
breaks it.

do_unit_move() reads units into a unit list at the beginning and at
each stop.  It writes them back when they move or sweep.  If a unit
changed in the file in between, the changes would get wiped out.
Therefore, do_unit_move() must not yield between stops.

do_unit_move() parses sub-commands into player->argp[], then supplies
defaults for missing arguments, so that code using them (radar(),
do_look(), sona(), mine(), landmine()) won't prompt for missing
arguments.  Unclean and brittle.  See also commit 28cc236e and commit
45106ab9.

Unfortunately, make_stale_if_command_arg() doesn't recognize the
difference between these defaulted arguments and parsed arguments, so
it makes objects stale, even though the defaulted arguments can't be
missing.  If a move or sweep follows, it triggers a false positive
generation oops.

To fix, test "points into argument buffer" (only true for parsed
arguments) instead of "is in player->argp[]".  Requires making the
argument buffer accessible: new struct player member argbuf[].  Use it
for parsing commands, in command(), execute(), do_unit_move().  Don't
use it in emp_config(), player_login(), move_ground(), because these
parse something else.
2011-07-09 15:16:21 +02:00