np2.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /* GETOBJ-- FIND OBJ DESCRIBED BY ADJ, NAME PAIR */
  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 "funcs.h"
  6. #include "vars.h"
  7. #include "parse.h"
  8. static logical thisit_ P((integer, integer, integer, integer));
  9. /* THIS ROUTINE DETAILS ON BIT 3 OF PRSFLG */
  10. integer getobj_(oidx, aidx, spcobj)
  11. integer oidx;
  12. integer aidx;
  13. integer spcobj;
  14. {
  15. /* System generated locals */
  16. integer ret_val, i__1;
  17. /* Local variables */
  18. integer i, av;
  19. integer obj;
  20. integer nobj;
  21. logical chomp;
  22. /* GETOBJ, PAGE 2 */
  23. chomp = FALSE_;
  24. av = advs_1.avehic[play_1.winner - 1];
  25. obj = 0;
  26. /* !ASSUME DARK. */
  27. if (! lit_(play_1.here)) {
  28. goto L200;
  29. }
  30. /* !LIT? */
  31. obj = schlst_(oidx, aidx, play_1.here, 0, 0, spcobj);
  32. /* !SEARCH ROOM. */
  33. if (obj < 0) {
  34. goto L1000;
  35. } else if (obj == 0) {
  36. goto L200;
  37. } else {
  38. goto L100;
  39. }
  40. /* !TEST RESULT. */
  41. L100:
  42. if (av == 0 || av == obj || (objcts_1.oflag2[obj - 1] & FINDBT)
  43. != 0) {
  44. goto L200;
  45. }
  46. if (objcts_1.ocan[obj - 1] == av) {
  47. goto L200;
  48. }
  49. /* !TEST IF REACHABLE. */
  50. chomp = TRUE_;
  51. /* !PROBABLY NOT. */
  52. L200:
  53. if (av == 0) {
  54. goto L400;
  55. }
  56. /* !IN VEHICLE? */
  57. nobj = schlst_(oidx, aidx, 0, av, 0, spcobj);
  58. /* !SEARCH VEHICLE. */
  59. if (nobj < 0) {
  60. goto L1100;
  61. } else if (nobj == 0) {
  62. goto L400;
  63. } else {
  64. goto L300;
  65. }
  66. /* !TEST RESULT. */
  67. L300:
  68. chomp = FALSE_;
  69. /* !REACHABLE. */
  70. if (obj == nobj) {
  71. goto L400;
  72. }
  73. /* !SAME AS BEFORE? */
  74. if (obj != 0) {
  75. nobj = -nobj;
  76. }
  77. /* !AMB RESULT? */
  78. obj = nobj;
  79. L400:
  80. nobj = schlst_(oidx, aidx, 0, 0, play_1.winner, spcobj);
  81. /* !SEARCH ADVENTURER. */
  82. if (nobj < 0) {
  83. goto L1100;
  84. } else if (nobj == 0) {
  85. goto L600;
  86. } else {
  87. goto L500;
  88. }
  89. /* !TEST RESULT */
  90. L500:
  91. if (obj != 0) {
  92. nobj = -nobj;
  93. }
  94. /* !AMB RESULT? */
  95. L1100:
  96. obj = nobj;
  97. /* !RETURN NEW OBJECT. */
  98. L600:
  99. if (chomp) {
  100. obj = -10000;
  101. }
  102. /* !UNREACHABLE. */
  103. L1000:
  104. ret_val = obj;
  105. if (ret_val != 0) {
  106. goto L1500;
  107. }
  108. /* !GOT SOMETHING? */
  109. i__1 = objcts_1.olnt;
  110. for (i = star_1.strbit + 1; i <= i__1; ++i) {
  111. /* !NO, SEARCH GLOBALS. */
  112. if (! thisit_(oidx, aidx, i, spcobj)) {
  113. goto L1200;
  114. }
  115. if (! ghere_(i, play_1.here)) {
  116. goto L1200;
  117. }
  118. /* !CAN IT BE HERE? */
  119. if (ret_val != 0) {
  120. ret_val = -i;
  121. }
  122. /* !AMB MATCH? */
  123. if (ret_val == 0) {
  124. ret_val = i;
  125. }
  126. L1200:
  127. ;
  128. }
  129. L1500:
  130. /* !END OF SEARCH. */
  131. return ret_val;
  132. } /* getobj_ */
  133. /* SCHLST-- SEARCH FOR OBJECT */
  134. /* DECLARATIONS */
  135. integer schlst_(oidx, aidx, rm, cn, ad, spcobj)
  136. integer oidx;
  137. integer aidx;
  138. integer rm;
  139. integer cn;
  140. integer ad;
  141. integer spcobj;
  142. {
  143. /* System generated locals */
  144. integer ret_val, i__1, i__2;
  145. /* Local variables */
  146. integer i, j, x;
  147. ret_val = 0;
  148. /* !NO RESULT. */
  149. i__1 = objcts_1.olnt;
  150. for (i = 1; i <= i__1; ++i) {
  151. /* !SEARCH OBJECTS. */
  152. if ((objcts_1.oflag1[i - 1] & VISIBT) == 0 || (rm == 0 || !
  153. qhere_(i, rm)) && (cn == 0 || objcts_1.ocan[i - 1] != cn)
  154. && (ad == 0 || objcts_1.oadv[i - 1] != ad)) {
  155. goto L1000;
  156. }
  157. if (! thisit_(oidx, aidx, i, spcobj)) {
  158. goto L200;
  159. }
  160. if (ret_val != 0) {
  161. goto L2000;
  162. }
  163. /* !GOT ONE ALREADY? */
  164. ret_val = i;
  165. /* !NO. */
  166. /* IF OPEN OR TRANSPARENT, SEARCH THE OBJECT ITSELF. */
  167. L200:
  168. if ((objcts_1.oflag1[i - 1] & TRANBT) == 0 && (
  169. objcts_1.oflag2[i - 1] & OPENBT) == 0) {
  170. goto L1000;
  171. }
  172. /* SEARCH IS CONDUCTED IN REVERSE. ALL OBJECTS ARE CHECKED TO */
  173. /* SEE IF THEY ARE AT SOME LEVEL OF CONTAINMENT INSIDE OBJECT 'I'. */
  174. /* IF THEY ARE AT LEVEL 1, OR IF ALL LINKS IN THE CONTAINMENT */
  175. /* CHAIN ARE OPEN, VISIBLE, AND HAVE SEARCHME SET, THEY CAN QUALIFY */
  176. /* AS A POTENTIAL MATCH. */
  177. i__2 = objcts_1.olnt;
  178. for (j = 1; j <= i__2; ++j) {
  179. /* !SEARCH OBJECTS. */
  180. if ((objcts_1.oflag1[j - 1] & VISIBT) == 0 || ! thisit_(
  181. oidx, aidx, j, spcobj)) {
  182. goto L500;
  183. }
  184. x = objcts_1.ocan[j - 1];
  185. /* !GET CONTAINER. */
  186. L300:
  187. if (x == i) {
  188. goto L400;
  189. }
  190. /* !INSIDE TARGET? */
  191. if (x == 0) {
  192. goto L500;
  193. }
  194. /* !INSIDE ANYTHING? */
  195. if ((objcts_1.oflag1[x - 1] & VISIBT) == 0 || (
  196. objcts_1.oflag1[x - 1] & TRANBT) == 0 && (
  197. objcts_1.oflag2[x - 1] & OPENBT) == 0 || (
  198. objcts_1.oflag2[x - 1] & SCHBT) == 0) {
  199. goto L500;
  200. }
  201. x = objcts_1.ocan[x - 1];
  202. /* !GO ANOTHER LEVEL. */
  203. goto L300;
  204. L400:
  205. if (ret_val != 0) {
  206. goto L2000;
  207. }
  208. /* !ALREADY GOT ONE? */
  209. ret_val = j;
  210. /* !NO. */
  211. L500:
  212. ;
  213. }
  214. L1000:
  215. ;
  216. }
  217. return ret_val;
  218. L2000:
  219. ret_val = -ret_val;
  220. /* !AMB RETURN. */
  221. return ret_val;
  222. } /* schlst_ */
  223. /* THISIT-- VALIDATE OBJECT VS DESCRIPTION */
  224. /* DECLARATIONS */
  225. static logical thisit_(oidx, aidx, obj, spcobj)
  226. integer oidx;
  227. integer aidx;
  228. integer obj;
  229. integer spcobj;
  230. {
  231. /* Initialized data */
  232. /* THE FOLLOWING DATA STATEMENT USED RADIX-50 NOTATION (R50MIN/1RA/) */
  233. /* IN RADIX-50 NOTATION, AN "A" IN THE FIRST POSITION IS */
  234. /* ENCODED AS 1*40*40 = 1600. */
  235. const integer r50min = 1600;
  236. /* System generated locals */
  237. logical ret_val;
  238. /* Local variables */
  239. integer i;
  240. ret_val = FALSE_;
  241. /* !ASSUME NO MATCH. */
  242. if (spcobj != 0 && obj == spcobj) {
  243. goto L500;
  244. }
  245. /* CHECK FOR OBJECT NAMES */
  246. i = oidx + 1;
  247. L100:
  248. ++i;
  249. if (ovoc[i - 1] <= 0 || ovoc[i - 1] >= r50min) {
  250. return ret_val;
  251. }
  252. /* !IF DONE, LOSE. */
  253. if (ovoc[i - 1] != obj) {
  254. goto L100;
  255. }
  256. /* !IF FAIL, CONT. */
  257. if (aidx == 0) {
  258. goto L500;
  259. }
  260. /* !ANY ADJ? */
  261. i = aidx + 1;
  262. L200:
  263. ++i;
  264. if (avoc[i - 1] <= 0 || avoc[i - 1] >= r50min) {
  265. return ret_val;
  266. }
  267. /* !IF DONE, LOSE. */
  268. if (avoc[i - 1] != obj) {
  269. goto L200;
  270. }
  271. /* !IF FAIL, CONT. */
  272. L500:
  273. ret_val = TRUE_;
  274. return ret_val;
  275. } /* thisit_ */