More magic number elimination
This commit is contained in:
parent
fbc80f0363
commit
8fcbc8ecba
2 changed files with 32 additions and 33 deletions
55
actions.c
55
actions.c
|
@ -24,7 +24,7 @@ static int attack(struct command_t *command)
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
}
|
}
|
||||||
long spk = actions[verb].message;
|
long spk = actions[verb].message;
|
||||||
if (obj == 0 || obj == INTRANSITIVE) {
|
if (obj == NO_OBJECT || obj == INTRANSITIVE) {
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
if (atdwrf(game.loc) > 0) {
|
if (atdwrf(game.loc) > 0) {
|
||||||
obj = DWARF;
|
obj = DWARF;
|
||||||
|
@ -51,7 +51,7 @@ static int attack(struct command_t *command)
|
||||||
++changes;
|
++changes;
|
||||||
}
|
}
|
||||||
/* check for low-priority targets */
|
/* check for low-priority targets */
|
||||||
if (obj == 0) {
|
if (obj == NO_OBJECT) {
|
||||||
/* Can't attack bird or machine by throwing axe. */
|
/* Can't attack bird or machine by throwing axe. */
|
||||||
if (HERE(BIRD) && verb != THROW) {
|
if (HERE(BIRD) && verb != THROW) {
|
||||||
obj = BIRD;
|
obj = BIRD;
|
||||||
|
@ -85,7 +85,7 @@ static int attack(struct command_t *command)
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj == 0)
|
if (obj == NO_OBJECT)
|
||||||
spk = NO_TARGET;
|
spk = NO_TARGET;
|
||||||
if (obj == CLAM || obj == OYSTER)
|
if (obj == CLAM || obj == OYSTER)
|
||||||
spk = SHELL_IMPERVIOUS;
|
spk = SHELL_IMPERVIOUS;
|
||||||
|
@ -460,8 +460,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj == BEAR && AT(TROLL)) {
|
} else if (obj == BEAR && AT(TROLL)) {
|
||||||
rspeak(TROLL_SCAMPERS);
|
rspeak(TROLL_SCAMPERS);
|
||||||
move(TROLL, 0);
|
move(TROLL, LOC_NOWHERE);
|
||||||
move(TROLL + NOBJECTS, 0);
|
move(TROLL + NOBJECTS, LOC_NOWHERE);
|
||||||
move(TROLL2, objects[TROLL].plac);
|
move(TROLL2, objects[TROLL].plac);
|
||||||
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
||||||
juggle(CHASM);
|
juggle(CHASM);
|
||||||
|
@ -497,18 +497,18 @@ static int drink(token_t verb, token_t obj)
|
||||||
/* Drink. If no object, assume water and look for it here. If water is in
|
/* Drink. If no object, assume water and look for it here. If water is in
|
||||||
* the bottle, drink that, else must be at a water loc, so drink stream. */
|
* the bottle, drink that, else must be at a water loc, so drink stream. */
|
||||||
{
|
{
|
||||||
int spk = actions[verb].message;
|
if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
|
||||||
if (obj == 0 && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE)))
|
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
if (obj != BLOOD) {
|
if (obj != BLOOD) {
|
||||||
if (obj != 0 && obj != WATER)
|
if (obj != NO_OBJECT && obj != WATER) {
|
||||||
spk = RIDICULOUS_ATTEMPT;
|
rspeak(RIDICULOUS_ATTEMPT);
|
||||||
if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
|
} else if (LIQUID() == WATER && HERE(BOTTLE)) {
|
||||||
game.prop[BOTTLE] = EMPTY_BOTTLE;
|
game.prop[BOTTLE] = EMPTY_BOTTLE;
|
||||||
game.place[WATER] = LOC_NOWHERE;
|
game.place[WATER] = LOC_NOWHERE;
|
||||||
spk = BOTTLE_EMPTY;
|
rspeak(BOTTLE_EMPTY);
|
||||||
|
} else {
|
||||||
|
rspeak(actions[verb].message);
|
||||||
}
|
}
|
||||||
rspeak(spk);
|
|
||||||
} else {
|
} else {
|
||||||
DESTROY(BLOOD);
|
DESTROY(BLOOD);
|
||||||
state_change(DRAGON, DRAGON_BLOODLESS);
|
state_change(DRAGON, DRAGON_BLOODLESS);
|
||||||
|
@ -656,10 +656,10 @@ int fill(token_t verb, token_t obj)
|
||||||
spk = WATER_URN + game.prop[URN];
|
spk = WATER_URN + game.prop[URN];
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj != 0 && obj != BOTTLE) {
|
} else if (obj != NO_OBJECT && obj != BOTTLE) {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj == 0 && !HERE(BOTTLE))
|
} else if (obj == NO_OBJECT && !HERE(BOTTLE))
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
spk = BOTTLED_WATER;
|
spk = BOTTLED_WATER;
|
||||||
if (LIQLOC(game.loc) == 0)
|
if (LIQLOC(game.loc) == 0)
|
||||||
|
@ -832,7 +832,7 @@ static int lock(token_t verb, token_t obj)
|
||||||
obj = GRATE;
|
obj = GRATE;
|
||||||
if (HERE(CHAIN))
|
if (HERE(CHAIN))
|
||||||
obj = CHAIN;
|
obj = CHAIN;
|
||||||
if (obj == 0 || obj == INTRANSITIVE) {
|
if (obj == NO_OBJECT || obj == INTRANSITIVE) {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
@ -875,9 +875,9 @@ static int pour(token_t verb, token_t obj)
|
||||||
* special tests for pouring water or oil on plant or rusty door. */
|
* special tests for pouring water or oil on plant or rusty door. */
|
||||||
{
|
{
|
||||||
int spk = actions[verb].message;
|
int spk = actions[verb].message;
|
||||||
if (obj == BOTTLE || obj == 0)
|
if (obj == BOTTLE || obj == NO_OBJECT)
|
||||||
obj = LIQUID();
|
obj = LIQUID();
|
||||||
if (obj == 0)
|
if (obj == NO_OBJECT)
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
if (!TOTING(obj)) {
|
if (!TOTING(obj)) {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
|
@ -1018,23 +1018,21 @@ static int throw (struct command_t *command)
|
||||||
* (Only way to do so!) Axe also special for dragon, bear, and
|
* (Only way to do so!) Axe also special for dragon, bear, and
|
||||||
* troll. Treasures special for troll. */
|
* troll. Treasures special for troll. */
|
||||||
{
|
{
|
||||||
int spk = actions[command->verb].message;
|
|
||||||
if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
|
if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
|
||||||
command->obj = ROD2;
|
command->obj = ROD2;
|
||||||
if (!TOTING(command->obj)) {
|
if (!TOTING(command->obj)) {
|
||||||
rspeak(spk);
|
rspeak(actions[command->verb].message);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (objects[command->obj].is_treasure && AT(TROLL)) {
|
if (objects[command->obj].is_treasure && AT(TROLL)) {
|
||||||
spk = TROLL_SATISFIED;
|
|
||||||
/* Snarf a treasure for the troll. */
|
/* Snarf a treasure for the troll. */
|
||||||
drop(command->obj, 0);
|
drop(command->obj, LOC_NOWHERE);
|
||||||
move(TROLL, 0);
|
move(TROLL, LOC_NOWHERE);
|
||||||
move(TROLL + NOBJECTS, 0);
|
move(TROLL + NOBJECTS, LOC_NOWHERE);
|
||||||
drop(TROLL2, objects[TROLL].plac);
|
drop(TROLL2, objects[TROLL].plac);
|
||||||
drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
||||||
juggle(CHASM);
|
juggle(CHASM);
|
||||||
rspeak(spk);
|
rspeak(TROLL_SATISFIED);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (command->obj == FOOD && HERE(BEAR)) {
|
if (command->obj == FOOD && HERE(BEAR)) {
|
||||||
|
@ -1045,8 +1043,7 @@ static int throw (struct command_t *command)
|
||||||
if (command->obj != AXE)
|
if (command->obj != AXE)
|
||||||
return (discard(command->verb, command->obj, false));
|
return (discard(command->verb, command->obj, false));
|
||||||
else {
|
else {
|
||||||
int i = atdwrf(game.loc);
|
if (atdwrf(game.loc) <= 0) {
|
||||||
if (i <= 0) {
|
|
||||||
if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
|
if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
|
||||||
return throw_support(DRAGON_SCALES);
|
return throw_support(DRAGON_SCALES);
|
||||||
if (AT(TROLL))
|
if (AT(TROLL))
|
||||||
|
@ -1057,18 +1054,18 @@ static int throw (struct command_t *command)
|
||||||
/* This'll teach him to throw the axe at the bear! */
|
/* This'll teach him to throw the axe at the bear! */
|
||||||
drop(AXE, game.loc);
|
drop(AXE, game.loc);
|
||||||
game.fixed[AXE] = -1;
|
game.fixed[AXE] = -1;
|
||||||
game.prop[AXE] = 1;
|
|
||||||
juggle(BEAR);
|
juggle(BEAR);
|
||||||
rspeak(AXE_LOST);
|
state_change(AXE, AXE_LOST);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
command->obj = 0;
|
command->obj = NO_OBJECT;
|
||||||
return (attack(command));
|
return (attack(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (randrange(NDWARVES + 1) < game.dflag) {
|
if (randrange(NDWARVES + 1) < game.dflag) {
|
||||||
return throw_support(DWARF_DODGES);
|
return throw_support(DWARF_DODGES);
|
||||||
} else {
|
} else {
|
||||||
|
long i = atdwrf(game.loc);
|
||||||
game.dseen[i] = false;
|
game.dseen[i] = false;
|
||||||
game.dloc[i] = 0;
|
game.dloc[i] = 0;
|
||||||
return throw_support((++game.dkill == 1)
|
return throw_support((++game.dkill == 1)
|
||||||
|
|
|
@ -2975,7 +2975,6 @@ arbitrary_messages: !!omap
|
||||||
- TROLL_SCAMPERS: |-
|
- TROLL_SCAMPERS: |-
|
||||||
The bear lumbers toward the troll, who lets out a startled shriek and
|
The bear lumbers toward the troll, who lets out a startled shriek and
|
||||||
scurries away. The bear soon gives up the pursuit and wanders back.
|
scurries away. The bear soon gives up the pursuit and wanders back.
|
||||||
- AXE_LOST: 'The axe misses and lands near the bear where you can''t get at it.'
|
|
||||||
- BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??'
|
- BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??'
|
||||||
- BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.'
|
- 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!'
|
- ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!'
|
||||||
|
@ -3202,7 +3201,7 @@ turn_thresholds:
|
||||||
twenty points lost for taking so long.
|
twenty points lost for taking so long.
|
||||||
|
|
||||||
objects: !!omap
|
objects: !!omap
|
||||||
- OBJ_0:
|
- NO_OBJECT:
|
||||||
inventory: !!null
|
inventory: !!null
|
||||||
descriptions: !!null
|
descriptions: !!null
|
||||||
- KEYS:
|
- KEYS:
|
||||||
|
@ -3444,8 +3443,11 @@ objects: !!omap
|
||||||
inventory: 'Dwarf''s axe'
|
inventory: 'Dwarf''s axe'
|
||||||
locations: LOC_NOWHERE
|
locations: LOC_NOWHERE
|
||||||
descriptions:
|
descriptions:
|
||||||
- 'There is a little axe here.'
|
- [AXE_HERE, 'There is a little axe here.']
|
||||||
- 'There is a little axe lying beside the bear.'
|
- [AXE_LOST, 'There is a little axe lying beside the bear.']
|
||||||
|
changes:
|
||||||
|
- ''
|
||||||
|
- 'The axe misses and lands near the bear where you can''t get at it.'
|
||||||
- OBJ_29:
|
- OBJ_29:
|
||||||
words: ['drawi']
|
words: ['drawi']
|
||||||
inventory: '*cave drawings'
|
inventory: '*cave drawings'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue