]> git.pond.sub.org Git - empserver/log
empserver
15 years agoRewrite the broken code to move cargo with its carrier
Markus Armbruster [Fri, 12 Sep 2008 23:31:48 +0000 (19:31 -0400)]
Rewrite the broken code to move cargo with its carrier

The old code did not move a carrier's cargo (planes, land units,
nukes) when the carrier moved.  Instead, it fixed up the location in
the postread callback.  Anything not going through ef_read(), in
particular the update, saw it in its old, incorrect location, until a
fixed up copy got written back.

Moreover, the timestamp did not change when cargo moved, so
incremental dumps did not pick up the movement.

The new code moves the cargo along with the carrier.

New unit_update_cargo() moves or destroys a carrier's cargo (planes,
land units, nukes) along with the carrier.  Call it from
shp_prewrite(), pln_prewrite() and lnd_prewrite() when the carrier
moves or gets destroyed.

Remove the code to destroy cargo from shp_prewrite(), pln_prewrite(),
lnd_prewrite().

Remove the code to fix up cargo location from pln_postread(),
lnd_postread(), nuk_postread().

This changes the message for ship and land unit cargo getting
destroyed from "sunk" and "MIA" to "lost".

15 years agoMake the item iterator capable of iterating over a cargo list
Markus Armbruster [Fri, 12 Sep 2008 22:46:54 +0000 (18:46 -0400)]
Make the item iterator capable of iterating over a cargo list

New snxtitem_cargo() initializes an iterator for a cargo list, with
new enum ns_seltype member NS_GROUP and new struct nstr_item member
next.  Extend nxtitem() and nxtitemp() to step through the list.

15 years agoClean up struct nstr_sect and struct nstr_item a bit
Markus Armbruster [Fri, 12 Sep 2008 22:41:55 +0000 (18:41 -0400)]
Clean up struct nstr_sect and struct nstr_item a bit

Members read were always set to ef_read, remove and call directly.

Member flag was only assigned to, never used, remove.

Change member group to char to match struct empobj.

15 years agoZap next uid in clink_rem(), check it in clink_add()
Markus Armbruster [Fri, 12 Sep 2008 02:10:14 +0000 (22:10 -0400)]
Zap next uid in clink_rem(), check it in clink_add()

The former ensures that next links are valid even for uids not on any
list.  The latter oopses on adding an uid to a list when it is already
on a list, unless it is at the tail.

15 years agoExpire lost items at the update instead of continuously
Markus Armbruster [Wed, 10 Sep 2008 11:30:48 +0000 (07:30 -0400)]
Expire lost items at the update instead of continuously

Replace thread DeleteItems running delete_lostitems() by simple
function delete_old_lostitems(), and call it from update_main().

15 years agoReplace econfig key lost_items_timeout by lost_keep_hours
Markus Armbruster [Wed, 10 Sep 2008 11:23:46 +0000 (07:23 -0400)]
Replace econfig key lost_items_timeout by lost_keep_hours

15 years agoFix commit d46b0b72 (didn't even compile with pthreads)
Markus Armbruster [Fri, 12 Sep 2008 22:05:25 +0000 (18:05 -0400)]
Fix commit d46b0b72 (didn't even compile with pthreads)

15 years agoFix journal_entry() to separate thread and event by space
Markus Armbruster [Fri, 12 Sep 2008 21:52:40 +0000 (17:52 -0400)]
Fix journal_entry() to separate thread and event by space

Broken in commit effc1b18.

15 years agoAdd missing error check for thread creation for WIN32
Ron Koenderink [Fri, 12 Sep 2008 01:14:35 +0000 (19:14 -0600)]
Add missing error check for thread creation for WIN32

_beginthread() call in empth_create() has two error
return values 0L and 1L.  Add the missing check for 0L.

15 years agoEnsure the empth_sleep() always yields for WIN32
Ron Koenderink [Fri, 12 Sep 2008 01:06:10 +0000 (19:06 -0600)]
Ensure the empth_sleep() always yields for WIN32

The WIN32 version did not block when the sleep was
already reached by the time empth_sleep() did the
time remaining calculation.  The other versions
of empth_sleep() do always yield.

15 years agoMake empth_name() and empth_set_name() take a thread argument
Markus Armbruster [Thu, 11 Sep 2008 23:25:34 +0000 (19:25 -0400)]
Make empth_name() and empth_set_name() take a thread argument

15 years agoUse empty schedule file for the nightly build
Ron Koenderink [Thu, 11 Sep 2008 20:58:32 +0000 (14:58 -0600)]
Use empty schedule file for the nightly build

This ensures that no unplanned updates occur
during the nightly build sequence.  Remove
unnecesary enables and disables from the script.
Remove unnecessary argument for force command.

15 years agoChange the thread name in play_cmd() to show country number
Ron Koenderink [Thu, 11 Sep 2008 20:50:08 +0000 (14:50 -0600)]
Change the thread name in play_cmd() to show country number

This makes the journal easier to read.  We can't use the country
number earlier, because it is not unique then.

15 years agoUse the thread name to identify threads in the journal
Ron Koenderink [Thu, 11 Sep 2008 20:49:28 +0000 (14:49 -0600)]
Use the thread name to identify threads in the journal

This makes the journal easier to read, and makes journals
from the nightly build easier to diff.

Since we use only the 10 first characters of the name,
abridge existing thread names to make them unique within
that many characters.

15 years agoNew empth_name() and empth_set_name()
Ron Koenderink [Thu, 11 Sep 2008 20:46:31 +0000 (14:46 -0600)]
New empth_name() and empth_set_name()

15 years agoRemove bogus comment from empthread.h
Markus Armbruster [Thu, 11 Sep 2008 11:51:03 +0000 (07:51 -0400)]
Remove bogus comment from empthread.h

Became bogus in commit d500a707.

15 years agoFix double free() in unit_onresize()
Markus Armbruster [Thu, 11 Sep 2008 11:50:18 +0000 (07:50 -0400)]
Fix double free() in unit_onresize()

Introduced in commit 64a53c90.

15 years agoSimplify tests for presence of load
Markus Armbruster [Mon, 8 Sep 2008 00:37:52 +0000 (20:37 -0400)]
Simplify tests for presence of load

Instead of counting the load with lnd_nland() / lnd_nxlight(), check
whether there's at least one loaded with lnd_first_on_land() /
pln_first_on_land().

15 years agoGet rid of ship and land unit load counters
Markus Armbruster [Sun, 7 Sep 2008 15:10:53 +0000 (11:10 -0400)]
Get rid of ship and land unit load counters

Load counters are redundant; they can be computed from the carrier
uids.  Keeping them up-to-date as the carriers change is a pain, and
we never got that quite complete.

Computing load counters straight from the carrier uids every time we
need them would be rather inefficient, but computing them from cargo
lists is not.  So do that.

Remove the load counters: struct shpstr members shp_nplane,
shp_nchoppers, shp_nxlight, shp_nland, and struct lndstr members
lnd_nxlight and lnd_nland.

Don't compute/update load counters in build_ship(), build_land(),
land(), ldump(), load_plane_ship(), load_land_ship(),
load_plane_land(), load_land_land(), lstat(), sdump(), shi(), sstat(),
tend_land(), check_trade(), put_combat(), pln_oneway_to_carrier_ok),
pln_newlanding(), fit_plane_on_ship(), fit_plane_on_land(),
unit_list().

Nothing left in fit_plane_off_ship(), fit_plane_off_land(), so remove
them.

load_land_ship(), load_land_land(), check_trade(), pln_newlanding(),
put_plane_on_ship(), take_plane_off_ship(), put_plane_on_land(),
take_plane_off_land() no longer change the carrier, so don't put it.

Remove functions to recompute the load counters from carrier uids:
count_units(), lnd_count_units(), count_planes(), count_land_planes(),
pln_fixup() and lnd_fixup(), along with the latter two's private
copies of fit_plane_on_ship() and fit_plane_on_land().

New cargo list functions to compute load counts: unit_cargo_count()
and unit_nplane(), with convenience wrappers shp_nplane(),
shp_nland(), lnd_nxlight(), lnd_nland().

Use them to make ship selectors nplane, nchoppers, nxlight, nland
virtual.  They now reflect what is loaded, not how the load uses the
available slots.  This makes a difference when x-light planes or
choppers use plane slots.

Use them to make land unit selectors nxlight and nland virtual.

Use them to get load counts in land(), ldump(), load_plane_ship(),
load_land_ship(), load_plane_land(), load_land_land(), sdump(), shi(),
tend_land(), fit_plane_on_land(), trade_desc(), unit_list().

Rewrite fit_plane_on_ship() and could_be_on_ship() to use
shp_nplane().  could_be_on_ship() now takes load count arguments, as
computed by shp_nplane(), so it can be used for checking against an
existing load as well.

15 years agoGet rid of struct plnstr member pln_nuktype
Markus Armbruster [Sun, 7 Sep 2008 02:15:41 +0000 (22:15 -0400)]
Get rid of struct plnstr member pln_nuktype

pln_nuktype is redundant; it can be computed from the nuke's
nuk_plane.

Make plane selector nuketype virtual and NSC_EXTRA.  It should have
been NSC_EXTRA all along.  This changes xdump plane.

Don't set it in arm(), disarm(), build_plane(), pln_damage() and
nuk_fixup().  The latter no longer does anything, remove it.

Deprecate edit key 'n' in doplane(), and don't show it in pr_plane().
The key never made much sense.

eff_bomb(), comm_bomb(), ship_bomb(), plane_bomb(), land_bomb(),
strat_bomb(), mission_pln_equip(), air_damage(), msl_hit(),
pln_equip() tested pln_nuketype to check whether a plane carries a
nuke.  Test nuk_on_plane() instead.

pdump(), plan(), trade_desc() print whether and what kind of nuke a
plane carries.  Adapt that to use nuk_on_plane().

15 years agoEnable the new nuk_on_plane(), replacing the old one
Markus Armbruster [Sat, 6 Sep 2008 23:22:56 +0000 (19:22 -0400)]
Enable the new nuk_on_plane(), replacing the old one

Callers changed, as the new one isn't a drop-in replacements.

15 years agoCargo lists storing lists of cargo for each carrier
Markus Armbruster [Sat, 6 Sep 2008 22:40:58 +0000 (18:40 -0400)]
Cargo lists storing lists of cargo for each carrier

Persistent game state encodes "who carries what" by storing the
carrier uid in the cargo.  Cargo lists augment that: they store lists
of cargo for each carrier.  They are not persistent.

New unit_cargo_init() to compute the cargo lists from game state.
Call it in ef_init_srv() and at the end of update_main().

New unit_onresize() to resize the cargo list data structure.
Installed as units' struct empfile callback onresize to make them
resize automatically with the unit files.

New unit_carrier_change() to update cargo lists when carriers change
in game state.  Convenience wrappers pln_carrier_change(),
lnd_carrier_change() and nuk_carrier_change().  Call them from
prewrite callbacks to keep cargo lists in sync with game state.

To make that work, unused units must not point to a carrier.  Add new
pln_oninit(), lnd_oninit() and nuk_oninit() take care of newly created
units.  Change lnd_prewrite() and nuk_prewrite() to take dead land
units and nukes off their carrier.  pln_prewrite() did that already.

New unit_cargo_first(), unit_cargo_next() to traverse cargo lists.
Convenience wrappers lnd_first_on_ship(), lnd_first_on_land(),
lnd_next_on_unit(), pln_first_on_ship(), pln_first_on_land(),
pln_next_on_unit() and nuk_on_plane().  The latter is disabled for now
because it clashes with an existing function.

15 years agoNew struct empfile callback onresize
Markus Armbruster [Sat, 6 Sep 2008 17:58:15 +0000 (13:58 -0400)]
New struct empfile callback onresize

15 years agoRevive struct empfile callback init as oninit
Markus Armbruster [Sun, 7 Sep 2008 15:27:18 +0000 (11:27 -0400)]
Revive struct empfile callback init as oninit

Commit a71f0158 removed unused callback init.  Bring it back renamed
to oninit, and without the redundant first argument.

15 years agoFix up filetable.c's file comment after rename.
Markus Armbruster [Sat, 6 Sep 2008 17:56:25 +0000 (13:56 -0400)]
Fix up filetable.c's file comment after rename.

15 years agoMove selector code from src/lib/global to src/lib/common
Markus Armbruster [Sat, 6 Sep 2008 17:56:08 +0000 (13:56 -0400)]
Move selector code from src/lib/global to src/lib/common

Future virtual selectors will need to access game state.  This depends
on common/file.c, which can't be used from global without creating a
cyclic dependency between libglobal.a and libcommon.a.

Move nsc.c to src/lib/common.  file.c depends on it, so move it as
well, renamed to filetable.c so it doesn't clash with the existing
file.c.

15 years agoNew lost_and_found() to record ownership changes.
Markus Armbruster [Sat, 6 Sep 2008 15:48:49 +0000 (11:48 -0400)]
New lost_and_found() to record ownership changes.

Factors out the common makelost()/makenotlost() pattern.

15 years agoUpdate lost file from prewrite callbacks
Markus Armbruster [Sat, 6 Sep 2008 15:21:32 +0000 (11:21 -0400)]
Update lost file from prewrite callbacks

Losses of sectors, ships, planes, land units and nukes are tracked in
the lost file.  To keep it current, makelost() and makenotlost() were
called whenever one of these changed owners.  Cumbersome and
error-prone.  In fact, the lost file was never perfectly accurate.

Detect the ownership change in the prewrite callback and call
makelost() / makenotlost() from there.  Remove lost file updates from
where they're no longer needed: right before a put.  takeover() is a
bit more involved: it doesn't put the sectors, but all callers do,
except for guerrilla().  So remove the lost file update from
takeover(), but add it to guerrilla().

This takes care of lost file update for all ownership changes that go
through ef_write().  It can't take care of any missing updates for
changes that don't go through it.

15 years agoPass old element to empfile callback prewrite()
Markus Armbruster [Sat, 6 Sep 2008 13:15:18 +0000 (09:15 -0400)]
Pass old element to empfile callback prewrite()

Change sct_prewrite(), shp_prewrite(), pln_prewrite(), lnd_prewrite(),
nuk_prewrite() accordingly.  New argument isn't used for anything,
yet.

15 years agoFix comments added in commit bf436a44.
Markus Armbruster [Sat, 6 Sep 2008 12:55:45 +0000 (08:55 -0400)]
Fix comments added in commit bf436a44.

15 years agoRemove bogus correction of sct_mobil from sct_prewrite()
Markus Armbruster [Sat, 6 Sep 2008 12:09:59 +0000 (08:09 -0400)]
Remove bogus correction of sct_mobil from sct_prewrite()

It used literal 127 instead of sect_mob_max, it didn't check the lower
bound, and it didn't report the corruption.  From Chainsaw 3.

Having *working* sanity checks there would be nice.  Left for another
day.

15 years agoDon't execute pre-write checks from sct_postread()
Markus Armbruster [Sat, 6 Sep 2008 12:03:08 +0000 (08:03 -0400)]
Don't execute pre-write checks from sct_postread()

Chainsaw 3 factored out most checks from sct_prewrite() into
checksect(), and called that from sct_postread() as well.  Revert
this, because it was a bad idea: whenever checksect() called from
ef_read() found something to change, it was actually a bug, and
changing it just hid the bug from whatever called ef_read().  But it
couldn't hide it from code going through ef_ptr().  So, instead of
having bugs visible everywhere, including census and such, they were
hidden in hard to observe places.  For instance, the previous commit
fixed one that was visible to the path finder, but not the actual path
user, which led to the path user choking on an incorrect path in a
rather obscure manner.

Things no longer "corrected" on read: excessive mobility, low work
despite no civilians present, sector owned despite neither civilians,
military nor land units.  The latter had a scary-looking caploss(),
but NF_SACKED should have rendered that harmless.

15 years agoDon't revert sectors without military to old owner
Markus Armbruster [Thu, 4 Sep 2008 00:00:30 +0000 (20:00 -0400)]
Don't revert sectors without military to old owner

Change checksect() not to abandon occupied sectors to the old owner
when there is no military and no land units.  This effectively
restores pre-Chainsaw 3 behavior.  Matching change to would_abandon().

Rationale.  Traditional ways to change sector owner:

(1) Attack, assault, paradrop can transfer a sector to the attacker,
    in take_def().

(2) Guerrilla warfare at the update can transfer a sector to the old
    owner, in guerilla().  This happens when che kill all military and
    the sector is sufficiently disloyal to the owner.

(3) Whenever all civilians, military and land units are removed from a
    sector, no matter how, it silently reverts to the deity, in
    checksect().

Chainsaw 3 added:

(4) Whenever all military and land units are removed from an occupied
    sector, no matter how, it silently reverts to the old owner, in
    checksect().

This addition isn't seamless.  Funnies include:

* When che kill all military and land units, but the sector is loyal,
  (3) doesn't transfer to the old owner.  But since there's no
  military and land units left, (4) transfers it anyway, only without
  telling the lucky old owner.  The latter transfer is buggy:
  checksect() runs only on ef_read() and ef_write(), not the update
  (bug#1010856), so the silent transfer is delayed until the next
  ef_write().  But code using ef_read() sees it right away.  For
  instance, the path finder, which doesn't use ef_read(), can route a
  path through a sector lost that way.  The actual move, which does
  use ef_read(), then chokes on that path.

* When you attack a sector, and get defeated with the help of reacting
  land units, but succeed in killing the *local* defenders, (4) makes
  the sector silently revert to the old owner.  Which might be
  somebody who wasn't involved in the fight, and gets no notification
  whatsoever of his windfall.

* You can abandon a sector to the old-owner by removing all military
  and land units from it, in a myriad of ways.  Some ways ask you for
  confirmation (move, march, load), many don't (navigate, plane
  construction, delivery; arguably bugs), and others simply don't let
  you (paradrop, fly, distribution).

  This problem also exists for abandoning to deity, i.e. through (3)
  instead of (4).  Some ways to move out civilians don't let you do
  that (distribute), but most do.  However, accidentally abandoning an
  empty sector to deity is less serious than a populated one to
  another player.

In my opinion, (4) doesn't add much to the game, and fixing the
funnies isn't worth the effort.

15 years agoFix execution of nightly build econfig patch script
rkoenderink@gmail.com [Thu, 4 Sep 2008 01:30:11 +0000 (19:30 -0600)]
Fix execution of nightly build econfig patch script

This is required for non-Windows environment as the files do not
have permission to execute.

15 years agoRemove pointless getFOO() from prewrite callbacks
Markus Armbruster [Tue, 2 Sep 2008 23:12:06 +0000 (19:12 -0400)]
Remove pointless getFOO() from prewrite callbacks

Empire3's C_SYNC code added these to sct_prewrite(), shp_prewrite(),
pln_prewrite(), lnd_prewrite() and nuk_prewrite().  They weren't
removed when C_SYNC was ripped out in 4.0.0.

15 years agoMake ef_close() clear baseid, cids and fids
Markus Armbruster [Mon, 1 Sep 2008 16:42:24 +0000 (12:42 -0400)]
Make ef_close() clear baseid, cids and fids

15 years agoMove view open/close into src/lib/common/file.c
Markus Armbruster [Mon, 1 Sep 2008 14:38:48 +0000 (10:38 -0400)]
Move view open/close into src/lib/common/file.c

Really belongs there, because it manipulates empfile[].

New ef_open_view() to replace ef_init_view().  Make ef_close() cope
with views, and remove ef_fina_view().  Make ef_extend() and
ef_truncate() oops on views.

15 years agoFix misuse of ef_cadef(EF_BAD)
Markus Armbruster [Mon, 1 Sep 2008 14:29:01 +0000 (10:29 -0400)]
Fix misuse of ef_cadef(EF_BAD)

ef_elt_by_name(), xdprval_sym() and symval() checked whether a file
type T is a symbol table by comparing ef_cadef(T) to symbol_ca, even
though T may be EF_BAD.  Before commit 50cfdcb5, ef_cadef(EF_BAD)
accessed empfile[] out of bounds, which could conceivably crash or
somehow happen to yield symbol_ca.  Since then, it oopses and returns
null.

Fix by testing the file type before calling ef_cadef().

15 years agoCheck argument of ef_cadef(), ef_nelem(), ef_flags(), ef_mtime()
Markus Armbruster [Mon, 1 Sep 2008 13:34:16 +0000 (09:34 -0400)]
Check argument of ef_cadef(), ef_nelem(), ef_flags(), ef_mtime()

This removes any need for calling ef_check() outside of file.c.
Remove its only occurence, from symval(), and give it internal
linkage.

15 years agoClean up maintenance of config table sentinels
Markus Armbruster [Mon, 1 Sep 2008 13:20:08 +0000 (09:20 -0400)]
Clean up maintenance of config table sentinels

Xundump had special hackery to maintain configuration tables'
sentinels: xubody() and getobj() added a sentinel element when
initializing or growing a table, which xubody() stripped off again
before returning.  The latter was an unclean hack.

Replace this by building knowledge of sentinels into struct empfile:
new flag EFF_SENTINEL, set for the appropriate members of empfile[],
obeyed by ef_extend() and ef_truncate().

15 years agoFix empfile[EF_VERSION].flags and .csize
Markus Armbruster [Mon, 1 Sep 2008 01:08:55 +0000 (21:08 -0400)]
Fix empfile[EF_VERSION].flags and .csize

csize was 0 instead of 1, and flags was 0 instead of EFF_STATIC.
xdump didn't care.

15 years agostruct empfile doc fixes
Markus Armbruster [Mon, 1 Sep 2008 00:28:07 +0000 (20:28 -0400)]
struct empfile doc fixes

15 years agoChange empfile members postread() and prewrite() to return void
Markus Armbruster [Sun, 31 Aug 2008 18:44:16 +0000 (14:44 -0400)]
Change empfile members postread() and prewrite() to return void

Callers ignore the value, and callees always return 1.  Pointless.

15 years agoFix/improve logging in ef_close(), ef_extend(), ef_truncate()
Markus Armbruster [Sun, 31 Aug 2008 18:24:53 +0000 (14:24 -0400)]
Fix/improve logging in ef_close(), ef_extend(), ef_truncate()

Change ef_close() to log ep->file instead of ep->name, to match
ef_open().

Fix ef_extend() to log ep->name instead of ep->file, which could be
null.  Also fix ef_ensure_space()'s function comment.  Both broken in
commit 2eb8672b.

ef_truncate()'s error logging lacked detail when ef_realloc_cache()
failed, fix.

15 years agoSimplify mapdist()
Markus Armbruster [Sun, 31 Aug 2008 13:53:33 +0000 (09:53 -0400)]
Simplify mapdist()

It became needlessly complicated in 4.0.1 to fix a "bug in mapdist not
taking world edges into account nicely enough."  That "fix" had no
effect, which was good, because it wasn't broken.

15 years agoUse MAPWIDTH() to allocate map buffers
Markus Armbruster [Sun, 31 Aug 2008 13:26:50 +0000 (09:26 -0400)]
Use MAPWIDTH() to allocate map buffers

sona(), radmap2() and satmap() used WORLD_X + 1, which equals
MAPWIDTH(1).  Using MAPWIDTH() is somewhat clearer and cleaner.

15 years agoSimplify routech[]
Markus Armbruster [Thu, 28 Aug 2008 01:30:56 +0000 (21:30 -0400)]
Simplify routech[]

routech[][1] hasn't been used in living memory.  Drop it, and simplify
to routech[].

15 years agoInclude destination in interception and plane mission messages
Markus Armbruster [Wed, 27 Aug 2008 01:33:48 +0000 (21:33 -0400)]
Include destination in interception and plane mission messages

Interception and missions launch planes automatically.  The plane
owner (and for missions, the base sector owner) gets a message.
Destination coordinates are often obvious from the context, but not
always, e.g. when flying in support of allies, or when the mission
gets interepted and aborts.  Include the destination coordinates in
the messages.  Reported by Ulrich Hannemann.

15 years agoFix client code for catching rogue redirections and executes
Markus Armbruster [Sat, 23 Aug 2008 20:19:09 +0000 (16:19 -0400)]
Fix client code for catching rogue redirections and executes

The client permits redirection and execute only if it recently saw
them in player input.  The caching of recent player input for this
purpose was broken.

When save_input() evicted a line, it kept its newline.  This could
make the recent_input ring buffer fill up, which then got redirections
and execute misdiagnosed as rogue.

save_input() also screwed up when evicting one line didn't make
sufficient room for the line to be saved.  This could cause assertion
failure in forget_input().

Broken in commit 8b7d0b91, v4.3.11.

15 years agoFix xdump realm to dump player instead of absolute coordinates
Markus Armbruster [Sat, 23 Aug 2008 19:40:41 +0000 (15:40 -0400)]
Fix xdump realm to dump player instead of absolute coordinates

Disclosed the true origin.  Broken in 45adbdb0, v4.3.0.

15 years agoFix spy to reliably avoid spying same sector more than once
Markus Armbruster [Sat, 23 Aug 2008 19:17:44 +0000 (15:17 -0400)]
Fix spy to reliably avoid spying same sector more than once

spy() stored coordinates of sectors successfully spied in an array.
Since it didn't bother to normalize coordinates, it could spy sectors
near the "seams" of the world more than once.  The array was also
wastefully large.

Fix by using a sector bitmap instead, like do_look().

15 years agoSimplify implementation of MAP_HIGH in draw_map()
Markus Armbruster [Sat, 23 Aug 2008 18:54:42 +0000 (14:54 -0400)]
Simplify implementation of MAP_HIGH in draw_map()

Own sectors are always visible on the map, so checking their
visibility with bitinit2() and emp_getbit() is superflous.

15 years agoFix size of sector bitmap in do_look() and draw_map()
Markus Armbruster [Sat, 23 Aug 2008 18:41:07 +0000 (14:41 -0400)]
Fix size of sector bitmap in do_look() and draw_map()

They allocated twice as much as needed.

15 years agoReplace broken GCFx(), GCFy() by sctoff()
Markus Armbruster [Sat, 23 Aug 2008 18:04:10 +0000 (14:04 -0400)]
Replace broken GCFx(), GCFy() by sctoff()

GCFx() and GCFy() pointlessly duplicate sctoff(), and don't work when
the argument is less than -WORLD_X or -WORLD_Y, respectively.  With
current code, this happens only for impractically tiny worlds:
emp_setbitmap() writes to bitmap[] out of bounds, and smashes the
heap.

15 years agoKeep coordinates normalized in getpath()
Markus Armbruster [Sat, 23 Aug 2008 17:20:45 +0000 (13:20 -0400)]
Keep coordinates normalized in getpath()

The old code is believed to be safe, but keeping coordinates
normalized is cleaner.

15 years agoFix move_ground() to pass coordinate arguments normalized
Markus Armbruster [Sat, 23 Aug 2008 17:14:18 +0000 (13:14 -0400)]
Fix move_ground() to pass coordinate arguments normalized

move_ground() passes curx, cury to various functions that should
probably be called with normalized coordinate arguments.  Make sure
curx, cury are normalized.

15 years agoFix satellite coordinates screwup in launch
Markus Armbruster [Sat, 23 Aug 2008 15:09:08 +0000 (11:09 -0400)]
Fix satellite coordinates screwup in launch

launch_sat() failed to normalize the satellite's coordinates when it
added a random course deviation.  Satellites with screwed up
coordinates were missed by skywatch, and possibly in other places.

15 years agoFix recently introduced memory corrupter in path()
Markus Armbruster [Sat, 23 Aug 2008 14:42:22 +0000 (10:42 -0400)]
Fix recently introduced memory corrupter in path()

path() failed to normalize coordinate argument for deltx() and
delty().  This could subscript map[] and mapbuf[] out of bounds.
Broken in commit 3ca88271.

15 years agoCorrections for player 8
Ron Koenderink [Sun, 24 Aug 2008 15:12:40 +0000 (09:12 -0600)]
Corrections for player 8

Fix the move in Turn 7, incorrect starting sector.
Fix the threshold in Turn 10, incorrect commodity.

15 years agoAdd server.log and journal.log to nightly build
Ron Koenderink [Sun, 24 Aug 2008 15:09:22 +0000 (09:09 -0600)]
Add server.log and journal.log to nightly build

Turn on journaling using journal.econfig.
Append the server.log and journal.log files
to the nightly build log in the SERVERSTOP step.
Remove the server.log and journal.log in the
SERVERSTART step to ensure only this run's log
events are included in the nightly build log.
Add the construction of a econfig in the
generate step using *.econfig in the patches
directory in a same way code patches are applied.
The mingw.patch was removed and replaced with the
mingw.econfig.  The mingw.econfig also required
the addition of exports to the win32.i386.config.

15 years agoFix pathrange() for paths spanning whole world (with border)
Markus Armbruster [Wed, 20 Aug 2008 01:44:56 +0000 (21:44 -0400)]
Fix pathrange() for paths spanning whole world (with border)

pathrange() screwed up when the result should have been as wide or as
high as the whole world.  This made the path command show a broken
map.

15 years agoRemove cheesy work-around for broken MAPWIDTH()
Markus Armbruster [Wed, 20 Aug 2008 01:30:49 +0000 (21:30 -0400)]
Remove cheesy work-around for broken MAPWIDTH()

MAPWIDTH(3) used to be one too small, which made rout() clobber the
map row's terminating zero when the map spans the whole world in x.
Since Chainsaw 2, rout() copied rows into an additional buffer to add
a terminating zero.  Remove that junk.

15 years agoFix MAPWIDTH() for arguments other than 1
Markus Armbruster [Wed, 20 Aug 2008 01:24:51 +0000 (21:24 -0400)]
Fix MAPWIDTH() for arguments other than 1

MAPWIDTH(x) was (x+2)/2 - 1 too small.  Affected were path and route,
which use MAPWIDTH(3) to size their map buffer: they clobber map rows'
terminating zero when the map spans the whole world in x.  rout() has
a cheesy work-around for that since Chainsaw 2.  path() doesn't, and
duly breaks.

15 years agoFix default map size in interactive move, test and transport
Markus Armbruster [Tue, 19 Aug 2008 01:36:40 +0000 (21:36 -0400)]
Fix default map size in interactive move, test and transport

Sub-command 'm' calls display_region_map() to display a map.  The map
is centered on the current sector by default.  It extended one sector
farther to the right and down than to the left and up.  Odd, and
inconsistent with the map size used by unit_map() for navigate and
march sub-command 'M'.  Fix that.

15 years agoUse snxtitem_xy() instead of snxtitem_dist(..., 0)
Markus Armbruster [Tue, 19 Aug 2008 00:53:32 +0000 (20:53 -0400)]
Use snxtitem_xy() instead of snxtitem_dist(..., 0)

Affected: launch_as() and takeover().

15 years agoSimplify draw_map()
Markus Armbruster [Tue, 19 Aug 2008 00:47:58 +0000 (20:47 -0400)]
Simplify draw_map()

No functional change.

15 years agoFold sarg_getrange() into sarg_area()
Markus Armbruster [Sun, 17 Aug 2008 23:51:43 +0000 (19:51 -0400)]
Fold sarg_getrange() into sarg_area()

sarg_area() is the only caller, and is not doing anything but calling
it anymore.

15 years agoRework code dealing with struct range fixing many bugs
Markus Armbruster [Sun, 17 Aug 2008 21:44:00 +0000 (17:44 -0400)]
Rework code dealing with struct range fixing many bugs

Change struct range from exclusive to inclusive upper bounds, for
consistency with struct realmstr and the area syntax.  Also fix many
bugs.

real()'s conversion from struct range's exclusive upper bounds to
struct realmstr's inclusive upper bounds could underflow and store -1
in the realms file.  Harmless, because its users didn't mind:
list_realm() and nstr_exec_val() convert back to relative coordinates,
and sarg_getrange() is only used by sarg_area(), which happened to
undo the damage.  The change to inclusive upper bounds gets rid of the
broken conversion.

xyinrange() incorrectly treated the upper bound as inclusive, unless
the bounds were equal.  Impact:

* nxtitem() and nxtitemp() cases NS_AREA and NS_DIST attempted to hack
  around xyinrange()'s lossage(!), but screwed up: sectors on the
  lower bound of of a range spanning the the whole world were skipped.
  This affected all command arguments that support area or distance
  syntax for items.  In sufficiently small worlds, it could also make
  radar miss satellites and ships, sonar miss ships, satellite miss
  ships and land units, nuclear detonations miss ships, planes, land
  units and nukes, automatic supply miss ship and land unit supply
  sources, ships and land units fail to return fire, ships fail to
  fire support.

* draw_map() could draw units sitting just right or just below of the
  mapped area.  No effect, as these parts of the map weren't actually
  shown.

xydist_range() produced an inclusive upper bound when it decided that
the range covers everything in that dimension (which it didn't get
quite right either).  This could make snxtsct_dist() and
snxtitem_dist() initialize the iterator with an incorrect upper bound.
Similar impact as the xyinrange() / nxtitem() lossage.

border() could print the hundreds line unnecessarily.

snxtsct() and snxtsct_all() screwed up for odd WORLD_Y: they failed to
include (WORLD_Y - 1) / 2 in the y-range.  This affected all command
arguments that support "*" syntax for sectors, plus add ... c, power
n, and break.

snxtsct_all() failed to normalize the bounds (presumed harmless).

There were a few correct, but somewhat unclean uses of struct range
with inclusive upper bounds:

* nat_reset() used one internally.

* pathrange() worked with inclusive upper bounds internally, but
  corrected to exclusive upper bounds before passing the range out.

* sarg_getrange() worked with inclusive upper bounds.  Its only caller
  sarg_area() corrected that to exclusive upper bounds.

The change to inclusive upper bounds cleans this up.

unit_map() and xysize_range() had no issues (isn't that amazing?), but
need to be updated for the changed struct range semantics.

15 years agoDoc fix for commit 7ca4f412
Markus Armbruster [Sun, 17 Aug 2008 13:52:03 +0000 (09:52 -0400)]
Doc fix for commit 7ca4f412

15 years agoMake snxtsct_area() expect correct range width and height
Markus Armbruster [Sun, 17 Aug 2008 13:23:22 +0000 (09:23 -0400)]
Make snxtsct_area() expect correct range width and height

snxtsct_area() computed width and height, overwriting the values
passed in, even though all but two callers passed correct values.  The
exceptions were snxtsct() in case NS_ALL, and snxtsct_all().  Change
them to pass correct values, and drop the recomputation from
snxtsct_area().  Simplifies the interface between snxtsct_area() and
its callers.

15 years agoClean up and simplify snxtitem_dist() and snxtsct_dist()
Markus Armbruster [Sun, 17 Aug 2008 11:51:23 +0000 (07:51 -0400)]
Clean up and simplify snxtitem_dist() and snxtsct_dist()

No functional change.

15 years agoOops on funny xysize_range() arguments
Markus Armbruster [Sun, 17 Aug 2008 02:07:28 +0000 (22:07 -0400)]
Oops on funny xysize_range() arguments

Comments claimed funny arguments could happen.  I don't think so.

15 years agoFix computation of map buffer indexes
Markus Armbruster [Sun, 17 Aug 2008 01:56:28 +0000 (21:56 -0400)]
Fix computation of map buffer indexes

The correct method to compute indexes into a map buffer for a struct
range is deltx(), delty().

path() used deltax(), deltay() instead, which yield correct results
only for indexes up to half the world size.  Pathes spanning larger
areas were screwed up.

sona(), radmap2(), satmap() also used deltax(), deltay(), but only
with arguments where those yield correct results.

draw_map() used xnorm(), ynorm() instead, which is correct, but less
clear and less efficient.

15 years agoFix deltx() for x < r->lx && r->lx < r->hx; likewise delty()
Markus Armbruster [Sat, 16 Aug 2008 18:57:13 +0000 (14:57 -0400)]
Fix deltx() for x < r->lx && r->lx < r->hx; likewise delty()

Bug couldn't bite, because callers pass only coordinates within the
interval.

15 years agoRemove some useless code from nav_map()
Markus Armbruster [Sat, 16 Aug 2008 18:22:22 +0000 (14:22 -0400)]
Remove some useless code from nav_map()

15 years agoBuild ecomony for player 8
Ron Koenderink [Tue, 19 Aug 2008 03:21:46 +0000 (21:21 -0600)]
Build ecomony for player 8

15 years agoExplore player 8's island
Ron Koenderink [Sun, 17 Aug 2008 21:54:21 +0000 (15:54 -0600)]
Explore player 8's island

Explore the player 8's island in preparation for
island development and future war with player 1.

15 years agoAdd additional tests to nightly build
Ron Koenderink [Sun, 17 Aug 2008 21:51:40 +0000 (15:51 -0600)]
Add additional tests to nightly build

The following tests were added:
bridge building
spy
radar (ship, sector)
look
convert
In additon, prepartion for testing research and
hapiness production was added and improvements
for general economy for player 1 were added.

15 years agoFix timestamps for data files and lost command
Ron Koenderink [Sun, 17 Aug 2008 21:13:57 +0000 (15:13 -0600)]
Fix timestamps for data files and lost command

Set the ef_timestamp to 100 for the nightly build.
Set the DUMP LOST timestamp to 101 for the nightly build.
This will the suppress the timestamp differences
that occur when testing lost command and will facilitate
testing for dump and xdump commands.

15 years agoBump version to 4.3.17
Markus Armbruster [Fri, 15 Aug 2008 11:52:36 +0000 (07:52 -0400)]
Bump version to 4.3.17

15 years agoAdd additional tests to nightly build
Ron Koenderink [Sat, 9 Aug 2008 21:05:40 +0000 (15:05 -0600)]
Add additional tests to nightly build

The following tests were added:
ship list
ship navigation
assault
tech production
sector lost
commodity monitoring
tech monitoring
education monitoring

15 years agoAdd change directory before starting server tests
Ron Koenderink [Sat, 9 Aug 2008 20:59:59 +0000 (14:59 -0600)]
Add change directory before starting server tests

The server tests would fail if the previous
steps were skippped.

15 years agoUpdate change log again for 4.3.16 v4.3.16
Markus Armbruster [Sat, 9 Aug 2008 15:58:01 +0000 (11:58 -0400)]
Update change log again for 4.3.16

15 years agoFail announce, pray, telegram and turn on aborted telegrams
Markus Armbruster [Sat, 9 Aug 2008 15:52:04 +0000 (11:52 -0400)]
Fail announce, pray, telegram and turn on aborted telegrams

Change tele() and turn() to return RET_FAIL when getele() fails.
Before, tele() returned RET_OK then, and turn() returned RET_SYN.

15 years agoFix recently changed command failures to use BTUs
Markus Armbruster [Sat, 9 Aug 2008 15:44:26 +0000 (11:44 -0400)]
Fix recently changed command failures to use BTUs

Failing a command with code RET_SYN prints help and doesn't charge
BTUs.  Failing with code RET_FAIL doesn't print help and charges BTUs.

A couple of command failures were changed or added recently to fail
with RET_SYN, because they're due to invalid player input.  Some of
them, however, can happen after the command already did something, so
BTUs must be charged, or else players can deliberately fail the
command to save BTUs:

* Commit 9eda5f87 adds RET_SYN failures when getting player input
  fails for:

  - arm third argument
  - deliver fourth argument
  - fire third argument
  - lmine second argument
  - order d fourth argument
  - range second argument
  - sail second argument
  - tend third argument

* Commit be41e70f likewise for:

  - designate second argument
  - morale second argument
  - set third argument
  - tend fourth argument

* Commit d000bf92 likewise (with a bogus commit message) for bdes
  second argument.

* Commit 9f4ce71a likewise for ltend third and fourth argument.

* Commit 9031b03b changes failure code from RET_FAIL when getting
  player input fails for threshold third argument.  It adds RET_SYN
  failure when the argument is bad.  Some bad arguments already failed
  that way before.

* Commit a7cf69af changes it from RET_FAIL when designate second
  argument is bad.

Change them all to fail with RET_FAIL.

Many other places have the same bug, but those are left for another
day.

15 years agoFix production command not to limit level production to 999
Markus Armbruster [Sat, 9 Aug 2008 13:03:03 +0000 (09:03 -0400)]
Fix production command not to limit level production to 999

Item production is limited to 999 units, level production is
unlimited.

Commit 0e721173 (v4.2.15) changed prod() from no limit to 999 units,
which fixed it for items, and broke it for levels.  Undo the change
for levels.

15 years agoGive some identifiers internal linkage
Markus Armbruster [Mon, 4 Aug 2008 01:00:40 +0000 (21:00 -0400)]
Give some identifiers internal linkage

Give draw_map(), xdeval(), LwpSchedQ[], LwpDeadQ, LwpContextPtr,
LwpMaxpri, LwpStackGrowsDown internal linkage.

15 years agoRemove unused xdprval()
Markus Armbruster [Mon, 4 Aug 2008 00:56:19 +0000 (20:56 -0400)]
Remove unused xdprval()

15 years agoFix work not to claim an engineer worked when it didn't
Markus Armbruster [Sun, 3 Aug 2008 21:32:35 +0000 (17:32 -0400)]
Fix work not to claim an engineer worked when it didn't

15 years agoFix work command to round mobility use randomly, not down
Markus Armbruster [Sun, 3 Aug 2008 21:21:07 +0000 (17:21 -0400)]
Fix work command to round mobility use randomly, not down

15 years agoFix work command not to spend more mobility than requested
Markus Armbruster [Sun, 3 Aug 2008 21:20:05 +0000 (17:20 -0400)]
Fix work command not to spend more mobility than requested

Culprit is careless rounding in work().

15 years agoDon't permit work command to spend more money than available
Markus Armbruster [Sun, 3 Aug 2008 20:54:14 +0000 (16:54 -0400)]
Don't permit work command to spend more money than available

Stop work() when there's not enough money left for the current
engineer.

15 years agoImprove work()'s message when sector doesn't need construction
Markus Armbruster [Sun, 3 Aug 2008 20:36:44 +0000 (16:36 -0400)]
Improve work()'s message when sector doesn't need construction

The cheesy test for repeated messages broke down when working on more
than one sector.  Reword the message so that repetition is fine, and
drop the test.

15 years agoFix improve not to spend more money than available
Markus Armbruster [Sun, 3 Aug 2008 19:09:15 +0000 (15:09 -0400)]
Fix improve not to spend more money than available

improve() attempted not to spend the last dollar, but screwed up when
improving more than one sector.  This could bankrupt the player.

Replace the flawed code by the same simple method that is used
elsewhere: break the loop when there's not enough money left for the
current sector.

15 years agochkmoney() is no longer used, remove it
Markus Armbruster [Sun, 3 Aug 2008 18:40:40 +0000 (14:40 -0400)]
chkmoney() is no longer used, remove it

15 years agoDon't permit convert to spend more money than available
Markus Armbruster [Sun, 3 Aug 2008 18:40:13 +0000 (14:40 -0400)]
Don't permit convert to spend more money than available

Complicated by the fact that conv() ran the conversion code twice,
first for adding up the cost for chkmoney(), then for actually
converting.  chkmoney() asks the player to confirm when he's about to
spend more than half his cash.  Get rid of that, not worth the
complexity.  This merges do_conv() back into conv().

15 years agoDon't permit demobilize to spend more money than available
Markus Armbruster [Sun, 3 Aug 2008 18:14:07 +0000 (14:14 -0400)]
Don't permit demobilize to spend more money than available

Complicated by the fact that demo() ran the demobilization code twice,
first for adding up the cost for chkmoney(), then for actually
demobilizing.  chkmoney() asks the player to confirm when he's about
to spend more than half his cash.  Get rid of that, not worth the
complexity.  This merges do_demo() back into demo().

It also removes the command's virtually undocumented fourth argument.
Update player_coms[] accordingly.  While there, make it require money;
it won't do anything useful without money anyway.

15 years agoChange nav_ship() not to use RET_OK and RET_SYN as return values
Markus Armbruster [Sun, 3 Aug 2008 16:18:14 +0000 (12:18 -0400)]
Change nav_ship() not to use RET_OK and RET_SYN as return values

These are only appropriate for commands and their helpers.

15 years agoGet rid of RET_SYS, just use RET_FAIL
Markus Armbruster [Sun, 3 Aug 2008 15:34:00 +0000 (11:34 -0400)]
Get rid of RET_SYS, just use RET_FAIL

RET_SYS was used for commands failing due to internal or environmental
errors, but not really systematically.  The difference to RET_FAIL is
how dispatch() treats them: RET_SYS got logged, and cost no BTUs.

More specific logging is possible at the point of failure than in
dispatch().  Make sure that's done for all failures that used to
return RET_SYS.

The change in BTU charging affects commands consider, offer, repay,
trade failing due to internal errors.  It also affects deity commands
reload and turn (irrelevant because deities get unlimited BTUs), and
commands apropos, info and motd (irrelevant because they cost no
BTUs).

15 years agoFix error return value of nav_loadship()
Markus Armbruster [Sun, 3 Aug 2008 14:25:48 +0000 (10:25 -0400)]
Fix error return value of nav_loadship()

Used RET_SYS as an error value, which is bogus; caller interprets
non-zero as "all loaded".  Return zero instead.