Commit graph

3419 commits

Author SHA1 Message Date
62076fbed7 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.
2008-09-03 21:17:46 -04:00
d929aa8b82 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().
2008-09-03 21:15:08 -04:00
50cfdcb5a7 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.
2008-09-03 20:43:13 -04:00
1492845c12 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().
2008-09-03 20:43:13 -04:00
02254398e8 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.
2008-09-03 20:43:13 -04:00
f9beb03d45 struct empfile doc fixes 2008-09-03 20:43:13 -04:00
bf436a4498 Change empfile members postread() and prewrite() to return void
Callers ignore the value, and callees always return 1.  Pointless.
2008-09-03 20:43:13 -04:00
e438f6b4cd 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.
2008-09-03 20:43:13 -04:00
0bc3cb460a 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.
2008-09-03 20:43:13 -04:00
7803cd9dd1 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.
2008-09-03 20:43:12 -04:00
d012940230 Simplify routech[]
routech[][1] hasn't been used in living memory.  Drop it, and simplify
to routech[].
2008-08-27 21:30:56 -04:00
2ec20c8896 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.
2008-08-26 21:46:49 -04:00
55b7fa1588 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.
2008-08-26 21:42:32 -04:00
741a7e54bd Fix xdump realm to dump player instead of absolute coordinates
Disclosed the true origin.  Broken in 45adbdb0, v4.3.0.
2008-08-26 21:42:32 -04:00
dda0a4c82f 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().
2008-08-26 21:42:32 -04:00
e9c7491449 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.
2008-08-26 21:42:32 -04:00
d44ae3ef96 Fix size of sector bitmap in do_look() and draw_map()
They allocated twice as much as needed.
2008-08-26 21:42:32 -04:00
c89f8172ec 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.
2008-08-26 21:42:32 -04:00
6316c4185a Keep coordinates normalized in getpath()
The old code is believed to be safe, but keeping coordinates
normalized is cleaner.
2008-08-26 21:42:32 -04:00
1e6c04a34e 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.
2008-08-26 21:42:32 -04:00
5621f62302 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.
2008-08-26 21:42:32 -04:00
1ac95e0ed7 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.
2008-08-26 21:42:32 -04:00
Ron Koenderink
99284a9beb Corrections for player 8
Fix the move in Turn 7, incorrect starting sector.
Fix the threshold in Turn 10, incorrect commodity.
2008-08-24 09:12:40 -06:00
Ron Koenderink
d9cc5aab10 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.
2008-08-24 09:09:22 -06:00
0f458d2c0c 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.
2008-08-20 07:40:51 -04:00
f6e62bd929 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.
2008-08-20 07:40:51 -04:00
955ef7d51f 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.
2008-08-20 07:40:51 -04:00
88997ec31f 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.
2008-08-20 07:40:51 -04:00
dce3ba7e2f Use snxtitem_xy() instead of snxtitem_dist(..., 0)
Affected: launch_as() and takeover().
2008-08-20 07:40:51 -04:00
058cabfa3b Simplify draw_map()
No functional change.
2008-08-20 07:40:51 -04:00
7a6073bb67 Fold sarg_getrange() into sarg_area()
sarg_area() is the only caller, and is not doing anything but calling
it anymore.
2008-08-20 07:40:51 -04:00
68f7c0ceda 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.
2008-08-20 07:40:32 -04:00
1ec0dc976a Doc fix for commit 7ca4f412 2008-08-19 08:54:05 -04:00
5c4963c464 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.
2008-08-19 08:54:05 -04:00
bf9389a7a9 Clean up and simplify snxtitem_dist() and snxtsct_dist()
No functional change.
2008-08-19 08:54:05 -04:00
d17f33d138 Oops on funny xysize_range() arguments
Comments claimed funny arguments could happen.  I don't think so.
2008-08-19 08:54:04 -04:00
3ca882714d 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.
2008-08-19 08:54:04 -04:00
42a8b315e5 Fix deltx() for x < r->lx && r->lx < r->hx; likewise delty()
Bug couldn't bite, because callers pass only coordinates within the
interval.
2008-08-19 08:54:04 -04:00
6830c80341 Remove some useless code from nav_map() 2008-08-19 08:54:04 -04:00
Ron Koenderink
6dadcd0976 Build ecomony for player 8 2008-08-18 21:21:46 -06:00
Ron Koenderink
8319414b01 Explore player 8's island
Explore the player 8's island in preparation for
island development and future war with player 1.
2008-08-17 15:54:21 -06:00
Ron Koenderink
b6c2d5bfa9 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.
2008-08-17 15:51:40 -06:00
Ron Koenderink
851ccd4876 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.
2008-08-17 15:13:57 -06:00
8c404f5b7f Bump version to 4.3.17 2008-08-15 07:52:36 -04:00
Ron Koenderink
047b4b1983 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
2008-08-09 15:05:40 -06:00
Ron Koenderink
931f6db90d Add change directory before starting server tests
The server tests would fail if the previous
steps were skippped.
2008-08-09 14:59:59 -06:00
fac3049bc2 Update change log again for 4.3.16 2008-08-09 12:10:06 -04:00
358de131f7 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.
2008-08-09 12:10:06 -04:00
a532c76428 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.
2008-08-09 12:09:50 -04:00
c7d2144154 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.
2008-08-09 09:03:03 -04:00