]> git.pond.sub.org Git - empserver/log
empserver
10 years agoedit: Don't show loyalty, plague stage and time as percentages
Markus Armbruster [Tue, 15 Jan 2013 18:25:40 +0000 (19:25 +0100)]
edit: Don't show loyalty, plague stage and time as percentages

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoedit: Show edited planes and land units just like ships
Markus Armbruster [Tue, 15 Jan 2013 18:19:56 +0000 (19:19 +0100)]
edit: Show edited planes and land units just like ships

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoedit: Show the edited ship even when its owner is invalid
Markus Armbruster [Mon, 14 Jan 2013 22:23:23 +0000 (23:23 +0100)]
edit: Show the edited ship even when its owner is invalid

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoprnatid: Recover from getnatp() failure
Markus Armbruster [Mon, 14 Jan 2013 22:18:11 +0000 (23:18 +0100)]
prnatid: Recover from getnatp() failure

cname() calls getnatp(), and returns a null pointer when it fails.
Some systems (GNU, Windows) deal gracefully with printing null
strings, others crash.

Because we keep table EF_NATION entirely in memory, getnatp() should
fail only on invalid country number.

Rewrite prnatid() to catch this error and recover.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoprnat() prnatid(): New, common country name (#number) formatting
Markus Armbruster [Mon, 14 Jan 2013 22:15:03 +0000 (23:15 +0100)]
prnat() prnatid(): New, common country name (#number) formatting

prnat() is more convenient when you already got the struct natstr *.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoedit: Rename some of helpers, and reorder parameters
Markus Armbruster [Mon, 14 Jan 2013 22:02:58 +0000 (23:02 +0100)]
edit: Rename some of helpers, and reorder parameters

doland() edits a sector, not a land unit.  That one's called dounit().
Lacks taste.  Call the helper for editing a FOO edit_FOO(), and make
the FOO * the first parameter instead of the last.

Rename the print helpers to print_FOO(), for consistency.  Also frees
up identifier prnat for the next commit.

While there, clean up an unused #define.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoReplace common pattern by new LIMIT_TO()
Markus Armbruster [Mon, 14 Jan 2013 21:34:05 +0000 (22:34 +0100)]
Replace common pattern by new LIMIT_TO()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agotests/actofgod: New, disabled for now because it oopses
Markus Armbruster [Sat, 1 Jun 2013 10:46:40 +0000 (12:46 +0200)]
tests/actofgod: New, disabled for now because it oopses

This is a fairly comprehensive test of the deity commands to edit game
state: edit, setresource, setsector, give, swapsector.

The test makes edit screw up game state, triggering oopses.  The
server refuses to start without -F then, and empdump -x warns "export
has errors, not importable as is".  Until these bugs are fixed, skip
this test in "make check".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agomake: Drop unused support for parallel test runs
Markus Armbruster [Sat, 1 Jun 2013 10:44:02 +0000 (12:44 +0200)]
make: Drop unused support for parallel test runs

Tests can't run in parallel anyway, because they use uses a single
sandbox directory and a single TCP port.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoempdump: Don't abort() on unresolvable symbols
Markus Armbruster [Sat, 1 Jun 2013 08:36:33 +0000 (10:36 +0200)]
empdump: Don't abort() on unresolvable symbols

empdump flags them since commit 2a5d12b (v4.3.28), but still aborts.
Avoid the abort.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agotests: Capture player output via journal instead of client
Markus Armbruster [Fri, 31 May 2013 08:41:18 +0000 (10:41 +0200)]
tests: Capture player output via journal instead of client

Capturing the client's output tests both client and server, which is
nice.  However, player input isn't visible in the resulting file,
which makes it more difficult to understand.

Route player output to journal (econfig key "keep_journal 2"), and
ignore client output.

Separate tests for the client would be useful.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoclient: Send login commands without trailing space
Markus Armbruster [Fri, 31 May 2013 08:02:54 +0000 (10:02 +0200)]
client: Send login commands without trailing space

Cosmetical improvement; the server is just fine with trailing space.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agotests: Cut off log file timestamp instead of normalizing it
Markus Armbruster [Fri, 31 May 2013 07:54:50 +0000 (09:54 +0200)]
tests: Cut off log file timestamp instead of normalizing it

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agotests: Enable thread stack checking (emp_server -s)
Markus Armbruster [Fri, 31 May 2013 07:27:09 +0000 (09:27 +0200)]
tests: Enable thread stack checking (emp_server -s)

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agocutoff level: Add FIXME comments to narrow coordinate columns
Markus Armbruster [Sun, 26 May 2013 09:31:21 +0000 (11:31 +0200)]
cutoff level: Add FIXME comments to narrow coordinate columns

When formatting coordinates for fixed-width output, the width should
be at least four characters.

cutoff was fine until 4.0.2 reduced coordinate width to three to make
space for civilian and military delivery thresholds.

level has always used width three.

Can't fix either without making lines too long or dropping
information, so just document the problem for now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agomission: Widen coordinate columns to four characters
Markus Armbruster [Sun, 26 May 2013 09:08:37 +0000 (11:08 +0200)]
mission: Widen coordinate columns to four characters

When formatting coordinates for fixed-width output, the width should
be at least four characters.

Columns x,y and op-sect use three.  Has always been that way.  Widen
them both to four.  This cleans up output for world sizes between 200
and 1998.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agosorder: Widen coordinate columns to four characters
Markus Armbruster [Sun, 26 May 2013 08:58:23 +0000 (10:58 +0200)]
sorder: Widen coordinate columns to four characters

When formatting coordinates for fixed-width output, the width should
be at least four characters.

Columns x,y, start and end use three.  Has always been that way,
except for end, which used two until commit e07fb30 (v4.2.13).

Widen them all to four.  This cleans up output for world sizes between
200 and 1998.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoland: Separate columns x,y and a in output properly
Markus Armbruster [Sat, 25 May 2013 17:59:19 +0000 (19:59 +0200)]
land: Separate columns x,y and a in output properly

Coordinates run into army when the y coordinate is wider than three
characters.  Has always been broken.  Insert a separating space.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agosatmap: Separate and align columns in output properly
Markus Armbruster [Sat, 25 May 2013 17:37:22 +0000 (19:37 +0200)]
satmap: Separate and align columns in output properly

Land unit coordinates run into efficiency in output of satellite when
the y coordinate is wider than three characters.  Broken in Empire 2.
Restore the separating space.

Both ship and land unit table header aren't aligned with the table
body.  Affects recon and sweep with spy planes, and satellite.  Fix
the header.

Reported-by: William Fittge <ptkei2@gmail.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agotcp_listen: Plug fd leak on OpenBSD with IPv6
Markus Armbruster [Sat, 25 May 2013 15:08:26 +0000 (17:08 +0200)]
tcp_listen: Plug fd leak on OpenBSD with IPv6

Leaks one file descriptor per configured IPv6 address, which should be
pretty harmless.  Broken in commit da154ff, v4.3.31.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoinfo/version: Update example to current output
Markus Armbruster [Sat, 25 May 2013 15:02:11 +0000 (17:02 +0200)]
info/version: Update example to current output

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoPut URIs and e-mail addresses in <angle brackets>
Markus Armbruster [Sat, 25 May 2013 15:01:05 +0000 (17:01 +0200)]
Put URIs and e-mail addresses in <angle brackets>

Also end URIs with '/' where appropriate.

Refrain from touching scripts/ and Stephen Crane's LWP authorship
note.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoversion: Consistently end sentences with periods
Markus Armbruster [Sat, 25 May 2013 14:47:55 +0000 (16:47 +0200)]
version: Consistently end sentences with periods

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agodoc/README: Clarify description of file coding
Markus Armbruster [Sat, 25 May 2013 13:51:15 +0000 (15:51 +0200)]
doc/README: Clarify description of file coding

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agodoc/coding: Correct spelling mistakes
Markus Armbruster [Sat, 25 May 2013 13:50:31 +0000 (15:50 +0200)]
doc/coding: Correct spelling mistakes

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agodoc/contributing: New file
Markus Armbruster [Sat, 25 May 2013 13:28:16 +0000 (15:28 +0200)]
doc/contributing: New file

Partly inspired by GNU coreutils HACKING[*].

doc/coding section "git" is now redundant, except for the note on
avoiding whitespace changes.  Move that to section "Code formatting",
and delete section "git".

[*] http://git.savannah.gnu.org/cgit/coreutils.git/plain/HACKING?id=77da73c

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoBump version to 4.3.32
Markus Armbruster [Wed, 15 May 2013 17:28:45 +0000 (19:28 +0200)]
Bump version to 4.3.32

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
10 years agoUpdate change log again for 4.3.31 v4.3.31
Markus Armbruster [Sun, 12 May 2013 16:59:42 +0000 (18:59 +0200)]
Update change log again for 4.3.31

10 years agoFix read beyond end of conditional argument on missing operand
Markus Armbruster [Sun, 12 May 2013 09:55:42 +0000 (11:55 +0200)]
Fix read beyond end of conditional argument on missing operand

nstr_parse_val() interprets argument "" as (empty) identifier, then
returns a pointer right beyond the end of the string.

The argument points into player->argbuf[].  If another argument
follows the conditional, it gets appended to the conditional.  Else,
whatever's left there from previous commands gets appended.  If the
argument is at the very end of player->argbuf[], we parse beyond the
buffer, until we run into a syntax error, or a zero byte.

Since player->argbuf[] is followed by a bunch of pointers, a syntax
error is almost certain.  If we somehow manage to parse all the
pointers and player->lasttime, the runaway parse will end at
player->btused, because that's definitely zero when conditionals get
parsed.

10 years agoDon't put broken links in HTML info pages
Markus Armbruster [Sat, 11 May 2013 14:44:40 +0000 (16:44 +0200)]
Don't put broken links in HTML info pages

Pass the valid info page names to emp2html.pl, and convert only valid
references to links there.

10 years agoTighten up emp2html's info reference recognition
Markus Armbruster [Sat, 11 May 2013 14:20:51 +0000 (16:20 +0200)]
Tighten up emp2html's info reference recognition

Combine the two loops looking for \*QNAME\*U and "info NAME" into one.
Recognize "info NAME" only with the closing '"' to be present.

No change with current info sources.

10 years agoFold subj2html.pl into emp2html.pl
Markus Armbruster [Sat, 11 May 2013 13:49:11 +0000 (15:49 +0200)]
Fold subj2html.pl into emp2html.pl

10 years agoUpdate change log for 4.3.31
Markus Armbruster [Wed, 8 May 2013 18:46:00 +0000 (20:46 +0200)]
Update change log for 4.3.31

10 years agoPermit ships that can drop depth charges, but not fire
Markus Armbruster [Wed, 8 May 2013 18:41:46 +0000 (20:41 +0200)]
Permit ships that can drop depth charges, but not fire

No such ships exist in the stock game.

10 years agoConsistently require guns for dropping depth charges
Markus Armbruster [Wed, 8 May 2013 18:37:36 +0000 (20:37 +0200)]
Consistently require guns for dropping depth charges

The fire command requires at least one gun for depth charging, but
missions and return fire don't.  Has always been that way, except
between 4.0.6 and commit a3ad623 (v4.3.12), when depth charging worked
exactly like gun fire, and guns were consistently required.

Require guns for all ways to drop depth charges.

10 years agoCover configure reporting "terminfo: no" in READMEs
Markus Armbruster [Wed, 8 May 2013 17:19:12 +0000 (19:19 +0200)]
Cover configure reporting "terminfo: no" in READMEs

10 years agoCast time_t to long for printing with %ld
Markus Armbruster [Wed, 8 May 2013 17:13:38 +0000 (19:13 +0200)]
Cast time_t to long for printing with %ld

struct timeval member tv_sec used to be long, but POSIX made it
time_t.

10 years agoInclude <sys/time.h> in lwp.h
Markus Armbruster [Tue, 7 May 2013 17:06:35 +0000 (19:06 +0200)]
Include <sys/time.h> in lwp.h

Missed in commit 08b9455, v4.3.20.  Triggers compiler warnings on
NetBSD 5.1.2.

10 years agoRefresh autoconf macros from autoconf-archive-2013.04.06
Markus Armbruster [Mon, 6 May 2013 18:13:43 +0000 (20:13 +0200)]
Refresh autoconf macros from autoconf-archive-2013.04.06

10 years agoMove auxiliary build tools to build-aux/
Markus Armbruster [Mon, 6 May 2013 18:03:22 +0000 (20:03 +0200)]
Move auxiliary build tools to build-aux/

10 years agoRefresh auxiliary build tools from automake 1.11.6
Markus Armbruster [Mon, 6 May 2013 17:55:05 +0000 (19:55 +0200)]
Refresh auxiliary build tools from automake 1.11.6

10 years agoChange econfig key rollover_avail_max from 0 to 50
Markus Armbruster [Mon, 6 May 2013 17:00:54 +0000 (19:00 +0200)]
Change econfig key rollover_avail_max from 0 to 50

So you don't have to micromanage workers to maximize useful work.

The previous commit made the problem a bit worse.  If you had a few
workers too many before, you perhaps produced an extra unit.  Now, you
get to keep the extra work instead.  Useless, unless it rolls over.

10 years agoMake sector production more predictable
Markus Armbruster [Mon, 6 May 2013 16:58:59 +0000 (18:58 +0200)]
Make sector production more predictable

produce() limits production to how many units the workers can produce,
rounding randomly.  It charges work for the units actually produced,
discarding fractions.

If you get lucky with the random rounding, you may get a bit of extra
work done for free.  Else, you get to keep the unused work, and may
even be undercharged a tiny bit of work.  Has always been that way.

The production command assumes the random rounding rounds up if and
only if the probability to do so is at least 50%.  Thus, it's
frequently off by one for sectors producing at their worker limit.

The budget command runs the update code, and is therefore also off by
one, only differently.

Rather annoying for tech and research centers, where a single unit
matters.  A tech center with full civilian population can produce 37.5
units in 60 etus.  Given enough materials, it'll fluctuate between 37
and 38.  Production consistently predicts 38, and budget randomly
predicts either 37 or 38.  Both are off by one half the time.

Fix this as follows: limit production to the amount the workers can
produce (no rounding).  Work becomes a hard limit, not subject to
random fluctuations.  Randomly round the work charged for actual
production.  On average, this charges exactly the work that's used.

More importantly, production and budget now predict how much gets
produced more accurately.  They're still not exact, as the amount of
work available for production remains slightly random.

This also "fixes" the smoke test on a i686 Debian 6 box for me.  The
root problem is that floating-point subexpressions may either be
computed in double precision or extended precision.  Different
machines (or different compilers, or even different compiler flags)
may use different precision, and get different results.

Example: producing 108 units at one work per unit, sector p.e. 0.4
needs to charge 108 / 0.4 work.  Computed in double precision, this
gets rounded to 270.0, then truncated to 270.  In 80 bit extended
precision, it gets rounded to 269.999999999, then truncated to 269.

With random rounding instead of truncation, the probability for a
different result is vanishingly small.  However, this commit
introduces truncation in another place.  It just happens not to mess
up the smoke test there.  I doubt this is the last time this kind of
problem upsets the smoke test.

10 years agoRearrange produce() and prod() a bit to make them more similar
Markus Armbruster [Sun, 5 May 2013 20:34:59 +0000 (22:34 +0200)]
Rearrange produce() and prod() a bit to make them more similar

10 years agoFactor prod_resource_limit() out of produce() and prod()
Markus Armbruster [Sun, 5 May 2013 15:09:00 +0000 (17:09 +0200)]
Factor prod_resource_limit() out of produce() and prod()

10 years agoAvoid double rounding materials when limiting products made
Markus Armbruster [Sat, 4 May 2013 15:54:37 +0000 (17:54 +0200)]
Avoid double rounding materials when limiting products made

We can make actual = roundavg(material_consume * prodeff) products.

When we reduce actual, we have to reduce material_consume, too.  Code
does that like this:

    material_consume = roundavg(actual' * material_consume / actual)

Double rounding.  Do this instead:

    material_consume = roundavg(actual' / prodeff)

10 years agoUse ITEM_MAX instead of 9999 as production material limit
Markus Armbruster [Sat, 4 May 2013 06:53:03 +0000 (08:53 +0200)]
Use ITEM_MAX instead of 9999 as production material limit

No functional change, as ITEM_MAX is 9999, just cleaner.

10 years agoprod() duplicates materials_cost(), clean up
Markus Armbruster [Fri, 3 May 2013 18:52:02 +0000 (20:52 +0200)]
prod() duplicates materials_cost(), clean up

Rename materials_cost() to prod_materials_cost(), give external
linkage, use it in prod().

10 years agoClean up redundant code in prod()
Markus Armbruster [Fri, 3 May 2013 18:42:51 +0000 (20:42 +0200)]
Clean up redundant code in prod()

10 years agoFix "info Products" on how to query sector type p.e.
Markus Armbruster [Fri, 3 May 2013 18:11:07 +0000 (20:11 +0200)]
Fix "info Products" on how to query sector type p.e.

It's show sect capabilities, not stats.

10 years agoFix xdump nat column ip for connections from "long" IPv6 addresses
Markus Armbruster [Mon, 29 Apr 2013 19:29:51 +0000 (21:29 +0200)]
Fix xdump nat column ip for connections from "long" IPv6 addresses

Broken in commit 3a7d7fa, which enlarged struct natstr member
nat_hostaddr[] from 32 to 46 characters, but neglected to update the
ca_len in nat_ca[].  Consequently, the address is truncated in xdump.
Can also break country * ?ip=... and such, but that's exotic.

10 years agoFix five year old show stopper bugs on big endian hosts
Markus Armbruster [Mon, 29 Apr 2013 19:28:17 +0000 (21:28 +0200)]
Fix five year old show stopper bugs on big endian hosts

emp_server and empdump refuse to start on most big endian hosts,
because ef_verify_config() chokes on mdchr_ca[]:

Config meta uid 0 field type: value 0 is not in symbol table meta-type
Config meta uid 1 field type: value 0 is not in symbol table meta-type
Config meta uid 2 field type: value 0 is not in symbol table meta-type
Config meta uid 3 field type: value 0 is not in symbol table meta-type
Config meta uid 4 field type: value 0 is not in symbol table meta-type

Broken in commit 06a0036 (v4.3.12), which changed struct castr member
ca_type from packed_nsc_type (typedef'ed to char) to enum nsc_type,
but neglected to update the ca_type in mdchr_ca[].

On little endian hosts, the selector reads the least significant byte,
with sign extension.  Happens to work, because the type values are all
sufficiently small integers.

On big endian hosts, the selector reads the most signiciant byte.
which is always zero (NSC_NOTYPE).  Makes ef_verify_config() fail.

Except when sizeof(enum nsc_notype) == 1.  Then selector type works
fine, and ef_verify_config() succeeds, but we run into the next
problem: the same commit also changed member ca_flags from nsc_flags
(typedef'ed to unsigned char) to int without updating the ca_type in
mdchr_ca[].  This breaks "only" xdump meta column flags.

v4.3.12 was released in April 2008.  Either nobody has tried to run a
game on a big endian host since, or all who did gave up quietly,
without reporting the problem.

We clearly need to test on a wider range of machines.

10 years agoFix xdump trade column type on big endian hosts
Markus Armbruster [Mon, 29 Apr 2013 19:24:51 +0000 (21:24 +0200)]
Fix xdump trade column type on big endian hosts

Broken in commit 14ea670 (v4.3.8), which changed struct trdstr member
trd_type from char to short, but neglected to update the ca_type in
trade_ca[].

On little endian hosts, the selector reads the least significant byte,
with sign extension.  Happens to work, because the type values are all
sufficiently small integers.

On big endian hosts, the selector reads the most signiciant byte,
which is always zero (EF_SECTOR).  Messes up xdump trade badly.

10 years agoFix xdump lost column type on big endian hosts
Markus Armbruster [Mon, 29 Apr 2013 19:23:13 +0000 (21:23 +0200)]
Fix xdump lost column type on big endian hosts

Broken in commit 09248d0 (v4.3.8), which changed struct loststr member
lost_type from char to short, but neglected to update the ca_type in
lost_ca[].

On little endian hosts, the selector reads the least significant byte,
with sign extension.  Happens to work, because the type values are all
sufficiently small integers.

On big endian hosts, the selector reads the most signiciant byte,
which is always zero (EF_SECTOR).  Messes up xdump lost badly.  Also
breaks lost * ?type=..., but that's exotic.

10 years agoImprove how mksubj.pl reports malformed .SA argument
Markus Armbruster [Sun, 28 Apr 2013 16:30:41 +0000 (18:30 +0200)]
Improve how mksubj.pl reports malformed .SA argument

10 years ago.SA should come last, make mksubj.pl enforce it
Markus Armbruster [Sun, 28 Apr 2013 16:29:36 +0000 (18:29 +0200)]
.SA should come last, make mksubj.pl enforce it

10 years agoSubject pages confuse topics and subjects, fix
Markus Armbruster [Sun, 28 Apr 2013 16:06:14 +0000 (18:06 +0200)]
Subject pages confuse topics and subjects, fix

Confused since they were added in Empire 2.

10 years agoSlightly less crude "info page is long" decision
Markus Armbruster [Sun, 28 Apr 2013 16:00:25 +0000 (18:00 +0200)]
Slightly less crude "info page is long" decision

"Unusually long" topics are marked with a "!" in subject indexes.
This should use the line count of the formatted page, but that's too
much trouble, so commit 4c0b4c0 (v4.3.27) approximated it by "source
file has more than 9999 bytes".  Change that to "source file has more
than 300 lines".

10 years agoSimplify how mksubj.pl keeps track of the subjects' topics
Markus Armbruster [Sun, 28 Apr 2013 15:45:05 +0000 (17:45 +0200)]
Simplify how mksubj.pl keeps track of the subjects' topics

Extend global variable %Subjects to hold topics.  Drop global
variables %subject and %largest.

10 years agoSimplify how mksubj.pl parses argument of .SA
Markus Armbruster [Sun, 28 Apr 2013 15:05:10 +0000 (17:05 +0200)]
Simplify how mksubj.pl parses argument of .SA

Call parse_see_also() immediately.  Permits eliminating global
variables %see_also and %sanr.

10 years agoMake mksubj.pl touch subject files only when it needs to change
Markus Armbruster [Sun, 28 Apr 2013 13:22:11 +0000 (15:22 +0200)]
Make mksubj.pl touch subject files only when it needs to change

Avoids unnecessary reformatting of subject pages again.

10 years agoDeclare subjects instead of picking them up automatically
Markus Armbruster [Sun, 28 Apr 2013 12:38:50 +0000 (14:38 +0200)]
Declare subjects instead of picking them up automatically

Since subjects were added in Empire 2, we've always picked them up
from .SA requests.  If you mistype a subject there, you get a "is a
NEW subject" warning, and incorrect subject pages.  When building a
pristine tree, you get bogus "is a NEW subject" warnings for all
subjects.  If you somehow delete the generated subjects.mk, but not
the generated subject files, the build breaks.

Declare subjects in Make variable subjects.  Drop generated makefile
subject.mk.

Treat unknown topics in .SA arguments as errors.  This replaces the
"$subj is a NEW subject" warning.

Treat subjects without member pages as errors.  This replaces the "The
subject $subj has been removed" warning.

Safer and simpler.

10 years agoFix remaking of info subject pages
Markus Armbruster [Sun, 28 Apr 2013 11:44:51 +0000 (13:44 +0200)]
Fix remaking of info subject pages

We used to do all the info indexing work in info.pl: find subjects,
create subjects.mk (to tell make the list of subjects), the subject
pages, and TOP.t.  Worked, but touching an info page triggered a full
rebuild of all subject pages and TOP.t.

Commit 2f14064 (v4.3.0) tried to avoid that by splitting info.pl into
findsubj.pl, mksubj.pl, mktop.pl.  findsubj.pl puts not just the
subjects into subjects.mk, but also make rules for the subject pages,
to guide their remaking.  mksubj.pl creates a single subject page.
mktop.pl creates TOP.t.

Unfortunately, this doesn't work so well.  Since subjects.mk doesn't
exist in a virgin tree, we use -include.  Unwanted consequence:
findsubj.pl failure doesn't stop make.  Moreover, the complex make
machinery breaks down when info sources get removed or subjects get
dropped.

Go back to the old method, except keep mktop.pl separate, as that part
works just fine, and use simpler make rules.  mksubj.pl now creates
subjects.mk and all subject pages, like info.pl did.

This effectively reverts most of commit 2f14064.  I'll address the
excessive rebuilding of subject pages in a different way shortly.

10 years agoPass subjects instead of subject filenames to info/mktop.pl
Markus Armbruster [Sat, 27 Apr 2013 15:03:34 +0000 (17:03 +0200)]
Pass subjects instead of subject filenames to info/mktop.pl

mktop.pl doesn't actually use the files, so this is simpler and
clearer.

10 years agoFix remaking of config.h and config.h.in
Markus Armbruster [Sat, 27 Apr 2013 13:32:53 +0000 (15:32 +0200)]
Fix remaking of config.h and config.h.in

Remaking config.h and config.h.in updates the target only when its
contents actually changes.  This is important, because after updating
config.h we need to recompile everything.

The make rules to do that are straight from the Autoconf manual.  But
they don't work: the rules that connect config.h and config.h.in to
stamp-h and stamp-h.in don't have recipes.  Since make doesn't have an
implicit rule either, it concludes that the target remains unchanged.
It still updates the prerequisites.  The recipe for updating the stamp
files then change the the targetes behind make's back.  Make misses
the change of config.h and/or config.h.in, and we get an incomplete
rebuild.

The rules need empty recipes instead.  This Autoconf manual was fixed
accordingly in autoconf.git commit 6b42b38.

10 years agoUpdate info lost example to current output
Markus Armbruster [Sun, 21 Apr 2013 11:29:37 +0000 (13:29 +0200)]
Update info lost example to current output

Looks like this hasn't been done since Peter Langston's days...

10 years agoDrop trailing space in output of financial
Markus Armbruster [Sun, 21 Apr 2013 11:22:01 +0000 (13:22 +0200)]
Drop trailing space in output of financial

10 years agoClean up some trailing whitespace
Markus Armbruster [Sun, 21 Apr 2013 10:58:26 +0000 (12:58 +0200)]
Clean up some trailing whitespace

10 years agoReplace .SA Obsolete by .LV Obsolete
Markus Armbruster [Fri, 29 Mar 2013 20:33:39 +0000 (21:33 +0100)]
Replace .SA Obsolete by .LV Obsolete

Mark obsolete pages with '+' in subject pages.  Drop the separate
"Obsolete" subject page: move "info Innards" to subject "Server", and
"info update" to "Updates" (where it came from in commit a5764534,
v4.3.10).

10 years agoSuppress explanation of '*' flag in subject pages when not used
Markus Armbruster [Fri, 29 Mar 2013 19:32:36 +0000 (20:32 +0100)]
Suppress explanation of '*' flag in subject pages when not used

10 years agoReplace 'our' by 'my' in Perl scripts
Markus Armbruster [Fri, 29 Mar 2013 18:51:56 +0000 (19:51 +0100)]
Replace 'our' by 'my' in Perl scripts

10 years agoInclude <process.h> in w32/unistd.h for getpid()
Markus Armbruster [Wed, 10 Apr 2013 19:41:09 +0000 (21:41 +0200)]
Include <process.h> in w32/unistd.h for getpid()

getpid() is used since commit 773019e.

10 years agoFix missing include "arpa/inet.h" in w32sockets.c
Markus Armbruster [Wed, 10 Apr 2013 19:36:41 +0000 (21:36 +0200)]
Fix missing include "arpa/inet.h" in w32sockets.c

Missed in commit afedb8c.

10 years agoDefine EWOULDBLOCK for w32 only if it's missing
Markus Armbruster [Wed, 10 Apr 2013 19:34:33 +0000 (21:34 +0200)]
Define EWOULDBLOCK for w32 only if it's missing

My version of MinGW provides it.

10 years agoUse IPv4 format for IPv4-mapped addresses
Markus Armbruster [Mon, 8 Apr 2013 17:34:37 +0000 (19:34 +0200)]
Use IPv4 format for IPv4-mapped addresses

For instance, use "127.0.0.1" for IPv4 loopback instead of
"::ffff:127.0.0.1".

Simplifies use of econfig key privip: plain dotted decimal now just
works regardless of IPv6 use, no need to add the IPv4-mapped form.

Also affects how addresses are logged and shown to players, and nation
selector ip.  Nicer that way.

10 years agoDrop extra blank line in output of pconfig
Markus Armbruster [Mon, 8 Apr 2013 17:23:58 +0000 (19:23 +0200)]
Drop extra blank line in output of pconfig

10 years agoDocument GNU libc lossage in listen_addr doc string
Markus Armbruster [Sun, 7 Apr 2013 18:40:29 +0000 (20:40 +0200)]
Document GNU libc lossage in listen_addr doc string

Systems using GNU libc such as Linux are frequently configured in a
way getaddrinfo(NULL, ...) put the IPv4 wildcard "0.0.0.0" *before*
the IPv6 wildcard "::" in the result.  Because of that, listen_addr ""
listens only on all IPv4 addresses.  Workaround: listen_addr "::".

Document it in listen_addr's doc string.

10 years agoLog connection attempts
Markus Armbruster [Sun, 7 Apr 2013 18:19:10 +0000 (20:19 +0200)]
Log connection attempts

10 years agoFix wildcard bind to at least bind IPv4 or else IPv6 on OpenBSD
Markus Armbruster [Sun, 7 Apr 2013 17:30:17 +0000 (19:30 +0200)]
Fix wildcard bind to at least bind IPv4 or else IPv6 on OpenBSD

OpenBSD refuses to implement IPV6_V6ONLY, in violation of RFC 3493.
RFC 4038 frowningly recognizes this practice.  The only way to bind
both IPv4 and IPv4 there is two separate sockets.  Requires more
surgery than I can do now.

Since we can't have both IPv6 and IPv6 on OpenBSD with our single
socket, prefer IPv4, but if that doesn't work, do IPv6.

To prefer IPv6 instead, put 'listen_addr "::"' into econfig.  Document
that in listen_addr's doc string.

10 years agoFix wildcard bind to bind both IPv6 and IPv4 on Windows & BSD
Markus Armbruster [Sun, 7 Apr 2013 17:16:09 +0000 (19:16 +0200)]
Fix wildcard bind to bind both IPv6 and IPv4 on Windows & BSD

We rely on AF_INET6 wildcard bind() binding the AF_INET port, too,
i.e. IPV6_V6ONLY off.  This should be the default according to RFC
3493 section 5.3, but isn't on Windows and BSD.  RFC 4038 recognizes
this fact in section 4.2.

When IPV6_V6ONLY is on, an AF_INET6 wildcard bind only accepts
connections from IPv6 addresses.  Thus, IPv4 doesn't work when
getaddrinfo() returns an AF_INET6 address first (which it should do
when the system has an IPv6 address configured).

Switch off IPV6_V6ONLY explicitly instead of relying on the default.
This makes IPv6 work on systems where IPV6_V6ONLY is on by default,
such as Windows and BSD.

Except for OpenBSD, which does not support switching it off.  To be
addressed in the next commit.

10 years agoIgnore error setting socket option SO_REUSEADDR
Markus Armbruster [Sun, 7 Apr 2013 17:14:57 +0000 (19:14 +0200)]
Ignore error setting socket option SO_REUSEADDR

Shouldn't fail.  If it fails, but bind() works, the failure doesn't
matter.  If bind() fails, we can just as well report that failure
instead of setsockopt()'s.

10 years agoClean up tcp_listen()'s addrinfo loop some
Markus Armbruster [Sun, 7 Apr 2013 17:13:44 +0000 (19:13 +0200)]
Clean up tcp_listen()'s addrinfo loop some

10 years agoLog the server's listening address
Markus Armbruster [Sun, 7 Apr 2013 11:52:48 +0000 (13:52 +0200)]
Log the server's listening address

10 years agoFactor sockaddr_ntop() out of player_accept()
Markus Armbruster [Sun, 7 Apr 2013 11:27:43 +0000 (13:27 +0200)]
Factor sockaddr_ntop() out of player_accept()

Oops on inet_ntop() failure instead of merely logging it.

10 years agoFix a comment in tcp_connect()
Markus Armbruster [Sun, 7 Apr 2013 11:25:02 +0000 (13:25 +0200)]
Fix a comment in tcp_connect()

10 years agoMake power sort countries of equal power predictably
Markus Armbruster [Sat, 6 Apr 2013 07:46:51 +0000 (09:46 +0200)]
Make power sort countries of equal power predictably

How qsort() sorts members that compare equal is unspecified.  Can
upset the smoke test.  Observed under FreeBSD 8.3.

Break ties in power by comparing country numbers.  Countries equal in
power are now sorted by increasing country number.

10 years agoChange fairland island size probability distribution
Markus Armbruster [Sun, 31 Mar 2013 09:05:32 +0000 (11:05 +0200)]
Change fairland island size probability distribution

Island size is randomly chosen from the interval [1..2*is+1], with
expected value is.  Use two dice to roll the size instead of one.
This makes extreme sizes much less likely.

10 years agoMake fairland record the island number in the deity territory
Markus Armbruster [Wed, 27 Mar 2013 15:58:40 +0000 (16:58 +0100)]
Make fairland record the island number in the deity territory

Can be useful for deities when further customizing their game setup.

10 years agoMake smoke test time out instead of hang when server misbehaves
Markus Armbruster [Mon, 25 Mar 2013 15:58:25 +0000 (16:58 +0100)]
Make smoke test time out instead of hang when server misbehaves

The smoke test waits for the server completing startup by trying to
connect until it works.  Hangs if the server doesn't complete startup
for some reason.  Make it give up after 5s.

Likewise, The smoke test waits for the server to terminate by trying
kill -0 until it fails.  Hangs if the server doesn't terminate.  Make
it give up after 5s.

10 years agoRemove superfluous #include "nuke.h"
Markus Armbruster [Mon, 14 Jan 2013 21:28:22 +0000 (22:28 +0100)]
Remove superfluous #include "nuke.h"

10 years agoSimplify market time left handling in a few places
Markus Armbruster [Mon, 14 Jan 2013 20:03:51 +0000 (21:03 +0100)]
Simplify market time left handling in a few places

10 years agoFix extension of market bidding time when high bidder changes
Markus Armbruster [Mon, 14 Jan 2013 19:59:04 +0000 (20:59 +0100)]
Fix extension of market bidding time when high bidder changes

Lots stay on the market until there's a bid and bidding time expires.

When the highest bidder changes, and less than five minutes of bidding
time are left, it gets extended by five minutes (since 4.0.7, actually
works since 4.0.9).

Normally, this ensures that the competition has at least five minutes
to react.  Except when this is the first bid, bidding time may have
expired already.  If it expired less than five minutes ago, the
competition still gets time to react, just less than it should.  If it
expired earlier, the sale is executed immediately for units.  For
commodities, the bidding time is set to expire in five minutes (since
4.2.0).

Instead of extending bidding time by five minutes, set it to expire in
five minutes, both for commodities and for units.

10 years agoFix pre-tax unit market price loss of precision
Markus Armbruster [Mon, 14 Jan 2013 19:52:04 +0000 (20:52 +0100)]
Fix pre-tax unit market price loss of precision

check_trade() converts the price to float, which can lose precision,
although only for ridiculously high prices.  Has been broken since
4.0.0 introduced the market.

Avoid the conversion.  Bulletins now show pre-tax price as $N instead
of $N.00.

10 years agoUse int instead of long for money
Markus Armbruster [Sun, 13 Jan 2013 16:59:29 +0000 (17:59 +0100)]
Use int instead of long for money

Code dealing with money mixes int and long pretty haphazardly.
Harmless, because practical amounts of money fit into int on any
machine capable of running the server.  Clean up anyway.

10 years agoFix melting of big piles of stuff by ridiculously heavy fallout
Markus Armbruster [Sun, 13 Jan 2013 16:17:44 +0000 (17:17 +0100)]
Fix melting of big piles of stuff by ridiculously heavy fallout

meltitems() computes #items * etus per update * fallout in type long.
Theoretical maximum is ITEM_MAX * etus * FALLOUT_MAX = 99980001 *
etus.  Can overflow 32 bits for etus > 21.  Has been broken since the
introduction of fallout in KSU.

Compute the product in double instead.

10 years agoClean up silly use of long in satmap()
Markus Armbruster [Sun, 13 Jan 2013 16:09:25 +0000 (17:09 +0100)]
Clean up silly use of long in satmap()

crackle's value is betwen 0 and 100, so change it to int.

10 years agoUse int instead of long for military reserves
Markus Armbruster [Sun, 13 Jan 2013 15:13:15 +0000 (16:13 +0100)]
Use int instead of long for military reserves

Code dealing with reserves mixes int and long pretty haphazardly.
Harmless, because practical reserves fit easily on any machine capable
of running the server.  Clean up anyway.

10 years agoUse int instead of long to count people
Markus Armbruster [Sun, 13 Jan 2013 14:04:24 +0000 (15:04 +0100)]
Use int instead of long to count people

Code dealing with counting people mixes int and long pretty
haphazardly.  Harmless, because practical populations fit into int
easily on any machine capable of running the server.  Clean up anyway.

10 years agoUse int instead of signed char for pln_flags
Markus Armbruster [Sun, 13 Jan 2013 13:16:01 +0000 (14:16 +0100)]
Use int instead of signed char for pln_flags

Just for consistency with other flags members.  Rearrange struct
plnstr to avoid holes.

10 years agoUse int instead of long for flags
Markus Armbruster [Sun, 13 Jan 2013 13:11:43 +0000 (14:11 +0100)]
Use int instead of long for flags

As long as symbol_by_value(), show_capab() and togg() support only
int, flags need to fit into int.

Not a problem in practice, because no machine capable of running
Empire has int narrower than 32 bits, and 32 bits suffice.

Some flags members are long instead of int: struct lchrstr member
l_flags, struct natstr member nat_flags, struct mchrstr member m_flags
are long.  Waste of space on machines with long wider than int.
Change them to int.

Rearrange struct lchrstr and struct natstr to avoid holes.