{
ushootm(dy, dx);
}
- else if (mapmonster[u.y + dy][u.x + dx] != -1)
+ else if (lvl.mons[u.y + dy][u.x + dx] != -1)
{
- uhitm(mapmonster[u.y + dy][u.x + dx]);
+ uhitm(lvl.mons[u.y + dy][u.x + dx]);
}
else
{
range = 1;
for ( ; !done; (y += sy), (x += sx))
{
- if (mapmonster[y][x] != -1)
+ if (lvl.mons[y][x] != -1)
{
done = 1;
- mptr = monsters + mapmonster[y][x];
+ mptr = monsters + lvl.mons[y][x];
tohit = zero_die(u.agility + u.level - range);
if (range == 1)
{
}
if (tohit >= mptr->defence)
{
- if (mon_visible(mapmonster[y][x]))
+ if (mon_visible(lvl.mons[y][x]))
{
print_msg("You hit ");
- print_mon_name(mapmonster[y][x], 1);
+ print_mon_name(lvl.mons[y][x], 1);
print_msg(".\n");
print_msg("You do %d damage.\n", damage);
}
- damage_mon(mapmonster[y][x], damage, 1);
+ damage_mon(lvl.mons[y][x], damage, 1);
if ((mptr->used) && (wep->obj_id == PO_THUNDERBOW))
{
- int kb = knockback_mon(mapmonster[y][x], sy, sx, true, true);
+ int kb = knockback_mon(lvl.mons[y][x], sy, sx, true, true);
switch (kb)
{
case 0:
else
{
print_msg("You miss ");
- print_mon_name(mapmonster[y][x], 1);
+ print_mon_name(lvl.mons[y][x], 1);
print_msg(".\n");
return 0;
}
}
- else if ((terrain[y][x] == WALL) || (terrain[y][x] == HARDWALL) ||
- (terrain[y][x] == DOOR))
+ else if ((lvl.terrain[y][x] == WALL) || (lvl.terrain[y][x] == HARDWALL) ||
+ (lvl.terrain[y][x] == DOOR))
{
- print_msg("Your %s hits the %s.\n", (wep->obj_id == PO_CROSSBOW) ? "bolt" : "arrow", (terrain[y][x] == DOOR) ? "door" : "wall");
+ print_msg("Your %s hits the %s.\n", (wep->obj_id == PO_CROSSBOW) ? "bolt" : "arrow", (lvl.terrain[y][x] == DOOR) ? "door" : "wall");
return 0;
}
}
!done;
(y += sy), (x += sx))
{
- if ((terrain[y][x] == WALL) || (terrain[y][x] == DOOR))
+ if ((lvl.terrain[y][x] == WALL) || (lvl.terrain[y][x] == DOOR))
{
done = 1;
}
print_msg("It misses you.\n");
}
}
- else if (mapmonster[y][x] != -1)
+ else if (lvl.mons[y][x] != -1)
{
done = 1;
- bystander = monsters + mapmonster[y][x];
+ bystander = monsters + lvl.mons[y][x];
switch (dtype)
{
case DT_COLD:
if (tohit >= bystander->defence)
{
damage = one_die(mptr->rdam);
- damage_mon(mapmonster[y][x], dtype, 0);
+ damage_mon(lvl.mons[y][x], dtype, 0);
}
}
}
{
y += sy;
x += sx;
- if ((mapmonster[y][x] != -1) &&
- (monsters[mapmonster[y][x]].used))
+ if ((lvl.mons[y][x] != -1) &&
+ (monsters[lvl.mons[y][x]].used))
{
- struct mon *mptr = monsters + mapmonster[y][x];
+ struct mon *mptr = monsters + lvl.mons[y][x];
switch (objects[obj].obj_id)
{
case PO_FLASK_WEAKNESS:
{
back_buffer[y][x] = &player_tile;
}
- else if ((!show_terrain) && (mapmonster[y][x] != -1) && mon_visible(mapmonster[y][x]))
+ else if ((!show_terrain) && (lvl.mons[y][x] != -1) && mon_visible(lvl.mons[y][x]))
{
- back_buffer[y][x] = monster_char(monsters[mapmonster[y][x]].mon_id);
+ back_buffer[y][x] = monster_char(monsters[lvl.mons[y][x]].mon_id);
}
- else if (mapflags[y][x] & MAPFLAG_EXPLORED)
+ else if (lvl.flags[y][x] & MAPFLAG_EXPLORED)
{
- if ((!show_terrain) && (mapobject[y][x] != -1))
+ if ((!show_terrain) && (lvl.objs[y][x] != -1))
{
- back_buffer[y][x] = object_char(objects[mapobject[y][x]].obj_id);
+ back_buffer[y][x] = object_char(objects[lvl.objs[y][x]].obj_id);
}
else
{
- back_buffer[y][x] = terrain_char(terrain[y][x]);
+ back_buffer[y][x] = terrain_char(lvl.terrain[y][x]);
}
}
else
*/
static bool dflt_blk(int y, int x)
{
- return ((y <= 0) || (x <= 0) || (y >= DUN_HEIGHT - 1) || (x >= DUN_WIDTH - 1) || (terrain_is_opaque(terrain[y][x])));
+ return ((y <= 0) || (x <= 0) || (y >= DUN_HEIGHT - 1) || (x >= DUN_WIDTH - 1) || (terrain_is_opaque(lvl.terrain[y][x])));
}
/*! \brief Function for marking affected cells as explored
*/
static bool mark_explored(int y, int x, void *pvt)
{
- mapflags[y][x] |= MAPFLAG_EXPLORED;
+ lvl.flags[y][x] |= MAPFLAG_EXPLORED;
newsym(y, x);
return true;
}
{
if (monsters[i].used)
{
- mapmonster[monsters[i].y][monsters[i].x] = i;
+ lvl.mons[monsters[i].y][monsters[i].x] = i;
}
}
}
{
if (objects[i].used && !objects[i].with_you)
{
- mapobject[objects[i].y][objects[i].x] = i;
+ lvl.objs[objects[i].y][objects[i].x] = i;
}
}
}
/* Write out the map flags; if we decide to have at-generation
* flags as well as at-exploration flags, the at-generation flags
* will be stored in a separate array. */
- fwrite(mapflags, DUN_HEIGHT, DUN_WIDTH * sizeof (int), fp);
+ fwrite(lvl.flags, 1, sizeof lvl.flags, fp);
/* Write out the permanent object data. This is hideously
* wasteful (and guarantees savefile breakage at version-up), but
* it makes handling flavours much easier... */
- fwrite(permobjs, 100, sizeof (struct permobj), fp);
+ fwrite(permobjs, NUM_OF_PERMOBJS, sizeof (struct permobj), fp);
/* Write out the dynamic monster/object arrays. */
- fwrite(monsters, 100, sizeof (struct mon), fp);
- fwrite(objects, 100, sizeof (struct obj), fp);
+ fwrite(monsters, MONSTERS_IN_PLAY, sizeof (struct mon), fp);
+ fwrite(objects, OBJECTS_IN_PLAY, sizeof (struct obj), fp);
/* Write out the depth */
fwrite(&depth, 1, sizeof depth, fp);
/* Write out the player. */
fp = fopen("victrix-abyssi.sav", "rb");
fread(rng_state, sizeof rng_state, 1, fp);
build_level();
- fread(mapflags, DUN_HEIGHT, DUN_WIDTH * sizeof (int), fp);
- fread(permobjs, 100, sizeof (struct permobj), fp);
- fread(monsters, 100, sizeof (struct mon), fp);
- fread(objects, 100, sizeof (struct obj), 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);
rebuild_mapobjs();
rebuild_mapmons();
fread(&depth, 1, sizeof depth, fp);
fread(&u, 1, sizeof u, fp);
fread(&game_tick, 1, sizeof game_tick, fp);
fclose(fp);
- unlink("victrix-abyssi.sav");
explore_around(u.y, u.x);
status_updated = 1;
map_updated = 1;
hard_redraw = 1;
print_msg("Game loaded.\n");
+ unlink("victrix-abyssi.sav");
}
int exclusive_flat(int lower, int upper)
return 0;
case GET_ITEM:
- if (mapobject[u.y][u.x] != -1)
+ if (lvl.objs[u.y][u.x] != -1)
{
attempt_pickup();
return 1;
if (u.armour != -1)
{
if ((u.resistances[DT_FIRE] == RESIST_ARMOUR) &&
- (terrain[u.y][u.x] == LAVA))
+ (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;
return 0;
case GO_DOWN_STAIRS:
- if (terrain[u.y][u.x] == STAIRS)
+ if (lvl.terrain[u.y][u.x] == STAIRS)
{
leave_level();
make_new_level();
print_msg("You have no ring to remove!\n");
return 0;
}
- else if ((terrain[u.y][u.x] == LAVA) && (u.resistances[DT_FIRE] == RESIST_RING))
+ else if ((lvl.terrain[u.y][u.x] == LAVA) && (u.resistances[DT_FIRE] == RESIST_RING))
{
print_msg("That ring is your only current source of fire resistance. Removing\nit here would incinerate you.\n");
return 0;
}
- else if ((objects[u.ring].obj_id == PO_RING_FROST) && (terrain[u.y][u.x] == WATER))
+ else if ((objects[u.ring].obj_id == PO_RING_FROST) && (lvl.terrain[u.y][u.x] == WATER))
{
print_msg("Since nobody ever taught you to swim, removing that ring\nhere would result in your death by drowning.\n");
return 0;
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 (mapobject[u.y][u.x] != -1)
+ if (lvl.objs[u.y][u.x] != -1)
{
print_msg("There is already an item here.\n");
return 0;
struct stat s;
int i;
display_init();
- memset(mapobject, -1, sizeof mapobject);
- memset(mapmonster, -1, sizeof mapmonster);
+ memset(lvl.objs, -1, sizeof lvl.objs);
+ memset(lvl.mons, -1, sizeof lvl.mons);
/* Do we have a saved game? */
i = stat("victrix-abyssi.sav.gz", &s);
if (!i)
#include "fov.hh"
#include <string.h>
-int mapobject[DUN_HEIGHT][DUN_WIDTH];
-int mapmonster[DUN_HEIGHT][DUN_WIDTH];
-enum terrain_num terrain[DUN_HEIGHT][DUN_WIDTH];
-int mapflags[DUN_HEIGHT][DUN_WIDTH];
+level lvl;
int depth = 1;
-enum level_theme current_theme;
-enum level_layout current_layout;
static int get_levgen_mon_floor(int *y, int *x);
static void build_level_shrine(void);
void leave_level(void)
{
int i;
- memset(mapobject, -1, sizeof mapobject);
- memset(mapmonster, -1, sizeof mapmonster);
- memset(terrain, 0, sizeof terrain);
- memset(mapflags, 0, sizeof mapflags);
+ memset(lvl.objs, -1, sizeof lvl.objs);
+ memset(lvl.mons, -1, sizeof lvl.mons);
+ memset(lvl.terrain, 0, sizeof lvl.terrain);
+ memset(lvl.flags, 0, sizeof lvl.flags);
for (i = 0; i < 100; i++)
{
/* Throw away each monster */
theme_roll = zero_die(depth + 50);
if (!zero_die(4))
{
- current_layout = LAYOUT_CAVE_INTRUSIONS;
+ lvl.layout = LAYOUT_CAVE_INTRUSIONS;
}
else if ((depth >= 15) && !zero_die(6))
{
- current_layout = LAYOUT_CAVE_SHRINE;
+ lvl.layout = LAYOUT_CAVE_SHRINE;
}
else
{
- current_layout = LAYOUT_CLASSIC_CAVE;
+ lvl.layout = LAYOUT_CLASSIC_CAVE;
}
if ((theme_roll < 50) || (depth < 10))
{
- current_theme = THEME_NORMAL; /* no restrictions */
+ lvl.theme = THEME_NORMAL; /* no restrictions */
}
else if (theme_roll < 60)
{
- current_theme = THEME_UNDEAD;
+ lvl.theme = THEME_UNDEAD;
}
else if (theme_roll < 80)
{
- current_theme = THEME_DRAGONS;
+ lvl.theme = THEME_DRAGONS;
}
else if (theme_roll < 90)
{
- current_theme = THEME_DEMONS;
+ lvl.theme = THEME_DEMONS;
}
- switch (current_layout)
+ switch (lvl.layout)
{
case LAYOUT_CAVE_SHRINE:
build_level_shrine();
run_random_walk(y, x, excavation_write, walk_data, LEVGEN_WALK_CELLS);
run_random_walk(y, x, excavation_write, walk_data, LEVGEN_WALK_CELLS);
- if ((current_theme != THEME_UNDEAD) && (depth > 20) && !zero_die(4))
+ if ((lvl.theme != THEME_UNDEAD) && (depth > 20) && !zero_die(4))
{
num_pools = inclusive_flat(1, 4);
walk_data[0] = 2;
do {
y = exclusive_flat(1, DUN_HEIGHT - 2);
x = exclusive_flat(1, DUN_WIDTH - 2);
- } while (terrain[y][x] != FLOOR);
+ } while (lvl.terrain[y][x] != FLOOR);
run_random_walk(y, x, excavation_write, walk_data, pool_size);
--num_pools;
}
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- } while (terrain[y][x] != FLOOR);
- terrain[y][x] = STAIRS;
+ } while (lvl.terrain[y][x] != FLOOR);
+ lvl.terrain[y][x] = STAIRS;
}
struct shrine shrines[4] =
switch (shrines[shrine_num].grid[i][j])
{
case '.':
- terrain[y][x] = FLOOR;
+ lvl.terrain[y][x] = FLOOR;
break;
case '#':
- terrain[y][x] = HARDWALL;
+ lvl.terrain[y][x] = HARDWALL;
break;
case '+':
- terrain[y][x] = DOOR;
+ lvl.terrain[y][x] = DOOR;
break;
case '_':
- terrain[y][x] = ALTAR;
+ lvl.terrain[y][x] = ALTAR;
break;
}
}
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- } while ((terrain[y][x] != FLOOR) &&
+ } while ((lvl.terrain[y][x] != FLOOR) &&
(y >= shrine_ty) && (y < shrine_ty + SHRINE_HEIGHT) &&
(x >= shrine_lx) && (x < shrine_lx + SHRINE_WIDTH));
- terrain[y][x] = STAIRS;
+ lvl.terrain[y][x] = STAIRS;
}
static int excavation_write(int y, int x, void *data)
const int *overwrite = data_as_ints + 2;
int newterr = data_as_ints[1];
int j;
- if (mapflags[y][x] & MAPFLAG_HARDWALL)
+ if (lvl.flags[y][x] & MAPFLAG_HARDWALL)
{
/* Don't bite into hardened walls, but don't waste a step on
* them either. */
}
for (j = 0; j < data_as_ints[0]; ++j)
{
- if (terrain[y][x] == overwrite[j])
+ if (lvl.terrain[y][x] == overwrite[j])
{
- terrain[y][x] = (terrain_num) newterr;
+ lvl.terrain[y][x] = (terrain_num) newterr;
return 1;
}
}
static int intrusion_write(int y, int x, void *data)
{
- if (terrain[y][x] != WALL)
+ if (lvl.terrain[y][x] != WALL)
{
return 0;
}
- if (mapflags[y][x] & MAPFLAG_HARDWALL)
+ if (lvl.flags[y][x] & MAPFLAG_HARDWALL)
{
return 0;
}
{
return 2;
}
- mapflags[y][x] |= MAPFLAG_HARDWALL;
- terrain[y][x] = HARDWALL;
+ lvl.flags[y][x] |= MAPFLAG_HARDWALL;
+ lvl.terrain[y][x] = HARDWALL;
return 1;
}
y = inclusive_flat((2 * DUN_HEIGHT) / 3, DUN_HEIGHT - 2);
}
//print_msg("Trying y %d x %d for intrusion\n", y, x);
- } while (mapflags[y][x] & MAPFLAG_HARDWALL);
+ } while (lvl.flags[y][x] & MAPFLAG_HARDWALL);
intrusion_size = inclusive_flat(27, 54);
//print_msg("Building intrusion %d size %d y %d x %d\n", i, intrusion_size, y, x);
run_random_walk(y, x, intrusion_write, NULL, intrusion_size);
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- } while (terrain[y][x] != FLOOR);
- terrain[y][x] = STAIRS;
+ } while (lvl.terrain[y][x] != FLOOR);
+ lvl.terrain[y][x] = STAIRS;
}
int get_levgen_mon_floor(int *y, int *x)
{
ty = exclusive_flat(0, DUN_HEIGHT - 1);
tx = exclusive_flat(0, DUN_WIDTH - 1);
- if ((terrain[ty][tx] != FLOOR) ||
- (mapmonster[ty][tx] != -1))
+ if ((lvl.terrain[ty][tx] != FLOOR) ||
+ (lvl.mons[ty][tx] != -1))
{
ty = -1;
tx = -1;
{
u.y = exclusive_flat(0, DUN_HEIGHT - 1);
u.x = exclusive_flat(0, DUN_WIDTH - 1);
- if (terrain[u.y][u.x] != FLOOR)
+ if (lvl.terrain[u.y][u.x] != FLOOR)
{
continue;
}
- if (mapmonster[u.y][u.x] != -1)
+ if (lvl.mons[u.y][u.x] != -1)
{
continue;
}
};
/* XXX map.c data and funcs*/
-extern int mapobject[DUN_HEIGHT][DUN_WIDTH];
-extern int mapmonster[DUN_HEIGHT][DUN_WIDTH];
-extern enum terrain_num terrain[DUN_HEIGHT][DUN_WIDTH];
-extern int mapflags[DUN_HEIGHT][DUN_WIDTH];
+struct level
+{
+ int objs[DUN_HEIGHT][DUN_WIDTH];
+ int mons[DUN_HEIGHT][DUN_WIDTH];
+ terrain_num terrain[DUN_HEIGHT][DUN_WIDTH];
+ uint32_t flags[DUN_HEIGHT][DUN_WIDTH];
+ level_theme theme;
+ level_layout layout;
+};
+
+extern level lvl;
+
extern int depth;
extern enum level_theme current_theme;
extern enum level_layout current_layout;
* Square closer to player: +1
* Square further from player: -1
*/
- if (!mon_can_pass(mapmonster[y][x], ai_cells[i].y, ai_cells[i].x))
+ if (!mon_can_pass(lvl.mons[y][x], ai_cells[i].y, ai_cells[i].x))
{
/* Square impassable to this monster. Set score WAY
* out of bounds and continue. */
* closing. When I add more AI state to the monster structure,
* this will change.
*/
- if (!mon_can_pass(mapmonster[y][x], ai_cells[i].y, ai_cells[i].x))
+ if (!mon_can_pass(lvl.mons[y][x], ai_cells[i].y, ai_cells[i].x))
{
/* Square impassable. Set score WAY out of bounds
* and continue. */
case 0:
/* Simple convergence */
get_naive_prefs(*py, *px, dy, dx, ai_y, ai_x);
- if (mon_can_pass(mapmonster[*py][*px], ai_y[0], ai_x[0]))
+ if (mon_can_pass(lvl.mons[*py][*px], ai_y[0], ai_x[0]))
{
y = ai_y[0];
x = ai_x[0];
}
- else if (mon_can_pass(mapmonster[*py][*px], ai_y[1], ai_x[1]))
+ else if (mon_can_pass(lvl.mons[*py][*px], ai_y[1], ai_x[1]))
{
y = ai_y[1];
x = ai_x[1];
}
- else if (mon_can_pass(mapmonster[*py][*px], ai_y[2], ai_x[2]))
+ else if (mon_can_pass(lvl.mons[*py][*px], ai_y[2], ai_x[2]))
{
y = ai_y[2];
x = ai_x[2];
/* On cardinal. Stay there if we can. But close anyway. */
x = *px + sx;
y = *py + sy;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
x = *px;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
y = *py;
x = *px + sx;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
* off cardinal in y than in x */
y = *py + sy;
x = *px;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
x = *px + sx;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
y = *py;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
/* One step off a diagonal cardinal, with adx > ady */
x = *px + sx;
y = *py;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
y = *py + sy;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
x = *px;
- if (mon_can_pass(mapmonster[*py][*px], y, x))
+ if (mon_can_pass(lvl.mons[*py][*px], y, x))
{
break;
}
/* "Drunk" monster i.e. monster moving while it doesn't know
* how to find you. */
get_drunk_prefs(*py, *px, dy, dx, ai_y, ai_x);
- if (mon_can_pass(mapmonster[*py][*px], ai_y[0], ai_x[0]))
+ if (mon_can_pass(lvl.mons[*py][*px], ai_y[0], ai_x[0]))
{
y = ai_y[0];
x = ai_x[0];
}
- else if (mon_can_pass(mapmonster[*py][*px], ai_y[1], ai_x[1]))
+ else if (mon_can_pass(lvl.mons[*py][*px], ai_y[1], ai_x[1]))
{
y = ai_y[1];
x = ai_x[1];
}
- else if (mon_can_pass(mapmonster[*py][*px], ai_y[2], ai_x[2]))
+ else if (mon_can_pass(lvl.mons[*py][*px], ai_y[2], ai_x[2]))
{
y = ai_y[2];
x = ai_x[2];
break;
case 5:
/* "chase" AI i.e. pursue your last known position. */
- get_chase_prefs(mapmonster[*py][*px], ai_y, ai_x);
+ get_chase_prefs(lvl.mons[*py][*px], ai_y, ai_x);
y = ai_y[0];
x = ai_x[0];
break;
print_msg("Program disordered: monster in player's square.\n");
print_msg("Discarding misplaced monster.\n");
mptr->used = 0;
- mapmonster[y][x] = -1;
+ lvl.mons[y][x] = -1;
return;
}
- if (mapmonster[y][x] != mon)
+ if (lvl.mons[y][x] != mon)
{
print_msg("Program disordered: monster(s) misplaced.\n");
mptr->used = 0;
- if (mapmonster[y][x] != -1)
+ if (lvl.mons[y][x] != -1)
{
- monsters[mapmonster[y][x]].used = 0;
- mapmonster[y][x] = -1;
+ monsters[lvl.mons[y][x]].used = 0;
+ lvl.mons[y][x] = -1;
}
return;
}
{
dy = zero_die(3) - 1;
dx = zero_die(3) - 1;
- if ((terrain[y + dy][x + dx] == FLOOR) &&
- (mapmonster[y + dy][x + dx] == -1) &&
+ if ((lvl.terrain[y + dy][x + dx] == FLOOR) &&
+ (lvl.mons[y + dy][x + dx] == -1) &&
((y + dy != u.y) || (x + dx != u.x)))
{
pmon = get_random_pmon();
int create_mon(int pm_idx, int y, int x)
{
int mon;
- if (mapmonster[y][x] != -1)
+ if (lvl.mons[y][x] != -1)
{
print_msg("Attempt to create monster at occupied space %d %d\n", y, x);
return -1;
monsters[mon].rdam = -1;
}
monsters[mon].awake = 0;
- mapmonster[y][x] = mon;
+ lvl.mons[y][x] = mon;
newsym(y, x);
return mon;
}
int x = monsters[mon].x;
int dy, dx;
int tryct;
- while (((mapobject[y][x] != -1) || (terrain[y][x] != FLOOR)) && tryct < 100)
+ while (((lvl.objs[y][x] != -1) || (lvl.terrain[y][x] != FLOOR)) && tryct < 100)
{
dy = zero_die(3) - 1;
dx = zero_die(3) - 1;
{
return 0;
}
- if (mapmonster[y][x] != -1)
+ if (lvl.mons[y][x] != -1)
{
return 0;
}
{
return 1;
}
- terr = terrain[y][x];
+ terr = lvl.terrain[y][x];
switch (terr)
{
case WALL:
default:
break;
}
- if ((terrain[y][x] == WATER) && !mon_resists_drowning(mon))
+ if ((lvl.terrain[y][x] == WATER) && !mon_resists_drowning(mon))
{
return 0;
}
print_msg(" dies.\n");
}
death_drop(mon);
- mapmonster[mptr->y][mptr->x] = -1;
+ lvl.mons[mptr->y][mptr->x] = -1;
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 ((mapmonster[y][x] == -1) && (terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
+ if ((lvl.mons[y][x] == -1) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
{
reloc_mon(mon, y, x);
rval = 0;
struct mon *mptr = monsters + mon;
int y = mptr->y + sy;
int x = mptr->x + sx;
- enum terrain_num terr = terrain[y][x];
+ enum terrain_num terr = lvl.terrain[y][x];
if (mon_resists_knockback(mon))
{
void reloc_mon(int mon, int y, int x)
{
struct mon *mptr = monsters + mon;
- mapmonster[mptr->y][mptr->x] = -1;
+ lvl.mons[mptr->y][mptr->x] = -1;
newsym(mptr->y, mptr->x);
mptr->y = y;
mptr->x = x;
- mapmonster[mptr->y][mptr->x] = mon;
+ lvl.mons[mptr->y][mptr->x] = mon;
newsym(mptr->y, mptr->x);
}
return;
}
mptr = monsters + mon;
- if (mapmonster[mptr->y][mptr->x] != mon)
+ if (lvl.mons[mptr->y][mptr->x] != mon)
{
print_msg("Monster map array in disorder.\n");
press_enter();
int i;
y2 = y - 1 + zero_die(3);
x2 = x - 1 + zero_die(3);
- if ((terrain[y2][x2] == FLOOR) && (mapmonster[y2][x2] == -1) &&
+ if ((lvl.terrain[y2][x2] == FLOOR) && (lvl.mons[y2][x2] == -1) &&
((y2 != u.y) || (x2 != u.x)))
{
i = create_mon(PM_DEMON, y2, x2);
}
if (!objects[i].with_you)
{
- mapobject[y][x] = i;
+ lvl.objs[y][x] = i;
}
return i;
}
{
struct obj *optr;
optr = objects + u.inventory[inv_idx];
- if (mapobject[u.y][u.x] == -1)
+ if (lvl.objs[u.y][u.x] == -1)
{
optr->y = u.y;
optr->x = u.x;
- mapobject[u.y][u.x] = u.inventory[inv_idx];
+ lvl.objs[u.y][u.x] = u.inventory[inv_idx];
if (u.weapon == u.inventory[inv_idx])
{
u.weapon = -1;
u.inventory[inv_idx] = -1;
optr->with_you = 0;
print_msg("You drop ");
- print_obj_name(mapobject[u.y][u.x]);
+ print_obj_name(lvl.objs[u.y][u.x]);
print_msg(".\n");
return 0;
}
{
int i;
int stackable;
- stackable = po_is_stackable(objects[mapobject[u.y][u.x]].obj_id);
+ stackable = po_is_stackable(objects[lvl.objs[u.y][u.x]].obj_id);
if (stackable)
{
for (i = 0; i < 19; i++)
{
- if ((objects[u.inventory[i]].obj_id == objects[mapobject[u.y][u.x]].obj_id))
+ if ((objects[u.inventory[i]].obj_id == objects[lvl.objs[u.y][u.x]].obj_id))
{
print_msg("You get ");
- print_obj_name(mapobject[u.y][u.x]);
+ print_obj_name(lvl.objs[u.y][u.x]);
print_msg(".\nYou now have\n");
- objects[u.inventory[i]].quan += objects[mapobject[u.y][u.x]].quan;
- objects[mapobject[u.y][u.x]].used = 0;
- mapobject[u.y][u.x] = -1;
+ 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;
print_msg("%c) ", 'a' + i);
print_obj_name(u.inventory[i]);
print_msg("\n");
print_msg("Your pack is full.\n");
return;
}
- u.inventory[i] = mapobject[u.y][u.x];
- mapobject[u.y][u.x] = -1;
+ u.inventory[i] = lvl.objs[u.y][u.x];
+ lvl.objs[u.y][u.x] = -1;
objects[u.inventory[i]].with_you = 1;
objects[u.inventory[i]].x = -1;
objects[u.inventory[i]].y = -1;
{
continue;
}
- if (mapmonster[y][x] != -1)
+ if (lvl.mons[y][x] != -1)
{
- struct mon *mptr = monsters + mapmonster[y][x];
+ struct mon *mptr = monsters + lvl.mons[y][x];
if (!pmon_resists_fire(mptr->mon_id))
{
- print_mon_name(mapmonster[y][x], 3);
+ print_mon_name(lvl.mons[y][x], 3);
print_msg(" is engulfed in roaring flames.\n");
- damage_mon(mapmonster[y][x], dice(4, 10), 1);
+ damage_mon(lvl.mons[y][x], dice(4, 10), 1);
}
}
}
print_msg("Attempted move out of bounds.\n");
return 0; /* No movement. */
}
- if (mapmonster[u.y + dy][u.x + dx] != -1)
+ if (lvl.mons[u.y + dy][u.x + dx] != -1)
{
if (u.weapon != -1)
{
}
return player_attack(dy, dx);
}
- switch (terrain[u.y + dy][u.x + dx])
+ switch (lvl.terrain[u.y + dy][u.x + dx])
{
case WALL:
case HARDWALL:
case LAVA:
if (u.resistances[DT_FIRE])
{
- if (terrain[u.y][u.x] != LAVA)
+ if (lvl.terrain[u.y][u.x] != LAVA)
{
print_msg("You walk on the lava.\n");
}
case WATER:
if ((u.ring != -1) && (objects[u.ring].obj_id == PO_RING_FROST))
{
- if (terrain[u.y][u.x] != WATER)
+ if (lvl.terrain[u.y][u.x] != WATER)
{
print_msg("You walk on the water.\n");
}
map_updated = 1;
status_updated = 1;
display_update();
- if (mapobject[y][x] != -1)
+ if (lvl.objs[y][x] != -1)
{
print_msg("You see here ");
- print_obj_name(mapobject[y][x]);
+ print_obj_name(lvl.objs[y][x]);
print_msg(".\n");
}
return 0;
{
y = exclusive_flat(0, DUN_HEIGHT - 1);
x = exclusive_flat(0, DUN_WIDTH - 1);
- if ((mapmonster[y][x] == -1) && (terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
+ if ((lvl.mons[y][x] == -1) && (lvl.terrain[y][x] == FLOOR) && ((y != u.y) || (x != u.x)))
{
print_msg("You are whisked away!\n");
reloc_player(y, x);