mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
new upstream
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@10080 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
47
COPYING
47
COPYING
@@ -102,11 +102,11 @@ These terms also apply to "hunt/Makeconfig", which is derived from the
|
||||
hunt "Makefile.inc" distributed by NetBSD.
|
||||
|
||||
The files "backgammon/backgammon/backlocal.h", "countmail/countmail",
|
||||
"hack/extern.h", "robots/auto.c", "sail/display.h" and
|
||||
"sail/restart.h" have a similar licence, but copyright is held by the
|
||||
NetBSD Foundation:
|
||||
"dm/utmpentry.c", "dm/utmpentry.h", "hack/extern.h", "robots/auto.c",
|
||||
"sail/display.h", "sail/restart.h" and the game "dab" have a similar
|
||||
licence, but copyright is held by the NetBSD Foundation:
|
||||
|
||||
Copyright (c) 1997, 1998, 1999, 2001 The NetBSD Foundation, Inc.
|
||||
Copyright (c) 1997, 1998, 1999, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -137,6 +137,32 @@ NetBSD Foundation:
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
In the case of "dab/dab.6", the copyright is held by Thomas Klausner:
|
||||
|
||||
Copyright (c) 2003 Thomas Klausner.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
In the case of "adventure/extern.h" the copyright is held by Christos
|
||||
Zoulas:
|
||||
|
||||
@@ -361,7 +387,7 @@ insofar as they get compiled into the games; note that the include
|
||||
files are probably irrelevant for this purpose as it is unlikely they
|
||||
are significant enough to make any binary a derived work).
|
||||
|
||||
Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Joseph Samuel Myers.
|
||||
Copyright (c) 1997-2004 Joseph Samuel Myers.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -400,16 +426,15 @@ qualify for copyright; but if not, then the terms given above apply
|
||||
(and, of course, running the test command gives an identical output
|
||||
file to which you could apply your own copyright).
|
||||
|
||||
The files "bsd-games.lsm", "ChangeLog.0", "THANKS", "INSTALL",
|
||||
"README", "TODO", "boggle/README.linux", "fortune/README.linux", and
|
||||
"hunt/README.linux" are still significantly derived from files in the
|
||||
original bsd-games package for Linux by Curt Olson and Andy Tefft. It
|
||||
is expected that the following terms will apply to these files, and to
|
||||
The files "bsd-games.lsm", "ChangeLog.0", "THANKS", "INSTALL" and
|
||||
"README" are still significantly derived from files in the original
|
||||
bsd-games package for Linux by Curt Olson and Andy Tefft. It is
|
||||
expected that the following terms will apply to these files, and to
|
||||
the compilation copyright on the package as a whole; ***this has yet
|
||||
to be confirmed with Andy Tefft***:
|
||||
|
||||
Copyright (c) 1993 Curt Olson, Andy Tefft.
|
||||
Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Joseph Samuel Myers.
|
||||
Copyright (c) 1997-2004 Joseph Samuel Myers.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
245
ChangeLog
245
ChangeLog
@@ -1,3 +1,248 @@
|
||||
2004-02-13 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* NEWS, bsd-games.lsm, bsd-games-non-free.lsm: Update.
|
||||
|
||||
* morse/morse.c: Update from NetBSD CVS.
|
||||
|
||||
* morse/morse.c: Encode and decode more characters. Don't put
|
||||
commas after every character. Don't encode whitespace as "...".
|
||||
Don't fail decoding across a 1024-byte boundary. Mark end of
|
||||
message appropriately. From OpenBSD but with punctuation taken
|
||||
from ITU-T Recommendation F.1 (03/98).
|
||||
* tests/morse.testsent, tests/morse.testsentd: New tests.
|
||||
* tests/morse.SOS, tests/morse.foo, tests/morse.sos: Update.
|
||||
* tests/morse.test: Update.
|
||||
|
||||
2004-02-11 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* tests/pom.2003fm1, tests/pom.2003fm2, tests/pom.2003fq1,
|
||||
tests/pom.2003fq2, tests/pom.2003lq1, tests/pom.2003lq2,
|
||||
tests/pom.2003nm1, tests/pom.2003nm2, tests/pom.2003ph1,
|
||||
tests/pom.2003ph2, tests/pom.2003ph3, tests/pom.2003ph4,
|
||||
tests/pom.2003ph5, tests/pom.2003ph6, tests/pom.2003ph7,
|
||||
tests/pom.2003ph8: New tests.
|
||||
* tests/pom.test: Update.
|
||||
|
||||
2004-02-10 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* primes/primes.6: Update from NetBSD CVS.
|
||||
|
||||
2004-02-09 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* configure: Ask for a documentation directory if building trek or
|
||||
rogue.
|
||||
* Makeconfig.in (DOCDIR): Define.
|
||||
* substfiles2: Add trek/trek.6.
|
||||
* trek/trek.6: Rename to trek/trek.6.in.
|
||||
* trek/trek.6.in: Mark documentation directory for substitution.
|
||||
* rogue/Makefrag, trek/Makefrag: Install USD documents.
|
||||
* INSTALL, PACKAGING, README: Update.
|
||||
|
||||
2004-02-08 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* backgammon/backgammon/main.c, backgammon/teachgammon/teach.c,
|
||||
cribbage/cribbage.h, dm/dm.c, fortune/unstr/unstr.c,
|
||||
hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/huntd/faketalk.c,
|
||||
hunt/huntd/hunt.h, phantasia/Makefile.bsd, rain/rain.c,
|
||||
worms/worms.c: Update from NetBSD CVS.
|
||||
|
||||
* rain/rain.c, worms/worms.c: Hide the cursor with curs_set(0).
|
||||
From OpenBSD.
|
||||
|
||||
* tests/factor.8675309, tests/factor.6172538568: New tests (from
|
||||
NetBSD src/regress).
|
||||
* tests/factor.test: Update.
|
||||
|
||||
* boggle/README.linux, dm/README.linux, fortune/README.linux,
|
||||
hunt/README.linux, trek/README.linux: Remove.
|
||||
* README: Move information from those files to here.
|
||||
* INSTALL: Update.
|
||||
* COPYING: Update.
|
||||
|
||||
* factor/Makefile.bsd, factor/factor.6, factor/factor.c,
|
||||
primes/Makefile.bsd, primes/primes.6: Update from NetBSD CVS.
|
||||
|
||||
* TODO: Update.
|
||||
|
||||
* substscr: Explicitly set execute permissions from those of
|
||||
source file.
|
||||
|
||||
* primes/primes.6: Separate manpage from that of factor.
|
||||
* primes/Makefrag: Update.
|
||||
* factor/factor.6: Change to be a manpage for factor only.
|
||||
|
||||
* factor/factor.c: Only use Pollard p-1 if remaining factor isn't
|
||||
prime. Correct comment. Increase base if p-1 algorithm reaches
|
||||
1.
|
||||
* tests/factor.2147483647111311, tests/factor.99999999999991: New
|
||||
tests.
|
||||
* tests/factor.test: Update.
|
||||
Bugs reported by David A Bagley <bagleyd@tux.org>.
|
||||
|
||||
* countmail/countmail.6, phantasia/fight.c, phantasia/io.c,
|
||||
sail/extern.h, sail/misc.c, snake/snake/snake.c: Update from
|
||||
NetBSD CVS.
|
||||
|
||||
2004-01-27 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* dab/.cvsignore: New file.
|
||||
|
||||
* Makeconfig.in: Add STRLCPY_DEFS and GETPROGNAME_DEFS.
|
||||
* arithmetic/Makefrag, fortune/fortune/Makefrag, rogue/Makefrag:
|
||||
Use them.
|
||||
|
||||
* dm/utmpentry.c, dm/utmpentry.h: New from NetBSD CVS of
|
||||
usr.bin/who.
|
||||
* COPYING: Update.
|
||||
* dm/dm.c: Follow NetBSD in use of this utmp handling.
|
||||
* dm/Makefrag: Update.
|
||||
* exec.objs: Update.
|
||||
|
||||
* lib/getprogname.c: New file.
|
||||
* include/stdlib.h: Update.
|
||||
* configure: Check for getprogname.
|
||||
* arithmetic/arithmetic.c, fortune/fortune/fortune.c: Follow
|
||||
NetBSD in use of getprogname().
|
||||
* exec.objs: Update.
|
||||
|
||||
* adventure/extern.h, adventure/main.c, arithmetic/arithmetic.c,
|
||||
atc/extern.h, atc/input.c, backgammon/backgammon/backlocal.h,
|
||||
backgammon/backgammon/move.c, backgammon/common_source/back.h,
|
||||
backgammon/teachgammon/tutor.h, banner/banner.c,
|
||||
battlestar/battlestar.c, battlestar/extern.h, battlestar/fly.c,
|
||||
battlestar/init.c, battlestar/parse.c, bcd/bcd.c,
|
||||
boggle/boggle/bog.c, boggle/boggle/extern.h, boggle/boggle/mach.c,
|
||||
boggle/boggle/prtable.c, boggle/boggle/timer.c, caesar/caesar.c,
|
||||
canfield/canfield/canfield.c, canfield/cfscores/cfscores.c,
|
||||
cribbage/crib.c, cribbage/cribbage.h, dm/dm.c, fish/fish.c,
|
||||
fortune/fortune/fortune.c, fortune/unstr/unstr.c, gomoku/gomoku.h,
|
||||
gomoku/main.c, gomoku/pickmove.c, hack/def.func_tab.h,
|
||||
hack/extern.h, hack/hack.apply.c, hack/hack.do.c, hack/hack.h,
|
||||
hack/hack.invent.c, hack/hack.main.c, hack/hack.shk.c,
|
||||
hack/hack.vault.c, hack/hack.zap.c, hangman/hangman.h,
|
||||
hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/hunt/playit.c,
|
||||
hunt/huntd/driver.c, hunt/huntd/execute.c, hunt/huntd/expl.c,
|
||||
hunt/huntd/faketalk.c, hunt/huntd/hunt.h, hunt/huntd/makemaze.c,
|
||||
hunt/huntd/shots.c, hunt/huntd/talk_ctl.h, mille/mille.h,
|
||||
mille/table.c, mille/varpush.c, monop/cards.c, monop/execute.c,
|
||||
monop/getinp.c, monop/houses.c, monop/malloc.c, monop/monop.c,
|
||||
monop/monop.def, monop/monop.ext, monop/monop.h, monop/morg.c,
|
||||
monop/print.c, monop/prop.c, monop/trade.c, morse/morse.c,
|
||||
number/number.c, pig/pig.c, pom/pom.c, ppt/ppt.c, primes/primes.c,
|
||||
quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, rain/rain.c,
|
||||
random/random.c, robots/auto.c, robots/main.c, robots/robots.h,
|
||||
robots/score.c, rogue/main.c, rogue/rogue.h, sail/extern.h,
|
||||
sail/pl_1.c, sail/sync.c, snake/snake/snake.c,
|
||||
snake/snscore/snscore.c, tetris/input.h, tetris/scores.c,
|
||||
tetris/scores.h, tetris/screen.c, tetris/screen.h,
|
||||
tetris/tetris.c, tetris/tetris.h, trek/compkl.c, trek/computer.c,
|
||||
trek/dumpgame.c, trek/getpar.c, trek/getpar.h, trek/main.c,
|
||||
trek/torped.c, trek/trek.h, worm/worm.c, worms/worms.c,
|
||||
wump/wump.c: Update from NetBSD CVS.
|
||||
|
||||
* adventure/extern.h, adventure/main.c, arithmetic/arithmetic.c,
|
||||
atc/extern.h, atc/input.c, backgammon/backgammon/backlocal.h,
|
||||
backgammon/backgammon/move.c, backgammon/common_source/back.h,
|
||||
backgammon/teachgammon/tutor.h, banner/banner.c,
|
||||
battlestar/battlestar.c, battlestar/extern.h, battlestar/fly.c,
|
||||
battlestar/init.c, battlestar/parse.c, bcd/bcd.c,
|
||||
boggle/boggle/bog.c, boggle/boggle/extern.h, boggle/boggle/mach.c,
|
||||
boggle/boggle/prtable.c, boggle/boggle/timer.c, caesar/caesar.c,
|
||||
canfield/canfield/canfield.c, canfield/cfscores/cfscores.c,
|
||||
cribbage/crib.c, cribbage/cribbage.h, dm/dm.c, fish/fish.c,
|
||||
fortune/fortune/fortune.c, fortune/unstr/unstr.c, gomoku/gomoku.h,
|
||||
gomoku/main.c, hack/def.func_tab.h, hack/extern.h,
|
||||
hack/hack.apply.c, hack/hack.do.c, hack/hack.h,
|
||||
hack/hack.invent.c, hack/hack.main.c, hack/hack.shk.c,
|
||||
hack/hack.vault.c, hack/hack.zap.c, hangman/hangman.h,
|
||||
hunt/hunt/hunt.c, hunt/hunt/otto.c, hunt/hunt/playit.c,
|
||||
hunt/huntd/driver.c, hunt/huntd/execute.c, hunt/huntd/expl.c,
|
||||
hunt/huntd/faketalk.c, hunt/huntd/hunt.h, hunt/huntd/makemaze.c,
|
||||
hunt/huntd/shots.c, hunt/huntd/talk_ctl.h, mille/mille.h,
|
||||
mille/table.c, mille/varpush.c, monop/cards.c, monop/execute.c,
|
||||
monop/getinp.c, monop/houses.c, monop/monop.c, monop/monop.def,
|
||||
monop/monop.ext, monop/monop.h, monop/morg.c, monop/print.c,
|
||||
monop/prop.c, monop/trade.c, monop/malloc.c, morse/morse.c,
|
||||
number/number.c, pig/pig.c, pom/pom.c, ppt/ppt.c, primes/primes.c,
|
||||
quiz/quiz.c, quiz/quiz.h, quiz/rxp.c, rain/rain.c,
|
||||
random/random.c, robots/auto.c, robots/main.c, robots/robots.h,
|
||||
robots/score.c, rogue/main.c, rogue/rogue.h, snake/snake/snake.c,
|
||||
snake/snscore/snscore.c, tetris/input.h, tetris/scores.c,
|
||||
tetris/scores.h, tetris/screen.c, tetris/screen.h,
|
||||
tetris/tetris.c, tetris/tetris.h, trek/compkl.c, trek/computer.c,
|
||||
trek/dumpgame.c, trek/getpar.c, trek/getpar.h, trek/main.c,
|
||||
trek/torped.c, trek/trek.h, worm/worm.c, worms/worms.c,
|
||||
wump/wump.c: Remove uses of __P.
|
||||
|
||||
* THANKS: Mention David A Bagley.
|
||||
|
||||
* sail/pl_1.c (child): Use int for wait status.
|
||||
|
||||
* gomoku/gomoku.h, robots/robots.h, sail/extern.h, sail/misc.c,
|
||||
sail/sync.c: Adjust system header includes.
|
||||
|
||||
* fortune/fortune/fortune.6.in: Update substitution for path to
|
||||
fortunes directory.
|
||||
|
||||
* cribbage/crib.c, cribbage/cribbage.h, cribbage/io.c,
|
||||
dab/Makefile.bsd, monop/misc.c, monop/monop.def, monop/monop.ext:
|
||||
Update from NetBSD CVS.
|
||||
|
||||
2004-01-26 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* sail/main.c: Reorder includes to match NetBSD.
|
||||
|
||||
* cribbage/cribbage.h, cribbage/crib.c, cribbage/io.c: Rename
|
||||
receive_int to receive_intr.
|
||||
|
||||
* hack/hack.pri.c: Fix typo in merge from NetBSD.
|
||||
|
||||
* configure: Consistently use balanced parentheses in case
|
||||
statements.
|
||||
|
||||
2004-01-25 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* monop/misc.c, monop/monop.def, monop/monop.ext: Rename yn to
|
||||
yncoms.
|
||||
|
||||
* cribbage/cribbage.h, cribbage/crib.c, cribbage/io.c: Rename rint
|
||||
to receive_int.
|
||||
|
||||
* fortune/fortune/fortune.c: Add test for __CYGWIN__.
|
||||
* configure: Test for sig_t.
|
||||
* include/signal.h: Use it.
|
||||
Cygwin issues reported by David A Bagley <bagleyd@tux.org>.
|
||||
|
||||
2004-01-16 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS.
|
||||
|
||||
2004-01-14 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* wtf/acronyms, wtf/acronyms.comp: Update from NetBSD CVS.
|
||||
|
||||
2004-01-04 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* COPYING: Note that TODO no longer contains anything from the
|
||||
original bsd-games 1.3.
|
||||
|
||||
* phantasia/phantasia.6, wtf/acronyms, wtf/acronyms.comp: Update
|
||||
from NetBSD CVS.
|
||||
|
||||
2004-01-02 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* atc/atc.6.in, backgammon/backgammon/main.c,
|
||||
backgammon/teachgammon/data.c, caesar/caesar.c,
|
||||
fortune/datfiles/fortunes, fortune/datfiles/fortunes2,
|
||||
fortune/fortune/fortune.c, hack/hack.options.c, phantasia/main.c,
|
||||
phantasia/misc.c, rogue/Makefile.bsd, rogue/rogue.h,
|
||||
wargames/wargames.6, worm/worm.6, wtf/acronyms: Update from NetBSD
|
||||
CVS.
|
||||
* dab: New directory from NetBSD CVS.
|
||||
* COPYING, INSTALL, README, bsd-games.lsm, Makeconfig.in,
|
||||
configure, exec.libs, exec.objs: Update.
|
||||
* dab/Makefrag: New file.
|
||||
|
||||
2003-12-18 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* Version 2.15.
|
||||
|
||||
20
INSTALL
20
INSTALL
@@ -23,17 +23,15 @@ the bsd-games-non-free package unpacks conventionally into a directory
|
||||
of its own. It can be built separately from bsd-games, or in the same
|
||||
source directory: to do the latter, move those files and directories
|
||||
that are in bsd-games-non-free but not bsd-games into the
|
||||
bsd-games-VERSION directory before building. If you are building
|
||||
bsd-games, cd to boggle and decide if you want -DNEW_STYLE or not --
|
||||
see boggle/README.linux for more information. If you are in a hurry,
|
||||
don't worry about it ... it really is more of an aesthetic thing.
|
||||
bsd-games-VERSION directory before building.
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
You need the following to build this distribution:
|
||||
|
||||
* GCC (the C compiler only - other languages not needed).
|
||||
* GCC (the C and C++ compilers only - other languages not needed; C++
|
||||
only needed for dab).
|
||||
|
||||
* glibc 2.3 or later. Older versions will not work (at least for
|
||||
hunt) since they lack the <ifaddrs.h> header.
|
||||
@@ -161,13 +159,7 @@ Building and installation
|
||||
this or a later version, and a new one created with the correct
|
||||
permissions.
|
||||
|
||||
10. You may wish to do something with the BSD Users' Supplementary
|
||||
Documents for trek and rogue, in trek/USD.doc/trek.me and
|
||||
rogue/USD.doc/rogue.me. You can look at them on a text terminal
|
||||
with "nroff -me" (piped to your pager), or format in PostScript
|
||||
for printing with "groff -me -Tps".
|
||||
|
||||
11. "make distclean" will restore the source directory to the original
|
||||
10. "make distclean" will restore the source directory to the original
|
||||
unpacked state. The automatically generated dependency files
|
||||
include paths to system headers, including those in gcc's internal
|
||||
header directory: if you have changed your compiler or library
|
||||
@@ -180,10 +172,6 @@ Building and installation
|
||||
Further information
|
||||
===================
|
||||
|
||||
Some subdirectories have README.linux files. If you are still having
|
||||
trouble with a program, check this file first -- it may contain some
|
||||
helpful hints, or information about further configuration options.
|
||||
|
||||
See TODO for information on what needs to be improved in this package;
|
||||
you may want to volunteer for some of the things in there.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makeconfig.in - configuration included in Makefiles after substitution.
|
||||
#
|
||||
# Copyright (c) 1997, 1998, 1999, 2000, 2003 Joseph Samuel Myers.
|
||||
# Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -50,6 +50,8 @@ MAN8DIR := @man8dir@
|
||||
MAN5DIR := @man5dir@
|
||||
# Constant data (arch-independent)
|
||||
SHAREDIR := @sharedir@
|
||||
# Miscellaneous documentation
|
||||
DOCDIR := @docdir@
|
||||
# Variable data
|
||||
VARLIBDIR := @varlibdir@
|
||||
# Directory for hidden games (dm)
|
||||
@@ -83,12 +85,17 @@ HIDE_GAME := @hidegame@
|
||||
|
||||
# Compilation details
|
||||
CC := @cc@
|
||||
CXX := @cxx@
|
||||
OPTIMIZE := @optimize_flags@
|
||||
WARNING := @warning_flags@
|
||||
CXX_WARNING := @cxx_warning_flags@
|
||||
CFLAGS := $(OPTIMIZE) $(WARNING) @other_cflags@
|
||||
CXXFLAGS := $(OPTIMIZE) $(CXX_WARNING) @other_cflags@
|
||||
LDFLAGS := @other_ldflags@
|
||||
FGETLN_DEFS := @fgetln_defs@
|
||||
GETLOADAVG_DEFS := @getloadavg_defs@
|
||||
STRLCPY_DEFS := @strlcpy_defs@
|
||||
GETPROGNAME_DEFS := @getprogname_defs@
|
||||
NCURSES_LIB := @ncurses_lib@
|
||||
NCURSES_INCS := @ncurses_includes@
|
||||
OPENSSL_LIB := @openssl_lib@
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.20 2002/06/16 22:24:00 itojun Exp $
|
||||
# $NetBSD: Makefile,v 1.21 2003/12/26 17:59:13 christos Exp $
|
||||
# @(#)Makefile 8.3 (Berkeley) 7/24/94
|
||||
|
||||
# Missing: ching dungeon warp
|
||||
@@ -6,8 +6,8 @@
|
||||
# Don't belong: xneko xroach
|
||||
|
||||
SUBDIR= adventure arithmetic atc backgammon banner battlestar bcd boggle \
|
||||
caesar canfield countmail cribbage dm factor fish fortune gomoku hack \
|
||||
hangman hunt larn mille monop morse number phantasia pig pom ppt \
|
||||
caesar canfield countmail cribbage dab dm factor fish fortune gomoku \
|
||||
hack hangman hunt larn mille monop morse number phantasia pig pom ppt \
|
||||
primes quiz rain random robots rogue sail snake tetris trek wargames \
|
||||
worm worms wtf wump
|
||||
|
||||
|
||||
16
NEWS
16
NEWS
@@ -11,6 +11,22 @@ changes in installation instructions. Packagers should also reread
|
||||
the PACKAGING file each version (or do a diff between the old and new
|
||||
versions of the package and read that).
|
||||
|
||||
Version 2.16 (2004-02-13)
|
||||
============
|
||||
|
||||
* Updated from NetBSD CVS of 2004-02-12. Includes a new game, dab
|
||||
(Dots and Boxes), written in C++.
|
||||
|
||||
* Supplementary documentation for trek and rogue now installed
|
||||
automatically (in a configurable directory).
|
||||
|
||||
* Some changes for portability to Cygwin, thanks to David A Bagley
|
||||
<bagleyd@tux.org>; more portability issues remain.
|
||||
|
||||
* Various improvements to morse from OpenBSD.
|
||||
|
||||
* Some bugs fixed, some backlogged.
|
||||
|
||||
Version 2.15 (2003-12-18)
|
||||
============
|
||||
|
||||
|
||||
@@ -50,12 +50,7 @@ may wish to provide a security-hardened system by giving each setgid
|
||||
game its own group so bugs in one do not affect others.
|
||||
|
||||
You may wish to include auxiliary documentation for users, such as the
|
||||
BSD Users' Supplementary Documents for trek and rogue
|
||||
(trek/USD.doc/trek.me and rogue/USD.doc/rogue.me, or formatted
|
||||
versions thereof), the AUTHORS and THANKS files, and the year 2000
|
||||
statement YEAR2000. Note that the trek manpage contains a reference
|
||||
to /usr/doc/trek, which should be updated to point to where you put
|
||||
trek.me or a formatted version.
|
||||
AUTHORS and THANKS files and the year 2000 statement YEAR2000.
|
||||
|
||||
Assuming you distribute source for your package (I do not believe any
|
||||
of the games have licences requiring this), and separate your patches
|
||||
|
||||
30
README
30
README
@@ -21,8 +21,7 @@ The games are mostly not enhanced from the NetBSD versions, but many
|
||||
bugs are fixed.
|
||||
|
||||
For installation instructions and details of prerequisites, see the
|
||||
file "INSTALL". Some games have "README.linux" files you may wish to
|
||||
read.
|
||||
file "INSTALL".
|
||||
|
||||
The statement of year 2000 issues associated with bsd-games and
|
||||
bsd-games-non-free is in the file "YEAR2000".
|
||||
@@ -50,6 +49,7 @@ caesar: reads fortunes from the game fortune, also some internet posts
|
||||
canfield: curses-based solitaire
|
||||
countmail: tell you how much new mail you have
|
||||
cribbage: cribbage
|
||||
dab: dots and boxes
|
||||
dm: dungeon master, regulates games playing
|
||||
factor: factor a number
|
||||
fish: go fish
|
||||
@@ -103,6 +103,32 @@ with the workings of any particular program, whereas you will be if
|
||||
you have been tracing and fixing a bug. The GCC info manual contains
|
||||
a discussion of how to produce good bug reports.
|
||||
|
||||
Notes on specific games:
|
||||
|
||||
boggle: by default this game compiles with certain Linux improvements;
|
||||
if you want the original BSD behaviour, remove -DNEW_STYLE from the
|
||||
boggle_boggle_DEFS in boggle/boggle/Makefrag. Defining NEW_STYLE will
|
||||
provide a more intuitive way of quitting or playing a new game after
|
||||
time has run out.
|
||||
|
||||
dm: the "dungeon master", a program that allows you to control when
|
||||
users can play games. (Note that this does not control any private
|
||||
copies of games they may have.) I do not claim that this program is
|
||||
actually useful, but it is included in bsd-games since it is in
|
||||
NetBSD. Add -DLOG to the DEFS in dm/Makefrag if you want logging of
|
||||
games playing (not regularly tested).
|
||||
|
||||
fortune: Another enhanced version is available from
|
||||
<ftp://ibiblio.org/pub/Linux/games/amusements/fortune/fortune-mod-9708.tar.gz>.
|
||||
unstr is not installed by default. If you want to install it,
|
||||
uncomment the relevant lines (installation command and definition of
|
||||
fortune_unstr_DIRS) in fortune/unstr/Makefrag before doing the top
|
||||
level "make install".
|
||||
|
||||
hunt: may well be unreliable or broken in various ways. There is some
|
||||
local configuration possible in hunt/Makeconfig but changing this may
|
||||
well break things.
|
||||
|
||||
Joseph S. Myers
|
||||
jsm@polyomino.org.uk
|
||||
|
||||
|
||||
4
THANKS
4
THANKS
@@ -12,6 +12,10 @@ in this list.
|
||||
|
||||
For recent work (since 1.3), thanks to:
|
||||
|
||||
David A Bagley <bagleyd@tux.org>
|
||||
|
||||
For work towards portability to Cygwin.
|
||||
|
||||
Joey Hess <joeyh@debian.org>
|
||||
|
||||
For the Debian patches, which covered what was needed to make the games
|
||||
|
||||
2
TODO
2
TODO
@@ -47,8 +47,6 @@ those. The issues listed there are not included in this list.
|
||||
has some; Paul Janzen is adding FreeBSD changes to
|
||||
OpenBSD, so they may reach me that way.
|
||||
|
||||
1998-09-04 - dm should not access the utmp file directly.
|
||||
|
||||
1998-09-11 - Move building of more files in which configuration
|
||||
variables are substituted from the configure script into
|
||||
the Makefiles.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.9 1998/09/13 15:21:37 hubertf Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.10 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
@@ -32,99 +32,99 @@
|
||||
#include <string.h>
|
||||
|
||||
/* crc.c */
|
||||
void crc_start __P((void));
|
||||
unsigned long crc __P((const char *, int));
|
||||
void crc_start(void);
|
||||
unsigned long crc(const char *, int);
|
||||
|
||||
/* done.c */
|
||||
int score __P((void));
|
||||
void done __P((int)) __attribute__((__noreturn__));
|
||||
void die __P((int));
|
||||
int score(void);
|
||||
void done(int) __attribute__((__noreturn__));
|
||||
void die(int);
|
||||
|
||||
/* init.c */
|
||||
void init __P((void));
|
||||
char *decr __P((int, int, int, int, int));
|
||||
void linkdata __P((void));
|
||||
void trapdel __P((int));
|
||||
void startup __P((void));
|
||||
void init(void);
|
||||
char *decr(int, int, int, int, int);
|
||||
void linkdata(void);
|
||||
void trapdel(int);
|
||||
void startup(void);
|
||||
|
||||
/* io.c */
|
||||
void getin __P((char **, char **));
|
||||
int yes __P((int, int, int));
|
||||
int yesm __P((int, int, int));
|
||||
int next __P((void));
|
||||
void rdata __P((void));
|
||||
int rnum __P((void));
|
||||
void rdesc __P((int));
|
||||
void rtrav __P((void));
|
||||
void getin(char **, char **);
|
||||
int yes(int, int, int);
|
||||
int yesm(int, int, int);
|
||||
int next(void);
|
||||
void rdata(void);
|
||||
int rnum(void);
|
||||
void rdesc(int);
|
||||
void rtrav(void);
|
||||
#ifdef DEBUG
|
||||
void twrite __P((int));
|
||||
void twrite(int);
|
||||
#endif
|
||||
void rvoc __P((void));
|
||||
void rlocs __P((void));
|
||||
void rdflt __P((void));
|
||||
void rliq __P((void));
|
||||
void rhints __P((void));
|
||||
void rspeak __P((int));
|
||||
void mspeak __P((int));
|
||||
void rvoc(void);
|
||||
void rlocs(void);
|
||||
void rdflt(void);
|
||||
void rliq(void);
|
||||
void rhints(void);
|
||||
void rspeak(int);
|
||||
void mspeak(int);
|
||||
struct text;
|
||||
void speak __P((const struct text *));
|
||||
void pspeak __P((int, int));
|
||||
void speak(const struct text *);
|
||||
void pspeak(int, int);
|
||||
|
||||
/* save.c */
|
||||
int save __P((const char *));
|
||||
int restore __P((const char *));
|
||||
int save(const char *);
|
||||
int restore(const char *);
|
||||
|
||||
/* subr.c */
|
||||
int toting __P((int));
|
||||
int here __P((int));
|
||||
int at __P((int));
|
||||
int liq2 __P((int));
|
||||
int liq __P((void));
|
||||
int liqloc __P((int));
|
||||
int bitset __P((int, int));
|
||||
int forced __P((int));
|
||||
int dark __P((void));
|
||||
int pct __P((int));
|
||||
int fdwarf __P((void));
|
||||
int march __P((void));
|
||||
int mback __P((void));
|
||||
int specials __P((void));
|
||||
int trbridge __P((void));
|
||||
void badmove __P((void));
|
||||
void bug __P((int)) __attribute__((__noreturn__));
|
||||
void checkhints __P((void));
|
||||
int trsay __P((void));
|
||||
int trtake __P((void));
|
||||
int dropper __P((void));
|
||||
int trdrop __P((void));
|
||||
int tropen __P((void));
|
||||
int trkill __P((void));
|
||||
int trtoss __P((void));
|
||||
int trfeed __P((void));
|
||||
int trfill __P((void));
|
||||
void closing __P((void));
|
||||
void caveclose __P((void));
|
||||
int toting(int);
|
||||
int here(int);
|
||||
int at(int);
|
||||
int liq2(int);
|
||||
int liq(void);
|
||||
int liqloc(int);
|
||||
int bitset(int, int);
|
||||
int forced(int);
|
||||
int dark(void);
|
||||
int pct(int);
|
||||
int fdwarf(void);
|
||||
int march(void);
|
||||
int mback(void);
|
||||
int specials(void);
|
||||
int trbridge(void);
|
||||
void badmove(void);
|
||||
void bug(int) __attribute__((__noreturn__));
|
||||
void checkhints(void);
|
||||
int trsay(void);
|
||||
int trtake(void);
|
||||
int dropper(void);
|
||||
int trdrop(void);
|
||||
int tropen(void);
|
||||
int trkill(void);
|
||||
int trtoss(void);
|
||||
int trfeed(void);
|
||||
int trfill(void);
|
||||
void closing(void);
|
||||
void caveclose(void);
|
||||
|
||||
/* vocab.c */
|
||||
void dstroy __P((int));
|
||||
void juggle __P((int));
|
||||
void move __P((int, int));
|
||||
int put __P((int, int, int));
|
||||
void carry __P((int, int));
|
||||
void drop __P((int, int));
|
||||
int vocab __P((const char *, int, int));
|
||||
void dstroy(int);
|
||||
void juggle(int);
|
||||
void move(int, int);
|
||||
int put(int, int, int);
|
||||
void carry(int, int);
|
||||
void drop(int, int);
|
||||
int vocab(const char *, int, int);
|
||||
|
||||
/* These three used to be functions in vocab.c */
|
||||
#define copystr(src, dest) strcpy((dest), (src))
|
||||
#define weq(str1, str2) (!strncmp((str1), (str2), 5))
|
||||
#define length(str) (strlen((str)) + 1)
|
||||
|
||||
void prht __P((void));
|
||||
void prht(void);
|
||||
|
||||
/* wizard.c */
|
||||
void datime __P((int *, int *));
|
||||
void poof __P((void));
|
||||
int Start __P((void));
|
||||
int wizard __P((void));
|
||||
void ciao __P((void));
|
||||
int ran __P((int));
|
||||
void datime(int *, int *);
|
||||
void poof(void);
|
||||
int Start(void);
|
||||
int wizard(void);
|
||||
void ciao(void);
|
||||
int ran(int);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.17 2003/08/07 09:36:51 agc Exp $ */
|
||||
/* $NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.17 2003/08/07 09:36:51 agc Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -59,7 +59,7 @@ __RCSID("$NetBSD: main.c,v 1.17 2003/08/07 09:36:51 agc Exp $");
|
||||
#include "hdr.h"
|
||||
#include "extern.h"
|
||||
|
||||
int main __P((int, char **));
|
||||
int main(int, char **);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefrag - makefile fragment for arithmetic
|
||||
#
|
||||
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
|
||||
# Copyright (c) 1997, 1998, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -26,6 +26,7 @@
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
arithmetic_DEFS := $(GETPROGNAME_DEFS)
|
||||
arithmetic_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
arithmetic_all: arithmetic/arithmetic arithmetic/arithmetic.6
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: arithmetic.c,v 1.19 2003/08/07 09:36:52 agc Exp $ */
|
||||
/* $NetBSD: arithmetic.c,v 1.20 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: arithmetic.c,v 1.19 2003/08/07 09:36:52 agc Exp $");
|
||||
__RCSID("$NetBSD: arithmetic.c,v 1.20 2004/01/27 20:30:28 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -84,14 +84,14 @@ __RCSID("$NetBSD: arithmetic.c,v 1.19 2003/08/07 09:36:52 agc Exp $");
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int getrandom __P((int, int, int));
|
||||
void intr __P((int)) __attribute__((__noreturn__));
|
||||
int main __P((int, char *[]));
|
||||
int opnum __P((int));
|
||||
void penalise __P((int, int, int));
|
||||
int problem __P((void));
|
||||
void showstats __P((int));
|
||||
void usage __P((void)) __attribute__((__noreturn__));
|
||||
int getrandom(int, int, int);
|
||||
void intr(int) __attribute__((__noreturn__));
|
||||
int main(int, char *[]);
|
||||
int opnum(int);
|
||||
void penalise(int, int, int);
|
||||
int problem(void);
|
||||
void showstats(int);
|
||||
void usage(void) __attribute__((__noreturn__));
|
||||
|
||||
const char keylist[] = "+-x/";
|
||||
const char defaultkeys[] = "+-";
|
||||
@@ -102,8 +102,6 @@ int nright, nwrong;
|
||||
time_t qtime;
|
||||
#define NQUESTS 20
|
||||
|
||||
extern char *__progname; /* from crt0.o */
|
||||
|
||||
/*
|
||||
* Select keys from +-x/ to be asked addition, subtraction, multiplication,
|
||||
* and division problems. More than one key may be given. The default is
|
||||
@@ -390,6 +388,6 @@ void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "Usage: %s [-o +-x/] [-r range]\n",
|
||||
__progname);
|
||||
getprogname());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: atc.6,v 1.19 2003/08/07 09:36:53 agc Exp $
|
||||
.\" $NetBSD: atc.6,v 1.21 2004/01/01 16:31:37 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -34,7 +34,7 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1986 Ed James. All rights reserved.
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dd January 1, 2004
|
||||
.Dt ATC 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -112,7 +112,6 @@ Suspending a game is not permitted.
|
||||
If you get a talk message, tough.
|
||||
When was the last time an Air Traffic Controller got called away to the phone?
|
||||
.Sh THE DISPLAY
|
||||
.Pp
|
||||
Depending on the terminal you run
|
||||
.Nm
|
||||
on, the screen will be divided into 4 areas.
|
||||
|
||||
154
atc/extern.h
154
atc/extern.h
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.10 2003/08/07 09:36:53 agc Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.11 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -58,81 +58,81 @@ extern struct termios tty_start, tty_new;
|
||||
|
||||
extern DISPLACEMENT displacement[MAXDIR];
|
||||
|
||||
int addplane __P((void));
|
||||
void append __P((LIST *, PLANE *));
|
||||
void check_adir __P((int, int, int));
|
||||
void check_edge __P((int, int));
|
||||
void check_edir __P((int, int, int));
|
||||
void check_line __P((int, int, int, int));
|
||||
void check_linepoint __P((int, int));
|
||||
void check_point __P((int, int));
|
||||
int checkdefs __P((void));
|
||||
int compar __P((const void *, const void *));
|
||||
void delete __P((LIST *, PLANE *));
|
||||
int dir_deg __P((int));
|
||||
int dir_no __P((char));
|
||||
void done_screen __P((void));
|
||||
void draw_all __P((void));
|
||||
void draw_line __P((WINDOW *, int, int, int, int, const char *));
|
||||
void erase_all __P((void));
|
||||
int getAChar __P((void));
|
||||
int getcommand __P((void));
|
||||
int gettoken __P((void));
|
||||
void init_gr __P((void));
|
||||
void ioaddstr __P((int, const char *));
|
||||
void ioclrtobot __P((void));
|
||||
void ioclrtoeol __P((int));
|
||||
void ioerror __P((int, int, const char *));
|
||||
void iomove __P((int));
|
||||
int list_games __P((void));
|
||||
int log_score __P((int));
|
||||
void log_score_quit __P((int)) __attribute__((__noreturn__));
|
||||
void loser __P((const PLANE *, const char *)) __attribute__((__noreturn__));
|
||||
int main __P((int, char *[]));
|
||||
char name __P((const PLANE *));
|
||||
int next_plane __P((void));
|
||||
void noise __P((void));
|
||||
int number __P((char));
|
||||
void open_score_file __P((void));
|
||||
void planewin __P((void));
|
||||
int pop __P((void));
|
||||
void push __P((int, int));
|
||||
void quit __P((int));
|
||||
int read_file __P((const char *));
|
||||
void redraw __P((void));
|
||||
void rezero __P((void));
|
||||
void setup_screen __P((const C_SCREEN *));
|
||||
int too_close __P((const PLANE *p1, const PLANE *p2, int));
|
||||
void update __P((int));
|
||||
int yyerror __P((const char *));
|
||||
int yylex __P((void));
|
||||
int addplane(void);
|
||||
void append(LIST *, PLANE *);
|
||||
void check_adir(int, int, int);
|
||||
void check_edge(int, int);
|
||||
void check_edir(int, int, int);
|
||||
void check_line(int, int, int, int);
|
||||
void check_linepoint(int, int);
|
||||
void check_point(int, int);
|
||||
int checkdefs(void);
|
||||
int compar(const void *, const void *);
|
||||
void delete(LIST *, PLANE *);
|
||||
int dir_deg(int);
|
||||
int dir_no(char);
|
||||
void done_screen(void);
|
||||
void draw_all(void);
|
||||
void draw_line(WINDOW *, int, int, int, int, const char *);
|
||||
void erase_all(void);
|
||||
int getAChar(void);
|
||||
int getcommand(void);
|
||||
int gettoken(void);
|
||||
void init_gr(void);
|
||||
void ioaddstr(int, const char *);
|
||||
void ioclrtobot(void);
|
||||
void ioclrtoeol(int);
|
||||
void ioerror(int, int, const char *);
|
||||
void iomove(int);
|
||||
int list_games(void);
|
||||
int log_score(int);
|
||||
void log_score_quit(int) __attribute__((__noreturn__));
|
||||
void loser(const PLANE *, const char *) __attribute__((__noreturn__));
|
||||
int main(int, char *[]);
|
||||
char name(const PLANE *);
|
||||
int next_plane(void);
|
||||
void noise(void);
|
||||
int number(char);
|
||||
void open_score_file(void);
|
||||
void planewin(void);
|
||||
int pop(void);
|
||||
void push(int, int);
|
||||
void quit(int);
|
||||
int read_file(const char *);
|
||||
void redraw(void);
|
||||
void rezero(void);
|
||||
void setup_screen(const C_SCREEN *);
|
||||
int too_close(const PLANE *p1, const PLANE *p2, int);
|
||||
void update(int);
|
||||
int yyerror(const char *);
|
||||
int yylex(void);
|
||||
#ifndef YYEMPTY
|
||||
int yyparse __P((void));
|
||||
int yyparse(void);
|
||||
#endif
|
||||
const char *Left __P((char));
|
||||
const char *Right __P((char));
|
||||
const char *airport __P((char));
|
||||
const char *beacon __P((char));
|
||||
const char *benum __P((char));
|
||||
const char *circle __P((char));
|
||||
const char *climb __P((char));
|
||||
const char *command __P((const PLANE *));
|
||||
const char *default_game __P((void));
|
||||
const char *delayb __P((char));
|
||||
const char *descend __P((char));
|
||||
const char *ex_it __P((char));
|
||||
PLANE *findplane __P((int));
|
||||
const char *ignore __P((char));
|
||||
const char *left __P((char));
|
||||
const char *mark __P((char));
|
||||
PLANE *newplane __P((void));
|
||||
const char *okay_game __P((const char *));
|
||||
const char *rel_dir __P((char));
|
||||
const char *right __P((char));
|
||||
const char *setalt __P((char));
|
||||
const char *setplane __P((char));
|
||||
const char *setrelalt __P((char));
|
||||
const char *timestr __P((int));
|
||||
const char *to_dir __P((char));
|
||||
const char *turn __P((char));
|
||||
const char *unmark __P((char));
|
||||
const char *Left(char);
|
||||
const char *Right(char);
|
||||
const char *airport(char);
|
||||
const char *beacon(char);
|
||||
const char *benum(char);
|
||||
const char *circle(char);
|
||||
const char *climb(char);
|
||||
const char *command(const PLANE *);
|
||||
const char *default_game(void);
|
||||
const char *delayb(char);
|
||||
const char *descend(char);
|
||||
const char *ex_it(char);
|
||||
PLANE *findplane(int);
|
||||
const char *ignore(char);
|
||||
const char *left(char);
|
||||
const char *mark(char);
|
||||
PLANE *newplane(void);
|
||||
const char *okay_game(const char *);
|
||||
const char *rel_dir(char);
|
||||
const char *right(char);
|
||||
const char *setalt(char);
|
||||
const char *setplane(char);
|
||||
const char *setrelalt(char);
|
||||
const char *timestr(int);
|
||||
const char *to_dir(char);
|
||||
const char *turn(char);
|
||||
const char *unmark(char);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: input.c,v 1.15 2003/08/07 09:36:54 agc Exp $ */
|
||||
/* $NetBSD: input.c,v 1.16 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -46,7 +46,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: input.c,v 1.15 2003/08/07 09:36:54 agc Exp $");
|
||||
__RCSID("$NetBSD: input.c,v 1.16 2004/01/27 20:30:28 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -67,7 +67,7 @@ typedef struct {
|
||||
int token;
|
||||
int to_state;
|
||||
const char *str;
|
||||
const char *(*func) __P((char));
|
||||
const char *(*func)(char);
|
||||
} RULE;
|
||||
|
||||
typedef struct {
|
||||
@@ -229,7 +229,7 @@ int
|
||||
getcommand()
|
||||
{
|
||||
int c, i, done;
|
||||
const char *s, *(*func) __P((char));
|
||||
const char *s, *(*func)(char);
|
||||
PLANE *pp;
|
||||
|
||||
rezero();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: backlocal.h,v 1.1 1997/10/10 08:59:35 lukem Exp $ */
|
||||
/* $NetBSD: backlocal.h,v 1.2 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@@ -36,13 +36,13 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
void dble __P((void));
|
||||
int dblgood __P((void));
|
||||
int eval __P((void));
|
||||
int freemen __P((int));
|
||||
void movcmp __P((void));
|
||||
void move __P((int));
|
||||
int movegood __P((void));
|
||||
void pickmove __P((void));
|
||||
int trapped __P((int, int));
|
||||
void trymove __P((int, int));
|
||||
void dble(void);
|
||||
int dblgood(void);
|
||||
int eval(void);
|
||||
int freemen(int);
|
||||
void movcmp(void);
|
||||
void move(int);
|
||||
int movegood(void);
|
||||
void pickmove(void);
|
||||
int trapped(int, int);
|
||||
void trymove(int, int);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.18 2003/08/07 09:36:56 agc Exp $ */
|
||||
/* $NetBSD: main.c,v 1.20 2004/02/08 22:23:50 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.18 2003/08/07 09:36:56 agc Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.20 2004/02/08 22:23:50 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: move.c,v 1.7 2003/08/07 09:36:56 agc Exp $ */
|
||||
/* $NetBSD: move.c,v 1.8 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: move.c,v 1.7 2003/08/07 09:36:56 agc Exp $");
|
||||
__RCSID("$NetBSD: move.c,v 1.8 2004/01/27 20:30:28 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -83,13 +83,13 @@ static int cg[5]; /* candidate finish position */
|
||||
static int race; /* game reduced to a race */
|
||||
|
||||
|
||||
static int bcomp __P((struct BOARD *, struct BOARD *));
|
||||
static struct BOARD *bsave __P((void));
|
||||
static void binsert __P((struct BOARD *));
|
||||
static void boardcopy __P((struct BOARD *));
|
||||
static void makefree __P((struct BOARD *));
|
||||
static void mvcheck __P((struct BOARD *, struct BOARD *));
|
||||
static struct BOARD *nextfree __P((void));
|
||||
static int bcomp(struct BOARD *, struct BOARD *);
|
||||
static struct BOARD *bsave(void);
|
||||
static void binsert(struct BOARD *);
|
||||
static void boardcopy(struct BOARD *);
|
||||
static void makefree(struct BOARD *);
|
||||
static void mvcheck(struct BOARD *, struct BOARD *);
|
||||
static struct BOARD *nextfree(void);
|
||||
|
||||
|
||||
void
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: back.h,v 1.13 2003/08/07 09:36:56 agc Exp $ */
|
||||
/* $NetBSD: back.h,v 1.14 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -129,57 +129,57 @@ extern int curc; /* column position of cursor */
|
||||
extern int begscr; /* 'beginning' of screen
|
||||
(not including board) */
|
||||
|
||||
int addbuf __P((int));
|
||||
void backone __P((int));
|
||||
void bsect __P((int, int, int, int));
|
||||
void buflush __P((void));
|
||||
int canhit __P((int, int));
|
||||
int checkd __P((int));
|
||||
int checkmove __P((int));
|
||||
void clear __P((void));
|
||||
void clend __P((void));
|
||||
void cline __P((void));
|
||||
int count __P((void));
|
||||
void curmove __P((int, int));
|
||||
int dotable __P((char, int));
|
||||
void errexit __P((const char *)) __attribute__((__noreturn__));
|
||||
void fancyc __P((int));
|
||||
void fboard __P((void));
|
||||
void fixcol __P((int, int, int, int, int));
|
||||
void fixpos __P((int, int, int, int, int));
|
||||
void fixtty __P((struct termios *));
|
||||
void getarg __P((char ***));
|
||||
int getcaps __P((const char *));
|
||||
void getmove __P((void));
|
||||
void getout __P((int)) __attribute__((__noreturn__));
|
||||
void gwrite __P((void));
|
||||
void init __P((void));
|
||||
int last __P((void));
|
||||
int main __P((int, char *[]));
|
||||
int makmove __P((int));
|
||||
int movallow __P((void));
|
||||
void movback __P((int));
|
||||
void moverr __P((int));
|
||||
int movokay __P((int));
|
||||
void newline __P((void));
|
||||
void newpos __P((void));
|
||||
void nexturn __P((void));
|
||||
void norec __P((const char *)) __attribute__((__noreturn__));
|
||||
void odds __P((int, int, int));
|
||||
void proll __P((void));
|
||||
int quit __P((void));
|
||||
int readc __P((void));
|
||||
void recover __P((const char *));
|
||||
void refresh __P((void));
|
||||
void roll __P((void));
|
||||
int rsetbrd __P((void));
|
||||
void save __P((int));
|
||||
int text __P((const char *const *));
|
||||
void wrboard __P((void));
|
||||
void wrbsub __P((void));
|
||||
void wrhit __P((int));
|
||||
void wrint __P((int));
|
||||
void writec __P((char));
|
||||
void writel __P((const char *));
|
||||
void wrscore __P((void));
|
||||
int yorn __P((char));
|
||||
int addbuf(int);
|
||||
void backone(int);
|
||||
void bsect(int, int, int, int);
|
||||
void buflush(void);
|
||||
int canhit(int, int);
|
||||
int checkd(int);
|
||||
int checkmove(int);
|
||||
void clear(void);
|
||||
void clend(void);
|
||||
void cline(void);
|
||||
int count(void);
|
||||
void curmove(int, int);
|
||||
int dotable(char, int);
|
||||
void errexit(const char *) __attribute__((__noreturn__));
|
||||
void fancyc(int);
|
||||
void fboard(void);
|
||||
void fixcol(int, int, int, int, int);
|
||||
void fixpos(int, int, int, int, int);
|
||||
void fixtty(struct termios *);
|
||||
void getarg(char ***);
|
||||
int getcaps(const char *);
|
||||
void getmove(void);
|
||||
void getout(int) __attribute__((__noreturn__));
|
||||
void gwrite(void);
|
||||
void init(void);
|
||||
int last(void);
|
||||
int main(int, char *[]);
|
||||
int makmove(int);
|
||||
int movallow(void);
|
||||
void movback(int);
|
||||
void moverr(int);
|
||||
int movokay(int);
|
||||
void newline(void);
|
||||
void newpos(void);
|
||||
void nexturn(void);
|
||||
void norec(const char *) __attribute__((__noreturn__));
|
||||
void odds(int, int, int);
|
||||
void proll(void);
|
||||
int quit(void);
|
||||
int readc(void);
|
||||
void recover(const char *);
|
||||
void refresh(void);
|
||||
void roll(void);
|
||||
int rsetbrd(void);
|
||||
void save(int);
|
||||
int text(const char *const *);
|
||||
void wrboard(void);
|
||||
void wrbsub(void);
|
||||
void wrhit(int);
|
||||
void wrint(int);
|
||||
void writec(char);
|
||||
void writel(const char *);
|
||||
void wrscore(void);
|
||||
int yorn(char);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: data.c,v 1.6 2003/08/07 09:36:58 agc Exp $ */
|
||||
/* $NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: data.c,v 1.6 2003/08/07 09:36:58 agc Exp $");
|
||||
__RCSID("$NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: teach.c,v 1.14 2003/08/07 09:36:58 agc Exp $ */
|
||||
/* $NetBSD: teach.c,v 1.15 2004/02/08 22:23:50 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: teach.c,v 1.14 2003/08/07 09:36:58 agc Exp $");
|
||||
__RCSID("$NetBSD: teach.c,v 1.15 2004/02/08 22:23:50 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tutor.h,v 1.7 2003/08/07 09:36:59 agc Exp $ */
|
||||
/* $NetBSD: tutor.h,v 1.8 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -62,7 +62,7 @@ extern const char *const stragy[];
|
||||
extern const struct situatn test[];
|
||||
|
||||
|
||||
int brdeq __P((const int *, const int *));
|
||||
void clrest __P((void));
|
||||
void leave __P((void)) __attribute__((__noreturn__));
|
||||
void tutor __P((void)) __attribute__((__noreturn__));
|
||||
int brdeq(const int *, const int *);
|
||||
void clrest(void);
|
||||
void leave(void) __attribute__((__noreturn__));
|
||||
void tutor(void) __attribute__((__noreturn__));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: banner.c,v 1.11 2003/08/07 09:36:59 agc Exp $ */
|
||||
/* $NetBSD: banner.c,v 1.12 2004/01/27 20:30:28 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993, 1994
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: banner.c,v 1.11 2003/08/07 09:36:59 agc Exp $");
|
||||
__RCSID("$NetBSD: banner.c,v 1.12 2004/01/27 20:30:28 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -1026,7 +1026,7 @@ int debug, i, j, linen, max, nchars, pc, term, trace, x, y;
|
||||
int width = DWIDTH; /* -w option: scrunch letters to 80 columns */
|
||||
|
||||
|
||||
int main __P((int, char *[]));
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: battlestar.c,v 1.13 2003/08/07 09:37:00 agc Exp $ */
|
||||
/* $NetBSD: battlestar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: battlestar.c,v 1.13 2003/08/07 09:37:00 agc Exp $");
|
||||
__RCSID("$NetBSD: battlestar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -52,7 +52,7 @@ __RCSID("$NetBSD: battlestar.c,v 1.13 2003/08/07 09:37:00 agc Exp $");
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
int main __P((int, char *[]));
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.29 2003/08/07 09:37:02 agc Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.30 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -328,60 +328,60 @@ extern const struct objs nightobjs[];
|
||||
|
||||
#define DEFAULT_SAVE_FILE ".Bstar"
|
||||
|
||||
void bury __P((void));
|
||||
int card __P((const char *, int));
|
||||
void chime __P((void));
|
||||
void convert __P((int));
|
||||
void crash __P((void));
|
||||
int cypher __P((void));
|
||||
void die __P((void)) __attribute__((__noreturn__));
|
||||
void diesig __P((int)) __attribute__((__noreturn__));
|
||||
void dig __P((void));
|
||||
void dooropen __P((void));
|
||||
int draw __P((void));
|
||||
void drink __P((void));
|
||||
int drive __P((void));
|
||||
int drop __P((const char *));
|
||||
int eat __P((void));
|
||||
int fight __P((int, int));
|
||||
int follow __P((void));
|
||||
char *getcom __P((char *, int, const char *, const char *));
|
||||
char *getword __P((char *, char *, int));
|
||||
int give __P((void));
|
||||
void initialize __P((const char *));
|
||||
int jump __P((void));
|
||||
void kiss __P((void));
|
||||
int land __P((void));
|
||||
int launch __P((void));
|
||||
void light __P((void));
|
||||
void live __P((void)) __attribute__((__noreturn__));
|
||||
void love __P((void));
|
||||
int moveplayer __P((int, int));
|
||||
void murder __P((void));
|
||||
void news __P((void));
|
||||
void newway __P((int));
|
||||
void open_score_file __P((void));
|
||||
void parse __P((void));
|
||||
void post __P((char));
|
||||
void printobjs __P((void));
|
||||
int put __P((void));
|
||||
int puton __P((void));
|
||||
const char *rate __P((void));
|
||||
void ravage __P((void));
|
||||
void restore __P((const char *));
|
||||
int ride __P((void));
|
||||
void save __P((const char *));
|
||||
char *save_file_name __P((const char *, size_t));
|
||||
int shoot __P((void));
|
||||
int take __P((unsigned int[]));
|
||||
int takeoff __P((void));
|
||||
int throw __P((const char *));
|
||||
const char *truedirec __P((int, char));
|
||||
int ucard __P((const unsigned int *));
|
||||
int use __P((void));
|
||||
int visual __P((void));
|
||||
int wearit __P((void));
|
||||
void whichway __P((struct room));
|
||||
void wordinit __P((void));
|
||||
void writedes __P((void));
|
||||
int zzz __P((void));
|
||||
void bury(void);
|
||||
int card(const char *, int);
|
||||
void chime(void);
|
||||
void convert(int);
|
||||
void crash(void);
|
||||
int cypher(void);
|
||||
void die(void) __attribute__((__noreturn__));
|
||||
void diesig(int) __attribute__((__noreturn__));
|
||||
void dig(void);
|
||||
void dooropen(void);
|
||||
int draw(void);
|
||||
void drink(void);
|
||||
int drive(void);
|
||||
int drop(const char *);
|
||||
int eat(void);
|
||||
int fight(int, int);
|
||||
int follow(void);
|
||||
char *getcom(char *, int, const char *, const char *);
|
||||
char *getword(char *, char *, int);
|
||||
int give(void);
|
||||
void initialize(const char *);
|
||||
int jump(void);
|
||||
void kiss(void);
|
||||
int land(void);
|
||||
int launch(void);
|
||||
void light(void);
|
||||
void live(void) __attribute__((__noreturn__));
|
||||
void love(void);
|
||||
int moveplayer(int, int);
|
||||
void murder(void);
|
||||
void news(void);
|
||||
void newway(int);
|
||||
void open_score_file(void);
|
||||
void parse(void);
|
||||
void post(char);
|
||||
void printobjs(void);
|
||||
int put(void);
|
||||
int puton(void);
|
||||
const char *rate(void);
|
||||
void ravage(void);
|
||||
void restore(const char *);
|
||||
int ride(void);
|
||||
void save(const char *);
|
||||
char *save_file_name(const char *, size_t);
|
||||
int shoot(void);
|
||||
int take(unsigned int[]);
|
||||
int takeoff(void);
|
||||
int throw(const char *);
|
||||
const char *truedirec(int, char);
|
||||
int ucard(const unsigned int *);
|
||||
int use(void);
|
||||
int visual(void);
|
||||
int wearit(void);
|
||||
void whichway(struct room);
|
||||
void wordinit(void);
|
||||
void writedes(void);
|
||||
int zzz(void);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fly.c,v 1.11 2003/08/07 09:37:02 agc Exp $ */
|
||||
/* $NetBSD: fly.c,v 1.12 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: fly.c,v 1.11 2003/08/07 09:37:02 agc Exp $");
|
||||
__RCSID("$NetBSD: fly.c,v 1.12 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -52,13 +52,13 @@ int ourclock = 120; /* time for all the flights in the game */
|
||||
static char cross = 0;
|
||||
static sig_t oldsig;
|
||||
|
||||
static void blast __P((void));
|
||||
static void endfly __P((void));
|
||||
static void moveenemy __P((int));
|
||||
static void notarget __P((void));
|
||||
static void screen __P((void));
|
||||
static void succumb __P((int));
|
||||
static void target __P((void));
|
||||
static void blast(void);
|
||||
static void endfly(void);
|
||||
static void moveenemy(int);
|
||||
static void notarget(void);
|
||||
static void screen(void);
|
||||
static void succumb(int);
|
||||
static void target(void);
|
||||
|
||||
static void
|
||||
succumb(dummy)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init.c,v 1.13 2003/08/07 09:37:02 agc Exp $ */
|
||||
/* $NetBSD: init.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -34,15 +34,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: init.c,v 1.13 2003/08/07 09:37:02 agc Exp $");
|
||||
__RCSID("$NetBSD: init.c,v 1.14 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
static int checkout __P((const char *));
|
||||
static const char *getutmp __P((void));
|
||||
static int wizard __P((const char *));
|
||||
static int checkout(const char *);
|
||||
static const char *getutmp(void);
|
||||
static int wizard(const char *);
|
||||
|
||||
void
|
||||
initialize(filename)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.13 2003/08/07 09:37:03 agc Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.13 2003/08/07 09:37:03 agc Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.14 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -44,9 +44,9 @@ __RCSID("$NetBSD: parse.c,v 1.13 2003/08/07 09:37:03 agc Exp $");
|
||||
#define HASHMUL 81
|
||||
#define HASHMASK (HASHSIZE - 1)
|
||||
|
||||
static int hash __P((const char *));
|
||||
static void install __P((struct wlist *));
|
||||
static struct wlist *lookup __P((const char *));
|
||||
static int hash(const char *);
|
||||
static void install(struct wlist *);
|
||||
static struct wlist *lookup(const char *);
|
||||
|
||||
static struct wlist *hashtab[HASHSIZE];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bcd.c,v 1.12 2003/08/07 09:37:04 agc Exp $ */
|
||||
/* $NetBSD: bcd.c,v 1.13 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: bcd.c,v 1.12 2003/08/07 09:37:04 agc Exp $");
|
||||
__RCSID("$NetBSD: bcd.c,v 1.13 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -124,8 +124,8 @@ const u_short holes[256] = {
|
||||
*/
|
||||
#define bit(w,i) ((w)&(1<<(i)))
|
||||
|
||||
int main __P((int, char *[]));
|
||||
void printcard __P((unsigned char *));
|
||||
int main(int, char *[]);
|
||||
void printcard(unsigned char *);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
README.linux for boggle
|
||||
=======================
|
||||
|
||||
I grabbed this game from comp.sources.games/volume4. This game is now
|
||||
merged with the NetBSD version.
|
||||
|
||||
If you wish to use a different dictionary, you can set
|
||||
boggle_mkdict_DICTSRC in mkdict/Makefrag.
|
||||
|
||||
|
||||
By default, this game compiles with certain Linux improvements; if you
|
||||
want the original BSD behaviour, remove -DNEW_STYLE from the
|
||||
boggle_boggle_DEFS in boggle/Makefrag. Defining NEW_STYLE will
|
||||
provide a more intuitive way of quitting or playing a new game after
|
||||
time has run out.
|
||||
|
||||
NOTE: You may wish to remove -DNEW_STYLE if you plan on using the post
|
||||
game word lookup feature. Press <ESC>, type a word, and bog will
|
||||
display where it is located. If NEW_STYLE is defined, it might be
|
||||
easy to accidently start typing the word with out pressing <ESC>
|
||||
first. This would start a new game, and you would never be able to
|
||||
know where that word was located. :(
|
||||
|
||||
Thanks to Andrew Kuchling. (See ../Credits for his email address.)
|
||||
|
||||
Curt Olson
|
||||
curt@sledge.mn.org
|
||||
|
||||
Boggle is under the BSD licence, thanks to Paul Janzen for checking
|
||||
this with the original author.
|
||||
|
||||
|
||||
|
||||
Local Variables:
|
||||
mode: text
|
||||
End:
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bog.c,v 1.17 2003/08/07 09:37:05 agc Exp $ */
|
||||
/* $NetBSD: bog.c,v 1.18 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bog.c 8.2 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: bog.c,v 1.17 2003/08/07 09:37:05 agc Exp $");
|
||||
__RCSID("$NetBSD: bog.c,v 1.18 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -57,8 +57,8 @@ __RCSID("$NetBSD: bog.c,v 1.17 2003/08/07 09:37:05 agc Exp $");
|
||||
#include "bog.h"
|
||||
#include "extern.h"
|
||||
|
||||
static int compar __P((const void *, const void *));
|
||||
int main __P((int, char *[]));
|
||||
static int compar(const void *, const void *);
|
||||
int main(int, char *[]);
|
||||
|
||||
struct dictindex dictindex[26];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.7 2003/08/07 09:37:05 agc Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.8 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@@ -33,39 +33,39 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
void addword __P((const char *));
|
||||
void badword __P((void));
|
||||
char *batchword __P((FILE *));
|
||||
void checkdict __P((void));
|
||||
int checkword __P((const char *, int, int *));
|
||||
void cleanup __P((void));
|
||||
void delay __P((int));
|
||||
long dictseek __P((FILE *, long, int));
|
||||
void findword __P((void));
|
||||
void flushin __P((FILE *));
|
||||
char *getline __P((char *));
|
||||
void getword __P((char *));
|
||||
int help __P((void));
|
||||
int inputch __P((void));
|
||||
int loaddict __P((FILE *));
|
||||
int loadindex __P((const char *));
|
||||
void newgame __P((const char *));
|
||||
char *nextword __P((FILE *));
|
||||
FILE *opendict __P((const char *));
|
||||
void playgame __P((void));
|
||||
void prompt __P((const char *));
|
||||
void prtable __P((const char *const [],
|
||||
int, int, int, void (*)(const char *const [], int), int (*)(const char *const [], int)));
|
||||
void putstr __P((const char *));
|
||||
void redraw __P((void));
|
||||
void results __P((void));
|
||||
int setup __P((int, time_t));
|
||||
void showboard __P((const char *));
|
||||
void showstr __P((const char *, int));
|
||||
void showword __P((int));
|
||||
void starttime __P((void));
|
||||
void startwords __P((void));
|
||||
void stoptime __P((void));
|
||||
int timerch __P((void));
|
||||
void usage __P((void)) __attribute__((__noreturn__));
|
||||
int validword __P((const char *));
|
||||
void addword(const char *);
|
||||
void badword(void);
|
||||
char *batchword(FILE *);
|
||||
void checkdict(void);
|
||||
int checkword(const char *, int, int *);
|
||||
void cleanup(void);
|
||||
void delay(int);
|
||||
long dictseek(FILE *, long, int);
|
||||
void findword(void);
|
||||
void flushin(FILE *);
|
||||
char *getline(char *);
|
||||
void getword(char *);
|
||||
int help(void);
|
||||
int inputch(void);
|
||||
int loaddict(FILE *);
|
||||
int loadindex(const char *);
|
||||
void newgame(const char *);
|
||||
char *nextword(FILE *);
|
||||
FILE *opendict(const char *);
|
||||
void playgame(void);
|
||||
void prompt(const char *);
|
||||
void prtable(const char *const [],
|
||||
int, int, int, void (*)(const char *const [], int), int (*)(const char *const [], int));
|
||||
void putstr(const char *);
|
||||
void redraw(void);
|
||||
void results(void);
|
||||
int setup(int, time_t);
|
||||
void showboard(const char *);
|
||||
void showstr(const char *, int);
|
||||
void showword(int);
|
||||
void starttime(void);
|
||||
void startwords(void);
|
||||
void stoptime(void);
|
||||
int timerch(void);
|
||||
void usage(void) __attribute__((__noreturn__));
|
||||
int validword(const char *);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mach.c,v 1.12 2003/08/07 09:37:05 agc Exp $ */
|
||||
/* $NetBSD: mach.c,v 1.13 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: mach.c,v 1.12 2003/08/07 09:37:05 agc Exp $");
|
||||
__RCSID("$NetBSD: mach.c,v 1.13 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -73,14 +73,14 @@ extern int usedbits, wordpath[];
|
||||
extern time_t start_t;
|
||||
extern int debug;
|
||||
|
||||
static void cont_catcher __P((int));
|
||||
static int prwidth __P((const char *const [], int));
|
||||
static void prword __P((const char *const [], int));
|
||||
static void stop_catcher __P((int));
|
||||
static void tty_cleanup __P((void));
|
||||
static int tty_setup __P((void));
|
||||
static void tty_showboard __P((const char *));
|
||||
static void winch_catcher __P((int));
|
||||
static void cont_catcher(int);
|
||||
static int prwidth(const char *const [], int);
|
||||
static void prword(const char *const [], int);
|
||||
static void stop_catcher(int);
|
||||
static void tty_cleanup(void);
|
||||
static int tty_setup(void);
|
||||
static void tty_showboard(const char *);
|
||||
static void winch_catcher(int);
|
||||
|
||||
/*
|
||||
* Do system dependent initialization
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prtable.c,v 1.7 2003/08/07 09:37:05 agc Exp $ */
|
||||
/* $NetBSD: prtable.c,v 1.8 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: prtable.c,v 1.7 2003/08/07 09:37:05 agc Exp $");
|
||||
__RCSID("$NetBSD: prtable.c,v 1.8 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <curses.h>
|
||||
@@ -45,7 +45,7 @@ __RCSID("$NetBSD: prtable.c,v 1.7 2003/08/07 09:37:05 agc Exp $");
|
||||
|
||||
#define NCOLS 5
|
||||
|
||||
static int get_maxlen __P((const char *const [], int, int (*)(const char *const *, int)));
|
||||
static int get_maxlen(const char *const [], int, int (*)(const char *const *, int));
|
||||
|
||||
/*
|
||||
* Routine to print a table
|
||||
@@ -66,8 +66,8 @@ void
|
||||
prtable(base, num, d_cols, width, prentry, length)
|
||||
const char *const base[];
|
||||
int num, d_cols, width;
|
||||
void (*prentry) __P((const char *const [], int));
|
||||
int (*length) __P((const char *const [], int));
|
||||
void (*prentry)(const char *const [], int);
|
||||
int (*length)(const char *const [], int);
|
||||
{
|
||||
int c, j;
|
||||
int a, b, cols, loc, maxlen, nrows, z;
|
||||
@@ -117,7 +117,7 @@ static int
|
||||
get_maxlen(base, num, length)
|
||||
const char *const base[];
|
||||
int num;
|
||||
int (*length) __P((const char *const *, int));
|
||||
int (*length)(const char *const *, int);
|
||||
{
|
||||
int i, len, max;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: timer.c,v 1.8 2003/08/07 09:37:06 agc Exp $ */
|
||||
/* $NetBSD: timer.c,v 1.9 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)timer.c 8.2 (Berkeley) 2/22/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: timer.c,v 1.8 2003/08/07 09:37:06 agc Exp $");
|
||||
__RCSID("$NetBSD: timer.c,v 1.9 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -54,7 +54,7 @@ __RCSID("$NetBSD: timer.c,v 1.8 2003/08/07 09:37:06 agc Exp $");
|
||||
#include "bog.h"
|
||||
#include "extern.h"
|
||||
|
||||
static int waitch __P((int));
|
||||
static int waitch(int);
|
||||
|
||||
extern int tlimit;
|
||||
extern time_t start_t;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
Begin4
|
||||
Title: bsd-games
|
||||
Version: 2.15
|
||||
Entered-date: 2003-12-18
|
||||
Version: 2.16
|
||||
Entered-date: 2004-02-13
|
||||
Description: Port of most of the games from NetBSD-current. Games
|
||||
included: adventure arithmetic atc backgammon banner battlestar
|
||||
bcd boggle caesar canfield countmail cribbage dm factor fish fortune
|
||||
gomoku hack hangman hunt mille monop morse number phantasia pig pom
|
||||
ppt primes quiz rain random robots sail snake tetris trek wargames
|
||||
worm worms wtf wump.
|
||||
bcd boggle caesar canfield countmail cribbage dab dm factor fish
|
||||
fortune gomoku hack hangman hunt mille monop morse number phantasia
|
||||
pig pom ppt primes quiz rain random robots sail snake tetris trek
|
||||
wargames worm worms wtf wump.
|
||||
Keywords: games, NetBSD
|
||||
Maintained-by: jsm@polyomino.org.uk (Joseph S. Myers)
|
||||
Primary-site: ibiblio.org /pub/Linux/games
|
||||
bsd-games-2.15.tar.gz
|
||||
bsd-games-2.16.tar.gz
|
||||
Alternate-site: tsx-11.mit.edu /pub/linux/sources/usr.games
|
||||
Original-site: ftp.netbsd.org /pub/NetBSD/NetBSD-current/tar_files/src
|
||||
games.tar.gz
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: caesar.c,v 1.12 2003/08/07 09:37:07 agc Exp $ */
|
||||
/* $NetBSD: caesar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)caesar.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: caesar.c,v 1.12 2003/08/07 09:37:07 agc Exp $");
|
||||
__RCSID("$NetBSD: caesar.c,v 1.14 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -76,8 +76,8 @@ double stdf[26] = {
|
||||
};
|
||||
|
||||
|
||||
int main __P((int, char *[]));
|
||||
void printit __P((const char *)) __attribute__((__noreturn__));
|
||||
int main(int, char *[]);
|
||||
void printit(const char *) __attribute__((__noreturn__));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: canfield.c,v 1.18 2003/08/07 09:37:07 agc Exp $ */
|
||||
/* $NetBSD: canfield.c,v 1.19 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: canfield.c,v 1.18 2003/08/07 09:37:07 agc Exp $");
|
||||
__RCSID("$NetBSD: canfield.c,v 1.19 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -198,53 +198,53 @@ bool startedgame = FALSE, infullgame = FALSE;
|
||||
time_t acctstart;
|
||||
int dbfd = -1;
|
||||
|
||||
void askquit __P((int));
|
||||
void cleanup __P((int)) __attribute__((__noreturn__));
|
||||
void cleanupboard __P((void));
|
||||
void clearabovemovebox __P((void));
|
||||
void clearbelowmovebox __P((void));
|
||||
void clearmsg __P((void));
|
||||
void clearstat __P((void));
|
||||
void destinerror __P((void));
|
||||
bool diffcolor __P((const struct cardtype *, const struct cardtype *));
|
||||
void dumberror __P((void));
|
||||
bool finish __P((void));
|
||||
void fndbase __P((struct cardtype **, int, int));
|
||||
void getcmd __P((int, int, const char *));
|
||||
void initall __P((void));
|
||||
void initdeck __P((struct cardtype *[]));
|
||||
void initgame __P((void));
|
||||
void instruct __P((void));
|
||||
int main __P((void));
|
||||
void makeboard __P((void));
|
||||
void movebox __P((void));
|
||||
void movecard __P((void));
|
||||
void movetofound __P((struct cardtype **, int));
|
||||
void movetotalon __P((void));
|
||||
bool notempty __P((const struct cardtype *));
|
||||
void printbottombettingbox __P((void));
|
||||
void printbottominstructions __P((void));
|
||||
void printcard __P((int, int, const struct cardtype *));
|
||||
void printrank __P((int, int, const struct cardtype *, bool));
|
||||
void printtopbettingbox __P((void));
|
||||
void printtopinstructions __P((void));
|
||||
bool rankhigher __P((const struct cardtype *, int));
|
||||
bool ranklower __P((const struct cardtype *, const struct cardtype *));
|
||||
void removecard __P((int, int));
|
||||
int samesuit __P((const struct cardtype *, int));
|
||||
void showcards __P((void));
|
||||
void showstat __P((void));
|
||||
void shuffle __P((struct cardtype *[]));
|
||||
void simpletableau __P((struct cardtype **, int));
|
||||
void startgame __P((void));
|
||||
void suspend __P((void));
|
||||
bool tabok __P((const struct cardtype *, int));
|
||||
void tabprint __P((int, int));
|
||||
void tabtotab __P((int, int));
|
||||
void transit __P((struct cardtype **, struct cardtype **));
|
||||
void updatebettinginfo __P((void));
|
||||
void usedstock __P((void));
|
||||
void usedtalon __P((void));
|
||||
void askquit(int);
|
||||
void cleanup(int) __attribute__((__noreturn__));
|
||||
void cleanupboard(void);
|
||||
void clearabovemovebox(void);
|
||||
void clearbelowmovebox(void);
|
||||
void clearmsg(void);
|
||||
void clearstat(void);
|
||||
void destinerror(void);
|
||||
bool diffcolor(const struct cardtype *, const struct cardtype *);
|
||||
void dumberror(void);
|
||||
bool finish(void);
|
||||
void fndbase(struct cardtype **, int, int);
|
||||
void getcmd(int, int, const char *);
|
||||
void initall(void);
|
||||
void initdeck(struct cardtype *[]);
|
||||
void initgame(void);
|
||||
void instruct(void);
|
||||
int main(void);
|
||||
void makeboard(void);
|
||||
void movebox(void);
|
||||
void movecard(void);
|
||||
void movetofound(struct cardtype **, int);
|
||||
void movetotalon(void);
|
||||
bool notempty(const struct cardtype *);
|
||||
void printbottombettingbox(void);
|
||||
void printbottominstructions(void);
|
||||
void printcard(int, int, const struct cardtype *);
|
||||
void printrank(int, int, const struct cardtype *, bool);
|
||||
void printtopbettingbox(void);
|
||||
void printtopinstructions(void);
|
||||
bool rankhigher(const struct cardtype *, int);
|
||||
bool ranklower(const struct cardtype *, const struct cardtype *);
|
||||
void removecard(int, int);
|
||||
int samesuit(const struct cardtype *, int);
|
||||
void showcards(void);
|
||||
void showstat(void);
|
||||
void shuffle(struct cardtype *[]);
|
||||
void simpletableau(struct cardtype **, int);
|
||||
void startgame(void);
|
||||
void suspend(void);
|
||||
bool tabok(const struct cardtype *, int);
|
||||
void tabprint(int, int);
|
||||
void tabtotab(int, int);
|
||||
void transit(struct cardtype **, struct cardtype **);
|
||||
void updatebettinginfo(void);
|
||||
void usedstock(void);
|
||||
void usedtalon(void);
|
||||
|
||||
/*
|
||||
* The following procedures print the board onto the screen using the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cfscores.c,v 1.11 2003/08/07 09:37:08 agc Exp $ */
|
||||
/* $NetBSD: cfscores.c,v 1.12 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: cfscores.c,v 1.11 2003/08/07 09:37:08 agc Exp $");
|
||||
__RCSID("$NetBSD: cfscores.c,v 1.12 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -66,8 +66,8 @@ struct betinfo {
|
||||
|
||||
int dbfd;
|
||||
|
||||
int main __P((int, char *[]));
|
||||
void printuser __P((const struct passwd *, int));
|
||||
int main(int, char *[]);
|
||||
void printuser(const struct passwd *, int);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
84
configure
vendored
84
configure
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# configure - home-grown configuration script for bsd-games.
|
||||
#
|
||||
# Copyright (c) 1997, 1998, 1999, 2000, 2003 Joseph Samuel Myers.
|
||||
# Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -56,10 +56,10 @@ ask () {
|
||||
read input
|
||||
fi
|
||||
case "$input" in
|
||||
'')
|
||||
('')
|
||||
input="$default"
|
||||
;;
|
||||
*)
|
||||
(*)
|
||||
;;
|
||||
esac
|
||||
eval $query_var=\"\$input\"
|
||||
@@ -73,13 +73,13 @@ ask_yn () {
|
||||
ask "$1" $2 $3
|
||||
eval answer=\$$2
|
||||
case "$answer" in
|
||||
[yY]*)
|
||||
([yY]*)
|
||||
answer=y
|
||||
;;
|
||||
[nN]*)
|
||||
([nN]*)
|
||||
answer=n
|
||||
;;
|
||||
*)
|
||||
(*)
|
||||
answer=
|
||||
echo "Please answer y or n"
|
||||
;;
|
||||
@@ -242,6 +242,13 @@ else
|
||||
subst_vars="$subst_vars man5dir"
|
||||
fi
|
||||
|
||||
if building_in trek || building_in rogue; then
|
||||
ask "Directory for miscellaneous documentation" docdir /usr/share/doc/bsd-games
|
||||
else
|
||||
docdir=
|
||||
subst_vars="$subst_vars docdir"
|
||||
fi
|
||||
|
||||
# The paths for data are as per the FHS. If a future version removes the
|
||||
# games ghettoes of /usr/games, /var/games, etc., then a subdirectory for
|
||||
# this package (/usr/share/bsdgames, /var/state/bsdgames, etc.) would be
|
||||
@@ -289,12 +296,12 @@ use_dot_so=
|
||||
while test x$use_dot_so = x; do
|
||||
ask "Use .so or symlinks for manpages" use_dot_so .so
|
||||
case "$use_dot_so" in
|
||||
.so)
|
||||
(.so)
|
||||
;;
|
||||
syml*)
|
||||
(syml*)
|
||||
use_dot_so=symlinks
|
||||
;;
|
||||
*)
|
||||
(*)
|
||||
use_dot_so=
|
||||
echo "Please answer \`.so\' or \`symlinks\'"
|
||||
;;
|
||||
@@ -317,13 +324,19 @@ subst_vars="$subst_vars install_script"
|
||||
echo
|
||||
echo "It is presumed in some places by the Makefiles that the compiler"
|
||||
echo "will be some form of gcc."
|
||||
ask "Compiler" cc gcc
|
||||
ask "C compiler" cc gcc
|
||||
if building_in dab; then
|
||||
ask "C++ compiler" cxx g++
|
||||
fi
|
||||
ask "Optimize flags" optimize_flags "-g -O2"
|
||||
echo
|
||||
echo "The default warning flags should give a compile with few warnings."
|
||||
# -Wbad-function-cast and -Wshadow give lots of warnings that are basically
|
||||
# harmless.
|
||||
ask "Compiler warning flags" warning_flags "-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings"
|
||||
ask "C compiler warning flags" warning_flags "-Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings"
|
||||
if building_in dab; then
|
||||
ask "C++ compiler warning flags" cxx_warning_flags "-Wall -W -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings"
|
||||
fi
|
||||
echo
|
||||
echo "You probably want the default here, or could use -lncurses_g for"
|
||||
echo "debugging ncurses. Use -lcurses -ltermcap if you want to try that,"
|
||||
@@ -409,6 +422,29 @@ main(void)
|
||||
}
|
||||
EOF
|
||||
|
||||
check_func sig_t <<EOF
|
||||
#include <signal.h>
|
||||
|
||||
sig_t s;
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
check_func getprogname <<EOF
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
const char *n = getprogname();
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "#endif /* !defined(LINUX_BSD_GAMES_H) */" >>include/bsd-games.h
|
||||
|
||||
|
||||
@@ -630,6 +666,24 @@ EOF
|
||||
for dir in $make_dirs; do
|
||||
udir=$(slashdot_to_under $dir)
|
||||
eval clean_$udir=
|
||||
if [ $dir = dab ]; then
|
||||
cat >>GNUmakefile <<EOF
|
||||
include $dir/Makefrag
|
||||
|
||||
$dir/%.o: $dir/%.cc
|
||||
\$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -c \$< -o \$@
|
||||
|
||||
$dir/%.ii: $dir/%.cc
|
||||
\$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -E \$< -o \$@
|
||||
|
||||
$dir/%.s: $dir/%.cc
|
||||
\$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS) -S -fverbose-asm \$< -o \$@
|
||||
|
||||
$dir/%.d: $dir/%.cc
|
||||
./mkdep \$< \$@ \$(CXX) \$(CXXFLAGS) \$(${udir}_CXXFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
|
||||
|
||||
EOF
|
||||
else
|
||||
cat >>GNUmakefile <<EOF
|
||||
include $dir/Makefrag
|
||||
|
||||
@@ -646,6 +700,7 @@ $dir/%.d: $dir/%.c
|
||||
./mkdep \$< \$@ \$(CC) \$(CFLAGS) \$(${udir}_CFLAGS) \$(${udir}_DEFS) \$(BASE_INCS) -I$dir \$(${udir}_INCS)
|
||||
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
|
||||
# This temporary file is needed because we don't know whether the last
|
||||
@@ -687,13 +742,18 @@ while read prog objs; do
|
||||
eval $obj_dep_var=y
|
||||
fi
|
||||
done
|
||||
if [ $dir = dab ]; then
|
||||
ccvar=CXX
|
||||
else
|
||||
ccvar=CC
|
||||
fi
|
||||
cat >>GNUmakefile <<EOF
|
||||
ifneq (\$(nodep),true)
|
||||
include $deps_to_inc
|
||||
endif
|
||||
|
||||
$exec: $nobjs
|
||||
\$(CC) \$(LDFLAGS) \$^ $libs \$(BASE_LIBS) -o \$@
|
||||
\$($ccvar) \$(LDFLAGS) \$^ $libs \$(BASE_LIBS) -o \$@
|
||||
|
||||
EOF
|
||||
done <exec.objs.tmp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: countmail.6,v 1.9 2003/07/26 17:31:47 salo Exp $
|
||||
.\" $NetBSD: countmail.6,v 1.10 2004/02/08 00:31:16 jsm Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997 Matthew R. Green
|
||||
.\" All rights reserved.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: crib.c,v 1.17 2003/08/07 09:37:09 agc Exp $ */
|
||||
/* $NetBSD: crib.c,v 1.19 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: crib.c,v 1.17 2003/08/07 09:37:09 agc Exp $");
|
||||
__RCSID("$NetBSD: crib.c,v 1.19 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -56,7 +56,7 @@ __RCSID("$NetBSD: crib.c,v 1.17 2003/08/07 09:37:09 agc Exp $");
|
||||
#include "cribcur.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
int main __P((int, char *[]));
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
@@ -107,7 +107,7 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
initscr();
|
||||
(void)signal(SIGINT, rint);
|
||||
(void)signal(SIGINT, receive_intr);
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cribbage.h,v 1.9 2003/08/07 09:37:09 agc Exp $ */
|
||||
/* $NetBSD: cribbage.h,v 1.12 2004/02/08 22:23:50 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -57,56 +57,56 @@ extern BOOLEAN playing; /* currently playing game */
|
||||
|
||||
extern char explan[]; /* string for explanation */
|
||||
|
||||
void addmsg __P((const char *, ...))
|
||||
void addmsg(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
int adjust __P((const CARD [], CARD));
|
||||
int anymove __P((const CARD [], int, int));
|
||||
int anysumto __P((const CARD [], int, int, int));
|
||||
void bye __P((void));
|
||||
int cchose __P((const CARD [], int, int));
|
||||
void cdiscard __P((BOOLEAN));
|
||||
int chkscr __P((int *, int));
|
||||
int comphand __P((const CARD [], const char *));
|
||||
void cremove __P((CARD, CARD [], int));
|
||||
int cut __P((BOOLEAN, int));
|
||||
int deal __P((int));
|
||||
void discard __P((BOOLEAN));
|
||||
void do_wait __P((void));
|
||||
void endmsg __P((void));
|
||||
int eq __P((CARD, CARD));
|
||||
int fifteens __P((const CARD [], int));
|
||||
void game __P((void));
|
||||
void gamescore __P((void));
|
||||
char *getline __P((void));
|
||||
int getuchar __P((void));
|
||||
int incard __P((CARD *));
|
||||
int infrom __P((const CARD [], int, const char *));
|
||||
void instructions __P((void));
|
||||
int is_one __P((CARD, const CARD [], int));
|
||||
void makeboard __P((void));
|
||||
void makedeck __P((CARD []));
|
||||
void makeknown __P((const CARD [], int));
|
||||
void msg __P((const char *, ...))
|
||||
int adjust(const CARD [], CARD);
|
||||
int anymove(const CARD [], int, int);
|
||||
int anysumto(const CARD [], int, int, int);
|
||||
void bye(void);
|
||||
int cchose(const CARD [], int, int);
|
||||
void cdiscard(BOOLEAN);
|
||||
int chkscr(int *, int);
|
||||
int comphand(const CARD [], const char *);
|
||||
void cremove(CARD, CARD [], int);
|
||||
int cut(BOOLEAN, int);
|
||||
int deal(int);
|
||||
void discard(BOOLEAN);
|
||||
void do_wait(void);
|
||||
void endmsg(void);
|
||||
int eq(CARD, CARD);
|
||||
int fifteens(const CARD [], int);
|
||||
void game(void);
|
||||
void gamescore(void);
|
||||
char *getline(void);
|
||||
int getuchar(void);
|
||||
int incard(CARD *);
|
||||
int infrom(const CARD [], int, const char *);
|
||||
void instructions(void);
|
||||
int is_one(CARD, const CARD [], int);
|
||||
void makeboard(void);
|
||||
void makedeck(CARD []);
|
||||
void makeknown(const CARD [], int);
|
||||
void msg(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
int msgcard __P((CARD, BOOLEAN));
|
||||
int msgcrd __P((CARD, BOOLEAN, const char *, BOOLEAN));
|
||||
int number __P((int, int, const char *));
|
||||
int numofval __P((const CARD [], int, int));
|
||||
int pairuns __P((const CARD [], int));
|
||||
int peg __P((BOOLEAN));
|
||||
int pegscore __P((CARD, const CARD [], int, int));
|
||||
int playhand __P((BOOLEAN));
|
||||
int plyrhand __P((const CARD [], const char *));
|
||||
void prcard __P((WINDOW *, int, int, CARD, BOOLEAN));
|
||||
void prcrib __P((BOOLEAN, BOOLEAN));
|
||||
void prhand __P((const CARD [], int, WINDOW *, BOOLEAN));
|
||||
void printcard __P((WINDOW *, int, CARD, BOOLEAN));
|
||||
void prpeg __P((int, int, BOOLEAN));
|
||||
void prtable __P((int));
|
||||
int readchar __P((void));
|
||||
void rint __P((int)) __attribute__((__noreturn__));
|
||||
int score __P((BOOLEAN));
|
||||
int scorehand __P((const CARD [], CARD, int, BOOLEAN, BOOLEAN));
|
||||
void shuffle __P((CARD []));
|
||||
void sorthand __P((CARD [], int));
|
||||
void wait_for __P((int));
|
||||
int msgcard(CARD, BOOLEAN);
|
||||
int msgcrd(CARD, BOOLEAN, const char *, BOOLEAN);
|
||||
int number(int, int, const char *);
|
||||
int numofval(const CARD [], int, int);
|
||||
int pairuns(const CARD [], int);
|
||||
int peg(BOOLEAN);
|
||||
int pegscore(CARD, const CARD [], int, int);
|
||||
int playhand(BOOLEAN);
|
||||
int plyrhand(const CARD [], const char *);
|
||||
void prcard(WINDOW *, int, int, CARD, BOOLEAN);
|
||||
void prcrib(BOOLEAN, BOOLEAN);
|
||||
void prhand(const CARD [], int, WINDOW *, BOOLEAN);
|
||||
void printcard(WINDOW *, int, CARD, BOOLEAN);
|
||||
void prpeg(int, int, BOOLEAN);
|
||||
void prtable(int);
|
||||
int readchar(void);
|
||||
void receive_intr(int) __attribute__((__noreturn__));
|
||||
int score(BOOLEAN);
|
||||
int scorehand(const CARD [], CARD, int, BOOLEAN, BOOLEAN);
|
||||
void shuffle(CARD []);
|
||||
void sorthand(CARD [], int);
|
||||
void wait_for(int);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: io.c,v 1.16 2003/08/07 09:37:10 agc Exp $ */
|
||||
/* $NetBSD: io.c,v 1.17 2004/01/26 09:58:35 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: io.c,v 1.16 2003/08/07 09:37:10 agc Exp $");
|
||||
__RCSID("$NetBSD: io.c,v 1.17 2004/01/26 09:58:35 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -582,7 +582,7 @@ getline()
|
||||
}
|
||||
|
||||
void
|
||||
rint(signo)
|
||||
receive_intr(signo)
|
||||
int signo __attribute__((__unused__));
|
||||
{
|
||||
bye();
|
||||
|
||||
6
dab/.cvsignore
Normal file
6
dab/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
||||
a.out
|
||||
*.d
|
||||
*.ii
|
||||
*.s
|
||||
*.d.tmp
|
||||
dab
|
||||
12
dab/Makefile.bsd
Normal file
12
dab/Makefile.bsd
Normal file
@@ -0,0 +1,12 @@
|
||||
# $NetBSD: Makefile,v 1.3 2004/01/05 15:35:59 christos Exp $
|
||||
|
||||
WARNS=2
|
||||
DPADD+=${LIBCURSES} ${LIBTERMCAP} ${LIBM}
|
||||
LDADD+=-lcurses -ltermcap -lm
|
||||
|
||||
PROG_CXX=dab
|
||||
MAN=dab.6
|
||||
SRCS=algor.cc board.cc main.cc human.cc box.cc player.cc gamescreen.cc \
|
||||
ttyscrn.cc random.cc
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
36
dab/Makefrag
Normal file
36
dab/Makefrag
Normal file
@@ -0,0 +1,36 @@
|
||||
# Makefrag - makefile fragment for banner
|
||||
#
|
||||
# Copyright (c) 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
dab_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
dab_all: dab/dab dab/dab.6
|
||||
|
||||
dab_install: dab_all
|
||||
$(INSTALL_BINARY) dab/dab $(INSTALL_PREFIX)$(GAMESDIR)/dab
|
||||
$(HIDE_GAME) dab
|
||||
$(INSTALL_MANUAL) dab/dab.6
|
||||
314
dab/algor.cc
Normal file
314
dab/algor.cc
Normal file
@@ -0,0 +1,314 @@
|
||||
/* $NetBSD: algor.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* algor.C: Computer algorithm
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: algor.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include "algor.h"
|
||||
#include "board.h"
|
||||
#include "box.h"
|
||||
#include "random.h"
|
||||
|
||||
ALGOR::ALGOR(const char c) : PLAYER(c)
|
||||
{
|
||||
#ifdef notyet
|
||||
// Single Edges = (x + y) * 2
|
||||
_edge1 = (_b.nx() * _b.ny()) * 2;
|
||||
// Shared Edges = (x * (y - 1)) + ((x - 1) * y)
|
||||
_edge2 = (_b.nx() * (_b.ny() - 1)) + ((_b.nx() - 1) * _b.ny());
|
||||
// Maximum Edges filled before closure = x * y * 2
|
||||
_maxedge = _b.nx() * _b.ny() * 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Find the first closure, i.e. a box that has 3 edges
|
||||
int ALGOR::find_closure(size_t& y, size_t& x, int& dir, BOARD& b)
|
||||
{
|
||||
RANDOM rdy(b.ny()), rdx(b.nx());
|
||||
|
||||
for (y = rdy(); y < b.ny(); y = rdy()) {
|
||||
rdx.clear();
|
||||
for (x = rdx(); x < b.nx(); x = rdx()) {
|
||||
BOX box(y, x, b);
|
||||
if (box.count() == 3) {
|
||||
for (dir = BOX::first; dir < BOX::last; dir++)
|
||||
if (!box.isset(dir))
|
||||
return 1;
|
||||
b.abort("find_closure: 3 sided box[%d,%d] has no free sides",
|
||||
y, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
size_t ALGOR::find_single()
|
||||
{
|
||||
size_t ne;
|
||||
|
||||
// Find the number of single edges in use
|
||||
for (size_t x = 0; x < b.nx(); x++) {
|
||||
BOX tbox(0, x, b);
|
||||
ne += tbox.isset(BOX::top);
|
||||
BOX bbox(b.ny() - 1, x, b);
|
||||
ne += bbox.isset(BOX::bottom);
|
||||
}
|
||||
for (size_t y = 0; y < _b.ny(); y++) {
|
||||
BOX lbox(y, 0, b);
|
||||
ne += lbox.isset(BOX::left);
|
||||
BOX rbox(y,_b.nx() - 1, b);
|
||||
ne += rbox.isset(BOX::right);
|
||||
}
|
||||
return ne;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Count a closure, by counting all boxes that we can close in the current
|
||||
// move
|
||||
size_t ALGOR::count_closure(size_t& y, size_t& x, int& dir, BOARD& b)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t tx, ty;
|
||||
int tdir, mv;
|
||||
|
||||
while (find_closure(ty, tx, tdir, b)) {
|
||||
if (i == 0) {
|
||||
// Mark the beginning of the closure
|
||||
x = tx;
|
||||
y = ty;
|
||||
dir = tdir;
|
||||
}
|
||||
if ((mv = b.domove(ty, tx, tdir, getWho())) == -1)
|
||||
b.abort("count_closure: Invalid move (%d, %d, %d)", y, x, dir);
|
||||
else
|
||||
i += mv;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find the largest closure, by closing all possible closures.
|
||||
* return the number of boxes closed in the maximum closure,
|
||||
* and the first box of the maximum closure in (x, y, dir)
|
||||
*/
|
||||
int ALGOR::find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b)
|
||||
{
|
||||
BOARD nb(b);
|
||||
int tdir, maxdir = -1;
|
||||
size_t nbox, maxbox = 0;
|
||||
size_t tx, ty, maxx = ~0, maxy = ~0;
|
||||
|
||||
while ((nbox = count_closure(ty, tx, tdir, nb)) != 0)
|
||||
if (nbox > maxbox) {
|
||||
// This closure is better, update max
|
||||
maxbox = nbox;
|
||||
maxx = tx;
|
||||
maxy = ty;
|
||||
maxdir = tdir;
|
||||
}
|
||||
|
||||
// Return the max found
|
||||
y = maxy;
|
||||
x = maxx;
|
||||
dir = maxdir;
|
||||
return maxbox;
|
||||
}
|
||||
|
||||
|
||||
// Find if a turn does not result in a capture on the given box
|
||||
// and return the direction if found.
|
||||
int ALGOR::try_good_turn(BOX& box, size_t y, size_t x, int& dir, BOARD& b)
|
||||
{
|
||||
// Sanity check; we must have a good box
|
||||
if (box.count() >= 2)
|
||||
b.abort("try_good_turn: box[%d,%d] has more than 2 sides occupied",
|
||||
y, x);
|
||||
|
||||
// Make sure we don't make a closure in an adjacent box.
|
||||
// We use a random direction to randomize the game
|
||||
RANDOM rd(BOX::last);
|
||||
for (dir = rd(); dir < BOX::last; dir = rd())
|
||||
if (!box.isset(dir)) {
|
||||
size_t by = y + BOX::edges[dir].y;
|
||||
size_t bx = x + BOX::edges[dir].x;
|
||||
if (!b.bounds(by, bx))
|
||||
return 1;
|
||||
|
||||
BOX nbox(by, bx, b);
|
||||
if (nbox.count() < 2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Try to find a turn that does not result in an opponent closure, and
|
||||
// return it in (x, y, dir); if not found return 0.
|
||||
int ALGOR::find_good_turn(size_t& y, size_t& x, int& dir, const BOARD& b)
|
||||
{
|
||||
BOARD nb(b);
|
||||
RANDOM rdy(b.ny()), rdx(b.nx());
|
||||
|
||||
for (y = rdy(); y < b.ny(); y = rdy()) {
|
||||
rdx.clear();
|
||||
for (x = rdx(); x < b.nx(); x = rdx()) {
|
||||
BOX box(y, x, nb);
|
||||
if (box.count() < 2 && try_good_turn(box, y, x, dir, nb))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// On a box with 2 edges, return the first or the last free edge, depending
|
||||
// on the order specified
|
||||
int ALGOR::try_bad_turn(BOX& box, size_t& y, size_t& x, int& dir, BOARD& b,
|
||||
int last)
|
||||
{
|
||||
if (4 - box.count() <= last)
|
||||
b.abort("try_bad_turn: Called at [%d,%d] for %d with %d",
|
||||
y, x, last, box.count());
|
||||
for (dir = BOX::first; dir < BOX::last; dir++)
|
||||
if (!box.isset(dir)) {
|
||||
if (!last)
|
||||
return 1;
|
||||
else
|
||||
last--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find a box that has 2 edges and return the first free edge of that
|
||||
// box or the last free edge of that box
|
||||
int ALGOR::find_bad_turn(size_t& y, size_t& x, int& dir, BOARD& b, int last)
|
||||
{
|
||||
RANDOM rdy(b.ny()), rdx(b.nx());
|
||||
for (y = rdy(); y < b.ny(); y = rdy()) {
|
||||
rdx.clear();
|
||||
for (x = rdx(); x < b.nx(); x = rdx()) {
|
||||
BOX box(y, x, b);
|
||||
if ((4 - box.count()) > last &&
|
||||
try_bad_turn(box, y, x, dir, b, last))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ALGOR::find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b,
|
||||
int last)
|
||||
{
|
||||
BOARD nb(b);
|
||||
int tdir, mindir = -1, xdir, mv;
|
||||
// number of boxes per closure
|
||||
size_t nbox, minbox = nb.nx() * nb.ny() + 1;
|
||||
size_t tx, ty, minx = ~0, miny = ~0;
|
||||
|
||||
while (find_bad_turn(ty, tx, tdir, nb, last)) {
|
||||
|
||||
// Play a bad move that would cause the opponent's closure
|
||||
if ((mv = nb.domove(ty, tx, tdir, getWho())) != 0)
|
||||
b.abort("find_min_closure1: Invalid move %d (%d, %d, %d)", mv,
|
||||
ty, tx, tdir);
|
||||
|
||||
// Count the opponent's closure
|
||||
if ((nbox = count_closure(y, x, xdir, nb)) == 0)
|
||||
b.abort("find_min_closure1: no closure found");
|
||||
|
||||
if (nbox <= minbox) {
|
||||
// This closure has fewer boxes
|
||||
minbox = nbox;
|
||||
minx = tx;
|
||||
miny = ty;
|
||||
mindir = tdir;
|
||||
}
|
||||
}
|
||||
|
||||
y = miny;
|
||||
x = minx;
|
||||
dir = mindir;
|
||||
return minbox;
|
||||
}
|
||||
|
||||
|
||||
// Search for the move that makes the opponent close the least number of
|
||||
// boxes; returns 1 if a move found, 0 otherwise
|
||||
int ALGOR::find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b)
|
||||
{
|
||||
size_t x1, y1;
|
||||
int dir1;
|
||||
int count = b.ny() * b.nx() + 1, count1;
|
||||
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
if (count > (count1 = find_min_closure1(y1, x1, dir1, b, i))) {
|
||||
count = count1;
|
||||
y = y1;
|
||||
x = x1;
|
||||
dir = dir1;
|
||||
}
|
||||
|
||||
return (size_t) count != b.ny() * b.nx() + 1;
|
||||
}
|
||||
|
||||
// Return a move in (y, x, dir)
|
||||
void ALGOR::play(const BOARD& b, size_t& y, size_t& x, int& dir)
|
||||
{
|
||||
// See if we can close the largest closure available
|
||||
if (find_max_closure(y, x, dir, b))
|
||||
return;
|
||||
|
||||
#ifdef notyet
|
||||
size_t sgl = find_single();
|
||||
size_t dbl = find_double();
|
||||
#endif
|
||||
|
||||
// See if we can play an edge without giving the opponent a box
|
||||
if (find_good_turn(y, x, dir, b))
|
||||
return;
|
||||
|
||||
// Too bad, find the move that gives the opponent the fewer boxes
|
||||
if (find_min_closure(y, x, dir, b))
|
||||
return;
|
||||
}
|
||||
86
dab/algor.h
Normal file
86
dab/algor.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $NetBSD: algor.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* algor.h: Computer's algorithm
|
||||
*/
|
||||
|
||||
#ifndef _H_ALGOR
|
||||
#define _H_ALGOR
|
||||
|
||||
#include "player.h"
|
||||
|
||||
class BOARD;
|
||||
class BOX;
|
||||
|
||||
class ALGOR : public PLAYER {
|
||||
public:
|
||||
ALGOR(const char c);
|
||||
// Return a proposed move in (y, x, dir)
|
||||
void play(const BOARD& b, size_t& y, size_t& x, int& dir);
|
||||
|
||||
private:
|
||||
// Closure searches
|
||||
int find_closure(size_t& y, size_t& x, int& dir, BOARD& b);
|
||||
int find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b);
|
||||
int find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b,
|
||||
int last);
|
||||
int find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b);
|
||||
|
||||
// Move searches
|
||||
int find_good_turn(size_t& y, size_t& x, int& dir, const BOARD& b);
|
||||
int find_bad_turn(size_t& y, size_t& x, int& dir, BOARD& b, int last);
|
||||
|
||||
// Move Attempts
|
||||
int try_bad_turn(BOX& box, size_t& y, size_t& x, int& dir, BOARD& b,
|
||||
int last);
|
||||
int try_good_turn(BOX& box, size_t y, size_t x, int& dir, BOARD& b);
|
||||
|
||||
// Utils
|
||||
size_t count_closure(size_t& y, size_t& x, int& dir, BOARD& b);
|
||||
|
||||
#ifdef notyet
|
||||
size_t find_single(void);
|
||||
#endif
|
||||
|
||||
size_t _edge1;
|
||||
size_t _edge2;
|
||||
size_t _maxedge;
|
||||
};
|
||||
|
||||
#endif
|
||||
260
dab/board.cc
Normal file
260
dab/board.cc
Normal file
@@ -0,0 +1,260 @@
|
||||
/* $NetBSD: board.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* board.C: Board manipulations
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: board.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "board.h"
|
||||
#include "gamescreen.h"
|
||||
#include "box.h"
|
||||
#include "player.h"
|
||||
|
||||
BOARD::BOARD(size_t y, size_t x, GAMESCREEN* scrn) :
|
||||
_ny(y),
|
||||
_nx(x),
|
||||
_scrn(scrn)
|
||||
{
|
||||
_ty = 2 * _ny + 1;
|
||||
_tx = 2 * _nx + 1;
|
||||
|
||||
_b = new int*[_ty];
|
||||
|
||||
for (y = 0; y < _ty; y++)
|
||||
_b[y] = new int[_tx];
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
BOARD::BOARD(const BOARD& b) :
|
||||
_ty(b._ty),
|
||||
_tx(b._tx),
|
||||
_ny(b._ny),
|
||||
_nx(b._nx),
|
||||
_scrn(NULL)
|
||||
{
|
||||
_b = new int*[_ty];
|
||||
|
||||
for (size_t y = 0; y < _ty; y++) {
|
||||
_b[y] = new int[_tx];
|
||||
(void) memcpy(_b[y], b._b[y], _tx * sizeof(int));
|
||||
}
|
||||
}
|
||||
|
||||
BOARD::~BOARD()
|
||||
{
|
||||
size_t y;
|
||||
|
||||
for (y = 0; y < _ty; y++)
|
||||
delete[] _b[y];
|
||||
|
||||
delete[] _b;
|
||||
}
|
||||
|
||||
// Clear all boxes and reset state for a new game
|
||||
void BOARD::init(void)
|
||||
{
|
||||
size_t x, y;
|
||||
|
||||
for (y = 0; y < _ny; y++)
|
||||
for (x = 0; x < _nx; x++) {
|
||||
BOX box(y, x, *this);
|
||||
box.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a move for player with initial 'c', adding an edge at box(x, y)
|
||||
* and the specified direction.
|
||||
* returns:
|
||||
* -1: Invalid move
|
||||
* n: Number of closures n E [0..2]
|
||||
*/
|
||||
int BOARD::domove(size_t y, size_t x, int dir, char c)
|
||||
{
|
||||
int closed = 0;
|
||||
|
||||
// Check if out of bounds
|
||||
if (!bounds(y, x))
|
||||
return -1;
|
||||
|
||||
BOX box1(y, x, *this);
|
||||
|
||||
// Check if the edge is already there
|
||||
if (box1.isset(dir))
|
||||
return -1;
|
||||
|
||||
box1.set(dir);
|
||||
|
||||
if (box1.count() == 4) {
|
||||
// New box; name it and count it
|
||||
box1.name() = c;
|
||||
closed++;
|
||||
}
|
||||
|
||||
box1.paint();
|
||||
|
||||
// Check other box
|
||||
x += BOX::edges[dir].x;
|
||||
y += BOX::edges[dir].y;
|
||||
|
||||
if (bounds(y, x)) {
|
||||
BOX box2(y, x, *this);
|
||||
if (box2.count() == 4) {
|
||||
box2.name() = c;
|
||||
box2.paint();
|
||||
closed++;
|
||||
}
|
||||
}
|
||||
return closed;
|
||||
}
|
||||
|
||||
// Return true if the board is full
|
||||
int BOARD::full(void) const
|
||||
{
|
||||
for (size_t y = 0; y < _ny; y++)
|
||||
for (size_t x = 0; x < _nx; x++) {
|
||||
BOX box(y, x, (BOARD&) *this);
|
||||
if (box.count() != 4)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Return if the coordinates are within bounds; we don't check for < 0,
|
||||
// since size_t is unsigned
|
||||
int BOARD::bounds(size_t y, size_t x) const
|
||||
{
|
||||
return x < _nx && y < _ny;
|
||||
}
|
||||
|
||||
// Paint all boxes, effectively redrawing the board
|
||||
void BOARD::paint(void) const
|
||||
{
|
||||
for (size_t y = 0; y < _ny; y++)
|
||||
for (size_t x = 0; x < _nx; x++) {
|
||||
BOX box(y, x, (BOARD&) *this);
|
||||
box.paint();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the screen
|
||||
void BOARD::clean(void) const
|
||||
{
|
||||
if (!_scrn)
|
||||
return;
|
||||
_scrn->clean();
|
||||
}
|
||||
|
||||
// Move cursor to x, y
|
||||
void BOARD::setpos(size_t y, size_t x) const
|
||||
{
|
||||
if (!_scrn)
|
||||
return;
|
||||
_scrn->moveto(y, x);
|
||||
_scrn->redraw();
|
||||
}
|
||||
|
||||
// Return character indicating move
|
||||
int BOARD::getmove(void) const
|
||||
{
|
||||
if (!_scrn)
|
||||
return 'q';
|
||||
_scrn->redraw();
|
||||
return _scrn->getinput();
|
||||
}
|
||||
|
||||
// Ring the bell
|
||||
void BOARD::bell(void) const
|
||||
{
|
||||
if (!_scrn)
|
||||
return;
|
||||
_scrn->bell();
|
||||
}
|
||||
|
||||
// Post the score in the current game for player i
|
||||
void BOARD::score(size_t i, const PLAYER& p)
|
||||
{
|
||||
if (_scrn == NULL)
|
||||
return;
|
||||
_scrn->score(i, p);
|
||||
}
|
||||
|
||||
// Post the number of games won for player i
|
||||
void BOARD::games(size_t i, const PLAYER& p)
|
||||
{
|
||||
if (_scrn == NULL)
|
||||
return;
|
||||
_scrn->games(i, p);
|
||||
}
|
||||
|
||||
// Post the total score for player i
|
||||
void BOARD::total(size_t i, const PLAYER& p)
|
||||
{
|
||||
if (_scrn == NULL)
|
||||
return;
|
||||
_scrn->total(i, p);
|
||||
}
|
||||
|
||||
// Post the total score for player i
|
||||
void BOARD::ties(const PLAYER& p)
|
||||
{
|
||||
if (_scrn == NULL)
|
||||
return;
|
||||
_scrn->ties(p);
|
||||
}
|
||||
|
||||
// Internal algorithm error; post and abort
|
||||
void BOARD::abort(const char* s, ...) const
|
||||
{
|
||||
for (size_t i = 0; i < _ny; i++)
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
va_list ap;
|
||||
fprintf(stderr, "Algorithm internal error: ");
|
||||
va_start(ap, s);
|
||||
vfprintf(stderr, s, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, "\n");
|
||||
::abort();
|
||||
}
|
||||
92
dab/board.h
Normal file
92
dab/board.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* $NetBSD: board.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* board.h: Board functions
|
||||
*/
|
||||
|
||||
#ifndef _H_BOARD
|
||||
#define _H_BOARD
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class GAMESCREEN;
|
||||
class PLAYER;
|
||||
|
||||
class BOARD {
|
||||
public:
|
||||
// Constructors and destructor
|
||||
BOARD(size_t y, size_t x, GAMESCREEN* scrn);// For the main screen
|
||||
BOARD(const BOARD& b); // For scratch screens
|
||||
~BOARD();
|
||||
|
||||
// member access
|
||||
size_t nx(void) const { return _nx; }
|
||||
size_t ny(void) const { return _ny; }
|
||||
size_t tx(void) const { return _tx; }
|
||||
size_t ty(void) const { return _ty; }
|
||||
GAMESCREEN* getScrn(void) const { return _scrn; }
|
||||
int& data(size_t y, size_t x) { return _b[y][x]; }
|
||||
|
||||
// Computing
|
||||
int domove(size_t y, size_t x, int dir, char c); // Play move
|
||||
void init(void); // Initialize a new game
|
||||
int full(void) const; // True if no more moves
|
||||
int bounds(size_t y, size_t x) const; // True if in bounds
|
||||
|
||||
// Screen updates
|
||||
void paint(void) const; // Redraw screen
|
||||
void clean(void) const; // Clear screen
|
||||
void setpos(size_t y, size_t x) const; // move cursor to pos
|
||||
int getmove(void) const; // Return move
|
||||
void bell(void) const; // Beep!
|
||||
void score(size_t i, const PLAYER& p); // Post score
|
||||
void games(size_t i, const PLAYER& p); // Post games
|
||||
void total(size_t i, const PLAYER& p); // Post totals
|
||||
void ties(const PLAYER& p); // Post ties
|
||||
void abort(const char *s, ...) const; // Algorithm error
|
||||
|
||||
|
||||
private:
|
||||
size_t _ty, _tx; // number of symbols in x and y dimension
|
||||
size_t _ny, _nx; // number of boxes in the x and y dimension
|
||||
int** _b; // board array of symbols
|
||||
GAMESCREEN* _scrn; // screen access, if we have one
|
||||
};
|
||||
|
||||
#endif
|
||||
157
dab/box.cc
Normal file
157
dab/box.cc
Normal file
@@ -0,0 +1,157 @@
|
||||
/* $NetBSD: box.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* box.C: Box computations
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: box.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include "box.h"
|
||||
#include "board.h"
|
||||
#include "gamescreen.h"
|
||||
#include <curses.h>
|
||||
|
||||
const POINT BOX::edges[BOX::last] =
|
||||
{ { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 } };
|
||||
const POINT BOX::corners[BOX::last] =
|
||||
{ { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };
|
||||
const int BOX::syms[BOX::last] =
|
||||
{ GAMESCREEN::GS_HLINE, GAMESCREEN::GS_HLINE,
|
||||
GAMESCREEN::GS_VLINE, GAMESCREEN::GS_VLINE };
|
||||
|
||||
BOX::BOX(size_t py, size_t px, BOARD& b) :
|
||||
_b(b)
|
||||
{
|
||||
_centery = py * 2 + 1;
|
||||
_centerx = px * 2 + 1;
|
||||
}
|
||||
|
||||
void BOX::addcorner(size_t y, size_t x)
|
||||
{
|
||||
char sym;
|
||||
_b.getScrn()->moveto(y, x);
|
||||
if (x == 0) {
|
||||
if (y == 0)
|
||||
sym = GAMESCREEN::GS_ULCORNER;
|
||||
else if (y == _b.ty() - 1)
|
||||
sym = GAMESCREEN::GS_LLCORNER;
|
||||
else
|
||||
sym = GAMESCREEN::GS_LTEE;
|
||||
} else if (x == _b.tx() - 1) {
|
||||
if (y == 0)
|
||||
sym = GAMESCREEN::GS_URCORNER;
|
||||
else if (y == _b.ty() - 1)
|
||||
sym = GAMESCREEN::GS_LRCORNER;
|
||||
else
|
||||
sym = GAMESCREEN::GS_RTEE;
|
||||
} else if (y == 0)
|
||||
sym = GAMESCREEN::GS_TTEE;
|
||||
else if (y == _b.ty() - 1)
|
||||
sym = GAMESCREEN::GS_BTEE;
|
||||
else
|
||||
sym = GAMESCREEN::GS_PLUS;
|
||||
|
||||
_b.getScrn()->addedge(sym);
|
||||
}
|
||||
|
||||
// Paint a box
|
||||
void BOX::paint(void)
|
||||
{
|
||||
int e;
|
||||
if (_b.getScrn() == NULL)
|
||||
return;
|
||||
|
||||
_b.getScrn()->moveto(_centery, _centerx);
|
||||
_b.getScrn()->addsym(name());
|
||||
|
||||
for (e = BOX::first; e < BOX::last; e++) {
|
||||
addcorner(_centery + corners[e].y, _centerx + corners[e].x);
|
||||
_b.getScrn()->moveto(_centery + edges[e].y, _centerx + edges[e].x);
|
||||
_b.getScrn()->addedge(edge((EDGE) e));
|
||||
}
|
||||
_b.getScrn()->redraw();
|
||||
}
|
||||
|
||||
// Return the name
|
||||
int& BOX::name(void)
|
||||
{
|
||||
return _b.data(_centery, _centerx);
|
||||
}
|
||||
|
||||
// Set an edge
|
||||
void BOX::set(int e)
|
||||
{
|
||||
_b.data(_centery + edges[e].y, _centerx + edges[e].x) = syms[e];
|
||||
}
|
||||
|
||||
// Clear an edge
|
||||
void BOX::clr(int e)
|
||||
{
|
||||
_b.data(_centery + edges[e].y, _centerx + edges[e].x) = ' ';
|
||||
}
|
||||
|
||||
// Test an edge
|
||||
int BOX::isset(int e) const
|
||||
{
|
||||
return _b.data(_centery + edges[e].y, _centerx + edges[e].x) != ' ';
|
||||
}
|
||||
|
||||
// Return the edge
|
||||
int& BOX::edge(int e)
|
||||
{
|
||||
return _b.data(_centery + edges[e].y, _centerx + edges[e].x);
|
||||
}
|
||||
|
||||
// Count the number of edges set in the box
|
||||
int BOX::count(void) const
|
||||
{
|
||||
int cnt = 0;
|
||||
|
||||
for (int e = BOX::first; e < BOX::last; e++)
|
||||
cnt += isset((EDGE) e);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
// Clear the box
|
||||
void BOX::reset(void)
|
||||
{
|
||||
for (int e = BOX::first; e < BOX::last; e++)
|
||||
clr((EDGE) e);
|
||||
name() = ' ';
|
||||
}
|
||||
100
dab/box.h
Normal file
100
dab/box.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $NetBSD: box.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* box.C: Single box utilities; A box is an entity with four edges, four
|
||||
* corners, and a center that maps directly to a board
|
||||
*/
|
||||
|
||||
#ifndef _H_BOX
|
||||
#define _H_BOX
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class BOARD;
|
||||
|
||||
class POINT {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class BOX {
|
||||
public:
|
||||
enum EDGE {
|
||||
first = 0,
|
||||
top = 0,
|
||||
bottom = 1,
|
||||
left = 2,
|
||||
right = 3,
|
||||
last = 4,
|
||||
};
|
||||
|
||||
BOX(size_t py, size_t px, BOARD& b);
|
||||
|
||||
void reset(void); // Clear a box
|
||||
void paint(void); // Paint a box
|
||||
|
||||
// Member access
|
||||
int& name(void);
|
||||
int& edge(int e);
|
||||
|
||||
// Edge maniputations
|
||||
void set(int e);
|
||||
void clr(int e);
|
||||
int isset(int e) const;
|
||||
|
||||
int count(void) const; // Count the number of edges in use
|
||||
|
||||
// Useful constants
|
||||
// Relative coordinates of the edges from the center of the box.
|
||||
static const POINT edges[BOX::last];
|
||||
// Relative coordinates of the corners from the center of the box.
|
||||
static const POINT corners[BOX::last];
|
||||
// Character symbols of the four edges
|
||||
static const int syms[BOX::last];
|
||||
|
||||
private:
|
||||
void addcorner(size_t y, size_t x); // add a corner character
|
||||
|
||||
size_t _centerx; // Coordinates of the center in board units
|
||||
size_t _centery;
|
||||
BOARD& _b; // The board we refer to
|
||||
};
|
||||
|
||||
#endif
|
||||
110
dab/dab.6
Normal file
110
dab/dab.6
Normal file
@@ -0,0 +1,110 @@
|
||||
.\" $NetBSD: dab.6,v 1.1.1.1 2003/12/26 17:57:04 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2003 Thomas Klausner.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd December 24, 2003
|
||||
.Dt DAB 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dab
|
||||
.Nd Dots and Boxes game
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl aw
|
||||
.Op Fl n Ar ngames
|
||||
.Op Fl p Ao Ar c|h Ac Ns Ao Ar c|h Ac
|
||||
.Op Ar xdim Oo Ar ydim Oc
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a game where each player tries to complete the most
|
||||
boxes.
|
||||
A turn consists of putting one border of a box; the player
|
||||
setting the fourth and final border of a box gets the
|
||||
point for the box and has another turn.
|
||||
.Pp
|
||||
The keys used are the vi keys:
|
||||
.Ic k
|
||||
for up,
|
||||
.Ic j
|
||||
for down,
|
||||
.Ic h
|
||||
for left, and
|
||||
.Ic l
|
||||
for right.
|
||||
To switch between even and odd rows, use one of the following
|
||||
keys:
|
||||
.Ic u
|
||||
.Pq diagonal right up ,
|
||||
.Ic y
|
||||
.Pq diagonal left up ,
|
||||
.Ic b
|
||||
.Pq diagonal left down ,
|
||||
.Ic n
|
||||
.Pq diagonal right down ;
|
||||
.Aq Ic space
|
||||
sets a new border,
|
||||
.Ic CTRL-L
|
||||
and
|
||||
.Ic CTRL-R
|
||||
redraw the screen, and
|
||||
.Ic q
|
||||
quits the game.
|
||||
.Pp
|
||||
Support options are:
|
||||
.Bl -tag -width XXnXngamesXXXXX
|
||||
.It Fl a
|
||||
Don't use the alternate character set.
|
||||
.It Fl n Ar ngames
|
||||
.Ar ngames
|
||||
games will be played.
|
||||
.Pq Especially useful in Fl p Ar cc No mode.
|
||||
.It Fl p Ao Ar c|h Ac Ns Ao Ar c|h Ac
|
||||
Select which of the two players is a human
|
||||
or a computer.
|
||||
The first argument is the first player;
|
||||
.Ic c
|
||||
stands for computer and
|
||||
.Ic h
|
||||
for human.
|
||||
.It Fl w
|
||||
Wait for a character press between games.
|
||||
.El
|
||||
.Pp
|
||||
.Ar xdim
|
||||
and
|
||||
.Ar ydim
|
||||
define the size of the board in the x and y
|
||||
dimensions.
|
||||
.Sh AUTHORS
|
||||
.An Christos Zoulas
|
||||
.Aq christos@NetBSD.org
|
||||
.Sh SEE ALSO
|
||||
.Rs
|
||||
.%A Elwyn R. Berlekamp
|
||||
.%T The Dots and Boxes Game: Sophisticated Child's Play
|
||||
.%D 2000
|
||||
.%I A K Peters
|
||||
.%O http://www.akpeters.com/book.asp?bID=111
|
||||
.Re
|
||||
51
dab/defs.h
Normal file
51
dab/defs.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* $NetBSD: defs.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* defs.h: Macro defines
|
||||
*/
|
||||
|
||||
#ifndef _H_DEFS
|
||||
#define _H_DEFS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define RCSID(id) \
|
||||
static const char *rcsid(const char* x) { return x ? rcsid(id) : x; }
|
||||
|
||||
#endif
|
||||
50
dab/gamescreen.cc
Normal file
50
dab/gamescreen.cc
Normal file
@@ -0,0 +1,50 @@
|
||||
/* $NetBSD: gamescreen.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* gamescreen.C: Common screen functions
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: gamescreen.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include "gamescreen.h"
|
||||
|
||||
// Nothing to do
|
||||
GAMESCREEN::~GAMESCREEN()
|
||||
{
|
||||
}
|
||||
79
dab/gamescreen.h
Normal file
79
dab/gamescreen.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* $NetBSD: gamescreen.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* screen.h: Screen base class
|
||||
*/
|
||||
|
||||
#ifndef _H_GAMESCREEN
|
||||
#define _H_GAMESCREEN
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class PLAYER;
|
||||
|
||||
class GAMESCREEN {
|
||||
public:
|
||||
enum EDGE {
|
||||
GS_HLINE,
|
||||
GS_VLINE,
|
||||
GS_ULCORNER,
|
||||
GS_URCORNER,
|
||||
GS_LLCORNER,
|
||||
GS_LRCORNER,
|
||||
GS_LTEE,
|
||||
GS_RTEE,
|
||||
GS_TTEE,
|
||||
GS_BTEE,
|
||||
GS_PLUS
|
||||
};
|
||||
virtual ~GAMESCREEN();
|
||||
virtual void clean(void) = 0; // Clear screen
|
||||
virtual void moveto(size_t y, size_t x) = 0; // Move to x, y
|
||||
virtual void addsym(const int sym) = 0; // Add character symbol
|
||||
virtual void addedge(const int sym) = 0; // Add character symbol
|
||||
virtual void redraw(void) = 0; // Refresh
|
||||
virtual int getinput(void) = 0; // Get user input
|
||||
virtual void bell(void) = 0; // Beep
|
||||
virtual void score(size_t p, const PLAYER& p) = 0; // Post current score
|
||||
virtual void games(size_t p, const PLAYER& p) = 0; // Post games won
|
||||
virtual void total(size_t p, const PLAYER& p) = 0; // Post total score
|
||||
virtual void ties(const PLAYER& p) = 0; // Post tie games
|
||||
};
|
||||
|
||||
#endif
|
||||
151
dab/human.cc
Normal file
151
dab/human.cc
Normal file
@@ -0,0 +1,151 @@
|
||||
/* $NetBSD: human.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* human.C: Human interface for dots, using rogue-like keys.
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: human.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include "human.h"
|
||||
#include "board.h"
|
||||
#include "box.h"
|
||||
|
||||
#define CONTROL(a) ((a) & 037)
|
||||
|
||||
HUMAN::HUMAN(const char c) :
|
||||
PLAYER(c),
|
||||
_curx(0),
|
||||
_cury(1)
|
||||
{
|
||||
}
|
||||
|
||||
void HUMAN::play(const BOARD& b, size_t& y, size_t& x, int& dir)
|
||||
{
|
||||
int mv;
|
||||
b.setpos(_cury, _curx);
|
||||
|
||||
for (;;) {
|
||||
switch (mv = b.getmove()) {
|
||||
case 'h': case 'H':
|
||||
_curx -= 2;
|
||||
break;
|
||||
|
||||
case 'l': case 'L':
|
||||
_curx += 2;
|
||||
break;
|
||||
|
||||
case 'k': case 'K':
|
||||
_cury -= 2;
|
||||
break;
|
||||
|
||||
case 'j': case 'J':
|
||||
_cury += 2;
|
||||
break;
|
||||
|
||||
case 'u': case 'U':
|
||||
_curx += 1;
|
||||
_cury -= 1;
|
||||
break;
|
||||
|
||||
case 'y': case 'Y':
|
||||
_curx -= 1;
|
||||
_cury -= 1;
|
||||
break;
|
||||
|
||||
case 'b': case 'B':
|
||||
_curx -= 1;
|
||||
_cury += 1;
|
||||
break;
|
||||
|
||||
case 'n': case 'N':
|
||||
_curx += 1;
|
||||
_cury += 1;
|
||||
break;
|
||||
|
||||
case 'q': case 'Q':
|
||||
exit(0);
|
||||
|
||||
case CONTROL('L'): case CONTROL('R'):
|
||||
b.clean();
|
||||
b.paint();
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
{
|
||||
x = _curx / 2;
|
||||
y = _cury / 2;
|
||||
|
||||
if (_cury & 1) {
|
||||
if (_curx == 0)
|
||||
dir = BOX::left;
|
||||
else {
|
||||
x--;
|
||||
dir = BOX::right;
|
||||
}
|
||||
}
|
||||
|
||||
if (_curx & 1) {
|
||||
if (_cury == 0)
|
||||
dir = BOX::top;
|
||||
else {
|
||||
y--;
|
||||
dir = BOX::bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// We add 2 before the comparison to avoid underflow
|
||||
if ((2 + _curx) - (_curx & 1) < 2)
|
||||
_curx = (b.nx() * 2) + (_curx & 1);
|
||||
if (_curx >= (b.nx() * 2) + 1)
|
||||
_curx = (_curx & 1);
|
||||
|
||||
if ((2 + _cury) - (_cury & 1) < 2)
|
||||
_cury = (b.ny() * 2) + (_cury & 1);
|
||||
if (_cury >= (b.ny() * 2) + 1)
|
||||
_cury = (_cury & 1);
|
||||
|
||||
b.setpos(_cury, _curx);
|
||||
}
|
||||
}
|
||||
59
dab/human.h
Normal file
59
dab/human.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* $NetBSD: human.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* human.h: Human input interface
|
||||
*/
|
||||
|
||||
#ifndef _H_HUMAN
|
||||
#define _H_HUMAN
|
||||
#include <stdlib.h>
|
||||
#include "player.h"
|
||||
|
||||
class BOARD;
|
||||
|
||||
class HUMAN : public PLAYER {
|
||||
public:
|
||||
HUMAN(const char c);
|
||||
// Return move in y, x, and dir
|
||||
void play(const BOARD& b, size_t& y, size_t& x, int& dir);
|
||||
private:
|
||||
size_t _curx, _cury; // Current cursor position
|
||||
};
|
||||
|
||||
#endif
|
||||
196
dab/main.cc
Normal file
196
dab/main.cc
Normal file
@@ -0,0 +1,196 @@
|
||||
/* $NetBSD: main.cc,v 1.2 2003/12/28 17:53:48 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* main.C: Main dots program
|
||||
*/
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: main.cc,v 1.2 2003/12/28 17:53:48 thorpej Exp $")
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include "algor.h"
|
||||
#include "board.h"
|
||||
#include "human.h"
|
||||
#include "ttyscrn.h"
|
||||
|
||||
// Print the command line usage
|
||||
static void usage(char* pname)
|
||||
{
|
||||
char* p = strrchr(pname, '/');
|
||||
if (p)
|
||||
p++;
|
||||
else
|
||||
p = pname;
|
||||
std::cerr << "Usage: " << p
|
||||
<< " [-w] [-p <c|h><c|h>] [-n <ngames>] [<ydim> [<xdim>]]" << std::endl;
|
||||
}
|
||||
|
||||
// Play a single game
|
||||
static void play(BOARD& b, PLAYER* p[2])
|
||||
{
|
||||
// Initialize
|
||||
b.init();
|
||||
p[0]->init();
|
||||
p[1]->init();
|
||||
b.paint();
|
||||
|
||||
// Alternate turns between players, scoring each turn
|
||||
for (size_t i = 0;; i = (i + 1) & 1) {
|
||||
b.score(i, *p[i]);
|
||||
if (!p[i]->domove(b)) {
|
||||
// No more moves, game over
|
||||
break;
|
||||
}
|
||||
b.score(i, *p[i]);
|
||||
}
|
||||
|
||||
// Find who won
|
||||
p[0]->wl(p[1]->getScore());
|
||||
p[1]->wl(p[0]->getScore());
|
||||
|
||||
// Post scores
|
||||
b.score(0, *p[0]);
|
||||
b.score(1, *p[1]);
|
||||
|
||||
// Post totals
|
||||
b.total(0, *p[0]);
|
||||
b.total(1, *p[1]);
|
||||
|
||||
// Post games
|
||||
b.games(0, *p[0]);
|
||||
b.games(1, *p[1]);
|
||||
|
||||
// Post ties
|
||||
b.ties(*p[0]);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
size_t ny, nx, nn = 1, wt = 0;
|
||||
const char* nc = "ch";
|
||||
int c;
|
||||
int acs = 1;
|
||||
|
||||
while ((c = getopt(argc, argv, "awp:n:")) != -1)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
acs = 0;
|
||||
break;
|
||||
case 'w':
|
||||
wt++;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
nc = optarg;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
nn = atoi(optarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get the size of the board if specified
|
||||
switch (argc - optind) {
|
||||
case 0:
|
||||
ny = nx = 3;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ny = nx = atoi(argv[optind]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
nx = atoi(argv[optind]);
|
||||
ny = atoi(argv[optind+1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
PLAYER* p[2];
|
||||
|
||||
// Allocate players
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
char n = nc[1] == nc[0] ? i + '0' : nc[i];
|
||||
switch (nc[i]) {
|
||||
case 'c':
|
||||
p[i] = new ALGOR(n);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
p[i] = new HUMAN(n);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
GAMESCREEN *sc = TTYSCRN::create(acs, ny, nx);
|
||||
if (sc == NULL)
|
||||
::errx(1, "Dimensions too large for current screen.");
|
||||
|
||||
BOARD b(ny, nx, sc);
|
||||
|
||||
// Play games
|
||||
while (nn--) {
|
||||
play(b, p);
|
||||
if (wt)
|
||||
b.getmove();
|
||||
}
|
||||
|
||||
if (wt == 0)
|
||||
b.getmove();
|
||||
// Cleanup
|
||||
delete sc;
|
||||
delete p[0];
|
||||
delete p[1];
|
||||
return 0;
|
||||
}
|
||||
98
dab/player.cc
Normal file
98
dab/player.cc
Normal file
@@ -0,0 +1,98 @@
|
||||
/* $NetBSD: player.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* player.C: Player base class
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: player.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include "board.h"
|
||||
#include "player.h"
|
||||
|
||||
PLAYER::PLAYER(char who) :
|
||||
_who(who),
|
||||
_score(0),
|
||||
_total(0),
|
||||
_games(0),
|
||||
_ties(0)
|
||||
{
|
||||
}
|
||||
|
||||
void PLAYER::init(void)
|
||||
{
|
||||
_score = 0;
|
||||
}
|
||||
|
||||
void PLAYER::wl(size_t sc)
|
||||
{
|
||||
_total += _score;
|
||||
_games += sc < _score;
|
||||
_ties += sc == _score;
|
||||
}
|
||||
|
||||
int PLAYER::domove(BOARD& b)
|
||||
{
|
||||
size_t y, x;
|
||||
int dir;
|
||||
int score;
|
||||
|
||||
for (;;) {
|
||||
if (b.full())
|
||||
return 0;
|
||||
|
||||
play(b, y, x, dir);
|
||||
|
||||
switch (score = b.domove(y, x, dir, _who)) {
|
||||
case 0:
|
||||
// No closure
|
||||
return 1;
|
||||
|
||||
case -1:
|
||||
// Not a valid move
|
||||
b.bell();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Closure, play again
|
||||
_score += score;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
76
dab/player.h
Normal file
76
dab/player.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $NetBSD: player.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* player.h: Player base class
|
||||
*/
|
||||
#ifndef _H_PLAYER
|
||||
#define _H_PLAYER
|
||||
|
||||
class BOARD;
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class PLAYER {
|
||||
public:
|
||||
PLAYER(char who);
|
||||
virtual void play(const BOARD& b, size_t& y, size_t& x, int& dir) = 0;
|
||||
|
||||
// Helper functions
|
||||
void init(void);
|
||||
int domove(BOARD& b);
|
||||
|
||||
// Member access
|
||||
char getWho(void) const { return _who; }
|
||||
|
||||
// Display
|
||||
size_t getScore(void) const { return _score; }
|
||||
size_t getTotal(void) const { return _total; }
|
||||
size_t getGames(void) const { return _games; }
|
||||
size_t getTies(void) const { return _ties; }
|
||||
void wl(size_t sc);
|
||||
|
||||
private:
|
||||
char _who;
|
||||
size_t _score;
|
||||
size_t _total;
|
||||
size_t _games;
|
||||
size_t _ties;
|
||||
};
|
||||
|
||||
#endif
|
||||
86
dab/random.cc
Normal file
86
dab/random.cc
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $NetBSD: random.cc,v 1.2 2003/12/28 17:49:10 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* random.C: Randomizer for the dots program
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: random.cc,v 1.2 2003/12/28 17:49:10 thorpej Exp $")
|
||||
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include "random.h"
|
||||
|
||||
RANDOM::RANDOM(size_t ns) :
|
||||
_bs(ns)
|
||||
{
|
||||
_bm = new char[(_bs >> 3) + 1];
|
||||
clear();
|
||||
}
|
||||
|
||||
RANDOM::~RANDOM()
|
||||
{
|
||||
delete[] _bm;
|
||||
}
|
||||
|
||||
// Reinitialize
|
||||
void RANDOM::clear(void)
|
||||
{
|
||||
_nv = 0;
|
||||
::srand48(::time(NULL));
|
||||
(void) ::memset(_bm, 0, (_bs >> 3) + 1);
|
||||
}
|
||||
|
||||
// Return the next random value
|
||||
size_t RANDOM::operator() (void)
|
||||
{
|
||||
// No more values
|
||||
if (_nv == _bs)
|
||||
return _bs;
|
||||
|
||||
for (;;) {
|
||||
size_t r = ::lrand48();
|
||||
size_t z = r % _bs;
|
||||
if (!isset(z)) {
|
||||
set(z);
|
||||
_nv++;
|
||||
return z;
|
||||
}
|
||||
}
|
||||
}
|
||||
73
dab/random.h
Normal file
73
dab/random.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $NetBSD: random.h,v 1.2 2003/12/28 17:49:10 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* random.h: Randomizer; returns a random sequence of values from [0..fx)
|
||||
* returning each value exactly once. After fx calls it returns fx.
|
||||
*/
|
||||
|
||||
#ifndef _H_RANDOM
|
||||
#define _H_RANDOM
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class RANDOM {
|
||||
public:
|
||||
// Constructor and destructor
|
||||
RANDOM(size_t fx);
|
||||
~RANDOM();
|
||||
|
||||
size_t operator () (void); // Next random
|
||||
void clear(void); // Reset
|
||||
|
||||
private:
|
||||
|
||||
int isset(size_t z) {
|
||||
return (_bm[z >> 3] & (1 << (z & 7))) != 0;
|
||||
}
|
||||
|
||||
void set(size_t z) {
|
||||
_bm[z >> 3] |= (1 << (z & 7));
|
||||
}
|
||||
|
||||
char* _bm; // Bitmap indicating the numbers used
|
||||
size_t _nv; // Number of values returned so far
|
||||
size_t _bs; // Maximum value
|
||||
};
|
||||
|
||||
#endif
|
||||
57
dab/test.cc
Normal file
57
dab/test.cc
Normal file
@@ -0,0 +1,57 @@
|
||||
/* $NetBSD: test.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* test.C: Test program for randomizer
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: test.cc,v 1.1 2003/12/27 01:16:55 christos Exp $")
|
||||
|
||||
#include <iostream>
|
||||
#include "random.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
RANDOM rd(10);
|
||||
|
||||
for (size_t x = rd(); x < 10; x = rd())
|
||||
std::cout << "x=" << x << std::endl;
|
||||
return 0;
|
||||
}
|
||||
235
dab/ttyscrn.cc
Normal file
235
dab/ttyscrn.cc
Normal file
@@ -0,0 +1,235 @@
|
||||
/* $NetBSD: ttyscrn.cc,v 1.2 2003/12/27 18:24:51 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ttyscrn.C: Curses screen implementation for dots
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
RCSID("$NetBSD: ttyscrn.cc,v 1.2 2003/12/27 18:24:51 martin Exp $")
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curses.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "player.h"
|
||||
#include "ttyscrn.h"
|
||||
|
||||
void TTYSCRN::clean(void)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void TTYSCRN::moveto(size_t y, size_t x)
|
||||
{
|
||||
move(y + TTYSCRN::offsy, x + TTYSCRN::offsx);
|
||||
}
|
||||
|
||||
void TTYSCRN::addsym(const int sym)
|
||||
{
|
||||
addch(sym);
|
||||
}
|
||||
|
||||
void TTYSCRN::addedge(const int sym)
|
||||
{
|
||||
int nsym;
|
||||
#ifdef A_ALTCHARSET
|
||||
if (_acs) {
|
||||
switch (sym) {
|
||||
case GS_HLINE:
|
||||
nsym = ACS_HLINE;
|
||||
break;
|
||||
case GS_VLINE:
|
||||
nsym = ACS_VLINE;
|
||||
break;
|
||||
case GS_ULCORNER:
|
||||
nsym = ACS_ULCORNER;
|
||||
break;
|
||||
case GS_URCORNER:
|
||||
nsym = ACS_URCORNER;
|
||||
break;
|
||||
case GS_LLCORNER:
|
||||
nsym = ACS_LLCORNER;
|
||||
break;
|
||||
case GS_LRCORNER:
|
||||
nsym = ACS_LRCORNER;
|
||||
break;
|
||||
case GS_LTEE:
|
||||
nsym = ACS_LTEE;
|
||||
break;
|
||||
case GS_RTEE:
|
||||
nsym = ACS_RTEE;
|
||||
break;
|
||||
case GS_TTEE:
|
||||
nsym = ACS_TTEE;
|
||||
break;
|
||||
case GS_BTEE:
|
||||
nsym = ACS_BTEE;
|
||||
break;
|
||||
case GS_PLUS:
|
||||
nsym = ACS_PLUS;
|
||||
break;
|
||||
case ' ':
|
||||
addsym(' ');
|
||||
return;
|
||||
default:
|
||||
::abort();
|
||||
}
|
||||
attron(A_ALTCHARSET);
|
||||
addch(nsym);
|
||||
attroff(A_ALTCHARSET);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
switch (sym) {
|
||||
case GS_HLINE:
|
||||
nsym = '-';
|
||||
break;
|
||||
case GS_VLINE:
|
||||
nsym = '|';
|
||||
break;
|
||||
case GS_ULCORNER:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_URCORNER:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_LLCORNER:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_LRCORNER:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_LTEE:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_RTEE:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_TTEE:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_BTEE:
|
||||
nsym = '.';
|
||||
break;
|
||||
case GS_PLUS:
|
||||
nsym = '+';
|
||||
break;
|
||||
case ' ':
|
||||
addsym(' ');
|
||||
return;
|
||||
default:
|
||||
::abort();
|
||||
}
|
||||
addsym(nsym);
|
||||
}
|
||||
|
||||
void TTYSCRN::redraw(void)
|
||||
{
|
||||
refresh();
|
||||
doupdate();
|
||||
}
|
||||
|
||||
void TTYSCRN::bell(void)
|
||||
{
|
||||
putc('\007', stdout);
|
||||
}
|
||||
|
||||
int TTYSCRN::getinput(void)
|
||||
{
|
||||
return getch();
|
||||
}
|
||||
|
||||
void TTYSCRN::score(size_t s, const PLAYER& p)
|
||||
{
|
||||
mvwprintw(stdscr, _sy + s + TTYSCRN::offsscore, _sx, "S %c:%5zd", p.getWho(),
|
||||
p.getScore());
|
||||
}
|
||||
|
||||
void TTYSCRN::total(size_t s, const PLAYER& p)
|
||||
{
|
||||
mvwprintw(stdscr, _sy + s + TTYSCRN::offstotal, _sx, "T %c:%5zd", p.getWho(),
|
||||
p.getTotal());
|
||||
}
|
||||
|
||||
void TTYSCRN::games(size_t s, const PLAYER& p)
|
||||
{
|
||||
mvwprintw(stdscr, _sy + s + TTYSCRN::offsgames, _sx, "G %c:%5zd", p.getWho(),
|
||||
p.getGames());
|
||||
}
|
||||
|
||||
void TTYSCRN::ties(const PLAYER& p)
|
||||
{
|
||||
mvwprintw(stdscr, _sy + TTYSCRN::offsties, _sx, "G =:%5zd", p.getTies());
|
||||
}
|
||||
|
||||
TTYSCRN* TTYSCRN::create(int acs, size_t y, size_t x)
|
||||
{
|
||||
int tx, ty;
|
||||
|
||||
initscr();
|
||||
|
||||
tx = getmaxx(stdscr);
|
||||
ty = getmaxy(stdscr);
|
||||
|
||||
if (tx == ERR || ty == ERR || (size_t)tx < x * 2 + TTYSCRN::offsx + 12
|
||||
|| (size_t)ty < y * 2 + TTYSCRN::offsy) {
|
||||
endwin();
|
||||
return NULL;
|
||||
}
|
||||
cbreak();
|
||||
noecho();
|
||||
|
||||
|
||||
TTYSCRN* that = new TTYSCRN;
|
||||
|
||||
that->_tx = tx;
|
||||
that->_ty = ty;
|
||||
that->_sx = tx - 12;
|
||||
that->_sy = TTYSCRN::offsy;
|
||||
that->_acs = acs;
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
TTYSCRN::~TTYSCRN(void)
|
||||
{
|
||||
nocbreak();
|
||||
echo();
|
||||
endwin();
|
||||
}
|
||||
81
dab/ttyscrn.h
Normal file
81
dab/ttyscrn.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* $NetBSD: ttyscrn.h,v 1.2 2003/12/28 17:49:10 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ttyscrn.h: Curses based screen for dots
|
||||
*/
|
||||
|
||||
#ifndef _H_TTYSCRN
|
||||
#define _H_TTYSCRN
|
||||
|
||||
#include "gamescreen.h"
|
||||
|
||||
class TTYSCRN : public GAMESCREEN {
|
||||
public:
|
||||
// Constructor that can fail
|
||||
static TTYSCRN* create(int acs, size_t y, size_t x);
|
||||
~TTYSCRN();
|
||||
|
||||
// Screen virtuals
|
||||
void clean(void);
|
||||
void moveto(size_t y, size_t x);
|
||||
void addsym(const int sym);
|
||||
void addedge(const int sym);
|
||||
void redraw(void);
|
||||
void bell(void);
|
||||
int getinput(void);
|
||||
void score(size_t s, const PLAYER& p);
|
||||
void games(size_t s, const PLAYER& p);
|
||||
void total(size_t s, const PLAYER& p);
|
||||
void ties(const PLAYER& p);
|
||||
|
||||
private:
|
||||
enum {
|
||||
offsx = 2, // board x offset from top left corner
|
||||
offsy = 2, // board y offset from top left corner
|
||||
offsscore = 0, // score y offset from top of the board
|
||||
offstotal = 3, // total y offset from top of the board
|
||||
offsgames = 6, // games y offset from top of the board
|
||||
offsties = 8 // ties y offset from top of the board
|
||||
};
|
||||
size_t _sx, _sy; // board size
|
||||
size_t _tx, _ty; // tty size
|
||||
int _acs; // do we want acs?
|
||||
};
|
||||
|
||||
#endif
|
||||
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,3 +1,9 @@
|
||||
bsdgames (2.16-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Sat, 14 Feb 2004 16:34:08 -0500
|
||||
|
||||
bsdgames (2.15-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
2
debian/control
vendored
2
debian/control
vendored
@@ -15,7 +15,7 @@ Description: a collection of classic textual unix games
|
||||
been enjoyed for decades on unix systems.
|
||||
.
|
||||
Includes these programs: adventure, arithmetic, atc, backgammon, battlestar,
|
||||
bcd, boggle, caesar, canfield, countmail, cribbage, fish, gomoku, hack,
|
||||
bcd, boggle, caesar, canfield, countmail, cribbage, dab, fish, gomoku, hack,
|
||||
hangman, hunt, mille, monop, morse, number, pig, phantasia, pom, ppt, primes,
|
||||
quiz, random, rain, robots, sail, snake, tetris, trek, wargames, worm, worms,
|
||||
wump, wtf
|
||||
|
||||
2
debian/rules
vendored
2
debian/rules
vendored
@@ -33,10 +33,8 @@ binary-arch: build
|
||||
$(MAKE) install
|
||||
cp atc/BUGS debian/bsdgames/usr/share/doc/bsdgames/BUGS.atc
|
||||
cp hunt/README debian/bsdgames/usr/share/doc/bsdgames/README.hunt
|
||||
cp hunt/README.linux debian/bsdgames/usr/share/doc/bsdgames/README.linux.hunt
|
||||
cp phantasia/README debian/bsdgames/usr/share/doc/bsdgames/README.phantasia
|
||||
cp boggle/README debian/bsdgames/usr/share/doc/bsdgames/README.boggle
|
||||
cp boggle/README.linux debian/bsdgames/usr/share/doc/bsdgames/README.linux.boggle
|
||||
cp hack/Original_READ_ME debian/bsdgames/usr/share/doc/bsdgames/Original_READ_ME.hack
|
||||
cp hack/READ_ME debian/bsdgames/usr/share/doc/bsdgames/READ_ME.hack
|
||||
# Since factor is not installed, and primes.6 is a symlink to
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefrag - makefile fragment for dm
|
||||
#
|
||||
# Copyright (c) 1997, 1998, 1999 Joseph Samuel Myers.
|
||||
# Copyright (c) 1997, 1998, 1999, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,7 +27,7 @@
|
||||
# SUCH DAMAGE.
|
||||
|
||||
# Add -DLOG if you want logging
|
||||
dm_DEFS := $(GETLOADAVG_DEFS) # -DLOG
|
||||
dm_DEFS := $(GETLOADAVG_DEFS) -D_GNU_SOURCE -DSUPPORT_UTMPX -DSUPPORT_UTMP # -DLOG
|
||||
dm_DIRS := $(GAMESDIR) $(MAN8DIR) $(MAN5DIR)
|
||||
|
||||
dm_all: dm/dm dm/dm.8 dm/dm.conf.5
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
1997-08-07
|
||||
|
||||
Dm is the `dungeon master', a program that allows you to control when
|
||||
users can play games. (Note that this does not control any private
|
||||
copies of games they may have). I do not claim that this program is
|
||||
actually useful, but it is included in bsd-games since it is in
|
||||
NetBSD.
|
||||
|
||||
Add -DLOG to the DEFS in the Makefile if you want logging of games
|
||||
playing.
|
||||
|
||||
Joseph S. Myers
|
||||
jsm@polyomino.org.uk
|
||||
45
dm/dm.c
45
dm/dm.c
@@ -1,5 +1,4 @@
|
||||
/* $NetBSD: dm.c,v 1.18 2003/08/07 09:37:11 agc Exp $ */
|
||||
/* For Linux: still using old utmp interface from version 1.16. */
|
||||
/* $NetBSD: dm.c,v 1.20 2004/02/08 22:23:50 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
@@ -40,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dm.c,v 1.18 2003/08/07 09:37:11 agc Exp $");
|
||||
__RCSID("$NetBSD: dm.c,v 1.20 2004/02/08 22:23:50 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -58,8 +57,8 @@ __RCSID("$NetBSD: dm.c,v 1.18 2003/08/07 09:37:11 agc Exp $");
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <utmp.h>
|
||||
|
||||
#include "utmpentry.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
static time_t now; /* current time value */
|
||||
@@ -67,16 +66,16 @@ static int priority = 0; /* priority game runs at */
|
||||
static char *game, /* requested game */
|
||||
*gametty; /* from tty? */
|
||||
|
||||
void c_day __P((const char *, const char *, const char *));
|
||||
void c_game __P((const char *, const char *, const char *, const char *));
|
||||
void c_tty __P((const char *));
|
||||
const char *hour __P((int));
|
||||
double load __P((void));
|
||||
int main __P((int, char *[]));
|
||||
void nogamefile __P((void));
|
||||
void play __P((char **)) __attribute__((__noreturn__));
|
||||
void read_config __P((void));
|
||||
int users __P((void));
|
||||
void c_day(const char *, const char *, const char *);
|
||||
void c_game(const char *, const char *, const char *, const char *);
|
||||
void c_tty(const char *);
|
||||
const char *hour(int);
|
||||
double load(void);
|
||||
int main(int, char *[]);
|
||||
void nogamefile(void);
|
||||
void play(char **) __attribute__((__noreturn__));
|
||||
void read_config(void);
|
||||
int users(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
@@ -253,16 +252,16 @@ load()
|
||||
int
|
||||
users()
|
||||
{
|
||||
static struct utmpentry *ohead = NULL;
|
||||
struct utmpentry *ep;
|
||||
int nusers;
|
||||
|
||||
int nusers, utmp;
|
||||
struct utmp buf;
|
||||
|
||||
if ((utmp = open(_PATH_UTMP, O_RDONLY, 0)) < 0)
|
||||
err(1, "%s", _PATH_UTMP);
|
||||
for (nusers = 0; read(utmp, (char *)&buf, sizeof(struct utmp)) > 0;)
|
||||
if (buf.ut_name[0] != '\0')
|
||||
++nusers;
|
||||
return (nusers);
|
||||
nusers = getutentries(NULL, &ep);
|
||||
if (ep != ohead) {
|
||||
freeutentries(ep);
|
||||
ohead = ep;
|
||||
}
|
||||
return nusers;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
278
dm/utmpentry.c
Normal file
278
dm/utmpentry.c
Normal file
@@ -0,0 +1,278 @@
|
||||
/* $NetBSD: utmpentry.c,v 1.4 2003/02/12 17:39:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: utmpentry.c,v 1.4 2003/02/12 17:39:36 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef SUPPORT_UTMP
|
||||
#include <utmp.h>
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMPX
|
||||
#include <utmpx.h>
|
||||
#endif
|
||||
|
||||
#include "utmpentry.h"
|
||||
|
||||
|
||||
#ifdef SUPPORT_UTMP
|
||||
static void getentry(struct utmpentry *, struct utmp *);
|
||||
static time_t utmptime = 0;
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMPX
|
||||
static void getentryx(struct utmpentry *, struct utmpx *);
|
||||
static time_t utmpxtime = 0;
|
||||
#endif
|
||||
#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
|
||||
static int setup(const char *);
|
||||
static void adjust_size(struct utmpentry *e);
|
||||
#endif
|
||||
|
||||
int maxname = 8, maxline = 8, maxhost = 16;
|
||||
static int numutmp = 0;
|
||||
static struct utmpentry *ehead;
|
||||
|
||||
#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
|
||||
static void
|
||||
adjust_size(struct utmpentry *e)
|
||||
{
|
||||
int max;
|
||||
|
||||
if ((max = strlen(e->name)) > maxname)
|
||||
maxname = max;
|
||||
if ((max = strlen(e->line)) > maxline)
|
||||
maxline = max;
|
||||
if ((max = strlen(e->host)) > maxhost)
|
||||
maxhost = max;
|
||||
}
|
||||
|
||||
static int
|
||||
setup(const char *fname)
|
||||
{
|
||||
int what = 3;
|
||||
struct stat st;
|
||||
|
||||
if (fname == NULL) {
|
||||
#ifdef SUPPORT_UTMPX
|
||||
setutxent();
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMP
|
||||
setutent();
|
||||
#endif
|
||||
} else {
|
||||
size_t len = strlen(fname);
|
||||
if (len == 0)
|
||||
errx(1, "Filename cannot be 0 length.");
|
||||
what = fname[len - 1] == 'x' ? 1 : 2;
|
||||
if (what == 1) {
|
||||
#ifdef SUPPORT_UTMPX
|
||||
if (utmpxname(fname) == 0)
|
||||
err(1, "Cannot open `%s'", fname);
|
||||
#else
|
||||
errx(1, "utmpx support not compiled in");
|
||||
#endif
|
||||
} else {
|
||||
#ifdef SUPPORT_UTMP
|
||||
if (utmpname(fname) == 0)
|
||||
err(1, "Cannot open `%s'", fname);
|
||||
#else
|
||||
errx(1, "utmp support not compiled in");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef SUPPORT_UTMPX
|
||||
if (what & 1) {
|
||||
(void)stat(fname ? fname : _PATH_UTMPX, &st);
|
||||
if (st.st_mtime > utmpxtime)
|
||||
utmpxtime = st.st_mtime;
|
||||
else
|
||||
what &= ~1;
|
||||
}
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMP
|
||||
if (what & 2) {
|
||||
(void)stat(fname ? fname : _PATH_UTMP, &st);
|
||||
if (st.st_mtime > utmptime)
|
||||
utmptime = st.st_mtime;
|
||||
else
|
||||
what &= ~2;
|
||||
}
|
||||
#endif
|
||||
|
||||
return what;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
freeutentries(struct utmpentry *ep)
|
||||
{
|
||||
#ifdef SUPPORT_UTMP
|
||||
utmptime = 0;
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMPX
|
||||
utmpxtime = 0;
|
||||
#endif
|
||||
if (ep == ehead) {
|
||||
ehead = NULL;
|
||||
numutmp = 0;
|
||||
}
|
||||
while (ep) {
|
||||
struct utmpentry *sep = ep;
|
||||
ep = ep->next;
|
||||
free(sep);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
getutentries(const char *fname, struct utmpentry **epp)
|
||||
{
|
||||
#ifdef SUPPORT_UTMPX
|
||||
struct utmpx *utx;
|
||||
#endif
|
||||
#ifdef SUPPORT_UTMP
|
||||
struct utmp *ut;
|
||||
#endif
|
||||
#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
|
||||
struct utmpentry *ep;
|
||||
int what = setup(fname);
|
||||
struct utmpentry **nextp = &ehead;
|
||||
if (what == 0) {
|
||||
*epp = ehead;
|
||||
return numutmp;
|
||||
} else {
|
||||
ehead = NULL;
|
||||
numutmp = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_UTMPX
|
||||
while ((what & 1) && (utx = getutxent()) != NULL) {
|
||||
if (fname == NULL && utx->ut_type != USER_PROCESS)
|
||||
continue;
|
||||
if ((ep = calloc(1, sizeof(struct utmpentry))) == NULL)
|
||||
err(1, NULL);
|
||||
getentryx(ep, utx);
|
||||
*nextp = ep;
|
||||
nextp = &(ep->next);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_UTMP
|
||||
while ((what & 2) && (ut = getutent()) != NULL) {
|
||||
if (fname == NULL && (*ut->ut_name == '\0' ||
|
||||
*ut->ut_line == '\0'))
|
||||
continue;
|
||||
/* Don't process entries that we have utmpx for */
|
||||
for (ep = ehead; ep != NULL; ep = ep->next) {
|
||||
if (strncmp(ep->line, ut->ut_line,
|
||||
sizeof(ut->ut_line)) == 0)
|
||||
break;
|
||||
}
|
||||
if (ep != NULL)
|
||||
continue;
|
||||
if ((ep = calloc(1, sizeof(struct utmpentry))) == NULL)
|
||||
err(1, NULL);
|
||||
getentry(ep, ut);
|
||||
*nextp = ep;
|
||||
nextp = &(ep->next);
|
||||
}
|
||||
#endif
|
||||
numutmp = 0;
|
||||
#if defined(SUPPORT_UTMP) && defined(SUPPORT_UTMPX)
|
||||
if (ehead != NULL) {
|
||||
struct utmpentry *from = ehead, *save;
|
||||
|
||||
ehead = NULL;
|
||||
while (from != NULL) {
|
||||
for (nextp = &ehead;
|
||||
(*nextp) && strcmp(from->line, (*nextp)->line) > 0;
|
||||
nextp = &(*nextp)->next)
|
||||
continue;
|
||||
save = from;
|
||||
from = from->next;
|
||||
save->next = *nextp;
|
||||
*nextp = save;
|
||||
numutmp++;
|
||||
}
|
||||
}
|
||||
*epp = ehead;
|
||||
return numutmp;
|
||||
#else
|
||||
*epp = NULL;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_UTMP
|
||||
static void
|
||||
getentry(struct utmpentry *e, struct utmp *up)
|
||||
{
|
||||
(void)strncpy(e->name, up->ut_name, sizeof(up->ut_name));
|
||||
e->name[sizeof(e->name) - 1] = '\0';
|
||||
(void)strncpy(e->line, up->ut_line, sizeof(up->ut_line));
|
||||
e->line[sizeof(e->line) - 1] = '\0';
|
||||
(void)strncpy(e->host, up->ut_host, sizeof(up->ut_host));
|
||||
e->name[sizeof(e->host) - 1] = '\0';
|
||||
e->tv.tv_sec = up->ut_time;
|
||||
e->tv.tv_usec = 0;
|
||||
adjust_size(e);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_UTMPX
|
||||
static void
|
||||
getentryx(struct utmpentry *e, struct utmpx *up)
|
||||
{
|
||||
(void)strncpy(e->name, up->ut_name, sizeof(up->ut_name));
|
||||
e->name[sizeof(e->name) - 1] = '\0';
|
||||
(void)strncpy(e->line, up->ut_line, sizeof(up->ut_line));
|
||||
e->line[sizeof(e->line) - 1] = '\0';
|
||||
(void)strncpy(e->host, up->ut_host, sizeof(up->ut_host));
|
||||
e->name[sizeof(e->host) - 1] = '\0';
|
||||
e->tv = up->ut_tv;
|
||||
adjust_size(e);
|
||||
}
|
||||
#endif
|
||||
50
dm/utmpentry.h
Normal file
50
dm/utmpentry.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* $NetBSD: utmpentry.h,v 1.2 2003/11/28 23:52:34 wiz Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
struct utmpentry {
|
||||
char name[65];
|
||||
char line[65];
|
||||
char host[257];
|
||||
struct timeval tv;
|
||||
struct utmpentry *next;
|
||||
};
|
||||
|
||||
extern int maxname, maxline, maxhost;
|
||||
|
||||
int getutentries(const char *, struct utmpentry **);
|
||||
void freeutentries(struct utmpentry *);
|
||||
@@ -1,7 +1,7 @@
|
||||
# exec.libs - details of libraries needed to link bsd-games programs.
|
||||
# This file is used for automatic makefile generation.
|
||||
#
|
||||
# Copyright (c) 1998, 1999, 2000, 2003 Joseph Samuel Myers.
|
||||
# Copyright (c) 1998, 1999, 2000, 2003, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,6 +35,7 @@ boggle/boggle/boggle $(NCURSES_LIB)
|
||||
caesar -lm
|
||||
canfield/canfield/canfield $(NCURSES_LIB)
|
||||
cribbage $(NCURSES_LIB)
|
||||
dab $(NCURSES_LIB)
|
||||
factor $(OPENSSL_LIB)
|
||||
gomoku $(NCURSES_LIB)
|
||||
hack $(NCURSES_LIB)
|
||||
|
||||
10
exec.objs
10
exec.objs
@@ -1,7 +1,7 @@
|
||||
# exec.objs - details of objects that go into bsd-games programs.
|
||||
# This file is used for automatic makefile generation.
|
||||
#
|
||||
# Copyright (c) 1998, 1999, 2000, 2001, 2003 Joseph Samuel Myers.
|
||||
# Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,7 +30,7 @@
|
||||
adventure crc.o data.o done.o init.o io.o main.o save.o subr.o \
|
||||
vocab.o wizard.o
|
||||
adventure/setup setup.o
|
||||
arithmetic arithmetic.o
|
||||
arithmetic arithmetic.o lib/getprogname.o
|
||||
atc extern.o grammar.o graphics.o input.o lex.o list.o \
|
||||
log.o main.o tunable.o update.o
|
||||
backgammon/backgammon/backgammon extra.o main.o move.o text.o \
|
||||
@@ -59,10 +59,12 @@ caesar caesar.o
|
||||
canfield/canfield/canfield canfield.o
|
||||
canfield/cfscores/cfscores cfscores.o
|
||||
cribbage cards.o crib.o extern.o instr.o io.o score.o support.o
|
||||
dm dm.o lib/getloadavg.o
|
||||
dab algor.o board.o box.o gamescreen.o human.o main.o \
|
||||
player.o random.o ttyscrn.o
|
||||
dm dm.o utmpentry.o lib/getloadavg.o
|
||||
factor factor.o primes/pr_tbl.o
|
||||
fish fish.o
|
||||
fortune/fortune/fortune fortune.o
|
||||
fortune/fortune/fortune fortune.o lib/getprogname.o
|
||||
fortune/strfile/strfile strfile.o
|
||||
fortune/unstr/unstr unstr.o
|
||||
gomoku bdinit.o bdisp.o main.o makemove.o pickmove.o stoc.o
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.10 2002/09/19 03:15:39 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.11 2004/02/08 13:16:25 jsm Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
# For MKCRYPTO
|
||||
@@ -17,7 +17,6 @@ DPADD+= ${LIBCRYPTO}
|
||||
.endif
|
||||
|
||||
MAN= factor.6
|
||||
MLINKS+=factor.6 primes.6
|
||||
.PATH: ${PRIMES}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: factor.6,v 1.8 2003/08/07 09:37:12 agc Exp $
|
||||
.\" $NetBSD: factor.6,v 1.9 2004/02/08 13:16:25 jsm Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -37,54 +37,45 @@
|
||||
.\"
|
||||
.\" chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dt PRIMES 6
|
||||
.Dd February 8, 2004
|
||||
.Dt FACTOR 6
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm primes
|
||||
.Nd generate primes
|
||||
.Nm factor
|
||||
.Nd factor a number
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Ar number ...
|
||||
.br
|
||||
.Nm primes
|
||||
.Op Ar start Op Ar stop
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm primes
|
||||
utility prints primes in ascending order, one per line, starting at or above
|
||||
.Ar start
|
||||
and continuing until, but not including
|
||||
.Ar stop .
|
||||
The
|
||||
.Ar start
|
||||
value must be at least 0 and not greater than
|
||||
.Ar stop .
|
||||
The
|
||||
.Ar stop
|
||||
value must not be greater than 4294967295.
|
||||
The default value of
|
||||
.Ar stop
|
||||
is 4294967295.
|
||||
.Nm
|
||||
utility will factor integers between \-2147483648 and 2147483647 inclusive.
|
||||
When a number is factored, it is printed, followed by a
|
||||
.Dq \&: ,
|
||||
and the list of factors on a single line.
|
||||
Factors are listed in ascending order, and are preceded by a space.
|
||||
If a factor divides a value more than once, it will be printed more than once.
|
||||
.Pp
|
||||
When the
|
||||
.Nm primes
|
||||
utility is invoked with no arguments,
|
||||
.Ar start
|
||||
is read from standard input.
|
||||
.Ar stop
|
||||
is taken to be 4294967295.
|
||||
The
|
||||
.Ar start
|
||||
value may be preceded by a single +.
|
||||
The
|
||||
.Ar start
|
||||
value is terminated by a non-digit character (such as a newline).
|
||||
The input line must not be longer than 255 characters.
|
||||
When
|
||||
.Nm
|
||||
is invoked with one or more arguments, each argument will be factored.
|
||||
.Pp
|
||||
When
|
||||
.Nm
|
||||
is invoked with no arguments,
|
||||
.Nm
|
||||
reads numbers, one per line, from standard input, until end of file or error.
|
||||
Leading white-space and empty lines are ignored.
|
||||
Numbers may be preceded by a single - or +.
|
||||
Numbers are terminated by a non-digit character (such as a newline).
|
||||
After a number is read, it is factored.
|
||||
Input lines must not be longer than 255 characters.
|
||||
.Sh DIAGNOSTICS
|
||||
Out of range or invalid input results in
|
||||
.Sq ouch
|
||||
an appropriate error message
|
||||
being written to standard error.
|
||||
.Sh BUGS
|
||||
.Nm primes
|
||||
won't get you a world record.
|
||||
.Nm
|
||||
cannot handle the
|
||||
.Dq 10 most wanted
|
||||
factor list.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: factor.c,v 1.14 2003/08/07 09:37:12 agc Exp $ */
|
||||
/* $NetBSD: factor.c,v 1.15 2004/02/08 11:47:36 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: factor.c,v 1.14 2003/08/07 09:37:12 agc Exp $");
|
||||
__RCSID("$NetBSD: factor.c,v 1.15 2004/02/08 11:47:36 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -231,7 +231,9 @@ pr_fact(BIGNUM *val)
|
||||
bnfact = BN_new();
|
||||
BN_set_word(bnfact, *(fact - 1));
|
||||
BN_sqr(bnfact, bnfact, ctx);
|
||||
if (BN_cmp(bnfact, val) > 0) {
|
||||
if (BN_cmp(bnfact, val) > 0
|
||||
|| BN_is_prime(val, PRIME_CHECKS, NULL, NULL,
|
||||
NULL) == 1) {
|
||||
putchar(' ');
|
||||
BN_print_dec_fp(stdout, val);
|
||||
} else
|
||||
@@ -280,23 +282,29 @@ usage(void)
|
||||
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
/* pollard rho, algorithm from Jim Gillogly, May 2000 */
|
||||
/* pollard p-1, algorithm from Jim Gillogly, May 2000 */
|
||||
|
||||
void
|
||||
pollard_pminus1(BIGNUM *val)
|
||||
{
|
||||
BIGNUM *base, *num, *i, *x;
|
||||
BIGNUM *base, *rbase, *num, *i, *x;
|
||||
|
||||
base = BN_new();
|
||||
rbase = BN_new();
|
||||
num = BN_new();
|
||||
i = BN_new();
|
||||
x = BN_new();
|
||||
|
||||
BN_set_word(rbase, 1);
|
||||
newbase:
|
||||
BN_add_word(rbase, 1);
|
||||
BN_set_word(i, 2);
|
||||
BN_set_word(base, 2);
|
||||
BN_copy(base, rbase);
|
||||
|
||||
for (;;) {
|
||||
BN_mod_exp(base, base, i, val, ctx);
|
||||
if (BN_is_one(base))
|
||||
goto newbase;
|
||||
|
||||
BN_copy(x, base);
|
||||
BN_sub_word(x, 1);
|
||||
|
||||
36
fish/fish.c
36
fish/fish.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fish.c,v 1.14 2003/08/07 09:37:13 agc Exp $ */
|
||||
/* $NetBSD: fish.c,v 1.15 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fish.c,v 1.14 2003/08/07 09:37:13 agc Exp $");
|
||||
__RCSID("$NetBSD: fish.c,v 1.15 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -78,22 +78,22 @@ int asked[RANKS], comphand[RANKS], deck[TOTCARDS];
|
||||
int userasked[RANKS], userhand[RANKS];
|
||||
int curcard = TOTCARDS;
|
||||
|
||||
void chkwinner __P((int, const int *));
|
||||
int compmove __P((void));
|
||||
int countbooks __P((const int *));
|
||||
int countcards __P((const int *));
|
||||
int drawcard __P((int, int *));
|
||||
int gofish __P((int, int, int *));
|
||||
void goodmove __P((int, int, int *, int *));
|
||||
void init __P((void));
|
||||
void instructions __P((void));
|
||||
int main __P((int, char *[]));
|
||||
int nrandom __P((int));
|
||||
void printhand __P((const int *));
|
||||
void printplayer __P((int));
|
||||
int promove __P((void));
|
||||
void usage __P((void)) __attribute__((__noreturn__));
|
||||
int usermove __P((void));
|
||||
void chkwinner(int, const int *);
|
||||
int compmove(void);
|
||||
int countbooks(const int *);
|
||||
int countcards(const int *);
|
||||
int drawcard(int, int *);
|
||||
int gofish(int, int, int *);
|
||||
void goodmove(int, int, int *, int *);
|
||||
void init(void);
|
||||
void instructions(void);
|
||||
int main(int, char *[]);
|
||||
int nrandom(int);
|
||||
void printhand(const int *);
|
||||
void printplayer(int);
|
||||
int promove(void);
|
||||
void usage(void) __attribute__((__noreturn__));
|
||||
int usermove(void);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
README.linux for fortune
|
||||
========================
|
||||
|
||||
Here is one port of fortune for Linux. Alternatively, you may wish to
|
||||
use the enhanced version available from
|
||||
<ftp://sunsite.unc.edu/pub/Linux/games/amusements/fortune-mod.tar.gz>.
|
||||
|
||||
unstr is not installed by default. If you want to install it,
|
||||
uncomment the relevant lines (installation command and definition of
|
||||
fortune_unstr_DIRS) in unstr/Makefrag before doing the top level `make
|
||||
install'.
|
||||
|
||||
Offensive fortunes:
|
||||
|
||||
The "offensive" fortunes (not very offensive) are disabled by default.
|
||||
If you want the "offensive" fortunes, answer 'y' to the question when
|
||||
running configure.
|
||||
|
||||
Have fun!
|
||||
Andy
|
||||
|
||||
[ This README.linux subsequently extensively modified - JSM ]
|
||||
@@ -10919,7 +10919,7 @@ of chemical pollutant in their drinking water. That is why I pledge to
|
||||
do all that I can to protect the environment of this great nation of
|
||||
ours, and put prayer back in the schools, where it belongs. What we
|
||||
need is jobs, not empty promises. I realize I'm risking my political
|
||||
career be being so outspoken on a sensitive issue such as the MX, but
|
||||
career by being so outspoken on a sensitive issue such as the MX, but
|
||||
that's just the kind of straight-talking honest person I am, and I
|
||||
can't help it.
|
||||
-- Dave Barry, "On Presidential Politics"
|
||||
|
||||
@@ -674,7 +674,7 @@ days old. He heard that a foal and his mummy are soon parted.
|
||||
long-distance caw.
|
||||
A musical reviewer admitted he always praised the first show of a
|
||||
new theatrical season. "Who am I to stone the first cast?"
|
||||
A hard-luck actor who appeared in one coloossal disaster after another
|
||||
A hard-luck actor who appeared in one colossal disaster after another
|
||||
finally got a break, a broken leg to be exact. Someone pointed out that it's
|
||||
the first time the poor fellow's been in the same cast for more than a week.
|
||||
%
|
||||
@@ -1032,7 +1032,7 @@ with social conventions?"
|
||||
%
|
||||
A ranger was walking through the forest and encountered a hunter
|
||||
carrying a shotgun and a dead loon. "What in the world do you think you're
|
||||
doing? Don't you know that the loon is on the endagered species list?"
|
||||
doing? Don't you know that the loon is on the endangered species list?"
|
||||
Instead of answering, the hunter showed the ranger his game bag,
|
||||
which contained twelve more loons.
|
||||
"Why would you shoot loons?", the ranger asked.
|
||||
@@ -1110,7 +1110,7 @@ secrets... so naturally British electronics leak smoke.
|
||||
-- Jack Banton, PCC Automotive Electrical School
|
||||
%
|
||||
A shy teenage boy finally worked up the nerve to give a gift to
|
||||
Maddona, a young puppy. It hitched its waggin' to a star.
|
||||
Madonna, a young puppy. It hitched its waggin' to a star.
|
||||
A girl spent a couple hours on the phone talking to her two best
|
||||
friends, Maureen Jones, and Maureen Brown. When asked by her father why she
|
||||
had been on the phone so long, she responded "I heard a funny story today
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefrag - makefile fragment for fortune/fortune
|
||||
#
|
||||
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
|
||||
# Copyright (c) 1997, 1998, 2004 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -26,7 +26,7 @@
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
fortune_fortune_DEFS := -DHAVE_REGCOMP
|
||||
fortune_fortune_DEFS := $(GETPROGNAME_DEFS) -DHAVE_REGCOMP
|
||||
fortune_fortune_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
fortune_fortune_INCS := -Ifortune/strfile
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ fortune 50% funny 50% not
|
||||
.Ed
|
||||
.Sh FILES
|
||||
.Bl -tag -width Pa -compact
|
||||
.It Pa @sharedir@/fortunes
|
||||
.It Pa @fortune_dir@
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr regex 3
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fortune.c,v 1.39 2003/08/07 09:37:14 agc Exp $ */
|
||||
/* $NetBSD: fortune.c,v 1.43 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fortune.c,v 1.39 2003/08/07 09:37:14 agc Exp $");
|
||||
__RCSID("$NetBSD: fortune.c,v 1.43 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -126,46 +126,46 @@ FILEDESC *Fortfile; /* Fortune file to use */
|
||||
|
||||
STRFILE Noprob_tbl; /* sum of data for all no prob files */
|
||||
|
||||
int add_dir __P((FILEDESC *));
|
||||
int add_file __P((int,
|
||||
const char *, const char *, FILEDESC **, FILEDESC **, FILEDESC *));
|
||||
void all_forts __P((FILEDESC *, const char *));
|
||||
char *copy __P((const char *, u_int));
|
||||
void rot13 __P((char *line, int len));
|
||||
void display __P((FILEDESC *));
|
||||
void do_free __P((void *));
|
||||
void *do_malloc __P((u_int));
|
||||
int form_file_list __P((char **, int));
|
||||
int fortlen __P((void));
|
||||
void get_fort __P((void));
|
||||
void get_pos __P((FILEDESC *));
|
||||
void get_tbl __P((FILEDESC *));
|
||||
void getargs __P((int, char *[]));
|
||||
void init_prob __P((void));
|
||||
int is_dir __P((const char *));
|
||||
int is_fortfile __P((const char *, char **, char **, int));
|
||||
int is_off_name __P((const char *));
|
||||
int main __P((int, char *[]));
|
||||
int max __P((int, int));
|
||||
int add_dir(FILEDESC *);
|
||||
int add_file(int,
|
||||
const char *, const char *, FILEDESC **, FILEDESC **, FILEDESC *);
|
||||
void all_forts(FILEDESC *, const char *);
|
||||
char *copy(const char *, u_int);
|
||||
void rot13(char *line, int len);
|
||||
void display(FILEDESC *);
|
||||
void do_free(void *);
|
||||
void *do_malloc(u_int);
|
||||
int form_file_list(char **, int);
|
||||
int fortlen(void);
|
||||
void get_fort(void);
|
||||
void get_pos(FILEDESC *);
|
||||
void get_tbl(FILEDESC *);
|
||||
void getargs(int, char *[]);
|
||||
void init_prob(void);
|
||||
int is_dir(const char *);
|
||||
int is_fortfile(const char *, char **, char **, int);
|
||||
int is_off_name(const char *);
|
||||
int main(int, char *[]);
|
||||
int max(int, int);
|
||||
FILEDESC *
|
||||
new_fp __P((void));
|
||||
char *off_name __P((const char *));
|
||||
void open_dat __P((FILEDESC *));
|
||||
void open_fp __P((FILEDESC *));
|
||||
new_fp(void);
|
||||
char *off_name(const char *);
|
||||
void open_dat(FILEDESC *);
|
||||
void open_fp(FILEDESC *);
|
||||
FILEDESC *
|
||||
pick_child __P((FILEDESC *));
|
||||
void print_file_list __P((void));
|
||||
void print_list __P((FILEDESC *, int));
|
||||
void sum_noprobs __P((FILEDESC *));
|
||||
void sum_tbl __P((STRFILE *, STRFILE *));
|
||||
void usage __P((void)) __attribute__((__noreturn__));
|
||||
void zero_tbl __P((STRFILE *));
|
||||
pick_child(FILEDESC *);
|
||||
void print_file_list(void);
|
||||
void print_list(FILEDESC *, int);
|
||||
void sum_noprobs(FILEDESC *);
|
||||
void sum_tbl(STRFILE *, STRFILE *);
|
||||
void usage(void) __attribute__((__noreturn__));
|
||||
void zero_tbl(STRFILE *);
|
||||
|
||||
#ifndef NO_REGEX
|
||||
char *conv_pat __P((char *));
|
||||
int find_matches __P((void));
|
||||
void matches_in_list __P((FILEDESC *));
|
||||
int maxlen_in_list __P((FILEDESC *));
|
||||
char *conv_pat(char *);
|
||||
int find_matches(void);
|
||||
void matches_in_list(FILEDESC *);
|
||||
int maxlen_in_list(FILEDESC *);
|
||||
#endif
|
||||
|
||||
#ifndef NO_REGEX
|
||||
@@ -210,14 +210,12 @@ char Re_error[1024];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(__linux__) && !defined(__GLIBC__)) || (defined(__GLIBC__) && !defined(_DIRENT_HAVE_D_NAMLEN))
|
||||
#if (defined(__linux__) && !defined(__GLIBC__)) || (defined(__GLIBC__) && !defined(_DIRENT_HAVE_D_NAMLEN)) || defined(__CYGWIN__)
|
||||
#define NAMLEN(d) (strlen((d)->d_name))
|
||||
#else
|
||||
#define NAMLEN(d) ((d)->d_namlen)
|
||||
#endif
|
||||
|
||||
extern char *__progname;
|
||||
|
||||
int
|
||||
main(ac, av)
|
||||
int ac;
|
||||
@@ -1403,7 +1401,8 @@ matches_in_list(list)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void) fprintf(stderr, "Usage: %s [-ae", __progname);
|
||||
|
||||
(void) fprintf(stderr, "Usage: %s [-ae", getprogname());
|
||||
#ifdef DEBUG
|
||||
(void) fprintf(stderr, "D");
|
||||
#endif /* DEBUG */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: unstr.c,v 1.8 2003/08/07 09:37:15 agc Exp $ */
|
||||
/* $NetBSD: unstr.c,v 1.11 2004/02/08 22:23:50 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)unstr.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: unstr.c,v 1.8 2003/08/07 09:37:15 agc Exp $");
|
||||
__RCSID("$NetBSD: unstr.c,v 1.11 2004/02/08 22:23:50 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -79,9 +79,9 @@ char *Infile, /* name of input file */
|
||||
|
||||
FILE *Inf, *Dataf;
|
||||
|
||||
void getargs __P((char *[]));
|
||||
int main __P((int, char *[]));
|
||||
void order_unstr __P((STRFILE *));
|
||||
void getargs(char *[]);
|
||||
int main(int, char *[]);
|
||||
void order_unstr(STRFILE *);
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gomoku.h,v 1.8 2003/08/07 09:37:17 agc Exp $ */
|
||||
/* $NetBSD: gomoku.h,v 1.10 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
@@ -35,10 +35,8 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
#include <stdio.h>
|
||||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
/* board dimensions */
|
||||
#define BSZ 19
|
||||
@@ -263,42 +261,42 @@ extern int debug;
|
||||
|
||||
#define ASSERT(x)
|
||||
|
||||
void bdinit __P((struct spotstr *));
|
||||
void init_overlap __P((void));
|
||||
int getline __P((char *, int));
|
||||
void ask __P((const char *));
|
||||
void dislog __P((const char *));
|
||||
void bdump __P((FILE *));
|
||||
void bdisp __P((void));
|
||||
void bdisp_init __P((void));
|
||||
void cursfini __P((void));
|
||||
void cursinit __P((void));
|
||||
void bdwho __P((int));
|
||||
void panic __P((const char *)) __attribute__((__noreturn__));
|
||||
void glog __P((const char *));
|
||||
void dlog __P((const char *));
|
||||
void quit __P((void)) __attribute__((__noreturn__));
|
||||
void quitsig __P((int)) __attribute__((__noreturn__));
|
||||
void whatsup __P((int));
|
||||
int readinput __P((FILE *));
|
||||
const char *stoc __P((int));
|
||||
int lton __P((int));
|
||||
int ctos __P((const char *));
|
||||
void update_overlap __P((struct spotstr *));
|
||||
int makemove __P((int, int));
|
||||
int list_eq __P((struct combostr **, struct combostr **, int));
|
||||
void clearcombo __P((struct combostr *, int));
|
||||
void makeempty __P((struct combostr *));
|
||||
void appendcombo __P((struct combostr *, int));
|
||||
void updatecombo __P((struct combostr *, int));
|
||||
void markcombo __P((struct combostr *));
|
||||
void printcombo __P((struct combostr *, char *));
|
||||
void makecombo __P((struct combostr *, struct spotstr *, int, int));
|
||||
void makecombo2 __P((struct combostr *, struct spotstr *, int, int));
|
||||
int sortcombo __P((struct combostr **, struct combostr **, struct combostr *));
|
||||
int checkframes __P((struct combostr *, struct combostr *, struct spotstr *,
|
||||
int, struct ovlp_info *));
|
||||
void addframes __P((int));
|
||||
void scanframes __P((int));
|
||||
int better __P((const struct spotstr *, const struct spotstr *, int));
|
||||
int pickmove __P((int));
|
||||
void bdinit(struct spotstr *);
|
||||
void init_overlap(void);
|
||||
int getline(char *, int);
|
||||
void ask(const char *);
|
||||
void dislog(const char *);
|
||||
void bdump(FILE *);
|
||||
void bdisp(void);
|
||||
void bdisp_init(void);
|
||||
void cursfini(void);
|
||||
void cursinit(void);
|
||||
void bdwho(int);
|
||||
void panic(const char *) __attribute__((__noreturn__));
|
||||
void glog(const char *);
|
||||
void dlog(const char *);
|
||||
void quit(void) __attribute__((__noreturn__));
|
||||
void quitsig(int) __attribute__((__noreturn__));
|
||||
void whatsup(int);
|
||||
int readinput(FILE *);
|
||||
const char *stoc(int);
|
||||
int lton(int);
|
||||
int ctos(const char *);
|
||||
void update_overlap(struct spotstr *);
|
||||
int makemove(int, int);
|
||||
int list_eq(struct combostr **, struct combostr **, int);
|
||||
void clearcombo(struct combostr *, int);
|
||||
void makeempty(struct combostr *);
|
||||
void appendcombo(struct combostr *, int);
|
||||
void updatecombo(struct combostr *, int);
|
||||
void markcombo(struct combostr *);
|
||||
void printcombo(struct combostr *, char *);
|
||||
void makecombo(struct combostr *, struct spotstr *, int, int);
|
||||
void makecombo2(struct combostr *, struct spotstr *, int, int);
|
||||
int sortcombo(struct combostr **, struct combostr **, struct combostr *);
|
||||
int checkframes(struct combostr *, struct combostr *, struct spotstr *,
|
||||
int, struct ovlp_info *);
|
||||
void addframes(int);
|
||||
void scanframes(int);
|
||||
int better(const struct spotstr *, const struct spotstr *, int);
|
||||
int pickmove(int);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.11 2003/08/07 09:37:17 agc Exp $ */
|
||||
/* $NetBSD: main.c,v 1.12 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.11 2003/08/07 09:37:17 agc Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.12 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -79,7 +79,7 @@ int movelog[BSZ * BSZ]; /* log of all the moves */
|
||||
int movenum; /* current move number */
|
||||
const char *plyr[2]; /* who's who */
|
||||
|
||||
int main __P((int, char *[]));
|
||||
int main(int, char *[]);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pickmove.c,v 1.10 2003/08/07 09:37:17 agc Exp $ */
|
||||
/* $NetBSD: pickmove.c,v 1.11 2004/01/27 20:26:20 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
@@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: pickmove.c,v 1.10 2003/08/07 09:37:17 agc Exp $");
|
||||
__RCSID("$NetBSD: pickmove.c,v 1.11 2004/01/27 20:26:20 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: def.func_tab.h,v 1.6 2003/04/02 18:36:34 jsm Exp $ */
|
||||
/* $NetBSD: def.func_tab.h,v 1.7 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -65,14 +65,14 @@
|
||||
#define _DEF_FUNC_TAB_H_
|
||||
struct func_tab {
|
||||
char f_char;
|
||||
int (*f_funct) __P((void));
|
||||
int (*f_funct)(void);
|
||||
};
|
||||
|
||||
extern const struct func_tab cmdlist[];
|
||||
|
||||
struct ext_func_tab {
|
||||
const char *ef_txt;
|
||||
int (*ef_funct) __P((void));
|
||||
int (*ef_funct)(void);
|
||||
};
|
||||
|
||||
extern const struct ext_func_tab extcmdlist[];
|
||||
|
||||
1006
hack/extern.h
1006
hack/extern.h
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hack.apply.c,v 1.7 2003/04/02 18:36:35 jsm Exp $ */
|
||||
/* $NetBSD: hack.apply.c,v 1.8 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: hack.apply.c,v 1.7 2003/04/02 18:36:35 jsm Exp $");
|
||||
__RCSID("$NetBSD: hack.apply.c,v 1.8 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "hack.h"
|
||||
@@ -71,16 +71,16 @@ __RCSID("$NetBSD: hack.apply.c,v 1.7 2003/04/02 18:36:35 jsm Exp $");
|
||||
#include "def.edog.h"
|
||||
#include "def.mkroom.h"
|
||||
|
||||
static void use_camera __P((struct obj *));
|
||||
static int in_ice_box __P((struct obj *));
|
||||
static int ck_ice_box __P((struct obj *));
|
||||
static int out_ice_box __P((struct obj *));
|
||||
static void use_ice_box __P((struct obj *));
|
||||
static struct monst *bchit __P((int, int , int , int));
|
||||
static void use_whistle __P((struct obj *));
|
||||
static void use_magic_whistle __P((struct obj *));
|
||||
static int dig __P((void));
|
||||
static int use_pick_axe __P((struct obj *));
|
||||
static void use_camera(struct obj *);
|
||||
static int in_ice_box(struct obj *);
|
||||
static int ck_ice_box(struct obj *);
|
||||
static int out_ice_box(struct obj *);
|
||||
static void use_ice_box(struct obj *);
|
||||
static struct monst *bchit(int, int , int , int);
|
||||
static void use_whistle(struct obj *);
|
||||
static void use_magic_whistle(struct obj *);
|
||||
static int dig(void);
|
||||
static int use_pick_axe(struct obj *);
|
||||
|
||||
int
|
||||
doapply()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hack.do.c,v 1.6 2003/04/02 18:36:35 jsm Exp $ */
|
||||
/* $NetBSD: hack.do.c,v 1.7 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: hack.do.c,v 1.6 2003/04/02 18:36:35 jsm Exp $");
|
||||
__RCSID("$NetBSD: hack.do.c,v 1.7 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */
|
||||
@@ -75,7 +75,7 @@ __RCSID("$NetBSD: hack.do.c,v 1.6 2003/04/02 18:36:35 jsm Exp $");
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static int drop __P((struct obj *));
|
||||
static int drop(struct obj *);
|
||||
|
||||
int
|
||||
dodrop()
|
||||
@@ -406,8 +406,8 @@ dothrow()
|
||||
mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 :
|
||||
(!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1,
|
||||
obj->olet,
|
||||
(void (*) __P((struct monst *, struct obj *))) 0,
|
||||
(int (*) __P((struct obj *, struct obj *))) 0, obj);
|
||||
(void (*)(struct monst *, struct obj *)) 0,
|
||||
(int (*)(struct obj *, struct obj *)) 0, obj);
|
||||
}
|
||||
if (mon) {
|
||||
/* awake monster if sleeping */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hack.h,v 1.9 2003/04/02 18:36:37 jsm Exp $ */
|
||||
/* $NetBSD: hack.h,v 1.10 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -110,7 +110,7 @@ struct prop {
|
||||
#define RIGHT_SIDE RIGHT_RING
|
||||
#define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
|
||||
long p_flgs;
|
||||
void (*p_tofn) __P((void)); /* called after timeout */
|
||||
void (*p_tofn)(void); /* called after timeout */
|
||||
};
|
||||
|
||||
struct you {
|
||||
@@ -212,8 +212,8 @@ extern char sdir[]; /* defined in hack.c */
|
||||
extern const char shtypes[]; /* = "=/)%?!["; 8 types: 7 specialized, 1 mixed */
|
||||
extern const char vowels[];
|
||||
extern coord bhitpos; /* place where thrown weapon falls to the ground */
|
||||
extern int (*afternmv) __P((void));
|
||||
extern int (*occupation) __P((void));
|
||||
extern int (*afternmv)(void);
|
||||
extern int (*occupation)(void);
|
||||
extern int CO, LI; /* usually COLNO and ROWNO+2 */
|
||||
extern int bases[];
|
||||
extern int doorindex;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hack.invent.c,v 1.8 2003/04/02 18:36:37 jsm Exp $ */
|
||||
/* $NetBSD: hack.invent.c,v 1.9 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: hack.invent.c,v 1.8 2003/04/02 18:36:37 jsm Exp $");
|
||||
__RCSID("$NetBSD: hack.invent.c,v 1.9 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -78,8 +78,8 @@ __RCSID("$NetBSD: hack.invent.c,v 1.8 2003/04/02 18:36:37 jsm Exp $");
|
||||
|
||||
static int lastinvnr = 51; /* 0 ... 51 */
|
||||
|
||||
static void assigninvlet __P((struct obj *));
|
||||
static char *xprname __P((struct obj *, char));
|
||||
static void assigninvlet(struct obj *);
|
||||
static char *xprname(struct obj *, char);
|
||||
|
||||
static void
|
||||
assigninvlet(otmp)
|
||||
@@ -566,7 +566,7 @@ ckunpaid(otmp)
|
||||
int
|
||||
ggetobj(word, fn, max)
|
||||
const char *word;
|
||||
int (*fn) __P((struct obj *));
|
||||
int (*fn)(struct obj *);
|
||||
int max;
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
@@ -575,8 +575,8 @@ ggetobj(word, fn, max)
|
||||
int oletct = 0, iletct = 0;
|
||||
boolean allflag = FALSE;
|
||||
char olets[20], ilets[20];
|
||||
int (*ckfn) __P((struct obj *)) =
|
||||
(int (*) __P((struct obj *))) 0;
|
||||
int (*ckfn)(struct obj *) =
|
||||
(int (*)(struct obj *)) 0;
|
||||
xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */
|
||||
if (!invent && !allowgold) {
|
||||
pline("You have nothing to %s.", word);
|
||||
@@ -652,8 +652,8 @@ askchain(objchn, olets, allflag, fn, ckfn, max)
|
||||
struct obj *objchn;
|
||||
char *olets;
|
||||
int allflag;
|
||||
int (*fn) __P((struct obj *));
|
||||
int (*ckfn) __P((struct obj *));
|
||||
int (*fn)(struct obj *);
|
||||
int (*ckfn)(struct obj *);
|
||||
int max;
|
||||
{
|
||||
struct obj *otmp, *otmp2;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hack.main.c,v 1.8 2003/04/02 18:36:37 jsm Exp $ */
|
||||
/* $NetBSD: hack.main.c,v 1.9 2004/01/27 20:30:29 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: hack.main.c,v 1.8 2003/04/02 18:36:37 jsm Exp $");
|
||||
__RCSID("$NetBSD: hack.main.c,v 1.9 2004/01/27 20:30:29 jsm Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <signal.h>
|
||||
@@ -79,8 +79,8 @@ __RCSID("$NetBSD: hack.main.c,v 1.8 2003/04/02 18:36:37 jsm Exp $");
|
||||
#define gamename "hack"
|
||||
#endif
|
||||
|
||||
int (*afternmv) __P((void));
|
||||
int (*occupation) __P((void));
|
||||
int (*afternmv)(void);
|
||||
int (*occupation)(void);
|
||||
const char *occtxt; /* defined when occupation != NULL */
|
||||
|
||||
int hackpid; /* current pid */
|
||||
@@ -92,8 +92,8 @@ char SAVEF[PL_NSIZ + 11] = "save/"; /* save/99999player */
|
||||
char *hname; /* name of the game (argv[0] of call) */
|
||||
char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */
|
||||
|
||||
int main __P((int, char *[]));
|
||||
static void chdirx __P((const char *, boolean));
|
||||
int main(int, char *[]);
|
||||
static void chdirx(const char *, boolean);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user