]> git.pond.sub.org Git - empserver/log
empserver
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.

10 years agoAbridge a few overly verbose declarations
Markus Armbruster [Sun, 13 Jan 2013 12:19:37 +0000 (13:19 +0100)]
Abridge a few overly verbose declarations

10 years agoClean up redundant forward declarations
Markus Armbruster [Sun, 13 Jan 2013 12:13:55 +0000 (13:13 +0100)]
Clean up redundant forward declarations

10 years agoFix crash on edit s, p, u key 'U' with negative argument
Markus Armbruster [Sun, 13 Jan 2013 09:32:54 +0000 (10:32 +0100)]
Fix crash on edit s, p, u key 'U' with negative argument

ef_ensure_space() oopses on negative ID, but succeeds anyway.  edit()
proceeds to ef_write(), which neglects to check for negative ID.
Since the ID isn't in the cache, it then passes a NULL old element to
callback prewrite(), which crashes.

Fix ef_ensure_space() to fail on negative ID.  Commit 5173f8cd
(v4.3.0) made it oops, but neglected to make it fail.

Fix ef_write() to oops and fail on negative ID.

ef_write() still passes NULL old element to prewrite() when the ID
isn't in the cache.  Doesn't actually happen, because we use
prewrite() callbacks only with fully cached tables.  Fragile.  Make
ef_open() fail when that assumption is violated.

10 years agoUnify owner of units built by deities in foreign sectors
Markus Armbruster [Sun, 13 Jan 2013 09:06:50 +0000 (10:06 +0100)]
Unify owner of units built by deities in foreign sectors

Newly built ships and land units are given to the player, planes and
nukes to the sector owner.  Matters only for deities, because only
deities can build in foreign sectors.  Stupid all the same.

This has always been inconsistent.  Empire 1 gave ships and nukes to
the player, and planes to the sector owner.  Chainsaw 3 added land
units, and gave them to the player.  Empire 2 changed build to give
nukes to the sector owner.

Building doesn't work when the unit built is given to POGO, because
giving a unit to POGO destroys it.  When build gives to the sector
owner, deities can't build in unowned sectors.  When build gives to
the player, POGO can't build at all.  That's more limiting, so change
build to always give to the sector owner.

10 years agoAdd Travis CI configuration
Markus Armbruster [Sat, 12 Jan 2013 16:45:52 +0000 (17:45 +0100)]
Add Travis CI configuration

Travis CI is a hosted, continuous integration service.  Let's see how
it works out for us.

10 years agoUse unsigned instead of unsigned long for fairland's random seed
Markus Armbruster [Thu, 3 Jan 2013 15:32:08 +0000 (16:32 +0100)]
Use unsigned instead of unsigned long for fairland's random seed

seed_prng() wants unsigned.  Server uses unsigned already.

10 years agoRemove a blank line before "fairland rips open"
Markus Armbruster [Sat, 29 Dec 2012 14:47:12 +0000 (15:47 +0100)]
Remove a blank line before "fairland rips open"

One blank line before and after now, looks better.

10 years agoDon't reprint "fairland rips open" and PRNG seed on each retry
Markus Armbruster [Sat, 29 Dec 2012 14:45:05 +0000 (15:45 +0100)]
Don't reprint "fairland rips open" and PRNG seed on each retry

10 years agoFix PRNG seeding to resist guessing
Markus Armbruster [Sat, 29 Dec 2012 14:06:29 +0000 (15:06 +0100)]
Fix PRNG seeding to resist guessing

We seed it with value of time().  It's the traditional way, but it
provides only a few bits of effective entropy when an attacker has a
rough idea when the program started.

Instead, seed with a kernel random number.  If we can't get one, fall
back to a hash of gettimeofday() and getpid().  This should happen
only on old systems or Windows.  Far worse than a kernel random
number, but far better than using time().

Note that fairland used to seed with time() + getpid() until commit
331aac2a (v4.2.20) dropped the getpid(), claiming it didn't improve
the randomness.  Perhaps it didn't under Windows then, but it
certainly did elsewhere, so it was a regression.

10 years agoSwitch PRNG from BSD random() to Mersenne Twister
Markus Armbruster [Sat, 25 Aug 2012 15:21:10 +0000 (17:21 +0200)]
Switch PRNG from BSD random() to Mersenne Twister

random() may yield different pseudo-random number sequences for the
same seed on another system.  For instance, at least some versions of
MinGW provide a random() in -liberty that differs from traditional BSD
(see commit c8231b12).  Rather inconvenient for regression testing.

MT19937 Mersenne Twister is a proven, high-quality PRNG.  Actual code
is reference code provided by the inventors[*].  Quick tests show
performance comparable to random().

Like random(), MT is not cryptographically secure: observing enough of
its output permits guessing its state, and thus its future output.  I
don't think players can do that.

Drop the copy of BSD random() we added for Windows.

Like the previous commit, this changes the server's die rolls, and
makes fairland create a different random map for the same seed.  Update
expected smoke test results accordingly.

[*] mt19937ar.sep.tgz downloaded from
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html

10 years agoFix tiny error in distribution of die rolls
Markus Armbruster [Sun, 19 Aug 2012 10:19:04 +0000 (12:19 +0200)]
Fix tiny error in distribution of die rolls

"random() % n" is sound only when n is a power of two.  The error is
hardly relevant in Empire, because random() yields 31 bits, and our n
are always much smaller than 2^31.  Fix it anyway.

Use smallest the 2^m >= n instead of n, and discard numbers exceeding
n.

Bonus: faster for me even in the worst case n = 2^m+1.

Like the recent change to damage(), this changes some of the server's
die rolls, only this time the effect is pretty pervasive.  Worse,
fairland now creates a completely different random map for the same
seed.  Update expected smoke test results accordingly.

10 years agoNew pct_chance(), for clarity, and symmetry with chance()
Markus Armbruster [Thu, 16 Aug 2012 19:05:42 +0000 (21:05 +0200)]
New pct_chance(), for clarity, and symmetry with chance()

10 years agoMake move_ground() use roundavg()
Markus Armbruster [Thu, 27 Dec 2012 08:33:10 +0000 (09:33 +0100)]
Make move_ground() use roundavg()

No functional change.

10 years agoMake damage() use roundavg()
Markus Armbruster [Tue, 14 Aug 2012 19:51:22 +0000 (21:51 +0200)]
Make damage() use roundavg()

Turns damage() into a one-liner.

damage() now uses random() % 32768 in chance() instead of random() %
100 inline, therefore can round differently for the same pseudo-random
number.  Update expected smoke test results accordingly.

Aside: "random() % n" distributes evenly only when n is a power of
two.  100 isn't.  However, because random() yields at least 31 bits,
and 100 is so much smaller than 2^31, the error is vanishingly small.

10 years agoConvert "info Damage" from random(N) to 1dN notation
Markus Armbruster [Tue, 14 Aug 2012 18:50:25 +0000 (20:50 +0200)]
Convert "info Damage" from random(N) to 1dN notation

10 years agoFix "info Damage" for shells, depth charges and torpedoes
Markus Armbruster [Tue, 14 Aug 2012 18:45:54 +0000 (20:45 +0200)]
Fix "info Damage" for shells, depth charges and torpedoes

Each random() is off by one there.

10 years agoReplace "roll0(N) + M" by "roll(N) + M-1"
Markus Armbruster [Tue, 14 Aug 2012 18:33:51 +0000 (20:33 +0200)]
Replace "roll0(N) + M" by "roll(N) + M-1"

10 years agoFairland's rnd() wrapper is trivial now, drop it
Markus Armbruster [Tue, 14 Aug 2012 17:54:34 +0000 (19:54 +0200)]
Fairland's rnd() wrapper is trivial now, drop it

10 years agoEncapsulate direct use of random(), srandom() in chance.c
Markus Armbruster [Tue, 14 Aug 2012 17:23:12 +0000 (19:23 +0200)]
Encapsulate direct use of random(), srandom() in chance.c

Wrap roll0() around random(), and seed_prng() around srandom().  In
preparation of replacing the PRNG.

10 years agoMove declarations for chance.c to new chance.h
Markus Armbruster [Tue, 14 Aug 2012 16:57:17 +0000 (18:57 +0200)]
Move declarations for chance.c to new chance.h

10 years agoFix prod_eff() function comment
Markus Armbruster [Thu, 16 Aug 2012 19:05:16 +0000 (21:05 +0200)]
Fix prod_eff() function comment

It returns product's level p.e. time sector type p.e, not just the
level p.e.  See "info Products".

10 years agoClean up land unit retreat chance and fix its documentation
Markus Armbruster [Thu, 16 Aug 2012 18:54:59 +0000 (20:54 +0200)]
Clean up land unit retreat chance and fix its documentation

Change chance in percent lnd_retreat - lnd_effic - 1 to lnd_retreat -
lnd_effic.  It's been that way since Empire 2, but I can't bring
myself to document the silly -1.

"info morale" wasn't updated when the retreat chance was changed in
Empire 2.  Fix that.

10 years agoClean up and document nuclear damage's chance to destroy nuke
Markus Armbruster [Thu, 16 Aug 2012 06:24:15 +0000 (08:24 +0200)]
Clean up and document nuclear damage's chance to destroy nuke

Change chance in percent from damage-1 to damage.  It's always been
damage-1, but I can't bring myself to document the silly -1.

10 years agoClean up launch_sat() random direction pick
Markus Armbruster [Tue, 14 Aug 2012 18:33:36 +0000 (20:33 +0200)]
Clean up launch_sat() random direction pick

Use DIR_FIRST rather than literal 1.

10 years agoMake smoke test's tech production more robust
Markus Armbruster [Sun, 5 May 2013 17:31:49 +0000 (19:31 +0200)]
Make smoke test's tech production more robust

The tech center doesn't have enough workers to use all materials in
some updates.  How much get made depends on a die roll then.  Tech
variations are inconvenient because they ripple through the rest of
the smoke test.

10 years agoLimit che action in smoke test some
Markus Armbruster [Fri, 28 Dec 2012 13:53:56 +0000 (14:53 +0100)]
Limit che action in smoke test some

Too easily upset by random variations.  Kill them off with anti after
two updates, and occupy with a few more military.

While there, enlist the military in a highway rather than an lcm
plant.

10 years agoEnlarge news cache from 5 to 8 entries per country
Markus Armbruster [Thu, 27 Dec 2012 13:48:06 +0000 (14:48 +0100)]
Enlarge news cache from 5 to 8 entries per country

10 years agoMake news item merging deterministic and safe for year 2038
Markus Armbruster [Thu, 27 Dec 2012 13:43:43 +0000 (14:43 +0100)]
Make news item merging deterministic and safe for year 2038

News reporting merges news items into recent items with same contents.
For that purpuse, we keep a small cache of recent items.  When a new
item can't be merged into an item in the cache, the oldest item gets
evicted to make space for the new one.

ncache() evicts the first item with the smallest timestamp (struct
nwsstr member nws_when).  Timestamps are in seconds, therefore clashes
are common, and eviction depends on exact timing.  Such indeterminism
can make the smoke test fail.

Moreover, ncache() assumes timestamps cannot exceed 0x7fffffff.  If
they do, it always evicts the slot 0.  They will in 2038.

Fix by evicting round robin.  This always evicts the oldest item.

10 years agoMake smoke test's plane build more robust
Markus Armbruster [Thu, 27 Dec 2012 13:00:00 +0000 (14:00 +0100)]
Make smoke test's plane build more robust

The airfield is a sector taken from player 8.  How many updates it
takes to convert is highly variable.  If it converts late, the
airfield may not be constructed in time.  This is currently the case
for me.

Move the airfield to a more dependable sector.

For me, the smoke test now fails frequently, because of differences in
news.  To be fixed next.

10 years agoRemove fairland from smoke test
Markus Armbruster [Tue, 18 Dec 2012 20:57:45 +0000 (21:57 +0100)]
Remove fairland from smoke test

Import xdump instead.  To decouple the smoke test from future fairland
changes that result in different worlds.

10 years agoAdd fairland test to make check
Markus Armbruster [Mon, 17 Dec 2012 20:45:49 +0000 (21:45 +0100)]
Add fairland test to make check

10 years agoAdd files test to make check
Markus Armbruster [Mon, 17 Dec 2012 20:44:45 +0000 (21:44 +0100)]
Add files test to make check

10 years agoFactor tests/test-common.sh out of tests/smoke-test
Markus Armbruster [Mon, 17 Dec 2012 20:36:53 +0000 (21:36 +0100)]
Factor tests/test-common.sh out of tests/smoke-test

For reuse by future tests.

10 years agoMake smoke test check the final empdump -x
Markus Armbruster [Sun, 12 Aug 2012 18:54:34 +0000 (20:54 +0200)]
Make smoke test check the final empdump -x

10 years agoGet rid of shell boilerplate in smoke test Empire batch files
Markus Armbruster [Sat, 14 Jul 2012 14:38:15 +0000 (16:38 +0200)]
Get rid of shell boilerplate in smoke test Empire batch files

10 years agoNew make target check
Markus Armbruster [Sat, 14 Jul 2012 06:46:38 +0000 (08:46 +0200)]
New make target check

Just a smoke test so far, extracted from src/scripts/nightly/.  This
makes the existing smoke test more easily accessible.  Noteworthy
differences:

* Instead of patching the code to make output more stable, postprocess
  the output to normalize it.

* Compare actual results to expected results instead of the previous
  test run's results.

* Much faster.  The old test harness used sleep liberally to "ensure"
  things always happen in the same order.

Known shortcomings:

* The smoke test hangs when the server fails to complete startup, or
  fails to terminate.

* Normalization of xdump hardcodes columns instead of getting them
  from xdump meta.

* Normalization of time values in xdump is an ugly hack.

* xdump meta column type isn't normalized.  Actual values can vary
  between systems, because the width of enumeration types is
  implementation-defined.  The smoke test works only when they're
  represented as int, which is the case on common systems.

* Currently expected to work only with thread package LWP and a
  random() that behaves exactly like the one on my development system,
  because:

  - Thread scheduling is reliably deterministic only with LWP

  - The PRN sequence produced by random() isn't portable

  - Shell builtin kill appears not to do the job in MinGW

  - The Windows server tries to run as service when -d isn't
    specified

Further work is needed to address these shortcomings.

Getting C programs behave exactly the same on all systems is hard.
We'll likely run into system-dependent differences that upset the
smoke test.  Floating-point computation seems particularly vulnerable.

Instead of updating src/scripts/nightly/ to use "make check", retire
it.  It hasn't been used in quite a while.  Investing more into our
homegrown auto-builder doesn't make sense, as canned auto-builders
such as Travis CI and Jenkins are readily available.

The shell scripts src/scripts/nightly/tests/?? become Empire batch
files tests/smoke/.  The shell scripts are actually shell boilerplate
around Empire batch files.  To make sure git recognizes the move, this
commit moves them unchanged.  tests/smoke-test strips the boilerplate
before it feeds the batch files to the client.  The next commit will
get rid fo that.

11 years agoDon't put file descriptor values in thread names
Markus Armbruster [Sun, 5 Aug 2012 15:03:08 +0000 (17:03 +0200)]
Don't put file descriptor values in thread names

The names are logged.  Loging file descriptor values gets in the way
of regression testing, such as the smoke test that'll be committed
shortly.

11 years agoDon't log threads initialization
Markus Armbruster [Sun, 5 Aug 2012 15:00:07 +0000 (17:00 +0200)]
Don't log threads initialization

11 years agoSimplify lnd_take_casualty()'s land unit retreat code
Markus Armbruster [Tue, 8 Jan 2013 19:00:09 +0000 (20:00 +0100)]
Simplify lnd_take_casualty()'s land unit retreat code

Bonus: avoids "may be used uninitialized" compiler warnings (the code
was safe despite the warning).

11 years agoReally fix accepting connections from "long" IPv6 address
Markus Armbruster [Tue, 8 Jan 2013 17:54:20 +0000 (18:54 +0100)]
Really fix accepting connections from "long" IPv6 address

Commit ee01ac19 (v4.3.23) enlarged player member hostaddr from 32 to
46 characters, but missed natstr member nat_hostaddr.  player_main()
copies hostaddr to nat_hostaddr.  Can overrun the destination, but
fortunately just into nat_hostname.

Impact:

* Can makes praddr() print only a suffix of the address.  Used by play
  command, for player messages during login and logout, and for
  logging.

* Can make player_main()'s test for "same address as last time" fail,
  causing extra "Last connection" messages.

* Matching against econfig key privip is not affected.

* Journal event login is not affected.

11 years agoSimplify head_meanwhile()
Markus Armbruster [Tue, 8 Jan 2013 17:02:07 +0000 (18:02 +0100)]
Simplify head_meanwhile()

No functional change.

11 years agoTake ship cost into account when picking missile interdiction target
Markus Armbruster [Tue, 8 Jan 2013 16:49:30 +0000 (17:49 +0100)]
Take ship cost into account when picking missile interdiction target

Due to a typo, shp_missile_interdiction() picks the admissible target
with highest efficiency instead of the one with highest efficiency *
build cost.

Broken in commit cd8d7423, v4.3.8.

11 years agoReally fix setsector and setres not to wipe out concurrent updates
Markus Armbruster [Tue, 8 Jan 2013 16:38:42 +0000 (17:38 +0100)]
Really fix setsector and setres not to wipe out concurrent updates

setsector() and setres() continue after check_sect_ok() fails.
Clobbers the updates that made check_sect_ok() fail, triggering a
seqno mismatch oops.

Commit 04a332a8 (v4.3.27) claimed to fix this, but actually only
suppressed the generation oops.

11 years agoReally fix give not to wipe out concurrent updates
Markus Armbruster [Tue, 8 Jan 2013 16:37:37 +0000 (17:37 +0100)]
Really fix give not to wipe out concurrent updates

give() continues after check_sect_ok() fails.  Clobbers the updates
that made check_sect_ok() fail, triggering a seqno mismatch oops.

Commit b58c37e2 (v4.3.27) claimed to fix this, but actually only
suppressed the generation oops.

11 years agoDrop resnoise()'s second parameter
Markus Armbruster [Tue, 8 Jan 2013 14:59:59 +0000 (15:59 +0100)]
Drop resnoise()'s second parameter

All callers pass the same argument.

11 years agoFix setsector not to disclose number of landmines to occupier
Markus Armbruster [Tue, 8 Jan 2013 14:52:27 +0000 (15:52 +0100)]
Fix setsector not to disclose number of landmines to occupier

When the deity sets the number of mines with setsector, the sector
owner (if any) is told the resulting number of mines.  Even for
occupied sectors, where mines belong to the old owner, and thus
shouldn't be disclosed.  Oops.

Fix setsector not to tell the sector owner anything then.

11 years agoanti, give, grind take <SECTS> argument, fix their documentation
Markus Armbruster [Tue, 8 Jan 2013 13:43:01 +0000 (14:43 +0100)]
anti, give, grind take <SECTS> argument, fix their documentation

11 years agoMake capital fail more nicely when sector is unsuitable
Markus Armbruster [Tue, 8 Jan 2013 13:41:30 +0000 (14:41 +0100)]
Make capital fail more nicely when sector is unsuitable

The command fails without an explanation then.  Change it to print
something like "X,Y is not a capital or mountain owned by you."

11 years agoChange capital to take a single sector as argument
Markus Armbruster [Tue, 8 Jan 2013 13:26:19 +0000 (14:26 +0100)]
Change capital to take a single sector as argument

Capital takes a <SECTS> argument, and picks the first suitable sector
it finds there.  It fails if none can be found, or if the first one
found already is the capital (even when more suitable sectors follow).
Has always worked that way, but never documented.

I don't think the search feature is really useful, and documenting it
isn't worth my while.  Change the command to take a <SECT> argument
instead, as documented.

11 years agoUpdate copyright notice
Markus Armbruster [Tue, 8 Jan 2013 12:39:17 +0000 (13:39 +0100)]
Update copyright notice

11 years agoChange GODNEWS reports not to affect headlines and relations
Markus Armbruster [Sat, 11 Aug 2012 15:21:48 +0000 (17:21 +0200)]
Change GODNEWS reports not to affect headlines and relations

Option GODNEWS controls news reports give's N_GIFT, N_TAKE, and edit's
and setsector's N_AIDS, N_HURTS.

They affect news headlines because of their non-zero r_good_will.
N_TAKE and N_HURTS can downgrade relations because of their negative
r_good_will.  All tolerable, except N_TAKE has actor and victim
reverted: the deity running the give command is the victim, and the
sector owner is the actor.  Because of that, give with a negative
amount downgrades the deity's relations towards the sector owner.
Inappropriate.

Has always been that way.  Chainsaw disabled these news at
compile-time; to enable you had to define GODNEWS (not documented
anywhere).  Empire 4.2.0 made GODNEWS a proper option, enabled by
default.

Fix by setting their r_good_will to zero.

11 years agoFix flying commands for destination equal to assembly point
Markus Armbruster [Sat, 11 Aug 2012 14:46:25 +0000 (16:46 +0200)]
Fix flying commands for destination equal to assembly point

bomb, drop, fly, paradrop, recon and sweep fail when given a
destination sector equal to the assembly point.  Broken in commit
404a76f7, v4.3.27.  Reported by Tom Johnson.

Before that commit, getpath() returned NULL on error, "" when input is
an empty path, "h" when it's coordinates of the assembly point, and a
non-empty path otherwise.

The commit accidentally changed it to return "" instead of "h".

Instead of changing it back, make it return NULL when input is an
empty path, and change bomb() & friends to accept empty flight paths.

This also affects sail: it now fails when you give it an empty path,
just like bomb & friends.  Path "h" still works.

11 years agoFix portability bug in configure test for Windows API
Markus Armbruster [Sat, 11 Aug 2012 13:36:07 +0000 (15:36 +0200)]
Fix portability bug in configure test for Windows API

The test uses an erroneous non-directive within #ifdef _WIN32 to
signal that _WIN32 is defined.  Some compilers choke on this even when
_WIN32 isn't defined.  Observed with FreeBSD 4.10's gcc 2.95.4.
Broken in commit c02468fd, v4.3.22.  Standaline client build already
broken in commit 774b590f, v4.3.17.

Use an unmatched brace instead.

11 years agoPolish empthread documentation somewhat
Markus Armbruster [Sun, 5 Aug 2012 07:23:11 +0000 (09:23 +0200)]
Polish empthread documentation somewhat

11 years agoOpen journal before daemonizing, so we can fail in foreground
Markus Armbruster [Sat, 4 Aug 2012 18:15:15 +0000 (20:15 +0200)]
Open journal before daemonizing, so we can fail in foreground

Just like we open server.log.  Also permits calling journal_prng()
right where we seed the PRNG.

11 years agoPermit empth_self() before empth_init()
Markus Armbruster [Sat, 4 Aug 2012 18:07:39 +0000 (20:07 +0200)]
Permit empth_self() before empth_init()

Next commit wants this.

11 years agoFix headline pasto in info lookout
Markus Armbruster [Sat, 4 Aug 2012 10:08:20 +0000 (12:08 +0200)]
Fix headline pasto in info lookout

Already present in BSD Empire 1.1.  Reported by Harald Katzer.

11 years agoForbid selling conquered populace
Markus Armbruster [Sun, 1 Jul 2012 12:51:45 +0000 (14:51 +0200)]
Forbid selling conquered populace

Only relevant when the deity allows selling civilians by customizing
table item, which is probably a bad idea.

11 years agoForbid selling units with unsalable cargo, permit selling military
Markus Armbruster [Sun, 1 Jul 2012 12:33:49 +0000 (14:33 +0200)]
Forbid selling units with unsalable cargo, permit selling military

Deities can customize which commodities can be sold in table item.
Default is to allow anything but civilians and military.  However,
this applies only to the commodity market, not to the unit market:
cargo of ships and land units is not restricted.

Make the two markets consistent: permit selling military by default,
forbid selling units carrying unsalable commodities.  This outlaws
selling units carrying civilians by default.

11 years agoDrop trade_desc()'s first argument
Markus Armbruster [Sun, 1 Jul 2012 11:06:23 +0000 (13:06 +0200)]
Drop trade_desc()'s first argument

11 years agoDrop unclean assignments in trade_desc()
Markus Armbruster [Sun, 1 Jul 2012 11:03:05 +0000 (13:03 +0200)]
Drop unclean assignments in trade_desc()

Assigning to tp->trd_owner is unclean.  Can be dropped safely, because
it has no effect: prior check_trade() drops all trades where the
assignment would change anything.

11 years agoClean up use of union empobj_storage * as parameter type
Markus Armbruster [Sun, 1 Jul 2012 10:21:58 +0000 (12:21 +0200)]
Clean up use of union empobj_storage * as parameter type

Use it only for functions that assign objects through a pointer
parameter.  Anything else can and should use struct empobj *.

11 years agoReplace trade_check_item_ok() by check_obj_ok()
Markus Armbruster [Sun, 1 Jul 2012 10:13:36 +0000 (12:13 +0200)]
Replace trade_check_item_ok() by check_obj_ok()

Relaxes the sanity check of the argument's ef_type.  Could be avoided,
but not worth the bother.

11 years agoFactor check_obj_ok() out of the check_*_ok()
Markus Armbruster [Sun, 1 Jul 2012 10:06:37 +0000 (12:06 +0200)]
Factor check_obj_ok() out of the check_*_ok()

11 years agoNew ef_nameof_pretty()
Markus Armbruster [Sun, 1 Jul 2012 09:53:53 +0000 (11:53 +0200)]
New ef_nameof_pretty()

11 years agoDrop obj_changed() parameter sz
Markus Armbruster [Sun, 1 Jul 2012 08:48:03 +0000 (10:48 +0200)]
Drop obj_changed() parameter sz

Get size from empfile[] instead.

11 years agoFix obj_changed() to check object exists
Markus Armbruster [Sun, 1 Jul 2012 08:00:35 +0000 (10:00 +0200)]
Fix obj_changed() to check object exists

Relatively harmless, because these kinds of objects don't go away.

11 years agoScrapping ships and land units now spreads the plague
Markus Armbruster [Sat, 30 Jun 2012 19:24:36 +0000 (21:24 +0200)]
Scrapping ships and land units now spreads the plague

11 years agoDon't let scrap give away civilians
Markus Armbruster [Sat, 30 Jun 2012 19:21:49 +0000 (21:21 +0200)]
Don't let scrap give away civilians

Scrapping unloads everything.  Even stuff that unload can't: foreign
civilians.  Kill them off instead, like scuttle does.

11 years agoPilots and air cargo now spread the plague
Markus Armbruster [Sat, 30 Jun 2012 15:09:24 +0000 (17:09 +0200)]
Pilots and air cargo now spread the plague

Planes flying one-way with crew or cargo spread plague from their old
base to their new base.  Planes dropping cargo spread plague from
their base to the drop's target sector.

11 years agoClarify info Plague slightly
Markus Armbruster [Sat, 30 Jun 2012 14:06:54 +0000 (16:06 +0200)]
Clarify info Plague slightly

11 years agoStreamline plist initialization
Markus Armbruster [Sat, 30 Jun 2012 13:34:44 +0000 (15:34 +0200)]
Streamline plist initialization

msl_equip(), find_escorts() and perform_mission() memset() the plist,
then assign to all members but load.  Just zero load instead, like
getilists(), msl_sel() and pln_sel() do.