Commit graph

3834 commits

Author SHA1 Message Date
a94ae5f8c1 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.
2011-01-15 14:40:06 +01:00
c7d9d4fcf4 Fix nightly's check for existing sandbox
Broken in commit 70c03561, v4.3.12.
2011-01-15 14:40:06 +01:00
c77db95fad Clean up a useless use of cat 2011-01-15 14:40:06 +01:00
37589489c6 Fix make clean to remove info.ps
Missed in commit 9067d7a4.
2011-01-09 15:27:26 +01:00
217fe6dd16 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.
2011-01-09 15:27:26 +01:00
91302d36dd Remove unused plurize()
Unused since commit 44c36fa, v4.3.23.
2011-01-09 15:21:39 +01:00
13d236a1e0 Change ioq_dequeue() to return void
For symmetry with ioq_append().
2010-08-29 11:38:02 +02:00
2bb8923c6f 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.
2010-08-29 11:31:02 +02:00
d28fbbb186 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.
2010-07-25 18:24:00 +02:00
25115f4997 Document xundump() memory leak more clearly 2010-07-25 18:24:00 +02:00
a5c2a24db6 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.
2010-07-25 18:23:45 +02:00
ceee05eb7e 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
2010-07-25 17:48:54 +02:00
10736cd157 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.
2010-07-25 17:48:53 +02:00
8c78b1188b Clean up dead store in skyw()
Dead since commit 38befcb4.  Spotted by the Clang Static Analyzer.
2010-07-25 17:48:53 +02:00
765bf06ab2 Make disabled recursive supply in s_commod() compile again
Untested.  Broken in commit 98f24d5c, v4.3.20.
2010-07-25 17:48:53 +02:00
a8a68287bb Remove unused variables in disabled lnd_fort_interdiction() 2010-07-25 17:48:53 +02:00
5eb337e232 Clean up unobvious coordinate system use in doland()
Use the obviously correct newown instead of sect->sct_own.  They're
actually equal here.
2010-07-25 17:48:53 +02:00
f0da4769dc Clean up unobvious coordinate system use in detonate()
Use the obviously correct player->cnum instead of own.  They're
actually equal here.
2010-07-25 17:48:53 +02:00
efd3940322 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.
2010-07-25 17:48:53 +02:00
1fa06bd45f 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.
2010-07-25 17:48:53 +02:00
eea0dfd133 Factor rad_char() out of radmap() and rad_map_set()
Code was duplicated in commit 0d477e5d.
2010-07-25 17:47:30 +02:00
e41762ca49 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.
2010-07-25 17:45:14 +02:00
e49cb13480 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.
2010-07-25 17:40:52 +02:00
a65ee5e9b2 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.
2010-07-25 17:40:36 +02:00
0d477e5df1 Simplify automatic bmap update from ship radar
Inline radmap2() into radmapupd() and simplify.  Drop unused parameter
seesub.  Rename to rad_map_set().
2010-07-25 17:34:44 +02:00
27f22f36bb Remove radmapnopr(), use radmapupd() instead 2010-07-24 11:28:45 +02:00
db04ba4355 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().
2010-07-24 11:28:40 +02:00
3aca5a701a 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().
2010-07-24 11:28:33 +02:00
a207032625 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().
2010-07-24 11:28:33 +02:00
2960ac40db 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.
2010-07-24 11:28:33 +02:00
18ce536041 Use lnd_delete() in lnd_mess() 2010-07-24 11:28:32 +02:00
2c4826e420 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().
2010-07-24 11:28:32 +02:00
2ae4799beb Rename put_land() to put_oland() for clarity 2010-07-24 11:28:32 +02:00
1f080ef570 Split get_land() into get_oland() and get_dland() & simplify 2010-07-24 11:28:24 +02:00
8e4d898f01 put_land()'s function comment has drifted away, fix 2010-07-24 11:23:17 +02:00
0d8ee6ee6c Fix oops recovery in lnd_set_tech()
Broken in commit 0219bf08.
2010-07-18 09:28:50 +02:00
8c12432327 PR() and PRdate() are no longer used, remove them 2010-07-18 09:28:50 +02:00
dcd192f324 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.
2010-07-18 09:28:49 +02:00
73260a8a6d Factor ac_dog_report() out of ac_dog() 2010-07-18 09:26:57 +02:00
97d6c5262f 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.
2010-07-18 08:36:19 +02:00
aa5bb9790c Factor common plane damage code into ac_damage_plane()
Out of ac_planedamage() and pinflak_planedamage().
2010-07-18 08:36:19 +02:00
1a4fc50d57 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.
2010-07-18 08:34:45 +02:00
7defa55394 Suppress "no damage" after "takes 0" when reporting flak 2010-07-18 08:34:45 +02:00
5bb4846267 Clean up ac_planedamage() a bit
Reshuffle code for clarity, and delete a bogus comment.
2010-07-18 08:34:45 +02:00
22834d6793 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.
2010-07-18 08:34:45 +02:00
16b16e34b3 Move printing from ac_planedamage() into callers
It prints only if show is non-zero, so only ac_fireflak() is affected.
2010-07-18 08:34:45 +02:00
4007fc0f99 Streamline ac_planedamage()'s last argument
ac_planedamage() writes up to 14 characters.  Trim excessive buffers
in callers.  Guard against overrun in callee.
2010-07-18 08:34:45 +02:00
38ae0252b8 Simplify ac_planedamage() to write straight to mesg[] 2010-07-18 08:34:45 +02:00
d96202fc90 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.
2010-07-18 08:34:45 +02:00
5161953996 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.
2010-07-18 08:34:25 +02:00