Use enums instead of magic values
This commit is contained in:
@@ -420,7 +420,7 @@ E void NDECL(save_currentstate);
|
|||||||
E void FDECL(u_collide_m, (struct monst *));
|
E void FDECL(u_collide_m, (struct monst *));
|
||||||
E void FDECL(goto_level, (d_level *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P));
|
E void FDECL(goto_level, (d_level *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P));
|
||||||
E void NDECL(maybe_lvltport_feedback);
|
E void NDECL(maybe_lvltport_feedback);
|
||||||
E void FDECL(schedule_goto, (d_level *, BOOLEAN_P, BOOLEAN_P, int,
|
E void FDECL(schedule_goto, (d_level *, int,
|
||||||
const char *, const char *));
|
const char *, const char *));
|
||||||
E void NDECL(deferred_goto);
|
E void NDECL(deferred_goto);
|
||||||
E boolean FDECL(revive_corpse, (struct obj *));
|
E boolean FDECL(revive_corpse, (struct obj *));
|
||||||
|
|||||||
@@ -334,6 +334,15 @@ enum utraptypes {
|
|||||||
TT_BURIEDBALL = 5
|
TT_BURIEDBALL = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum utotypes {
|
||||||
|
UTOTYPE_NONE = 0x00,
|
||||||
|
UTOTYPE_ATSTAIRS = 0x01,
|
||||||
|
UTOTYPE_FALLING = 0x02,
|
||||||
|
UTOTYPE_PORTAL = 0x04,
|
||||||
|
UTOTYPE_RMPORTAL = 0x10, /* remove portal */
|
||||||
|
UTOTYPE_DEFERRED = 0x20, /* deferred_goto */
|
||||||
|
};
|
||||||
|
|
||||||
/*** Information about the player ***/
|
/*** Information about the player ***/
|
||||||
struct you {
|
struct you {
|
||||||
xchar ux, uy; /* current map coordinates */
|
xchar ux, uy; /* current map coordinates */
|
||||||
|
|||||||
29
src/do.c
29
src/do.c
@@ -1446,7 +1446,7 @@ boolean at_stairs, falling, portal;
|
|||||||
assign_level(&u.uz0, &u.uz);
|
assign_level(&u.uz0, &u.uz);
|
||||||
assign_level(&u.uz, newlevel);
|
assign_level(&u.uz, newlevel);
|
||||||
assign_level(&u.utolev, newlevel);
|
assign_level(&u.utolev, newlevel);
|
||||||
u.utotype = 0;
|
u.utotype = UTOTYPE_NONE;
|
||||||
if (!builds_up(&u.uz)) { /* usual case */
|
if (!builds_up(&u.uz)) { /* usual case */
|
||||||
if (dunlev(&u.uz) > dunlev_reached(&u.uz))
|
if (dunlev(&u.uz) > dunlev_reached(&u.uz))
|
||||||
dunlev_reached(&u.uz) = dunlev(&u.uz);
|
dunlev_reached(&u.uz) = dunlev(&u.uz);
|
||||||
@@ -1784,24 +1784,13 @@ final_level()
|
|||||||
|
|
||||||
/* change levels at the end of this turn, after monsters finish moving */
|
/* change levels at the end of this turn, after monsters finish moving */
|
||||||
void
|
void
|
||||||
schedule_goto(tolev, at_stairs, falling, portal_flag, pre_msg, post_msg)
|
schedule_goto(tolev, utotype_flags, pre_msg, post_msg)
|
||||||
d_level *tolev;
|
d_level *tolev;
|
||||||
boolean at_stairs, falling;
|
int utotype_flags;
|
||||||
int portal_flag;
|
|
||||||
const char *pre_msg, *post_msg;
|
const char *pre_msg, *post_msg;
|
||||||
{
|
{
|
||||||
int typmask = 0100; /* non-zero triggers `deferred_goto' */
|
/* UTOTYPE_DEFERRED is used, so UTOTYPE_NONE can trigger deferred_goto() */
|
||||||
|
u.utotype = utotype_flags | UTOTYPE_DEFERRED;
|
||||||
/* destination flags (`goto_level' args) */
|
|
||||||
if (at_stairs)
|
|
||||||
typmask |= 1;
|
|
||||||
if (falling)
|
|
||||||
typmask |= 2;
|
|
||||||
if (portal_flag)
|
|
||||||
typmask |= 4;
|
|
||||||
if (portal_flag < 0)
|
|
||||||
typmask |= 0200; /* flag for portal removal */
|
|
||||||
u.utotype = typmask;
|
|
||||||
/* destination level */
|
/* destination level */
|
||||||
assign_level(&u.utolev, tolev);
|
assign_level(&u.utolev, tolev);
|
||||||
|
|
||||||
@@ -1823,8 +1812,10 @@ deferred_goto()
|
|||||||
assign_level(&oldlev, &u.uz);
|
assign_level(&oldlev, &u.uz);
|
||||||
if (g.dfr_pre_msg)
|
if (g.dfr_pre_msg)
|
||||||
pline1(g.dfr_pre_msg);
|
pline1(g.dfr_pre_msg);
|
||||||
goto_level(&dest, !!(typmask & 1), !!(typmask & 2), !!(typmask & 4));
|
goto_level(&dest, !!(typmask & UTOTYPE_ATSTAIRS),
|
||||||
if (typmask & 0200) { /* remove portal */
|
!!(typmask & UTOTYPE_FALLING),
|
||||||
|
!!(typmask & UTOTYPE_PORTAL));
|
||||||
|
if (typmask & UTOTYPE_RMPORTAL) { /* remove portal */
|
||||||
struct trap *t = t_at(u.ux, u.uy);
|
struct trap *t = t_at(u.ux, u.uy);
|
||||||
|
|
||||||
if (t) {
|
if (t) {
|
||||||
@@ -1835,7 +1826,7 @@ deferred_goto()
|
|||||||
if (g.dfr_post_msg && !on_level(&u.uz, &oldlev))
|
if (g.dfr_post_msg && !on_level(&u.uz, &oldlev))
|
||||||
pline1(g.dfr_post_msg);
|
pline1(g.dfr_post_msg);
|
||||||
}
|
}
|
||||||
u.utotype = 0; /* our caller keys off of this */
|
u.utotype = UTOTYPE_NONE; /* our caller keys off of this */
|
||||||
if (g.dfr_pre_msg)
|
if (g.dfr_pre_msg)
|
||||||
free((genericptr_t) g.dfr_pre_msg), g.dfr_pre_msg = 0;
|
free((genericptr_t) g.dfr_pre_msg), g.dfr_pre_msg = 0;
|
||||||
if (g.dfr_post_msg)
|
if (g.dfr_post_msg)
|
||||||
|
|||||||
@@ -182,13 +182,13 @@ boolean seal;
|
|||||||
branch *br;
|
branch *br;
|
||||||
d_level *dest;
|
d_level *dest;
|
||||||
struct trap *t;
|
struct trap *t;
|
||||||
int portal_flag;
|
int portal_flag = u.uevent.qexpelled ? UTOTYPE_NONE : UTOTYPE_PORTAL;
|
||||||
|
|
||||||
br = dungeon_branch("The Quest");
|
br = dungeon_branch("The Quest");
|
||||||
dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1;
|
dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1;
|
||||||
portal_flag = u.uevent.qexpelled ? 0 /* returned via artifact? */
|
if (seal)
|
||||||
: !seal ? 1 : -1;
|
portal_flag |= UTOTYPE_RMPORTAL;
|
||||||
schedule_goto(dest, FALSE, FALSE, portal_flag, (char *) 0, (char *) 0);
|
schedule_goto(dest, portal_flag, (char *) 0, (char *) 0);
|
||||||
if (seal) { /* remove the portal to the quest - sealing it off */
|
if (seal) { /* remove the portal to the quest - sealing it off */
|
||||||
int reexpelled = u.uevent.qexpelled;
|
int reexpelled = u.uevent.qexpelled;
|
||||||
|
|
||||||
|
|||||||
@@ -941,7 +941,7 @@ level_tele()
|
|||||||
}
|
}
|
||||||
newlevel.dnum = u.uz.dnum;
|
newlevel.dnum = u.uz.dnum;
|
||||||
newlevel.dlevel = llimit + newlev;
|
newlevel.dlevel = llimit + newlev;
|
||||||
schedule_goto(&newlevel, FALSE, FALSE, 0, (char *) 0, (char *) 0);
|
schedule_goto(&newlevel, UTOTYPE_NONE, (char *) 0, (char *) 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1049,7 +1049,7 @@ level_tele()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule_goto(&newlevel, FALSE, FALSE, 0, (char *) 0,
|
schedule_goto(&newlevel, UTOTYPE_NONE, (char *) 0,
|
||||||
flags.verbose ? "You materialize on a different level!"
|
flags.verbose ? "You materialize on a different level!"
|
||||||
: (char *) 0);
|
: (char *) 0);
|
||||||
|
|
||||||
@@ -1090,7 +1090,7 @@ register struct trap *ttmp;
|
|||||||
}
|
}
|
||||||
|
|
||||||
target_level = ttmp->dst;
|
target_level = ttmp->dst;
|
||||||
schedule_goto(&target_level, FALSE, FALSE, 1,
|
schedule_goto(&target_level, UTOTYPE_PORTAL,
|
||||||
"You feel dizzy for a moment, but the sensation passes.",
|
"You feel dizzy for a moment, but the sensation passes.",
|
||||||
(char *) 0);
|
(char *) 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ unsigned ftflags;
|
|||||||
Sprintf(msgbuf, "The hole in the %s above you closes up.",
|
Sprintf(msgbuf, "The hole in the %s above you closes up.",
|
||||||
ceiling(u.ux, u.uy));
|
ceiling(u.ux, u.uy));
|
||||||
|
|
||||||
schedule_goto(&dtmp, FALSE, TRUE, 0, (char *) 0,
|
schedule_goto(&dtmp, UTOTYPE_FALLING, (char *) 0,
|
||||||
!td ? msgbuf : (char *) 0);
|
!td ? msgbuf : (char *) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ u_init()
|
|||||||
u.udg_cnt = 0;
|
u.udg_cnt = 0;
|
||||||
u.mh = u.mhmax = u.mtimedone = 0;
|
u.mh = u.mhmax = u.mtimedone = 0;
|
||||||
u.uz.dnum = u.uz0.dnum = 0;
|
u.uz.dnum = u.uz0.dnum = 0;
|
||||||
u.utotype = 0;
|
u.utotype = UTOTYPE_NONE;
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
u.uz.dlevel = 1;
|
u.uz.dlevel = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user