GithubHelp home page GithubHelp logo

troglobit / adventure Goto Github PK

View Code? Open in Web Editor NEW
70.0 3.0 12.0 850 KB

Classic Colossal Cave Adventure

License: The Unlicense

C 96.85% Makefile 1.49% Shell 0.03% M4 1.37% Dockerfile 0.26%
game text-adventure text-adventure-game

adventure's Introduction

adventure's People

Contributors

troglobit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

adventure's Issues

Is the hint implementation missing?

I've been having fun porting this to a 6502 forth and noticed that altho advent.h defines the HINTx conditions these don't seem to be referenced in the code. The hint messages are present in advent4.h (e.g. #63) but I can't find any equivalent of the checkhints routine from the open-adventure code.

advent.h:#define HINTC       16
advent.h:#define HINTB       32
advent.h:#define HINTS       64
advent.h:#define HINTM       128
advent.h:#define HINT        240

also doc/advent.txt mentions the feature, but maybe disappeared again later?

J) Hint feature restored with original messages
           (exact original algorithm unknown)

I'd be happy to try and restore if you have any traces of the original code.

"I don't know how to apply that word here"

I'm very excited that you've done this port! I didn't find the commands to build in the readmes, so I made my best guess as to how to build it:

./autogen
./configure
make

(were there instructions I missed?) I started the game by running src/advent, but pretty quickly I ran into problems with it not recognizing commands. "take lamp" etc worked, but "follow stream" yields "I don't know how to apply that word here." (and no directions work to get me to the grate). Looks like either a problem with my compile or a bug in the program?

Accessing arrays out of bounds

There are a couple of places in the turn.c file where the code accesses arrays out-of-bounds.
The following code segment will access the non existent elements prop[MAXOBJ] and place[MAXOBJ] (via toting() function).

85 if (closed) {
86 if (prop[OYSTER] < 0 && toting(OYSTER))
87 pspeak(OYSTER, 1);
88 for (i = 1; i <= MAXOBJ; ++i)
89 if (toting(i) && prop[i] < 0)
90 prop[i] = -1 - prop[i];
91 }

The following code will access place[MAXOBJ] (via toting() function). The call to dstroy() may or may not be a problem, that function allows values >= MAXOBJ, but may not give the intended result here.

792 for (i = 1; i <= MAXOBJ; ++i)
793 if (toting(i))
794 dstroy(i);

In the file database.c there appears to be a related problem in the move() function, where a value >= MAXOBJ will access the fixed array out-of-bounds - the intended array element is likely fixed[obj - MAXOBJ].

298 /*
299 Routine to destroy an object
300 */
301 void dstroy(int obj)
302 {
303 move(obj, 0);
304 }
305
306 /*
307 Routine to move an object
308 */
309 void move(int obj, int where)
310 {
311 int from;
312
313 from = (obj < MAXOBJ) ? place[obj] : fixed[obj];
314 if (from > 0 && from <= 300)
315 carry(obj, from);
316 drop(obj, where);
317 }
318

The arrays are declared in the advdef.h file with a size of MAXOBJ

26 int place[MAXOBJ]; /* object location */
27 int fixed[MAXOBJ]; /* second object loc */
28 int visited[MAXLOC]; /* >0 if has been here */
29 int prop[MAXOBJ]; /* status of object */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.