From: NHOrus Date: Wed, 5 Jul 2017 17:23:34 +0000 (+0300) Subject: Moved state_change to misc.c to start using it in main.c, too X-Git-Tag: takebird~7 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F215%2Fhead;p=open-adventure.git Moved state_change to misc.c to start using it in main.c, too --- diff --git a/actions.c b/actions.c index 2ac545c..f73fa5c 100644 --- a/actions.c +++ b/actions.c @@ -6,13 +6,6 @@ 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, diff --git a/advent.h b/advent.h index 45b1c0c..470e79f 100644 --- 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 void state_change(long obj, long state); + void bug(enum bugtype, const char *) __attribute__((__noreturn__)); diff --git a/adventure.yaml b/adventure.yaml index 4338eb3..c816099 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -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.' -- 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!' @@ -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.' + 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' diff --git a/main.c b/main.c index 5edcc75..59bb4e1 100644 --- a/main.c +++ b/main.c @@ -726,8 +726,7 @@ static void playermove( int motion) 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; diff --git a/misc.c b/misc.c index a2626b4..b4869d8 100644 --- a/misc.c +++ b/misc.c @@ -689,3 +689,10 @@ void bug(enum bugtype num, const char *error_string) // 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