]> git.pond.sub.org Git - empserver/log
empserver
12 years agoFix clear_telegram_is_new() for TEL_NORM from POGO at the epoch
Markus Armbruster [Sun, 20 Nov 2011 18:26:20 +0000 (19:26 +0100)]
Fix clear_telegram_is_new() for TEL_NORM from POGO at the epoch

Purely theoretical, of course.

12 years agoClean up how telegram_is_new() detects production report
Markus Armbruster [Sun, 20 Nov 2011 18:11:04 +0000 (19:11 +0100)]
Clean up how telegram_is_new() detects production report

Test for TEL_UPDATE, not update_running.

12 years agoMove clear_telegram_is_new() call to beginning of update
Markus Armbruster [Sun, 20 Nov 2011 17:30:39 +0000 (18:30 +0100)]
Move clear_telegram_is_new() call to beginning of update

The call was added in 4.2.5 "so that the next telegram is flagged as
new and not part of the update".  Since the update sends only
TEL_UPDATE telegrams (the previous commit restored that property), and
nothing else does, the next telegram is flagged as new automatically,
except when it's from the next update.  Document that, and move the
call to a more natural place.

12 years agoEnsure the update's production report isn't split by bulletins
Markus Armbruster [Sun, 20 Nov 2011 17:26:43 +0000 (18:26 +0100)]
Ensure the update's production report isn't split by bulletins

During the update, wu() sends TEL_UPDATE telegrams ("Production
Report") instead of TEL_BULLETIN telegrams, but typed_wu() has no such
logic.  It's used by tele(), which doesn't run during the update, and
mpr(), which may, e.g. called from ship or mission code used by
autonav or sail.  This inserts bulletins in the middle of the
production report, splitting it apart.

Happens since mpr() was added in Empire 2.  Before, only tele() used
typed_wu() directly, and everything else wu().

Change mpr() to use wu().

12 years agoSaner error handling in typed_wu()
Markus Armbruster [Sun, 20 Nov 2011 14:14:36 +0000 (15:14 +0100)]
Saner error handling in typed_wu()

Leave nat_ann, nat_tgm alone and return -1 on all errors.  Before,
only failed open was handled that way.  Failed write and close were
logged and ignored.  While there, improve the log messages a bit.

Note: the return value fix has little effect.  It makes tele() log the
failure, which is redundant.  Everything else goes through wu() and
ignores the value.

12 years agoDrop superfluous fseek() from rea()
Markus Armbruster [Sun, 13 Nov 2011 18:04:07 +0000 (19:04 +0100)]
Drop superfluous fseek() from rea()

12 years agoMake add require confirmation for unadvisable actions
Markus Armbruster [Sun, 6 Nov 2011 18:40:21 +0000 (19:40 +0100)]
Make add require confirmation for unadvisable actions

Deleting a country in state STAT_SANCT, STAT_ACTIVE or STAT_GOD is
risky, because any references to this country become dangling, which
makes ef_verify() unhappy.  For a reason: we may well have code that
isn't prepared for dangling references, and breaks.

Replacing a country that is being used is risky, because it can get us
into weird states.  For instance, replacing a player by a visitor can
result in a visitor that owns stuff.

12 years agoMake add refuse to touch a country while it's being played
Markus Armbruster [Sun, 6 Nov 2011 18:13:59 +0000 (19:13 +0100)]
Make add refuse to touch a country while it's being played

I suspect player code could get terminally confused by country state
changing unexpectedly.  Not worth the risk.

12 years agoFix add not to crash on negative country number
Markus Armbruster [Sun, 6 Nov 2011 18:09:26 +0000 (19:09 +0100)]
Fix add not to crash on negative country number

12 years agoDon't bother giving POGO BTUs in files
Markus Armbruster [Sun, 6 Nov 2011 18:02:56 +0000 (19:02 +0100)]
Don't bother giving POGO BTUs in files

Deity's BTUs get reset to maximum on login anyway.

12 years agoCreate all deities with $123456789, not just POGO
Markus Armbruster [Sun, 6 Nov 2011 13:00:54 +0000 (14:00 +0100)]
Create all deities with $123456789, not just POGO

12 years agoMove setting nat_cnam, nat_pnam into nat_reset()
Markus Armbruster [Sun, 6 Nov 2011 12:56:34 +0000 (13:56 +0100)]
Move setting nat_cnam, nat_pnam into nat_reset()

12 years agoUse nat_reset() for POGO in files.c
Markus Armbruster [Sun, 6 Nov 2011 12:30:14 +0000 (13:30 +0100)]
Use nat_reset() for POGO in files.c

Requires moving it from subs/natsub.c to common/nat.c.

12 years agoMake files set the usual nation flags for POGO
Markus Armbruster [Sun, 6 Nov 2011 09:28:54 +0000 (10:28 +0100)]
Make files set the usual nation flags for POGO

The add command sets nation flags NF_FLASH, NF_BEEP, NF_COASTWATCH,
NF_SONAR, and since 4.2.6 NF_TECHLISTS.  POGO is created by the files
utility, which sets only NF_FLASH (since 4.2.2).  Change files to
match add.

12 years agonat_reset() is no longer used with STAT_SANCT, simplify
Markus Armbruster [Sun, 6 Nov 2011 09:17:09 +0000 (10:17 +0100)]
nat_reset() is no longer used with STAT_SANCT, simplify

12 years agoChange newcap back to not wiping the country
Markus Armbruster [Sat, 5 Nov 2011 15:57:56 +0000 (16:57 +0100)]
Change newcap back to not wiping the country

Just create sanctuaries, put country into STAT_SANCT, grant BTUs and
money, set origin and initial realms.

This reverts commit e1a68c72 (v4.3.12) as far as newcap is concerned.
Except we still set nat_access, because that needs to be set along
with nat_btu.

Additionally, leave levels and telegrams alone.

Should have no effect in practice, because newcap works only in
STAT_NEW, and we get there with the add command, which wipes the
country.

12 years agoMake add always reset the country
Markus Armbruster [Sun, 30 Oct 2011 17:46:24 +0000 (18:46 +0100)]
Make add always reset the country

Before, add reset the country only when adding a player or a visitor.
When adding a deity or deleting a country, it set just nat_cnam,
nat_pnam and nat_state.  Has always been that way.

Because of that, a newly minted deity country could inherit all kinds
of crap from a previous user of its country number: origin, realms,
relations, telegrams, ...  Harmless if the country number has never
been used before, which is how add is generally used.

When adding a deity country, initial levels (start_education, ...) now
apply, relations start NEUTRAL instead of AT_WAR, and the usual
initial nation flags are set.

Reset on delete as well, just to get rid of the special case.

12 years agoRename add argument "new" to "player"
Markus Armbruster [Sun, 30 Oct 2011 15:29:32 +0000 (16:29 +0100)]
Rename add argument "new" to "player"

This makes the correct choice for player countries obvious.  Keep
recognizing "new" for now, but deprecate it.

12 years agoDrop add argument "active"
Markus Armbruster [Sun, 30 Oct 2011 15:11:02 +0000 (16:11 +0100)]
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.

12 years agoDrop add's obscure sector check and wipe functionality
Markus Armbruster [Sun, 30 Oct 2011 14:51:46 +0000 (15:51 +0100)]
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.

12 years agoDrop add's undocumented land unit destruction feature
Markus Armbruster [Sun, 30 Oct 2011 14:46:42 +0000 (15:46 +0100)]
Drop add's undocumented land unit destruction feature

It doesn't destroy ships, planes or nukes, either.

12 years agoPermit no-op country name change again
Markus Armbruster [Sun, 30 Oct 2011 14:43:56 +0000 (15:43 +0100)]
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.

12 years agoImprove newcap's origin error message
Markus Armbruster [Sun, 30 Oct 2011 07:17:58 +0000 (08:17 +0100)]
Improve newcap's origin error message

12 years agoStreamline a few files error messages
Markus Armbruster [Sat, 29 Oct 2011 19:06:36 +0000 (21:06 +0200)]
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.

12 years agoFix files and fairland to report ef_open() failure just once
Markus Armbruster [Sat, 29 Oct 2011 18:52:33 +0000 (20:52 +0200)]
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.

12 years agoReplace exit(-1) by exit(1)
Markus Armbruster [Sat, 29 Oct 2011 18:25:01 +0000 (20:25 +0200)]
Replace exit(-1) by exit(1)

exit() uses only the least significant byte of its argument.

12 years agoMake allocate_memory() return void
Markus Armbruster [Sat, 29 Oct 2011 18:19:06 +0000 (20:19 +0200)]
Make allocate_memory() return void

It can't fail since commit ba1a320c, v4.3.15.

12 years agoGuard against unusable fd in pthreads' empth_select()
Markus Armbruster [Sat, 29 Oct 2011 15:16:08 +0000 (17:16 +0200)]
Guard against unusable fd in pthreads' empth_select()

0 <= fd < FD_SETSIZE must hold, or else undefined behavior in
FD_SET().

12 years agoFix lwpSleepFd()'s guard against unusable fd
Markus Armbruster [Sat, 29 Oct 2011 15:11:18 +0000 (17:11 +0200)]
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.

12 years agoPlug FILE leak on show_first_tel() error paths
Markus Armbruster [Sat, 29 Oct 2011 13:35:43 +0000 (15:35 +0200)]
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.

12 years agoPlug memory leak in set_paths() error path
Markus Armbruster [Sat, 29 Oct 2011 13:14:39 +0000 (15:14 +0200)]
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.

12 years agoFix read_schedule() not to fclose(stdin)
Markus Armbruster [Sat, 29 Oct 2011 12:51:37 +0000 (14:51 +0200)]
Fix read_schedule() not to fclose(stdin)

Did that since the initial commit 71320ed6, v4.3.10.

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.