home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / monhl104 / part11 < prev    next >
Encoding:
Internet Message Format  |  1992-08-02  |  42.3 KB

  1. Path: uunet!mcsun!news.funet.fi!hydra!klaava!hurtta
  2. From: Kari.Hurtta@Helsinki.FI (Kari E. Hurtta)
  3. Newsgroups: vmsnet.sources.games
  4. Subject: Monster Helsinki V 1.04 - part 11/32
  5. Keywords: Monster, a multiplayer adventure game
  6. Message-ID: <1992Jun14.011834.4158@klaava.Helsinki.FI>
  7. Date: 14 Jun 92 01:18:34 GMT
  8. Sender: hurtta@klaava.Helsinki.FI (Kari Hurtta)
  9. Followup-To: vmsnet.sources.d
  10. Organization: University of Helsinki
  11. Lines: 1614
  12.  
  13. Archieve-name: monster_helsinki_104/part11
  14. Author: Kari.Hurtta@Helsinki.FI
  15. Product: Monster Helsinki V 1.04
  16. Environment: VMS, Pascal
  17. Part: 11/32
  18.  
  19. -+-+-+-+-+-+-+-+ START OF PART 11 -+-+-+-+-+-+-+-+
  20. X`009real_user,`009`009`123 10 is real VMS username `125
  21. X`009spell_name`009`009`123 11 is spell's name `125
  22. X `009`009: `091global`093 namrec;
  23. X
  24. X`009anint   : `091global`093 intrec;  `123 info about game players `125
  25. X`009obj:      `091global`093 objectrec;
  26. X`009spell   : `091global`093 spellrec;
  27. X
  28. X`009block: `091global`093 descrec;    `123 a text block of descmax lines `12
  29. V5
  30. X`009indx: `091global`093 indexrec;    `123 an record allocation record `125
  31. X`009global: intrec;`009`009    `123 for global flags and values `125
  32. X`009read_global: `091global`093 boolean := TRUE; `123 global flags not in va
  33. Vlid `125
  34. X`009oneliner: `091global`093 linerec; `123 a line record `125
  35. X
  36. X`009heredsc: `091global`093 descrec;
  37. X
  38. X
  39. X    `123 Tiedostot : `125
  40. X
  41. X        headerfile: `091global`093 file of headerrec;`009    `123 tiedosto h
  42. Veader -tietueille    `125
  43. X`009roomfile :  `091global`093 file of room;
  44. X`009eventfile:  `091global`093 file of eventrec;
  45. X`009namfile:    `091global`093 file of namrec;
  46. X`009descfile:   `091global`093 file of descrec;
  47. X`009linefile:   `091global`093 file of linerec;
  48. X`009indexfile:  `091global`093 file of indexrec;
  49. X`009intfile:    `091global`093 file of intrec;
  50. X`009objfile:    `091global`093 file of objectrec;
  51. X`009spellfile:  `091global`093 file of spellrec;
  52. X
  53. X
  54. X`091global`093
  55. Xprocedure collision_wait;
  56. Xvar
  57. X`009wait_time: real;
  58. X
  59. Xbegin
  60. X`009wait_time := random;
  61. X`009if wait_time < 0.001 then
  62. X`009`009wait_time := 0.001;
  63. X`009wait(wait_time);
  64. Xend;
  65. X
  66. X
  67. X`123 increment err; if err is too high, suspect deadlock `125
  68. X`123 this is called by all getX procedures to ease deadlock checking `125
  69. X`091global`093
  70. Xprocedure deadcheck(var err: integer; s:string);
  71. X
  72. Xbegin
  73. X`009err := err + 1;
  74. X`009if err > maxerr then begin
  75. X`009`009writeln('%warning- ',s,' seems to be deadlocked; notify the Monster
  76. V Manager');
  77. X`009`009finish_guts;
  78. X`009`009halt;
  79. X`009`009err := 0;
  80. X`009end;
  81. Xend;
  82. X
  83. Xprocedure open_playing;
  84. Xbegin
  85. X    open(headerfile,root+'HEADER.MON',access_method := direct,
  86. X`009sharing := readwrite,
  87. X`009history := old,
  88. X    error := continue);
  89. X   `032
  90. X    open(roomfile,root+'ROOMS.MON',access_method := direct,
  91. X`009sharing := readwrite,
  92. X`009history := old,
  93. X`009error := continue);
  94. X
  95. X    open(namfile,root+'NAMS.MON',access_method := direct,
  96. X`009sharing := readwrite,
  97. X`009history := old,
  98. X`009error := continue);
  99. X
  100. X    open(eventfile,root+'EVENTS.MON',access_method := direct,
  101. X`009sharing := readwrite,
  102. X`009history := old,
  103. X`009error := continue);
  104. X
  105. X    open(descfile,root+'DESC.MON',access_method := direct,
  106. X`009sharing := readwrite,
  107. X`009history := old,
  108. X`009error := continue);
  109. X
  110. X    open(indexfile,root+'INDEX.MON',access_method := direct,
  111. X`009sharing := readwrite,
  112. X`009history := old,
  113. X`009error := continue);
  114. X
  115. X    open(linefile,root+'LINE.MON',access_method := direct,
  116. X`009sharing := readwrite,
  117. X`009history := old,
  118. X`009error := continue);
  119. X
  120. X    open(intfile,root+'INTFILE.MON',access_method := direct,
  121. X`009sharing := readwrite,
  122. X`009history := old,
  123. X`009error := continue);
  124. X
  125. X    open(objfile,root+'OBJECTS.MON',access_method := direct,
  126. X`009sharing := readwrite,
  127. X`009history := old,
  128. X`009error := continue);
  129. X
  130. X    open(spellfile,root+'SPELLS.MON',access_method := direct,
  131. X`009sharing := readwrite,
  132. X`009history := old,
  133. X`009error := continue);
  134. X
  135. Xend;
  136. X
  137. Xprocedure open_modify;
  138. Xbegin
  139. X    open(headerfile,root+'HEADER.MON',access_method := direct,
  140. X`009sharing := none,
  141. X`009history := unknown,
  142. X    error := continue);
  143. X   `032
  144. X    open(roomfile,root+'ROOMS.MON',access_method := direct,
  145. X`009sharing := none,
  146. X`009history := unknown,
  147. X`009error := continue);
  148. X
  149. X    open(namfile,root+'NAMS.MON',access_method := direct,
  150. X`009sharing := none,
  151. X`009history := unknown,
  152. X`009error := continue);
  153. X
  154. X    open(eventfile,root+'EVENTS.MON',access_method := direct,
  155. X`009sharing := none,
  156. X`009history := unknown,
  157. X`009error := continue);
  158. X
  159. X    open(descfile,root+'DESC.MON',access_method := direct,
  160. X`009sharing := none,
  161. X`009history := unknown,
  162. X`009error := continue);
  163. X
  164. X    open(indexfile,root+'INDEX.MON',access_method := direct,
  165. X`009sharing := none,
  166. X`009history := unknown,
  167. X`009error := continue);
  168. X
  169. X    open(linefile,root+'LINE.MON',access_method := direct,
  170. X`009sharing := none,
  171. X`009history := unknown,
  172. X`009error := continue);
  173. X
  174. X    open(intfile,root+'INTFILE.MON',access_method := direct,
  175. X`009sharing := none,
  176. X`009history := unknown,
  177. X`009error := continue);
  178. X
  179. X    open(objfile,root+'OBJECTS.MON',access_method := direct,
  180. X`009sharing := none,
  181. X`009history := unknown,
  182. X`009error := continue);
  183. X
  184. X    open(spellfile,root+'SPELLS.MON',access_method := direct,
  185. X`009sharing := none,
  186. X`009history := unknown,
  187. X`009error := continue);
  188. X
  189. Xend;
  190. X
  191. X
  192. X
  193. X`091global`093
  194. Xfunction open_database(playing : boolean := true): boolean;
  195. Xbegin
  196. X    if debug then writeln('%open_database:',playing);
  197. X
  198. X    if playing then open_playing
  199. X    else open_modify;
  200. X
  201. X    if ((status(roomfile)<>0) or
  202. X`009(status(namfile)<>0) or
  203. X`009(status(eventfile)<>0) or
  204. X`009(status(descfile)<>0) or
  205. X`009(status(indexfile)<>0) or
  206. X`009(status(intfile)<>0) or
  207. X`009(status(objfile)<>0) or
  208. X`009(status(spellfile)<>0) or
  209. X`009(status(headerfile)<>0) )
  210. X    then begin
  211. X`009if debug then writeln('%open_database: fail');
  212. X`009open_database :=false
  213. X    end else begin
  214. X`009if debug then writeln('%open_database: succeed');
  215. X`009open_database :=true
  216. X    end;
  217. X
  218. Xend;`009`123 open_database `125
  219. X
  220. X`091global`093 procedure close_database;
  221. Xbegin
  222. X    close(roomfile);
  223. X    close(namfile);
  224. X    close(eventfile);
  225. X    close(descfile);
  226. X    close(indexfile);
  227. X    close(intfile);
  228. X    close(objfile);
  229. X    close(spellfile);
  230. X    close(headerfile);
  231. Xend;
  232. X
  233. X`091global`093
  234. Xprocedure getheader(n: integer);
  235. Xvar
  236. X    err: integer;
  237. Xbegin
  238. X    headerfile`094.validate := 0;
  239. X    err := 0;
  240. X    if debug then
  241. X`009writeln('%getheader(',n:1,')');
  242. X    find(headerfile,n,error := continue);
  243. X    while status(headerfile) > 0 do begin
  244. X`009deadcheck(err,'getheader');
  245. X`009collision_wait;
  246. X`009find(headerfile,n,error := continue);
  247. X    end;
  248. X
  249. X    if headerfile`094.validate <> n then begin
  250. X`009writeln('%Fatal error in getheader');
  251. X`009writeln('%Wrong validate code');
  252. X`009writeln('%Record number = ',n:1);
  253. X`009writeln('%Validate code = ',headerfile`094.validate:1);
  254. X`009unlock (headerfile, error := continue);
  255. X`009halt;
  256. X    end;
  257. X
  258. X    header := headerfile`094;
  259. Xend;`009`123 getheader `125
  260. X
  261. X`091global`093
  262. Xprocedure putheader;
  263. Xbegin
  264. X    locate(headerfile,header.validate);
  265. X    headerfile`094 := header;
  266. X    put(headerfile);
  267. Xend; `123 putheader `125
  268. X
  269. X`091global`093
  270. Xprocedure freeheader;`009`123 unlock the record if you're not going to write
  271. V it `125
  272. Xbegin
  273. X    unlock(headerfile);
  274. Xend;
  275. X
  276. X`123 first procedure of form getX
  277. X  attempts to get given room record
  278. X  resolves record access conflicts, checks for deadlocks
  279. X  Locks record; use freeroom immediately after getroom if data is
  280. X  for read-only
  281. X`125
  282. X`091global`093
  283. Xprocedure getroom(n: integer:= 0);
  284. Xvar
  285. X    err: integer;
  286. Xbegin
  287. X    if n = 0 then
  288. X`009n := location;
  289. X    roomfile`094.valid := 0;
  290. X    err := 0;
  291. X    if debug then
  292. X`009    writeln('%getroom(',n:1,')');
  293. X    find(roomfile,n,error := continue);
  294. X    while status(roomfile) > 0 do begin
  295. X`009deadcheck(err,'getroom');
  296. X`009collision_wait;
  297. X`009find(roomfile,n,error := continue);
  298. X    end;
  299. X  `032
  300. X    if roomfile`094.valid <> n then begin
  301. X`009writeln('%Fatal error in getroom');
  302. X`009writeln('%Wrong validate code');
  303. X`009writeln('%Record number = ',n:1);
  304. X`009writeln('%Validate code = ',roomfile`094.valid:1);
  305. X`009unlock (roomfile, error := continue);
  306. X`009halt;
  307. X    end;
  308. X
  309. X    here := roomfile`094;
  310. X
  311. X    inmem := false;
  312. X`009`009`123 since this getroom could be doing anything, we will
  313. X`009`009  assume that it is bozoing the correct here record for
  314. X`009`009  this room.  If this getroom called by gethere, then
  315. X`009`009  gethere will correct inmem immediately.  Otherwise
  316. X`009`009  the next gethere will restore the correct here record. `125
  317. Xend;`009`123 getroom `125
  318. X
  319. X`091global`093
  320. Xprocedure putroom;
  321. Xbegin
  322. X    locate(roomfile,here.valid);
  323. X    roomfile`094 := here;
  324. X    put(roomfile);
  325. Xend;`009`123 putroom `125
  326. X
  327. X`091global`093
  328. Xprocedure freeroom;`009`123 unlock the record if you're not going to write i
  329. Vt `125
  330. Xbegin
  331. X    unlock(roomfile);
  332. Xend;
  333. X
  334. X`123 generic namfile handlic procedures: hurtta@finuh `125
  335. X
  336. Xprocedure get_namfile(reccode: integer; var rec: namrec);
  337. Xvar err: integer;
  338. Xbegin
  339. X    namfile`094.validate := 0;
  340. X    err := 0;`032
  341. X    find(namfile,reccode,error := continue);
  342. X    while status(namfile) > 0 do begin
  343. X`009deadcheck(err,'get_namfile');
  344. X`009collision_wait;
  345. X`009find(namfile,reccode,error := continue);
  346. X    end;
  347. X    if namfile`094.validate <> reccode then begin
  348. X`009writeln('%Fatal error in get_namfile');
  349. X`009writeln('%Wrong validate code');
  350. X`009writeln('%Record number = ',reccode:1);
  351. X`009writeln('%Validate code = ',namfile`094.validate:1);
  352. X`009unlock (namfile, error := continue);
  353. X`009halt;
  354. X    end;
  355. X    rec := namfile`094;
  356. Xend; `123 get_namfile `125
  357. X
  358. Xprocedure put_namfile(reccode: integer; rec: namrec);
  359. Xbegin
  360. X    if rec.validate <> reccode then begin
  361. X`009writeln('%Fatal error in put_namfile');
  362. X`009writeln('%Wrong validate code');
  363. X`009writeln('%Record number = ',reccode:1);
  364. X`009writeln('%Validate code = ',rec.validate:1);
  365. X`009unlock(namfile, error := continue);
  366. X`009halt;
  367. X    end;
  368. X    locate(namfile,reccode);
  369. X    namfile`094:= rec;
  370. X    put(namfile);
  371. Xend; `123 put_namfile `125
  372. X
  373. X`091global`093
  374. Xprocedure getown;
  375. Xbegin
  376. X    get_namfile(T_OWN,own);
  377. Xend; `123 getown `125
  378. X
  379. X`091global`093
  380. Xprocedure freeown;
  381. Xbegin
  382. X    unlock(namfile);
  383. Xend; `123 freeown `125
  384. X
  385. X`091global`093
  386. Xprocedure putown;
  387. Xbegin
  388. X    put_namfile(T_OWN,own);
  389. Xend; `123 putown `125
  390. X
  391. X
  392. X`091global`093
  393. Xprocedure getnam;   `123 rooms' name `125
  394. Xbegin
  395. X    get_namfile(T_NAM,nam);
  396. Xend; `123 getnam `125
  397. X
  398. X`091global`093
  399. Xprocedure freenam;
  400. Xbegin
  401. X    unlock(namfile);
  402. Xend; `123 freenam `125
  403. X
  404. X`091global`093
  405. Xprocedure putnam;
  406. Xbegin
  407. X    put_namfile(T_NAM,nam);
  408. Xend; `123 putnam `125
  409. X
  410. X`091global`093
  411. Xprocedure getobj(n: integer);
  412. Xvar
  413. X`009err: integer;
  414. X
  415. Xbegin
  416. X    if n = 0 then
  417. X`009n := location;
  418. X    objfile`094.objnum := 0;
  419. X    err := 0;
  420. X    find(objfile,n,error := continue);
  421. X    while status(objfile) > 0 do begin
  422. X`009deadcheck(err,'getobj');
  423. X`009collision_wait;
  424. X`009find(objfile,n,error := continue);
  425. X    end;
  426. X    if objfile`094.objnum <> n then begin
  427. X`009writeln('%Fatal error in getobj');
  428. X`009writeln('%Wrong validate code');
  429. X`009writeln('%Record number = ',n:1);
  430. X`009writeln('%Validate code = ',objfile`094.objnum:1);
  431. X`009unlock (objfile, error := continue);
  432. X`009halt;
  433. X    end;
  434. X
  435. X    obj := objfile`094;
  436. Xend;`009`123 getobj `125
  437. X
  438. X`091global`093
  439. Xprocedure putobj;
  440. Xbegin
  441. X    locate(objfile,obj.objnum);
  442. X    objfile`094 := obj;
  443. X    put(objfile);
  444. Xend;`009`123 putobj `125
  445. X
  446. X`091global`093
  447. Xprocedure freeobj;`009`123 unlock the record if you're not going to write it
  448. V `125
  449. Xbegin
  450. X    unlock(objfile);
  451. Xend;`009`123 freeobj `125
  452. X
  453. X
  454. X`091global`093
  455. Xprocedure getint(n: integer);
  456. Xvar
  457. X    err: integer;
  458. Xbegin
  459. X    intfile`094.intnum := 0;
  460. X    err := 0;
  461. X    find(intfile,n,error := continue);
  462. X    while status(intfile) > 0 do begin
  463. X`009deadcheck(err,'getint');
  464. X`009collision_wait;
  465. X`009find(intfile,n,error := continue);
  466. X    end;
  467. X
  468. X    if intfile`094.intnum <> n then begin
  469. X`009writeln('%Fatal error in getint');
  470. X`009writeln('%Wrong validate code');
  471. X`009writeln('%Record number = ',n:1);
  472. X`009writeln('%Validate code = ',intfile`094.intnum:1);
  473. X`009unlock (intfile, error := continue);
  474. X`009halt;
  475. X    end;
  476. X
  477. X    anint := intfile`094;
  478. Xend;`009`123 getint `125
  479. X
  480. X
  481. X`091global`093
  482. Xprocedure freeint;
  483. Xbegin
  484. X    unlock(intfile);
  485. Xend;`009`123 getint `125
  486. X
  487. X`091global`093
  488. Xprocedure putint;
  489. Xvar
  490. X    n: integer;
  491. Xbegin
  492. X    n := anint.intnum;
  493. X    locate(intfile,n);
  494. X    intfile`094:= anint;
  495. X    put(intfile);
  496. Xend;`009`123 putint `125
  497. X
  498. X
  499. X`091global`093
  500. Xprocedure getspell(n: integer := 0);
  501. Xvar
  502. X    err: integer;
  503. Xbegin
  504. X    if n = 0 then
  505. X`009n := mylog;
  506. X
  507. X    spellfile`094.recnum := 0;
  508. X    err := 0;
  509. X    find(spellfile,n,error := continue);
  510. X    while status(spellfile) > 0 do begin
  511. X`009deadcheck(err,'getspell');
  512. X`009collision_wait;
  513. X`009find(spellfile,n,error := continue);
  514. X    end;
  515. X   `032
  516. X    if spellfile`094.recnum <> n then begin
  517. X`009writeln('%Fatal error in getspell');
  518. X`009writeln('%Wrong validate code');
  519. X`009writeln('%Record number = ',n:1);
  520. X`009writeln('%Validate code = ',spellfile`094.recnum:1);
  521. X`009unlock (spellfile, error := continue);
  522. X`009halt;
  523. X    end;
  524. X
  525. X    spell := spellfile`094;
  526. Xend;`009`123 getspell `125
  527. X
  528. X`091global`093
  529. Xprocedure freespell;
  530. Xbegin
  531. X    unlock(spellfile);
  532. Xend;`009`123 freespell `125
  533. X
  534. X`091global`093
  535. Xprocedure putspell;
  536. Xvar
  537. X    n: integer;
  538. Xbegin
  539. X    n := spell.recnum;
  540. X    locate(spellfile,n);
  541. X    spellfile`094:= spell;
  542. X    put(spellfile);
  543. Xend;`009`123 putspell `125
  544. X
  545. X
  546. X`091global`093
  547. Xprocedure getuser;`009`123 get log rec with everyone's userids in it `125
  548. Xbegin
  549. X    get_namfile(T_USER,user);
  550. Xend;`009`123 getuser `125
  551. X
  552. X`091global`093
  553. Xprocedure freeuser;
  554. Xbegin
  555. X    unlock(namfile);
  556. Xend;`009`123 freeuser `125
  557. X
  558. X`091global`093
  559. Xprocedure putuser;
  560. Xbegin
  561. X    put_namfile(T_USER,user);
  562. Xend;`009`123 putuser `125
  563. X
  564. X`091global`093
  565. Xprocedure getpasswd;`009`123 get log rec with everyone's password in it `125
  566. Xbegin
  567. X    get_namfile(T_PASSWD,passwd);
  568. Xend;`009`123 getpasswd `125
  569. X
  570. X`091global`093
  571. Xprocedure freepasswd;
  572. Xbegin
  573. X    unlock(namfile);
  574. Xend;`009`123 freepasswd `125
  575. X
  576. X`091global`093
  577. Xprocedure putpasswd;
  578. Xbegin
  579. X    put_namfile(T_PASSWD,passwd);
  580. Xend;`009`123 putpasswd `125
  581. X
  582. X
  583. X`091global`093
  584. Xprocedure getreal_user;`009`123 get log rec with everyone's userids in it `1
  585. V25
  586. Xbegin
  587. X    get_namfile(T_REAL_USER,real_user);
  588. Xend;`009`123 getreal_user `125
  589. X
  590. X`091global`093
  591. Xprocedure freereal_user;
  592. Xbegin
  593. X    unlock(namfile);
  594. Xend;`009`123 freereal_user `125
  595. X
  596. X`091global`093
  597. Xprocedure putreal_user;
  598. Xbegin
  599. X    put_namfile(T_REAL_USER,real_user);
  600. Xend;`009`123 putreal_user `125
  601. X
  602. X`091global`093
  603. Xprocedure getspell_name;`009`123 get spell name rec `125
  604. Xbegin
  605. X    get_namfile(T_SPELL_NAME,spell_name);
  606. Xend;`009`123 getspell_name `125
  607. X
  608. X`091global`093
  609. Xprocedure freespell_name;
  610. Xbegin
  611. X    unlock(namfile);
  612. Xend;`009`123 freespell_name `125
  613. X
  614. X`091global`093
  615. Xprocedure putspell_name;
  616. Xbegin
  617. X    put_namfile(T_SPELL_NAME,spell_name);
  618. Xend;`009`123 putspell_name `125
  619. X
  620. X
  621. X`091global`093
  622. Xprocedure getdate;`009`123 get log rec with date of last play in it `125
  623. Xbegin
  624. X    get_namfile(T_DATE,adate);
  625. Xend;`009`123 getdate `125
  626. X
  627. X`091global`093
  628. Xprocedure freedate;
  629. Xbegin
  630. X    unlock(namfile);
  631. Xend;`009`123 freedate `125
  632. X
  633. X`091global`093
  634. Xprocedure putdate;
  635. Xbegin
  636. X    put_namfile(T_DATE,adate);
  637. Xend;`009`123 freedate `125
  638. X
  639. X`091global`093
  640. Xprocedure gettime;`009`123 get log rec with time of last play in it `125
  641. Xbegin
  642. X    get_namfile(T_TIME,atime);
  643. Xend;`009`123 gettime `125
  644. X
  645. X`091global`093
  646. Xprocedure freetime;
  647. Xbegin
  648. X    unlock(namfile);
  649. Xend;`009`123 freetime `125
  650. X
  651. X`091global`093
  652. Xprocedure puttime;
  653. Xbegin
  654. X    put_namfile(T_TIME,atime);
  655. Xend;`009`123 puttime `125
  656. X
  657. X`091global`093
  658. Xprocedure getobjnam;
  659. Xbegin
  660. X    get_namfile(T_OBJNAM,objnam);
  661. Xend;`009`123 getobjnam `125
  662. X
  663. X`091global`093
  664. Xprocedure freeobjnam;
  665. Xbegin
  666. X    unlock(namfile);
  667. Xend;`009`123 freeobjnam `125
  668. X
  669. X`091global`093
  670. Xprocedure putobjnam;
  671. Xbegin
  672. X    put_namfile(T_OBJNAM,objnam);
  673. Xend;`009`123 putobjnam `125
  674. X
  675. X`091global`093
  676. Xprocedure getobjown;
  677. Xbegin
  678. X    get_namfile(T_OBJOWN,objown);
  679. Xend;`009`123 getobjown `125
  680. X
  681. X`091global`093
  682. Xprocedure freeobjown;
  683. Xbegin
  684. X    unlock(namfile);
  685. Xend;`009`123 freeobjown `125
  686. X
  687. X`091global`093
  688. Xprocedure putobjown;
  689. Xbegin
  690. X    put_namfile(T_OBJOWN,objown);
  691. Xend;`009`123 putobjown `125
  692. X
  693. X`091global`093
  694. Xprocedure getpers;`009`123 get log rec with everyone's pers names in it `125
  695. Xbegin
  696. X    get_namfile(T_PERS,pers);
  697. Xend;`009`123 getpers `125
  698. X
  699. X`091global`093
  700. Xprocedure freepers;
  701. Xbegin
  702. X    unlock(namfile);
  703. Xend;`009`123 freepers `125
  704. X
  705. X`091global`093
  706. Xprocedure putpers;
  707. Xbegin
  708. X    put_namfile(T_PERS,pers);
  709. Xend;`009`123 putpers `125
  710. X
  711. X`091global`093
  712. Xprocedure getevent(n: integer := 0);
  713. Xvar
  714. X    err: integer;
  715. Xbegin
  716. X    if n = 0 then
  717. X`009    n := location;
  718. X
  719. X    n := (n mod numevnts) + 1;
  720. X
  721. X    eventfile`094.validat := 0;
  722. X    err := 0;
  723. X    find(eventfile,n,error := continue);
  724. X    while status(eventfile) > 0 do begin
  725. X`009deadcheck(err,'getevent');
  726. X`009collision_wait;
  727. X`009find(eventfile,n,error := continue);
  728. X    end;
  729. X
  730. X    if eventfile`094.validat <> n then begin
  731. X`009writeln('%Fatal error in getevent');
  732. X`009writeln('%Wrong validate code');
  733. X`009writeln('%Record number = ',n:1);
  734. X`009writeln('%Validate code = ',eventfile`094.validat:1);
  735. X`009unlock (eventfile, error := continue);
  736. X`009halt;
  737. X    end;
  738. X
  739. X    event := eventfile`094;
  740. Xend;`009`123 getevent `125
  741. X
  742. X`091global`093
  743. Xprocedure freeevent;
  744. Xbegin
  745. X    unlock(eventfile);
  746. Xend;`009`123 freeevent `125
  747. X
  748. X`091global`093
  749. Xprocedure putevent;
  750. Xbegin
  751. X    locate(eventfile,event.validat);
  752. X    eventfile`094:= event;
  753. X    put(eventfile);
  754. Xend;`009`123 putevent `125
  755. X
  756. X`091global`093
  757. Xprocedure getblock(n: integer);
  758. Xvar
  759. X    err: integer;
  760. Xbegin
  761. X    if debug then
  762. X`009writeln('%getblock: ',n:1);
  763. X    descfile`094.descrinum := 0;
  764. X    err := 0;
  765. X    find(descfile,n,error := continue);
  766. X    while status(descfile) > 0 do begin
  767. X`009deadcheck(err,'getblock');
  768. X`009collision_wait;
  769. X`009find(descfile,n,error := continue);
  770. X    end;
  771. X
  772. X    if descfile`094.descrinum <> n then begin
  773. X`009writeln('%Fatal error in getblock');
  774. X`009writeln('%Wrong validate code');
  775. X`009writeln('%Record number = ',n:1);
  776. X`009writeln('%Validate code = ',descfile`094.descrinum:1);
  777. X`009unlock (descfile, error := continue);
  778. X`009halt;
  779. X    end;
  780. X
  781. X    block := descfile`094;
  782. Xend;`009`123 getblock `125
  783. X
  784. X`091global`093
  785. Xprocedure putblock;
  786. Xvar
  787. X    n: integer;
  788. Xbegin
  789. X    n := block.descrinum;
  790. X    if debug then
  791. X`009writeln('%putblock: ',n:1);
  792. X    if n <> 0 then begin
  793. X`009locate(descfile,n);
  794. X`009descfile`094 := block;
  795. X`009put(descfile);
  796. X    end;
  797. Xend;`009`123 putblock `125
  798. X
  799. X`091global`093
  800. Xprocedure freeblock;`009`123 unlock the record if you're not going to write
  801. V it `125
  802. Xbegin
  803. X    unlock(descfile);
  804. Xend;`009`123 freeblock `125
  805. X
  806. X
  807. X`091global`093
  808. Xprocedure getline(n: integer);
  809. Xvar
  810. X    err: integer;
  811. Xbegin
  812. X    if n = -1 then begin
  813. X`009oneliner.theline := '';
  814. X    end else begin
  815. X`009err := 0;
  816. X`009linefile`094.linenum := 0;
  817. X`009find(linefile,n,error := continue);
  818. X`009while status (linefile) > 0 do begin
  819. X`009    deadcheck(err,'getline');
  820. X`009    collision_wait;
  821. X`009    find(linefile,n,error := continue);
  822. X`009end;
  823. X
  824. X`009if linefile`094.linenum <> n then begin
  825. X`009    writeln('%Fatal error in getline');
  826. X`009    writeln('%Wrong validate code');
  827. X`009    writeln('%Record number = ',n:1);
  828. X`009    writeln('%Validate code = ',linefile`094.linenum:1);
  829. X`009    unlock (descfile, error := continue);
  830. X`009    halt;
  831. X`009end;
  832. X
  833. X`009oneliner := linefile`094;
  834. X    end;
  835. Xend;`009`123 getline `125
  836. X
  837. X`091global`093
  838. Xprocedure putline;
  839. Xbegin
  840. X    if oneliner.linenum > 0 then begin
  841. X`009locate(linefile,oneliner.linenum);
  842. X`009linefile`094 := oneliner;
  843. X`009put(linefile);
  844. X    end;
  845. Xend;`009`123 putline `125
  846. X
  847. X`091global`093
  848. Xprocedure freeline;`009`123 unlock the record if you're not going to write i
  849. Vt `125
  850. Xbegin
  851. X    unlock(linefile);
  852. Xend;`009`123 freeline `125
  853. X
  854. X`123
  855. XIndex record 1 -- Description blocks that are free
  856. XIndex record 2 -- One liners that are free
  857. X`125
  858. X
  859. X`091global`093
  860. Xprocedure getindex(n: integer);
  861. Xvar
  862. X    err: integer;
  863. Xbegin
  864. X    indexfile`094.indexnum := 0;
  865. X    err := 0;
  866. X    find(indexfile,n,error := continue);
  867. X    while status(indexfile) > 0 do begin
  868. X`009deadcheck(err,'getindex');
  869. X`009collision_wait;
  870. X`009find(indexfile,n,error := continue);
  871. X    end;
  872. X
  873. X    if indexfile`094.indexnum <> n then begin
  874. X`009writeln('%Fatal error in getindex');
  875. X`009writeln('%Wrong validate code');
  876. X`009writeln('%Record number = ',n:1);
  877. X`009writeln('%Validate code = ',indexfile`094.indexnum:1);
  878. X`009unlock (indexfile, error := continue);
  879. X`009halt;
  880. X    end;
  881. X
  882. X    indx := indexfile`094;
  883. Xend;`009`123 getindex `125
  884. X
  885. X`091global`093
  886. Xprocedure putindex;
  887. Xbegin
  888. X    locate(indexfile,indx.indexnum);
  889. X    indexfile`094 := indx;
  890. X    put(indexfile);
  891. Xend;`009`123 putindex `125
  892. X
  893. X`091global`093
  894. Xprocedure freeindex;`009`123 unlock the record if you're not going to write
  895. V it `125
  896. Xbegin
  897. X    unlock(indexfile);
  898. Xend;`009`123 freeindex `125
  899. X
  900. Xprocedure getglobal;
  901. Xvar
  902. X    err: integer;
  903. Xbegin
  904. X    intfile`094.intnum := 0;
  905. X    err := 0;
  906. X    find(intfile,N_GLOBAL,error := continue);
  907. X    while status(intfile) > 0 do begin
  908. X`009deadcheck(err,'getglobal');
  909. X`009collision_wait;
  910. X`009find(intfile,N_GLOBAL,error := continue);
  911. X    end;
  912. X
  913. X    if intfile`094.intnum <> N_GLOBAL then begin
  914. X`009writeln('%Fatal error in getglobal');
  915. X`009writeln('%Wrong validate code');
  916. X`009writeln('%Record number = ',N_GLOBAL:1);
  917. X`009writeln('%Validate code = ',intfile`094.intnum:1);
  918. X`009unlock (intfile, error := continue);
  919. X`009halt;
  920. X    end;
  921. X
  922. X    global := intfile`094;
  923. Xend;`009`123 getglobal `125
  924. X
  925. Xprocedure putglobal;
  926. Xbegin
  927. X    locate(intfile,global.intnum);
  928. X    intfile`094 := global;
  929. X    put(intfile);
  930. Xend;`009`123 putglobal `125
  931. X
  932. Xprocedure freeglobal;
  933. Xbegin`032
  934. X    unlock(intfile);
  935. Xend;`009`123 freeglobal `125
  936. X
  937. X`091global`093
  938. Xprocedure log_event(`009send: integer := 0;`009`123 slot of sender `125
  939. X`009`009`009act:integer;`009`009`123 what event occurred `125
  940. X`009`009`009targ: integer := 0;`009`123 target of event `125
  941. X`009`009`009p: integer := 0;`009`123 expansion parameter `125
  942. X`009`009`009s: string := '';`009`123 string for messages `125
  943. X`009`009`009room: integer := 0`009`123 room to log event in `125
  944. X`009`009   );
  945. X
  946. Xbegin
  947. X`009if room = 0 then
  948. X`009`009room := location;
  949. X`009getevent(room);
  950. X`009event.point := event.point + 1;
  951. X`009if debug then
  952. X`009`009writeln('%logging event ',act:1,' to point ',event.point:1);
  953. X`009if event.point > maxevent then
  954. X`009`009event.point := 1;
  955. X`009with event.evnt`091event.point`093 do begin
  956. X`009`009sender := send;
  957. X`009`009action := act;
  958. X`009`009target := targ;
  959. X`009`009parm := p;
  960. X`009`009msg := s;
  961. X`009`009loc := room;
  962. X`009end;
  963. X`009putevent;
  964. Xend; `123 log_event `125
  965. X
  966. X
  967. X`091global`093
  968. Xfunction read_global_flag (flag: integer; force_read: boolean := false): boo
  969. Vlean;
  970. Xbegin
  971. X    if Gf_Types `091 flag`093 <> G_Flag then begin
  972. X`009writeln('%Error in function read_global_flag:');
  973. X        writeln('%Global value #',flag:1,' isn''t boolean flag.');
  974. X`009writeln('%Notify Monster Manager.');
  975. X    end;
  976. X    if read_global or force_read then begin
  977. X`009getglobal;
  978. X`009freeglobal;
  979. X`009read_global := false;
  980. X    end;
  981. X    read_global_flag := global.int`091 flag `093>0;
  982. Xend; `123 read_global-flag `125
  983. X
  984. X`091global`093
  985. Xprocedure set_global_flag (flag: integer; value: boolean;
  986. X`009`009`009    message: string := '');
  987. Xvar lcv: integer;
  988. Xbegin
  989. X    if Gf_Types `091 flag`093 <> G_Flag then begin
  990. X`009writeln('%Error in function set_global_flag:');
  991. X        writeln('%Global value #',flag:1,' isn''t boolean flag.');
  992. X`009writeln('%Notify Monster Manager.');
  993. X    end else begin
  994. X
  995. X`009getglobal;
  996. X`009if value then global.int`091flag`093 := 1
  997. X`009else global.int`091flag`093 := 0;
  998. X`009putglobal;
  999. X`009read_global := false;
  1000. X  `032
  1001. X`009for lcv :=1 to numevnts do
  1002. X          log_event(0,E_GLOBAL_CHANGE,0,0,message,lcv);
  1003. X
  1004. X    end;
  1005. Xend; `123 set_global_flag `125
  1006. X
  1007. X
  1008. X`091global`093
  1009. Xfunction view_global_value (flag: integer; force_read: boolean := false):`03
  1010. V2
  1011. X`009string;
  1012. Xbegin
  1013. X   `032
  1014. X   if read_global or force_read then begin
  1015. X`009getglobal;
  1016. X`009freeglobal;
  1017. X`009read_global := false;
  1018. X    end;
  1019. X
  1020. X    case Gf_Types `091 flag`093 of`032
  1021. X`009G_Flag: begin
  1022. X`009    if global.int `091flag`093 > 0 then
  1023. X`009`009view_global_value := 'Boolean: TRUE'
  1024. X`009    else view_global_value := 'Boolean: FALSE'
  1025. X`009end;
  1026. X`009G_Int: begin
  1027. X`009    if global.int `091flag`093 = 0 then
  1028. X`009`009view_global_value := 'Integer: Zero'
  1029. X`009    else view_global_value := 'Integer: NonZero'
  1030. X`009end;
  1031. X`009G_Text: begin
  1032. X`009    if global.int `091flag`093 > 0 then
  1033. X`009`009view_global_value := 'Description: Block'
  1034. X`009    else if global.int `091flag`093 < 0 then
  1035. X`009`009view_global_value := 'Desription: Line'
  1036. X`009    else view_global_value := 'Description: None'
  1037. X`009end;
  1038. X`009G_Code: begin
  1039. X`009    if global.int `091flag`093 > 0 then
  1040. X`009`009view_global_value := 'Clobal Code: Exist'
  1041. X`009    else view_global_value := 'Clobal Code: None'
  1042. X`009end;
  1043. X        otherwise view_global_value := 'Unknown';
  1044. X`032
  1045. X    end;
  1046. Xend; `123 view_global_value `125
  1047. X
  1048. X
  1049. X`091global`093
  1050. Xfunction alloc_general(class: integer;`032
  1051. X`009`009`009var n: integer):boolean; `123 hurtta@finuh `125
  1052. Xvar
  1053. X`009found: boolean;
  1054. X
  1055. Xbegin
  1056. X`009getindex(class);
  1057. X`009if indx.inuse = indx.top then begin
  1058. X`009`009freeindex;
  1059. X`009`009n := 0;
  1060. X`009`009alloc_general := false
  1061. X`009end else begin
  1062. X`009`009n := 1;
  1063. X`009`009found := false;
  1064. X`009`009while (not found) and (n <= indx.top) do begin
  1065. X`009`009`009if indx.free`091n`093 then
  1066. X`009`009`009`009found := true
  1067. X`009`009`009else
  1068. X`009`009`009`009n := n + 1;
  1069. X`009`009end;
  1070. X`009`009if found then begin
  1071. X`009`009`009indx.free`091n`093 := false;
  1072. X`009`009`009alloc_general := true;
  1073. X`009`009`009indx.inuse := indx.inuse + 1;
  1074. X`009`009`009putindex;
  1075. X`009`009end else begin
  1076. X`009`009`009freeindex;
  1077. X`009`009       `009writeln('%serious error in alloc_general; notify Monster
  1078. V Manager');
  1079. X`009`009`009alloc_general := false;
  1080. X`009`009end;
  1081. X`009end;
  1082. Xend;                             `032
  1083. X
  1084. X`091global`093
  1085. Xprocedure delete_general(class: integer; var n: integer); `123 hurtta@finuh
  1086. V `125
  1087. X
  1088. Xbegin
  1089. X`009if n <> 0 then begin
  1090. X`009`009getindex(class);
  1091. X`009`009indx.inuse := indx.inuse - 1;
  1092. X`009`009indx.free`091n`093 := true;
  1093. X`009`009putindex;
  1094. X                n := 0;
  1095. X`009end;
  1096. Xend;
  1097. X
  1098. X
  1099. X`091global`093
  1100. Xfunction level(score: integer): integer;
  1101. Xvar i : integer;
  1102. Xbegin
  1103. X  level := 1;
  1104. X  for i := 1 to levels do if leveltable`091i`093.exp <= score then
  1105. X     level := i;
  1106. Xend; `123 level `125
  1107. X
  1108. X`091global`093
  1109. Xprocedure command_help(command: shortstring);
  1110. Xvar fd: text;
  1111. X    line: string;
  1112. X    found: boolean;
  1113. X    count: integer;
  1114. X
  1115. X    procedure leave;
  1116. X    begin
  1117. X`009writeln('EXIT');
  1118. X`009line := '-';
  1119. X    end;
  1120. X
  1121. Xbegin
  1122. X    open(fd,root+'monster.help',readonly,error:=continue);
  1123. X    if status(fd) > 0 then begin
  1124. X`009writeln('Can''t open monster.help. Notify Monster Manager');
  1125. X    end else begin
  1126. X`009found := false;
  1127. X`009reset(fd);
  1128. X`009while not eof(fd) and not found do begin
  1129. X`009    readln(fd,line);
  1130. X`009    if line = ':'+command then found := true
  1131. X`009end;
  1132. X`009
  1133. X`009if not found then
  1134. X`009    writeln ('No entry for ''',command,'''.');
  1135. X`009   `032
  1136. X`009count := 0;
  1137. X`009while not eof(fd) and found do begin
  1138. X`009    readln(fd,line);
  1139. X`009    if line > '' then begin
  1140. X`009`009if line`0911`093 = ':' then found := false
  1141. X`009`009else writeln(line);
  1142. X`009    end else writeln;
  1143. X`009    count := count + 1;
  1144. X`009    if count > terminal_page_len-2 then begin
  1145. X`009`009count := 0;
  1146. X`009`009grab_line('-more-',line,erase := true,eof_handler := leave);
  1147. X`009`009if line > '' then found := false;
  1148. X`009    end;
  1149. X`009end;
  1150. X`009close(fd);
  1151. X    end;
  1152. Xend; `123 command_help `125
  1153. X
  1154. X`091global`093
  1155. Xprocedure add_counter(rec: integer; player: integer; n: integer := 1);
  1156. Xbegin
  1157. X    getint(rec);
  1158. X    anint.int`091player`093 := anint.int`091player`093 +n;
  1159. X    putint;  `032
  1160. Xend;
  1161. X
  1162. X`091global`093
  1163. Xprocedure sub_counter(rec: integer; player: integer; n: integer := 1);
  1164. Xbegin
  1165. X    getint(rec);
  1166. X    anint.int`091player`093 := anint.int`091player`093 -n;
  1167. X    putint;  `032
  1168. Xend;
  1169. X
  1170. X`091global`093
  1171. Xfunction get_counter(rec: integer; player: integer): integer;
  1172. Xbegin
  1173. X    getint(rec);
  1174. X    freeint;
  1175. X    get_counter := anint.int`091player`093;
  1176. Xend;
  1177. X
  1178. X`091global`093`032
  1179. Xprocedure change_owner(source,target: integer);
  1180. Xvar i: integer;
  1181. X    acp: integer;
  1182. Xbegin
  1183. X
  1184. X    acp := 0;
  1185. X    for i := 1 to maxexit do
  1186. X`009if here.exits`091i`093.kind = 5 then acp := acp +1;
  1187. X
  1188. X    if source > 0 then begin
  1189. X`009sub_counter(N_NUMROOMS,source);
  1190. X`009sub_counter(N_ACCEPT,source,acp);
  1191. X    end ;
  1192. X
  1193. X    if target > 0 then begin
  1194. X`009add_counter(N_NUMROOMS,target);
  1195. X`009add_counter(N_ACCEPT,target,acp);
  1196. X    end;
  1197. Xend; `123 change_owner `125
  1198. X
  1199. X`123 for /REBUILD and /BUILD `125
  1200. X
  1201. X`091global`093
  1202. Xprocedure addrooms(n: integer);
  1203. Xvar`009i: integer;
  1204. Xbegin
  1205. X`009getindex(I_ROOM);
  1206. X`009if indx.top + n > maxroom then begin `123 maxroom limits all kind names
  1207. V `125
  1208. X`009    writeln('Number for identifiers limited to ',maxroom:1,'.');
  1209. X`009    writeln('Can''t add ',n:1,' rooms.');
  1210. X`009    n := maxroom - indx.top;
  1211. X`009    writeln('Adding only ',n:1,' rooms.');
  1212. X`009end;
  1213. X
  1214. X`009if indx.top + n > maxindex then begin `123 maxindex limits all kind bloc
  1215. Vks `125
  1216. X`009    writeln('Number for blocks limited to ',maxindex:1,'.');
  1217. X`009    writeln('Can''t add ',n:1,' rooms.');
  1218. X`009    n := maxindex - indx.top;
  1219. X`009    writeln('Adding only ',n:1,' rooms.');
  1220. X`009end;
  1221. X
  1222. X`009for i := indx.top+1 to indx.top+n do begin
  1223. X`009`009locate(roomfile,i);
  1224. X`009`009roomfile`094.valid := i;
  1225. X`009`009roomfile`094.locnum := i;
  1226. X`009`009roomfile`094.primary := 0;
  1227. X`009`009roomfile`094.secondary := 0;
  1228. X`009`009roomfile`094.which := 0;
  1229. X`009`009put(roomfile);
  1230. X`009end;
  1231. X`009indx.top := indx.top + n;
  1232. X`009putindex;
  1233. Xend;
  1234. X
  1235. X`091global`093
  1236. Xprocedure addints(n: integer);
  1237. Xvar`009i: integer;
  1238. Xbegin
  1239. X`009getindex(I_INT);
  1240. X`009if indx.top + n > maxindex then begin `123 maxindex limits all kind bloc
  1241. Vks `125
  1242. X`009    writeln('Number for blocks limited to ',maxindex:1,'.');
  1243. X`009    writeln('Can''t add ',n:1,' integertables.');
  1244. X`009    n := maxindex - indx.top;
  1245. X`009    writeln('Adding only ',n:1,' integertables.');
  1246. X`009end;
  1247. X`009for i := indx.top+1 to indx.top+n do begin
  1248. X`009`009locate(intfile,i);
  1249. X`009`009intfile`094.intnum := i;
  1250. X`009`009put(intfile);
  1251. X`009end;
  1252. X`009indx.top := indx.top + n;
  1253. X`009putindex;
  1254. Xend;
  1255. X
  1256. X`091global`093
  1257. Xprocedure addlines(n: integer);
  1258. Xvar`009i: integer;
  1259. Xbegin
  1260. X`009getindex(I_LINE);
  1261. X`009if indx.top + n > maxindex then begin `123 maxindex limits all kind bloc
  1262. Vks `125
  1263. X`009    writeln('Number for blocks limited to ',maxindex:1,'.');
  1264. X`009    writeln('Can''t add ',n:1,' line descriptions.');
  1265. X`009    n := maxindex - indx.top;
  1266. X`009    writeln('Adding only ',n:1,' line descriptions.');
  1267. X`009end;
  1268. X`009for i := indx.top+1 to indx.top+n do begin
  1269. X`009`009locate(linefile,i);
  1270. X`009`009linefile`094.linenum := i;
  1271. X`009`009put(linefile);
  1272. X`009end;
  1273. X`009indx.top := indx.top + n;
  1274. X`009putindex;
  1275. Xend;
  1276. X
  1277. X`091global`093
  1278. Xprocedure addblocks(n: integer);
  1279. Xvar`009i: integer;
  1280. Xbegin
  1281. X`009getindex(I_BLOCK);
  1282. X`009if indx.top + n > maxindex then begin `123 maxindex limits all kind bloc
  1283. Vks `125
  1284. X`009    writeln('Number for blocks limited to ',maxindex:1,'.');
  1285. X`009    writeln('Can''t add ',n:1,' block descriptions.');
  1286. X`009    n := maxindex - indx.top;
  1287. X`009    writeln('Adding only ',n:1,' block descriptions.');
  1288. X`009end;
  1289. X`009for i := indx.top+1 to indx.top+n do begin
  1290. X`009`009locate(descfile,i);
  1291. X`009`009descfile`094.descrinum := i;
  1292. X`009`009put(descfile);
  1293. X`009end;
  1294. X`009indx.top := indx.top + n;
  1295. X`009putindex;
  1296. Xend;
  1297. X
  1298. X`091global`093
  1299. Xprocedure addobjects(n: integer);
  1300. Xvar`009i: integer;
  1301. Xbegin
  1302. X`009getindex(I_OBJECT);
  1303. X`009if indx.top + n > maxroom then begin `123 maxroom limits all kind names
  1304. V `125
  1305. X`009    writeln('Number for identifiers limited to ',maxroom:1,'.');
  1306. X`009    writeln('Can''t add ',n:1,' objects.');
  1307. X`009    n := maxroom - indx.top;
  1308. X`009    writeln('Adding only ',n:1,' objects.');
  1309. X`009end;
  1310. X`009if indx.top + n > maxindex then begin `123 maxindex limits all kind bloc
  1311. Vks `125
  1312. X`009    writeln('Number for blocks limited to ',maxindex:1,'.');
  1313. X`009    writeln('Can''t add ',n:1,' objects.');
  1314. X`009    n := maxindex - indx.top;
  1315. X`009    writeln('Adding only ',n:1,' objects.');
  1316. X`009end;
  1317. X`009for i := indx.top+1 to indx.top+n do begin
  1318. X`009`009locate(objfile,i);
  1319. X`009`009objfile`094.objnum := i;
  1320. X`009`009put(objfile);
  1321. X`009end;
  1322. X`009indx.top := indx.top + n;
  1323. X`009putindex;
  1324. Xend;
  1325. X
  1326. X`091global`093
  1327. Xfunction file_name(code: integer): mega_string;
  1328. Xvar apu: mega_string;
  1329. Xbegin
  1330. X  writev(apu,coderoot,'CODE',code:1,'.MON');
  1331. X  file_name := apu
  1332. Xend; `123 file_name `125
  1333. X
  1334. X
  1335. X`091global`093 `032
  1336. Xprocedure addheaders(amount: integer);
  1337. Xvar i: integer;
  1338. X    fl: text;
  1339. Xbegin                   `032
  1340. X   getindex(I_HEADER);
  1341. X    if indx.top + amount > maxindex then begin `123 maxindex limits all kind
  1342. V blocks `125
  1343. X`009writeln('Number for blocks limited to ',maxindex:1,'.');
  1344. X`009writeln('Can''t add ',amount:1,' MDL headers.');
  1345. X`009amount := maxindex - indx.top;
  1346. X`009writeln('Adding only ',amount:1,' MDL headers.');
  1347. X    end;
  1348. X   for i := indx.top +1 to indx.top + amount  do begin
  1349. X      indx.free`091i`093 := true; `032
  1350. X
  1351. X      locate(headerfile,i);
  1352. X      headerfile`094.validate := i;
  1353. X      put(headerfile);            `032
  1354. X                               `032
  1355. X      open(fl,file_name(i),new, record_length := mega_length +20);
  1356. X      rewrite(fl);
  1357. X      close(fl)                `032
  1358. X   end;                        `032
  1359. X
  1360. X   indx.top := indx.top + amount;
  1361. X   putindex;                   `032
  1362. Xend;
  1363. X
  1364. Xend. `123 enf of module `125
  1365. $ CALL UNPACK DATABASE.PAS;51 2064428185
  1366. $ create/nolog 'f'
  1367. X! DOG.MDL by Kari Hurtta
  1368. X
  1369. X- LABEL state tail(string tail(get state()))
  1370. X
  1371. X- LABEL state head(string head(get state()))
  1372. X
  1373. X- LABEL leave(if(=(player name,GOSUB state tail()),
  1374. X`009`009 if (=("follow",GOSUB state head()),
  1375. X`009`009     GOSUB follow(GOSUB state tail()),
  1376. X`009`009     if (=("keep",GOSUB state head()),
  1377. X`009`009         GOSUB keep it(GOSUB state tail())
  1378. X                        )
  1379. X                    )
  1380. X                )
  1381. X`009     )
  1382. X
  1383. X- LABEL say(if(privilege(player name,"wizard, manager"),
  1384. X               GOSUB check(strip(speech))))
  1385. X
  1386. X- LABEL check(if(=(string head(p1),"dog"),
  1387. X                 GOSUB check2(string tail(p1))
  1388. X                )
  1389. X             )
  1390. X
  1391. X
  1392. X- LABEL check2(GOSUB case(string head(p1),string tail(p1)))
  1393. X
  1394. X- LABEL case(if(=(p1,"bite"),
  1395. X                GOSUB bite(p2),
  1396. X`009`009if(=(p1,"follow"),
  1397. X                    GOSUB set(p2),
  1398. X                    GOSUB case2(p1,p2)
  1399. X                  )
  1400. X               )
  1401. X            )
  1402. X
  1403. X- LABEL case2(if(=(p1,"go"),
  1404. X                 GOSUB go to(p2),
  1405. X`009`009 if(=(p1,"home"),
  1406. X                    GOSUB home(),
  1407. X`009`009    GOSUB case3(p1,p2)
  1408. X                   )
  1409. X                )
  1410. X             )
  1411. X
  1412. X- LABEL case3(if(=(p1,"stay"),
  1413. X                 GOSUB stay(p2),
  1414. X                 if(=(p1,"keep"),
  1415. X                    GOSUB keep(p2)
  1416. X                   )
  1417. X                )
  1418. X             )
  1419. X
  1420. X
  1421. X- LABEL bite(if(lookup player(p1),
  1422. X                SUBMIT attack("0",lookup player(p1))
  1423. X               )
  1424. X            )
  1425. X
  1426. X- LABEL attack(GOSUB bite it("7"))
  1427. X
  1428. X
  1429. X- LABEL bite it(if(=(where(player name),where(monster name)),
  1430. X                   if(attack(p1),
  1431. X                      null(pprint("Dog bites you."),
  1432. X`009                   oprint(+("Dog bites ",player name)),
  1433. X`009`009`009   if(=(where(player name),"void"),
  1434. X                              null(oprint(+("Dog eats ",player name)),
  1435. X                                   GOSUB jump(where(GOSUB state tail()))
  1436. X                                  )
  1437. X                             )
  1438. X`009                  ),
  1439. X                      GOSUB jump(where(GOSUB state tail()))
  1440. X                     ),
  1441. X                   null(GOSUB jump(where(player name)),
  1442. X                        SUBMIT attack("5",player name)
  1443. X                       )
  1444. X                  )
  1445. X               )
  1446. X
  1447. X- LABEL`009follow(if(target,
  1448. X`009`009  null(pprint("Dog follows you."),
  1449. X`009`009       oprint(+("Dog follows ",p1)),
  1450. X`009`009       if(move(target),print("Dog comes to here.")
  1451. X                         )
  1452. X`009`009      ),
  1453. X`009`009  if(=(random("a, b"),"a"),
  1454. X                     GOSUB home2()
  1455. X`009`009    )
  1456. X`009         )
  1457. X              )
  1458. X
  1459. X- LABEL keep it(if(target,
  1460. X                   null(set state(+("back ",where(player name))),
  1461. X                        GOSUB jump(target)
  1462. X                       )
  1463. X                  )
  1464. X               )
  1465. X
  1466. X- LABEL enter(if(=(GOSUB state head(),"back"),
  1467. X                 null(GOSUB get back2(GOSUB state tail()),
  1468. X                      set state(+("keep ",player name))
  1469. X                     )
  1470. X                )
  1471. X             )
  1472. X
  1473. X- LABEL get back2(if(=(p1,where(player name)),
  1474. X                     "",
  1475. X                     null(pprint("Dog forces you back to ",p1),
  1476. X                          oprint(+("Dog forces ",player name),
  1477. X                                   " back to ",p2
  1478. X                                  ),
  1479. X                          null(GOSUB jump(p1),
  1480. X                               if(pmove(p1),
  1481. X                                   oprint("Dog forces ",player name,
  1482. X                                          " back to here."
  1483. X                                         )
  1484. X                                 )
  1485. X                              )
  1486. X                         )
  1487. X                    )
  1488. X                 )
  1489. X
  1490. X- LABEL home2(null(GOSUB jump("kitchen"),
  1491. X                   set state("")
  1492. X                  )
  1493. X             )
  1494. X
  1495. X- LABEL home(GOSUB home2(set state("")))
  1496. X
  1497. X- LABEL set(if(lookup player(p1),
  1498. X               null(set state(+("follow",lookup player(p1))),
  1499. X                    print("Dog: vuf !"),
  1500. X                    GOSUB jump(where(lookup player(p1)))
  1501. X                   ),
  1502. X               if(not(p1),
  1503. X                  null(set state(+("follow",player name)),
  1504. X                       print("Dog: vuf !")
  1505. X                      )
  1506. X                 )
  1507. X              )
  1508. X           )
  1509. X
  1510. X- LABEL keep(if(lookup player(p1),
  1511. X               null(set state(+("keep",lookup player(p1))),
  1512. X                    print("Dog: vuf !"),
  1513. X                    GOSUB jump(where(lookup player(p1)))
  1514. X                   )
  1515. X              )
  1516. X           )
  1517. X
  1518. X- LABEL command(if(=(command,"state"),
  1519. X                   pprint("State: ",get state()),
  1520. X                   pprint("You can't",command,"Dog.")
  1521. X                  )
  1522. X               )
  1523. X
  1524. X- LABEL go to(GOSUB go2(lookup room(p1)))
  1525. X
  1526. X- LABEL go2(if(p1,
  1527. X               null(GOSUB jump(p1),
  1528. X                    set state("")
  1529. X                   )
  1530. X              )
  1531. X           )
  1532. X
  1533. X- LABEL jump2(if(=(where(monster name),p1),
  1534. X                "",
  1535. X                null(print(+("Dog goes ",p1)),
  1536. X                     if(move(p1),
  1537. X                        print("Dog comes here.")
  1538. X                       )
  1539. X                    )
  1540. X               )
  1541. X             )
  1542. X
  1543. X- LABEL jump(if(p1,
  1544. X                GOSUB jump2(p1),
  1545. X                GOSUB jump2("kitchen")
  1546. X               )
  1547. X            )
  1548. X
  1549. X- LABEL stay(null(set state(""),
  1550. X                  print("Dog: Vuf !")
  1551. X                 )
  1552. X            )
  1553. X
  1554. X- LABEL look you(if(=(GOSUB state head(),"keep"),
  1555. X                    "",
  1556. X                    if(=(random("a, b, c, d"),"a"),
  1557. X                       GOSUB set()
  1558. X                      )
  1559. X                   )
  1560. X                )
  1561. X
  1562. X- LABEL look()
  1563. $ CALL UNPACK DOG.MDL;26 34433687
  1564. $ create/nolog 'f'
  1565. X! That file fix database errors
  1566. X! Usage: MONSTER/BATCH=FIX.BATCH
  1567. XGS                                    ! Mark monster shutdown
  1568. XG-                                    ! Mark database as invalid
  1569. XC                                     ! Create event file
  1570. XD                                     ! Reallocate descriptions
  1571. XK                                     ! Reallocate MDL codes
  1572. XI                                     ! Repair index file
  1573. XG                                     ! Calculate objects' number in existen
  1574. Vce
  1575. XN                                     ! Clear/create and recount quota datab
  1576. Vase.
  1577. XJ                                     ! Repair paths
  1578. XL                                     ! repair monsters' location
  1579. XOW                                    ! Check owners of rooms, objects and M
  1580. VDLs
  1581. XG+                                    ! Mark database as valid
  1582. XGU                                    ! Mark monster active
  1583. X! Let's hope that's all !
  1584. XV                                     ! View database capacity
  1585. XGV                                    ! View global flags
  1586. X!
  1587. X!                       - Kari Hurtta (hurtta@finuh)
  1588. X
  1589. $ CALL UNPACK FIX.BATCH;4 1648825448
  1590. $ create/nolog 'f'
  1591. X`091environment,inherit ('sys$library:starlet')`093
  1592. XModule Global;`009    `123 global definations `125
  1593. X
  1594. Xconst
  1595. X
  1596. X        MAX_PING = 5;
  1597. X                            `032
  1598. X`009string_len = 80;
  1599. X`009veryshortlen = 12;`009`123 very short string length for userid's etc `12
  1600. V5
  1601. X`009shortlen = 20;`009`009`123 ordinary short string `125
  1602. X        MEGA_LENGTH = 1000;`009`123 must be same as string_length `125
  1603. X`009`009`009`009`123 in module interpreter`009`125
  1604. X`009RANDOM_EVENT_CYCLE = 80;`123 time between random evet checks`009`125
  1605. X`009maxobjs = 15;`009`009`123 max objects allow on floor in a room `125
  1606. X`009maxpeople = 10;`009`009`123 max people allowed in a room `125
  1607. X`009maxplayers = 300;`009`123 max log entries to make for players `125
  1608. X`009maxcmds = 99;`009`009`123 top value for cmd keyword slots `125
  1609. X`009maxshow = 50;`009`009`123 top value for set/show keywords `125
  1610. X`009maxexit = 6;`009`009`123 6 exits from each loc: NSEWUD `125
  1611. X`009maxroom = 1000;`009`009`123 Total maximum ever possible`009`125
  1612. X`009maxdetail = 5;`009`009`123 max num of detail keys/descriptions per room
  1613. V `125
  1614. X`009maxevent = 15;`009`009`123 event slots per event block `125
  1615. X`009maxindex = 10000;`009`123 top value for bitmap allocation `125
  1616. X`009maxhold = 6;`009`009`123 max # of things a player can be holding `125
  1617. X`009maxerr = 15;`009`009`123 # of consecutive record collisions before the
  1618. X`009`009`009`009  the deadlock error message is printed `125
  1619. X`009numevnts = 10;`009`009`123 # of different event records to be maintained
  1620. V `125
  1621. X`009numpunches = 12;`009`123 # of different kinds of punches there are `125
  1622. X`009maxparm = 20;`009`009`123 parms for object USEs `125
  1623. X`009maxspells = 50;`009`009`123 total number of spells available `125
  1624. X
  1625. X`009descmax = 10;`009`009`123 lines per description block `125
  1626. +-+-+-+-+-+-+-+-  END  OF PART 11 +-+-+-+-+-+-+-+-
  1627.