Cleared up lock/unlock logic
authorNHOrus <jy6x2b32pie9@yahoo.com>
Thu, 6 Jul 2017 07:12:55 +0000 (10:12 +0300)
committerNHOrus <jy6x2b32pie9@yahoo.com>
Thu, 6 Jul 2017 07:12:55 +0000 (10:12 +0300)
actions.c

index cb5a119cc0cca8c71a9675e10aca53ca192d3b3b..159a71cb7af3d3a7466bba04a4c70140e3f90b36 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -932,29 +932,29 @@ static int lock(token_t verb, obj_t obj)
 
     /*  Lock, unlock object.  Special stuff for opening clam/oyster
      *  and for chain. */
-    if (obj == GRATE ||
-        obj == CHAIN) {
+
+    switch (obj) {
+    case CHAIN:
+        if (HERE(KEYS)) {
+            return chain(verb);
+        } else
+            rspeak(NO_KEYS);
+        break;
+    case GRATE:
         if (HERE(KEYS)) {
-            if (obj == CHAIN)
-                return chain(verb);
             if (game.closng) {
                 rspeak(EXIT_CLOSED);
                 if (!game.panic)
                     game.clock2 = PANICTIME;
                 game.panic = true;
-                return GO_CLEAROBJ ;
             } else {
                 state_change(GRATE, (verb == LOCK) ?
                              GRATE_CLOSED :
                              GRATE_OPEN);
-                return GO_CLEAROBJ;
             }
-        }
-        rspeak(NO_KEYS);
-        return GO_CLEAROBJ;
-    }
-
-    switch (obj) {
+        } else
+            rspeak(NO_KEYS);
+        break;
     case CLAM:
         if (verb == LOCK)
             rspeak(HUH_MAN);
@@ -966,14 +966,13 @@ static int lock(token_t verb, obj_t obj)
             drop(PEARL, LOC_CULDESAC);
             rspeak(PEARL_FALLS);
         }
-        return GO_CLEAROBJ;
+        break;
     case OYSTER:
         if (verb == LOCK)
             rspeak(HUH_MAN);
         else
             rspeak(OYSTER_OPENER);
-
-        return GO_CLEAROBJ;
+        break;
     case DOOR:
         rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
         break;