]> git.pond.sub.org Git - empserver/log
empserver
12 years agoFix how play_cmd() ensures connection close
Markus Armbruster [Wed, 22 Feb 2012 13:30:58 +0000 (14:30 +0100)]
Fix how play_cmd() ensures connection close

play_cmd() needs to return in a state that makes player_login() break
the login command loop.

play_cmd() assumes player_main() always returns in such a state:
connection's EOF indicator set.  Unfortunately, the assumption is
wrong.  Fortunately, play_cmd() checks it, oopses and recovers.

player_main() can return with neiter error nor EOF indicator set,
e.g. when the game is down.

player_main() can return with just the error indicator set.  For
instance, when the client dies, io_input() detects ECONNRESET, sets
the error indicator and fails.

Broken in commit 8549efbc.  Fix by setting the EOF indicator silently
(without oopsing) when necessary.

12 years agoRestore amusing comment on naming of empmod.c
Markus Armbruster [Sat, 18 Feb 2012 19:57:42 +0000 (20:57 +0100)]
Restore amusing comment on naming of empmod.c

Got lost in 4.2.0.

12 years agoDrop C_MOD flag from commands that "obviously" don't need it
Markus Armbruster [Sat, 18 Feb 2012 17:09:34 +0000 (18:09 +0100)]
Drop C_MOD flag from commands that "obviously" don't need it

C_MOD prevents print functions from blocking.  The common reason for
wanting non-blocking prints are "read, print, write back" patterns.
There might be other reasons lurking in the code, and that's why
messing with C_MOD is scary.

Nevertheless, drop it from cutoff, headlines, land, lstat, motd,
neweff, payoff, qorder, sorder, and wall.  These commands have had
C_MOD "forever", even though they clearly don't modify game state.
They're all pretty simple.  Similar commands such as census, news,
ship, plane, nuke, sstat, pstat, flash never had C_MOD.

12 years agoNormalize command capability order in player_coms[] initializer
Markus Armbruster [Sat, 18 Feb 2012 16:14:37 +0000 (17:14 +0100)]
Normalize command capability order in player_coms[] initializer

No functional change.

12 years agoRevise money and capital command permissions
Markus Armbruster [Sat, 18 Feb 2012 15:49:53 +0000 (16:49 +0100)]
Revise money and capital command permissions

arm and disarm no longer require money, for consistency with the other
commands to move stuff around.

satellite no longer requires money, for consistency with lookout,
radar, sonar and skywatch.

qorder, sorder, survey and test no longer require a capital, for
consistency with the other commands that report on stuff the player
owns.

start and stop no longer require a capital, for consistency with the
other commands to control production.

fortify now requires a capital, for consistency with mission, morale
and range.

12 years agoRevise nation status command permissions
Markus Armbruster [Sat, 18 Feb 2012 15:19:59 +0000 (16:19 +0100)]
Revise nation status command permissions

Create new command capability NONVIS.  Give it to players in any state
except visitors (and STAT_UNUSED, but those must not exist).  This
makes it possible to have commands available to anyone but visitors.

Command change fails when the player is a visitor.  Simply make it
unavailable instead, by requiring NONVIS.

Make read unavailable to visitors, because it's useless: visitors
can't receive telegrams (typed_wu() fails).

Make census, commodity and sinfra unavailable to visitors.  Visitors
don't normally have sectors.

Make map and nmap unavailable to visitors.  Visitors don't have sectors,
so their maps are always empty.

Make them unavailable to new players (between add and newcap) and
players in sanctuary, too.  This is consistent with all the other
commands to examine the environment.  It also prevents people from
trying multiple unbroken countries in a blitz to find the one with the
nicest vicinity.

Make resource available to new players, for consistency with census
and commodity.

Make country, echo and financial available to anyone.

12 years agoClean up c_permit values of deity commands
Markus Armbruster [Sat, 18 Feb 2012 14:00:57 +0000 (15:00 +0100)]
Clean up c_permit values of deity commands

A player may execute a command when his player->nstat has all the bits
in the command's c_permit.

Normal player commands require bit(2).  Command break requires bit(1),
and execute requires bit(5).  Deity commands require both bit(2) and
bit(3).  Works, because deities always have both bits set in nstat, as
they may execute normal player commands, too.  But it's a bit
confusing.  Change them to only require their own bit(3).

12 years agoDrop useless nstat value VIS
Markus Armbruster [Sat, 18 Feb 2012 12:55:58 +0000 (13:55 +0100)]
Drop useless nstat value VIS

A player may execute a command when his player->nstat has all the bits
in the command's c_permit.

All commands require bit(0).  All players always have it.  Silly; get
rid of it.

12 years agoClean up info sect on highlighting
Markus Armbruster [Sat, 18 Feb 2012 11:52:49 +0000 (12:52 +0100)]
Clean up info sect on highlighting

Don't say selected sectors "show up in reverse video", that depends on
the client.  Just say "will be highlighted", like we do for the other
commands that highlight, e.g. info survey.

12 years agoread can print telegram without header after deletion prompt
Markus Armbruster [Sat, 18 Feb 2012 09:04:06 +0000 (10:04 +0100)]
read can print telegram without header after deletion prompt

rea() loops if more telegrams arrive while we wait for the player to
confirm deletion.  If the first new one is a continuation of the last
old one, its header is suppressed.  Don't do that.

Broken in commit 17223e8f, v4.3.29.

12 years agoFix 'm' in path argument of explore, move, transport
Markus Armbruster [Sat, 11 Feb 2012 08:51:46 +0000 (09:51 +0100)]
Fix 'm' in path argument of explore, move, transport

Two related bugs:

* It moans about deprecated argument syntax ('m' without a space
  before its argument) even when there's no argument.

* It uses the third instead of second argument for map flags (second
  argument is ignored): "m# s" doesn't show ships, and "m# s p" shows
  planes instead of ships.

Broken in commit 28d48474, v4.3.27.

12 years agoClarify buytax econfig doc string
Markus Armbruster [Sat, 11 Feb 2012 08:01:30 +0000 (09:01 +0100)]
Clarify buytax econfig doc string

Reported by Scott C. Zielinski.

12 years agoPolish the bulletin the seller gets after a unit sale
Markus Armbruster [Thu, 9 Feb 2012 18:40:26 +0000 (19:40 +0100)]
Polish the bulletin the seller gets after a unit sale

12 years agoMake market command unavailable to visitors, and set C_MOD flag
Markus Armbruster [Wed, 8 Feb 2012 18:11:12 +0000 (19:11 +0100)]
Make market command unavailable to visitors, and set C_MOD flag

The market command executes all trades that have become ready, by
calling check_market() and check_trade().  This modifies game state,
but market lacks C_MOD.  That's wrong.  But can it do harm?

Turns out yes.  check_trade() looks safe, but check_market() telexes
seller and buyer while holding a copy of the commodity struct.  If
this telexes the player who sent the market command, and he has
NF_INFORM on, the telegram notification may yield the processor.  It
then writes back its copy, triggering a generation oops.  Any updates
made by other threads meanwhile are wiped out, triggering a seqno
mismatch oops.

This can cause commodity trades to be executed multiple times,
multiplying the sold commodities.  Abuse seems tricky, but possible:
conspiring trade partners trade commodities back and forth to multiply
them.  One of them needs to get the output backlog just right to make
the telegram notification yield, and the timing right so that the
MarketUpdate thread or another player's buy, market, reset, sell, set
or trade command runs check_market() before his thread resumes.

Closely related bug: visitors can trigger execution of trades by means
of command market.  That's clearly inappropriate.

Broken in Empire 3.  Reported by Scott C. Zielinski.

12 years agoClarify what happens when the player aborts commands
Markus Armbruster [Tue, 7 Feb 2012 06:26:57 +0000 (07:26 +0100)]
Clarify what happens when the player aborts commands

12 years agoFix market not to expropriate sellers of units
Markus Armbruster [Sun, 5 Feb 2012 18:31:35 +0000 (19:31 +0100)]
Fix market not to expropriate sellers of units

When a ship, plane, land unit or nuke is sold, the seller is replaced
by POGO: POGO gets the money, the telegrams and makes the news.
Likewise when a sale fails because the buyer can't pay.

Broken in commit 94a3108b, v4.3.17.  Reported by Scott C. Zielinski.

12 years agoFix server shutdown to let player output drain properly
Markus Armbruster [Sun, 29 Jan 2012 11:06:30 +0000 (12:06 +0100)]
Fix server shutdown to let player output drain properly

Commit 1e1dfc86 (v4.3.23) attempted to do this, but it's flawed.

Server shutdown makes the player command loops terminate.  Each player
thread then flushes buffered output and closes the server's end of the
connection.  The client eventually gets EOF, and closes its end of the
connection.  All is well.

However, if the client sends more input after the server closed its
end of the connection, but before it completed receiving server
output, it gets ECONNRESET, and the remaining output is lost.

Instead of closing the server's end of the connection, we need to shut
down its transmission direction, then wait for the client to close its
end, by receiving client input until EOF.  Do that in io_close().

The output flushing in player_login() is now superfluous.  Remove it.

Make shutdwn() wait for the io_close() to complete instead of output
queues to drain.  Without that, we could still close the server's end
of the connection prematurely, through program termination.  Change
player_delete() to keep the player in Players until after io_close()
completes, so that shutdwn() can detect completion.

12 years agoClean up how quit and server shutdown trigger connection close
Markus Armbruster [Sun, 29 Jan 2012 09:44:28 +0000 (10:44 +0100)]
Clean up how quit and server shutdown trigger connection close

Simply set the player connection's EOF indicator.  Cleaner than
setting player->state to PS_SHUTDOWN from random places.

Move the assignment of PS_PLAYING from player_main() to its caller
play_cmd(), so that player->state is exclusively controlled in
login.c.

12 years agoFix login command quit to really quit
Markus Armbruster [Sun, 29 Jan 2012 09:34:47 +0000 (10:34 +0100)]
Fix login command quit to really quit

quit_cmd() calls io_shutdown() to make player_login()'s next command
read detect EOF.  io_shutdown() drains the input queue and shuts down
the socket with shutdown().  player_login()'s next io_gets() fails all
right, but then io_input() *can* read more from the socket on my Linux
box, at least when I send plenty of input fast.  Thus, we ignore
whatever input after quit was already queued, then resume reading
commands, not necessarily at the beginning of a line.

Fix by setting the EOF indicator instead.

12 years agoFix idle timeout during execute
Markus Armbruster [Sun, 29 Jan 2012 07:52:30 +0000 (08:52 +0100)]
Fix idle timeout during execute

Timeout during execute gets handled just like an EOF cookie: end the
batch file, resume reading normal commands.  That's wrong, we need to
close the connection.

A real EOF is recorded in the player's connection's EOF indicator.
Let's use that for all "connection needs to be closed" conditions, so
they all work the same.  Create io_set_eof() to provide access.

Make recvclient() set the player connection's EOF indicator on
timeout.  This makes the timeout "stick".  Record receipt of an EOF
cookie in new struct player member got_ctld.  Also abort the command,
as before.  This leaves further interpretation of the EOF cookie to
the command loops.

Make player_main() set the player connection's EOF indicator on
got_ctld.  Player connection gets closed on on EOF cookie, as before.

Change execute() to break the batch command loop when got_ctld is set,
then reset it.  Ends the batch file on EOF cookie, as before.

Change status() back to checking EOF and error indicators (partial
revert of commit 9c5854c8, v4.3.16), and drop struct player member
eof.

12 years agoMake execute yield the processor after every command
Markus Armbruster [Sun, 29 Jan 2012 07:41:54 +0000 (08:41 +0100)]
Make execute yield the processor after every command

A player sending execute script contents quickly could theoretically
get an unfair share of the server.  Missed in commit db6fd8da
(v4.2.22), which made only the normal command loop yield.

12 years agoSimplify recvclient() to return -1 for all failures
Markus Armbruster [Sat, 28 Jan 2012 16:49:20 +0000 (17:49 +0100)]
Simplify recvclient() to return -1 for all failures

Callers don't care.  Also fix some comments.

12 years agoDon't lose output when client shuts down input transmission
Markus Armbruster [Sat, 28 Jan 2012 15:48:08 +0000 (16:48 +0100)]
Don't lose output when client shuts down input transmission

player_login() skips sending C_EXIT and flushing server output when
io_eof() is true.  That's the case after a read from the socket
returned zero, which means the client has shut down transmission on
his socket, or closed it.  If it's the former, then dropping output
like that is bad.  Our client never does that, but others might.

Condition was introduced in Empire 2, don't know why.

12 years agoShow treasury status on EOF, quit, shutdown
Markus Armbruster [Sat, 28 Jan 2012 14:34:25 +0000 (15:34 +0100)]
Show treasury status on EOF, quit, shutdown

status() informs the player of non-trivial command costs and earnings,
and when he goes broke or becomes solvent.  However, this is skipped
when the command gets aborted by the player signalling EOF, or by
server shutdown, and after a quit command.

Fix by moving the check for EOF or shutdown down to the may_play_now()
check.

This looks a bit like it would also fix charging of play time.  But
that's not broken, because player_main() charges, too.

12 years agoFix client's command abort at beginning of first input line
Markus Armbruster [Thu, 26 Jan 2012 19:46:42 +0000 (20:46 +0100)]
Fix client's command abort at beginning of first input line

Commit 3cceb59b (v4.3.26) fixed the client to abort commands reliably
on ^C, even when it arrives at the beginning of an input line.  Except
it didn't work at the beginning of the first input line, because
input_eol was initialized to zero.

Easily fixed, but "end of line" isn't quite right there.  Revert sense
and rename to partial_line_sent.

12 years agoSimplify journal_entry_pr(), rename to journal_entry_write()
Markus Armbruster [Sat, 21 Jan 2012 15:48:53 +0000 (16:48 +0100)]
Simplify journal_entry_pr(), rename to journal_entry_write()

journal_entry_pr(S, N) writes up to N characters from zero-terminated
string S.  journal_input() passes -1 for N to write all characters.
Unclean.  SIZE_MAX would do, but it's C99, and MSC doesn't provide it.

Simplify journal_entry_pr() to write exactly N characters.  This makes
it more similar to write() than to pr(), therefore rename.

12 years agoPut home page URL into configure --help
Markus Armbruster [Sat, 21 Jan 2012 09:44:57 +0000 (10:44 +0100)]
Put home page URL into configure --help

12 years agoBump version to 4.3.30
Markus Armbruster [Sat, 21 Jan 2012 09:12:42 +0000 (10:12 +0100)]
Bump version to 4.3.30

12 years agoFinal change log polish for 4.3.29 v4.3.29
Markus Armbruster [Fri, 20 Jan 2012 19:21:37 +0000 (20:21 +0100)]
Final change log polish for 4.3.29

12 years agoUpdate change log for 4.3.29
Markus Armbruster [Sun, 15 Jan 2012 18:47:04 +0000 (19:47 +0100)]
Update change log for 4.3.29

12 years agodrop and fly from carrier can fail to load last civ or mil
Markus Armbruster [Sat, 26 Nov 2011 21:48:28 +0000 (22:48 +0100)]
drop and fly from carrier can fail to load last civ or mil

pln_equip() refuses to abandon its base sector.  Unfortunately, it
checks even when flying off carriers, and refuses to load the last
civilian or military depending on what happens to be in uninitialized
variable sect.

Broken in commit 91139692, v4.3.0.

12 years agoClean up journal_open() to open the journal write-only
Markus Armbruster [Sat, 26 Nov 2011 19:25:04 +0000 (20:25 +0100)]
Clean up journal_open() to open the journal write-only

We don't actually need update mode.

12 years agoClean up read to open telegram file read-only
Markus Armbruster [Sat, 26 Nov 2011 15:45:01 +0000 (16:45 +0100)]
Clean up read to open telegram file read-only

Update mode hasn't been necessary since 4.0.11 dropped use of
ftruncate().

12 years agoCheck for mailbox creation failure
Markus Armbruster [Sat, 26 Nov 2011 15:06:01 +0000 (16:06 +0100)]
Check for mailbox creation failure

Deity command add logs the failure, utility program files reports it
and exits unsuccessfully.  Before, this failure was silently ignored.

12 years agoFactor mailbox_create() out of nat_reset() and files.c
Markus Armbruster [Sat, 26 Nov 2011 15:01:51 +0000 (16:01 +0100)]
Factor mailbox_create() out of nat_reset() and files.c

12 years agoChange read and wire to never delete a corrupt mailbox
Markus Armbruster [Wed, 23 Nov 2011 19:24:51 +0000 (20:24 +0100)]
Change read and wire to never delete a corrupt mailbox

Before, rea() deleted the mailbox regardless of errors.  Acceptable
only when the user gets a chance to avoid that after the problem is
reported.  Not the case for "read y".

Not an issue for announcements, but treat them the same for
simplicity.

12 years agoClean up how read deals with new telegram arrivals
Markus Armbruster [Wed, 23 Nov 2011 18:56:24 +0000 (19:56 +0100)]
Clean up how read deals with new telegram arrivals

Fooling around with the file size is silly.  It works only because
read has flag C_MOD set, so they can only arrive while we're sitting
at the delete confirmation prompt, not during reading.

Simply try to read more telegrams instead.

12 years agoChange wire not to read more after confirming deletion
Markus Armbruster [Wed, 23 Nov 2011 06:34:19 +0000 (07:34 +0100)]
Change wire not to read more after confirming deletion

Telegram deletion deletes the mailbox.  If more telegrams arrive while
we wait for the player to confirm deletion, the mailbox again contains
unread telegrams, so we can't just delete it.  Instead, rea() loops to
read the new telegrams.

Announcements worked the same until Empire 3 put them in a single file
shared by all.  Since then, deleting announcements merely updates
nat_annotim, and there's no need to read new announcements after
getting the player's confirmation.  So don't.

12 years agoLimit telegram squashing to 5s total
Markus Armbruster [Mon, 21 Nov 2011 19:38:02 +0000 (20:38 +0100)]
Limit telegram squashing to 5s total

Before, only the time between adjacent telegrams was limited, not the
total time.

12 years agoDon't lie "You have a new telegram" after read with inform off
Markus Armbruster [Mon, 21 Nov 2011 19:07:48 +0000 (20:07 +0100)]
Don't lie "You have a new telegram" after read with inform off

Here's how telegram notification works with NF_INFORM off: typed_wu()
increments the telegram recipient's nat_tgms.  status(), running right
before command prompts, notifies the player when nat_tgms > 0, and
resets it.  Thus, we tell the player how many telegrams arrived since
the previous command prompt.

However, what we really want is something else, namely the number of
"new telegrams waiting".  That's what the notification message says,
after all.  Telegrams already printed by read shouldn't count, even
when they arrived since the previous command prompt.

Make them not count by clearing pending telegrams on read regardless
of toggle inform.

Same for announcements.

12 years agoFix telegram notifications during read (toggle inform on)
Markus Armbruster [Mon, 21 Nov 2011 19:05:45 +0000 (20:05 +0100)]
Fix telegram notifications during read (toggle inform on)

Reset number of pending telegrams before delete prompt instead of
after.

Before, the client claimed pending telegrams at that prompt, because
it wasn't C_INFORMed of the read, yet.  Worse, if more telegrams
arrived while sitting at the prompt, the reset clobbered their number
and sent a bogus clear C_INFORM message, effectively hiding the new
arrivals from the player.

12 years agoFix wire not to clear pending telegrams with toggle inform on
Markus Armbruster [Mon, 21 Nov 2011 06:26:02 +0000 (07:26 +0100)]
Fix wire not to clear pending telegrams with toggle inform on

Broken since Empire 2 introduced toggle inform.

12 years agoFix pending anno count for annos squashed together
Markus Armbruster [Mon, 21 Nov 2011 06:20:01 +0000 (07:20 +0100)]
Fix pending anno count for annos squashed together

Adjacent announcements are squashed together when the sender is the
same and the timestamp is "close enough".  Except typed_wu()
increments natstr member nat_ann regardless.  Fix that to work exactly
like nat_tgms.

12 years agoFix read not to split production report when update is slow
Markus Armbruster [Mon, 21 Nov 2011 06:26:02 +0000 (07:26 +0100)]
Fix read not to split production report when update is slow

Adjacent telegrams are squashed together if type and sender are the
same, and the timestamp is "close enough".  This is done in two
places: rea() and typed_wu().  They're inconsistent: typed_wu()
ignores the timestamp for production reports since Empire 2, but rea()
doesn't.

Record typed_wu()'s decision in new telstr member tel_cont.  Use it in
rea().

12 years agoSimplify how typed_wu() counts telegrams
Markus Armbruster [Sun, 20 Nov 2011 19:14:00 +0000 (20:14 +0100)]
Simplify how typed_wu() counts telegrams

typed_wu() counts telegrams to update nat_tgms and, since Empire 2,
send C_INFORM messages.  Adjacent telegrams are squashed together if
type and sender are the same, and the timestamp is within TEL_SECONDS.

typed_wu() increments nat_tgms when it sends a telegram that read
doesn't squash into the previous one.

Since Empire 2, it also sends a C_INFORM message then.  Inexplicably,
it fails to use the same condition: it tests just new_tele, not
new_tele || np->nat_tgms == 0.  C_INFORM messages got missed, until
4.0.18 made rea() call clear_telegram_is_new().  Convoluted.

Send C_INFORM exactly when incrementing nat_tgms, and back out
4.0.18's fix.

12 years agoFix clear_telegram_is_new() for TEL_NORM from POGO at the epoch
Markus Armbruster [Sun, 20 Nov 2011 18:26:20 +0000 (19:26 +0100)]
Fix clear_telegram_is_new() for TEL_NORM from POGO at the epoch

Purely theoretical, of course.

12 years agoClean up how telegram_is_new() detects production report
Markus Armbruster [Sun, 20 Nov 2011 18:11:04 +0000 (19:11 +0100)]
Clean up how telegram_is_new() detects production report

Test for TEL_UPDATE, not update_running.

12 years agoMove clear_telegram_is_new() call to beginning of update
Markus Armbruster [Sun, 20 Nov 2011 17:30:39 +0000 (18:30 +0100)]
Move clear_telegram_is_new() call to beginning of update

The call was added in 4.2.5 "so that the next telegram is flagged as
new and not part of the update".  Since the update sends only
TEL_UPDATE telegrams (the previous commit restored that property), and
nothing else does, the next telegram is flagged as new automatically,
except when it's from the next update.  Document that, and move the
call to a more natural place.

12 years agoEnsure the update's production report isn't split by bulletins
Markus Armbruster [Sun, 20 Nov 2011 17:26:43 +0000 (18:26 +0100)]
Ensure the update's production report isn't split by bulletins

During the update, wu() sends TEL_UPDATE telegrams ("Production
Report") instead of TEL_BULLETIN telegrams, but typed_wu() has no such
logic.  It's used by tele(), which doesn't run during the update, and
mpr(), which may, e.g. called from ship or mission code used by
autonav or sail.  This inserts bulletins in the middle of the
production report, splitting it apart.

Happens since mpr() was added in Empire 2.  Before, only tele() used
typed_wu() directly, and everything else wu().

Change mpr() to use wu().

12 years agoSaner error handling in typed_wu()
Markus Armbruster [Sun, 20 Nov 2011 14:14:36 +0000 (15:14 +0100)]
Saner error handling in typed_wu()

Leave nat_ann, nat_tgm alone and return -1 on all errors.  Before,
only failed open was handled that way.  Failed write and close were
logged and ignored.  While there, improve the log messages a bit.

Note: the return value fix has little effect.  It makes tele() log the
failure, which is redundant.  Everything else goes through wu() and
ignores the value.

12 years agoDrop superfluous fseek() from rea()
Markus Armbruster [Sun, 13 Nov 2011 18:04:07 +0000 (19:04 +0100)]
Drop superfluous fseek() from rea()

12 years agoMake add require confirmation for unadvisable actions
Markus Armbruster [Sun, 6 Nov 2011 18:40:21 +0000 (19:40 +0100)]
Make add require confirmation for unadvisable actions

Deleting a country in state STAT_SANCT, STAT_ACTIVE or STAT_GOD is
risky, because any references to this country become dangling, which
makes ef_verify() unhappy.  For a reason: we may well have code that
isn't prepared for dangling references, and breaks.

Replacing a country that is being used is risky, because it can get us
into weird states.  For instance, replacing a player by a visitor can
result in a visitor that owns stuff.

12 years agoMake add refuse to touch a country while it's being played
Markus Armbruster [Sun, 6 Nov 2011 18:13:59 +0000 (19:13 +0100)]
Make add refuse to touch a country while it's being played

I suspect player code could get terminally confused by country state
changing unexpectedly.  Not worth the risk.

12 years agoFix add not to crash on negative country number
Markus Armbruster [Sun, 6 Nov 2011 18:09:26 +0000 (19:09 +0100)]
Fix add not to crash on negative country number

12 years agoDon't bother giving POGO BTUs in files
Markus Armbruster [Sun, 6 Nov 2011 18:02:56 +0000 (19:02 +0100)]
Don't bother giving POGO BTUs in files

Deity's BTUs get reset to maximum on login anyway.

12 years agoCreate all deities with $123456789, not just POGO
Markus Armbruster [Sun, 6 Nov 2011 13:00:54 +0000 (14:00 +0100)]
Create all deities with $123456789, not just POGO

12 years agoMove setting nat_cnam, nat_pnam into nat_reset()
Markus Armbruster [Sun, 6 Nov 2011 12:56:34 +0000 (13:56 +0100)]
Move setting nat_cnam, nat_pnam into nat_reset()

12 years agoUse nat_reset() for POGO in files.c
Markus Armbruster [Sun, 6 Nov 2011 12:30:14 +0000 (13:30 +0100)]
Use nat_reset() for POGO in files.c

Requires moving it from subs/natsub.c to common/nat.c.

12 years agoMake files set the usual nation flags for POGO
Markus Armbruster [Sun, 6 Nov 2011 09:28:54 +0000 (10:28 +0100)]
Make files set the usual nation flags for POGO

The add command sets nation flags NF_FLASH, NF_BEEP, NF_COASTWATCH,
NF_SONAR, and since 4.2.6 NF_TECHLISTS.  POGO is created by the files
utility, which sets only NF_FLASH (since 4.2.2).  Change files to
match add.

12 years agonat_reset() is no longer used with STAT_SANCT, simplify
Markus Armbruster [Sun, 6 Nov 2011 09:17:09 +0000 (10:17 +0100)]
nat_reset() is no longer used with STAT_SANCT, simplify

12 years agoChange newcap back to not wiping the country
Markus Armbruster [Sat, 5 Nov 2011 15:57:56 +0000 (16:57 +0100)]
Change newcap back to not wiping the country

Just create sanctuaries, put country into STAT_SANCT, grant BTUs and
money, set origin and initial realms.

This reverts commit e1a68c72 (v4.3.12) as far as newcap is concerned.
Except we still set nat_access, because that needs to be set along
with nat_btu.

Additionally, leave levels and telegrams alone.

Should have no effect in practice, because newcap works only in
STAT_NEW, and we get there with the add command, which wipes the
country.

12 years agoMake add always reset the country
Markus Armbruster [Sun, 30 Oct 2011 17:46:24 +0000 (18:46 +0100)]
Make add always reset the country

Before, add reset the country only when adding a player or a visitor.
When adding a deity or deleting a country, it set just nat_cnam,
nat_pnam and nat_state.  Has always been that way.

Because of that, a newly minted deity country could inherit all kinds
of crap from a previous user of its country number: origin, realms,
relations, telegrams, ...  Harmless if the country number has never
been used before, which is how add is generally used.

When adding a deity country, initial levels (start_education, ...) now
apply, relations start NEUTRAL instead of AT_WAR, and the usual
initial nation flags are set.

Reset on delete as well, just to get rid of the special case.

12 years agoRename add argument "new" to "player"
Markus Armbruster [Sun, 30 Oct 2011 15:29:32 +0000 (16:29 +0100)]
Rename add argument "new" to "player"

This makes the correct choice for player countries obvious.  Keep
recognizing "new" for now, but deprecate it.

12 years agoDrop add argument "active"
Markus Armbruster [Sun, 30 Oct 2011 15:11:02 +0000 (16:11 +0100)]
Drop add argument "active"

Argument "active" is obscure.  It creates a country in STAT_ACTIVE
that doesn't have a capital, and has its origin at the true origin.
If you really want such a country, create it in STAT_NEW normally,
then use edit to go to STAT_ACTIVE.

12 years agoDrop add's obscure sector check and wipe functionality
Markus Armbruster [Sun, 30 Oct 2011 14:51:46 +0000 (15:51 +0100)]
Drop add's obscure sector check and wipe functionality

If you really need to wipe out a country, there's much more to wipe
than just sectors.

12 years agoDrop add's undocumented land unit destruction feature
Markus Armbruster [Sun, 30 Oct 2011 14:46:42 +0000 (15:46 +0100)]
Drop add's undocumented land unit destruction feature

It doesn't destroy ships, planes or nukes, either.

12 years agoPermit no-op country name change again
Markus Armbruster [Sun, 30 Oct 2011 14:43:56 +0000 (15:43 +0100)]
Permit no-op country name change again

Commit aa5861d1 (v4.3.20) made add, edit and change reject a country
name that is already in use.  Even if it's used by the same country.
Relax that.

12 years agoImprove newcap's origin error message
Markus Armbruster [Sun, 30 Oct 2011 07:17:58 +0000 (08:17 +0100)]
Improve newcap's origin error message

12 years agoStreamline a few files error messages
Markus Armbruster [Sat, 29 Oct 2011 19:06:36 +0000 (21:06 +0200)]
Streamline a few files error messages

Write one nice line to stderr instead of a cryptic one to stderr, and
an uninformative one to stdout.

12 years agoFix files and fairland to report ef_open() failure just once
Markus Armbruster [Sat, 29 Oct 2011 18:52:33 +0000 (20:52 +0200)]
Fix files and fairland to report ef_open() failure just once

ef_open() already reports failure since commit 7eb2fe57, v4.2.20.
Drop the second report from its callers.

12 years agoReplace exit(-1) by exit(1)
Markus Armbruster [Sat, 29 Oct 2011 18:25:01 +0000 (20:25 +0200)]
Replace exit(-1) by exit(1)

exit() uses only the least significant byte of its argument.

12 years agoMake allocate_memory() return void
Markus Armbruster [Sat, 29 Oct 2011 18:19:06 +0000 (20:19 +0200)]
Make allocate_memory() return void

It can't fail since commit ba1a320c, v4.3.15.

12 years agoGuard against unusable fd in pthreads' empth_select()
Markus Armbruster [Sat, 29 Oct 2011 15:16:08 +0000 (17:16 +0200)]
Guard against unusable fd in pthreads' empth_select()

0 <= fd < FD_SETSIZE must hold, or else undefined behavior in
FD_SET().

12 years agoFix lwpSleepFd()'s guard against unusable fd
Markus Armbruster [Sat, 29 Oct 2011 15:11:18 +0000 (17:11 +0200)]
Fix lwpSleepFd()'s guard against unusable fd

0 <= fd < FD_SETSIZE must hold, or else undefined behavior in FD_SET()
and buffer overrun in LwpFdwait[fd].  Check of upper bound off by one,
check of lower bound missing.

12 years agoPlug FILE leak on show_first_tel() error paths
Markus Armbruster [Sat, 29 Oct 2011 13:35:43 +0000 (15:35 +0200)]
Plug FILE leak on show_first_tel() error paths

Leak introduced in commit 4238323d, v4.3.20.  Unlikely to bite in
practice, as only corrupt mailbox files can cause these errors.

12 years agoPlug memory leak in set_paths() error path
Markus Armbruster [Sat, 29 Oct 2011 13:14:39 +0000 (15:14 +0200)]
Plug memory leak in set_paths() error path

Leak appeared in commit 91eefc3f, v4.3.12.  Harmless in practice,
since the error is ultimately fatal.

12 years agoFix read_schedule() not to fclose(stdin)
Markus Armbruster [Sat, 29 Oct 2011 12:51:37 +0000 (14:51 +0200)]
Fix read_schedule() not to fclose(stdin)

Did that since the initial commit 71320ed6, v4.3.10.

12 years agoPlug FILE leak on read_schedule() parse error path
Markus Armbruster [Sat, 29 Oct 2011 12:47:02 +0000 (14:47 +0200)]
Plug FILE leak on read_schedule() parse error path

Leak introduced in initial commit 71320ed6, v4.3.10.

12 years agoPlug memory leak in verify_row()
Markus Armbruster [Wed, 26 Oct 2011 19:12:19 +0000 (21:12 +0200)]
Plug memory leak in verify_row()

Leak introduced in commit b30c83cd, v4.3.28.

12 years agoMake play show no last command when there hasn't been one
Markus Armbruster [Wed, 26 Oct 2011 18:00:00 +0000 (20:00 +0200)]
Make play show no last command when there hasn't been one

Before, it printed NULL, which isn't helpful.

12 years agoRemove unreachable code in sell()
Markus Armbruster [Wed, 26 Oct 2011 17:42:37 +0000 (19:42 +0200)]
Remove unreachable code in sell()

sell used to search multiple sectors for sellable commodities, keeping
tally in totalcom.  It failed with message "No eligible" when none
could be found.

sell's second argument got changed to a single sector in Empire 3.  If
the sector can't sell, we return early.  Else, totalcom is positive.
Thus, the "No eligible" code is unreachable.  Remove it.

12 years agoFix info sell on second argument
Markus Armbruster [Wed, 26 Oct 2011 17:34:16 +0000 (19:34 +0200)]
Fix info sell on second argument

Empire 3 changed it to a single sector, but neglected to update info.

12 years agoMake scripts/savecore create the core directory
Markus Armbruster [Wed, 26 Oct 2011 16:55:27 +0000 (18:55 +0200)]
Make scripts/savecore create the core directory

12 years agoRename tgz to arc in scripts/backup
Markus Armbruster [Wed, 26 Oct 2011 16:53:24 +0000 (18:53 +0200)]
Rename tgz to arc in scripts/backup

tgz looks silly when you hack the script to use something other than
tar+gzip.

12 years agoFix empire(6) synopsis for argument of -s
Markus Armbruster [Wed, 26 Oct 2011 16:49:55 +0000 (18:49 +0200)]
Fix empire(6) synopsis for argument of -s

Commit 464094a6 (v4.3.26) changed it in section description, but
missed section synopsis.

12 years agoFix use-after-free when plane is downed or aborted in dogfight
Markus Armbruster [Sun, 9 Oct 2011 16:40:11 +0000 (18:40 +0200)]
Fix use-after-free when plane is downed or aborted in dogfight

ac_dog() passed ap and dp to ac_dog_report() after ac_planedamage()
freed it.  Broken in commit 73260a8a, v4.3.27.  Diagnosed with
valgrind.

12 years agoBump version to 4.3.29
Markus Armbruster [Wed, 3 Aug 2011 18:36:28 +0000 (20:36 +0200)]
Bump version to 4.3.29

12 years agoClean up omit_ids() not to set an extra element in idgap[] v4.3.28
Markus Armbruster [Sat, 16 Jul 2011 13:30:10 +0000 (15:30 +0200)]
Clean up omit_ids() not to set an extra element in idgap[]

12 years agoUpdate change log for 4.3.28
Markus Armbruster [Sat, 16 Jul 2011 11:34:22 +0000 (13:34 +0200)]
Update change log for 4.3.28

12 years agoDon't let POGO (#0) navigate and march ghosts
Markus Armbruster [Sat, 16 Jul 2011 11:06:17 +0000 (13:06 +0200)]
Don't let POGO (#0) navigate and march ghosts

POGO can navigate dead ships, and march dead land units.  The ghosts
even get sighted and interdicted, and can hit mines (landmines only
until commit fe372539, v4.3.27).  Noted for ships in commit 9100af0b.
Has always been broken.  Fix by making shp_sel() and lnd_sel()
explicitly reject ghosts.

Same code pattern also exists in pln_sel, but dead plains fail the
efficiency test, so it's harmless there.  Apply the same fix anyway.

12 years agoMake llook ignore land units and planes loaded on land units
Markus Armbruster [Sat, 16 Jul 2011 09:47:52 +0000 (11:47 +0200)]
Make llook ignore land units and planes loaded on land units

Probably overlooked when trains were added in 4.0.0.

12 years agoFix "sector can board" test to ignore land units on land units
Markus Armbruster [Sat, 16 Jul 2011 09:38:50 +0000 (11:38 +0200)]
Fix "sector can board" test to ignore land units on land units

boar() lets a sector board if it has mobility or usable land units.
Embarked land units are not usable.  But it tests only "on ship", not
"on land unit".  Broken in 4.0.17.

12 years agoFix transport to reject planes loaded on land units
Markus Armbruster [Sat, 16 Jul 2011 07:10:46 +0000 (09:10 +0200)]
Fix transport to reject planes loaded on land units

The transported plane remains on its carrier.  When the land unit
moves, the plane is teleported right back to it.  Broken since
Chainsaw 3 added land units.

While there, improve the message for planes on ships.

12 years agoFix lradar to reject land units loaded on land units
Markus Armbruster [Wed, 13 Jul 2011 20:47:05 +0000 (22:47 +0200)]
Fix lradar to reject land units loaded on land units

Probably overlooked when trains were added in 4.0.0.

While there, improve the message for land units on ships.

12 years agoFix strength to ignore land units loaded on land units
Markus Armbruster [Wed, 13 Jul 2011 18:37:41 +0000 (20:37 +0200)]
Fix strength to ignore land units loaded on land units

They can't defend their sector, see get_dlist().

Missed when 4.2.0 made them not defend the sector.

12 years agoFix navigate and march to find paths longer than 7 sectors again
Markus Armbruster [Tue, 12 Jul 2011 05:11:31 +0000 (07:11 +0200)]
Fix navigate and march to find paths longer than 7 sectors again

Broken in commit 8f008bf8, v4.3.27.  How embarrassing...

12 years agoMake march sub-command 'i' show military, #land units loaded
Markus Armbruster [Sun, 10 Jul 2011 18:57:01 +0000 (20:57 +0200)]
Make march sub-command 'i' show military, #land units loaded

12 years agoUpdate doc/debugging for recent commit a9611a57
Markus Armbruster [Sun, 10 Jul 2011 18:36:00 +0000 (20:36 +0200)]
Update doc/debugging for recent commit a9611a57

12 years agoNew server option -F to force start even when state looks bad
Markus Armbruster [Sun, 10 Jul 2011 15:53:31 +0000 (17:53 +0200)]
New server option -F to force start even when state looks bad

Risks crashes and further corruption, but gives deities a chance to
fix up a bad game state with edit commands and such.

12 years agoGive init_server() internal linkage
Markus Armbruster [Sun, 10 Jul 2011 15:41:53 +0000 (17:41 +0200)]
Give init_server() internal linkage