Home | History | Annotate | only in /src/games/rogue
History log of /src/games/rogue
RevisionDateAuthorComments
 1.4 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.3 13-Mar-2000  soren Fix doubled 'the'.
 1.2 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.22 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.21 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.20 11-Jun-2018  kamil branches: 1.20.2;
Restore the MKGROFF=bo MKCXX=yes build

Mark the documentation in dc(1), gprof(1), rogue(6) and fsck_ffs(8) with
the .roff flag in SUBDIR.

Sponsored by <The NetBSD Foundation>
 1.19 05-Jul-2014  dholland branches: 1.19.22;
Rework /usr/share/doc.

Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.

- Build and install text, ps, pdf, and/or html, not roff sources.

- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.

- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.

- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.

- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)

- Enumerate the .png files groff emits along with html so they can be
installed.

- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
- explicit use of soelim
- refer
- tbl
- pic
- eqn

- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.

- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.

Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.
 1.18 11-Aug-2013  dholland branches: 1.18.2;
WARNS=5
 1.17 06-Feb-2010  he branches: 1.17.6; 1.17.12;
When using -lcurses, you also need -lterminfo.
This fixes the build for sun2, and also builds with LDSTATIC=-static,
since archive libraries don't record inter-library dependencies.
 1.16 01-Jan-2004  jsm Don't use -fwritable-strings. Add one more const.
 1.15 07-Jul-2002  tron Make "rogue" build with "WARNS=2". The necessary patches were supplied
by David A. Holland in PR bin/17498.
 1.14 13-Sep-1999  jsm Remove rogue's old and bit-rotten cut-down version of curses.
 1.13 05-Apr-1999  abs s/SETUIDGAME/SETGIDGAME/ - catch up with the rest of the world.
 1.12 18-Feb-1998  jtc branches: 1.12.2;
Simply include -lcurses instead of -lcurses -ltermcap
 1.11 04-Feb-1998  christos Remove -lcompat; not needed
 1.10 20-Nov-1997  mrg install games that need it setgid.
 1.9 22-Oct-1997  lukem use CPPFLAGS instead of CFLAGS
 1.8 11-Oct-1997  mycroft branches: 1.8.2;
Use bsd.subdir.mk as appropriate.
 1.7 22-Apr-1995  cgd don't forget to install the docs.
 1.6 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.5 22-Dec-1994  cgd specify man pages the new way.
 1.4 01-Apr-1994  cgd don't -g by default
 1.3 10-Nov-1993  cgd new curses update
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.2 20-Nov-1997  mrg pull up from trunk:
- install games files with the correct permissions.
- install games that need it setgid.
 1.8.2.1 08-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.12.2.1 06-Apr-1999  abs Pull up 1.13: Correct SETUIDGAME setting to SETGIDGAME
 1.17.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.2.1 10-Aug-2014  tls Rebase.
 1.19.22.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 13-Sep-1999  jsm Remove rogue's old and bit-rotten cut-down version of curses.
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.9 14-Jan-2008  dholland Whitespace/KNF nits.
 1.8 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.7 07-Aug-2003  agc branches: 1.7.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.6 07-Jul-2002  tron Make "rogue" build with "WARNS=2". The necessary patches were supplied
by David A. Holland in PR bin/17498.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.22.2 23-Mar-2008  matt sync with HEAD
 1.7.22.1 09-Jan-2008  matt sync with HEAD
 1.18 08-Aug-2008  drochner if initscr() fails, exit with a message rather than crash in the
next curses call
 1.17 14-Jan-2008  dholland branches: 1.17.6;
ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.16 14-Jan-2008  dholland Whitespace/KNF nits.
 1.15 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.14 15-Dec-2007  perry convert __attribute__s to applicable cdefs.h macros
 1.13 07-Aug-2003  agc branches: 1.13.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.12 06-Dec-2001  blymn Change deprecated curses call to new equivalent.
 1.11 03-Jul-2000  matt More include additions for exit, abs, strcmp, etc.
 1.10 12-Sep-1999  jsm Security improvements for games (largely from or inspired by OpenBSD).

Games which run setgid from dm, but don't need to, should drop their
privileges at startup.

Games which have a scorefile should open it at startup, then drop all
privileges leaving just the open writable file descriptor. If the
game can invoke subprocesses, this should be made close-on-exec.

Games with scorefiles should make sure they do not get a file
descriptor < 3. (Otherwise, they could get confused and corrupt the
scorefile when using stdin, stdout or stderr.)

Some old setuid revokes from the days of setuid games change into gid
revokes.
 1.9 09-Sep-1999  jsm Check for failure of malloc() and calloc() at various places in the games.
 1.8 08-Sep-1999  jsm Add `__noreturn__' and `__unused__' attributes where appropriate to
the games.

This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).

Most noreturn attributes were previously added in bin/6144, with some
others that were missed then in bin/8082. Previous `unused'
attributes were covered in bin/6557, bin/8058 and other PRs (all these
PRs have already been handled and closed).
 1.7 10-Nov-1998  hubertf constify, per PR 6148
 1.6 27-Jul-1998  mycroft const poisoning.
 1.5 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.4 28-Apr-1995  mycroft Use POSIX tty semantics.
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.22.2 23-Mar-2008  matt sync with HEAD
 1.13.22.1 09-Jan-2008  matt sync with HEAD
 1.17.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.15 26-Aug-2011  dholland Use __dead and __printflike instead of __attribute__.
 1.14 12-Aug-2009  dholland sprinkle static
 1.13 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.12 14-Jan-2008  dholland Whitespace/KNF nits.
 1.11 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.10 14-May-2006  christos branches: 1.10.10;
XXX: GCC uninitialized
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.8 01-Oct-2002  mrg - use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.

tested by simonb.
 1.7 07-Jul-2002  tron Make "rogue" build with "WARNS=2". The necessary patches were supplied
by David A. Holland in PR bin/17498.
 1.6 10-Nov-1998  hubertf branches: 1.6.10; 1.6.12;
constify, per PR 6148
 1.5 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.4 17-May-1997  pk NULL => 0 (Arne Juul; PR#3629)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.1 01-Oct-2002  lukem Pull up revision 1.8 (requested by mrg in ticket #892):
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.
tested by simonb.
 1.6.10.1 02-Oct-2002  itojun games/rogue/inventory.c 1.8
games/rogue/save.c 1.8
games/rogue/message.c 1.9
games/rogue/rogue.h 1.13

Use correctly bounded strings when reloading a saved game. In particular,
do not let the save game file "string length" exceed the amount of space
supplied. As noted by <stanojr@iserver.sk> on bugtraq. Fixes SA#2002-021.

(mrg)
 1.10.10.2 23-Mar-2008  matt sync with HEAD
 1.10.10.1 09-Jan-2008  matt sync with HEAD
 1.10 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.9 14-Jan-2008  dholland Whitespace/KNF nits.
 1.8 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.7 07-Aug-2003  agc branches: 1.7.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.6 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.22.2 23-Mar-2008  matt sync with HEAD
 1.7.22.1 09-Jan-2008  matt sync with HEAD
 1.20 01-Dec-2012  mbalmer Fix misspelling of acceptible (it's only acceptable with an 'a', not an 'i').
 1.19 01-Sep-2011  plunky branches: 1.19.2; 1.19.8;
reinstate NULL cast by request, where the NULL was being passed as a vararg
 1.18 31-Aug-2011  plunky NULL does not need a cast
 1.17 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.16 14-Jan-2008  dholland Whitespace/KNF nits.
 1.15 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.14 24-Apr-2006  snj branches: 1.14.10;
It's "its."
 1.13 15-Feb-2005  jsm Cast last argument of execl to (char *).

Reviewed by <hubertf>.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.11 13-Sep-1999  jsm Remove rogue's old and bit-rotten cut-down version of curses.
 1.10 12-Sep-1999  jsm Security improvements for games (largely from or inspired by OpenBSD).

Games which run setgid from dm, but don't need to, should drop their
privileges at startup.

Games which have a scorefile should open it at startup, then drop all
privileges leaving just the open writable file descriptor. If the
game can invoke subprocesses, this should be made close-on-exec.

Games with scorefiles should make sure they do not get a file
descriptor < 3. (Otherwise, they could get confused and corrupt the
scorefile when using stdin, stdout or stderr.)

Some old setuid revokes from the days of setuid games change into gid
revokes.
 1.9 10-Nov-1998  hubertf constify, per PR 6148
 1.8 27-Jul-1998  mycroft const poisoning.
 1.7 21-Jul-1998  hubertf As per PR bin/5806 by Joseph Myers <jsm28@cam.ac.uk>/lash@tellabs.com:
- Init Random by time, not by pid
- Fix lossage with fire-spitting, monster-killing dragons
 1.6 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.5 28-Apr-1995  mycroft Use POSIX tty semantics.
 1.4 24-Apr-1995  cgd Various changes to make games compile w/o warnings on the alpha:
Include appropriate includes, delete bogus function declarations,
change sizes of variables and casts.
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.10.2 23-Mar-2008  matt sync with HEAD
 1.14.10.1 09-Jan-2008  matt sync with HEAD
 1.19.8.1 25-Feb-2013  tls resync with head
 1.19.2.1 16-Jan-2013  yamt sync with (a bit old) head
 1.9 20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
 1.8 14-Jan-2008  dholland branches: 1.8.6;
ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.7 14-Jan-2008  dholland Whitespace/KNF nits.
 1.6 27-Jan-2004  jsm branches: 1.6.22;
Remove uses of __P.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.1 23-Mar-2008  matt sync with HEAD
 1.8.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.16 01-Aug-2023  mrg fix new GCC 12 warning that can't happen by forcing unsigned context for
values that are always positive by this point.
 1.15 02-May-2021  rillig games: remove trailing whitespace in *.c and *.h
 1.14 12-Aug-2009  dholland sprinkle static
 1.13 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.12 14-Jan-2008  dholland Whitespace/KNF nits.
 1.11 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.10 07-Aug-2003  agc branches: 1.10.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.9 01-Oct-2002  mrg - use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.

tested by simonb.
 1.8 10-Jul-2000  itojun branches: 1.8.2;
printf() pedant - do not pass variable alone, use %s.
idea from openbsd. after looking at freebsd commit msgs from kris@freebsd.
 1.7 10-Nov-1998  hubertf branches: 1.7.10;
constify, per PR 6148
 1.6 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.5 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.4 10-Nov-1993  cgd new curses update
 1.3 10-Aug-1993  mycroft Rewrite special character handling.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.10.1 02-Oct-2002  itojun games/rogue/inventory.c 1.8
games/rogue/save.c 1.8
games/rogue/message.c 1.9
games/rogue/rogue.h 1.13

Use correctly bounded strings when reloading a saved game. In particular,
do not let the save game file "string length" exceed the amount of space
supplied. As noted by <stanojr@iserver.sk> on bugtraq. Fixes SA#2002-021.

(mrg)
 1.8.2.1 01-Oct-2002  lukem Pull up revision 1.9 (requested by mrg in ticket #892):
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.
tested by simonb.
 1.10.22.2 23-Mar-2008  matt sync with HEAD
 1.10.22.1 09-Jan-2008  matt sync with HEAD
 1.18 07-Apr-2025  hgutch Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe@snert.com>
(committed with a small modification of said patch).
 1.17 11-Aug-2013  dholland branches: 1.17.36; 1.17.38;
WARNS=5
 1.16 19-Oct-2009  dholland branches: 1.16.6; 1.16.12;
Fix '=' for '==' in a test. From NAKAJIMA Yoshihiro in PR 42177.
 1.15 12-Aug-2009  dholland sprinkle static
 1.14 14-Jan-2008  dholland branches: 1.14.10; 1.14.16;
ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.13 14-Jan-2008  dholland Whitespace/KNF nits.
 1.12 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.11 30-Mar-2006  jnemeth branches: 1.11.10;
Coverity CID 1287: not checking for error return
 1.10 09-Jun-2005  tron Change marker from "pmppc" to "powerpc" because a NetBSD-macppc build
is also affected.
 1.9 09-Jun-2005  he Add an initialization to placate -Wuninitialized.
Marked with XXXGCC for pmppc (found while compiling for it).
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.7 10-Nov-1998  hubertf constify, per PR 6148
 1.6 11-Sep-1998  hubertf fix prototype of mon_sees(), per PR#5867
 1.5 21-Jul-1998  hubertf As per PR bin/5806 by Joseph Myers <jsm28@cam.ac.uk>/lash@tellabs.com:
- Init Random by time, not by pid
- Fix lossage with fire-spitting, monster-killing dragons
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.10.2 23-Mar-2008  matt sync with HEAD
 1.11.10.1 09-Jan-2008  matt sync with HEAD
 1.14.16.1 21-Apr-2010  matt sync to netbsd-5
 1.14.10.1 09-Dec-2009  snj Pull up following revision(s) (requested by jdarrow in ticket #1186):
games/rogue/monster.c: revision 1.16
Fix '=' for '==' in a test. From NAKAJIMA Yoshihiro in PR 42177.
 1.16.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.38.1 02-Aug-2025  perseant Sync with HEAD
 1.17.36.1 12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).
 1.13 23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.12 12-Aug-2009  dholland sprinkle static
 1.11 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.10 14-Jan-2008  dholland Whitespace/KNF nits.
 1.9 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.8 14-May-2006  christos branches: 1.8.10;
XXX: GCC uninitialized
 1.7 30-Mar-2006  jnemeth Coverity CID 1293: not checking for an error return
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.10.2 23-Mar-2008  matt sync with HEAD
 1.8.10.1 09-Jan-2008  matt sync with HEAD
 1.15 07-Apr-2025  hgutch Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe@snert.com>
(committed with a small modification of said patch).
 1.14 12-Aug-2009  dholland branches: 1.14.56; 1.14.58;
sprinkle static
 1.13 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.12 14-Jan-2008  dholland Whitespace/KNF nits.
 1.11 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.10 30-Mar-2006  jnemeth branches: 1.10.10;
Coverity CID 993: dereference of NULL pointer
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.8 10-Nov-1998  hubertf constify, per PR 6148
 1.7 11-Sep-1998  hubertf fix prototypes, per PR#5867
 1.6 15-Oct-1997  mycroft Better fix for the previous.
 1.5 15-Oct-1997  is make gcc happy on Sparc
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.10.2 23-Mar-2008  matt sync with HEAD
 1.10.10.1 09-Jan-2008  matt sync with HEAD
 1.14.58.1 02-Aug-2025  perseant Sync with HEAD
 1.14.56.1 12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).
 1.12 23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.11 12-Aug-2009  dholland sprinkle static
 1.10 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.9 14-Jan-2008  dholland Whitespace/KNF nits.
 1.8 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.7 07-Aug-2003  agc branches: 1.7.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.6 10-Nov-1998  hubertf constify, per PR 6148
 1.5 11-Sep-1998  hubertf fix prototypes, per PR#5867
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.22.2 23-Mar-2008  matt sync with HEAD
 1.7.22.1 09-Jan-2008  matt sync with HEAD
 1.5 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.4 07-Aug-2003  agc branches: 1.4.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.22.1 23-Mar-2008  matt sync with HEAD
 1.11 06-Apr-2025  hgutch Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().

Pointed out by Anthony C Howe <achowe@snert.com>
 1.10 03-Feb-2019  mrg branches: 1.10.10; 1.10.12;
- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.9 14-Jan-2008  dholland branches: 1.9.68;
ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.8 14-Jan-2008  dholland Whitespace/KNF nits.
 1.7 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.6 07-Aug-2003  agc branches: 1.6.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.2 23-Mar-2008  matt sync with HEAD
 1.6.22.1 09-Jan-2008  matt sync with HEAD
 1.9.68.1 10-Jun-2019  christos Sync with HEAD
 1.10.12.1 02-Aug-2025  perseant Sync with HEAD
 1.10.10.1 12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).
 1.8 12-Aug-2009  dholland sprinkle static
 1.7 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.6 14-Jan-2008  dholland Whitespace/KNF nits.
 1.5 07-Aug-2003  agc branches: 1.5.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.22.1 23-Mar-2008  matt sync with HEAD
 1.9 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.8 14-Jan-2008  dholland Whitespace/KNF nits.
 1.7 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.6 07-Aug-2003  agc branches: 1.6.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.2 23-Mar-2008  matt sync with HEAD
 1.6.22.1 09-Jan-2008  matt sync with HEAD
 1.11 15-Sep-2005  wiz Use standard AUTHORS section header. From YOMURA Masanori in private mail
Sort sections if necessary. Use more/better markup.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.9 26-Apr-2003  wiz Drop a trailing dot. From jmc@openbsd.
 1.8 26-Sep-2002  wiz Lots of minor fixes resulting from reading these man pages in detail.
 1.7 26-Sep-2002  wiz New sentences begin on new lines.
Patch from Richard Elz, slightly improved by yours truly.
 1.6 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.5 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.4 09-Aug-1993  jtc Rogue stores scores in /var/games/rogue.scores, not .../rogue_roll.
 1.3 05-Aug-1993  jtc Convert to -mandoc macros.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25 07-Apr-2025  hgutch Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe@snert.com>
(committed with a small modification of said patch).
 1.24 11-Aug-2013  dholland branches: 1.24.36; 1.24.38;
WARNS=5
 1.23 11-Aug-2013  dholland typo in comment
 1.22 26-Aug-2011  dholland branches: 1.22.2; 1.22.8;
Use __dead and __printflike instead of __attribute__.
 1.21 23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.20 12-Aug-2009  dholland sprinkle static
 1.19 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.18 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.17 15-Feb-2005  jsm branches: 1.17.16;
Avoid arrays of incomplete types (required to build with GCC 4).

Reviewed by <hubertf>.
 1.16 27-Jan-2004  jsm Remove uses of __P.
 1.15 01-Jan-2004  jsm Don't use -fwritable-strings. Add one more const.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.13 01-Oct-2002  mrg - use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.

tested by simonb.
 1.12 05-Feb-2001  christos branches: 1.12.2;
remove duplicate decls
 1.11 13-Sep-1999  jsm branches: 1.11.8;
Remove rogue's old and bit-rotten cut-down version of curses.
 1.10 12-Sep-1999  jsm Security improvements for games (largely from or inspired by OpenBSD).

Games which run setgid from dm, but don't need to, should drop their
privileges at startup.

Games which have a scorefile should open it at startup, then drop all
privileges leaving just the open writable file descriptor. If the
game can invoke subprocesses, this should be made close-on-exec.

Games with scorefiles should make sure they do not get a file
descriptor < 3. (Otherwise, they could get confused and corrupt the
scorefile when using stdin, stdout or stderr.)

Some old setuid revokes from the days of setuid games change into gid
revokes.
 1.9 08-Sep-1999  jsm Add `__noreturn__' and `__unused__' attributes where appropriate to
the games.

This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).

Most noreturn attributes were previously added in bin/6144, with some
others that were missed then in bin/8082. Previous `unused'
attributes were covered in bin/6557, bin/8058 and other PRs (all these
PRs have already been handled and closed).
 1.8 10-Nov-1998  hubertf constify, per PR 6148
 1.7 13-Sep-1998  hubertf mark non-returning functions (PR#6144 by Joseph Myers <jsm28@cam.ac.uk>)
 1.6 27-Jul-1998  mycroft const poisoning.
 1.5 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.4 24-Apr-1995  cgd Various changes to make games compile w/o warnings on the alpha:
Include appropriate includes, delete bogus function declarations,
change sizes of variables and casts.
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.8.1 02-Oct-2002  itojun games/rogue/inventory.c 1.8
games/rogue/save.c 1.8
games/rogue/message.c 1.9
games/rogue/rogue.h 1.13

Use correctly bounded strings when reloading a saved game. In particular,
do not let the save game file "string length" exceed the amount of space
supplied. As noted by <stanojr@iserver.sk> on bugtraq. Fixes SA#2002-021.

(mrg)
 1.12.2.1 01-Oct-2002  lukem Pull up revision 1.13 (requested by mrg in ticket #892):
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.
tested by simonb.
 1.17.16.2 23-Mar-2008  matt sync with HEAD
 1.17.16.1 09-Jan-2008  matt sync with HEAD
 1.22.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.38.1 02-Aug-2025  perseant Sync with HEAD
 1.24.36.1 12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).
 1.14 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.13 12-Aug-2009  dholland branches: 1.13.46;
sprinkle static
 1.12 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.11 14-Jan-2008  dholland Whitespace/KNF nits.
 1.10 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.9 02-Apr-2006  christos branches: 1.9.10;
Coverity CID 2788: If no room gets returned, don't try to place a monster.
 1.8 30-Mar-2006  jnemeth Coverity CID 1288: possible negative array index
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.6 10-Nov-1998  hubertf constify, per PR 6148
 1.5 11-Sep-1998  hubertf fix prototype, per PR#5867
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.10.2 23-Mar-2008  matt sync with HEAD
 1.9.10.1 09-Jan-2008  matt sync with HEAD
 1.13.46.1 10-Jun-2019  christos Sync with HEAD
 1.15 07-Apr-2025  hgutch Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe@snert.com>
(committed with a small modification of said patch).
 1.14 02-May-2021  rillig branches: 1.14.6; 1.14.8;
games: remove trailing whitespace in *.c and *.h
 1.13 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.12 14-Jan-2008  dholland Whitespace/KNF nits.
 1.11 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.10 17-Mar-2006  abs branches: 1.10.10;
Call fclose() appropriately if there is a problem with the save file.
Coverty CID 2063
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.8 01-Oct-2002  mrg - use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.

tested by simonb.
 1.7 18-Sep-1999  jsm branches: 1.7.8; 1.7.10;
Fix -Wsign-compare warnings.
 1.6 13-Sep-1999  jsm Fix buffer overrun in rogue.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.10.1 01-Oct-2002  lukem Pull up revision 1.8 (requested by mrg in ticket #892):
- use correctly bounded strings when reloading a saved game. in particular,
do not let the save game file "string length" exceed the amount of space
supplied. as noted by <stanojr@iserver.sk> on bugtraq.
- minor KNF.
tested by simonb.
 1.7.8.1 02-Oct-2002  itojun games/rogue/inventory.c 1.8
games/rogue/save.c 1.8
games/rogue/message.c 1.9
games/rogue/rogue.h 1.13

Use correctly bounded strings when reloading a saved game. In particular,
do not let the save game file "string length" exceed the amount of space
supplied. As noted by <stanojr@iserver.sk> on bugtraq. Fixes SA#2002-021.

(mrg)
 1.10.10.2 23-Mar-2008  matt sync with HEAD
 1.10.10.1 09-Jan-2008  matt sync with HEAD
 1.14.8.1 02-Aug-2025  perseant Sync with HEAD
 1.14.6.1 12-Apr-2025  martin Pull up following revision(s) (requested by hgutch in ticket #1090):

games/rogue/rogue.h: revision 1.25
games/rogue/play.c: revision 1.11
games/rogue/monster.c: revision 1.18
games/rogue/save.c: revision 1.15
games/rogue/object.c: revision 1.15

Fix segfault when canceling "Quit" operation

When pressing 'Q' followed by anything other than 'y', make sure not to
end up calling __unreachable().
Pointed out by Anthony C Howe <achowe%snert.com@localhost>

Fix loading save files

Both monster and weapon damage are represented as strings like "1d1", and
internally the game keeps track of them as pointers to static strings
in memory. When saving, the game saves these pointers and when loading
them the pointers end up being identical to before - which now points to
undefined memory.

So when loading a save game, reset the damage strings based on the type
of monster or weapon.

Pointed out and fix suggested by Anthony C Howe <achowe%snert.com@localhost>
(committed with a small modification of said patch).
 1.16 26-Aug-2011  dholland Use __dead and __printflike instead of __attribute__.
 1.15 12-Aug-2009  dholland sprinkle static
 1.14 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.13 14-Jan-2008  dholland Whitespace/KNF nits.
 1.12 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.11 07-Aug-2003  agc branches: 1.11.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.10 07-Jul-2002  tron Make "rogue" build with "WARNS=2". The necessary patches were supplied
by David A. Holland in PR bin/17498.
 1.9 09-Aug-2001  wiz Fix for FreeBSD/13278, from FreeBSD:
When a game ends that makes the top 10, the function insert_score in
score.c is called to make the new score file. But the case for KFIRE
(killed by fire) incorrectly uses strcpy instead of strcat (all the
other cases use strcat). This puts the string in the wrong place and
corrupts the score file.
 1.8 12-Sep-1999  jsm Security improvements for games (largely from or inspired by OpenBSD).

Games which run setgid from dm, but don't need to, should drop their
privileges at startup.

Games which have a scorefile should open it at startup, then drop all
privileges leaving just the open writable file descriptor. If the
game can invoke subprocesses, this should be made close-on-exec.

Games with scorefiles should make sure they do not get a file
descriptor < 3. (Otherwise, they could get confused and corrupt the
scorefile when using stdin, stdout or stderr.)

Some old setuid revokes from the days of setuid games change into gid
revokes.
 1.7 10-Nov-1998  hubertf constify, per PR 6148
 1.6 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.5 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.4 10-Nov-1993  cgd new curses update
 1.3 23-Sep-1993  mycroft Use `r+' rather than `a+' when opening score file.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.22.2 23-Mar-2008  matt sync with HEAD
 1.11.22.1 09-Jan-2008  matt sync with HEAD
 1.9 23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.8 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.7 14-Jan-2008  dholland Whitespace/KNF nits.
 1.6 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.5 07-Aug-2003  agc branches: 1.5.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.22.2 23-Mar-2008  matt sync with HEAD
 1.5.22.1 09-Jan-2008  matt sync with HEAD
 1.12 23-May-2011  joerg Kill some pointer indirections. Don't use variables as format strings.
 1.11 12-Aug-2009  dholland sprinkle static
 1.10 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.9 14-Jan-2008  dholland Whitespace/KNF nits.
 1.8 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.7 30-Mar-2006  jnemeth branches: 1.7.10;
Coverity CID 2452: possible negative array index; CID 1518 and CID 1517: possible overrun of static array
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.10.2 23-Mar-2008  matt sync with HEAD
 1.7.10.1 09-Jan-2008  matt sync with HEAD
 1.10 12-Aug-2009  dholland sprinkle static
 1.9 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.8 14-Jan-2008  dholland Whitespace/KNF nits.
 1.7 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.6 07-Aug-2003  agc branches: 1.6.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.2 23-Mar-2008  matt sync with HEAD
 1.6.22.1 09-Jan-2008  matt sync with HEAD
 1.11 02-May-2021  rillig games: remove trailing whitespace in *.c and *.h
 1.10 12-Aug-2009  dholland sprinkle static
 1.9 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.8 14-Jan-2008  dholland Whitespace/KNF nits.
 1.7 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.6 07-Aug-2003  agc branches: 1.6.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.2 23-Mar-2008  matt sync with HEAD
 1.6.22.1 09-Jan-2008  matt sync with HEAD
 1.9 14-Jan-2008  dholland ANSIfy. Remove unnecessary casts. Clean up for -Wsign-compare. Make more
things file-static. Other minor tidyups, and fix a couple minor bugs found
along the way.
 1.8 14-Jan-2008  dholland Whitespace/KNF nits.
 1.7 27-Dec-2007  dholland Comprehensive (or at least extensive) string handling cleanup for rogue.

This patch dates (mostly) back to 2002; the critical parts of it were
handled back then by security-officer. As far as I know, there's
nothing exploitable fixed herein.

A slightly earlier version of this patch was reviewed by Christian Biere
when I filed it as PR 34750.
 1.6 07-Aug-2003  agc branches: 1.6.22;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.5 10-Nov-1998  hubertf constify, per PR 6148
 1.4 12-Oct-1997  lukem WARNSify (not an insignificant task...)
 1.3 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Apr-1995  cgd src/games/rogue from Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.22.2 23-Mar-2008  matt sync with HEAD
 1.6.22.1 09-Jan-2008  matt sync with HEAD
 1.7 05-Jul-2014  dholland Reorg docs, part 1:
Move all the reference manuals to subdirs of /usr/share/doc/reference.
We have subdirs ref1-ref9, corresponding to man page sections 1-9.

Everything that's the reference manual for a program (sections 1, 6,
8), C interface (sections 2, 3), driver or file system (section 4),
format or configuration (section 5), or kernel internal interface
(section 9) belongs in here.

Section 7 is a little less clear: some things that might go in section
7 if they were a man page aren't really reference manuals. So I'm only
putting things in reference section 7 that are (to me) clearly
reference material, rather than e.g. tutorials, guides, FAQs, etc.
This obviously leaves some room for debate, especially without first
editing the docs with this distinction in mind, but if people hate
what I've done things can always be moved again.

Note also that while roff macro man pages traditionally go in section
7, I have put all the roff documentation (macros, tools, etc.) in one
place in reference/ref1/roff. This will make it easier to find and
also easier to edit it into some kind of coherent form.
 1.6 05-Jul-2014  dholland Rework /usr/share/doc.

Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.

- Build and install text, ps, pdf, and/or html, not roff sources.

- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.

- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.

- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.

- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)

- Enumerate the .png files groff emits along with html so they can be
installed.

- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
- explicit use of soelim
- refer
- tbl
- pic
- eqn

- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.

- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.

Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.
 1.5 17-Feb-2013  jmcneill branches: 1.5.6;
rename target paper.${PRINTER} to paper.ps -- PRINTER isnt defined anywhere!
 1.4 10-Jul-2003  lukem branches: 1.4.54; 1.4.60;
Rename a large chunk of the make(1) variables which refer to a
program/tool from "FOO" to "TOOL_FOO". The new variables are:
TOOL_ASN1_COMPILE TOOL_CAP_MKDB TOOL_CAT TOOL_CKSUM TOOL_COMPILE_ET
TOOL_CONFIG TOOL_CRUNCHGEN TOOL_CTAGS TOOL_DB TOOL_EQN TOOL_FGEN
TOOL_GENCAT TOOL_GROFF TOOL_HEXDUMP TOOL_INDXBIB TOOL_INSTALLBOOT
TOOL_INSTALL_INFO TOOL_M4 TOOL_MAKEFS TOOL_MAKEINFO TOOL_MAKEWHATIS
TOOL_MDSETIMAGE TOOL_MENUC TOOL_MKCSMAPPER TOOL_MKESDB
TOOL_MKLOCALE TOOL_MKMAGIC TOOL_MKTEMP TOOL_MSGC TOOL_MTREE
TOOL_PAX TOOL_PIC TOOL_PREPMKBOOTIMAGE TOOL_PWD_MKDB TOOL_REFER
TOOL_ROFF_ASCII TOOL_ROFF_DVI TOOL_ROFF_HTML TOOL_ROFF_PS
TOOL_ROFF_RAW TOOL_RPCGEN TOOL_SOELIM TOOL_SUNLABEL TOOL_TBL
TOOL_UUDECODE TOOL_VGRIND TOOL_ZIC

For each, provide default in <bsd.sys.mk> of the form:
TOOL_FOO?= foo
and for the ${USETOOLS}=="yes" case in <bsd.own.mk>, provide override:
TOOL_FOO= ${TOOLDIR}/bin/${_TOOL_PREFIX}foo

Document all of these in bsd.README.

This cleans up a chunk of potential (and actual) namespace collision
within our build infrastructure, as well as improves consistency in
the share/mk documentation and provision of appropriate defaults for
each of these variables.
 1.3 05-Jan-2003  pooka Add ${MACROS} to ${ROFF} usage to make output readable

from jbernard@mines.edu in misc/19685
 1.2 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.1 22-Apr-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 22-Apr-1995  cgd src/games/rogue from Lite
 1.4.60.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.60.1 25-Feb-2013  tls resync with head
 1.4.54.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.6.1 10-Aug-2014  tls Rebase.
 1.6 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.4 09-Aug-2001  wiz Fix pasto. From FreeBSD.
 1.3 07-Jan-1997  tls Sync to 4.4BSD-Lite2
 1.2 22-Apr-1995  cgd clean up import, NetBSD RCS Ids
 1.1 22-Apr-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 28-Dec-1996  tls Import from 4.4BSD-Lite2
 1.1.1.1 22-Apr-1995  cgd src/games/rogue from Lite

RSS XML Feed