dso3.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* FINDXT- FIND EXIT FROM ROOM */
  2. /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
  3. /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
  4. /* WRITTEN BY R. M. SUPNIK */
  5. #include <stdio.h>
  6. #include "funcs.h"
  7. #include "vars.h"
  8. logical findxt_(dir, rm)
  9. integer dir;
  10. integer rm;
  11. {
  12. /* System generated locals */
  13. logical ret_val;
  14. /* Local variables */
  15. integer i, xi;
  16. integer xxxflg;
  17. ret_val = TRUE_;
  18. /* !ASSUME WINS. */
  19. xi = rooms_1.rexit[rm - 1];
  20. /* !FIND FIRST ENTRY. */
  21. if (xi == 0) {
  22. goto L1000;
  23. }
  24. /* !NO EXITS? */
  25. L100:
  26. i = exits_1.travel[xi - 1];
  27. /* !GET ENTRY. */
  28. curxt_1.xroom1 = i & xpars_1.xrmask;
  29. /* mask to 16-bits to get rid of sign extension problems with 32-bit ints
  30. */
  31. xxxflg = ~ xpars_1.xlflag & 65535;
  32. curxt_1.xtype = ((i & xxxflg) / xpars_1.xfshft & xpars_1.xfmask) + 1;
  33. switch (curxt_1.xtype) {
  34. case 1: goto L110;
  35. case 2: goto L120;
  36. case 3: goto L130;
  37. case 4: goto L130;
  38. }
  39. /* !BRANCH ON ENTRY. */
  40. bug_(10, curxt_1.xtype);
  41. L130:
  42. curxt_1.xobj = exits_1.travel[xi + 1] & xpars_1.xrmask;
  43. curxt_1.xactio = exits_1.travel[xi + 1] / xpars_1.xashft;
  44. L120:
  45. curxt_1.xstrng = exits_1.travel[xi];
  46. /* !DOOR/CEXIT/NEXIT - STRING. */
  47. L110:
  48. xi += xpars_1.xelnt[curxt_1.xtype - 1];
  49. /* !ADVANCE TO NEXT ENTRY. */
  50. if ((i & xpars_1.xdmask) == dir) {
  51. return ret_val;
  52. }
  53. if ((i & xpars_1.xlflag) == 0) {
  54. goto L100;
  55. }
  56. L1000:
  57. ret_val = FALSE_;
  58. /* !YES, LOSE. */
  59. return ret_val;
  60. } /* findxt_ */
  61. /* FWIM- FIND WHAT I MEAN */
  62. /* DECLARATIONS */
  63. integer fwim_(f1, f2, rm, con, adv, nocare)
  64. integer f1;
  65. integer f2;
  66. integer rm;
  67. integer con;
  68. integer adv;
  69. logical nocare;
  70. {
  71. /* System generated locals */
  72. integer ret_val, i__1, i__2;
  73. /* Local variables */
  74. integer i, j;
  75. /* OBJECTS */
  76. ret_val = 0;
  77. /* !ASSUME NOTHING. */
  78. i__1 = objcts_1.olnt;
  79. for (i = 1; i <= i__1; ++i) {
  80. /* !LOOP */
  81. if ((rm == 0 || objcts_1.oroom[i - 1] != rm) && (adv == 0 ||
  82. objcts_1.oadv[i - 1] != adv) && (con == 0 || objcts_1.ocan[
  83. i - 1] != con)) {
  84. goto L1000;
  85. }
  86. /* OBJECT IS ON LIST... IS IT A MATCH? */
  87. if ((objcts_1.oflag1[i - 1] & VISIBT) == 0) {
  88. goto L1000;
  89. }
  90. if (~ (nocare) & (objcts_1.oflag1[i - 1] & TAKEBT) == 0 || (
  91. objcts_1.oflag1[i - 1] & f1) == 0 && (objcts_1.oflag2[i - 1]
  92. & f2) == 0) {
  93. goto L500;
  94. }
  95. if (ret_val == 0) {
  96. goto L400;
  97. }
  98. /* !ALREADY GOT SOMETHING? */
  99. ret_val = -ret_val;
  100. /* !YES, AMBIGUOUS. */
  101. return ret_val;
  102. L400:
  103. ret_val = i;
  104. /* !NOTE MATCH. */
  105. /* DOES OBJECT CONTAIN A MATCH? */
  106. L500:
  107. if ((objcts_1.oflag2[i - 1] & OPENBT) == 0) {
  108. goto L1000;
  109. }
  110. i__2 = objcts_1.olnt;
  111. for (j = 1; j <= i__2; ++j) {
  112. /* !NO, SEARCH CONTENTS. */
  113. if (objcts_1.ocan[j - 1] != i || (objcts_1.oflag1[j - 1] &
  114. VISIBT) == 0 || (objcts_1.oflag1[j - 1] & f1) ==
  115. 0 && (objcts_1.oflag2[j - 1] & f2) == 0) {
  116. goto L700;
  117. }
  118. if (ret_val == 0) {
  119. goto L600;
  120. }
  121. ret_val = -ret_val;
  122. return ret_val;
  123. L600:
  124. ret_val = j;
  125. L700:
  126. ;
  127. }
  128. L1000:
  129. ;
  130. }
  131. return ret_val;
  132. } /* fwim_ */
  133. /* YESNO- OBTAIN YES/NO ANSWER */
  134. /* CALLED BY- */
  135. /* YES-IS-TRUE=YESNO(QUESTION,YES-STRING,NO-STRING) */
  136. logical yesno_(q, y, n)
  137. integer q;
  138. integer y;
  139. integer n;
  140. {
  141. /* System generated locals */
  142. logical ret_val;
  143. /* Local variables */
  144. char ans[100];
  145. L100:
  146. rspeak_(q);
  147. /* !ASK */
  148. (void) fflush(stdout);
  149. (void) fgets(ans, sizeof ans, stdin);
  150. more_input();
  151. /* !GET ANSWER */
  152. if (*ans == 'Y' || *ans == 'y') {
  153. goto L200;
  154. }
  155. if (*ans == 'N' || *ans == 'n') {
  156. goto L300;
  157. }
  158. rspeak_(6);
  159. /* !SCOLD. */
  160. goto L100;
  161. L200:
  162. ret_val = TRUE_;
  163. /* !YES, */
  164. rspeak_(y);
  165. /* !OUT WITH IT. */
  166. return ret_val;
  167. L300:
  168. ret_val = FALSE_;
  169. /* !NO, */
  170. rspeak_(n);
  171. /* !LIKEWISE. */
  172. return ret_val;
  173. } /* yesno_ */