Commit graph

4506 commits

Author SHA1 Message Date
d068259487 Simplify lnd_take_casualty()'s land unit retreat code
Bonus: avoids "may be used uninitialized" compiler warnings (the code
was safe despite the warning).
2013-01-12 17:56:39 +01:00
3a7d7fa866 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.
2013-01-12 17:56:39 +01:00
75619c3732 Simplify head_meanwhile()
No functional change.
2013-01-12 17:56:39 +01:00
bcff368909 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.
2013-01-12 17:56:39 +01:00
bfea79a72d 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.
2013-01-12 17:56:34 +01:00
c4c4413ea5 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.
2013-01-12 17:56:26 +01:00
efa4ecdc4d Drop resnoise()'s second parameter
All callers pass the same argument.
2013-01-12 17:56:26 +01:00
eb4adc93ff 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.
2013-01-12 17:56:26 +01:00
6fbc291272 anti, give, grind take <SECTS> argument, fix their documentation 2013-01-12 17:56:26 +01:00
f2e5e467c0 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."
2013-01-12 17:56:26 +01:00
3783652d7a 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.
2013-01-12 17:51:22 +01:00
df4925d696 Update copyright notice 2013-01-12 17:45:01 +01:00
c300dc7055 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.
2012-08-12 09:36:07 +02:00
0f1e14f0f3 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.
2012-08-12 09:34:49 +02:00
9645a73bfb 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.
2012-08-11 15:36:56 +02:00
3e3c2eecf9 Polish empthread documentation somewhat 2012-08-05 09:26:32 +02:00
efc3a8e6e2 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.
2012-08-05 09:26:08 +02:00
fc64b4fa83 Permit empth_self() before empth_init()
Next commit wants this.
2012-08-05 09:24:57 +02:00
3d7383c548 Fix headline pasto in info lookout
Already present in BSD Empire 1.1.  Reported by Harald Katzer.
2012-08-04 12:11:55 +02:00
30dbd609bc Forbid selling conquered populace
Only relevant when the deity allows selling civilians by customizing
table item, which is probably a bad idea.
2012-07-13 20:15:34 +02:00
324109ae45 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.
2012-07-13 20:15:34 +02:00
6c086a8110 Drop trade_desc()'s first argument 2012-07-13 20:15:34 +02:00
4f3d6792e3 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.
2012-07-13 20:15:34 +02:00
d9cafc156c 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 *.
2012-07-13 20:15:33 +02:00
f75544ee70 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.
2012-07-13 20:15:33 +02:00
29f6d10a34 Factor check_obj_ok() out of the check_*_ok() 2012-07-13 20:15:33 +02:00
e25ff14f0c New ef_nameof_pretty() 2012-07-13 20:15:33 +02:00
4072098c32 Drop obj_changed() parameter sz
Get size from empfile[] instead.
2012-07-13 20:15:33 +02:00
9728e68a42 Fix obj_changed() to check object exists
Relatively harmless, because these kinds of objects don't go away.
2012-07-13 20:15:33 +02:00
b0fc3f43d4 Scrapping ships and land units now spreads the plague 2012-07-13 20:15:33 +02:00
3d3d272eef 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.
2012-07-13 20:15:33 +02:00
612ec6257d 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.
2012-07-13 20:15:33 +02:00
a8739d86e3 Clarify info Plague slightly 2012-07-13 20:15:33 +02:00
bad2fd5aac 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.
2012-07-13 20:15:33 +02:00
48f3d1c033 Initialize struct plist member queue properly in msl_equip()
Harmless, because queue isn't actually used.  Clean it up anyway.
2012-07-13 20:15:33 +02:00
154f04f218 scripts: Use mailx rather than mail, and drop bogus -e 2012-07-13 20:15:33 +02:00
729cf65e12 Don't let fly and drop give away civilians
Flying them to a foreign destination magically changes their
allegiance.  Prohibit that.

Equivalent change was already in commit 35887222 (v4.2.17) but got
reverted immediately (commit 20199b22), because fly and drop should
stay consistent with load, which let you give away civilians then.  No
more since commit 92a366ce (v4.3.20).  This change makes fly and drop
consistent with load again.
2012-07-13 20:15:33 +02:00
b4acb73fd1 Replace pln_oneway_to_carrier_ok() by pln_can_land_on_carrier()
Avoids reading the target ship again.
2012-07-13 20:15:33 +02:00
d9a915a05b Replace pln_onewaymission() by pln_where_to_land()
New function reads and returns target sector/ship.  Avoids reading the
target sector unnecessarily.  Callers receive the target ship, not
just its number.  Next commit will put it to use.
2012-07-13 20:14:10 +02:00
41b2fa433f Fix fly to permit flying civs to a carrier in an occupied sector
Broken in commit 35887222, v4.2.17.
2012-07-12 19:52:33 +02:00
72f1e22b95 Drop could_be_on_ship()'s load count parameters
Just one caller wants them.  Inline that call, and simplify the
others.
2012-07-12 19:52:33 +02:00
665d0d723d Inline fit_plane_on_ship() and fit_plane_on_land()
Just one call site each.
2012-07-12 19:52:33 +02:00
b60e5be22c Don't let planes fly to a carrier without sufficient space
We test whether the the carrier has space for each plane individually
instead of whether it has space for all of them.  The planes that fit
land, the others abort and get teleported home.  Abusable.

pln_oneway_to_carrier_ok() was created in commit 1127762c (v4.2.17) to
fix almost the same bug.  It worked fine then, because
fit_plane_on_ship() worked with load counters, and incremented them.

Broken in commit 3e370da5 (v4.3.17), which made fit_plane_on_ship()
count the loaded planes, to permit the removal of load counters.  But
unlike load counters, loaded planes don't change during
pln_oneway_to_carrier_ok().  Thus, each plane is checked individually.

Fix by tallying all the planes before checking for space.
2012-07-12 19:51:57 +02:00
81efebd367 Factor inc_shp_nplane() out of could_be_on_ship() 2012-06-24 08:49:57 +02:00
ae279968b9 Factor ship_can_carry() out of could_be_on_ship() 2012-06-24 08:49:57 +02:00
5424142f62 Fix tend to refuse tending civilians to foreign ships
Broken when Chainsaw 2 added tending to allies.
2012-06-24 08:49:34 +02:00
e16fc41b2e Fix tend not to leak which commodities are loaded on friendlies
Tending a negative number of commodities takes from the target ships.
The target ships must be owned.  Tend complains when the target
doesn't have the commodity loaded.  It does that even for friendly
foreign ships.  Don't.

Broken when Chainsaw 2 added tending to allies.
2012-06-24 08:47:08 +02:00
20b2598214 Fix tend from target not to stop on foreign target
Tending a negative number of commodities takes from the target ships.
When a target ship is foreign, tend silently stops.  This is wrong.
Fix it to skip foreign target ships instead.

Broken when Chainsaw 2 added tending to allies.
2012-06-24 08:45:55 +02:00
f11071f3b7 Let march sub-command 'm' sweep own and allied landmines 2012-06-11 17:28:19 +02:00
0b7fba038a Land units no longer sweep allied landmines
They don't hit them since commit fe372539, v4.3.27.  Sweeping was
forgotten then.

Closes #717591.
2012-06-11 17:28:14 +02:00