Commit graph

49 commits

Author SHA1 Message Date
Jason S. Ninneman
d5582df121 Rescope and retype a variable. 2017-06-13 20:43:44 +03:00
Jason S. Ninneman
065974d03e Make GETTXT() a bit closer to actual C. 2017-06-13 20:43:44 +03:00
Eric S. Raymond
a07e59b0f1 Simplify bitmask test/set from FORTRANish to actual C. 2017-06-13 20:43:43 +03:00
Eric S. Raymond
e738596c74 Macro elimination - easy cases first. No logic changes. 2017-06-13 20:43:43 +03:00
Eric S. Raymond
1fffdfb680 Header consolidation - main.h, misc.h, and share.h merge to advent.h.
For a project this small size with a small type ontology, it's better
C style to have one header where all the assumptions about types and
structures are immediately visible.

This is a first step towards turning all that global state into a handful
of structures - probably just two, one saveable as a binary game state.
2017-06-13 20:43:43 +03:00
Michael Jarvis
c5071a1bb5 added braces around initialization of subobjects for clarity 2017-06-13 20:43:43 +03:00
Michael Jarvis
f8152ac470 Cast size_t to long to silence warning 2017-06-13 20:43:43 +03:00
Jason S. Ninneman
39b2c286d9 Fix a bug in RNDVOC() that prevented the reservoir magic word for working.
To do this, I first had to refactor the code into proper C, just so I could understand it. Then I found another layer of encryption around the value itself. Finally, I discovered that the line to actually set the new magic word was placed such that it was using a global index instead of the local one.
2017-06-13 20:43:42 +03:00
Jason S. Ninneman
863edfb60a Make RNDVOC() into better C. 2017-06-13 20:43:42 +03:00
Jason S. Ninneman
e4d145d727 Really mean it about strict C99 compliance. 2017-06-13 20:43:42 +03:00
Eric S. Raymond
7bf56ac60e Simplify build: nested makefiles considered harmful. 2017-06-13 20:43:42 +03:00
Jason S. Ninneman
0b02f361de Move database compilation out into its own tool (for now). 2017-06-13 20:43:42 +03:00
Jason S. Ninneman
e281f895d4 Factor out handling of variables populated from the database.
This reorganization is a first step toward handling database compilation separately.
2017-06-13 20:43:41 +03:00
Jason S. Ninneman
0064a4257e Just say no to encrypting internal state. 2017-06-13 20:43:41 +03:00
Eric S. Raymond
d96c66ac36 Fix bug that led to comments bnot being ignored. 2017-06-13 20:43:41 +03:00
Eric S. Raymond
ff467f276b Implement fallback handler that looks at the raw command buffer.
With database cinpilation not broken this time...
2017-06-13 20:43:41 +03:00
Jason S. Ninneman
000b97ff11 Stop command-logging from non-stdin sources. 2017-06-13 20:43:41 +03:00
Eric S. Raymond
341bf61139 Once again, take srand()/random() out of the initialization chain.
They have exactly the wrong kind of randomness for this job - not
returning consistent sequences across different platforms or C library
versions, and because pseodorandom not really better than sampling
the clock.
2017-06-13 20:43:41 +03:00
Eric S. Raymond
4d50cce210 Re-enable skipping of #-led comments. 2017-06-13 20:43:41 +03:00
Eric S. Raymond
eb91f49dd5 Reapply "Clean up logic for exiting input loop and scoring." 2017-06-13 20:43:41 +03:00
Eric S. Raymond
06795f691f Revert SEED handling and comment orocessing. It broke database compilation.
This code is remarkably like the game it implements - a maze of twisty
little FORTRANisms, all alike.  Very easy to get lost.
2017-06-13 20:43:41 +03:00
Eric S. Raymond
bd64a4ceda Take srand()/rand() out of the initialization chain...
...they're not guatanteed to produce consistent across platforms or
libc versions.
2017-06-13 20:43:41 +03:00
Eric S. Raymond
9ef91255bc Clean up logic for exiting input loop and scoring. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
9407cd7bc3 Allow comments in logfiles. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
016bcf2ff2 Seed command fully implemented but apparently buggy.
Dwarf appearance is not yet reproducible.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
1c4150055a Implement stub handler for SEED command. Not hooked up to PRNG yet. 2017-06-13 20:43:40 +03:00
Jason S. Ninneman
ebfa184a6c Remove a bad use of tv_nsec. 2017-06-13 20:43:40 +03:00
Jason S. Ninneman
8d97eb71ff Move a line that got out of place. 2017-06-13 20:43:40 +03:00
Jason S. Ninneman
24f327cc09 Add seedable PRNG using an adaptation the original LCG algorithm. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
b0a3c821e9 Fix the slightly broken prompt test. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
aa7e291bc6 Revert structurization changes, they broke database compilation...
...bug showing only if adventure.data was absent.  We'll need to sneak up
on this more carefully.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
3f57114791 Revert a variable name previously changed to be out of the way.
Also, make output from replays easier to interpret by adding prompts.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
ac14bf8ae9 Echo commands to stdout when replaying...
...makes check loads full transcripts abd more readable.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
91bfd55c1c Begin gathering saveable game state into a structure. Not yet complete.
No logic changes.  A bunch of globals turn into fields (with the same names
except for lowercasing) in struct game_t.

Eventually this will allow drastic simplification of the save/load logic.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
ec4c0c8cd0 Input source is parametrized all the way down.
This means that, potentially, do_command() could be called on any text file
pointer and the right thing would happen.
2017-06-13 20:43:40 +03:00
Eric S. Raymond
0ad8d13f27 Added oldstyle option. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
c16e4cb078 Fix capitalization glitches. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
0eda56fae9 Add -l option to enable command logging. 2017-06-13 20:43:40 +03:00
Eric S. Raymond
42e6e7cdb7 Fix strange inside-out organization of the input routines.
Seems to have nbben a result of FORTRAN not having anything like a
stream object that can be passed around.

A step towards logging and log replay.
2017-06-13 20:43:39 +03:00
Eric S. Raymond
de1ac23b2e Remove unused labels. 2017-06-13 20:43:39 +03:00
Eric S. Raymond
7f25697673 Don't use a magic number when we can use sizeof(). 2017-06-13 20:43:39 +03:00
Eric S. Raymond
f376383a89 Prototypization. 2017-06-13 20:43:39 +03:00
Eric S. Raymond
a7f6f62a1a Correct long-size bug that resulted in checksum error.
Idea thanks tp Max Ninneman.
2017-06-13 20:43:39 +03:00
Eric S. Raymond
301f38586b Fix up case on all comments to make them more readable. No code changes.
The all-capsing was a FORTRAN remnant.Also, we change a few FORTRANisms
so they are less confusing in this C context; ".TRUE." and ".FALSE." become
"true" and "false", "MOD" is mapped to % in places tha t are like C expressions
and (usually) "modulo" in places that aren't.
2017-06-13 20:43:39 +03:00
Eric S. Raymond
343551ee79 More ANSI prototype conversions. 2017-06-13 20:43:39 +03:00
Eric S. Raymond
936a4a27b5 More boolification.
Constants and formals have been converted, but not globals yet.
2017-06-13 20:43:39 +03:00
Eric S. Raymond
6ef3e68c0c Replace fDATIME with ANSI/POSIX clock_gettime(). Rip out DOS/AMIGA shims.
The thinking here is that we simplify life by going pure ANSI/POSIX.
This is a text game.  If it ever runs on anything but Unix again it's
almost certain to be on something like WSL that supplies a
POSIX-conformant text console.
2017-06-13 20:43:39 +03:00
Eric S. Raymond
afddd9b263 Partially ANSIfy C, fix compiler warnings. 2017-06-13 20:43:39 +03:00
Eric S. Raymond
f16343f8dc Don Wood's 430-point Adventure 2.5 from 1995, from rec.games.int-fiction. 2017-06-13 20:43:39 +03:00