Commit Graph

74 Commits

Author SHA1 Message Date
dholland 6f629695aa Minor tidyup. 2014-03-22 22:04:40 +00:00
dholland 337d73a6f4 tag decl() __noinline, as inlining it would defeat its purpose
(which is to not have interesting string literals appear in the
compiled binary)
2014-03-22 20:07:05 +00:00
jmcneill 410c4edada Workaround a toolchain issue by renaming the 'setup' host tool to 'mkdata' to make UAC happy when building with Cygwin. As described here -- http://msdn.microsoft.com/en-us/library/windows/desktop/bb756960.aspx -- 32-bit executables whose filenames include the strings 'install', 'setup', 'update', 'patch', etc. by default will request admin privileges unless an application manifest is provided. 2013-02-16 16:30:28 +00:00
dholland 24462a68ab fix previous, thanks asau@ 2012-10-12 15:41:10 +00:00
dholland 6dd1299b8b Pass -Wstrict-overflow. 2012-10-12 10:38:53 +00:00
dholland 8879f685e9 grumble. 2012-01-08 18:17:41 +00:00
dholland 158b740733 Oops, I forgot to actually implement the checksumming code for the new
savefile format, so any savefiles generated yesterday can be tampered
with. Oh well. While here, tidy up the crc code.
2012-01-08 18:16:00 +00:00
dholland c99eaa0a43 Redo save file handling. The old save files were unportable, had no
magic number or versioning, relied on random(3) never changing to a
different implementation, and were also saving pointers to disk and
reading them back again. It *looks* as if the pointers thus loaded
were reset before being used, but it's not particularly clear as the
main loop of this thing is goto-based FORTRAN translated lightly to C.
I've changed the logic to null these pointers instead of saving and
loading them, and things seem to still work.

The new save files have a header, support versioning, write only sized
types in network byte order, and for the toy encryption to discourage
cheating do something self-contained instead of using random(3) as a
stream cipher.

Because between the original import from 4.4 until earlier today
trying to save would result in SIGSEGV on most platforms, it's
unlikely anyone has a save file, but just in case (since the pointer
issue appears to be nonlethal) I've kept compat code for old save
files.
2012-01-07 22:23:16 +00:00
dholland f08dd5ca74 Make this not crash on machines that are (a) 64 bit, or (b) have signed
chars by default (i.e., almost all machines). Makes it possible to save
the game. This has been broken since 4.4 and probably ever since the
FORTRAN -> C translation.

Crash reported by Petri Laakso in private mail.
2012-01-07 18:08:35 +00:00
plunky 9f61b80465 NULL does not need a cast 2011-08-31 16:24:54 +00:00
snj 550147bd6a Remove 3rd and 4th clauses in christos' license. OK christos. 2009-10-21 01:07:44 +00:00
dholland 7c9708a909 Use __dead. 2009-08-25 06:58:04 +00:00
dholland aa19a9d0a5 Whn ths cd ws wrttn, thr ws bt shrtg nd vwls wr xtrml xpnsv. Nowadays,
however, we have an ample vowel budget, and bit shortages are a thing
of the past (even in a down economy) so spend a bit to improve
readability.
2009-08-25 06:56:52 +00:00
dholland 84bca7035f ANSIfy a leftover function.
Also note some unportable code with a comment. Can't change it because
it'd break save files, though.
2009-08-25 06:04:17 +00:00
dholland c62bf84c55 sprinkle static 2009-08-12 04:28:27 +00:00
lukem 2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
perry 8b0f9554ff convert __attribute__s to applicable cdefs.h macros 2007-12-15 19:44:37 +00:00
mrg 06b50ed8b9 don't try to switch a char and have a case of EOF - use an int. 2006-05-18 18:42:59 +00:00
christos dd3fe9b2dc Coverity CID 2737: Handle linked-lists properly. Use calloc instead of malloc
so that we don't end up storing garbage accidentally and the next pointer is
initialized. If there is an inconsistency in the file abort instead
of dereferencing NULL.
2006-03-21 17:14:15 +00:00
christos f80221a1cd Coverity CID 570: Remove impossible check. 2006-03-18 23:35:51 +00:00
christos 44fa0e017a Coverity CID 1195: Check for possible negative index. 2006-03-18 23:33:38 +00:00
christos 8319a6a7da Coverity CID 777: Fix NULL pointer deref and de-obfuscate code. 2006-03-18 23:31:19 +00:00
rtr 0c0f6ae5dc don't access out of bounds element of static alloc array.
found by Coverity, CID 1519 / Run 5

XXX possible that intention was to start with i = 0.
2006-03-18 05:16:46 +00:00
jmc 243d04ef01 KNF and WARNS=3 2005-07-01 00:03:36 +00:00
jsm cb5fd8342e Remove uses of __P. 2004-01-27 20:30:28 +00:00
jsm e98705eff6 Fix capitalisation of compass directions. 2004-01-01 15:58:03 +00:00
lukem e606e2dcb2 Improve how various "simple" host tools are built and invoked. 2003-11-16 14:14:18 +00:00
lukem 130ab7336b Rework how MAKEVERBOSE operates:
*	Don't bother prefixing commands with a line of  ${_MKCMD}\
	and instead rely upon "make -s".  This is less intrusive on
	all the Makefiles than the former.  Idea from David Laight.

    *	Rename the variables use to print messages.  The scheme now is:
	    _MKMSG_FOO		Run  _MKMSG 'foo'
	    _MKTARGET_FOO	Run  _MKMSG_FOO ${.TARGET}
	From discussion with Alistair Crooks.
2003-10-21 10:01:19 +00:00
lukem ddff99b7f4 rework to use the newer _MKMSGCREATE (et al) macros 2003-10-19 04:45:01 +00:00
lukem 2b8c8463a6 Support MAKEVERBOSE. (Some host tools still generate verbose runtime messages) 2003-10-19 01:01:44 +00:00
itojun b7bf49278d off-by-one. aaron@openbsd 2003-09-19 10:01:53 +00:00
itojun 8a75cadd4e off-by-one. aaron@openbsd 2003-09-19 10:01:21 +00:00
agc e5aeb4ea46 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22269, verified by myself.
2003-08-07 09:36:50 +00:00
thorpej 0e02b70640 No need to reference .OBJDIR here. 2002-03-05 21:28:12 +00:00
jsm d929aa8aeb Ensure trailing newline is present on error and warning messages (lost
in previous conversion from <err.h> functions to ISO C ones).
2001-08-29 18:22:56 +00:00
christos 762fbcf25e eliminate redundant decls 2001-02-05 00:20:05 +00:00
simonb 0ac29f6624 Don't use <sys/cdefs.h> __COPYRIGHT/__RCSID macros or <err.h> err/errx
functions for host programs - use portable ANSI constructs instead.

Patches from Chris Demetriou.
2000-07-31 11:25:50 +00:00
matt 3233065035 More include additions for exit, abs, strcmp, etc. 2000-07-03 03:57:39 +00:00
mycroft f9eca6973d Use setgid(), not setregid(). 2000-05-08 07:55:59 +00:00
pk b63c26a995 HOST_CC -> HOST_LINK.c 2000-04-24 15:15:05 +00:00
jsm a5da40c55a Use err(1, NULL) and warn(NULL) for `out of memory' error messages. 2000-01-09 17:17:19 +00:00
hubertf ef49c17e92 This patch fixes adventure(6) to use `extern' on declarations of
objects in its header file, and to add corresponding definitions to
init.c accordingly.  (See the C standard - relying on linker commons
where there are multiple uninitialised declarations of an object in
the program traditionally works on Unix, but is not standard C.)

The patch also removes a bit-rotten code fragment under #ifdef
OLDSTUFF.

Patch submitted in PR 8105 by Joseph Myers <jsm28@cam.ac.uk>
1999-07-28 23:23:39 +00:00
hubertf aac1ec24ab Adventure(6) should check for errors (e.g. disk full or quota
exceeded) when writing out saved games. Do so!

Patch supplied by Joseph Myers <jsm28@cam.ac.uk> in PR 8016
1999-07-17 20:02:48 +00:00
hubertf adf74b1e92 This patch cleans up the handling of the variable `saved' in
adventure(6).  The handling of this variable is somewhat confusing,
since it is used for two different purposes (controlling the time
required before a saved game can be restored, and controlling various
aspects of dwarf behaviour); in fact, it is also declared twice in
hdr.h.  Except possibly when saving a game fails, these uses can never
interfere; when used for controlling dwarf behaviour, we always have
saved == -1.  This can be better understood with reference to the
original PDP-10 FORTRAN source (URL in patch, since hdr.h references
the comments of the FORTRAN as still relevant to this version) of
which the C version is a direct translation: the wrong value for
`saved' meant that someone was cheating and had bypassed normal
initialisation.  Saving was done by halting and telling the user to
save their core image, so the question of carrying on after saving
failed to open the output file did not arise.

This patch separates the uses of `saved' into uses of two separate
variables.

Closes PR 8005 by Joseph Myers <jsm28@cam.ac.uk>
1999-07-16 01:38:20 +00:00
hubertf 76139748e2 From PR 7985 by Joseph Myers <jsm28@cam.ac.uk>:
games/adventure/setup.c fails to check for errors when writing its
output.  This means that, if the disk fills up at this point during a
build, it would nevertheless fail to return an error status.
1999-07-14 17:21:03 +00:00
hubertf 752e969da2 Add __attribute__() to a variable. From PR 6557, after discussion with
Joseph S. Myers <jsm28@cam.ac.uk>
1999-02-10 12:38:54 +00:00
hubertf c7bcded63e The patch below does some minor cleanup of adventure(6): an additional
use of const I missed in bin/6041; avoiding a signed/unsigned warning;
marking an unused parameter as such; revoking setgid privileges
(including the saved gid) rather than setuid ones; includes and
function prototypes in setup.c; the string passed to err() should not
end with a `.'.  Together with the patch sent concerning adventure's
EOF handling, this synchronises adventure(6) in NetBSD with the Linux
port of the NetBSD games.

Via PR 6557 by Joseph Myers <jsm28@cam.ac.uk>
1999-02-10 00:29:21 +00:00
hubertf 08ab0f321a The game adventure(6) handles EOF on standard input rather
ungracefully.  The patch, derived from OpenBSD, improves this
handling.

Sent in in PR 6556 by Joseph Myers <jsm28@cam.ac.uk>.
1999-02-10 00:11:28 +00:00
hubertf 006cc8ac96 return error on errors (PR#6147 by Joseph Myers <jsm28@cam.ac.uk>) 1998-09-14 09:29:08 +00:00
hubertf 878ef9cb13 check for malloc failures (PR#6136 by Joseph Myers <jsm28@cam.ac.uk>) 1998-09-13 15:24:09 +00:00