Commit graph

297 commits

Author SHA1 Message Date
Eric S. Raymond
2848494a01 Proof of cobcept for state defines.
It is now possible in the YAML to declare defines for all state values
associated with an object.  This are visible in the C code and can be used
to replace magic numbers.
2017-06-23 14:07:44 -04:00
Eric S. Raymond
1e8c3a4a1d Support loud locations. 2017-06-23 11:16:37 -04:00
Eric S. Raymond
f47dc9f447 Location sounds are now declared by YAML. 2017-06-23 10:10:48 -04:00
Eric S. Raymond
7f7f49b739 Switch fully over to YAML generation of condition bits. COND is gone. 2017-06-22 17:28:39 -04:00
Eric S. Raymond
433e787de8 Simple fix for GitLab issue #14: Behaviour of magic words changed
Say "Nothing happens" on "foo" not in Giant Room, rather than "What's
the matter, can't you read?  Now you'd best start over." which only
makes sense there.

It would be funnier to say something like "Well, that was remarkably
pointless." Maybe later.
2017-06-21 17:23:28 -04:00
Eric S. Raymond
fd6da15373 Fix GitLab issue #13 - The "eat" command exhibits strange behavior
The problem wasn't actually with "eat" but with "grate".  Processing
of any two-word command with an object of "grate", when given at certain
locations including the start, inappropriately jumped directly
to the movement code (ignoring the verb).

There was a similar bug in the ancestral 2.5, though it manifested slightly
differently.
2017-06-21 16:54:10 -04:00
Peje Nilsson
deb61e3dcd Replace SETPRM/[PR]SPEAK with variadic [pr]speak
Rename/rewrite old speak to vspeak and take a va_list
Add new speak that takes variadic parameters

Remove SETPRM & PARMS[]
2017-06-21 13:14:53 -04:00
Eric S. Raymond
e798355e80 Further code simplification. 2017-06-20 20:44:21 -04:00
Eric S. Raymond
237f1a876f Code simplification. 2017-06-20 20:39:45 -04:00
Eric S. Raymond
358fdd437b Chage read handler argument to by-value.
This (sort of) documents the fact that, unlike say() and attack(),
read() never scribbles on the interpreter's command block.

What those other functions are doing is unclean - though less so than
fully exposed globals. I don't see a way to fix it that isn't pretty
intrusive, alas.
2017-06-20 20:24:30 -04:00
Eric S. Raymond
9437ccca36 WD* globals abolished. They're now members of the command block. 2017-06-20 20:06:32 -04:00
Eric S. Raymond
7a3f3ec7a6 Introduce command encapsulation structure. 2017-06-20 17:40:41 -04:00
Eric S. Raymond
a678b68b39 Mostly confine assumptions about what token_t is to misc.c
The token_t things like WD* are presently longs and will someday be
char[6].  By introducing some trivial functions - wordeq(),
wordempty(), and wordclear() - we mostly hide the difference.

All runtime knowledge about packing now lives only in misc.c and the
list of magic WORD_* defines in advent.h.  Outside this, literals are
now accessed through #define names that could expand to either longs
or strings.

Still to be done: WD* values are sometiimes compated to zero in
ways implying they can be negative. Must figure out wat thus means.
2017-06-19 17:21:45 -04:00
Eric S. Raymond
87961483a2 Concentrate all magic-number values for packed-string constants in one place. 2017-06-19 16:53:55 -04:00
Eric S. Raymond
79f5701e07 More semantic typing - a step towards eliminating packing. 2017-06-19 14:20:45 -04:00
NHOrus
e9aff2568f Even less magic 2017-06-19 20:18:20 +03:00
Eric S. Raymond
0b91efc9eb Restructure some code. 2017-06-19 09:46:04 -04:00
Eric S. Raymond
98b02eeeb1 Magic number elimination, repair some careless replace damage. 2017-06-19 08:37:19 -04:00
Jason S. Ninneman
624ba16aad Change YES() to take const char* arguments. 2017-06-18 19:51:59 -07:00
Eric S. Raymond
fa9b6d317f No longer restricted to 6-character FORTRAN identifiers. 2017-06-18 21:17:57 -04:00
Eric S. Raymond
fd02259c7f Reindent and cleanup. 2017-06-18 20:24:37 -04:00
Bob Little
04eca720d9 magic numbers, show usage, fixed linty warnings
Show usage when using bad parameter with ./advent
Converted magic numbers to enums for BUG().  Also bug now shows
stringify'ed version of bug enumeration (not just a number).
2017-06-18 19:33:21 -04:00
Jason S. Ninneman
550734fd3f Gut and rebuild YES() with cleaner approach that doesn't rely on packing.
The new support functions get_input() and echo_input() (and others not made yet) will eventually replace GETIN() and MAPLIN().
2017-06-18 13:39:59 -07:00
Eric S. Raymond
704b86afbb Refactor scoring so score() does not conditionally exit. 2017-06-18 12:51:05 -04:00
Eric S. Raymond
937714f31d Magic-number limination. Improve test coverage. 2017-06-18 09:44:34 -04:00
Eric S. Raymond
6333544efb Simplify code, improve test coverage. 2017-06-18 08:57:08 -04:00
Eric S. Raymond
c8dbb241e8 Rxtend test coverage, remove magic numbers. 2017-06-18 07:11:20 -04:00
Eric S. Raymond
ff7db8b0c8 Improve test coverage, simplify code. 2017-06-18 06:41:16 -04:00
Eric S. Raymond
b3057f038b Re-format to consistent indent style with "make indent". 2017-06-18 06:18:51 -04:00
Eric S. Raymond
900822d38f Magic-number elimination. 2017-06-17 19:39:25 -04:00
Bob Little
a3485d2a41 Move a few prototypes and static'ed a few functions
Moved prototypes for initialise() and action() from main.c to advent.h
Made the following functions static, so they wouldn't require prototypes:
   sig_handler (main.c)
   spotted_by_pirate (main.c)
   light (actions.c)
2017-06-17 18:19:09 -04:00
Eric S. Raymond
13f2e85535 Correct a message. 2017-06-17 11:09:55 -04:00
Eric S. Raymond
851f90cdf7 Improve test coverage. 2017-06-16 15:40:46 -04:00
Eric S. Raymond
59a558b762 Code simplification. 2017-06-16 15:08:21 -04:00
Peje Nilsson
a6feda5307 Split saveresume to reduce complexity
Fixed a bug where current time was printed as version of advent
when loading an old savegame.
2017-06-16 14:16:02 -04:00
Peje Nilsson
adbbd1df25 Merge branch 'master' into actions-arithmetic 2017-06-16 17:43:14 +02:00
Eric S. Raymond
d97574d35c Magic-number elimination. 2017-06-16 08:55:53 -04:00
Eric S. Raymond
a57d93ce35 Magic-number elimination. 2017-06-16 07:00:57 -04:00
Eric S. Raymond
1b5ab6c808 Code simplification. 2017-06-16 06:44:22 -04:00
Peje Nilsson
d4fc7a88b4 Merge branch 'master' into actions-arithmetic 2017-06-16 10:10:38 +02:00
Peje Nilsson
9a32f4c770 Fix more arithmetic on locations & messages 2017-06-16 10:06:01 +02:00
Eric S. Raymond
eaee02aa09 Squasgh -Wextra warnings. 2017-06-15 19:39:43 -04:00
Eric S. Raymond
14486d67d4 Magic-numnber elimination. 2017-06-15 12:19:06 -04:00
Peje Nilsson
a86c67c2ab Merge branch 'master' into actions-arithmetic 2017-06-15 17:33:15 +02:00
Eric S. Raymond
49edca485d More use of manifeat constants. 2017-06-15 11:15:45 -04:00
Peje Nilsson
29121a82f8 Fix arithmetic on message number 2017-06-15 17:01:10 +02:00
Eric S. Raymond
0dc78b4221 More use of manifest constants. 2017-06-15 10:59:43 -04:00
Eric S. Raymond
1896e0f886 Use symbolic shortnames for locations. 2017-06-15 10:31:26 -04:00
NHOrus
f1f7cfd4e9 Localizing variables 2017-06-15 16:16:21 +03:00
Eric S. Raymond
e5f9c4fbea Use LOC_* constants for locations. Clean up some ARB_* constants. 2017-06-15 08:49:47 -04:00