Moved state_change to misc.c to start using it in main.c, too 215/head
authorNHOrus <jy6x2b32pie9@yahoo.com>
Wed, 5 Jul 2017 17:23:34 +0000 (20:23 +0300)
committerNHOrus <jy6x2b32pie9@yahoo.com>
Wed, 5 Jul 2017 17:23:34 +0000 (20:23 +0300)
actions.c
advent.h
adventure.yaml
main.c
misc.c

index 2ac545c726e699bcd60065f11948ac95c613b73a..f73fa5c29c69baf907255998d3d2b3821c5ec0e3 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -6,13 +6,6 @@
 
 static int fill(token_t, token_t);
 
 
 static int fill(token_t, token_t);
 
-static void state_change(long obj, long state)
-/* Object must have a change-message list for this to be useful; only some do */
-{
-    game.prop[obj] = state;
-    pspeak(obj, change, state, true);
-}
-
 static int attack(struct command_t *command)
 /*  Attack.  Assume target if unambiguous.  "Throw" also links here.
  *  Attackable objects fall into two categories: enemies (snake,
 static int attack(struct command_t *command)
 /*  Attack.  Assume target if unambiguous.  "Throw" also links here.
  *  Attackable objects fall into two categories: enemies (snake,
index 45b1c0c034256834de840433552860e28d1940e9..470e79ff5879d1a369dd30e308cf6f06a9d29789 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -242,6 +242,8 @@ extern int resume(void);
 extern int restore(FILE *);
 extern long initialise(void);
 extern int action(struct command_t *command);
 extern int restore(FILE *);
 extern long initialise(void);
 extern int action(struct command_t *command);
+extern void state_change(long obj, long state);
+
 
 void bug(enum bugtype, const char *) __attribute__((__noreturn__));
 
 
 void bug(enum bugtype, const char *) __attribute__((__noreturn__));
 
index 4338eb33fb20742bfc0899357fe8ef8ee7d9d4b7..c816099f83c36590d7c0e823510bc9dc3af3f937 100644 (file)
@@ -2963,11 +2963,6 @@ arbitrary_messages:  !!omap
 - TROLL_SATISFIED: 'The troll catches your treasure and scurries away out of sight.'
 - TROLL_BLOCKS: 'The troll refuses to let you cross.'
 - BRIDGE_GONE: 'There is no longer any way across the chasm.'
 - TROLL_SATISFIED: 'The troll catches your treasure and scurries away out of sight.'
 - TROLL_BLOCKS: 'The troll refuses to let you cross.'
 - BRIDGE_GONE: 'There is no longer any way across the chasm.'
-- BRIDGE_COLLAPSE: |-
-    Just as you reach the other side, the bridge buckles beneath the
-    weight of the bear, which was still following you around.  You
-    scrabble desperately for support, but as the bridge collapses you
-    stumble back and fall into the chasm.
 - BEAR_HANDS: 'With what?  Your bare hands?  Against *HIS* bear hands??'
 - BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.'
 - ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!'
 - BEAR_HANDS: 'With what?  Your bare hands?  Against *HIS* bear hands??'
 - BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.'
 - ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!'
@@ -3497,6 +3492,13 @@ objects: !!omap
     descriptions:
     - 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist.  A notice posted on the bridge reads, "Stop! Pay troll!"'
     - 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.'
     descriptions:
     - 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist.  A notice posted on the bridge reads, "Stop! Pay troll!"'
     - 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.'
+    changes:
+    - ''
+    - |- 
+        Just as you reach the other side, the bridge buckles beneath the
+        weight of the bear, which was still following you around.  You
+        scrabble desperately for support, but as the bridge collapses you
+        stumble back and fall into the chasm.
 - TROLL:
     words: ['troll']
     inventory: '*troll'
 - TROLL:
     words: ['troll']
     inventory: '*troll'
diff --git a/main.c b/main.c
index 5edcc755389d593929cfac3da0eac26cefb37aa6..59bb4e1fcf5126b76b0f2be2101843a8fd4f402a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -726,8 +726,7 @@ static void playermove( int motion)
                             game.prop[TROLL] = TROLL_PAIDONCE;
                         if (!TOTING(BEAR))
                             return;
                             game.prop[TROLL] = TROLL_PAIDONCE;
                         if (!TOTING(BEAR))
                             return;
-                        rspeak(BRIDGE_COLLAPSE);
-                        game.prop[CHASM] = BRIDGE_WRECKED;
+                        state_change(CHASM, BRIDGE_WRECKED);
                         game.prop[TROLL] = TROLL_GONE;
                         drop(BEAR, game.newloc);
                         game.fixed[BEAR] = IS_FIXED;
                         game.prop[TROLL] = TROLL_GONE;
                         drop(BEAR, game.newloc);
                         game.fixed[BEAR] = IS_FIXED;
diff --git a/misc.c b/misc.c
index a2626b4d3f02ae66ea69ed4dbf99c4c1939debe0..b4869d8568d4f2ac5b46b4b25caac491eccde1af 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -689,3 +689,10 @@ void bug(enum bugtype num, const char *error_string)
 // LCOV_EXCL_STOP
 
 /* end */
 // LCOV_EXCL_STOP
 
 /* end */
+
+void state_change(long obj, long state)
+/* Object must have a change-message list for this to be useful; only some do */
+{
+    game.prop[obj] = state;
+    pspeak(obj, change, state, true);
+}
\ No newline at end of file