From e91742e1b9ff7715ba47f7354f8d8803b11a5df9 Mon Sep 17 00:00:00 2001 From: NHOrus Date: Sun, 2 Jul 2017 16:27:20 +0300 Subject: [PATCH] Fixed regression in #21 Cleaned up logic of light/extinguish --- actions.c | 18 ++++++++++-------- tests/urntest.chk | 10 +++++----- tests/urntest.log | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/actions.c b/actions.c index ae46321..51a3f59 100644 --- a/actions.c +++ b/actions.c @@ -523,13 +523,12 @@ static int eat(token_t verb, token_t obj) static int extinguish(token_t verb, int obj) /* Extinguish. Lamp, urn, dragon/volcano (nice try). */ { - int spk = actions[verb].message; if (obj == INTRANSITIVE) { if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT) obj = LAMP; if (HERE(URN) && game.prop[URN] == URN_LIT) - obj = obj * NOBJECTS + URN; - if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) + obj = URN; + if (obj == INTRANSITIVE) return GO_UNKNOWN; } @@ -539,13 +538,16 @@ static int extinguish(token_t verb, int obj) } else { pspeak(URN, change, URN_DARK); } - return GO_CLEAROBJ; + } else if (obj == LAMP) { state_change(LAMP, LAMP_DARK); - spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE; - } else if (obj == DRAGON || obj == VOLCANO) - spk = BEYOND_POWER; - rspeak(spk); + rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE); + } else if (obj == DRAGON || obj == VOLCANO) { + rspeak(BEYOND_POWER); + + } else { + rspeak(actions[verb].message); + } return GO_CLEAROBJ; } diff --git a/tests/urntest.chk b/tests/urntest.chk index 90ae17c..8beba1b 100644 --- a/tests/urntest.chk +++ b/tests/urntest.chk @@ -2013,7 +2013,7 @@ A small oil flame extrudes from an urn embedded in the rock. > extinguish -I'm afraid I don't understand. +The urn is now dark. > look @@ -2023,11 +2023,11 @@ long description of your location. The forest thins out here to reveal a steep cliff. There is no way down, but a small ledge can be seen to the west across the chasm. -A small oil flame extrudes from an urn embedded in the rock. +A small urn full of oil is embedded in the rock. -> extinguish urn +> light -The urn is now dark. +The urn is now lit. > look @@ -2037,7 +2037,7 @@ long description of your location. The forest thins out here to reveal a steep cliff. There is no way down, but a small ledge can be seen to the west across the chasm. -A small urn full of oil is embedded in the rock. +A small oil flame extrudes from an urn embedded in the rock. > extinguish urn diff --git a/tests/urntest.log b/tests/urntest.log index 48c9836..4cd8c31 100644 --- a/tests/urntest.log +++ b/tests/urntest.log @@ -344,7 +344,7 @@ read urn look extinguish look -extinguish urn +light look extinguish urn look -- 2.31.1