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().
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.
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.
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.
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().
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().
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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
- 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.
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.
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().
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.
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).
Behave like plane_bomb() and land_bomb(): deal with leading whitespace
and signs in the input, print a message when asked to bomb a ship that
is not there.
Disable collateral damage for automatically launched missiles
4.0.17 made missiles that miss their target do collateral damage to
the target sector. The code didn't work: it did collateral damage
even when the launch failed or the missile got intercepted. 4.0.18
disabled it again for the launch command (see also commit fa7e3aa9).
Disable it for automatically launched missiles, too, in
msl_launch_mindam().
The initial parts of struct loststr and struct empobj must match.
Commit 49780e2c screwed that up for members lost_uid/uid, which also
broke the equivalence of lost_owner/own. Since lost_uid is not used,
the former had no effect. But the latter broke xdvisible(). Could
make xdump lost leak information.
Commit a680c811 reorderd struct loststr members to make lost_timestamp
equivalent to new struct empobj member timestamp, but failed due to
the bug in commit 49780e2c. Commit f33b96b1 then set the timestamp
through empobj, which screwed up timestamps in lostitems, i.e. it
broke incremental xdump lost.
All of the above is in v4.3.12.
Commit 536ef0b0 (v4.3.15) added lost_seqno / seqno. No effect,
because only seqno is used.
This is the human-readable buddy of xdump product, which dumps pchr[].
It duplicates much of the information in show sect c, but in more
accessible form. It's in show_product().
Remove product information from info Quick-ref. show reflects the
actual game, is more complete, and should be just as readable.
Show packing type instead of selected bonuses in show se s
show_sect_stats() used to show packing bonuses for military,
uncompensated workers, civilians, bars and lcms. The bonus for lcms
was labelled "other", which was okay only as long as all other
commodities receive the same packing bonuses.
Show packing bonus type instead. The actual bonus for each commodity
and packing type is already shown by show item. But change its header
for the NPKG column from "rg" to "no", because packing type NPKG is
shown by show se s as "normal".
show_sect_build() showed only sectors with unusual build
characteristics. Which begged the question what the usual build
characteristics are. Add a line to show them.
Fix extra prompt after abort due to misuse of snxtitem()
The old code used getstarg() to get an argument with a different
prompt than snxtitem() uses, then passed the value to snxtitem()
unchecked. If the player aborts, getstarg() returns a null pointer,
and snxtitem() prompts again. Affected:
* load/lload plane/land third argument; load_plane_ship(),
load_land_ship(), load_plane_land(), load_land_land()
* bomb, drop, fly, paradrop, recon and sweep second argument;
get_planes()
* tend and ltend second and fourth argument; ltend(), tend(),
tend_land()
* mission second argument; mission()
Fix by making snxtitem() taking a prompt argument, null pointer
requests the old prompt.
Use that to simplify multifire() and torp(). Change the other callers
to pass NULL.
Broken since commit 35db407d, v.4.3.12. v4.3.14 and v4.3.15 were
distributed with a stale sources.mk in the tarball. The latter does
not build out of the box because of that.
There were two checks meant to enforce positive numbers, both dating
back to the earliest known versions of the code, and both wrong.
The first one applied only to thresholds given with the command, not
ones prompted for, and it incorrectly rejected numbers starting with +
or prefixed by whitespace. Remove it.
The second one failed to reject negative numbers when prefixed by
whitespace. Fix.
Fortunately, the update doesn't conjure up stuff to satisfy negative
thresholds.