dso5.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
  2. /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
  3. /* WRITTEN BY R. M. SUPNIK */
  4. #include "funcs.h"
  5. #include "vars.h"
  6. /* GTTIME-- GET TOTAL TIME PLAYED */
  7. void gttime_(t)
  8. integer *t;
  9. {
  10. integer h, m, s;
  11. itime_(&h, &m, &s);
  12. *t = h * 60 + m - (time_1.shour * 60 + time_1.smin);
  13. if (*t < 0) {
  14. *t += 1440;
  15. }
  16. *t += time_1.pltime;
  17. return;
  18. } /* gttime_ */
  19. /* OPNCLS-- PROCESS OPEN/CLOSE FOR DOORS */
  20. /* DECLARATIONS */
  21. logical opncls_(obj, so, sc)
  22. integer obj;
  23. integer so;
  24. integer sc;
  25. {
  26. /* System generated locals */
  27. integer i__1;
  28. logical ret_val;
  29. ret_val = TRUE_;
  30. /* !ASSUME WINS. */
  31. if (prsvec_1.prsa == vindex_1.closew) {
  32. goto L100;
  33. }
  34. /* !CLOSE? */
  35. if (prsvec_1.prsa == vindex_1.openw) {
  36. goto L50;
  37. }
  38. /* !OPEN? */
  39. ret_val = FALSE_;
  40. /* !LOSE */
  41. return ret_val;
  42. L50:
  43. if ((objcts_1.oflag2[obj - 1] & OPENBT) != 0) {
  44. goto L200;
  45. }
  46. /* !OPEN... IS IT? */
  47. rspeak_(so);
  48. objcts_1.oflag2[obj - 1] |= OPENBT;
  49. return ret_val;
  50. L100:
  51. if (! ((objcts_1.oflag2[obj - 1] & OPENBT) != 0)) {
  52. goto L200;
  53. }
  54. /* !CLOSE... IS IT? */
  55. rspeak_(sc);
  56. objcts_1.oflag2[obj - 1] &= ~ OPENBT;
  57. return ret_val;
  58. L200:
  59. i__1 = rnd_(3) + 125;
  60. rspeak_(i__1);
  61. /* !DUMMY. */
  62. return ret_val;
  63. } /* opncls_ */
  64. /* LIT-- IS ROOM LIT? */
  65. /* DECLARATIONS */
  66. logical lit_(rm)
  67. integer rm;
  68. {
  69. /* System generated locals */
  70. integer i__1, i__2;
  71. logical ret_val;
  72. /* Local variables */
  73. integer i, j, oa;
  74. ret_val = TRUE_;
  75. /* !ASSUME WINS */
  76. if ((rooms_1.rflag[rm - 1] & RLIGHT) != 0) {
  77. return ret_val;
  78. }
  79. i__1 = objcts_1.olnt;
  80. for (i = 1; i <= i__1; ++i) {
  81. /* !LOOK FOR LIT OBJ */
  82. if (qhere_(i, rm)) {
  83. goto L100;
  84. }
  85. /* !IN ROOM? */
  86. oa = objcts_1.oadv[i - 1];
  87. /* !NO */
  88. if (oa <= 0) {
  89. goto L1000;
  90. }
  91. /* !ON ADV? */
  92. if (advs_1.aroom[oa - 1] != rm) {
  93. goto L1000;
  94. }
  95. /* !ADV IN ROOM? */
  96. /* OBJ IN ROOM OR ON ADV IN ROOM */
  97. L100:
  98. if ((objcts_1.oflag1[i - 1] & ONBT) != 0) {
  99. return ret_val;
  100. }
  101. if ((objcts_1.oflag1[i - 1] & VISIBT) == 0 || (
  102. objcts_1.oflag1[i - 1] & TRANBT) == 0 && (
  103. objcts_1.oflag2[i - 1] & OPENBT) == 0) {
  104. goto L1000;
  105. }
  106. /* OBJ IS VISIBLE AND OPEN OR TRANSPARENT */
  107. i__2 = objcts_1.olnt;
  108. for (j = 1; j <= i__2; ++j) {
  109. if (objcts_1.ocan[j - 1] == i && (objcts_1.oflag1[j - 1] &
  110. ONBT) != 0) {
  111. return ret_val;
  112. }
  113. /* L500: */
  114. }
  115. L1000:
  116. ;
  117. }
  118. ret_val = FALSE_;
  119. return ret_val;
  120. } /* lit_ */
  121. /* WEIGHT- RETURNS SUM OF WEIGHT OF QUALIFYING OBJECTS */
  122. /* DECLARATIONS */
  123. integer weight_(rm, cn, ad)
  124. integer rm;
  125. integer cn;
  126. integer ad;
  127. {
  128. /* System generated locals */
  129. integer ret_val, i__1;
  130. /* Local variables */
  131. integer i, j;
  132. ret_val = 0;
  133. i__1 = objcts_1.olnt;
  134. for (i = 1; i <= i__1; ++i) {
  135. /* !OMIT BIG FIXED ITEMS. */
  136. if (objcts_1.osize[i - 1] >= 10000) {
  137. goto L100;
  138. }
  139. /* !IF FIXED, FORGET IT. */
  140. if (qhere_(i, rm) && rm != 0 || objcts_1.oadv[i - 1] == ad && ad
  141. != 0) {
  142. goto L50;
  143. }
  144. j = i;
  145. /* !SEE IF CONTAINED. */
  146. L25:
  147. j = objcts_1.ocan[j - 1];
  148. /* !GET NEXT LEVEL UP. */
  149. if (j == 0) {
  150. goto L100;
  151. }
  152. /* !END OF LIST? */
  153. if (j != cn) {
  154. goto L25;
  155. }
  156. L50:
  157. ret_val += objcts_1.osize[i - 1];
  158. L100:
  159. ;
  160. }
  161. return ret_val;
  162. } /* weight_ */