Commit graph

33 commits

Author SHA1 Message Date
373651359e Coding style fixes, mostly indentation and whitespace 2010-06-20 18:36:38 +02:00
ad80846283 Fix getpath() not to crash when path exceeds MAX_PATH_LEN
Trivial for players to trigger.  Broken in commit 0b0612ea, v4.3.16.
Spotted by the Clang Static Analyzer.
2010-01-19 08:40:17 +01:00
73e25ff21e Update copyright notice 2010-01-19 08:40:17 +01:00
c528fcbe3e Update known contributors comments 2009-12-13 17:34:28 +01:00
90f8f2b099 Don't use 0 as null pointer constant, part 2
This part replaces E != 0 by E, where E has pointer type.
2009-03-24 21:46:01 +01:00
35ef345ecb Update copyright notice 2009-02-08 09:33:18 +01:00
d702068457 Fix trailing whitespace 2008-09-17 21:31:40 -04:00
db4770426e Update known contributors comments 2008-09-17 18:54:15 -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
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
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
0b0612ea04 Simplify getpath() 2008-07-21 08:13:40 -04:00
db02dda32f Update copyright notice 2008-01-19 10:15:37 +01:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
Ron Koenderink
fa0b12e332 (getpath): Remove check for DIR_MAP.
DIR_MAP is not a value that can be entered by the user.
2006-07-29 17:55:22 +00:00
e42053d928 Break inclusion cycle: prototypes.h and commands.h included each
other.  Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special).  New header types.h to
help avoid inclusion cycles.  Sort include directives.  Remove some
superflous includes.
2006-07-10 06:37:23 +00:00
Ron Koenderink
ca246d0bf9 (getpath): Remove unused local variables. 2006-06-09 00:24:06 +00:00
0ea38208d1 (P_WALKING): Unused, remove.
(getpath): Remove P_WALKING case.
2006-06-04 16:42:36 +00:00
9c2b741b2e (getpath): Supply the missing code for P_SAILING. This makes the sail
command accept destination sectors as well as paths.  Clean up the
case discrimination.
2006-04-05 07:30:41 +00:00
b923c951ed (P_NONE, P_WALKING, P_FLYING, P_SAILING, p_mode): Turn into new
enumeration p_mode.  Users changed.  s_char and register purge.
2006-04-05 07:21:49 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
85a64e9fef (getpath): Fix buffer overflow. Remote hole in commands bomb, drop,
fly, para, reco, sail, sweep.  Old code also screwed up when
getstring() failed, unless player->aborted.  Fixed code is still ugly
and cries for a rewrite.
2005-09-25 18:55:55 +00:00
72c623ee92 (getpath): Fix message when no path to destination sector can be
found.
2005-09-25 17:03:53 +00:00
269913baee (getpath): Parameter showxy makes no sense and is not used. Remove.
Get rid of s_char.  Callers changed.
2005-09-25 17:00:50 +00:00
dfa56cb0ef (diridx): New. Use instead of chkdir() where direction characters
must be valid.  Oopses on bad direction characters.
(pathtoxy, ac_encounter): Bad direction characters used to lead to bad
array subscript and potential disaster.
(pathrange, path): Stop on DIR_STOP as well as on bad direction
characters.  This is just for consistency with other code; DIR_STOP
should occur only last in a path here.
(sail_nav_fleet, nav_ship): No change except for the oops.
2005-09-25 09:49:36 +00:00
6bfdc38df1 (SELL_NOT_DELIV, getdir, chkpath): Unused, remove. 2005-09-25 09:07:31 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
c85f674059 (mcost): Unused, remove. 2004-10-05 18:41:18 +00:00
fac342ed49 Update copyright notice. 2004-09-07 15:07:16 +00:00
9b7adfbecc Indented with src/scripts/indent-emp. 2003-09-02 20:48:48 +00:00
d8b7fdfae1 Import of Empire 4.2.12 2003-08-23 12:23:04 +00:00