]> git.pond.sub.org Git - empserver/log
empserver
13 years agoChange flash not to print "Flash sent" for deities
Markus Armbruster [Sat, 5 Feb 2011 09:42:58 +0000 (10:42 +0100)]
Change flash not to print "Flash sent" for deities

It's annoying.  It never did that for mortals.

13 years agoRemove pointless variables from setrel()
Markus Armbruster [Sat, 5 Feb 2011 09:18:30 +0000 (10:18 +0100)]
Remove pointless variables from setrel()

13 years agoMake setrel() refuse to change relations to self
Markus Armbruster [Sat, 5 Feb 2011 08:31:44 +0000 (09:31 +0100)]
Make setrel() refuse to change relations to self

No current caller actually attempts that, but let's make it obvious.

13 years agoChange setrel(), setcont(), setrej() to return void
Markus Armbruster [Sat, 5 Feb 2011 08:30:12 +0000 (09:30 +0100)]
Change setrel(), setcont(), setrej() to return void

Nobody cares for their value anyway.

13 years agoOops on invalid arguments in setrel(), setcont(), setrej()
Markus Armbruster [Sat, 5 Feb 2011 08:28:05 +0000 (09:28 +0100)]
Oops on invalid arguments in setrel(), setcont(), setrej()

Before, they recovered silently.

13 years agoUse feels_like_helping() in dosupport(), lnd_support()
Markus Armbruster [Mon, 31 Jan 2011 19:53:44 +0000 (20:53 +0100)]
Use feels_like_helping() in dosupport(), lnd_support()

feels_like_helping() case cn == foe is missing in the code it
replaces.  No difference in behavior, because:

* cn == foe && cn == friend can't happen.  Because you can't get into
  ground combat against yourself (assault, attack and paradrop don't
  let you), friend != foe for support.

* cn == foe && cn != friend behaves the same: no support.
  feels_like_helping() returns 0 because of the explicit case.  The
  replaced code doesn't support because cn can't be at war with
  itself.

13 years agoFactor feels_like_helping() out of quiet_bigdef(), sd(), dd()
Markus Armbruster [Mon, 31 Jan 2011 19:46:53 +0000 (20:46 +0100)]
Factor feels_like_helping() out of quiet_bigdef(), sd(), dd()

13 years agoPlug memory leaks in mission execution code
Markus Armbruster [Mon, 31 Jan 2011 06:56:44 +0000 (07:56 +0100)]
Plug memory leaks in mission execution code

Mission execution first builds lists of eligible units, one list per
country.  These lists are passed to perform_mission() one by one,
where they get freed.

Bugs:

* unit_interdict() didn't pass the list for the submarine's owner, but
  build_mission_list_type() built one.  Any submarine movement within
  own submarine interdiction mission op areas leaked memory.

* dosupport() passed only lists for countries that actually support
  (ally at war with victim), but build_mission_list_type() built lists
  for all countries hostile to the victim.  Ground combat within
  support mission op areas countries that are hostile to one of the
  party without actually supporting the other leaked memory.

* perform_mission() failed to free missiles targeting units.

Fixing the latter is straightforward.

Fix the first two by deciding whether a country acts on a mission
trigger before building any lists, in ground_interdict(),
unit_interdict(), dosupport().  Remove the code dealing with that from
build_mission_list_type() and the loops around perform_mission().

13 years agoMove code from def_support(), off_support() to dosupport()
Markus Armbruster [Mon, 31 Jan 2011 19:02:23 +0000 (20:02 +0100)]
Move code from def_support(), off_support() to dosupport()

13 years agoEliminate nav_loadship() variables landown, shipown
Markus Armbruster [Sun, 30 Jan 2011 16:08:00 +0000 (17:08 +0100)]
Eliminate nav_loadship() variables landown, shipown

Code is clearer without them.  Works because load_it() never changes
ship or sector owner.

13 years agoDrop redundant nav_loadship() parameter cnum
Markus Armbruster [Sun, 30 Jan 2011 15:55:15 +0000 (16:55 +0100)]
Drop redundant nav_loadship() parameter cnum

13 years agoEliminate nav_ship() variable cnum
Markus Armbruster [Sun, 30 Jan 2011 15:54:19 +0000 (16:54 +0100)]
Eliminate nav_ship() variable cnum

Code is clearer without it.

13 years agoOops on invalid actor and victim arguments in nreport()
Markus Armbruster [Sun, 30 Jan 2011 15:12:14 +0000 (16:12 +0100)]
Oops on invalid actor and victim arguments in nreport()

Replaces the existing, silent recovery from invalid victim argument.

13 years agoClean up use of current player in march code
Markus Armbruster [Sat, 29 Jan 2011 09:40:59 +0000 (10:40 +0100)]
Clean up use of current player in march code

lnd_mar() and lnd_mar_one_sector() take an actor argument.
Nevertheless, they sometimes used player->cnum.  Fortunately, they are
the same: all callers pass current player for actor.  Normalize to
actor for consistency.

13 years agoFix land unit attack mobility cost out of allied sectors
Markus Armbruster [Sun, 23 Jan 2011 18:39:48 +0000 (19:39 +0100)]
Fix land unit attack mobility cost out of allied sectors

Land units pay a mobility penalty when marching into a non-old-owned
sector without sector mobility, to slow them down in newly taken
sectors.  Attacking land units pay this penalty regardless of sector
mobility.

When attacking out of an allied sector, the penalty was computed as if
the land unit was owned by that ally.  Attacking sectors old-owned by
that ally was too cheap, and taking back one's own was too expensive.

Broken since attacking land units pay the "newly taken" mobility
penalty: commit 2e693275, v4.3.6.

13 years agoFix attack when attacking sector gets taken by ally
Markus Armbruster [Thu, 20 Jan 2011 06:49:44 +0000 (07:49 +0100)]
Fix attack when attacking sector gets taken by ally

When an attacking sector got lost while the player was at a prompt,
and the new owner was allied to the player, the server got confused:

1. If the sector attacked with mil, the server let the ghost mil
attack, but not occupy.

2. If the sector was allied, the server reported the sector loss and
land units dropping out of the attack, but claimed the lost sector was
yours.

Fix 1. by dropping sectors from attack when they change owner away
from the player, regardless of relations.  Side effect: also drops any
surviving land units there.  Before, they dropped out only if the new
owner wasn't allied to the player.  That change's okay.

Fix 2. the obvious way: change the messages.

Broken in 4.0.0.

13 years agoFix trade ships to pay off in own harbor
Markus Armbruster [Sun, 16 Jan 2011 20:20:28 +0000 (21:20 +0100)]
Fix trade ships to pay off in own harbor

Broken in commit 3318e4e4, v4.3.17.

13 years agoRemove option SLOW_WAR
Markus Armbruster [Sun, 9 Jan 2011 18:03:38 +0000 (19:03 +0100)]
Remove option SLOW_WAR

SLOW_WAR has issues:

* The check whether the attacker old-owns the attacked sector is
  broken, because att_abort() uses sect.sct_oldown uninitialized.

  Spotted by the Clang Static Analyzer.

* Its implementation in setrel() is somewhat scary.  It's actually
  okay, because that part of setrel() only runs within decl().  Other
  callers don't reach it: update_main() because player->god != 0
  there, and the rest because they never pass a rel < HOSTILE.

* Documentation is a bit vague.

SLOW_WAR hasn't been used in a public game in years.  Fixing it is not
worth it, so remove it instead.

13 years agoFix nightly's sandbox cleanup not to hang when stdin is a tty
Markus Armbruster [Sat, 15 Jan 2011 13:39:30 +0000 (14:39 +0100)]
Fix nightly's sandbox cleanup not to hang when stdin is a tty

"rm -r" prompts for read-only files when stdin is a tty.  Probably
broken since we install builtin configuration read-only, in commit
b4161cd7, v4.3.0.

Move "done" message to the right place.  Broken in commit 70c03561,
v4.3.12.

13 years agoFix nightly's check for existing sandbox
Markus Armbruster [Sat, 15 Jan 2011 12:47:16 +0000 (13:47 +0100)]
Fix nightly's check for existing sandbox

Broken in commit 70c03561, v4.3.12.

13 years agoClean up a useless use of cat
Markus Armbruster [Sat, 15 Jan 2011 12:46:43 +0000 (13:46 +0100)]
Clean up a useless use of cat

13 years agoFix make clean to remove info.ps
Markus Armbruster [Sun, 15 Aug 2010 09:18:31 +0000 (11:18 +0200)]
Fix make clean to remove info.ps

Missed in commit 9067d7a4.

13 years agoFix sail command to support full path length
Markus Armbruster [Sun, 18 Jul 2010 16:16:01 +0000 (18:16 +0200)]
Fix sail command to support full path length

Off-by-one in cmd_sail_ship() chopped off the last character of
full-length sail paths.

13 years agoRemove unused plurize()
Markus Armbruster [Sun, 18 Jul 2010 13:14:41 +0000 (15:14 +0200)]
Remove unused plurize()

Unused since commit 44c36fa, v4.3.23.

13 years agoChange ioq_dequeue() to return void
Markus Armbruster [Sun, 29 Aug 2010 09:38:02 +0000 (11:38 +0200)]
Change ioq_dequeue() to return void

For symmetry with ioq_append().

13 years agoErr, the race in io_output() doesn't double-free
Markus Armbruster [Sun, 29 Aug 2010 09:31:02 +0000 (11:31 +0200)]
Err, the race in io_output() doesn't double-free

The previous commit's message claims the race can lead to duplicated
output, use after free, then double-free.  That's correct only up to
the use after free.  There is no double-free.

Heap corruption (double-free?) has been observed in Changeling,
though.  Player logged in (still in sanctuary), map #, crashed within
removecc()'s free(io->data).  Partial backtrace:

    raise () from /lib64/libc.so.6
    abort () from /lib64/libc.so.6
    __libc_message () from /lib64/libc.so.6
    malloc_printerr () from /lib64/libc.so.6
    removecc (ioq=0x251fd10, cc=468) at ../src/lib/gen/ioqueue.c:350
    ioq_dequeue (ioq=0x251fd10, cc=468) at ../src/lib/gen/ioqueue.c:135
    io_output (iop=0x251fc90, wait=1) at ../src/lib/empthread/io.c:231
    recvclient (cmd=0x258d8e0 "", size=1024) at ../src/lib/player/recvclient.c:82
    getcommand (combufp=0x2557068 "map #1") at ../src/lib/player/empdis.c:84

I haven't been able to reproduce.

To hopefully catch ioqueue going south earlier, make ioq_dequeue()
oops when it can't dequeue as many bytes as requested.

13 years agoFix race in io_output() that can lead to double-free
Markus Armbruster [Sun, 4 Jul 2010 15:30:33 +0000 (17:30 +0200)]
Fix race in io_output() that can lead to double-free

Move call of ioq_makeiov() to its use, because calling it before
empth_select() is racy, as follows.

Player thread flushes output by calling io_output(player->iop, 1).
io_output() sets up iov[] to point to queued output.  empth_select()
blocks on output.

Another thread sends a C_FLASH or C_INFORM message to this player.
This calls io_output(p->iop, 0).  The output file descriptor has
become writable since the player thread blocked on it, so some output
gets written and dequeued.

The player thread resumes, writes out iov[] and dequeues.  Any output
already written by the other thread gets duplicated.  If the other
thread's dequeue operation freed struct io buffers, there's use after
free followed by double-free.

13 years agoDocument xundump() memory leak more clearly
Markus Armbruster [Sun, 4 Jul 2010 15:30:03 +0000 (17:30 +0200)]
Document xundump() memory leak more clearly

13 years agoPlanes get to sweep and sonar only after flak and interception
Markus Armbruster [Sun, 27 Jun 2010 07:33:24 +0000 (09:33 +0200)]
Planes get to sweep and sonar only after flak and interception

If defenders get to shoot before bombs are dropped, they surely get to
shoot before time-consuming missions like sweep and sonar.

Sweep and sonar used to happen after air defense, but before flak and
interception.  Air defense existed from Chainsaw 3 to v4.3.19.

13 years agoNeater plane sonar contact output
Markus Armbruster [Sun, 18 Jul 2010 08:37:43 +0000 (10:37 +0200)]
Neater plane sonar contact output

plane_sona() prints an empty line to make sonar contacts stand out.
Move it so the contact is visually "attached" to the right sector,
like this:

    flying over sea at 15,-3
    Sonar contact in 15,-3
    sub #3 13,-3

    flying over sea at 13,-3

Before:

    flying over sea at 15,-3

    Sonar contact in 15,-3
    sb   submarine (#3) 13,-3
    flying over sea at 13,-3

13 years agoDon't write garbage to unused trade destination in trade file
Markus Armbruster [Sun, 27 Jun 2010 09:35:08 +0000 (11:35 +0200)]
Don't write garbage to unused trade destination in trade file

struct trdstr members trd_x, trd_y are used only for teleporting
trades.  For others, trad() wrote garbage coordinates to the trade
file.  They weren't used except by xdump.  Fortunately, even there
they're visible only to deities.

Write invalid coordinates instead.  Do that in set() as well, so that
coordinates are valid only when we have a teleport destination.

Spotted by the Clang Static Analyzer.

13 years agoClean up dead store in skyw()
Markus Armbruster [Sun, 27 Jun 2010 08:09:30 +0000 (10:09 +0200)]
Clean up dead store in skyw()

Dead since commit 38befcb4.  Spotted by the Clang Static Analyzer.

13 years agoMake disabled recursive supply in s_commod() compile again
Markus Armbruster [Sun, 20 Jun 2010 16:34:58 +0000 (18:34 +0200)]
Make disabled recursive supply in s_commod() compile again

Untested.  Broken in commit 98f24d5c, v4.3.20.

13 years agoRemove unused variables in disabled lnd_fort_interdiction()
Markus Armbruster [Sun, 20 Jun 2010 16:33:42 +0000 (18:33 +0200)]
Remove unused variables in disabled lnd_fort_interdiction()

13 years agoClean up unobvious coordinate system use in doland()
Markus Armbruster [Sun, 20 Jun 2010 15:58:30 +0000 (17:58 +0200)]
Clean up unobvious coordinate system use in doland()

Use the obviously correct newown instead of sect->sct_own.  They're
actually equal here.

13 years agoClean up unobvious coordinate system use in detonate()
Markus Armbruster [Sun, 20 Jun 2010 15:57:55 +0000 (17:57 +0200)]
Clean up unobvious coordinate system use in detonate()

Use the obviously correct player->cnum instead of own.  They're
actually equal here.

13 years agoClean up unobvious coordinate system use in pln_airbase_ok()
Markus Armbruster [Sun, 20 Jun 2010 15:57:17 +0000 (17:57 +0200)]
Clean up unobvious coordinate system use in pln_airbase_ok()

Use the obviously correct player->cnum instead of pp->pln_own.
They're actually equal here.

13 years agoClean up suspicious coordinate system use in unit_put()
Markus Armbruster [Sun, 20 Jun 2010 15:53:17 +0000 (17:53 +0200)]
Clean up suspicious coordinate system use in unit_put()

It showed unit coordinates in unit's coordinate system instead of the
actor's.  Fortunately, they're the same, since it is reachable only
for non-zero actor, only shp_nav_one_sector(), lnd_mar_one_sector()
and sail_nav_fleet() pass that, and even deities can't navigate
foreign ships or march foreign land units.

13 years agoFactor rad_char() out of radmap() and rad_map_set()
Markus Armbruster [Sun, 20 Jun 2010 14:34:08 +0000 (16:34 +0200)]
Factor rad_char() out of radmap() and rad_map_set()

Code was duplicated in commit 0d477e5d.

13 years agoCompute radar range in one place, rad_range()
Markus Armbruster [Sun, 20 Jun 2010 14:19:22 +0000 (16:19 +0200)]
Compute radar range in one place, rad_range()

Before, a part was duplicated in radmap() and rad_map_set(), and
another part in their callers.

13 years agoDon't limit radar command's range to fit into world map
Markus Armbruster [Sun, 20 Jun 2010 12:55:30 +0000 (14:55 +0200)]
Don't limit radar command's range to fit into world map

Limited since Chainsaw 2 so that the radar map fits into a world map
without clipping, i.e. its diameter neither exceeds WORLD_X / 2 nor
WORLD_Y.  Maybe range exceeding that triggered bugs then.  It doesn't
now, and it makes no sense.

The limit never applied to automatic bmap update from ship radar.

13 years agoSimplify radmap() and radmap2()
Markus Armbruster [Sun, 20 Jun 2010 11:55:52 +0000 (13:55 +0200)]
Simplify radmap() and radmap2()

radmap() is now radmap2()'s only caller.  Inline radmap2() and
simplify.  This cleans up a suspicious-looking use of xyas(): it
relied on the fact that owner == player->cnum if pr_flag.

13 years agoSimplify automatic bmap update from ship radar
Markus Armbruster [Sun, 20 Jun 2010 11:43:16 +0000 (13:43 +0200)]
Simplify automatic bmap update from ship radar

Inline radmap2() into radmapupd() and simplify.  Drop unused parameter
seesub.  Rename to rad_map_set().

13 years agoRemove radmapnopr(), use radmapupd() instead
Markus Armbruster [Sun, 20 Jun 2010 11:32:03 +0000 (13:32 +0200)]
Remove radmapnopr(), use radmapupd() instead

13 years agoClean up output destinations in navigation code
Markus Armbruster [Sun, 20 Jun 2010 08:47:37 +0000 (10:47 +0200)]
Clean up output destinations in navigation code

shp_nav() and shp_nav_one_sector() printed both to their actor
argument and to ship owner.  shp_nav_one_sector()'s use of xyas()
looked particularly suspicious: it passed actor, then printed the
result to the ship owner.  Fortunately, actor and ship owner are the
same, since even deities can't navigate foreign ships.  Normalize to
actor for consistency.

While there, rename shp_mess() to shp_stays().

13 years agoClean up output destinations in march code
Markus Armbruster [Sun, 20 Jun 2010 08:42:34 +0000 (10:42 +0200)]
Clean up output destinations in march code

lnd_mar(), lnd_sweep() and lnd_mar_one_sector() printed to the current
player, their actor argument, and to land unit owner.
lnd_mar_one_sector()'s use of xyas() looked particularly suspicious:
it passed actor, then printed the result to the current player or land
unit owner.  Fortunately, all three are the same: all callers pass
current player for actor, and land unit owner is the same, since even
deities can't march foreign land units.  Normalize to actor for
consistency.

While there, rename lnd_mess() to lnd_stays().

13 years agoClean up confusing use of def->own in move_in_land()
Markus Armbruster [Sun, 20 Jun 2010 08:40:00 +0000 (10:40 +0200)]
Clean up confusing use of def->own in move_in_land()

It passed def->own to lnd_sweep(), which looks like a bug.  But it's
actually player->cnum there, because take_def() already set def->own
to player->owner: take_def() first changes the owner of the attacked
sector by calling takeover(), then updates def->own from that in
att_get_combat().

13 years agoClean up output destinations in attack code
Markus Armbruster [Sun, 20 Jun 2010 08:02:27 +0000 (10:02 +0200)]
Clean up output destinations in attack code

take_def() and ask_move_in() printed both to the current player and to
land unit owner.  Their use of prcom() and xyas() looked particularly
suspicious: they used the current player, then printed the result to
the land unit owner.  Fortunately, current player and land unit owner
are the same, since even even deities can't attack with foreign land
units.  Normalize to current player for consistency.

Switch get_ototal(), get_oland(), kill_land() and move_in_land() to
current player as well.

13 years agoUse lnd_delete() in lnd_mess()
Markus Armbruster [Sun, 20 Jun 2010 07:00:42 +0000 (09:00 +0200)]
Use lnd_delete() in lnd_mess()

13 years agolnd_delete() can no longer print a message
Markus Armbruster [Sun, 20 Jun 2010 06:34:11 +0000 (08:34 +0200)]
lnd_delete() can no longer print a message

Callers changed to print it themselves.

But print the first "boards" message before plane takeover instead of
after, in take_def().

13 years agoRename put_land() to put_oland() for clarity
Markus Armbruster [Sun, 20 Jun 2010 06:33:35 +0000 (08:33 +0200)]
Rename put_land() to put_oland() for clarity

13 years agoSplit get_land() into get_oland() and get_dland() & simplify
Markus Armbruster [Sat, 19 Jun 2010 15:54:44 +0000 (17:54 +0200)]
Split get_land() into get_oland() and get_dland() & simplify

13 years agoput_land()'s function comment has drifted away, fix
Markus Armbruster [Sat, 19 Jun 2010 14:29:33 +0000 (16:29 +0200)]
put_land()'s function comment has drifted away, fix

13 years agoFix oops recovery in lnd_set_tech()
Markus Armbruster [Sat, 19 Jun 2010 12:13:30 +0000 (14:13 +0200)]
Fix oops recovery in lnd_set_tech()

Broken in commit 0219bf08.

13 years agoPR() and PRdate() are no longer used, remove them
Markus Armbruster [Fri, 18 Jun 2010 19:04:25 +0000 (21:04 +0200)]
PR() and PRdate() are no longer used, remove them

13 years agoUse mpr() instead of PR() where possible
Markus Armbruster [Fri, 18 Jun 2010 19:02:18 +0000 (21:02 +0200)]
Use mpr() instead of PR() where possible

The difference between the two is that PR() buffers partial lines, and
mpr() suppresses output to country#0.  Doesn't matter when printing
complete lines to a country other than #0, e.g. the owner of a unit.

13 years agoFactor ac_dog_report() out of ac_dog()
Markus Armbruster [Fri, 18 Jun 2010 18:04:41 +0000 (20:04 +0200)]
Factor ac_dog_report() out of ac_dog()

13 years agoStreamline flak damage report to plane owner
Markus Armbruster [Fri, 18 Jun 2010 05:53:11 +0000 (07:53 +0200)]
Streamline flak damage report to plane owner

Don't tell him that it's his plane, he knows that.

Put a " -- " between "takes N%" and "aborted" / "shot down" for
ordinary flak as well, not just for flak vs. pinpoint bombing.

13 years agoFactor common plane damage code into ac_damage_plane()
Markus Armbruster [Thu, 17 Jun 2010 05:47:45 +0000 (07:47 +0200)]
Factor common plane damage code into ac_damage_plane()

Out of ac_planedamage() and pinflak_planedamage().

13 years agoMake flak vs. pinpoint bombing consistent with ordinary flak
Markus Armbruster [Thu, 17 Jun 2010 05:38:47 +0000 (07:38 +0200)]
Make flak vs. pinpoint bombing consistent with ordinary flak

Reduce abort chance from 100-eff to 80-eff.  Ordinary flak's abort
chance was reduced from 100-eff (if eff<80) to 80-eff in commit
0252d4a7, v4.3.6.

Report plane efficiency when it aborts, not 100 - efficiency.

Charge mobility proportional to damage, down to -32.

13 years agoSuppress "no damage" after "takes 0" when reporting flak
Markus Armbruster [Thu, 17 Jun 2010 05:05:07 +0000 (07:05 +0200)]
Suppress "no damage" after "takes 0" when reporting flak

13 years agoClean up ac_planedamage() a bit
Markus Armbruster [Wed, 16 Jun 2010 19:26:19 +0000 (21:26 +0200)]
Clean up ac_planedamage() a bit

Reshuffle code for clarity, and delete a bogus comment.

13 years agoRename ac_planedamage() argument show to flak
Markus Armbruster [Wed, 16 Jun 2010 19:24:00 +0000 (21:24 +0200)]
Rename ac_planedamage() argument show to flak

Parameter name "show" is misleading since the previous commit:
non-zero no longer shows anything, only suppresses output.

13 years agoMove printing from ac_planedamage() into callers
Markus Armbruster [Wed, 16 Jun 2010 19:20:27 +0000 (21:20 +0200)]
Move printing from ac_planedamage() into callers

It prints only if show is non-zero, so only ac_fireflak() is affected.

13 years agoStreamline ac_planedamage()'s last argument
Markus Armbruster [Wed, 16 Jun 2010 18:50:16 +0000 (20:50 +0200)]
Streamline ac_planedamage()'s last argument

ac_planedamage() writes up to 14 characters.  Trim excessive buffers
in callers.  Guard against overrun in callee.

13 years agoSimplify ac_planedamage() to write straight to mesg[]
Markus Armbruster [Wed, 16 Jun 2010 18:41:53 +0000 (20:41 +0200)]
Simplify ac_planedamage() to write straight to mesg[]

13 years agoRemove dead code from ac_planedamage()
Markus Armbruster [Tue, 15 Jun 2010 18:44:50 +0000 (20:44 +0200)]
Remove dead code from ac_planedamage()

Since Empire 3 made option NEWPAF mandatory, checkabort is always
non-zero, and show implies checkabort != 1 and other == 0.  Drop
unreachable code, and remove unused parameters checkabort and other.

13 years agoClean up call of writemap() in ac_encounter()
Markus Armbruster [Mon, 14 Jun 2010 05:42:30 +0000 (07:42 +0200)]
Clean up call of writemap() in ac_encounter()

Pass the more obviously correct plane_owner instead of player->cnum.
They're the same, actually.

When deities could still fly foreign planes (before commit 2023b47c),
they weren't.  ac_encounter() updated the plane owner's in-memory
bmap, but wrote the current player's bmap to disk.

13 years agoFix recon and satellite to write spy plane bmap updates to disk
Markus Armbruster [Mon, 14 Jun 2010 05:18:01 +0000 (07:18 +0200)]
Fix recon and satellite to write spy plane bmap updates to disk

satdisp_sect() updated the in-memory bmap, but failed to write the
updates to disk.  Its callers already update bmap from other sources,
so move this update there, and connect it to the existing write back.

13 years agoFactor look_at_sect() out of do_look() and ac_encounter()
Markus Armbruster [Mon, 14 Jun 2010 04:57:04 +0000 (06:57 +0200)]
Factor look_at_sect() out of do_look() and ac_encounter()

13 years agoRestrict ac_encounter() mission_flags to current player
Markus Armbruster [Mon, 14 Jun 2010 04:28:48 +0000 (06:28 +0200)]
Restrict ac_encounter() mission_flags to current player

The only user is reco(), so the restriction is fine.  Several
functions called on behalf of mission_flags assumed it already:
plane_sweep(), sathead(), satdisp_sect(), satdisp_units().  Simplify
the rest accordingly: plane_sona() and ac_encounter() itself.

13 years agoFix lookout to report sector owner properly to deities
Markus Armbruster [Fri, 11 Jun 2010 06:34:29 +0000 (08:34 +0200)]
Fix lookout to report sector owner properly to deities

It reported all sectors as owned by the deity.

13 years agoFix bogus message when deity attempts to march foreign land unit
Markus Armbruster [Sun, 13 Jun 2010 15:59:49 +0000 (17:59 +0200)]
Fix bogus message when deity attempts to march foreign land unit

Much of the code assumes that only the land unit's owner can march it.
The assumption is correct, because lnd_mar() leaves foreign land units
behind with a bogus "was disbanded at" message (suppressed for country

It would be nice to let deities march foreign land units, but the
assumption is not trivial to remove.  For now, just avoid the bogus
message.

Historical note: it looks like deities used to be able to march
foreign land units just fine until Empire 2 factored common code out
of navigate, sail and autonav, and updated march to match navigate.
Likewise, it looks like they could board with foreign land units until
Empire 2 factored out common ground combat code.  Commands attack and
assault have always rejected foreign land units, even for deities.

13 years agoFix bogus message when deity attempts to navigate foreign ship
Markus Armbruster [Sun, 13 Jun 2010 15:54:27 +0000 (17:54 +0200)]
Fix bogus message when deity attempts to navigate foreign ship

Much of the code assumes that only the ship's owner can navigate it.
The assumption is correct, because shp_nav() leaves foreign ships
behind with a bogus "was sunk at" message (suppressed for country #0).

It would be nice to let deities navigate foreign ships, but the
assumption is not trivial to remove.  For now, just avoid the bogus
message.

Historical note: it looks like deities used to be able to navigate
foreign ships just fine until Empire 2 factored common code out of
navigate, sail and autonav.

13 years agoDon't let deities fly foreign planes
Markus Armbruster [Sun, 13 Jun 2010 15:20:00 +0000 (17:20 +0200)]
Don't let deities fly foreign planes

Much code assumes that only the plane's owner can fly it.
pln_airbase_ok() oopses since commit 446f1991.  Before, flying planes
from carriers failed with a bogus "not valid for" message, and flying
from sectors had output misdirected to the plane's owner.

It would be nice to let deities fly foreign planes, but the assumption
is not trivial to remove, so just satisfy it for now.

Historical note: it looks like deities used to be able to fly foreign
planes just fine until Chainsaw 3 added missions.  The launch command
has always rejected foreign planes, even for deities.

13 years agoOops when mpr() is misused for printing partial lines
Markus Armbruster [Tue, 8 Jun 2010 04:28:25 +0000 (06:28 +0200)]
Oops when mpr() is misused for printing partial lines

Such misuse creates a bulletin with a partial line.  The read command
normally merges it with the next one, but if the bulletins are more
than five seconds apart (clock jumped somehow), we get a bulletin
header in the middle of a line.

13 years agoClean up misuse of mpr() in pln_damage()
Markus Armbruster [Sun, 6 Jun 2010 21:05:58 +0000 (23:05 +0200)]
Clean up misuse of mpr() in pln_damage()

Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

While there, wrap long "blam" lines.  Can only happen for bomb loads
above 16.  Stock game needs a tech 406 jhb for that.

The mpr() misuse was introduced in Empire 2.

13 years agoClean up misuse of mpr() in shp_missile_defense()
Markus Armbruster [Sun, 6 Jun 2010 20:40:44 +0000 (22:40 +0200)]
Clean up misuse of mpr() in shp_missile_defense()

Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

The mpr() misuse was introduced in Empire 2.

13 years agoClean up misuse of mpr() in msl_launch()
Markus Armbruster [Sun, 6 Jun 2010 20:39:52 +0000 (22:39 +0200)]
Clean up misuse of mpr() in msl_launch()

Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

The mpr() misuse was introduced in Empire 2.

13 years agoMessage for land unit hitting mines lacked a newline
Markus Armbruster [Sun, 6 Jun 2010 20:34:05 +0000 (22:34 +0200)]
Message for land unit hitting mines lacked a newline

Broken in Empire 2.

13 years agoDon't beep when plane, land unit or nuke die on collapsing bridge
Markus Armbruster [Sun, 6 Jun 2010 20:26:02 +0000 (22:26 +0200)]
Don't beep when plane, land unit or nuke die on collapsing bridge

Not nice, because it could beep many times, and could put beeps in
bulletins.  Moreover, it misused mpr() and thus put the beep in its
own bulletin.  The read command normally merges this bulletin with the
adjacent ones, but if the bulletins are more than five seconds apart
(clock jumped somehow), we can get an empty bulletin just for the
beep.

Beeping was added in v4.0.18.

13 years agoImprove bulletin for nuke destroyed by nuclear attack
Markus Armbruster [Sun, 6 Jun 2010 20:18:31 +0000 (22:18 +0200)]
Improve bulletin for nuke destroyed by nuclear attack

Explain what destroyed the nuke, just like for damage to ships, planes
and land units.

13 years agoAll-nuclear bombing run reported "bombing raid did 0 damage"
Markus Armbruster [Sun, 6 Jun 2010 15:42:03 +0000 (17:42 +0200)]
All-nuclear bombing run reported "bombing raid did 0 damage"

Broken in commit 162435e6, v4.3.26.

13 years agoClean up code to report nuclear damage to sectors
Markus Armbruster [Sun, 6 Jun 2010 15:35:36 +0000 (17:35 +0200)]
Clean up code to report nuclear damage to sectors

It was too clever by half.

13 years agoFix empty lines in bulletin reporting nuclear damage to sectors
Markus Armbruster [Sun, 6 Jun 2010 15:23:25 +0000 (17:23 +0200)]
Fix empty lines in bulletin reporting nuclear damage to sectors

Broken in Chainsaw 3.

13 years agoFix misdirected nuclear detonation output
Markus Armbruster [Sun, 6 Jun 2010 13:03:35 +0000 (15:03 +0200)]
Fix misdirected nuclear detonation output

Output went to the owner of the nuke instead of the player.
Fortunately, they're the same in normal usage.  They can differ only
when a deity drops a foreign nuke from a foreign plane.

The fix also cleans up a misuse of mpr() in kaboom(): it used multiple
calls to print a single line, which creates a separate bulletin for
each part.  The read command normally merges the bulletins, but if the
bulletins are more than five seconds apart (clock jumped somehow), we
get a bulletin header in the middle of a line.  Fortunately, that
could happen only when a deity drops a foreign nuke.  Before commit
a269cdd7 (v4.3.23), it could also happen for missions.

Broken in Empire 2.

13 years agoDrop get_land() parameter victim_land
Markus Armbruster [Mon, 24 May 2010 16:07:03 +0000 (18:07 +0200)]
Drop get_land() parameter victim_land

Use combat_mode instead.

13 years agoDrop prxy()'s parameter country
Markus Armbruster [Mon, 24 May 2010 07:05:51 +0000 (09:05 +0200)]
Drop prxy()'s parameter country

Argument is always player->cnum.  Hardly surprising, because that's
to whom it prints.

13 years agoClean up suspicious coordinate system use in unit_list()
Markus Armbruster [Mon, 24 May 2010 06:59:01 +0000 (08:59 +0200)]
Clean up suspicious coordinate system use in unit_list()

It showed unit coordinates in unit's coordinate system instead of the
player's.  Fortunately, they're the same, since even deities can't
navigate foreign ships or march foreign land units.

13 years agoFix misdirected prints when missile explodes on launch
Markus Armbruster [Sun, 16 May 2010 17:34:46 +0000 (19:34 +0200)]
Fix misdirected prints when missile explodes on launch

msl_launch() printed some lines to the player instead of the missile
owner when the missile exploded on launch.  They are different when
the launch is for a mission or an interception.  This disclosed the
the owner's origin.  Broken in Empire 2.

13 years agoClean up suspicious coordinate system use in lnd_mar()
Markus Armbruster [Sun, 16 May 2010 16:43:28 +0000 (18:43 +0200)]
Clean up suspicious coordinate system use in lnd_mar()

When refusing to march foreign land units, it reported the land unit's
location in the land unit's coordinate system instead of the player's.
Fortunately, they're the same, since even deities can't march foreign
land unit.

13 years agoFix autonav to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 11:52:14 +0000 (13:52 +0200)]
Fix autonav to use correct coordinate system

When autonav reported to a ship owner that it can't load or unload
foreign civilians, it used the sector owner's coordinate system.  This
disclosed the sector owner's origin.  Abusable.

13 years agoFix nuclear detontation to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 11:38:52 +0000 (13:38 +0200)]
Fix nuclear detontation to use correct coordinate system

When the nuke bounced off a sanctuary, the bulletin to the sanctuary
owner used the attacker's coordinate system.  This disclosed the
attacker's origin.

13 years agoFix sabotage command to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 09:12:29 +0000 (11:12 +0200)]
Fix sabotage command to use correct coordinate system

It reported the spy's location in the spy's coordinate system
instead of the player's.  Fortunately, they're the same in normal
usage.  They can differ only when a deity uses a foreign spy.

13 years agoFix sail command to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 09:10:45 +0000 (11:10 +0200)]
Fix sail command to use correct coordinate system

It reported the ship's location in the ship's coordinate system
instead of the player's.  Fortunately, they're the same in normal
usage.  They can differ only when a deity uses a foreign ship.

13 years agoFix lmine to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 09:07:04 +0000 (11:07 +0200)]
Fix lmine to use correct coordinate system

It reported the engineer's location in the engineer's coordinate
system instead of the player's.  Fortunately, they're the same in
normal usage.  They can differ only when a deity uses a foreign
engineer.

The buggy code is also reachable from and march sub-command 'd', but
can't bite there, because even deities can't march foreign land units.

13 years agoFix nation command to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 08:40:00 +0000 (10:40 +0200)]
Fix nation command to use correct coordinate system

It reported capital location in the nation's coordinate system instead
of the player's.  Fortunately, they're the same in normal usage.  They
can differ only when a deity requests a nation report for another
country.

13 years agoFix sweep command to use correct coordinate system
Markus Armbruster [Sun, 16 May 2010 18:18:14 +0000 (20:18 +0200)]
Fix sweep command to use correct coordinate system

When reporting sweeps, it reported the location in the plane owner's
coordinate system instead of the player's.  Fortunately, they're the
same in normal usage.  They can differ only when a deity flies foreign
planes.

13 years agoTidy up whitespace in macro replacement lists
Markus Armbruster [Sun, 23 May 2010 15:49:33 +0000 (17:49 +0200)]
Tidy up whitespace in macro replacement lists

13 years agoConvert tab after #define to space
Markus Armbruster [Sat, 22 May 2010 13:57:07 +0000 (15:57 +0200)]
Convert tab after #define to space