{
ushootm(dy, dx);
}
- else if (lvl.mons[u.y + dy][u.x + dx] != -1)
+ else if (lvl.mons[u.y + dy][u.x + dx] != NO_MON)
{
uhitm(lvl.mons[u.y + dy][u.x + dx]);
}
int uhitm(int mon)
{
- struct mon *mp;
- struct obj *wep;
+ Mon *mp;
+ Obj *wep;
struct permobj *pwep;
- struct obj *ring;
+ Obj *ring;
int tohit;
int damage;
int healing;
print_msg("You hit ");
print_mon_name(mon, 1);
print_msg(".\n");
- if (u.weapon != -1)
+ if (u.weapon != NO_OBJ)
{
wep = objects + u.weapon;
pwep = permobjs + wep->obj_id;
{
damage = u.body / 10;
}
- if (u.ring != -1)
+ if (u.ring != NO_OBJ)
{
ring = objects + u.ring;
switch (ring->obj_id)
}
print_msg("You do %d damage.\n", damage);
damage_mon(mon, damage, 1);
- if (u.weapon != -1)
+ if (u.weapon != NO_OBJ)
{
damage_obj(u.weapon);
}
int range;
int y, x;
int done = 0;
- struct mon *mptr;
- struct obj *wep;
+ Mon *mptr;
+ Obj *wep;
struct permobj *pwep;
int damage;
wep = objects + u.weapon;
range = 1;
for ( ; !done; (y += sy), (x += sx))
{
- if (lvl.mons[y][x] != -1)
+ if (lvl.mons[y][x] != NO_MON)
{
done = 1;
mptr = monsters + lvl.mons[y][x];
int tohit;
int damage;
int unaffected;
- struct mon *mptr = monsters + mon;
+ Mon *mptr = monsters + mon;
tohit = zero_die(mptr->mtohit + 5);
if (tohit < u.defence)
{
/* Note: Yes, all attacks can damage your armour. Deal. */
- if ((u.armour != -1) && (tohit > agility_modifier()))
+ if ((u.armour != NO_OBJ) && (tohit > agility_modifier()))
{
/* Monster hit your armour. */
print_msg("Your armour deflects ");
int mshootu(int mon)
{
- struct mon *mptr;
- struct mon *bystander;
+ Mon *mptr;
+ Mon *bystander;
int y;
int x;
int dy;
/* Use agility-based defence for necromantic blasts and lightning
* bolts */
evasion = u.agility * 100;
- if (u.armour != -1)
+ if (u.armour != NO_OBJ)
{
evasion -= (u.agility * evasion_penalty(u.armour));
}
print_msg("It misses you.\n");
}
}
- else if (lvl.mons[y][x] != -1)
+ else if (lvl.mons[y][x] != NO_MON)
{
done = 1;
bystander = monsters + lvl.mons[y][x];
{
int i;
int y, x;
+ int mon;
for (i = 0, y = u.y, x = u.x; i < 10; ++i)
{
y += sy;
x += sx;
- if ((lvl.mons[y][x] != -1) &&
- (monsters[lvl.mons[y][x]].used))
+ mon = lvl.mons[y][x];
+ if ((mon != NO_MON) &&
+ (monsters[mon].used))
{
- struct mon *mptr = monsters + lvl.mons[y][x];
+ Mon *mptr = monsters + lvl.mons[y][x];
switch (objects[obj].obj_id)
{
case PO_FLASK_WEAKNESS:
/* Prototypes for static funcs */
static const cchar_t *object_char(int object_id);
static const cchar_t *monster_char(int monster_id);
-static const cchar_t *terrain_char(enum terrain_num terrain_type);
+static const cchar_t *terrain_char(Terrain terrain_type);
static void draw_status_line(void);
static void draw_world(void);
mvwprintw(status_window, 1, 44, "Agility: %02d/%02d", u.agility - u.adam, u.agility);
}
-static const cchar_t *terrain_char(enum terrain_num terrain_type)
+static const cchar_t *terrain_char(Terrain terrain_type)
{
return terrain_tiles + terrain_type;
}
{
back_buffer[y][x] = &player_tile;
}
- else if ((!show_terrain) && (lvl.mons[y][x] != -1) && mon_visible(lvl.mons[y][x]))
+ else if ((!show_terrain) && (lvl.mons[y][x] != NO_MON) && mon_visible(lvl.mons[y][x]))
{
back_buffer[y][x] = monster_char(monsters[lvl.mons[y][x]].mon_id);
}
else if (lvl.flags[y][x] & MAPFLAG_EXPLORED)
{
- if ((!show_terrain) && (lvl.objs[y][x] != -1))
+ if ((!show_terrain) && (lvl.objs[y][x] != NO_OBJ))
{
back_buffer[y][x] = object_char(objects[lvl.objs[y][x]].obj_id);
}
wattr_set(inventory_window, colour_attrs[Gcol_d_grey], Gcol_d_grey, NULL);
for (i = 0; i < 19; i++)
{
- if (u.inventory[i] == -1)
+ if (u.inventory[i] == NO_OBJ)
{
wattr_set(inventory_window, colour_attrs[Gcol_d_grey], Gcol_d_grey, NULL);
mvwprintw(inventory_window, i + 1, 0, "%c) -----\n", 'a' + i);
for (i = 0; i < 19; i++)
{
- if ((u.inventory[i] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[i]].obj_id].poclass == filter)))
+ if ((u.inventory[i] != NO_OBJ) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[i]].obj_id].poclass == filter)))
{
items++;
}
* set is a strict superset of ASCII. IF we're not, the
* following code may break. */
selection = ch - 'a';
- if ((u.inventory[selection] != -1) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[selection]].obj_id].poclass == filter)))
+ if ((u.inventory[selection] != NO_OBJ) && ((filter == POCLASS_NONE) || (permobjs[objects[u.inventory[selection]].obj_id].poclass == filter)))
{
hide_inv();
return selection;
fwrite(lvl.terrain, 1, sizeof lvl.terrain, fp);
fwrite(lvl.flags, 1, sizeof lvl.flags, fp);
fwrite(permobjs, NUM_OF_PERMOBJS, sizeof (struct permobj), fp);
- fwrite(monsters, MONSTERS_IN_PLAY, sizeof (struct mon), fp);
- fwrite(objects, OBJECTS_IN_PLAY, sizeof (struct obj), fp);
+ fwrite(monsters, MONSTERS_IN_PLAY, sizeof (Mon), fp);
+ fwrite(objects, OBJECTS_IN_PLAY, sizeof (Obj), fp);
/* Write out the depth */
fwrite(&depth, 1, sizeof depth, fp);
/* Write out the player. */
fread(lvl.terrain, 1, sizeof lvl.terrain, fp);
fread(lvl.flags, 1, sizeof lvl.flags, fp);
fread(permobjs, NUM_OF_PERMOBJS, sizeof (struct permobj), fp);
- fread(monsters, MONSTERS_IN_PLAY, sizeof (struct mon), fp);
- fread(objects, OBJECTS_IN_PLAY, sizeof (struct obj), fp);
+ fread(monsters, MONSTERS_IN_PLAY, sizeof (Mon), fp);
+ fread(objects, OBJECTS_IN_PLAY, sizeof (Obj), fp);
rebuild_mapobjs();
rebuild_mapmons();
fread(&depth, 1, sizeof depth, fp);
return 0;
case GET_ITEM:
- if (lvl.objs[u.y][u.x] != -1)
+ if (lvl.objs[u.y][u.x] != NO_OBJ)
{
attempt_pickup();
return 1;
i = inv_select(POCLASS_WEAPON, "wield", 1);
if (i == -2)
{
- u.weapon = -1;
+ u.weapon = NO_OBJ;
print_msg("Weapon unwielded.\n");
}
else if (i >= 0)
return 0;
case EMANATE_ARMOUR:
- if (u.armour == -1)
+ if (u.armour == NO_OBJ)
{
print_msg("You are not wearing any armour.\n");
return 0;
return emanate_armour();
case ZAP_WEAPON:
- if (u.weapon == -1)
+ if (u.weapon == NO_OBJ)
{
print_msg("You have no weapon in hand.\n");
return 0;
return zap_weapon();
case MAGIC_RING:
- if (u.weapon == -1)
+ if (u.weapon == NO_OBJ)
{
print_msg("You are not wearing a ring.\n");
return 0;
return magic_ring();
case TAKE_OFF_ARMOUR:
- if (u.armour != -1)
+ if (u.armour != NO_OBJ)
{
if ((u.resistances[DT_FIRE] == RESIST_ARMOUR) &&
(lvl.terrain[u.y][u.x] == LAVA))
print_msg("Your armour is your only current source of fire\nresistance; removing it here would incinerate you.\n");
return 0;
}
- u.armour = -1;
+ u.armour = NO_OBJ;
recalc_defence();
print_msg("You take off your armour.\n");
return 1;
j = read_scroll(u.inventory[i]);
if (j)
{
- u.inventory[i] = -1;
+ u.inventory[i] = NO_OBJ;
}
return 1;
}
j = eat_food(u.inventory[i]);
if (j == -1)
{
- u.inventory[i] = -1;
+ u.inventory[i] = NO_OBJ;
}
return 1;
}
j = quaff_potion(u.inventory[i]);
if (j)
{
- u.inventory[i] = -1;
+ u.inventory[i] = NO_OBJ;
}
return 1;
}
return 0;
case REMOVE_RING:
- if (u.ring == -1)
+ if (u.ring == NO_OBJ)
{
print_msg("You have no ring to remove!\n");
return 0;
else
{
print_msg("You remove your ring.\n");
- u.ring = -1;
+ u.ring = NO_OBJ;
}
return 1;
case PUT_ON_RING:
- if (u.ring != -1)
+ if (u.ring != NO_OBJ)
{
print_msg("You are already wearing a ring.\n");
return 0;
return 0;
case INSPECT_ITEM:
i = inv_select(POCLASS_NONE, "inspect", 0);
- if ((i >= 0) && (u.inventory[i] != -1))
+ if ((i >= 0) && (u.inventory[i] != NO_OBJ))
{
describe_object(u.inventory[i]);
}
print_msg("1d32-1: %d %d %d %d %d %d %d %d\n", zero_die(32), zero_die(32), zero_die(32), zero_die(32), zero_die(32), zero_die(32), zero_die(32), zero_die(32));
return 0;
case DROP_ITEM:
- if (lvl.objs[u.y][u.x] != -1)
+ if (lvl.objs[u.y][u.x] != NO_OBJ)
{
print_msg("There is already an item here.\n");
return 0;
i = inv_select(POCLASS_NONE, "drop", 0);
if (i >= 0)
{
- if ((u.inventory[i] != -1) &&
+ if ((u.inventory[i] != NO_OBJ) &&
((u.inventory[i] == u.ring) ||
(u.inventory[i] == u.armour)))
{
{
if (lvl.terrain[y][x] == overwrite[j])
{
- lvl.terrain[y][x] = (terrain_num) newterr;
+ lvl.terrain[y][x] = (Terrain) newterr;
return 1;
}
}
ty = exclusive_flat(0, DUN_HEIGHT - 1);
tx = exclusive_flat(0, DUN_WIDTH - 1);
if ((lvl.terrain[ty][tx] != FLOOR) ||
- (lvl.mons[ty][tx] != -1))
+ (lvl.mons[ty][tx] != NO_MON))
{
ty = -1;
tx = -1;
{
continue;
}
- if (lvl.mons[u.y][u.x] != -1)
+ if (lvl.mons[u.y][u.x] != NO_MON)
{
continue;
}
false, false, false, false
};
-bool terrain_is_opaque(enum terrain_num terr)
+bool terrain_is_opaque(Terrain terr)
{
return terrain_opacity[terr];
}
#endif
/* XXX enum terrain_num */
-enum terrain_num {
+enum Terrain {
// cheap hack: opaque terrain goes first, and walls very first.
WALL = 0, HARDWALL, DOOR, FLOOR, ALTAR, STAIRS, LAVA, WATER
};
{
int objs[DUN_HEIGHT][DUN_WIDTH];
int mons[DUN_HEIGHT][DUN_WIDTH];
- terrain_num terrain[DUN_HEIGHT][DUN_WIDTH];
+ Terrain terrain[DUN_HEIGHT][DUN_WIDTH];
uint32_t flags[DUN_HEIGHT][DUN_WIDTH];
level_theme theme;
level_layout layout;
extern void populate_level(void);
extern void inject_player(void);
extern void explore_around(int y, int x);
-extern bool terrain_is_opaque(enum terrain_num terr);
+extern bool terrain_is_opaque(Terrain terr);
#endif
/* map.h */
void mon_acts(int mon)
{
- struct mon *mptr;
+ Mon *mptr;
int dy, dx;
int y, x;
int sy, sx;
print_msg("Program disordered: monster in player's square.\n");
print_msg("Discarding misplaced monster.\n");
mptr->used = 0;
- lvl.mons[y][x] = -1;
+ lvl.mons[y][x] = NO_MON;
return;
}
if (lvl.mons[y][x] != mon)
{
print_msg("Program disordered: monster(s) misplaced.\n");
mptr->used = 0;
- if (lvl.mons[y][x] != -1)
+ if (lvl.mons[y][x] != NO_MON)
{
monsters[lvl.mons[y][x]].used = 0;
- lvl.mons[y][x] = -1;
+ lvl.mons[y][x] = NO_MON;
}
return;
}
#include "victrix-abyssi.hh"
#include "monsters.hh"
-struct mon monsters[100];
+Mon monsters[100];
static int reject_mon(int pm);
int summoning(int y, int x, int how_many)
dy = zero_die(3) - 1;
dx = zero_die(3) - 1;
if ((lvl.terrain[y + dy][x + dx] == FLOOR) &&
- (lvl.mons[y + dy][x + dx] == -1) &&
+ (lvl.mons[y + dy][x + dx] == NO_MON) &&
((y + dy != u.y) || (x + dx != u.x)))
{
pmon = get_random_pmon();
continue;
}
mon = create_mon(-1, y + dy, x + dx);
- if (mon != -1)
+ if (mon != NO_MON)
{
created++;
break;
int create_mon(int pm_idx, int y, int x)
{
int mon;
- if (lvl.mons[y][x] != -1)
+ if (lvl.mons[y][x] != NO_MON)
{
print_msg("Attempt to create monster at occupied space %d %d\n", y, x);
return -1;
monsters[mon].mtohit = permons[pm_idx].mtohit + ood(permons[pm_idx].power, 3);
monsters[mon].defence = permons[pm_idx].defence + ood(permons[pm_idx].power, 3);
monsters[mon].mdam = permons[pm_idx].mdam + ood(permons[pm_idx].power, 5);
- if (permons[pm_idx].rdam != -1)
+ if (permons[pm_idx].rdam != NO_MON)
{
monsters[mon].rtohit = permons[pm_idx].rtohit + ood(permons[pm_idx].power, 3);
monsters[mon].rdam = permons[pm_idx].rdam + ood(permons[pm_idx].power, 5);
int x = monsters[mon].x;
int dy, dx;
int tryct;
- while (((lvl.objs[y][x] != -1) || (lvl.terrain[y][x] != FLOOR)) && tryct < 100)
+ while (((lvl.objs[y][x] != NO_OBJ) || (lvl.terrain[y][x] != FLOOR)) && tryct < 100)
{
dy = zero_die(3) - 1;
dx = zero_die(3) - 1;
int mon_can_pass(int mon, int y, int x)
{
- enum terrain_num terr;
+ Terrain terr;
if ((y < 0) || (x < 0) || (y >= DUN_HEIGHT) || (x >= DUN_WIDTH))
{
return 0;
}
- if (lvl.mons[y][x] != -1)
+ if (lvl.mons[y][x] != NO_MON)
{
return 0;
}
void damage_mon(int mon, int amount, int by_you)
{
- struct mon *mptr;
+ Mon *mptr;
mptr = monsters + mon;
if (amount >= mptr->hpcur)
{
print_msg(" dies.\n");
}
death_drop(mon);
- lvl.mons[mptr->y][mptr->x] = -1;
+ lvl.mons[mptr->y][mptr->x] = NO_MON;
newsym(mptr->y, mptr->x);
mptr->used = 0;
map_updated = 1;
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- if ((lvl.mons[y][x] == -1) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
+ if ((lvl.mons[y][x] == NO_MON) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
{
reloc_mon(mon, y, x);
rval = 0;
int knockback_mon(int mon, int sy, int sx, bool cansee, bool by_you)
{
/* 0 = blocked, 1 = knocked, 2 = killed */
- struct mon *mptr = monsters + mon;
+ Mon *mptr = monsters + mon;
int y = mptr->y + sy;
int x = mptr->x + sx;
- enum terrain_num terr = lvl.terrain[y][x];
+ Terrain terr = lvl.terrain[y][x];
if (mon_resists_knockback(mon))
{
void reloc_mon(int mon, int y, int x)
{
- struct mon *mptr = monsters + mon;
- lvl.mons[mptr->y][mptr->x] = -1;
+ Mon *mptr = monsters + mon;
+ lvl.mons[mptr->y][mptr->x] = NO_MON;
newsym(mptr->y, mptr->x);
mptr->y = y;
mptr->x = x;
void move_mon(int mon, int y, int x)
{
- struct mon *mptr;
+ Mon *mptr;
if (!mon_can_pass(mon, y, x))
{
print_msg("Warning: monster attempted an invalid move.\n");
int i;
y2 = y - 1 + zero_die(3);
x2 = x - 1 + zero_die(3);
- if ((lvl.terrain[y2][x2] == FLOOR) && (lvl.mons[y2][x2] == -1) &&
+ if ((lvl.terrain[y2][x2] == FLOOR) && (lvl.mons[y2][x2] == NO_MON) &&
((y2 != u.y) || (x2 != u.x)))
{
i = create_mon(PM_DEMON, y2, x2);
- if (i != -1)
+ if (i != NO_MON)
{
print_msg("Another demon appears!\n");
}
/* XXX struct mon */
#define MONSTERS_IN_PLAY 100
-struct mon {
+struct Mon {
int mon_id;
int y;
int x;
int next_summon;
bool resists(Damtyp dt) const;
};
-extern struct mon monsters[MONSTERS_IN_PLAY];
+extern Mon monsters[MONSTERS_IN_PLAY];
+
+#define NO_MON (-1)
+#define PLAYER_MON (-2)
/* XXX monsters.c data and funcs */
extern void update_mon(int mon);
#include "victrix-abyssi.hh"
#include "monsters.hh"
-struct obj objects[100];
+Obj objects[100];
int get_random_pobj(void);
const char ring_colours[20][16] = {
int read_scroll(int obj)
{
- struct obj *optr = objects + obj;
+ Obj *optr = objects + obj;
int i;
switch (optr->obj_id)
{
}
else
{
- u.armour = -1;
+ u.armour = NO_OBJ;
}
recalc_defence();
}
else if (obj == u.weapon)
{
- u.weapon = -1;
+ u.weapon = NO_OBJ;
recalc_defence();
}
else if (obj == u.ring)
{
- u.ring = -1;
+ u.ring = NO_OBJ;
recalc_defence();
}
if (!objects[obj].used)
{
if (u.inventory[i] == obj)
{
- u.inventory[i] = -1;
+ u.inventory[i] = NO_OBJ;
break;
}
}
int eat_food(int obj)
{
- struct obj *optr = objects + obj;
+ Obj *optr = objects + obj;
if (permobjs[optr->obj_id].poclass != POCLASS_FOOD)
{
print_msg("Error: attempt to eat non-food (%d)!\n", optr->obj_id);
int quaff_potion(int obj)
{
- struct obj *optr = objects + obj;
+ Obj *optr = objects + obj;
switch (optr->obj_id)
{
case PO_POT_BODY:
void sprint_obj_name(char *buf, int obj, int len)
{
- struct obj *optr;
+ Obj *optr;
struct permobj *poptr;
optr = objects + obj;
poptr = permobjs + optr->obj_id;
void fprint_obj_name(FILE *fp, int obj)
{
- struct obj *optr;
+ Obj *optr;
struct permobj *poptr;
optr = objects + obj;
poptr = permobjs + optr->obj_id;
void print_obj_name(int obj)
{
- struct obj *optr;
+ Obj *optr;
struct permobj *poptr;
optr = objects + obj;
poptr = permobjs + optr->obj_id;
int drop_obj(int inv_idx)
{
- struct obj *optr;
+ Obj *optr;
optr = objects + u.inventory[inv_idx];
- if (lvl.objs[u.y][u.x] == -1)
+ if (lvl.objs[u.y][u.x] == NO_OBJ)
{
optr->y = u.y;
optr->x = u.x;
lvl.objs[u.y][u.x] = u.inventory[inv_idx];
if (u.weapon == u.inventory[inv_idx])
{
- u.weapon = -1;
+ u.weapon = NO_OBJ;
}
- u.inventory[inv_idx] = -1;
+ u.inventory[inv_idx] = NO_OBJ;
optr->with_you = 0;
print_msg("You drop ");
print_obj_name(lvl.objs[u.y][u.x]);
print_msg(".\nYou now have\n");
objects[u.inventory[i]].quan += objects[lvl.objs[u.y][u.x]].quan;
objects[lvl.objs[u.y][u.x]].used = 0;
- lvl.objs[u.y][u.x] = -1;
+ lvl.objs[u.y][u.x] = NO_OBJ;
print_msg("%c) ", 'a' + i);
print_obj_name(u.inventory[i]);
print_msg("\n");
}
for (i = 0; i < 19; i++)
{
- if (u.inventory[i] == -1)
+ if (u.inventory[i] == NO_OBJ)
{
break;
}
return;
}
u.inventory[i] = lvl.objs[u.y][u.x];
- lvl.objs[u.y][u.x] = -1;
+ lvl.objs[u.y][u.x] = NO_OBJ;
objects[u.inventory[i]].with_you = 1;
objects[u.inventory[i]].x = -1;
objects[u.inventory[i]].y = -1;
void describe_object(int obj)
{
- struct obj *optr;
+ Obj *optr;
struct permobj *poptr;
print_obj_name(obj);
optr = objects + obj;
int magic_ring(void)
{
- struct obj *optr = objects + u.ring;
+ Obj *optr = objects + u.ring;
switch (optr->obj_id)
{
case PO_RING_TELEPORT:
int emanate_armour(void)
{
- struct obj *optr = objects + u.armour;
+ Obj *optr = objects + u.armour;
switch (optr->obj_id)
{
case PO_RIBBONS:
int zap_weapon(void)
{
- struct obj *optr = objects + u.weapon;
+ Obj *optr = objects + u.weapon;
switch (optr->obj_id)
{
case PO_STAFF_OF_FIRE:
{
continue;
}
- if (lvl.mons[y][x] != -1)
+ if (lvl.mons[y][x] != NO_MON)
{
- struct mon *mptr = monsters + lvl.mons[y][x];
+ Mon *mptr = monsters + lvl.mons[y][x];
if (!pmon_resists_fire(mptr->mon_id))
{
print_mon_name(lvl.mons[y][x], 3);
};
extern struct permobj permobjs[NUM_OF_PERMOBJS];
-/* XXX struct obj */
+/* XXX Obj */
#define OBJ_MAX_DUR 100
#define OBJECTS_IN_PLAY 100
-struct obj {
+struct Obj {
int obj_id;
int quan;
int with_you; /* Preserved when item DB is reaped on level change. */
int used; /* Entry is occupied. */
int durability; /* Weapons and armour degrade with use. */
};
-extern struct obj objects[OBJECTS_IN_PLAY];
+extern Obj objects[OBJECTS_IN_PLAY];
+
+#define NO_OBJ (-1)
/* XXX objects.c data and funcs */
extern void flavours_init(void);
{
/* Returns zero for no spell selected, -1 for unsupported spell
* selected, 1 for supported spell selected. */
- struct mon *mptr = monsters + mon;
+ Mon *mptr = monsters + mon;
int dy, dx;
int sy, sx;
enum monspell to_cast = MS_REJECT;
u.resistances[i] &= RESIST_MASK_TEMPORARY;
}
u.speed = (u.leadfoot ? 0 : 1);
- if (u.armour != -1)
+ if (u.armour != NO_OBJ)
{
u.defence = u.armourmelt ? 0 : permobjs[objects[u.armour].obj_id].power;
u.defence += u.withering ? (u.agility / 10) : (u.agility / 5);
{
u.defence = u.withering ? (u.agility / 10) : (u.agility / 5);
}
- if (u.ring != -1)
+ if (u.ring != NO_OBJ)
{
switch (objects[u.ring].obj_id)
{
print_msg("Attempted move out of bounds.\n");
return 0; /* No movement. */
}
- if (lvl.mons[u.y + dy][u.x + dx] != -1)
+ if (lvl.mons[u.y + dy][u.x + dx] != NO_MON)
{
- if (u.weapon != -1)
+ if (u.weapon != NO_OBJ)
{
if ((objects[u.weapon].obj_id == PO_BOW) ||
(objects[u.weapon].obj_id == PO_CROSSBOW))
return 0;
}
case WATER:
- if ((u.ring != -1) && (objects[u.ring].obj_id == PO_RING_FROST))
+ if ((u.ring != NO_OBJ) && (objects[u.ring].obj_id == PO_RING_FROST))
{
if (lvl.terrain[u.y][u.x] != WATER)
{
map_updated = 1;
status_updated = 1;
display_update();
- if (lvl.objs[y][x] != -1)
+ if (lvl.objs[y][x] != NO_OBJ)
{
print_msg("You see here ");
print_obj_name(lvl.objs[y][x]);
fprintf(fp, "Inventory:\n");
for (i = 0; i < 19; i++)
{
- if (u.inventory[i] != -1)
+ if (u.inventory[i] != NO_OBJ)
{
fprint_obj_name(fp, u.inventory[i]);
fputc('\n', fp);
u.food = 2000;
memset(u.inventory, -1, sizeof u.inventory);
u.inventory[0] = create_obj(PO_DAGGER, 1, 1, -1, -1);
- if (u.inventory[0] == -1)
+ if (u.inventory[0] == NO_OBJ)
{
print_msg("Couldn't create dagger!\n");
}
u.inventory[1] = create_obj(PO_IRON_RATION, 1, 1, -1, -1);
u.inventory[2] = create_obj(PO_BATTLE_BALLGOWN, 1, 1, -1, -1);
u.weapon = u.inventory[0];
- u.ring = -1;
+ u.ring = NO_OBJ;
u.armour = u.inventory[2];
recalc_defence();
}
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- if ((lvl.mons[y][x] == -1) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
+ if ((lvl.mons[y][x] == NO_MON) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
{
print_msg("You are whisked away!\n");
reloc_player(y, x);