| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include "act.h" |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#include "AltInfo.h" |
| 14 |
#include "output.h" |
| 15 |
#include "msg.h" |
| 16 |
#include "exe.h" |
| 17 |
#include "lists.h" |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
static void executeCommand(int verb, Parameter parameters[]) |
| 22 |
{ |
| 23 |
static AltInfo *altInfos = NULL; |
| 24 |
int altIndex; |
| 25 |
|
| 26 |
|
| 27 |
if (altInfos != NULL) |
| 28 |
free(altInfos); |
| 29 |
|
| 30 |
altInfos = findAllAlternatives(verb, parameters); |
| 31 |
|
| 32 |
if (anyCheckFailed(altInfos, EXECUTE_CHECK_BODY_ON_FAIL)) |
| 33 |
return; |
| 34 |
|
| 35 |
|
| 36 |
if (!anythingToExecute(altInfos)) |
| 37 |
error(M_CANT0); |
| 38 |
|
| 39 |
|
| 40 |
for (altIndex = lastAltInfoIndex(altInfos); altIndex >= 0; altIndex--) { |
| 41 |
if (altInfos[altIndex].alt != 0) |
| 42 |
if (altInfos[altIndex].alt->qual == (Aword)Q_BEFORE |
| 43 |
|| altInfos[altIndex].alt->qual == (Aword)Q_ONLY) { |
| 44 |
if (!executedOk(&altInfos[altIndex])) |
| 45 |
abortPlayerCommand(); |
| 46 |
if (altInfos[altIndex].alt->qual == (Aword)Q_ONLY) |
| 47 |
return; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
for (altIndex = 0; !altInfos[altIndex].end; altIndex++) { |
| 53 |
if (altInfos[altIndex].alt != 0) |
| 54 |
if (altInfos[altIndex].alt->qual != (Aword)Q_AFTER) |
| 55 |
if (!executedOk(&altInfos[altIndex])) |
| 56 |
abortPlayerCommand(); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
for (altIndex = lastAltInfoIndex(altInfos); altIndex >= 0; altIndex--) { |
| 61 |
if (altInfos[altIndex].alt != 0) |
| 62 |
if (!executedOk(&altInfos[altIndex])) |
| 63 |
abortPlayerCommand(); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
void action(int verb, Parameter parameters[], Parameter multipleMatches[]) |
| 77 |
{ |
| 78 |
int i, multiplePosition; |
| 79 |
char marker[20]; |
| 80 |
|
| 81 |
multiplePosition = findMultiplePosition(parameters); |
| 82 |
if (multiplePosition != -1) { |
| 83 |
jmp_buf savedReturnLabel; |
| 84 |
memcpy(savedReturnLabel, returnLabel, sizeof(returnLabel)); |
| 85 |
sprintf(marker, "($%d)", multiplePosition+1); |
| 86 |
for (i = 0; !isEndOfArray(&multipleMatches[i]); i++) { |
| 87 |
copyParameter(¶meters[multiplePosition], &multipleMatches[i]); |
| 88 |
setGlobalParameters(parameters); |
| 89 |
output(marker); |
| 90 |
|
| 91 |
if (setjmp(returnLabel) == NO_JUMP_RETURN) |
| 92 |
executeCommand(verb, parameters); |
| 93 |
if (multipleMatches[i+1].instance != EOF) |
| 94 |
para(); |
| 95 |
} |
| 96 |
memcpy(returnLabel, savedReturnLabel, sizeof(returnLabel)); |
| 97 |
parameters[multiplePosition].instance = 0; |
| 98 |
} else { |
| 99 |
setGlobalParameters(parameters); |
| 100 |
executeCommand(verb, parameters); |
| 101 |
} |
| 102 |
|
| 103 |
} |