From: Eric S. Raymond Date: Sat, 10 Mar 2018 22:58:46 +0000 (-0500) Subject: Fix for GitLab issue #40: Inconsistant inventory space X-Git-Tag: 1.5~7 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=6de0149f9e33a170c8ceb28466d3221be230fb96 Fix for GitLab issue #40: Inconsistant inventory space --- diff --git a/misc.c b/misc.c index aa16472..679c2c8 100644 --- a/misc.c +++ b/misc.c @@ -585,7 +585,9 @@ void carry(obj_t object, loc_t where) if (game.place[object] == CARRIED) return; game.place[object] = CARRIED; - ++game.holdng; + + if (object!= BIRD) + ++game.holdng; } if (game.atloc[where] == object) { game.atloc[where] = game.link[object]; @@ -606,7 +608,14 @@ void drop(obj_t object, loc_t where) game.fixed[object - NOBJECTS] = where; else { if (game.place[object] == CARRIED) - --game.holdng; + if (object != BIRD) + /* The bird has to be weightless. This ugly hack (and the + * corresponding code in the drop function) brought to you + * by the fact that when the bird is caged, we need to be able + * to either 'take bird' or 'take cage' and have the right thing + * happen. + */ + --game.holdng; game.place[object] = where; } if (where == LOC_NOWHERE || diff --git a/tests/birdweight.chk b/tests/birdweight.chk new file mode 100644 index 0000000..0df99e6 --- /dev/null +++ b/tests/birdweight.chk @@ -0,0 +1,464 @@ + +Welcome to Adventure!! Would you like instructions? + +> n + +You are standing at the end of a road before a small brick building. +Around you is a forest. A small stream flows out of the building and +down a gully. + +> seed 976729036 + +Seed set to 976729036 + +You're in front of building. + +> in + +You are inside a building, a well house for a large spring. + +There are some keys on the ground here. + +There is a shiny brass lamp nearby. + +There is food here. + +There is a bottle of water here. + +> take lamp + +OK + +> take food + +OK + +> take bottle + +OK + +> inventory + +You are currently holding the following: +Brass lantern +Tasty food +Small bottle +Water in the bottle + +> out + +You're in front of building. + +> s + +You are in a valley in the forest beside a stream tumbling along a +rocky bed. + +> w + +You are wandering aimlessly through the forest. + +> n + +You are wandering aimlessly through the forest. + +Your keen eye spots a severed leporine appendage lying on the ground. + +> take appendage + +OK + +> s + +You are wandering aimlessly through the forest. + +> s + +You're in valley. + +> n + +You're in front of building. + +> in + +You're inside building. + +There are some keys on the ground here. + +> xyzzy + +>>Foof!<< + +It is now pitch dark. If you proceed you will likely fall into a pit. + +> on + +Your lamp is now on. + +You are in a debris room filled with stuff washed in from the surface. +A low wide passage with cobbles becomes plugged with mud and debris +here, but an awkward canyon leads upward and west. In the mud someone +has scrawled, "MAGIC WORD XYZZY". + +A three foot black rod with a rusty star on an end lies nearby. + +> e + +You are crawling over cobbles in a low passage. There is a dim light +at the east end of the passage. + +There is a small wicker cage discarded nearby. + +> take cage + +OK + +> w + +You're in debris room. + +A three foot black rod with a rusty star on an end lies nearby. + +> w + +You are in an awkward sloping east/west canyon. + +> w + +You are in a splendid chamber thirty feet high. The walls are frozen +rivers of orange stone. An awkward canyon and a good passage exit +from east and west sides of the chamber. + +A cheerful little bird is sitting here singing. + +> take bird + +OK + +> e + +You are in an awkward sloping east/west canyon. + +> e + +You're in debris room. + +A three foot black rod with a rusty star on an end lies nearby. + +> take rod + +OK + +> w + +You are in an awkward sloping east/west canyon. + +> w + +You're in bird chamber. + +> w + +At your feet is a small pit breathing traces of white mist. An east +passage ends here except for a small crack leading on. + +Rough stone steps lead down the pit. + +> d + +You are at one end of a vast hall stretching forward out of sight to +the west. There are openings to either side. Nearby, a wide stone +staircase leads downward. The hall is filled with wisps of white mist +swaying to and fro almost as if alive. A cold wind blows up the +staircase. There is a passage at the top of a dome behind you. + +Rough stone steps lead up the dome. + +> inventory + +You are currently holding the following: +Brass lantern +Wicker cage +Black rod +Little bird in cage +Tasty food +Small bottle +Water in the bottle +Leporine appendage + +> w + +You are on the east bank of a fissure slicing clear across the hall. +The mist is quite thick here, and the fissure is too wide to jump. + +> wave rod + +The bird flies agitatedly about the cage. + +A crystal bridge now spans the fissure. + +> drop rod + +OK + +> e + +You're in Hall of Mists. + +Rough stone steps lead up the dome. + +> s + +This is a low room with a crude note on the wall. The note says, +"You won't get it up the steps". + +There is a large sparkling nugget of gold here! + +> take gold + +OK + +> n + +You're in Hall of Mists. + +> w + +You're on east bank of fissure. + +A three foot black rod with a rusty star on an end lies nearby. + +A crystal bridge spans the fissure. + +> w + +You are on the west side of the fissure in the Hall of Mists. + +There are diamonds here! + +A crystal bridge spans the fissure. + +> drop gold + +OK + +> take diamonds + +OK + +> w + +You are at the west end of the Hall of Mists. A low wide crawl +continues west and another goes north. To the south is a little +passage 6 feet off the floor. + +> w + +You are at the east end of a very long hall apparently without side +chambers. To the east a low wide crawl slants up. To the north a +round two foot hole slants down. + +> w + +You are at the west end of a very long featureless hall. The hall +joins up with a narrow north/south passage. + +> inventory + +You are currently holding the following: +Brass lantern +Wicker cage +Little bird in cage +Tasty food +Small bottle +Water in the bottle +Leporine appendage +Several diamonds + +> s + +You are in a maze of twisty little passages, all different. + +> sw + +You are in a little maze of twisty passages, all different. + +> se + +You are in a little maze of twisting passages, all different. + +> s + +A little dwarf just walked around a corner, saw you, threw a little +axe at you which missed, cursed, and ran away. + +Dead end + +There is a little axe here. + +There is a massive and somewhat battered vending machine here. The +instructions on it read: "Drop coins here to receive fresh batteries." + +> drop food + +OK + +> drop water + +OK + +> take axe + +OK + +> kill machine + +As you strike the vending machine, it pivots backward along with a +section of wall, revealing a dark passage leading south. + +> s + +You are in a long, rough-hewn, north/south corridor. + +> s + +You are in a large chamber with passages to the west and north. + +A formidable ogre bars the northern exit. + +> drop diamonds + +OK + +> w + +You are in a long, rough-hewn, north/south corridor. + +> w + +There is no way to go that direction. + +You are in a long, rough-hewn, north/south corridor. + +> n + +Dead end + +There is a bottle of water here. + +There is food here. + +There is a massive vending machine here, swung back to reveal a +southward passage. + +> n + +You are in a little maze of twisting passages, all different. + +> n + +You are in a little maze of twisty passages, all different. + +> nw + +You are in a maze of twisty little passages, all different. + +> d + +You're at west end of long hall. + +> e + +You're at east end of long hall. + +> e + +You're at west end of Hall of Mists. + +> e + +You're on west bank of fissure. + +There is a large sparkling nugget of gold here! + +A crystal bridge spans the fissure. + +> take gold + +OK + +> w + +You're at west end of Hall of Mists. + +> w + +You're at east end of long hall. + +> w + +You're at west end of long hall. + +> s + +You are in a maze of twisty little passages, all different. + +> sw + +You are in a little maze of twisty passages, all different. + +> se + +You are in a little maze of twisting passages, all different. + +> s + +Dead end + +There is a bottle of water here. + +There is food here. + +There is a massive vending machine here, swung back to reveal a +southward passage. + +> take bottle + +OK + +> take food + +OK + +> s + +You are in a long, rough-hewn, north/south corridor. + +> s + +You are in a large chamber with passages to the west and north. + +There are diamonds here! + +A formidable ogre bars the northern exit. + +> throw appendage + +OK + +> kill ogre + +The ogre, who despite his bulk is quite agile, easily dodges your +attack. He seems almost amused by your puny effort. + +> take appendage + +OK + + +You scored 61 out of a possible 430, using 81 turns. + +Your score qualifies you as a novice class adventurer. + +To achieve the next higher rating, you need 60 more points. diff --git a/tests/birdweight.log b/tests/birdweight.log new file mode 100644 index 0000000..bc07eb6 --- /dev/null +++ b/tests/birdweight.log @@ -0,0 +1,87 @@ +## Verify that the bird is weightless in inventory +# Checks fix for GitLab issue #40 +n +#seed 687800971 +seed 976729036 +in +take lamp +take food +take bottle +inventory +out +s +w +n +take appendage +s +s +n +in +xyzzy +on +e +take cage +w +w +w +take bird +e +e +take rod +w +w +w +d +inventory +w +wave rod +drop rod +e +s +take gold +n +w +w +drop gold +take diamonds +w +w +w +inventory +s +sw +se +s +drop food +drop water +take axe +kill machine +s +s +drop diamonds +w +w +n +# Back at vending machine +n +n +nw +d +e +e +e +take gold +w +w +w +s +sw +se +s +take bottle +take food +s +s +throw appendage +kill ogre +take appendage