Commit graph

1023 commits

Author SHA1 Message Date
56cadfe157 subs: Rename lnd_delete() to lnd_put_one()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-17 15:25:24 +01:00
7548337e73 subs: Rename shp_put() to shp_nav_put()
For consistency with lnd_mar_put().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-17 15:25:24 +01:00
18bf9e0b34 subs: Split lnd_mar_put() off lnd_put() and specialize
lnd_put() serves two masters: march, which wants it to report
"stopped" and write back struct ulist member mobility to
unit.land.lnd_mobil, and ground combat, which doesn't.

lnd_put() assumes march when actor is non-zero.  Correct (but see
commit 8c502d4).  Dates back to Empire 2.

Too ugly for my taste.  Specialize for each master instead:
lnd_mar_put() for march, and lnd_put() for ground combat.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-17 15:25:23 +01:00
b5ffc1ca49 subs: Split unit_put() into shp_put() and lnd_put() again
Commit d94d269 combined them into unit_put(), but that has turned out
not to be useful.  Split them again.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-17 15:25:16 +01:00
62b9399cdf subs: Factor lnd_insque() out of lnd_sel(), ask_olist(), ...
... get_dlist(), att_reacting_units().

This loses malloc() error checking in ask_olist() and get_dlist().  No
great loss, because we don't check in so many other places, including
att_reacting_units().  We should use a wrapper that terminates on
error, though.  Left for another day.

ask_olist(), get_dlist() and att_reacting_units() zero the struct
ulist with memset().  lnd_insque() doesn't, so these functions need to
zero any members not otherwise initialized explicitly now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-14 19:08:47 +01:00
5c9d6063a4 unit: Fix comments on struct ulist member use
Members x, y, eff, supplied are not "LAND only", they're used only by
ground combat.  They're not used by march.

In ground combat, member mobil is not how much the land unit has left,
it's how much it still needs to be charged.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-14 19:08:46 +01:00
fe42e6e8dd subs: Factor shp_insque() out of shp_sel(), shp_missdef(), ...
... nav_ship(), fltp_to_list().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-01-14 19:08:46 +01:00
76ca2011c3 trade: Clean up type of trdswitchown()'s second parameter
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:27 +01:00
5cbcdc0497 Clean up superfluous includes
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:26 +01:00
3b6f3a5516 retreat: Move function declarations to retreat.h
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:26 +01:00
c03db4c5ef shpsub: Make shp_check_nav() return more useful information
Some callers have to second-guess shp_check_nav() to figure out
whether CN_LANDLOCKED means "too big to fit into the canal" or "can't
go there at all".

Fix that by returning d_navigation.  CN_LANDLOCKED becomes either
NAV_CANAL or NAV_NONE, CN_CONSTRUCTION becomes either NAV_02 or
NAV_60, and CN_NAVIGABLE becomes NAVOK.

The CN_NAVIGABLE, ... codes are now unused.  Drop them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:25 +01:00
a0cdd157f1 shpsub: Move declarations to ship.h
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 13:19:25 +01:00
636752a234 bridgefall: Factor bridge_support_at() out of bridgefall()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 12:00:18 +01:00
296f3272e2 path: New DIR_BACK()
Actually pathfind.c's rev_dir() turned into a macro, to make it
available elsewhere.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 12:00:18 +01:00
a109de948b Remove option TREATIES
TREATIES has issues:

* Treaties can cover attack, assault, paradrop, board, lboard, fire,
  build (s|p|l|n) and enlist, but not bomb, launch, torpedo and
  enlistment centers.

* Usability is very poor.  While a treaty is in effect, every player
  action that violates a treaty condition triggers a prompt like this:

    This action is in contravention of  treaty #0 (with Curmudgeon)
    Do you wish to go ahead anyway? [yn]

  If you decline, the action is not executed.  If you accept, it is.
  In both cases, your decision is reported in the news.

  You cannot get rid of these prompts until the treaty expires.

* Virtually nobody uses them.

* Virtually unused code is buggy code.  There is at least one race
  condition: multifire() reads the firing sector, ship or land unit
  before the treaty prompt, and writes it back after, triggering a
  generation oops.  Any updates made by other threads while trechk()
  waits for input are wiped out, triggering a seqno mismatch oops.

* The treaty prompts could confuse smart clients that aren't prepared
  for them.  WinACE isn't, but is reported to work anyway at least
  common usage.  Ron Koenderink (the WinACE maintainer) suspects there
  could be a few situations where it will fail.

This feature is not earning its keep.  Remove it.  Drop command
treaty, consider treaty, offer treaty, xdump treaty, reject treaties.
Output of accept changed, obviously.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-16 11:44:14 +01:00
4877a2f024 accept: rejectname() makes no sense outside acce(); inline
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-02-03 20:45:25 +01:00
e852d458f9 tests: New test-suite-only command __cmd
Adding or removing a command to/from a test has unfortunate effects:

* Before the previous commit: if the command consumes pseudorandom
  numbers, all subsequent users of pseudorandom numbers get different
  ones.  This has always been a major headache.

* Since the previous commit: all subsequent users of pseudorandom
  numbers get different ones whether the command consumes any or not.
  That's even worse.

* If the command uses BTUs, subsequent prompts are changed.  Not
  nearly as bad as the above, but still annoying.

Create a new command __cmd to allow compensating for adding/removing
commands for tests.  Throw in the ability to compensate treasury
changes for good measure.  Three arguments: command count, BTU use,
money use.

Usage example: say you add a convert command to a test, and it uses 3
BTUs and $15.  Then you compensate by adding "__cmd added 1 3 15"
right after it.

The command must not be available unless running_test_suite is on, of
course.  Make it require the new player command capability TESTING,
and give that to all players when running_test_suite is on.

The command is intentionally not documented in info.  Switch
running_test_suite off for info-test, to hide it (and any future
TESTING commands) from info-test.

Suppress the command counter increment for TESTING commands, so they
can be used without upsetting pseudorandom numbers

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-19 10:16:24 +01:00
f7ac7532b2 econfig: New key running_test_suite, for use by tests
For now, it just logs "Configured for testing" on startup, and prints
a scary warning on player login.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-19 10:09:17 +01:00
bb467c335d Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
b4c8a2238c Update known contributors comments
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
5dd2cbd423 stockpile: New command, counterpart of fleetadd, wingadd, army
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:48 +01:00
329da055dd nukes: New selector stockpile
Not interesting without way to make stockpiles.  Coming soon.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2014-01-02 14:33:47 +01:00
e6c1476c2f actofgod: New divine_nat_change(), similar to divine_sct_change()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:02 +02:00
4aa2f071ba edit: Report flags change properly
Print a message, send bulletin to owner.  Affects ship key 'W', land
unit key 'W', and plane key 'f'.  The message is necessary to give the
deity a chance to catch unexpected changes, e.g. a player modifying
retreat conditions right before the deity edits them.  Watching out
for such changes is especially important with non-interactive edit.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:02 +02:00
ef2e2d08a2 edit: Teleport planes and land units to carrier on load
Edit lets deities load units onto remote carriers, resulting in a
carriers having cargo in another sector.  Not good.  Cargo gets
teleported to its carrier belatedly when the carrier moves.

Better let edit take care of the teleport.

Also tell the deity that he just caused a teleport.  Necessary to give
the deity a chance to catch unexpected changes, e.g. a player moving a
plane right before the deity edits it.  Watching out for such changes
is especially important with non-interactive edit.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:02 +02:00
cbe9897bfa edit: Report loading/unloading of planes & land units properly
Print a message, send bulletin to owner.  Affects plane keys 's', 'y',
and land unit keys 'S', 'Y'.  The message is necessary to give the
deity a chance to catch unexpected changes, e.g. a player loading a
plane right before the deity edits it.  Watching out for such changes
is especially important with non-interactive edit.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:02 +02:00
5e4af4a6f0 actofgod: New divine_unit_change(), similar to divine_sct_change()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
2f475a54dc actofgod: Factor report_divine_gift() out of give()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
004c4d0f23 edit &c: Report sector non-change differently
Print "unchanged" instead of "changed from X to X".  Affects edit,
setresource, setsector.  Suppress bulletin and news.  Affects only
edit sector key 'L'.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
6ff503c288 actofgod: Factor divine_sct_change() out of edit.c
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
0f3134fc15 sctoff2xy(): New, factored out of sct_oninit()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
f2b1ea3161 xy.h: Move declaration of sctoff() from sect.h to xy.h
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
e109d981b8 setsector setresource: Switch to edit_sect()
One copy of the code suffices.

"Fertility content" becomes just "Fertility" in messages.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:01 +02:00
fec5ad692d edit: Report sector loss and gain properly for key 'L'
Send bulletin to owner and report news exactly like for key 'o'.

Also print a "sector duplicated" message, just for consistency with
other keys.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:00 +02:00
a922cc9c5f prototypes.h: Fix and complete documentation of src/lib/gen/
Commit 77e95bd7 (v4.3.12) missed the move of log.c there.  A few
pointers to other headers are missing.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:55:00 +02:00
61a32b8b69 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>
2013-06-06 19:52:26 +02:00
726b9380d1 Replace common pattern by new LIMIT_TO()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2013-06-06 19:52:25 +02:00
edfb80a1f7 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>
2013-06-01 10:42:39 +02:00
2af8d77920 Include <sys/time.h> in lwp.h
Missed in commit 08b9455, v4.3.20.  Triggers compiler warnings on
NetBSD 5.1.2.
2013-05-08 14:35:04 +02:00
ba2600e7db Factor prod_resource_limit() out of produce() and prod() 2013-05-08 06:57:58 +02:00
f0927e7f64 prod() duplicates materials_cost(), clean up
Rename materials_cost() to prod_materials_cost(), give external
linkage, use it in prod().
2013-05-08 06:57:58 +02:00
2d3bac803c Drop extra blank line in output of pconfig 2013-05-08 06:57:56 +02:00
1afe0a7993 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.
2013-05-08 06:57:56 +02:00
da154ffd06 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.
2013-05-08 06:57:56 +02:00
5f46ced826 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.
2013-05-08 06:57:54 +02:00
74b8b9932d 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.
2013-05-08 06:57:54 +02:00
5d7f011900 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.
2013-05-08 06:57:54 +02:00
948757cb0c Use int instead of signed char for pln_flags
Just for consistency with other flags members.  Rearrange struct
plnstr to avoid holes.
2013-05-08 06:57:54 +02:00
e51b3fb842 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.
2013-05-08 06:57:51 +02:00
77f8846273 Abridge a few overly verbose declarations 2013-05-08 06:55:21 +02:00