]> git.pond.sub.org Git - empserver/log
empserver
12 years agoPlug FILE leak on read_schedule() parse error path
Markus Armbruster [Sat, 29 Oct 2011 12:47:02 +0000 (14:47 +0200)]
Plug FILE leak on read_schedule() parse error path

Leak introduced in initial commit 71320ed6, v4.3.10.

12 years agoPlug memory leak in verify_row()
Markus Armbruster [Wed, 26 Oct 2011 19:12:19 +0000 (21:12 +0200)]
Plug memory leak in verify_row()

Leak introduced in commit b30c83cd, v4.3.28.

12 years agoMake play show no last command when there hasn't been one
Markus Armbruster [Wed, 26 Oct 2011 18:00:00 +0000 (20:00 +0200)]
Make play show no last command when there hasn't been one

Before, it printed NULL, which isn't helpful.

12 years agoRemove unreachable code in sell()
Markus Armbruster [Wed, 26 Oct 2011 17:42:37 +0000 (19:42 +0200)]
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.

12 years agoFix info sell on second argument
Markus Armbruster [Wed, 26 Oct 2011 17:34:16 +0000 (19:34 +0200)]
Fix info sell on second argument

Empire 3 changed it to a single sector, but neglected to update info.

12 years agoMake scripts/savecore create the core directory
Markus Armbruster [Wed, 26 Oct 2011 16:55:27 +0000 (18:55 +0200)]
Make scripts/savecore create the core directory

12 years agoRename tgz to arc in scripts/backup
Markus Armbruster [Wed, 26 Oct 2011 16:53:24 +0000 (18:53 +0200)]
Rename tgz to arc in scripts/backup

tgz looks silly when you hack the script to use something other than
tar+gzip.

12 years agoFix empire(6) synopsis for argument of -s
Markus Armbruster [Wed, 26 Oct 2011 16:49:55 +0000 (18:49 +0200)]
Fix empire(6) synopsis for argument of -s

Commit 464094a6 (v4.3.26) changed it in section description, but
missed section synopsis.

12 years agoFix use-after-free when plane is downed or aborted in dogfight
Markus Armbruster [Sun, 9 Oct 2011 16:40:11 +0000 (18:40 +0200)]
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.

12 years agoBump version to 4.3.29
Markus Armbruster [Wed, 3 Aug 2011 18:36:28 +0000 (20:36 +0200)]
Bump version to 4.3.29

12 years agoClean up omit_ids() not to set an extra element in idgap[] v4.3.28
Markus Armbruster [Sat, 16 Jul 2011 13:30:10 +0000 (15:30 +0200)]
Clean up omit_ids() not to set an extra element in idgap[]

12 years agoUpdate change log for 4.3.28
Markus Armbruster [Sat, 16 Jul 2011 11:34:22 +0000 (13:34 +0200)]
Update change log for 4.3.28

12 years agoDon't let POGO (#0) navigate and march ghosts
Markus Armbruster [Sat, 16 Jul 2011 11:06:17 +0000 (13:06 +0200)]
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.

12 years agoMake llook ignore land units and planes loaded on land units
Markus Armbruster [Sat, 16 Jul 2011 09:47:52 +0000 (11:47 +0200)]
Make llook ignore land units and planes loaded on land units

Probably overlooked when trains were added in 4.0.0.

12 years agoFix "sector can board" test to ignore land units on land units
Markus Armbruster [Sat, 16 Jul 2011 09:38:50 +0000 (11:38 +0200)]
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.

12 years agoFix transport to reject planes loaded on land units
Markus Armbruster [Sat, 16 Jul 2011 07:10:46 +0000 (09:10 +0200)]
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.

12 years agoFix lradar to reject land units loaded on land units
Markus Armbruster [Wed, 13 Jul 2011 20:47:05 +0000 (22:47 +0200)]
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.

12 years agoFix strength to ignore land units loaded on land units
Markus Armbruster [Wed, 13 Jul 2011 18:37:41 +0000 (20:37 +0200)]
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.

12 years agoFix navigate and march to find paths longer than 7 sectors again
Markus Armbruster [Tue, 12 Jul 2011 05:11:31 +0000 (07:11 +0200)]
Fix navigate and march to find paths longer than 7 sectors again

Broken in commit 8f008bf8, v4.3.27.  How embarrassing...

12 years agoMake march sub-command 'i' show military, #land units loaded
Markus Armbruster [Sun, 10 Jul 2011 18:57:01 +0000 (20:57 +0200)]
Make march sub-command 'i' show military, #land units loaded

12 years agoUpdate doc/debugging for recent commit a9611a57
Markus Armbruster [Sun, 10 Jul 2011 18:36:00 +0000 (20:36 +0200)]
Update doc/debugging for recent commit a9611a57

12 years agoNew server option -F to force start even when state looks bad
Markus Armbruster [Sun, 10 Jul 2011 15:53:31 +0000 (17:53 +0200)]
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.

12 years agoGive init_server() internal linkage
Markus Armbruster [Sun, 10 Jul 2011 15:41:53 +0000 (17:41 +0200)]
Give init_server() internal linkage

12 years agoChange empdump to export even when game state looks bad
Markus Armbruster [Sun, 10 Jul 2011 14:07:30 +0000 (16:07 +0200)]
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.

12 years agoSplit ef_verify() into ef_verify_config(), ef_verify_state()
Markus Armbruster [Sun, 10 Jul 2011 15:23:02 +0000 (17:23 +0200)]
Split ef_verify() into ef_verify_config(), ef_verify_state()

12 years agoFactor verify_table() out of ef_verify()
Markus Armbruster [Sun, 10 Jul 2011 15:08:03 +0000 (17:08 +0200)]
Factor verify_table() out of ef_verify()

12 years agoFix return value of ef_verify() to match function comment
Markus Armbruster [Sun, 10 Jul 2011 15:05:03 +0000 (17:05 +0200)]
Fix return value of ef_verify() to match function comment

Comment added in commit 6eec0010.  Callers don't actually care.

12 years agoFix prewrite callbacks' cargo list update for in-place update
Markus Armbruster [Sun, 10 Jul 2011 13:36:24 +0000 (15:36 +0200)]
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.

12 years agoLand units loaded on land units fight che again
Markus Armbruster [Sat, 9 Jul 2011 15:46:40 +0000 (17:46 +0200)]
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.

12 years agoDon't leave cargo stuck on land unit killed by che
Markus Armbruster [Sat, 9 Jul 2011 15:46:40 +0000 (17:46 +0200)]
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.

12 years agoFactor lnd_dies_fighting_che() out of take_casualties()
Markus Armbruster [Sat, 9 Jul 2011 15:19:42 +0000 (17:19 +0200)]
Factor lnd_dies_fighting_che() out of take_casualties()

12 years agoUnits no longer die from lack of maintenance
Markus Armbruster [Tue, 5 Jul 2011 19:29:03 +0000 (21:29 +0200)]
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.

12 years agoBelatedly update info Maintenance for removed budget priorities
Markus Armbruster [Tue, 5 Jul 2011 19:16:05 +0000 (21:16 +0200)]
Belatedly update info Maintenance for removed budget priorities

Missed in commit 520446ef, v4.3.6.

12 years agoOops when stuck cargo snaps to new ship, plane or land unit
Markus Armbruster [Tue, 5 Jul 2011 19:06:40 +0000 (21:06 +0200)]
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.

12 years agoAvoid false positive generation oops in navigate and march
Markus Armbruster [Sun, 3 Jul 2011 07:53:39 +0000 (09:53 +0200)]
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.

12 years agoFix client redirection and execute for non-ASCII characters
Markus Armbruster [Sat, 2 Jul 2011 15:17:53 +0000 (17:17 +0200)]
Fix client redirection and execute for non-ASCII characters

The client rejects unauthorized redirection and execute.  Its
authorized check always fails for arguments with non-ASCII characters.
The culprit is ring_search(): It compares plain char to unsigned char,
which breaks when char is signed.  Believed to be broken in commit
8b7d0b91, v4.3.11.

Note that non-ASCII characters only work in UTF-8 sessions.  In ASCII
sessions, the server replaces them, and the authorized check fails.
Works as designed.

12 years agoFix prexec() comment pasto
Markus Armbruster [Sat, 2 Jul 2011 08:06:40 +0000 (10:06 +0200)]
Fix prexec() comment pasto

12 years agoFix execute not to mangle the argument when it prompts for it
Markus Armbruster [Sat, 2 Jul 2011 08:04:07 +0000 (10:04 +0200)]
Fix execute not to mangle the argument when it prompts for it

The argument is UTF-8.  If it's missing, execute() gets it with
getstring(), which mangles non-ASCII characters.  Clients reject
mangled file names for security reasons.

Fix by switching to ugetstring().  Missed in commit 69832255, v4.3.11.

Non-ASCII characters are still mangled in ASCII sessions, but that's
not expected to work.

12 years agoRevert "Simplify execute(): use getstarg() instead of getstring()"
Markus Armbruster [Sat, 2 Jul 2011 08:00:05 +0000 (10:00 +0200)]
Revert "Simplify execute(): use getstarg() instead of getstring()"

This reverts commit 96d1039c24774a9032b9e2014d4ce585fa0c764b.  It's in
the next commit's way.

12 years agoFix execute to filter input just like the main command loop
Markus Armbruster [Fri, 1 Jul 2011 18:12:37 +0000 (20:12 +0200)]
Fix execute to filter input just like the main command loop

When we added input filtering in v4.2.21, we missed the execute
command.  Because of that, funny characters can be treated differently
in batch files.

The main command loop uses getcommand(), which filters input.
execute() uses recvclient() directly, and doesn't filter input.  Both
feed the command to parse(), which drops unwanted control and
non-ASCII characters.

Input filtering drops unwanted control characters and, for ASCII
sessions, replaces non-ASCII characters by '?'.

Because of that, execute in ASCII sessions drops non-ASCII command
characters in batch files rather than replacing them.

Except where parts of the command are used raw: execute's command
echo, flash and wall message argument.  There, unwanted control
characters aren't dropped in UTF-8 sessions, and non-ASCII characters
are interpreted as UTF-8 in ASCII sessions.  Output filtering replaces
any resulting non-ASCII characters.

players column "last command" also uses the command raw, but commands
executed from batch files are not visible there, so it isn't affected.

To get rid of the differences, move the prompting from getcommand() to
command(), then switch execute() over to getcommand().

Side effect: the batch file's commands are now recorded in
player_commands[].  That's desirable.

12 years agoDon't record prompts in player_commands[]
Markus Armbruster [Fri, 1 Jul 2011 17:54:55 +0000 (19:54 +0200)]
Don't record prompts in player_commands[]

Recording prompts is of marginal value, and it's in the next commit's
way.

If you need better logs after a crash, consider enabling the journal
log file.

12 years agoFix execute to print UTF-8 command correctly
Markus Armbruster [Sat, 2 Jul 2011 05:36:07 +0000 (07:36 +0200)]
Fix execute to print UTF-8 command correctly

execute() prints the UTF-8 command as normal text, which messes up
non-ASCII characters.  Broken in commit 2cc44bb1, v4.2.21.

12 years agoFix input/output filtering to ASCII
Markus Armbruster [Sat, 2 Jul 2011 07:09:27 +0000 (09:09 +0200)]
Fix input/output filtering to ASCII

copy_utf8_to_ascii_no_funny() eats the character following a replaced
non-ASCII character.  Buffer overrun possible when the terminating
zero gets eaten.  Broken in commit b5ff7e3b, v4.2.21.

Affected commands:

* players column "last command" in ASCII sessions: struct player
  member combuf is UTF-8, uprnf() filters to ASCII.

* read in ASCII sessions: telegram chunks are UTF-8, uprnf() filters
  to ASCII.

* flash and wall with message argument in ASCII sessions: argument is
  used raw, i.e. UTF-8, pr_flash() filters to ASCII.  Safe as long as
  we have input filtering sanitizing the raw argument.  command() does
  that, but execute() doesn't (bug, to be fixed in a later commit).

* execute prompting for its argument in UTF-8 sessions: prmptrd()
  receives user text, and filters to ASCII.

Unaffected:

* dispatch() argument redir is UTF-8, uprnf() can filter to ASCII.
  Safe as long as we have input filtering sanitizing the raw argument.
  command() does that.  execute() doesn't, but rejects redirections
  before calling dispatch().

* getele() buffer is UTF-8, uprnf() can filter to ASCII.  Safe,
  because its contents comes from uprmptrd(), which filters input.

12 years agoUpdate and report status even after empty command
Markus Armbruster [Fri, 1 Jul 2011 17:05:16 +0000 (19:05 +0200)]
Update and report status even after empty command

When getcommand() reads an empty string, it prints another prompt and
reads another line, without running status().  That's bad:

* nat_timeused is not updated.  Affects the player's prompt, deities'
  nat selector timeused, and commands edit, players, xdump nat.

* Mortal player isn't logged off for game hours, game down, and time
  limit.

* Notifications are delayed: going broke, becoming solvent, new
  telegrams (toggle inform off only), new announcements, capital lost.

Fix by removing the loop.  Callers handle empty input just fine since
4.2.2.

Side effect: empty commands are now recorded in player_commands[].
That's okay.

12 years agoFix xundump's "value must match" check for split tables
Markus Armbruster [Mon, 20 Jun 2011 19:55:52 +0000 (21:55 +0200)]
Fix xundump's "value must match" check for split tables

The check applies to selectors with flag NSC_CONST set.  It permits
initializing them in new objects, but prevents changing them in
existing objects.  For split tables, initialization worked only in the
first part, because new objects were considered old in later parts.

For instance, in a custom config sect-chr with mnem in the second
part's field 2, new sector types were rejected with `Value for field 2
must be ""'.

12 years agoBelatedly update xdump.pl not to use "xdump ver"
Markus Armbruster [Wed, 15 Jun 2011 09:36:45 +0000 (11:36 +0200)]
Belatedly update xdump.pl not to use "xdump ver"

"version" is a normal table since commit da8a1dae, v4.3.12.  xdump.pl
wasn't updated for that, and queried the version table twice.  When
the deprecated special "xdump ver" was removed in commit 78b3af20
(v4.3.27), the extra query broke.  Remove it.

12 years agoDisable test of pre_update_hook in nightly build
Markus Armbruster [Thu, 2 Jun 2011 18:08:52 +0000 (20:08 +0200)]
Disable test of pre_update_hook in nightly build

Where exactly the output from pre_update_hook gets inserted in the log
depends on timing.  Messes up diffs between test runs.

12 years agoFix nightly's diff_to_prev.sh
Markus Armbruster [Thu, 2 Jun 2011 15:26:30 +0000 (17:26 +0200)]
Fix nightly's diff_to_prev.sh

Broken in commit 5d512312, v4.3.11

12 years agoFactor product code out of ef_verify() into verify_products()
Markus Armbruster [Sun, 22 May 2011 06:42:35 +0000 (08:42 +0200)]
Factor product code out of ef_verify() into verify_products()

12 years agoFold pln_zap_transient_flags() into verify_planes()
Markus Armbruster [Sun, 22 May 2011 06:39:07 +0000 (08:39 +0200)]
Fold pln_zap_transient_flags() into verify_planes()

12 years agoVerify carrier references are sane
Markus Armbruster [Sun, 22 May 2011 06:20:25 +0000 (08:20 +0200)]
Verify carrier references are sane

Catch bad references here, before unit_cargo_init() chokes on them.

12 years agoDrop pln_zap_transient_flags()'s work-around for unusable putplane()
Markus Armbruster [Sun, 22 May 2011 06:10:41 +0000 (08:10 +0200)]
Drop pln_zap_transient_flags()'s work-around for unusable putplane()

I believe putplane() became usable here in commit 3cf29456, v4.3.17.
The work-around was pretty wasteful (not that it mattered).

12 years agoFix empdump not to touch plane file when import fails
Markus Armbruster [Sun, 22 May 2011 05:46:57 +0000 (07:46 +0200)]
Fix empdump not to touch plane file when import fails

pln_zap_transient_flags() fixes up planes stuck in the air (commit
7ca4f412, v4.3.12).  Since commit 4e9e58bf (v4.3.14), it writes back
the fixed planes.  This is wrong for empdump.

empdump should touch data only on successful import.  When it fails
because ef_verify() fails, and any planes are found stuck in the air,
the plane file gets rewritten.

Make parameter ef_verify() take parameter may_put to let empdump
suppress the plane write-back.  The plane file still get written out
on successful import, along with the other imported game state.

12 years agoVerify game state and configuration reference sanity
Markus Armbruster [Mon, 25 Apr 2011 07:45:58 +0000 (09:45 +0200)]
Verify game state and configuration reference sanity

Table elements reference other table elements.  Bad things happen when
references dangle.  ef_verify() already checks whether the referenced
table elements exist.  This commit makes it check whether the elements
are "in use".  This catches stuff like living planes on dead carriers.

12 years agoVerify table uid sanity more tightly
Markus Armbruster [Mon, 25 Apr 2011 07:34:11 +0000 (09:34 +0200)]
Verify table uid sanity more tightly

verify_row() refrains from rejecting zero uids, because some tables
may contain blank entries, with zero uid.

Change it to check only header sanity for entries that are not in use.
This filters out all legitimately blank entries.  Tighten up the uid
check.

For computing "in use", factor empobj_in_use() out of xdvisible().
Note that xdvisible()'s case EF_COUNTRY doesn't bother to check
nat_stat, because that's implied by what it does check.  It's not
implied in empobj_in_use(), so add it there.

12 years agoFactor verify_tabref() out of verify_row()
Markus Armbruster [Mon, 25 Apr 2011 06:44:11 +0000 (08:44 +0200)]
Factor verify_tabref() out of verify_row()

12 years agoChange xdump realm not to dump unused countries' realms
Markus Armbruster [Sun, 19 Jun 2011 16:52:32 +0000 (18:52 +0200)]
Change xdump realm not to dump unused countries' realms

Affects only deities; mortals can only see their own realms.

12 years agoRemove option LANDSPIES, customize table land-chr instead
Markus Armbruster [Sun, 22 May 2011 15:04:46 +0000 (17:04 +0200)]
Remove option LANDSPIES, customize table land-chr instead

Spy units are now enabled when a land unit type with capability spy
exists.  To disable them, deities have to customize table land-chr.

Before, spy units types were ignored when option LANDSPIES was
disabled.  Except for xdump land-chr, which happily dumped unusable
spy unit types.

12 years agoRemove option TRADESHIPS, customize table ship-chr instead
Markus Armbruster [Sun, 22 May 2011 14:49:17 +0000 (16:49 +0200)]
Remove option TRADESHIPS, customize table ship-chr instead

Trade ships are now enabled when a ship type with capability trade
exists.  No such type exists by default; to enable trade ships,
deities have to customize table ship-chr.

Before, trade ship types were ignored when option TRADESHIPS was
disabled.  Except for xdump ship-chr, which happily dumped unusable
trade ship types.

12 years agoFix scuttle_it()'s "is a trade ship" sanity check
Markus Armbruster [Sun, 22 May 2011 10:40:07 +0000 (12:40 +0200)]
Fix scuttle_it()'s "is a trade ship" sanity check

Only trade ships can be auto-scuttled.  orde() rejects scuttle orders
for other ships.  scuttle_it() double-checks, but gets the test wrong:
it rejects only when opt_TRADESHIPS is enabled.  Fix that.  While
there, make it oops on inadmissible ships.

12 years agoFix how configuration tables and empdump treat omitted entries
Markus Armbruster [Sun, 22 May 2011 07:14:11 +0000 (09:14 +0200)]
Fix how configuration tables and empdump treat omitted entries

Change xundump to blank out omitted rows.  Before, they were left
alone.  Impact:

* No change for reading builtin tables.

* Reading custom tables now replaces the builtin tables instead of
  sort-of-merging them.  Wasn't a real merge, because it dropped
  builtin entries after the last custom entry, except for
  non-truncatable tables item, sect-chr and infrastructure.

* empdump -i now replaces the old state instead of sort-of-merging the
  dump into the old state.  Wasn't a real merge, because it dropped
  old state entries after the last entry in the dump, except for the
  fixed-size tables sect, nat, realm and game.

12 years agoDon't misinterpret blank configuration entries as sentinels
Markus Armbruster [Sat, 21 May 2011 15:49:17 +0000 (17:49 +0200)]
Don't misinterpret blank configuration entries as sentinels

Configuration table entries not defined by builtin and custom
configuration files remain blank.  They get misinterpreted as sentinel
in tables that use one.  Affected are tables product, ship-chr,
plane-chr, land-chr and nuke-chr.  Tables item, sect-chr and
infrastructure are immune despite using a sentinel, because omitting
entries is not permitted there.

Code relying on the sentinel fails to pick up entries after the first
blank one.  They don't get set up correctly, they're invisible to
build and show, and not recognized as symbolic selector values (the
frg in ship ?type=frg).  xdump is fine, because it doesn't rely on
sentinels.  It dumps blank entries normally.

The bugs don't bite in the stock game, because the builtin
configuration files are all dense.

The sentinels are all null strings.  Set them to "" in the affected
tables' oninit callback.  Fix up code iterating over the tables to
ignore such entries.  This is precisely the code relying on sentinels,
plus xdump's xdvisible().

12 years agoChange stmtch() to recognize only null as sentinel
Markus Armbruster [Mon, 25 Apr 2011 12:21:44 +0000 (14:21 +0200)]
Change stmtch() to recognize only null as sentinel

Before, it also recognized "" (since commit 844b654d, v4.2.14), but
no caller depends on that.

While there, back out the macro cleverness added in commit 844b654d.

12 years agoPermit omitting rows at the end of tables nat and game
Markus Armbruster [Tue, 14 Jun 2011 07:09:19 +0000 (09:09 +0200)]
Permit omitting rows at the end of tables nat and game

When not enough rows are supplied for a table with fixed size, treat
the rows missing at the end just like rows omitted elsewhere: make
them blank if the omission is permitted (tables nat and game), else
fail (tables sect and realm; no change).

12 years agoForbid omitting rows in config item and sect-chr
Markus Armbruster [Mon, 13 Jun 2011 09:27:04 +0000 (11:27 +0200)]
Forbid omitting rows in config item and sect-chr

Forbid omitting rows for tables with const fields: item and sect-chr.
This is consistent with the rule for truncation.

The server expects certain entries in these two tables, and
malfunctions when they're blank.  Omitting them in the builtin tables
has always left them blank, but deities are not supposed to edit them,
and maintainers are supposed to know what they're doing, so the issue
was deemed unimportant and ignored.  However, I plan to blank out
omitted rows in custom tables as well, and then the issue isn't
unimportant anymore.

12 years agoMake xundump check each partial table supplies the same rows
Markus Armbruster [Sun, 8 May 2011 04:56:11 +0000 (06:56 +0200)]
Make xundump check each partial table supplies the same rows

Also streamline the error message for missing rows at end of table.

12 years agoMake xundump reject out-of-order rows
Markus Armbruster [Sat, 7 May 2011 15:45:19 +0000 (17:45 +0200)]
Make xundump reject out-of-order rows

This also catches duplicate rows.  Will make blanking out gaps easier.

12 years agoPermit truncating table product
Markus Armbruster [Sat, 18 Jun 2011 15:10:34 +0000 (17:10 +0200)]
Permit truncating table product

Truncating is actually fine for table product.  It's forbidden because
selector sname has flag NSC_CONST set.  I don't remember why sname was
made const in commit 445dfec9 along with item selector mnem, sect-chr
selector mnem and infrastructure selector name.  Unlike the other
tables, no code depends on product's builtin values.  Clear the flag.

12 years agoClean up xundump's test whether table may be truncated
Markus Armbruster [Sun, 22 May 2011 09:05:01 +0000 (11:05 +0200)]
Clean up xundump's test whether table may be truncated

A table may be truncated when its size is variable and it doesn't have
const fields.  The old code tested table IDs instead.

12 years agoOverhaul how xundump keeps track of current object
Markus Armbruster [Sat, 7 May 2011 15:30:44 +0000 (17:30 +0200)]
Overhaul how xundump keeps track of current object

Factor tracking of cur_type, cur_obj, cur_id and cur_is_blank into a
set of functions.  They replace getobj().  While there, improve some
error messages.

12 years agoMove src/lib/subs/empobj.c back to src/lib/common/
Markus Armbruster [Sat, 21 May 2011 13:52:26 +0000 (15:52 +0200)]
Move src/lib/subs/empobj.c back to src/lib/common/

Commit 77e95bd7 (v4.3.12) moved it from its natural home because
obj_nameof() required stuff from subs/.  Now that obj_nameof() is
gone, move it back.

12 years agoRename obj_nameof() to unit_nameof() and move to unitsub.c
Markus Armbruster [Sat, 21 May 2011 13:42:38 +0000 (15:42 +0200)]
Rename obj_nameof() to unit_nameof() and move to unitsub.c

12 years agoRemove unused get_empobj_chr()
Markus Armbruster [Sat, 21 May 2011 13:33:31 +0000 (15:33 +0200)]
Remove unused get_empobj_chr()

Unused since commit 5e77193c, v4.3.24.

12 years agoRefuse to grow or truncate files with fixed size
Markus Armbruster [Wed, 4 May 2011 18:51:54 +0000 (20:51 +0200)]
Refuse to grow or truncate files with fixed size

Make ef_write() treat it like any other invalid write beyond the file
size: oops.  Be less harsh in ef_extend() and ef_truncate(): log an
error.

12 years agoMake ef_open() extend files with fixed size automatically
Markus Armbruster [Wed, 4 May 2011 05:45:05 +0000 (07:45 +0200)]
Make ef_open() extend files with fixed size automatically

Turns the fixed size into an invariant.  Before, the files utility
created them empty, then extended them.

12 years agoMove pln_oninit(), lnd_oninit(), nuk_oninit() to filetable.c
Markus Armbruster [Tue, 3 May 2011 19:47:29 +0000 (21:47 +0200)]
Move pln_oninit(), lnd_oninit(), nuk_oninit() to filetable.c

They set up invariants, and thus should be always active, not just in
the server.  Since ef_blank() isn't used for these files outside the
server right now, this isn't a bug fix, just cleanup.

12 years agoMove file initialization from files.c to empfile oninit()
Markus Armbruster [Tue, 3 May 2011 18:48:56 +0000 (20:48 +0200)]
Move file initialization from files.c to empfile oninit()

files.c writes initial contents to game state files with fixed size.
Necessary for setting up invariants, such as struct sctstr members
sct_x, sct_y matching sct_uid.

Do that from the oninit() callback, so ef_blank() sets up invariants
correctly.  Since ef_blank() isn't used for these files right now,
this isn't a bug fix, just cleanup.

12 years agoInitialize empfile user callbacks explicitly
Markus Armbruster [Tue, 3 May 2011 18:46:38 +0000 (20:46 +0200)]
Initialize empfile user callbacks explicitly

Instead of stuffing NULL initializers into the cache initializer
macros UNMAPPED_CACHE(), ARRAY_CACHE(), PTR_CACHE(), ARRAY_TABLE().
In preparation of having some non-NULL initializers.

12 years agoFix empdump not to grow game state files with fixed size
Markus Armbruster [Tue, 3 May 2011 05:53:37 +0000 (07:53 +0200)]
Fix empdump not to grow game state files with fixed size

empdump -i now complains about extra rows instead of silently growing
the file to a size the server will reject.  Affects tables sector,
nation, realms, game.

Bonus fix: better error message on I/O error or insufficient memory.

12 years agoFix empdump not to truncate game state files with fixed size
Markus Armbruster [Mon, 2 May 2011 20:27:26 +0000 (22:27 +0200)]
Fix empdump not to truncate game state files with fixed size

empdump -i now complains about missing rows instead of silently
truncating the file to a size the server will reject.  Affects tables
sector, nation, realms, game.

12 years agoClean up how game state file sizes are checked
Markus Armbruster [Sun, 1 May 2011 12:18:24 +0000 (14:18 +0200)]
Clean up how game state file sizes are checked

New struct empfile member nent replaces ef_open() parameter nelt.
Cleaner, because the expected size is a property of the file, not of
how it's used.  Also fixes empdump to check file sizes.

Complication: with EFF_CREATE, ef_open() creates an empty file, to be
extended to the correct size.  Callers passed nelt argument -1 along
with EFF_CREATE, to make ef_open() accept the empty file.  Can't do
the same for empfile member nent.  Instead, make ef_open() not check
the (zero) size then.

Replaces commit 5750107b, v4.3.15.

12 years agoFix empdump to open views, too
Markus Armbruster [Sun, 1 May 2011 12:09:35 +0000 (14:09 +0200)]
Fix empdump to open views, too

ef_verify() assumes views are open.  Bug is harmless, because
ef_nelem() returns zero for closed views, and ef_verify() accesses
only immutable parts of struct empfile then.

12 years agoClean up how a view's base table is defined
Markus Armbruster [Sun, 1 May 2011 11:59:17 +0000 (13:59 +0200)]
Clean up how a view's base table is defined

New struct empfile member base replaces ef_open_view() parameter base.
Cleaner, because the base table is a property of the view, not of how
it's used.

Use it to clean up verify_fail()'s base table access, and for extra
sanity checks in ef_open() and ef_open_view().

12 years agoSimplify how ef_write() handles write beyond end of file
Markus Armbruster [Fri, 29 Apr 2011 05:23:07 +0000 (07:23 +0200)]
Simplify how ef_write() handles write beyond end of file

12 years agoMake ef_close() set fids later, so it's cleaned up on error
Markus Armbruster [Thu, 28 Apr 2011 18:52:37 +0000 (20:52 +0200)]
Make ef_close() set fids later, so it's cleaned up on error

Just for cleanliness.

12 years agoClean up ef_close() to zap csize along with cache
Markus Armbruster [Thu, 28 Apr 2011 18:41:59 +0000 (20:41 +0200)]
Clean up ef_close() to zap csize along with cache

12 years agoChange struct empfile callback onresize() to return void
Markus Armbruster [Thu, 28 Apr 2011 18:38:39 +0000 (20:38 +0200)]
Change struct empfile callback onresize() to return void

ef_open() handles onresize() failing incorrectly.  Instead of fixing
that, drop the failure mode.  It's not really used: unit_onresize()
fails only when used incorrectly.  It isn't.  If it ever is, ignoring
the failure is safe.

12 years agoFix clearing mutable flags on ef_close()
Markus Armbruster [Thu, 28 Apr 2011 18:20:43 +0000 (20:20 +0200)]
Fix clearing mutable flags on ef_close()

Make ef_close() clear them always, even for views.  Harmless, as
ef_open_view() always sets the same flags.

Drop redundant assignment to ep->flags in ef_open().  ef_close()
clears mutable flags, no need to clear them some more right before
calling it.  Missed in commit 3eb3607f, v4.3.0.

12 years agoFix EFF_IMMUTABLE to include EFF_SENTINEL
Markus Armbruster [Wed, 27 Apr 2011 17:46:15 +0000 (19:46 +0200)]
Fix EFF_IMMUTABLE to include EFF_SENTINEL

ef_open() and ef_close() clear EFF_SENTINEL because of that.  Broken
since commit 1492845c (v4.3.17) added EFF_SENTINEL.  Harmless, as no
file-backed table has a sentinel.

12 years agoFix ef_open()'s error message for file larger than static cache
Markus Armbruster [Wed, 27 Apr 2011 17:44:26 +0000 (19:44 +0200)]
Fix ef_open()'s error message for file larger than static cache

The message claims the file is larger than it actually is.  Broken
since commit 71908018 (v4.3.0) implemented static cache in ef_open().
Harmless, because no file-backed table has a statically allocated
cache.

12 years agoFix how empdump rejects attempt to split table sect
Markus Armbruster [Sun, 8 May 2011 10:40:56 +0000 (12:40 +0200)]
Fix how empdump rejects attempt to split table sect

Split tables require the record index in the leftmost column.
defellipsis() correctly rejects "..." when the table doesn't have one.
It fails to reject it when it has one that is NSC_EXTRA, and thus not
permitted in a dump.  This is the case for table sect.  defellipsis()
happily succeeds, then chkflds() demands column "uid" if it's missing,
and rejects it if its present.

12 years agoempdump failed to catch some invalid column names
Markus Armbruster [Sun, 8 May 2011 10:12:09 +0000 (12:12 +0200)]
empdump failed to catch some invalid column names

It missed those with more flags than just NSC_EXTRA set: table sect
name uid, table nat names passwd, xorg, yorg, contacts, rejects.
Since xundump() doesn't provide space for these, the bug could lead to
buffer overruns.  Fixes flawed commit 726a8e3d, v4.3.12.

12 years agoFix empdump to check for truncation failure
Markus Armbruster [Sat, 7 May 2011 19:05:02 +0000 (21:05 +0200)]
Fix empdump to check for truncation failure

xubody() neglected to check ef_truncate()'s return value.  Two failure
modes: invalid arguments, and ftruncate() failure.  The former
shouldn't happen, and the latter can happen only for file-backed
tables, hence only in empdump -i.

12 years agoMake xundump report invalid record IDs
Markus Armbruster [Sat, 7 May 2011 15:17:06 +0000 (17:17 +0200)]
Make xundump report invalid record IDs

It failed silently before.

12 years agoMake xundump reject numbers that don't fit into integral field
Markus Armbruster [Sat, 7 May 2011 15:12:05 +0000 (17:12 +0200)]
Make xundump reject numbers that don't fit into integral field

Numbers are read into a double, then cast to the field type.  The cast
may change the value.  Flag that as error, except for floating-point
fields.

12 years agoRestrict xundump to tables with a file name
Markus Armbruster [Mon, 2 May 2011 20:20:58 +0000 (22:20 +0200)]
Restrict xundump to tables with a file name

Tables with a file name are: any game state, and any table that's
initialized from a .config file.

Tables that are no longer customizable: "updates" (customization had
no effect, because update_get_schedule() overwrote it), "table",
"meta" and the symbol tables (customization couldn't change them
anyway), and news-chr (customizing r_newsstory[] was kind of neat, but
unsafe because they are format strings for sprintf()).

12 years agoFix xdump updates not to dump bogus extra updates
Markus Armbruster [Sat, 30 Apr 2011 05:35:14 +0000 (07:35 +0200)]
Fix xdump updates not to dump bogus extra updates

"xdump updates" believes there are always 15 (UPDATE_TIME_LEN - 1)
scheduled updates.  When fewer than 15 updates are scheduled, it shows
whatever crap update time happens to be in the unused part of
update_time[]: the initial zero or a previously scheduled update.

Root cause is that table EF_UPDATES has always UPDATE_TIME_LEN - 1
entries, which is incorrect when fewer updates are scheduled.  Only
xdump is affected, as the other users ignore the length and stop at
the sentinel.

Fix update_get_schedule() to resize table EF_UPDATES.

12 years agoCheck record uid comes first in split config tables
Markus Armbruster [Wed, 27 Apr 2011 05:15:00 +0000 (07:15 +0200)]
Check record uid comes first in split config tables

setnum() requires the record uid to come first, so we better ensure it
does.

12 years agoDon't stop checking xdump field headers when join field is missing
Markus Armbruster [Wed, 27 Apr 2011 05:03:09 +0000 (07:03 +0200)]
Don't stop checking xdump field headers when join field is missing

Also improve the error message a bit.

12 years agoA few comment fixes for nsc.[ch] file.[ch]
Markus Armbruster [Mon, 25 Apr 2011 08:45:04 +0000 (10:45 +0200)]
A few comment fixes for nsc.[ch] file.[ch]