]> git.pond.sub.org Git - empserver/commit
Fix bitmap overruns when WORLD_X * WORLD_Y not a multiple of 16
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 28 Feb 2011 05:58:51 +0000 (06:58 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 11 Apr 2011 20:29:12 +0000 (22:29 +0200)
commit88983a1a2e522ff2f62271381b873c164339520a
tree270dce6f03f7827b0733140248da7f3cbda4e45a
parent6c9363cc4f9e2f1e63113608ab01f69fdb1e6659
Fix bitmap overruns when WORLD_X * WORLD_Y not a multiple of 16

World-sized bitmaps were allocated with size WORLD_SZ() / 8, which
expands to (WORLD_X * WORLD_Y / 2) / 8.  The divisions truncate unless
WORLD_X * WORLD_Y is a multiple of 16.  The bitmaps were one byte too
small then.  Bitmap overruns happen when:

* A lookout looks at one of the last sectors of the sector file.
  Besides commands look and llook, this affects navigate and march
  sub-command 'l'.

* Command spy spies into one of the last sectors of the sector file.

* A map or nmap (but not a bmap) shows one of the last sectors of the
  sector file, or a sector that can see one of the last sectors
  (visual range is two sectors at 100% efficiency).  Besides commands
  lmap, map, nmap, pmap, smap, this affects move and transport
  sub-command 'm'.

Diagnosed with valgrind.

Already broken in BSD Empire 1.1 (bitmaps were on the stack then).
src/lib/commands/look.c
src/lib/commands/spy.c
src/lib/subs/maps.c