X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=misc.c;h=679c2c87505ecfb5f1a451e80988ec7a2394ad66;hp=302e61cc641d4faeac7b176839ddd2aa05cac9a1;hb=6d9481130bc122dd1fa0815cb22fe0df38d6e56b;hpb=9e2cb3c19196a26af8e20803314f42b69dc0e014 diff --git a/misc.c b/misc.c index 302e61c..679c2c8 100644 --- a/misc.c +++ b/misc.c @@ -1,3 +1,11 @@ +/* + * I/O and support riutines. + * + * Copyright (c) 1977, 2005 by Will Crowther and Don Woods + * Copyright (c) 2017 by Eric S. Raymond + * SPDX-License-Identifier: BSD-2-clause + */ + #include #include #include @@ -577,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]; @@ -598,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 || @@ -646,8 +663,10 @@ bool tstbit(long mask, int bit) void set_seed(int32_t seedval) /* Set the LCG seed */ { - game.lcg_x = (uint32_t) seedval % LCG_M; - + game.lcg_x = seedval % LCG_M; + if (game.lcg_x < 0) { + game.lcg_x = LCG_M + game.lcg_x; + } // once seed is set, we need to generate the Z`ZZZ word for (int i = 0; i < 5; ++i) { game.zzword[i] = 'A' + randrange(26);