Fix some terribly depressing corruption during restore.
In rogue5/state.c, rs_read_daemons() zeroes out the argument and delay
if the daemon slot is empty. Unfortunately that code ended up on the
wrong side of the brace that closes the for loop, so instead of running
after each daemon, it got run once after the loop exited, when the
index was of course out of bounds.
This tended to manifest, when compiled with -O2, by overwriting hw and
setting it to NULL. When inventory() next ran, hw would be passed to
wgetch(), which returns ERR when it gets a NULL argument. This made
md_readchar() think something was wrong and autosave the game.
Upon investigation, rogue3 was found to commit the same mistake.
rogue4 and srogue don't zero the data. arogue5 already does it
properly.
Someday I am going to run all this through Valgrind. Someday when I
am a kinder person who will not be driven to invoke hordes of trolls
and centaurs upon the original authors.
<html><head><title></title></head><body><h1 align=center><b>A Guide to the Dungeons of Doom</b></h1><h2 align=center><i>Michael C. Toy</i></h2><h3 align=center>Computer Systems Research Group<br>Department of Electrical Engineering and Computer Science<br>University of California<br>Berkeley, California 94720</h3><h2 align=center><i>ABSTRACT</i></h2><blockquote> <blockquote> <p align="justify"><font size="2">Rogue is a visual CRT based fantasy game which runs under the UNIX timesharing system. This paper describes how to play rogue, and gives a few hints for those who might otherwise get lost in the Dungeons of Doom.</font></p> </blockquote></blockquote><h2 align="justify"><b>1. Introduction</b></h2><p align="justify">You have just finished your years as astudent at the local fighter’s guild. After muchpractice and sweat you have finally completed your trainingand are ready to embark upon a perilous adventure. As a testof your skills, the local guildmasters have sent you intothe Dungeons of Doom. Your task is to return with the Amuletof Yendor. Your reward for the completion of this task willbe a full membership in the local guild. In addition, youare allowed to keep all the loot you bring back from thedungeons.</p><p align="justify">In preparation for your journey, you aregiven an enchanted sword, takenfrom a dragon’s hoard in the far off Dark Mountains.You are also outfitted with elf-crafted armor and givenenough food to reach the dungeons. You say goodbye to familyand friends for what may be the last time and head up theroad.</p><p align="justify">You set out on your way to the dungeons andafter several days of uneventful travel, you see theancient ruins that mark the entrance to the Dungeons ofDoom. It is late at night so you make camp at the entranceand spend the night sleeping under the open skies. In themorning you gather your sword, put on your armor, eat whatis almost your last food and enter thedungeons.</p><h2 align="justify"><b>2. What is going on here?</b></h2><p align="justify">You have just begun a game of rogue. Yourgoal is to grab as much treasure as you can, find the Amuletof Yendor, and get out of the Dungeons of Doom alive. On thescreen, a map of where you have been and what you have seenon the current dungeon level is kept. As you explore more ofthe level, it appears on the screen in front ofyou.</p><p align="justify">Rogue differs from most computer fantasygames in that it is screen oriented. Commands are all one ortwo keystrokes<sup>1 </sup>and theresults of your commands are displayed graphically on thescreen rather than being explained in words<sup>2</sup>.</p><p align="justify">Another major difference between rogue and other computer fantasy games is that once you have solvedall the puzzles in a standard fantasy game, it has lost mostof its excitement and it ceases to be fun. Rogue on theother hand generates a new dungeon every time you play itand even the author finds it an entertaining and excitinggame.</p><h2 align="justify"><b>3. What do all those things on the screen mean?</b></h2><p align="justify">In order to understand what is going on inrogue you have to first get some grasp of what rogue isdoing with the screen. The rogue screen is intended toreplace the “You can see ...” descriptions ofstandard fantasy games. Here is a sample of what a rogue screen might look like.</p><div align="center"><pre> --------------------- |...................+ |...@...........[...| |........B..........| |...................| --------+------------Level: 1 Gold: 0 Hp: 12(12) Str: 16 Ac: 6 Exp: 1/0</pre></div><h3 align="justify"><b>3.1. The bottom line</b></h3><p align="justify">At the bottom line of the screen is a fewpieces of cryptic information describing your currentstatus. Here is an explanation of what these thingsmean:</p><table border="0" width="100%" id="table1" cellspacing="3" cellpadding="3"> <tr> <td><p align="justify">Level </p></td> <td><p align="justify">This number indicates how deep you have gone in the dungeon. It starts at one and goes up forever<sup>2</sup>.</p></td> </tr> <tr> <td><p align="justify">Gold</p></td> <td><p align="justify">The number of gold pieces you have managed to find and keep with you so far.</td> </tr> <tr> <td><p align="justify">Hp</p></td> <td><p align="justify">Your current and maximum hit points. Health points indicate how much damage you can take before you die. The more you get hit in a fight, the lower they get. You can regain health points by resting. The number in parentheses is the maximum number your hit points can reach.</p></td> </tr> <tr> <td><p align="justify">Str</p></td> <td><p align="justify">Your current strength. This can be any integer less than or equal to eighteen. The higher the number, the stronger you are.</td> </tr> <tr> <td><p align="justify">Ac</p></td> <td><p align="justify">Your current armor class. This number indicates how effective your armor is in stopping blows from unfriendly creatures. The lower this number is, the more effective the armor.</p></td> </tr> <tr> <td><p align="justify">Exp</p></td> <td><p align="justify">These two numbers give your current experience level and experience points. As you do things, you gain experience points. At certain experience point totals, you gain an experience level. The more experienced you are, the better you are able to fight and to withstand magical attacks.</p></td> </tr></table><h3 align="justify"><b>3.2. The top line</b></h3><p align="justify">The top line of the screen is reserved forprinting messages that describe things that are impossibleto represent visually. If you see a “--More--”on the top line, this means that rogue wants to printanother message on the screen, but it wants to make certainthat you have read the one that is there first. To read thenext message, just type a space.</p><h3 align="justify"><b>3.3. The rest of the screen</b></h3><p align="justify">The rest of the screen is the map of thelevel as you have explored it so far. Each symbol on thescreen represents something. Here is a list of what thevarious symbols mean:</p><table border="0" width="100%" id="table2" cellspacing="3" cellpadding="3"> <tr> <td>@</td> <td><p align="justify">This symbol represents you, the adventurer.</p></td> </tr> <tr> <td>- |</td> <td><p align="justify">These symbols represent the walls of rooms.</p></td> </tr> <tr> <td>+</td> <td> <p align="justify">A door to/from a room.</p></td> </tr> <tr> <td>.</td> <td><p align="justify">The floor of a room.</p></td> </tr> <tr> <td>#</td> <td><p align="justify">The floor of a passage between rooms.</p></td> </tr> <tr> <td>*</td> <td><p align="justify">A pile or pot of gold.</p></td> </tr> <tr> <td>)</td> <td><p align="justify">A weapon of some sort.</p></td> </tr> <tr> <td>]</td> <td><p align="justify">A piece of armor.</p></td> </tr> <tr> <td>!</td> <td><p align="justify">A flask containing a magic potion.</p></td> </tr> <tr> <td>?</td> <td><p align="justify">A piece of paper, usually a magic scroll.</p></td> </tr> <tr> <td>^</td> <td><p align="justify">A trap, watch out for these.</p></td> </tr> <tr> <td>%</td> <td><p align="justify">The passage leading down to the next level.</p></td> </tr> <tr> <td>:</td> <td><p align="justify">A piece of food.</p></td> </tr> <tr> <td>A-Z </td> <td><p align="justify">The uppercase letters represent the various inhabitants of the Dungeons of Doom. Watch out, they can be mean.</p></td> </tr></table><h2 align="justify"><b>4. Commands</b></h2><p align="justify">Commands are given to rogue by pressing single letters.Most commands can be preceded by a count to repeat them(e.g. typing "10s" will do ten searches) The listof commands is rather long, but it can be read at any timeduring the game with the ? command. Here it is forreference, with a short explanation of each command.</p><div align="center"><table border="0" cellspacing="3" cellpadding="3" id="table3"> <tr> <td>?</td> <td><p align="justify">The help command. Asks for a character to give help on. If you type a "*", it will list all the commands, otherwise it will explain what the character you typed does.</p></td> </tr> <tr> <td>/</td> <td align="justify"><p>This is the "What is that on the screen?" command. A "/" followed by any character that you see on the level, will tell you what that character is. For instance, typing "/@" will tell you that the @ symbol represents you, the player.</p></td> </tr> <tr> <td colspan="2">h, H</td> </tr> <tr> <td> </td> <td><p align="justify">Move left. You move one space to the left. If you use upper case h, you will continue to move left until you run into something. This works for all movement commands (e.g. "L" means run in direction "l")</p></td> </tr> <tr> <td>j</td> <td><p align="justify">Move down.</p></td> </tr> <tr> <td>k</td> <td><p align="justify">Move up.</p></td> </tr> <tr> <td>l</td> <td><p align="justify">Move right.</p></td> </tr> <tr> <td>y</td> <td><p align="justify">Move diagonally up and left.</p></td> </tr> <tr> <td>u</td> <td><p align="justify">Move diagonally up and right.</p></td> </tr> <tr> <td>b</td> <td><p align="justify">Move diagonally down and left.</p></td> </tr> <tr> <td>n</td> <td><p align="justify">Move diagonally down and right.</p></td> </tr> <tr> <td>t</td> <td><p align="justify">Throw an object. This is a prefix command. When followed with a direction it throws an object in the specified direction. (e.g. type “th” to throw something to the left.)</p></td> </tr> <tr> <td>f</td> <td><p align="justify">Find prefix. When followed by a direction it means to continue moving in the specified direction until you pass something interesting or run into a wall.</p></td> </tr> <tr> <td>t</td> <td><p align="justify">Throw an object. This is a prefix command. Follow it with a direction and you throw an object in the specified direction. (e.g. type "th" to throw something left.)</p></td> </tr> <tr> <td>></td> <td><p align="justify">If you are standing over the passage down to the next level, this command means to climb down.</p></td> </tr> <tr> <td>s</td> <td><p align="justify">Search for traps and secret doors. Examine each space immediately adjacent to you for the existence of a trap or secret door. There is a large chance that even if there is something there, you won’t find it so you might have to search a while before you find something.</p></td> </tr> <tr> <td> </td> <td><p align="justify">(space) Rest. This is the "do nothing" command. This is good for waiting and healing.</p></td> </tr> <tr> <td align="left" valign="top"> <p>i</td> <td align="justify"> <p>Inventory. List what you are carrying in your pack.</td> </tr> <tr> <td>I</td> <td><p align="justify">Selective inventory. Tells you what a single item in your pack is.</p></td> </tr> <tr> <td>q</td> <td><p align="justify">Quaff. Drink one of the potions you are carrying.</p></td> </tr> <tr> <td>r</td> <td><p align="justify">Read. Read one of the scrolls in your pack.</p></td> </tr> <tr> <td>e</td> <td><p align="justify">Eat food. Take some food out of your pack and eat it.</p></td> </tr> <tr> <td>w</td> <td><p align="justify">Wield a weapon. Take a weapon out of your pack and carry it. You must be wielding weapon to use it (except to throw things). To fire an arrow, you must wield the bow. You can only wield one weapon at a time.</p></td> </tr> <tr> <td>W</td> <td><p align="justify">Wear armor. Take a piece of armor out of your pack and put it on. You can only wear one suit of armor at a time.</td> </tr> <tr> <td>T</td> <td><p align="justify">Take armor off. You can’t remove armor that is cursed. This takes extra time.</p></td> </tr> <tr> <td>d</td> <td><p align="justify">Drop an object. Take something out of your pack and leave it lying on the floor. Only one object can occupy each space.</p></td> </tr> <tr> <td>o</td> <td><p align="justify">Examine and set options. This command is further explained in the section on options.</p></td> </tr> <tr> <td>^L</td> <td><p align="justify">Redraws the screen. Useful if spurious messages or transmission errors have messed up the display.</p></td> </tr> <tr> <td>v</td> <td><p align="justify">Prints the program version number.</p></td> </tr> <tr> <td>Q</td> <td><p align="justify">Quit. Leave the game.</p></td> </tr> <tr> <td>R</td> <td><p align="justify">Repeat last message. Useful when a message disappears before you can read it.</p></td> </tr> <tr> <td>S</td> <td><p align="justify">Save the current game in a file. Caveat: Rogue won’t let you start up a copy of a saved game, and it removes the save file as soon as you start up a restored game. This is to prevent people from saving a game just before a dangerous position and then restarting it if they die. To restore a saved game, give the file name as an argument to rogue. As in % rogue36 save_file</p></td> </tr></table></div><h2 align="justify"><b>5. Dealing with objects</b></h2><p align="justify">When you find something in the dungeon, it is common towant to pick the object up. This is accomplished in rogue bywalking over the object. If you are carrying too manythings, the program will tell you and it won’t pick upthe object, otherwise it will add it to your pack and if thenotify option is set, tell you what you just picked up.</p><p align="justify">Many of the commands that operate on objects must promptyou to find out which object you want to use. If you changeyour mind and don’t want to do that command after all,just press an escape and the command will be aborted.</p><h2 align="justify"><b>6. Light</b></h2><p align="justify">Rooms in the dungeons are either lit or dark. If youwalk into a lit room, the entire room will be drawn on thescreen as soon as you enter. If you walk into a dark room,it will only be displayed as you explore it. Upon leaving adark room, all objects inside the room which might move areremoved from the screen. In the darkness you can only seeone space in all directions around you.</p><h2 align="justify"><b>7. Fighting</b></h2><p align="justify">If you see a monster and you wish to fight it, justattempt to run into it. Many times a monster you find willmind its own business unless you attack it. It is often thecase that discretion is the better part of valor.</p><h2 align="justify">8<b>. Armor</b></h2><p align="justify">There are various sorts of armor lying around in thedungeon. Some of it is enchanted, some is cursed and some isjust normal. Different armor types have different armorclasses. The lower the armor class, the more protection thearmor affords against the blows of monsters. If a piece ofarmor is enchanted or cursed, its armor class will be higheror lower than normal. Here is a list of the various armortypes and their normal armor class.</p><div align="center"> <table border="1" cellspacing="3" cellpadding="3" id="table4" style="border-collapse: collapse"> <tr> <th><i>Type</i></th> <th><i>Class</i></th> </tr> <tr> <td>Leather armor</td> <td align="center">8</td> </tr> <tr> <td>Studded leather / Ring mail</td> <td align="center">7</td> </tr> <tr> <td>Scale mail </td> <td align="center">6</td> </tr> <tr> <td>Chain mail </td> <td align="center">5</td> </tr> <tr> <td>Banded mail / Splint mail</td> <td align="center">4</td> </tr> <tr> <td>Plate mail</td> <td align="center">3</td> </tr> </table></div><h2 align="justify">9<b>. Options</b></h2><p align="justify">Due to variations in personal tastes and conceptions ofthe way rogue should do things, there are a set of optionsyou can set that cause rogue to behave in various differentways.</p><h3 align="justify"><b>9.1 Setting the options</b></h3><p align="justify">There are basically two ways to set the options. Thefirst is with the "o" command of rogue, the secondis with the ROGUEOPTS environment variable. On Version 6systems, there is no equivalent of the ROGUEOPTSfeature.</p><h3 align="justify"><b>9.1.1. Using the "o" command</b></h3><p align="justify">When you press "o" in rogue, it clears thescreen and displays the current settings for all theoptions. It then places the cursor by the value of the firstoption and waits for you to type. You can type a RETURNwhich means to go to the next option, a "−"which means to go to the previous option, an escape whichmeans to return to the game, or you can give the option avalue. For boolean options this merely involves pressing"t" for true or "f" for false. Forstring options, type the new value followed by a return.</p><h3 align="justify">9<b>.1.2. Using the ROGUEOPTS variable</b></h3><p align="justify">The ROGUEOPTS variable is a string containing a commaseparated list of initial values for the various options.Boolean variables can be turned on by listing their name andturned off by putting a "no" in front of the name.Thus to set up an environment variable so that jump is on,terse is off, the name is set to "Conan theBarbarian" and the fruit is "mango", use thecommand</p><div align="justify"><pre> % setenv ROGUEOPTS "jump,noterse,name=Conan the Barbarian,fruit=mango"<sup>3</sup></pre></div><h3 align="justify"><b>9.2. Option list</b></h3><p align="justify">Here is a list of the options and an explanation of whateach one is for. The default value for each is enclosed insquare brackets.</p><p align="justify"><b>terse</b>[<i>noterse</i>]</p><blockquote> <p align="justify"> Useful for those who are tired of the sometimes lengthy messages of rogue. This is a useful option for those on slow terminals. This option defaults to on if your are on a slow (under 1200 baud) terminal.</p></blockquote><p align="justify"><b>jump</b>[<i>nojump</i>]</p><blockquote> <p align="justify">If this option is set, running moves will not be displayed until you reach the end of the move. This saves considerable cpu time and display time. This option defaults to on if you are using a slow terminal.</p></blockquote><p align="justify"><b>step</b>[<i>nostep</i>]</p><blockquote> <p align="justify">When step is set, lists of things, like inventories or "*" responses to "Which item do you wish to xxxx? " questions, are displayed one item at a time on the top of the screen, rather than clearing the screen, displaying the list, then re-displaying the dungeon level.</p></blockquote><p align="justify"><b>flush</b>[<i>noflush</i>]</p><blockquote> <p align="justify">If flush is set, all typeahead is thrown away after each round of battle. This is useful for those who type way ahead and watch to their dismay as a Kobold kills them.</p></blockquote><p align="justify"><b>askme</b>[<i>noaskme</i>]</p><blockquote> <p align="justify">Upon reading a scroll or quaffing a potion which does not automatically identify it upon use, rogue will ask you what to name it so you can recognize it in the future.</p></blockquote><p align="justify"><b>name</b> [account name]</p><blockquote> <p align="justify">This is the name of your character. It is used if you get on the top ten scorer’s list. It should be less than eighty characters long.</p></blockquote><p align="justify"><b>fruit</b>[<i>slime-mold</i>]</p><blockquote> <p align="justify">This should hold the name of a fruit that you enjoy eating. It is basically a whimsy that the program uses in a couple of places.</p></blockquote><p align="justify"><b>file</b>[<i>rogue3.save</i>]</p><blockquote> <p align="justify">The default file name for saving the game. If your phone is hung up by accident, rogue will automatically save the game in this file. The file name may contain the special character "~" which expands to be your home directory.</p></blockquote><h2 align="justify"><br><b>10. Acknowledgements</b></h2><p align="justify">Rogue was originally conceived of by Glenn Wichman andMichael Toy. The help of Ken Arnold in making the programeasier to use and putting the finishing touches on isgreatly appreciated. I would also like to thank MartyMcNary, Scott Nelson, Daniel Jensen, Kipp Hickman, JoeKalash, Steve Maurer, Bill Joy, Mark Horton and Jan Millerfor their ideas and assistance.</p><table border="0" width="100%" cellspacing="3" cellpadding="0" id="table5"> <tr> <td align="center"><sup>1</sup></td> <td>As opposed to pseudo English sentences.</td> </tr> <tr> <td align="center"><sup>2</sup></td> <td>Or until you get killed or decide to quit.</td> </tr> <tr> <td align="center"><sup>3</sup> </td> <td><p>For those of you who use the Bourne shell, the commands would be</p><pre> $ ROGUEOPTS="jump,noterse,name=Conan the Barbarian,fruit=mango" $ export ROGUEOPTS</pre> </td> </tr></table></body></html>