Rework stairs structure

Use a linked list to store stair and ladder information, instead
of having fixed up/down stairs/ladders and a single "special" (branch)
stair.

Breaks saves and bones.

Adds information to migrating objects and monsters for the dungeon
and level where they are migrating from.
This commit is contained in:
Pasi Kallinen
2020-11-09 18:50:02 +02:00
parent e23f764d11
commit 6ec55a3624
34 changed files with 552 additions and 361 deletions

View File

@@ -75,16 +75,6 @@ struct dgn_topology { /* special dungeon levels for speed */
#define sokoend_level (g.dungeon_topology.d_sokoend_level)
/* clang-format on */
#define xdnstair (g.dnstair.sx)
#define ydnstair (g.dnstair.sy)
#define xupstair (g.upstair.sx)
#define yupstair (g.upstair.sy)
#define xdnladder (g.dnladder.sx)
#define ydnladder (g.dnladder.sy)
#define xupladder (g.upladder.sx)
#define yupladder (g.upladder.sy)
#define dunlev_reached(x) (g.dungeons[(x)->dnum].dunlev_ureached)
#include "quest.h"
@@ -726,10 +716,7 @@ struct instance_globals {
int y_maze_max;
int otg_temp; /* used by object_to_glyph() [otg] */
int in_doagain;
stairway dnstair; /* stairs down */
stairway upstair; /* stairs up */
stairway dnladder; /* ladder down */
stairway upladder; /* ladder up */
stairway *stairs;
int smeq[MAXNROFROOMS + 1];
int doorindex;
char *save_cm;
@@ -754,7 +741,6 @@ struct instance_globals {
number of shots, index of current one, validity check, shoot vs throw */
struct multishot m_shot;
dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */
stairway sstairs;
dest_area updest;
dest_area dndest;
coord inv_pos;
@@ -765,9 +751,6 @@ struct instance_globals {
boolean mrg_to_wielded; /* weapon picked is merged with wielded one */
struct plinemsg_type *plinemsg_types;
char toplines[TBUFSZ];
struct mkroom *upstairs_room;
struct mkroom *dnstairs_room;
struct mkroom *sstairs_room;
coord bhitpos; /* place where throw or zap hits or stops */
boolean in_steed_dismounting;
coord doors[DOORMAX];

View File

@@ -34,7 +34,9 @@ typedef struct s_level { /* special dungeon level element */
typedef struct stairway { /* basic stairway identifier */
xchar sx, sy; /* x / y location of the stair */
d_level tolev; /* where does it go */
char up; /* what type of stairway (up/down) */
boolean up; /* up or down? */
boolean isladder; /* ladder or stairway? */
struct stairway *next;
} stairway;
/* level region types */

View File

@@ -630,6 +630,15 @@ E void FDECL(next_level, (BOOLEAN_P));
E void FDECL(prev_level, (BOOLEAN_P));
E void FDECL(u_on_newpos, (int, int));
E void FDECL(u_on_rndspot, (int));
E void FDECL(stairway_add, (int,int, BOOLEAN_P, BOOLEAN_P, d_level *));
E void NDECL(stairway_print);
E void NDECL(stairway_free_all);
E stairway *FDECL(stairway_at, (int, int));
E stairway *FDECL(stairway_find, (d_level *));
E stairway *FDECL(stairway_find_from, (d_level *, BOOLEAN_P));
E stairway *FDECL(stairway_find_dir, (BOOLEAN_P));
E stairway *FDECL(stairway_find_type_dir, (BOOLEAN_P, BOOLEAN_P));
E stairway *FDECL(stairway_find_special_dir, (BOOLEAN_P));
E void FDECL(u_on_sstairs, (int));
E void NDECL(u_on_upstairs);
E void NDECL(u_on_dnstairs);

View File

@@ -82,6 +82,7 @@ struct monst {
xchar mx, my;
xchar mux, muy; /* where the monster thinks you are */
#define MTSZ 4
/* mtrack[0..2] is used to keep extra data when migrating the monster */
coord mtrack[MTSZ]; /* monster track */
int mhp, mhpmax;
unsigned mappearance; /* for undetected mimics and the wiz */

View File

@@ -122,6 +122,8 @@ struct obj {
long age; /* creation date */
long owornmask;
unsigned lua_ref_cnt; /* # of lua script references for this object */
xchar omigr_from_dnum; /* where obj is migrating from */
xchar omigr_from_dlevel; /* where obj is migrating from */
struct oextra *oextra; /* pointer to oextra struct */
};

View File

@@ -17,7 +17,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 24
#define EDITLEVEL 25
/*
* Development status possibilities.

View File

@@ -243,6 +243,8 @@ enum screen_symbols {
#define is_cmap_furniture(i) ((i) >= S_upstair && (i) <= S_fountain)
#define is_cmap_water(i) ((i) == S_pool || (i) == S_water)
#define is_cmap_lava(i) ((i) == S_lava)
#define is_cmap_stairs(i) ((i) == S_upstair || (i) == S_dnstair || \
(i) == S_upladder || (i) == S_dnladder)
struct symdef {