| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include "Location.h" |
| 7 |
|
| 8 |
#include "instance.h" |
| 9 |
#include "options.h" |
| 10 |
#include "word.h" |
| 11 |
#include "inter.h" |
| 12 |
#include "lists.h" |
| 13 |
#include "checkentry.h" |
| 14 |
#include "debug.h" |
| 15 |
#include "memory.h" |
| 16 |
#include "dictionary.h" |
| 17 |
#include "output.h" |
| 18 |
#include "msg.h" |
| 19 |
#include "current.h" |
| 20 |
|
| 21 |
|
| 22 |
static void traceExit(int location, int dir, char *what) { |
| 23 |
printf("\n<EXIT %s[%d] from ", |
| 24 |
(char *)pointerTo(dictionary[playerWords[currentWordIndex-1].code].string), dir); |
| 25 |
traceSay(location); |
| 26 |
printf("[%d], %s:>\n", location, what); |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
void go(int location, int dir) |
| 33 |
{ |
| 34 |
ExitEntry *theExit; |
| 35 |
bool ok; |
| 36 |
Aword oldloc; |
| 37 |
|
| 38 |
theExit = (ExitEntry *) pointerTo(instances[location].exits); |
| 39 |
if (instances[location].exits != 0) |
| 40 |
while (!isEndOfArray(theExit)) { |
| 41 |
if (theExit->code == dir) { |
| 42 |
ok = true; |
| 43 |
if (theExit->checks != 0) { |
| 44 |
if (traceSectionOption) |
| 45 |
traceExit(location, dir, "Checking"); |
| 46 |
ok = !checksFailed(theExit->checks, EXECUTE_CHECK_BODY_ON_FAIL); |
| 47 |
} |
| 48 |
if (ok) { |
| 49 |
oldloc = location; |
| 50 |
if (theExit->action != 0) { |
| 51 |
if (traceSectionOption) |
| 52 |
traceExit(location, dir, "Executing"); |
| 53 |
interpret(theExit->action); |
| 54 |
} |
| 55 |
|
| 56 |
if (where(HERO, TRANSITIVE) == oldloc) { |
| 57 |
if (traceSectionOption) |
| 58 |
traceExit(location, dir, "Moving"); |
| 59 |
locate(HERO, theExit->target); |
| 60 |
} |
| 61 |
return; |
| 62 |
} else |
| 63 |
error(NO_MSG); |
| 64 |
} |
| 65 |
theExit++; |
| 66 |
} |
| 67 |
error(M_NO_WAY); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
bool exitto(int to, int from) |
| 73 |
{ |
| 74 |
ExitEntry *theExit; |
| 75 |
|
| 76 |
if (instances[from].exits == 0) |
| 77 |
return false; |
| 78 |
|
| 79 |
for (theExit = (ExitEntry *) pointerTo(instances[from].exits); !isEndOfArray(theExit); theExit++) |
| 80 |
if (theExit->target == to) |
| 81 |
return true; |
| 82 |
|
| 83 |
return false; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
void look(void) |
| 89 |
{ |
| 90 |
int i; |
| 91 |
|
| 92 |
|
| 93 |
for (i = 1; i <= header->instanceMax; i++) |
| 94 |
admin[i].alreadyDescribed = false; |
| 95 |
|
| 96 |
if (anyOutput) |
| 97 |
para(); |
| 98 |
|
| 99 |
setSubHeaderStyle(); |
| 100 |
sayInstance(current.location); |
| 101 |
setNormalStyle(); |
| 102 |
|
| 103 |
newline(); |
| 104 |
capitalize = true; |
| 105 |
if (describe(current.location)) |
| 106 |
describeInstances(); |
| 107 |
} |