Commit graph

3395 commits

Author SHA1 Message Date
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
aee8272d3d Give some identifiers internal linkage
Give draw_map(), xdeval(), LwpSchedQ[], LwpDeadQ, LwpContextPtr,
LwpMaxpri, LwpStackGrowsDown internal linkage.
2008-08-09 08:40:04 -04:00
0a49cd24a3 Remove unused xdprval() 2008-08-09 08:40:04 -04:00
e628c50b21 Fix work not to claim an engineer worked when it didn't 2008-08-09 08:40:04 -04:00
063a7d9988 Fix work command to round mobility use randomly, not down 2008-08-09 08:40:04 -04:00
ab2893fa41 Fix work command not to spend more mobility than requested
Culprit is careless rounding in work().
2008-08-09 08:40:04 -04:00
3615cfc8ac Don't permit work command to spend more money than available
Stop work() when there's not enough money left for the current
engineer.
2008-08-09 08:40:04 -04:00
ede42fb9ce 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.
2008-08-09 08:40:04 -04:00
c20ac26ecc 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.
2008-08-09 08:40:04 -04:00
4b696a5c30 chkmoney() is no longer used, remove it 2008-08-09 08:40:04 -04:00
82c916654c 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().
2008-08-09 08:38:07 -04:00
cc4cf23273 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.
2008-08-09 08:34:00 -04:00
2434d2c8ee Change nav_ship() not to use RET_OK and RET_SYN as return values
These are only appropriate for commands and their helpers.
2008-08-03 12:18:14 -04:00
29aefc356f 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).
2008-08-03 11:34:00 -04:00
e803950463 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.
2008-08-03 10:25:48 -04:00
ed9da7cf06 Update known contributors comments 2008-08-03 08:04:08 -04:00
4ac09a3cd9 Update change log for 4.3.16 2008-08-02 21:29:48 -04:00
5c18d33e21 Make ship_bomb() friendlier
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.
2008-08-02 21:25:31 -04:00
278c3fe2d8 Simplify control flow in ship_bomb(), plane_bomb(), land_bomb()
No functional change.
2008-08-02 21:25:31 -04:00
fcb9c7f546 Remove key 'd' at bomb ship, plane and land unit target prompts
Key 'd' has always been there, but never documented.  Key '~' does the
same, and the prompt mentions it since 4.2.2.  Drop 'd'.
2008-08-02 21:23:07 -04:00
bc805ba81a Fix land unit flak when pin-bombed to match flak when overflown
land_bomb() failed to reduce flak proportional to efficiency.  Missed
in commit c7f68f2e, v4.3.6.

Also change it to round randomly instead of down, to match
ac_landflak().
2008-08-02 18:12:58 -04:00
6a95e67e4f Don't permit bombing of embarked planes and land units
Change planesatxy() not to list embarked planes, plane_bomb() not to
bomb them, and land_bomb() not to bomb embarked land units.

Curiously, embarked land units were not listed as targets before, but
could be bombed all the same.
2008-08-02 17:28:05 -04:00
3a9545fe99 Remove redundant and misleading stuff from info bomb 2008-08-02 17:17:08 -04:00
b7c7fa00e1 Fix capital maintenance to charge at 60% efficiency
produce_sect() started to charge at 61%.  Has always been that way.
2008-08-02 15:46:35 -04:00
def5ef11ff Make launch command require only 40% plane efficiency
This is to make it consistent with automatic missile launch.
2008-08-02 15:03:44 -04:00