(lndstr, natstr, shpstr): Fix string types from s_char[] to char[].
They were declared NSC_STRINGY in their selector descriptors, and
NSC_STRINGY is specified to represent char[].
(player): Get rid of s_char.
(babies): Factored out of grow_people(). Identical, except it doesn't
bother to `optimize' the maxpop case, and it drops the weird food
limit computation for opt_NOFOOD, which didn't limited for any
reasonable game parameters.
(natstr): Member nat_connected is inappropriate, because it is
transient server state, not persistent game state. Remove.
(player_main, edit): Remove uses.
(coun): Use getplayer() instead of nat_connected. Delete the message
on command being out of order.
(player_find_other): Replace by getplayer. player_find_other()
searches for a player other than US for country CNUM, which is in
state PS_PLAYING. Since there can be at most one player in state
PS_PLAYING, and no caller pass that player as US, they can simply use
getplayer() instead.
(getplayer): There may be multiple players for the same country in the
list of players, but at most one in state PS_PLAYING. getplayer()
used to get the one first in the list. However, its callers need the
one in state PS_PLAYING. In particular, typed_wu() notifies the
player obtained from getplayer(). If the player in state PS_PLAYING
isn't first, say because another one is trying to log in, the
notification gets lost. Fix by making getplayer() return the player
in state PS_PLAYING.
(getpath): Fix buffer overflow. Remote hole in commands bomb, drop,
fly, para, reco, sail, sweep. Old code also screwed up when
getstring() failed, unless player->aborted. Fixed code is still ugly
and cries for a rewrite.
(diridx): New. Use instead of chkdir() where direction characters
must be valid. Oopses on bad direction characters.
(pathtoxy, ac_encounter): Bad direction characters used to lead to bad
array subscript and potential disaster.
(pathrange, path): Stop on DIR_STOP as well as on bad direction
characters. This is just for consistency with other code; DIR_STOP
should occur only last in a path here.
(sail_nav_fleet, nav_ship): No change except for the oops.
Ron Koenderink [Sun, 21 Aug 2005 17:17:38 +0000 (17:17 +0000)]
(io_output_all,update_main,update_wait): Do not block on writing when
aborting commands for an update. Move update_pending to the start of
the update sequence where the commands are aborted.
(sorde): Output messed up for ships with sail path. Fix and
simplify. Remove inappropriate ship sanity check, should be done
elsewhere, and differently.
(qorde): Output messed up for ships with sail path. Fix and
simplify. Remove inappropriate ship sanity check, should be done
elsewhere, and differently.
(checksect, give_back_cap, guerrilla): No longer change capital to
agribusiness. That was done when the occupier abandons the old-owners
capital or it revolts, to prevent players from sacking the same
capital many timers. The server has a much better way to prevent that
since 4.2.7, so this weird hack is no longer useful. Thanks to Pat
Loney for pointing this out.
(player_init) [LISTENMAXCONN]: Comment seems to claim Linux doesn't
have SOMAXCONN, but has LISTENMAXCONN. In fact, it has SOMAXCONN, and
LISTENMAXCONN doesn't exist anywhere in /usr/include or the Internet.
Remove the special case.
[_DECTHREADS_] Drop support for DECthreads d4, a.k.a. DCE threads,
which are obsolete since at least 1997.
(empth_terminate, empth_wakeup) [__ppc__]: Ancient versions of OS X
lacked pthread_kill(). As a work-around, its use was disabled here
for all versions of OS X. The work-around could lead to hangs.
Remove it and drop support for ancient versions of OS X.
(empth_create) [__linux__]: Linux has supported thread attribute
stacksize for ages. Remove the special case.
Ron Koenderink [Sat, 23 Jul 2005 13:58:11 +0000 (13:58 +0000)]
Fix lrangeedit to lrange. Fix rangeedit to range. Fix attack to Attacking.
Add html links for info references. Remove inconsistent periods.
Add missing closing brackets. Change info to information to improve
readability. Improve the readability for range/lrange sentence.
Ron Koenderink [Sat, 23 Jul 2005 13:43:35 +0000 (13:43 +0000)]
(player_init) [_WIN32,__linux__ && __alpha__]: Remove the
SO_REUSEADDR socket option as it is not required for WIN32.
In WIN32, there is no waiting time when a port is closed before
it can be reused so SO_REUSEADDR is not required for WIN32.
Leave the option has a undesirable effect of allowing a second
server instance to start without an error and leaving both
instances running. ALPHA and LINUX do support SO_REUSEADDR.
Ron Koenderink [Sat, 23 Jul 2005 13:37:36 +0000 (13:37 +0000)]
(player_main): Add empth_yield() in the command processing loop to ensure
after every command, other players gets a chance to execute a command.
This prevents denial of service attack that monopolizing the active server
thread by continuing feeding data to the server from a client.
Ron Koenderink [Thu, 7 Jul 2005 21:57:15 +0000 (21:57 +0000)]
(show_sect_capab, mission_pln_equip, pln_equip): Change i_type
references to use I_NONE instead of zero. Zero has been invalid since
item.h rev. 1.12, and was questionable style before.
Ron Koenderink [Mon, 4 Jul 2005 14:07:31 +0000 (14:07 +0000)]
(pr_player, upr_player): Blocking I/O on another player's struct iop *
is unsafe! By the time the blocked thread wakes up, that player may
be gone, along with its struct iop *, and io_write() follows a
dangling pointer. Moreover, at most one thread may use empth_select()
on the same file descriptor. Violations of that restriction cause
threads to hang under Windows since ntthread.c rev. 1.15. Make all
output to another player non-blocking for now. Historically, player
threads sent output only to their socket, though their own iop. This
was broken by flash and asynchronous telegram notification a long time
ago.