aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2017-02-19 21:31:22 -0500
committerMark Oteiza2017-02-19 22:00:10 -0500
commit0db5ba48b294640774262b01e2f9abc9cbf23d31 (patch)
tree0676b1751978393f2d79ba8d72188e124355be29
parentc8d14cfc6c2d19077d137c7e917fbb4f104de222 (diff)
downloademacs-0db5ba48b294640774262b01e2f9abc9cbf23d31.tar.gz
emacs-0db5ba48b294640774262b01e2f9abc9cbf23d31.zip
Replace nested ifs with cond
* lisp/play/dunnet.el (dun-messages, dun-describe-room, dun-examine): (dun-eat, dun-put-objs, dun-turn, dun-press, dun-ls, dun-cd): Use when and cond where appropriate. (dun-sauna-heat): Accept sauna level as an argument. Use cond. (dun-take): Use null and dun-mprincl. (dun-inven-weight, dun-load-d): Reformat. (dun-remove-obj-from-inven, dun-remove-obj-from-room): Nix setq to nil.
-rw-r--r--lisp/play/dunnet.el552
1 files changed, 252 insertions, 300 deletions
diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el
index 755c6583e7a..a5aa7040c14 100644
--- a/lisp/play/dunnet.el
+++ b/lisp/play/dunnet.el
@@ -1154,14 +1154,12 @@ treasures for points?" "4" "four")
1154(defun dun-messages () 1154(defun dun-messages ()
1155 (if dun-dead 1155 (if dun-dead
1156 (text-mode) 1156 (text-mode)
1157 (if (eq dungeon-mode 'dungeon) 1157 (when (eq dungeon-mode 'dungeon)
1158 (progn 1158 (when (not (= room dun-current-room))
1159 (if (not (= room dun-current-room)) 1159 (dun-describe-room dun-current-room)
1160 (progn 1160 (setq room dun-current-room))
1161 (dun-describe-room dun-current-room) 1161 (dun-fix-screen)
1162 (setq room dun-current-room))) 1162 (dun-mprinc ">"))))
1163 (dun-fix-screen)
1164 (dun-mprinc ">")))))
1165 1163
1166 1164
1167;;;###autoload 1165;;;###autoload
@@ -1192,24 +1190,23 @@ treasures for points?" "4" "four")
1192 (not (string= dun-mode "long"))) 1190 (not (string= dun-mode "long")))
1193 nil 1191 nil
1194 (dun-mprinc (car (nth (abs room) dun-rooms))) 1192 (dun-mprinc (car (nth (abs room) dun-rooms)))
1195 (dun-mprinc "\n")) 1193 (dun-mprinc "\n"))
1196 (if (not (string= dun-mode "long")) 1194 (when (and (not (string= dun-mode "long"))
1197 (if (not (member (abs room) dun-visited)) 1195 (not (member (abs room) dun-visited)))
1198 (setq dun-visited (append (list (abs room)) dun-visited)))) 1196 (setq dun-visited (append (list (abs room)) dun-visited)))
1199 (dolist (xobjs (nth dun-current-room dun-room-objects)) 1197 (dolist (xobjs (nth dun-current-room dun-room-objects))
1200 (if (= xobjs obj-special) 1198 (cond
1201 (dun-special-object) 1199 ((= xobjs obj-special)
1202 (if (>= xobjs 0) 1200 (dun-special-object))
1203 (dun-mprincl (car (nth xobjs dun-objects))) 1201 ((>= xobjs 0)
1204 (if (not (and (= xobjs obj-bus) dun-inbus)) 1202 (dun-mprincl (car (nth xobjs dun-objects))))
1205 (progn 1203 ((not (and (= xobjs obj-bus) dun-inbus))
1206 (dun-mprincl (car (nth (abs xobjs) dun-perm-objects))))))) 1204 (dun-mprincl (car (nth (abs xobjs) dun-perm-objects)))))
1207 (if (and (= xobjs obj-jar) dun-jar) 1205 (when (and (= xobjs obj-jar) dun-jar)
1208 (progn 1206 (dun-mprincl "The jar contains:")
1209 (dun-mprincl "The jar contains:") 1207 (dolist (x dun-jar)
1210 (dolist (x dun-jar) 1208 (dun-mprinc " ")
1211 (dun-mprinc " ") 1209 (dun-mprincl (car (nth x dun-objects))))))
1212 (dun-mprincl (car (nth x dun-objects)))))))
1213 (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus) 1210 (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
1214 (dun-mprincl "You are on the bus.")))) 1211 (dun-mprincl "You are on the bus."))))
1215 1212
@@ -1314,35 +1311,31 @@ disk bursts into flames, and disintegrates.")
1314 (dun-mprincl (cadr (nth x dun-objects)))))))))) 1311 (dun-mprincl (cadr (nth x dun-objects))))))))))
1315 1312
1316(defun dun-shake (obj) 1313(defun dun-shake (obj)
1317 (let (objnum) 1314 (let ((objnum (dun-objnum-from-args-std obj)))
1318 (when (setq objnum (dun-objnum-from-args-std obj)) 1315 (when objnum
1319 (if (member objnum dun-inventory) 1316 (cond
1320 (progn 1317 ((member objnum dun-inventory)
1321;;; If shaking anything will do anything, put here. 1318 ;; If shaking anything will do anything, put here.
1322 (dun-mprinc "Shaking ") 1319 (dun-mprinc "Shaking ")
1323 (dun-mprinc (downcase (cadr (nth objnum dun-objects)))) 1320 (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
1324 (dun-mprinc " seems to have no effect.") 1321 (dun-mprinc " seems to have no effect.")
1325 (dun-mprinc "\n") 1322 (dun-mprinc "\n"))
1326 ) 1323 ((and (not (member objnum (nth dun-current-room dun-room-silents)))
1327 (if (and (not (member objnum (nth dun-current-room dun-room-silents))) 1324 (not (member objnum (nth dun-current-room dun-room-objects))))
1328 (not (member objnum (nth dun-current-room dun-room-objects)))) 1325 (dun-mprincl "I don't see that here."))
1329 (dun-mprincl "I don't see that here.") 1326 ;; Shaking trees can be deadly
1330;;; Shaking trees can be deadly 1327 ((= objnum obj-tree)
1331 (if (= objnum obj-tree) 1328 (dun-mprinc
1332 (progn
1333 (dun-mprinc
1334 "You begin to shake a tree, and notice a coconut begin to fall from the air. 1329 "You begin to shake a tree, and notice a coconut begin to fall from the air.
1335As you try to get your hand up to block it, you feel the impact as it lands 1330As you try to get your hand up to block it, you feel the impact as it lands
1336on your head.") 1331on your head.")
1337 (dun-die "a coconut")) 1332 (dun-die "a coconut"))
1338 (if (= objnum obj-bear) 1333 ((= objnum obj-bear)
1339 (progn 1334 (dun-mprinc
1340 (dun-mprinc
1341"As you go up to the bear, it removes your head and places it on the ground.") 1335"As you go up to the bear, it removes your head and places it on the ground.")
1342 (dun-die "a bear")) 1336 (dun-die "a bear"))
1343 (if (< objnum 0) 1337 ((< objnum 0) (dun-mprincl "You cannot shake that."))
1344 (dun-mprincl "You cannot shake that.") 1338 (t (dun-mprincl "You don't have that."))))))
1345 (dun-mprincl "You don't have that.")))))))))
1346 1339
1347 1340
1348(defun dun-drop (obj) 1341(defun dun-drop (obj)
@@ -1396,36 +1389,33 @@ through.")))))
1396;;; Give long description of current room, or an object. 1389;;; Give long description of current room, or an object.
1397 1390
1398(defun dun-examine (obj) 1391(defun dun-examine (obj)
1399 (let (objnum) 1392 (let ((objnum (dun-objnum-from-args obj)))
1400 (setq objnum (dun-objnum-from-args obj)) 1393 (cond
1401 (if (eq objnum obj-special) 1394 ((eq objnum obj-special)
1402 (dun-describe-room (* dun-current-room -1)) 1395 (dun-describe-room (* dun-current-room -1)))
1403 (if (and (eq objnum obj-computer) 1396 ((and (eq objnum obj-computer)
1404 (member obj-pc (nth dun-current-room dun-room-silents))) 1397 (member obj-pc (nth dun-current-room dun-room-silents)))
1405 (dun-examine '("pc")) 1398 (dun-examine '("pc")))
1406 (if (eq objnum nil) 1399 ((null objnum)
1407 (dun-mprincl "I don't know what that is.") 1400 (dun-mprincl "I don't know what that is."))
1408 (if (and (not (member objnum 1401 ((and (not (member objnum (nth dun-current-room dun-room-objects)))
1409 (nth dun-current-room dun-room-objects))) 1402 (not (and (member obj-jar dun-inventory)
1410 (not (and (member obj-jar dun-inventory) 1403 (member objnum dun-jar)))
1411 (member objnum dun-jar))) 1404 (not (member objnum (nth dun-current-room dun-room-silents)))
1412 (not (member objnum 1405 (not (member objnum dun-inventory)))
1413 (nth dun-current-room dun-room-silents))) 1406 (dun-mprincl "I don't see that here."))
1414 (not (member objnum dun-inventory))) 1407 ((>= objnum 0)
1415 (dun-mprincl "I don't see that here.") 1408 (if (and (= objnum obj-bone)
1416 (if (>= objnum 0) 1409 (= dun-current-room marine-life-area) dun-black)
1417 (if (and (= objnum obj-bone)
1418 (= dun-current-room marine-life-area) dun-black)
1419 (dun-mprincl 1410 (dun-mprincl
1420"In this light you can see some writing on the bone. It says: 1411"In this light you can see some writing on the bone. It says:
1421For an explosive time, go to Fourth St. and Vermont.") 1412For an explosive time, go to Fourth St. and Vermont.")
1422 (if (nth objnum dun-physobj-desc) 1413 (if (nth objnum dun-physobj-desc)
1423 (dun-mprincl (nth objnum dun-physobj-desc)) 1414 (dun-mprincl (nth objnum dun-physobj-desc))
1424 (dun-mprincl "I see nothing special about that."))) 1415 (dun-mprincl "I see nothing special about that."))))
1425 (if (nth (abs objnum) dun-permobj-desc) 1416 ((nth (abs objnum) dun-permobj-desc)
1426 (progn 1417 (dun-mprincl (nth (abs objnum) dun-permobj-desc)))
1427 (dun-mprincl (nth (abs objnum) dun-permobj-desc))) 1418 (t (dun-mprincl "I see nothing special about that.")))))
1428 (dun-mprincl "I see nothing special about that.")))))))))
1429 1419
1430(defun dun-take (obj) 1420(defun dun-take (obj)
1431 (setq obj (dun-firstword obj)) 1421 (setq obj (dun-firstword obj))
@@ -1447,10 +1437,8 @@ For an explosive time, go to Fourth St. and Vermont.")
1447 (dun-mprincl "Nothing to take.")))) 1437 (dun-mprincl "Nothing to take."))))
1448 (let (objnum) 1438 (let (objnum)
1449 (setq objnum (cdr (assq (intern obj) dun-objnames))) 1439 (setq objnum (cdr (assq (intern obj) dun-objnames)))
1450 (if (eq objnum nil) 1440 (if (null objnum)
1451 (progn 1441 (dun-mprincl "I don't know what that is.")
1452 (dun-mprinc "I don't know what that is.")
1453 (dun-mprinc "\n"))
1454 (if (and dun-inbus (not (and (member objnum dun-jar) 1442 (if (and dun-inbus (not (and (member objnum dun-jar)
1455 (member obj-jar dun-inventory)))) 1443 (member obj-jar dun-inventory))))
1456 (dun-mprincl "You can't take anything while on the bus.") 1444 (dun-mprincl "You can't take anything while on the bus.")
@@ -1485,12 +1473,12 @@ For an explosive time, go to Fourth St. and Vermont.")
1485 (dun-mprinc "\n"))) 1473 (dun-mprinc "\n")))
1486 1474
1487(defun dun-inven-weight () 1475(defun dun-inven-weight ()
1488 (let (total) 1476 (let ((total 0))
1489 (setq total 0)
1490 (dolist (x dun-jar) 1477 (dolist (x dun-jar)
1491 (setq total (+ total (nth x dun-object-lbs)))) 1478 (setq total (+ total (nth x dun-object-lbs))))
1492 (dolist (x dun-inventory) 1479 (dolist (x dun-inventory)
1493 (setq total (+ total (nth x dun-object-lbs)))) total)) 1480 (setq total (+ total (nth x dun-object-lbs))))
1481 total))
1494 1482
1495;;; We try to take an object that is untakable. Print a message 1483;;; We try to take an object that is untakable. Print a message
1496;;; depending on what it is. 1484;;; depending on what it is.
@@ -1533,18 +1521,19 @@ For an explosive time, go to Fourth St. and Vermont.")
1533notice that the tree is very unsteady."))))) 1521notice that the tree is very unsteady.")))))
1534 1522
1535(defun dun-eat (obj) 1523(defun dun-eat (obj)
1536 (let (objnum) 1524 (let ((objnum (dun-objnum-from-args-std obj)))
1537 (when (setq objnum (dun-objnum-from-args-std obj)) 1525 (when objnum
1538 (if (not (member objnum dun-inventory)) 1526 (cond
1539 (dun-mprincl "You don't have that.") 1527 ((not (member objnum dun-inventory))
1540 (if (not (= objnum obj-food)) 1528 (dun-mprincl "You don't have that."))
1541 (progn 1529 ((/= objnum obj-food)
1542 (dun-mprinc "You forcefully shove ") 1530 (dun-mprinc "You forcefully shove ")
1543 (dun-mprinc (downcase (cadr (nth objnum dun-objects)))) 1531 (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
1544 (dun-mprincl " down your throat, and start choking.") 1532 (dun-mprincl " down your throat, and start choking.")
1545 (dun-die "choking")) 1533 (dun-die "choking"))
1546 (dun-mprincl "That tasted horrible.") 1534 (t
1547 (dun-remove-obj-from-inven obj-food)))))) 1535 (dun-mprincl "That tasted horrible.")
1536 (dun-remove-obj-from-inven obj-food))))))
1548 1537
1549(defun dun-put (args) 1538(defun dun-put (args)
1550 (let (newargs objnum objnum2 obj) 1539 (let (newargs objnum objnum2 obj)
@@ -1580,65 +1569,59 @@ notice that the tree is very unsteady.")))))
1580 1569
1581 (if (= obj2 obj-disposal) (setq obj2 obj-chute)) 1570 (if (= obj2 obj-disposal) (setq obj2 obj-chute))
1582 1571
1583 (if (and (= obj1 obj-cpu) (= obj2 obj-computer)) 1572 (cond
1584 (progn 1573 ((and (= obj1 obj-cpu) (= obj2 obj-computer))
1585 (dun-remove-obj-from-inven obj-cpu) 1574 (dun-remove-obj-from-inven obj-cpu)
1586 (setq dun-computer t) 1575 (setq dun-computer t)
1587 (dun-mprincl 1576 (dun-mprincl
1588"As you put the CPU board in the computer, it immediately springs to life. 1577"As you put the CPU board in the computer, it immediately springs to life.
1589The lights start flashing, and the fans seem to startup.")) 1578The lights start flashing, and the fans seem to startup."))
1590 (if (and (= obj1 obj-weight) (= obj2 obj-button)) 1579 ((and (= obj1 obj-weight) (= obj2 obj-button))
1591 (dun-drop '("weight")) 1580 (dun-drop '("weight")))
1592 (if (= obj2 obj-jar) ;; Put something in jar 1581 ((= obj2 obj-jar) ; Put something in jar
1593 (if (not (member obj1 (list obj-paper obj-diamond obj-emerald 1582 (if (not (member obj1 (list obj-paper obj-diamond obj-emerald
1594 obj-license obj-coins obj-egg 1583 obj-license obj-coins obj-egg
1595 obj-nitric obj-glycerine))) 1584 obj-nitric obj-glycerine)))
1596 (dun-mprincl "That will not fit in the jar.") 1585 (dun-mprincl "That will not fit in the jar.")
1597 (dun-remove-obj-from-inven obj1) 1586 (dun-remove-obj-from-inven obj1)
1598 (setq dun-jar (append dun-jar (list obj1))) 1587 (setq dun-jar (append dun-jar (list obj1)))
1599 (dun-mprincl "Done.")) 1588 (dun-mprincl "Done.")))
1600 (if (= obj2 obj-chute) ;; Put something in chute 1589 ((= obj2 obj-chute) ; Put something in chute
1601 (progn 1590 (dun-remove-obj-from-inven obj1)
1602 (dun-remove-obj-from-inven obj1) 1591 (dun-mprincl "You hear it slide down the chute and off into the distance.")
1603 (dun-mprincl 1592 (dun-put-objs-in-treas (list obj1)))
1604"You hear it slide down the chute and off into the distance.") 1593 ((= obj2 obj-box) ; Put key in key box
1605 (dun-put-objs-in-treas (list obj1))) 1594 (if (/= obj1 obj-key)
1606 (if (= obj2 obj-box) ;; Put key in key box 1595 (dun-mprincl "You can't put that in the key box!")
1607 (if (= obj1 obj-key) 1596 (dun-mprincl
1608 (progn
1609 (dun-mprincl
1610"As you drop the key, the box begins to shake. Finally it explodes 1597"As you drop the key, the box begins to shake. Finally it explodes
1611with a bang. The key seems to have vanished!") 1598with a bang. The key seems to have vanished!")
1612 (dun-remove-obj-from-inven obj1) 1599 (dun-remove-obj-from-inven obj1)
1613 (dun-replace dun-room-objects computer-room (append 1600 (dun-replace dun-room-objects computer-room (append
1614 (nth computer-room 1601 (nth computer-room
1615 dun-room-objects) 1602 dun-room-objects)
1616 (list obj1))) 1603 (list obj1)))
1617 (dun-remove-obj-from-room dun-current-room obj-box) 1604 (dun-remove-obj-from-room dun-current-room obj-box)
1618 (setq dun-key-level (1+ dun-key-level))) 1605 (setq dun-key-level (1+ dun-key-level))))
1619 (dun-mprincl "You can't put that in the key box!")) 1606
1620 1607 ((and (= obj1 obj-floppy) (= obj2 obj-pc))
1621 (if (and (= obj1 obj-floppy) (= obj2 obj-pc)) 1608 (setq dun-floppy t)
1622 (progn 1609 (dun-remove-obj-from-inven obj1)
1623 (setq dun-floppy t) 1610 (dun-mprincl "Done."))
1624 (dun-remove-obj-from-inven obj1) 1611
1625 (dun-mprincl "Done.")) 1612 ((= obj2 obj-urinal) ; Put object in urinal
1626 1613 (dun-remove-obj-from-inven obj1)
1627 (if (= obj2 obj-urinal) ;; Put object in urinal 1614 (dun-replace dun-room-objects urinal (append
1628 (progn 1615 (nth urinal dun-room-objects)
1629 (dun-remove-obj-from-inven obj1) 1616 (list obj1)))
1630 (dun-replace dun-room-objects urinal (append 1617 (dun-mprincl "You hear it plop down in some water below."))
1631 (nth urinal dun-room-objects) 1618 ((= obj2 obj-mail)
1632 (list obj1))) 1619 (dun-mprincl "The mail chute is locked."))
1633 (dun-mprincl 1620 ((member obj1 dun-inventory)
1634 "You hear it plop down in some water below.")) 1621 (dun-mprincl
1635 (if (= obj2 obj-mail)
1636 (dun-mprincl "The mail chute is locked.")
1637 (if (member obj1 dun-inventory)
1638 (dun-mprincl
1639"I don't know how to combine those objects. Perhaps you should 1622"I don't know how to combine those objects. Perhaps you should
1640just try dropping it.") 1623just try dropping it."))
1641 (dun-mprincl "You can't put that there."))))))))))) 1624 (t (dun-mprincl "You can't put that there."))))
1642 1625
1643(defun dun-type (_args) 1626(defun dun-type (_args)
1644 (if (not (= dun-current-room computer-room)) 1627 (if (not (= dun-current-room computer-room))
@@ -1890,73 +1873,67 @@ huge rocks sliding down from the ceiling, and blocking your way out.\n")
1890 (dun-mprincl 1873 (dun-mprincl
1891 "The dial will not turn further in that direction.") 1874 "The dial will not turn further in that direction.")
1892 (setq dun-sauna-level 0)) 1875 (setq dun-sauna-level 0))
1893 (dun-sauna-heat)))))))) 1876 (dun-sauna-heat dun-sauna-level))))))))
1894 1877
1895(defun dun-sauna-heat () 1878(defun dun-sauna-heat (level)
1896 (if (= dun-sauna-level 0) 1879 (cond
1897 (dun-mprincl 1880 ((= level 0)
1898 "The temperature has returned to normal room temperature.")) 1881 (dun-mprincl "The temperature has returned to normal room temperature."))
1899 (if (= dun-sauna-level 1) 1882 ((= level 1)
1900 (dun-mprincl "It is now luke warm in here. You are perspiring.")) 1883 (dun-mprincl "It is now luke warm in here. You are perspiring."))
1901 (if (= dun-sauna-level 2) 1884 ((= level 2)
1902 (dun-mprincl "It is pretty hot in here. It is still very comfortable.")) 1885 (dun-mprincl "It is pretty hot in here. It is still very comfortable."))
1903 (if (= dun-sauna-level 3) 1886 ((= level 3)
1904 (progn 1887 (dun-mprincl
1905 (dun-mprincl 1888 "It is now very hot. There is something very refreshing about this.")
1906"It is now very hot. There is something very refreshing about this.") 1889 (when (or (member obj-rms dun-inventory)
1907 (if (or (member obj-rms dun-inventory) 1890 (member obj-rms (nth dun-current-room dun-room-objects)))
1908 (member obj-rms (nth dun-current-room dun-room-objects))) 1891 (dun-mprincl
1909 (progn
1910 (dun-mprincl
1911"You notice the wax on your statuette beginning to melt, until it completely 1892"You notice the wax on your statuette beginning to melt, until it completely
1912melts off. You are left with a beautiful diamond!") 1893melts off. You are left with a beautiful diamond!")
1913 (if (member obj-rms dun-inventory) 1894 (if (member obj-rms dun-inventory)
1914 (progn 1895 (progn
1915 (dun-remove-obj-from-inven obj-rms) 1896 (dun-remove-obj-from-inven obj-rms)
1916 (setq dun-inventory (append dun-inventory 1897 (setq dun-inventory (append dun-inventory
1917 (list obj-diamond)))) 1898 (list obj-diamond))))
1918 (dun-remove-obj-from-room dun-current-room obj-rms) 1899 (dun-remove-obj-from-room dun-current-room obj-rms)
1919 (dun-replace dun-room-objects dun-current-room 1900 (dun-replace dun-room-objects dun-current-room
1920 (append (nth dun-current-room dun-room-objects) 1901 (append (nth dun-current-room dun-room-objects)
1921 (list obj-diamond)))))) 1902 (list obj-diamond)))))
1922 (if (or (member obj-floppy dun-inventory) 1903 (when (or (member obj-floppy dun-inventory)
1923 (member obj-floppy (nth dun-current-room dun-room-objects))) 1904 (member obj-floppy (nth dun-current-room dun-room-objects)))
1924 (progn 1905 (dun-mprincl
1925 (dun-mprincl
1926"You notice your floppy disk beginning to melt. As you grab for it, the 1906"You notice your floppy disk beginning to melt. As you grab for it, the
1927disk bursts into flames, and disintegrates.") 1907disk bursts into flames, and disintegrates.")
1928 (if (member obj-floppy dun-inventory) 1908 (if (member obj-floppy dun-inventory)
1929 (dun-remove-obj-from-inven obj-floppy) 1909 (dun-remove-obj-from-inven obj-floppy)
1930 (dun-remove-obj-from-room dun-current-room obj-floppy)))))) 1910 (dun-remove-obj-from-room dun-current-room obj-floppy))))
1931 1911
1932 (if (= dun-sauna-level 4) 1912 ((= level 4)
1933 (progn 1913 (dun-mprincl "As the dial clicks into place, you immediately burst into flames.")
1934 (dun-mprincl 1914 (dun-die "burning"))))
1935"As the dial clicks into place, you immediately burst into flames.")
1936 (dun-die "burning"))))
1937 1915
1938(defun dun-press (obj) 1916(defun dun-press (obj)
1939 (let (objnum) 1917 (let ((objnum (dun-objnum-from-args-std obj)))
1940 (when (setq objnum (dun-objnum-from-args-std obj)) 1918 (cond
1941 (if (not (or (member objnum (nth dun-current-room dun-room-objects)) 1919 ((not (or (member objnum (nth dun-current-room dun-room-objects))
1942 (member objnum (nth dun-current-room dun-room-silents)))) 1920 (member objnum (nth dun-current-room dun-room-silents))))
1943 (dun-mprincl "I don't see that here.") 1921 (dun-mprincl "I don't see that here."))
1944 (if (not (member objnum (list obj-button obj-switch))) 1922 ((not (member objnum (list obj-button obj-switch)))
1945 (progn 1923 (dun-mprinc "You can't ")
1946 (dun-mprinc "You can't ") 1924 (dun-mprinc (car line-list))
1947 (dun-mprinc (car line-list)) 1925 (dun-mprincl " that."))
1948 (dun-mprincl " that.")) 1926 ((= objnum obj-button)
1949 (if (= objnum obj-button) 1927 (dun-mprincl
1950 (dun-mprincl
1951"As you press the button, you notice a passageway open up, but 1928"As you press the button, you notice a passageway open up, but
1952as you release it, the passageway closes.")) 1929as you release it, the passageway closes."))
1953 (if (= objnum obj-switch) 1930 ((= objnum obj-switch)
1954 (if dun-black 1931 (if dun-black
1955 (progn 1932 (progn
1956 (dun-mprincl "The button is now in the off position.") 1933 (dun-mprincl "The button is now in the off position.")
1957 (setq dun-black nil)) 1934 (setq dun-black nil))
1958 (dun-mprincl "The button is now in the on position.") 1935 (dun-mprincl "The button is now in the on position.")
1959 (setq dun-black t)))))))) 1936 (setq dun-black t))))))
1960 1937
1961(defun dun-swim (_args) 1938(defun dun-swim (_args)
1962 (if (not (member dun-current-room (list lakefront-north lakefront-south))) 1939 (if (not (member dun-current-room (list lakefront-north lakefront-south)))
@@ -2376,15 +2353,14 @@ for a moment, then straighten yourself up.
2376;;; Load an encrypted file, and eval it. 2353;;; Load an encrypted file, and eval it.
2377 2354
2378(defun dun-load-d (filename) 2355(defun dun-load-d (filename)
2379 (let (old-buffer result) 2356 (let ((old-buffer (current-buffer))
2380 (setq result t) 2357 (result t))
2381 (setq old-buffer (current-buffer))
2382 (switch-to-buffer (get-buffer-create "*loadc*")) 2358 (switch-to-buffer (get-buffer-create "*loadc*"))
2383 (erase-buffer) 2359 (erase-buffer)
2384 (condition-case nil 2360 (condition-case nil
2385 (insert-file-contents filename) 2361 (insert-file-contents filename)
2386 (error (setq result nil))) 2362 (error (setq result nil)))
2387 (unless (not result) 2363 (when result
2388 (condition-case nil 2364 (condition-case nil
2389 (dun-rot13) 2365 (dun-rot13)
2390 (error (yank))) 2366 (error (yank)))
@@ -2397,7 +2373,6 @@ for a moment, then straighten yourself up.
2397 2373
2398(defun dun-remove-obj-from-room (room objnum) 2374(defun dun-remove-obj-from-room (room objnum)
2399 (let (newroom) 2375 (let (newroom)
2400 (setq newroom nil)
2401 (dolist (x (nth room dun-room-objects)) 2376 (dolist (x (nth room dun-room-objects))
2402 (if (not (= x objnum)) 2377 (if (not (= x objnum))
2403 (setq newroom (append newroom (list x))))) 2378 (setq newroom (append newroom (list x)))))
@@ -2405,7 +2380,6 @@ for a moment, then straighten yourself up.
2405 2380
2406(defun dun-remove-obj-from-inven (objnum) 2381(defun dun-remove-obj-from-inven (objnum)
2407 (let (new-inven) 2382 (let (new-inven)
2408 (setq new-inven nil)
2409 (dolist (x dun-inventory) 2383 (dolist (x dun-inventory)
2410 (if (not (= x objnum)) 2384 (if (not (= x objnum))
2411 (setq new-inven (append new-inven (list x))))) 2385 (setq new-inven (append new-inven (list x)))))
@@ -2567,24 +2541,19 @@ Note: Restricted bourne shell in use.\n")))
2567 (setq dungeon-mode 'dungeon))) 2541 (setq dungeon-mode 'dungeon)))
2568 2542
2569(defun dun-ls (args) 2543(defun dun-ls (args)
2570 (if (car args) 2544 (let ((ocdroom dun-cdroom))
2571 (let (ocdpath ocdroom) 2545 (if (car args)
2572 (setq ocdpath dun-cdpath) 2546 (let ((ocdpath dun-cdpath))
2573 (setq ocdroom dun-cdroom) 2547 (if (not (eq (dun-cd args) -2))
2574 (if (not (eq (dun-cd args) -2)) 2548 (dun-ls nil))
2575 (dun-ls nil)) 2549 (setq dun-cdpath ocdpath)
2576 (setq dun-cdpath ocdpath) 2550 (setq dun-cdroom ocdroom))
2577 (setq dun-cdroom ocdroom)) 2551 (cond
2578 (if (= dun-cdroom -10) 2552 ((= ocdroom -10) (dun-ls-inven))
2579 (dun-ls-inven)) 2553 ((= ocdroom -2) (dun-ls-rooms))
2580 (if (= dun-cdroom -2) 2554 ((= ocdroom -3) (dun-ls-root))
2581 (dun-ls-rooms)) 2555 ((= ocdroom -4) (dun-ls-usr))
2582 (if (= dun-cdroom -3) 2556 ((> ocdroom 0) (dun-ls-room))))))
2583 (dun-ls-root))
2584 (if (= dun-cdroom -4)
2585 (dun-ls-usr))
2586 (if (> dun-cdroom 0)
2587 (dun-ls-room))))
2588 2557
2589(defun dun-ls-root () 2558(defun dun-ls-root ()
2590 (dun-mprincl "total 4 2559 (dun-mprincl "total 4
@@ -2853,80 +2822,63 @@ drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2853 (dun-uexit nil)))))))) 2822 (dun-uexit nil))))))))
2854 2823
2855(defun dun-cd (args) 2824(defun dun-cd (args)
2856 (let (tcdpath tcdroom path-elements room-check) 2825 (if (not (car args))
2857 (if (not (car args)) 2826 (dun-mprincl "Usage: cd <path>")
2858 (dun-mprincl "Usage: cd <path>") 2827 (let ((tcdpath dun-cdpath)
2859 (setq tcdpath dun-cdpath) 2828 (tcdroom dun-cdroom)
2860 (setq tcdroom dun-cdroom) 2829 path-elements)
2861 (setq dun-badcd nil) 2830 (setq dun-badcd nil)
2862 (condition-case nil 2831 (condition-case nil
2863 (setq path-elements (dun-get-path (car args) nil)) 2832 (setq path-elements (dun-get-path (car args) nil))
2864 (error (dun-mprincl "Invalid path") 2833 (error (dun-mprincl "Invalid path")
2865 (setq dun-badcd t))) 2834 (setq dun-badcd t)))
2866 (dolist (pe path-elements) 2835 (dolist (pe path-elements)
2867 (unless dun-badcd 2836 (when (and (not dun-badcd)
2868 (if (not (string= pe ".")) 2837 (not (string= pe ".")))
2869 (if (string= pe "..") 2838 (cond
2870 (progn 2839 ((string= pe "..")
2871 (if (> tcdroom 0) ;In a room 2840 (cond
2872 (progn 2841 ((> tcdroom 0) ;In a room
2873 (setq tcdpath "/rooms") 2842 (setq tcdpath "/rooms")
2874 (setq tcdroom -2)) 2843 (setq tcdroom -2))
2875 ;In /rooms,/usr,root 2844 ((memq tcdroom '(-2 -3 -4)) ; In /rooms,/usr,root
2876 (if (or 2845 (setq tcdpath "/")
2877 (= tcdroom -2) (= tcdroom -4) 2846 (setq tcdroom -3))
2878 (= tcdroom -3)) 2847 ((= tcdroom -10)
2879 (progn 2848 (setq tcdpath "/usr")
2880 (setq tcdpath "/") 2849 (setq tcdroom -4))))
2881 (setq tcdroom -3)) 2850 ((string= pe "/")
2882 (if (= tcdroom -10) ;In /usr/toukmond 2851 (setq tcdpath "/")
2883 (progn 2852 (setq tcdroom -3))
2884 (setq tcdpath "/usr") 2853 ((= tcdroom -4)
2885 (setq tcdroom -4)))))) 2854 (if (not (string= pe "toukmond"))
2886 (if (string= pe "/") 2855 (dun-nosuchdir)
2887 (progn 2856 (setq tcdpath "/usr/toukmond")
2888 (setq tcdpath "/") 2857 (setq tcdroom -10)))
2889 (setq tcdroom -3)) 2858 ((or (= tcdroom -10) (> tcdroom 0)) (dun-nosuchdir))
2890 (if (= tcdroom -4) 2859 ((= tcdroom -3)
2891 (if (string= pe "toukmond") 2860 (cond
2892 (progn 2861 ((string= pe "rooms")
2893 (setq tcdpath "/usr/toukmond") 2862 (setq tcdpath "/rooms")
2894 (setq tcdroom -10)) 2863 (setq tcdroom -2))
2895 (dun-nosuchdir)) 2864 ((string= pe "usr")
2896 (if (= tcdroom -10) 2865 (setq tcdpath "/usr")
2897 (dun-nosuchdir) 2866 (setq tcdroom -4))
2898 (if (> tcdroom 0) 2867 (t (dun-nosuchdir))))
2899 (dun-nosuchdir) 2868 ((= tcdroom -2)
2900 (if (= tcdroom -3) 2869 (let (room-check)
2901 (progn 2870 (dolist (x dun-visited)
2902 (if (string= pe "rooms") 2871 (setq room-check (nth x dun-room-shorts))
2903 (progn 2872 (when (string= room-check pe)
2904 (setq tcdpath "/rooms") 2873 (setq tcdpath (concat "/rooms/" room-check))
2905 (setq tcdroom -2)) 2874 (setq tcdroom x))))
2906 (if (string= pe "usr") 2875 (when (= tcdroom -2)
2907 (progn 2876 (dun-nosuchdir))))))
2908 (setq tcdpath "/usr") 2877 (if dun-badcd
2909 (setq tcdroom -4)) 2878 -2
2910 (dun-nosuchdir)))) 2879 (setq dun-cdpath tcdpath)
2911 (if (= tcdroom -2) 2880 (setq dun-cdroom tcdroom)
2912 (progn 2881 0))))
2913 (dolist (x dun-visited)
2914 (setq room-check
2915 (nth x
2916 dun-room-shorts))
2917 (if (string= room-check pe)
2918 (progn
2919 (setq tcdpath
2920 (concat "/rooms/" room-check))
2921 (setq tcdroom x))))
2922 (if (= tcdroom -2)
2923 (dun-nosuchdir)))))))))))))
2924 (if (not dun-badcd)
2925 (progn
2926 (setq dun-cdpath tcdpath)
2927 (setq dun-cdroom tcdroom)
2928 0)
2929 -2))))
2930 2882
2931(defun dun-nosuchdir () 2883(defun dun-nosuchdir ()
2932 (dun-mprincl "No such directory.") 2884 (dun-mprincl "No such directory.")