Mercurial > hg > early-roguelike
annotate arogue7/eat.c @ 297:317166b49d8a
Ultra-Rogue: add a NULL check.
| author | John "Elwin" Edwards | 
|---|---|
| date | Thu, 08 Feb 2018 18:56:15 -0500 | 
| parents | f9ef86cf22b2 | 
| children | 
| rev | line source | 
|---|---|
| 125 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 1 /* | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 2 * eat.c - Functions for dealing with digestion | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 3 * | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 4 * Advanced Rogue | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 6 * All rights reserved. | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 7 * | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 8 * Based on "Rogue: Exploring the Dungeons of Doom" | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 10 * All rights reserved. | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 11 * | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 12 * See the file LICENSE.TXT for full copyright and licensing information. | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 13 */ | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 14 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 15 #include "curses.h" | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 16 #include "rogue.h" | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 17 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 18 /* | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 19 * eat: | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 20 * He wants to eat something, so let him try | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 21 */ | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 22 | 
| 219 
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
 John "Elwin" Edwards parents: 
125diff
changeset | 23 void | 
| 
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
 John "Elwin" Edwards parents: 
125diff
changeset | 24 eat(void) | 
| 125 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 25 { | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 26 register struct linked_list *item; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 27 int which; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 28 unsigned long temp; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 29 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 30 if (player.t_action != C_EAT) { | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 31 if ((item = get_item(pack, "eat", FOOD, FALSE, FALSE)) == NULL) | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 32 return; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 33 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 34 player.t_using = item; /* Remember what it is */ | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 35 player.t_action = C_EAT; /* We are eating */ | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 36 which = (OBJPTR(item))->o_which; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 37 player.t_no_move = max(foods[which].mi_food/100, 1) * movement(&player); | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 38 return; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 39 } | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 40 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 41 /* We have waited our time, let's eat the food */ | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 42 item = player.t_using; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 43 player.t_using = NULL; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 44 player.t_action = A_NIL; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 45 | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 46 which = (OBJPTR(item))->o_which; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 47 if ((food_left += foods[which].mi_food) > STOMACHSIZE) | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
changeset | 48 food_left = STOMACHSIZE; | 
| 
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
 John "Elwin" Edwards parents: diff
chan | 
