Reset map x/y start/size in single place

This commit is contained in:
Pasi Kallinen
2022-08-02 17:02:25 +03:00
parent 24e94b70d4
commit f4d0e99fad
3 changed files with 15 additions and 18 deletions

View File

@@ -2538,6 +2538,7 @@ extern void release_sound_mappings(void);
#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) #if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET)
extern void create_des_coder(void); extern void create_des_coder(void);
extern void reset_xystart_size(void);
extern struct mapfragment *mapfrag_fromstr(char *); extern struct mapfragment *mapfrag_fromstr(char *);
extern void mapfrag_free(struct mapfragment **); extern void mapfrag_free(struct mapfragment **);
extern schar mapfrag_get(struct mapfragment *, int, int); extern schar mapfrag_get(struct mapfragment *, int, int);

View File

@@ -733,10 +733,7 @@ clear_level_structures(void)
stairway_free_all(); stairway_free_all();
g.made_branch = FALSE; g.made_branch = FALSE;
clear_regions(); clear_regions();
g.xstart = 1; reset_xystart_size();
g.ystart = 0;
g.xsize = COLNO - 1;
g.ysize = ROWNO;
if (g.lev_message) { if (g.lev_message) {
free(g.lev_message); free(g.lev_message);
g.lev_message = (char *) 0; g.lev_message = (char *) 0;

View File

@@ -201,6 +201,15 @@ static struct monst *invent_carrying_monster = (struct monst *) 0;
#define TYP_CANNOT_MATCH(typ) ((typ) == MAX_TYPE || (typ) == INVALID_TYPE) #define TYP_CANNOT_MATCH(typ) ((typ) == MAX_TYPE || (typ) == INVALID_TYPE)
void
reset_xystart_size(void)
{
g.xstart = 1; /* column [0] is off limits */
g.ystart = 0;
g.xsize = COLNO - 1; /* 1..COLNO-1 */
g.ysize = ROWNO; /* 0..ROWNO-1 */
}
/* Does typ match with levl[][].typ, considering special types /* Does typ match with levl[][].typ, considering special types
MATCH_WALL and MAX_TYPE (aka transparency)? */ MATCH_WALL and MAX_TYPE (aka transparency)? */
static boolean static boolean
@@ -3923,12 +3932,8 @@ spo_endroom(struct sp_coder* coder UNUSED)
/* Need to ensure xstart/ystart/xsize/ysize have something sensible, /* Need to ensure xstart/ystart/xsize/ysize have something sensible,
in case there's some stuff to be created outside the outermost in case there's some stuff to be created outside the outermost
room, and there's no MAP. */ room, and there's no MAP. */
if (g.xsize <= 1 && g.ysize <= 1) { if (g.xsize <= 1 && g.ysize <= 1)
g.xstart = 1; reset_xystart_size();
g.ystart = 0;
g.xsize = COLNO - 1;
g.ysize = ROWNO;
}
} }
update_croom(); update_croom();
} }
@@ -6349,10 +6354,7 @@ TODO: g.coder->croom needs to be updated
g.ystart = 0; g.ystart = 0;
} }
if (g.xsize <= 1 && g.ysize <= 1) { if (g.xsize <= 1 && g.ysize <= 1) {
g.xstart = 1; reset_xystart_size();
g.ystart = 0;
g.xsize = COLNO - 1;
g.ysize = ROWNO;
} else { } else {
coordxy mptyp; coordxy mptyp;
@@ -6493,10 +6495,7 @@ sp_level_coder_init(void)
g.level.flags.is_maze_lev = 0; g.level.flags.is_maze_lev = 0;
g.xstart = 1; /* column [0] is off limits */ reset_xystart_size();
g.ystart = 0;
g.xsize = COLNO - 1; /* 1..COLNO-1 */
g.ysize = ROWNO; /* 0..ROWNO-1 */
return coder; return coder;
} }