From: Eric S. Raymond Date: Fri, 7 Apr 2023 17:19:51 +0000 (-0400) Subject: Refactor put() function and calls. X-Git-Tag: 1.16~14 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=9cd7c53d789a8a3bc845ff8f6b0e6b46af631627;p=open-adventure.git Refactor put() function and calls. --- diff --git a/advent.h b/advent.h index 62a54ac..55d1b82 100644 --- a/advent.h +++ b/advent.h @@ -276,7 +276,7 @@ extern bool silent_yes_or_no(void); extern bool yes_or_no(const char*, const char*, const char*); extern void juggle(obj_t); extern void move(obj_t, loc_t); -extern loc_t put(obj_t, loc_t, int); +extern void put(obj_t, loc_t, int); extern void carry(obj_t, loc_t); extern void drop(obj_t, loc_t); extern int atdwrf(loc_t); diff --git a/main.c b/main.c index 981e4d4..a740b42 100644 --- a/main.c +++ b/main.c @@ -863,12 +863,12 @@ static bool closecheck(void) * objects he might be carrying (lest he have some which * could cause trouble, such as the keys). We describe the * flash of light and trundle back. */ - game.objects[BOTTLE].prop = put(BOTTLE, LOC_NE, EMPTY_BOTTLE); - game.objects[PLANT].prop = put(PLANT, LOC_NE, PLANT_THIRSTY); - game.objects[OYSTER].prop = put(OYSTER, LOC_NE, STATE_FOUND); - game.objects[LAMP].prop = put(LAMP, LOC_NE, LAMP_DARK); - game.objects[ROD].prop = put(ROD, LOC_NE, STATE_FOUND); - game.objects[DWARF].prop = put(DWARF, LOC_NE, 0); + put(BOTTLE, LOC_NE, EMPTY_BOTTLE); + put(PLANT, LOC_NE, PLANT_THIRSTY); + put(OYSTER, LOC_NE, STATE_FOUND); + put(LAMP, LOC_NE, LAMP_DARK); + put(ROD, LOC_NE, STATE_FOUND); + put(DWARF, LOC_NE, 0); game.loc = LOC_NE; game.oldloc = LOC_NE; game.newloc = LOC_NE; @@ -877,13 +877,13 @@ static bool closecheck(void) move(GRATE, LOC_SW); move(SIGN, LOC_SW); game.objects[SIGN].prop = ENDGAME_SIGN; - game.objects[SNAKE].prop = put(SNAKE, LOC_SW, SNAKE_CHASED); - game.objects[BIRD].prop = put(BIRD, LOC_SW, BIRD_CAGED); - game.objects[CAGE].prop = put(CAGE, LOC_SW, STATE_FOUND); - game.objects[ROD2].prop = put(ROD2, LOC_SW, STATE_FOUND); - game.objects[PILLOW].prop = put(PILLOW, LOC_SW, STATE_FOUND); + put(SNAKE, LOC_SW, SNAKE_CHASED); + put(BIRD, LOC_SW, BIRD_CAGED); + put(CAGE, LOC_SW, STATE_FOUND); + put(ROD2, LOC_SW, STATE_FOUND); + put(PILLOW, LOC_SW, STATE_FOUND); - game.objects[MIRROR].prop = put(MIRROR, LOC_NE, STATE_FOUND); + put(MIRROR, LOC_NE, STATE_FOUND); game.objects[MIRROR].fixed = LOC_SW; for (int i = 1; i <= NOBJECTS; i++) { diff --git a/misc.c b/misc.c index b8bc461..8889941 100644 --- a/misc.c +++ b/misc.c @@ -595,12 +595,12 @@ void move(obj_t object, loc_t where) drop(object, where); } -loc_t put(obj_t object, loc_t where, int pval) +void put(obj_t object, loc_t where, int pval) /* put() is the same as move(), except it returns a value used to set up the * negated game.prop values for the repository objects. */ { move(object, where); - return (-1) - pval;; // Needs to stay sinchronized with STASHED + game.objects[object].prop = (-1) - pval;; // Needs to stay synchronized with STASHED } void carry(obj_t object, loc_t where)